akhauriyash/Code-Regression huggingface dataset:
#include<cctype>
#include<cstdio>
#include<cstring>
#include<algorithm>
using i64=long long;
const int V=327,E=26087;const i64 inf=1e18;
int n,m,s,t,tot,head[V],vis[V];i64 cost,dis[V];
struct edge{int v,f;i64 c;int next;}e[E];
struct node{int x,y;i64 v;}p[V];
struct opt{int o,a,b;}op[V];
int read(){int x=0;int c=getchar();while(isspace(c))c=getchar();while(isdigit(c))(x*=10)+=c&15,c=getchar();return x;}
i64 raed(){i64 x=0;int c=getchar();while(isspace(c))c=getchar();while(isdigit(c))(x*=10)+=c&15,c=getchar();return x;}
void add(int u,int v,int f,i64 c){e[++tot]={v,f,c,head[u]},head[u]=tot,e[++tot]={u,0,-c,head[v]},head[v]=tot;}
int update()
{
    i64 mn=inf;
    for(int u=1;u<=t;++u) if(vis[u]) for(int i=head[u];i;i=e[i].next) if(!vis[e[i].v]&&e[i].f) mn=std::min(mn,dis[e[i].v]+e[i].c-dis[u]);
    if(mn==inf) return 0;
    for(int u=1;u<=t;++u) if(vis[u]) dis[u]+=mn;
    return 1;
}
int dfs(int u,int res)
{
    if(u==t) return cost-=dis[s]*res,res;
    int use=0;vis[u]=1;
    for(int i=head[u],t;i;i=e[i].next)
	if(!vis[e[i].v]&&e[i].f&&dis[u]==dis[e[i].v]+e[i].c)
	{
	    t=dfs(e[i].v,std::min(res-use,e[i].f)),use+=t,e[i].f-=t,e[i^1].f+=t;
	    if(use==res) return use;
	}
    return use;
}
void solve(int k)
{
    static int lx[V],rx[V],ly[V],ry[V];
    tot=1,cost=0,s=2*k+2*n+1,t=s+1,memset(head+1,0,t<<2),memset(dis+1,0,t<<3);
    memset(lx+1,0,k<<2),memset(ly+1,0,k<<2),memset(rx+1,0x7f,k<<2),memset(ry+1,0x7f,k<<2);
    for(int i=1;i<=k;++i) add(s,i,1,0),add(i+n+n+k,t,1,0);
    for(int i=1;i<=n;++i) add(i+k,i+n+k,1,-p[i].v);
    for(int i=1;i<=m;++i)
	switch(op[i].o)
	{
	case'U':for(int j=1;j<=k-op[i].b;++j)ry[j]=std::min(ry[j],op[i].a-1);break;
	case'D':for(int j=op[i].b+1;j<=k;++j)ly[j]=std::max(ly[j],op[i].a+1);break;
	case'L':for(int j=op[i].b+1;j<=k;++j)lx[j]=std::max(lx[j],op[i].a+1);break;
	case'R':for(int j=1;j<=k-op[i].b;++j)rx[j]=std::min(rx[j],op[i].a-1);break;
	}
    for(int i=1;i<=k;++i) for(int j=1;j<=n;++j) if(lx[i]<=p[j].x&&p[j].x<=rx[i]) add(i,j+k,1,0);
    for(int i=1;i<=k;++i) for(int j=1;j<=n;++j) if(ly[i]<=p[j].y&&p[j].y<=ry[i]) add(j+n+k,i+n+n+k,1,0);
    do do memset(vis+1,0,t<<2);while(dfs(s,1e9));while(update());
}
int main()
{
    i64 ans=0;
    n=read();for(int i=1;i<=n;++i) p[i]={read(),read(),raed()};
    m=read();for(int i=1;i<=m;++i) op[i]={getchar(),read(),read()};
    for(int k=1;k<=n;++k) solve(k),ans=std::max(ans,cost);
    printf("%lld",ans);
}


Measured memory_bytes: 640
import numpy as np
import math

class GradientDescent:
    def __init__(self, f, df, eta=0.01, eps=1e-8):
        self.f, self.df = f, df
        self.eta = eta      # 学習率
        self.eps = eps      # 学習のストップ判定に用いる定数

    def solve(self, x, count_max):
        path = []
        grad = self.df(x)
        count = 0
        while (grad**2).sum() > self.eps**2 and count < count_max:
            x = x - self.eta * grad
            grad = self.df(x)
            path.append(x)
            count += 1
        self.x = x          # 最適化された変数の値
        self.opt = f(x)     # 最適化後の f(x)の値
        
def f(xy):
    x = xy[0]
    y = xy[1]
    ret = 0.
    for i in range(n):
        dx, dy = x - p[i][0], y - p[i][1]
        ret = max(ret, dx**2 + dy**2)
    return math.sqrt(ret)

def df(xy):
    mu = 1e-9
    x, y = xy
    return np.array([
        (f([x + mu, y]) - f([x - mu, y])) / (2. * mu),
        (f([x, y + mu]) - f([x, y - mu])) / (2. * mu)])

n = int(input())
p = []
for i in range(n):
    xy = list(map(float, input().split()))
    p.append(xy)

xy = np.array([500., 500.])
gd = GradientDescent(f, df)
for e_eta in range(2, -9, -1):
    gd.eta = 10 ** e_eta
    gd.solve(xy, 200)
    xy = gd.x

print(gd.opt)

Measured memory_bytes: 14500
#include<bits/stdc++.h>
using namespace std;

struct Edge{
    int src,dest;
    int w;
};
using Graph=vector<vector<Edge>>;
const int INF=1e9;
vector<int> Dijkstra(int s,Graph& g){
    priority_queue<pair<int,int>,vector<pair<int,int>>,greater<>> que;
    int n=g.size();
    vector<int> res(n,INF);
    res[s]=0;
    que.push({0,s});
    while(!que.empty()){
        auto tmp=que.top(); que.pop();
        int v=tmp.second;
        if(res[v]<tmp.first) continue;
        for(auto &e:g[v]){
            if(res[v]+e.w<res[e.dest]){
                res[e.dest]=res[v]+e.w;
                que.push({res[e.dest],e.dest});
            }
        }
    }
    return res;
}
int solve(int cap,int s,int d,Graph &g,set<int> &gas){
    int n=g.size();
    // for(int i=0;i<n;i++){
    //     for(int j=0;j<g[i].size();j++){
    //         cerr<<"#"<<i<<" "<<g[i][j].dest<<endl;
    //     }
    // }
    Graph sg(n);
    for(auto v:gas){
        vector<int> d=Dijkstra(v,g);
        // cerr<<"##"<<v<<endl;
        // for(int i=0;i<n;i++){
        //      cerr<<"#"<<d[i]<<endl;
        // }
        for(auto to:gas){
            if(d[to]<=cap){
                sg[v].push_back(Edge{v,to,d[to]});
            }
        }
    }
    return Dijkstra(s,sg)[d];
}
int main(){
    int n,m,cap;
    while(cin>>n>>m>>cap,n){
        cap*=10;
        map<string,int> dict;
        int idx=0;
        auto index=[&](string name){
            if(dict.count(name)) return dict[name];
            else return dict[name]=idx++;
        };
        string src,dest;
        cin>>src>>dest;
        int s=index(src),d=index(dest);
        vector<Edge> edges(n);
        for(int i=0;i<n;i++){
            string a,b;
            int w;
            cin>>a>>b>>w;
            int x=index(a),y=index(b);
            edges[i].src=x,edges[i].dest=y,edges[i].w=w;
        }
        Graph g(idx);
        for(int i=0;i<n;i++){
            g[edges[i].src].push_back(edges[i]);
            swap(edges[i].src,edges[i].dest);
            g[edges[i].src].push_back(edges[i]);
        }
        set<int> gas;
        for(int i=0;i<m;i++){
            string name;
            cin>>name;
            gas.insert(index(name));
        }
        gas.insert(s);
        gas.insert(d);
        int ret=solve(cap,s,d,g,gas);
        cout<<(ret==INF ? -1 : ret)<<endl;
    }
    return 0;
}


Measured memory_bytes: 5420
#include <bits/stdc++.h>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ll long long
using namespace std;

int main() {
    rep(i, 5) {
        int in;
        cin >> in;
        if(in == 0) {
            cout << i+1 << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 3632
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;
// }}}

int N;

void init()
{
}

int rec(int v)
{
    if(v < 6) return v;
    int ret = INF;
    int x = 1;
    while(x * 6 <= v){
        x *= 6;
    }
    ret = min(ret, rec(v-x)+1);
    x = 1;
    while(x * 9 <= v){
        x *= 9;
    }
    ret = min(ret, rec(v-x)+1);
    return ret;
}

void solve3()
{
    cout << rec(N) << endl;;
}

void solve2()
{
    int ret = 0;
    int n2 = 0, n3 = 0;
    int NN = N;
    while(NN % 2 == 0){
        NN /= 2;
        n2++;
    }
    while(NN % 3 == 0){
        NN /= 3;
        n3++;
    }
    cout << NN << " " << n2 << " " << n3 << endl;
}

void solve()
{
    int ret = 0;
    const int vs[] = {9, 6};
    while(N >= 6){
        int ns[] = {1, 1};
        REP(i, 2){
            int n = 0;
            while(ns[i]*vs[i] < N){
                ns[i] *= vs[i];
            }
        }
        if(ns[0] >= ns[1]){
            N -= ns[0];
            cout << ns[0] << " " << N << endl;
        }else{
            N -= ns[1];
            cout << ns[1] << " " << N << endl;
        }
        ret++;
    }
    ret += N;
    cout << ret << endl;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    solve3();
    return 0;
}

// vim:set foldmethod=marker:


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
int main(){
	string s;
	cin>>s;
	cout<<s.substr(0,4)<<" "<<s.substr(4)<<endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.ExceptionServices;
using System.Runtime.InteropServices;
using System.Text;


namespace AtCoderDotNetCore
{
	class Program
	{
		static void Main(string[] args)
		{
			Question.Exec();
		}
	}

	public static class Question
	{
		public static void Exec()
		{
			Dictionary<char, char> dict = new Dictionary<char, char>();
			dict.Add('A', 'T');
			dict.Add('C', 'G');
			dict.Add('G', 'C');
			dict.Add('T', 'A');
			char c = Console.ReadLine()[0];
			
			Console.WriteLine($"{dict[c]}");
		}
	}
}

Measured memory_bytes: 26292
import numpy as np

n, m = map(int, input().split())
h = np.array(list(map(int, input().split())))
g = [[] for _ in range(n)] 
for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    g[a].append(b)
    g[b].append(a)

good_observatories = [-1] * n
sort_idx = np.argsort(-h)
for i, idx in enumerate(sort_idx):
    if good_observatories[idx] == -1:
        if all([h[idx] > h[v] for v in g[idx]]):
            good_observatories[idx] = 1
            for v in g[idx]:
                good_observatories[v] = 0
print(good_observatories.count(1))


Measured memory_bytes: 46468
#include <bits/stdc++.h>
using namespace std;

int main(){
  int N;
  cin >> N;
  vector<string> Blue(N);
  for (int i = 0; i < N; i++){
    cin >> Blue.at(i);
  }
  int M;
  cin >> M;
  vector<string> Red(M);
  for (int i = 0; i < M; i++){
    cin >> Red.at(i);
  }
  int Answer = 0;
  for (int i = 0;i < N; i++){
    int count = 0;
    for (int j = 0;j < N; j++){
      if (Blue.at(i) == Blue.at(j)){
        count++;
      }
    }
    for (int j = 0;j < M; j++){
      if (Blue.at(i) == Red.at(j)){
        count--;
      }
    }
    if (count > Answer){
      Answer = count;
    }
  }
  cout << Answer << endl;
}

Measured memory_bytes: 256
function Main(input){
  input = input.split(' ').map(num => Number(num));
  var a = input[0];
  var b = input[1];

  if( a === 1) {
      a = 14;
  }
  if (b === 1) {
      b = 14;
  }
  
  if ( a > b ) {
      console.log('Alice')
  } else if( b > a) {
      console.log('Bob')
  } else {
      console.log('Draw');
  }

}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
#define _for(i,a,b) for(int i = (a);i <= (b);++i)
#define LOCAL
typedef long long ll;
const int maxn = 1e5+5;
const int mod = 1e9+7;
template<typename T>
inline T read()
{
    T x = 0;
    int w = 1;
    char ch = 0;
    while (ch < '0' || ch > '9')
    {
        if (ch == '-')
        w = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9')
    {
        x = x * 10 + (ch - '0');
        ch = getchar();
    }
    return x * w;
}
template<typename T>
inline void write(T x)
{
    static int sta[35];
    int top = 0;
    do
    {
        sta[top++] = x % 10, x /= 10;
    } while (x);
    while (top)
    putchar(sta[--top] + 48); // 48 是 '0'
    puts("");
}
ll a[maxn];
ll jec[maxn];
ll qpow(ll a,ll b){
    ll res = 1;
    for(;b;b>>=1){
        if(b&1)res=res*a%mod;
        a=a*a%mod;
    }
    return res;
}
ll get(int n,int m)
{
    if(n<m)return 0;
    ll ans = jec[n]*qpow(jec[m]*jec[n-m]%mod,mod-2)%mod;
    return ans;
}
int main()
{
#ifdef LOCALa
    freopen("simple.in","r",stdin);
    freopen("simple.out","w",stdout);
#endif  
    int n,k;
    n = read<int>();
    k = read<int>();
    jec[0]=1;
    for(int i = 1;i <= n;++i)jec[i]=jec[i-1]*i%mod;
    for(int i = 1;i <= n;++i)a[i]=read<ll>();
    if(k==1){
        printf("0\n");
        return 0;
    }
    sort(a+1,a+1+n);
    ll ans = 0;
    ll sumn,sump;
    sumn=sump=0;
    for(int i = 1;i <= n;++i)
    {
        sumn=(sumn+a[i]*get(i-1,k-1))%mod;
        sump=(sump+a[i]*get(n-i,k-1))%mod;
    }
    cout<<(sumn-sump+mod)%mod<<endl;
    return 0;
}

Measured memory_bytes: 1920
#include <stdio.h>

int main(void)
{
	int num, i, a, b, min = 0, max;

	scanf("%d", &num);

	scanf("%d", &a);
	scanf("%d", &b);
	max = b - a;

	if (a < b) {
		min = a;
	}
	else {
		min = b;
	}

	for (i = 0; i < num - 2; i++) {
		scanf("%d", &a);

		if (a - min > max) {
			max = a - min;
		}

		if (min > a) {
			min = a;
		}
	}

	printf("%d\n", max);

	return 0;	
}


Measured memory_bytes: 2140
#include "bits/stdc++.h"
#define PRECISION(x) cout << fixed << setprecision(x)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define ALLR(X) (X).rbegin(), (X).rend()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second

using namespace std;
 
template<class T> bool max_self(T & a, const T & b){ 
  return b > a ? a = b, true : false; 
}
template<class T> bool min_self(T & a, const T & b){ 
  return b < a ? a = b, true : false;    
}
typedef long long LL;
const int INF = 1e9 + 7;
const double PI = acos(-1.0);
const double EPS = (1e-9);

 
int main(){
  FAST_IO
  int N;
  cin >> N;

  vector<LL> num(N);
  for(LL &ele : num) cin >> ele;
  sort(ALL(num));

  __int128 product = 1;
  for(LL ele : num){
    product = product * ele;
    if(product > (LL)1e18){
      cout << "-1\n";
      return 0;
    }
  }

  cout << (LL)product << '\n';
  return 0;
}


Measured memory_bytes: 3992
{-#LANGUAGE FlexibleContexts#-}
import Control.Monad
import Control.Monad.State
import Control.Monad.Reader
import Control.Arrow
-- import Control.Comonad
import Data.Maybe
import Data.List
import Data.Bool
import Data.Fixed
import Data.Tuple
import Data.Ratio
import qualified Data.Map.Strict as M
import qualified Data.Array.IO as IA
import qualified Data.Vector as V

getI = read <$> getLine :: IO Int
getIs = map read . words <$> getLine :: IO [Int]
getD = read <$> getLine :: IO Double
getDs = map read . words <$> getLine :: IO [Double]
getInt = read <$> getLine :: IO Integer
getInts = map read . words <$> getLine :: IO [Integer]

type Row = Integer
type Col = Integer
type PointI = (Integer, Integer)
type Point = (Int, Int)

mmm = 1000000007
fact n
    | n < 1 = 1
    | True = foldr1 (*) [1..n]
ti = toInteger
fi = fromInteger
fig = fromIntegral
rf = realToFrac

(.<.) :: Integer -> Integer -> Integer
(.<.) f g -- combination
    | g < 1 || f < 1 || f < g = 1
    | True = foldr1 (*) (take (fi g) [f,f-1..]) `div` fact g
(.>.) f g --combination with repetition
    | g < 1 || f < 1 = 1
    | True = fact (f + g - 1) `div` (fact (f - 1) * fact g)
comb = (.<.)
combWp = (.>.)

unique a = unique_ (reverse . sort $ a) [] Nothing
    where
        unique_ [] arr _ = arr
        unique_ (x:xs) arr n
            | n == Just x = unique_ xs arr n
            | otherwise = unique_ xs (x:arr) $ Just x
 
zeroume keta num
    | (length . show $ num) > keta = show num
    | otherwise = do 
        let zeros = take keta $ repeat '0'
        reverse . take keta $ (reverse . show $ num) ++ zeros
 
i2b num
    | num < 2 = show num
    | otherwise = i2b_ num []
        where
            i2b_ num str
                | num == 0 = str
                | num == 1 = '1':str
                | otherwise = do
                    let next = num `div` 2
                    let this = if odd num then '1' else '0'
                    i2b_ next (this:str)

mapIncr = mapPlus 1
mapPlus n Nothing = Just n
mapPlus n a = (+) n <$> a

countIf f = length . filter f

enumDivisor :: Int -> [Int]
enumDivisor n = do
    let sqrted = floor $ sqrt (fromIntegral n)
        smaller = filter (\x -> mod n x == 0) [1..sqrted]
        bigger = reverse $ map (div n) smaller
    if head bigger == sqrted then smaller ++ (init bigger)
    else smaller ++ bigger

-- 
--
--

main = do
    inp <- getLine
    case all even $ map (\x -> countIf (== x) inp)['a'..'z'] of
        True -> putStrLn "Yes"
        _ -> putStrLn "No"


Measured memory_bytes: 380
#include <bits/stdc++.h>

using namespace std;

// Repetitions
#define FOR(i,a,n) for(ll i = ((ll) a); i < ((ll) n); ++i)
#define FORR(i, s, g) for(ll i = ((ll)s - 1); i >= ((ll) g); --i)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) FORR(i, n, 0)

// Container Utils
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define SORTALL(v) sort(ALL(v))
#define SZ(a) int((a).size())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())

// For Debug
#define DMP(x)  cerr << #x << " = " << (x) << endl
#define DBG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

// Aliases
#define PB push_back
#define MP make_pair
using ll = long long;
using ld = long double;
using str = string;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vs = vector<str>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vpii = vector<pii>;
using vpll = vector<pll>;

// Constant variables
const ld PI = (acos(-1));
const ll MOD = 1000000007;

// I/O Asynchronizing
struct __io_async{
    __io_async(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
};

#define MAX_N 50
int n;
int connect[MAX_N][MAX_N];
set<pii> st;

bool can_reach(const int start_node, set<int> &ns) {
    ns.insert(start_node);
    REP(i, n) {
        if(i == start_node) continue;
        if(connect[start_node][i] == 1 && ns.count(i) == 0) {
            can_reach(i, ns);
        }
    }
    return ns.size() == n;
}

int search() {
    int ans = 0;
    for(auto e : st) {
        connect[e.first][e.second] = 0;
        connect[e.second][e.first] = 0;
        set<int> ns;
        if(!can_reach(e.first, ns)) ans++;
        connect[e.first][e.second] = 1;
        connect[e.second][e.first] = 1;
    }
    return ans;
}

int main() {
    int m;
    cin >> n >> m;
    REP(i, m) {
        int a, b;
        cin >> a >> b;
        connect[a - 1][b - 1] = 1;
        connect[b - 1][a - 1] = 1;
        st.insert(make_pair(a -1, b - 1));
    }
    cout << search() << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(n) begin(n), end(n)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    int N;
    cin>>N;
    ll ans=0;
    for (int i = 1; i <= N; i++)
    {
            ll k = N/i;
            ans += i * k*(k+1)/2;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>

int main(int argc, char const *argv[])
{
    int a = 0;
    int b = 0;

    std::cin >> a >> b;

    std::cout << "a";

    if (a > b) {
        std::cout << " > ";
    } else if (a < b) {
        std::cout << " < ";
    } else {
        std::cout << " == ";
    }

    std::cout << "b" << std::endl;

    return 0;
}

Measured memory_bytes: 3068
using System;
using System.Linq;

public class Test
{
	public static void Main()
	{
		// your code goes here
		
		var a = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
		int n = a[0];
		int l = a[1];
		int[] azi = new int[n];
		azi[0] = l;
		int sum = l;
		int lowest = 114514;
		int sa = 0;
		int last = 0;
		
		for(int i=1; i!=n; i++){
			azi[i] = azi[i-1]+1;
			sum = sum+azi[i];
		}
		
		for(int j=0; j!=n; j++){
			sa=Math.Abs(azi[j]);
			if(lowest>sa){
				lowest = sa;
				last = j;
			}
		}
		
		Console.WriteLine(sum-azi[last]);
		
	}
}

Measured memory_bytes: 13396
import java.util.*;
import java.io.*;

public class Main {
	private static void solve(){
		//Implement solution here.
		int x = ni();
		int a = ni();
		System.out.println(x < a ? 0 : 10);
	}

	//Switch input source (stdin/file)
	private static BufferedReader br  = new BufferedReader(new InputStreamReader(System.in));
	public static void main(String[] args){
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		solve();
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

Measured memory_bytes: 21460
#include<iostream>
#include <stdio.h>
#include<string>
using namespace std;

int main(){
	int n;
	string line;
	scanf("%d ",&n);
	
	for(int x=0;x<n;x++){
		getline(cin,line);
		while (line.find("Hoshino") != string::npos) {
			line.replace(line.find("Hoshino"), 7, "Hoshina");
		}
		cout << line << endl;
    }
	return 0;
}

Measured memory_bytes: 3148
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define FOR(i, x, y) for (ll i = x; i < y; i++)
typedef long long ll;
using namespace std;

deque<string> end_b, reg;
ll ans = 0, indx = 0;

void iter(string i) {
    // cout << i << ' ' << indx << endl;
    FOR(j, 0, i.size() - 1) if (i[j] == 'A' && i[j + 1] == 'B') ans++;
    if (i.back() == 'A' && indx < end_b.size()) {
        ans++;
        iter(end_b[indx++]);
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin >> n;
    FOR(i, 0, n) {
        string s;
        cin >> s;
        if (s[0] == 'B') {
            if (s.back() == 'A') end_b.push_front(s);
            else end_b.push_back(s);
        }
        else {
            if (s.back() == 'A') reg.push_front(s);
            else reg.push_back(s);
        }
    }
    for (auto& i : reg) iter(i);
    for (; indx < end_b.size();) iter(end_b[indx++]);
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll a[2];
  rep(i,2) R a[i];
  sort(a,a+2);
  ll ans=a[1];
  a[1]--;
  sort(a,a+2);
  ans+=a[1];
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
 int a,b;
  cin>>a>>b;
  int f[a];
  for(int i=0;i<a;i++){
	cin>>f[i];
  }
  sort(f,f+a);
  int sum=0;
  for(int j=0;j<b;j++){
  	sum=sum+f[j];
  
  }
  cout<<sum<<"\n";
  
  
  
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N,M,Z=0;
  cin>>N>>M;
  vector<int> p(N);
  for(int i=0;i<N;i++){
    int a;
    cin>>a;
    p.at(i)=a-1;
  }
  vector<vector<int>> G(N);
  for(int i=0;i<M;i++){
    int a,b;
    cin>>a>>b;
    a--;
    b--;
    G.at(a).push_back(b);
    G.at(b).push_back(a);
  }
  vector<int> c(N);
  for(int i=0;i<N;i++){
    if(c.at(i)==0){
      c.at(i)=1;
      queue<int> q;
      vector<int> w;
      vector<int> e;
      q.push(i);
      w.push_back(i);
      e.push_back(p.at(i));
      while(!(q.empty())){
        int a=q.front();
        q.pop();
        for(int x:G.at(a)){
          if(c.at(x)==0){
            c.at(x)=1;
            q.push(x);
            w.push_back(x);
            e.push_back(p.at(x));
          }
        }
      }
      sort(w.begin(), w.end());
      sort(e.begin(), e.end());
      int a=0,b=0;
      while(a<w.size()&&b<e.size()){
        if(w.at(a)>e.at(b)){
          b++;
        }
        else if(w.at(a)<e.at(b)){
          a++;
        }
        else{
          Z++;
          a++;
          b++;
        }
      }
    }
  }
  cout<<Z<<endl;
            
}

Measured memory_bytes: 7372
class Bridge(val a : Int, val b : Int)
class Island(var group : Int)

fun moveGroup(s : MutableList<Int>, t : MutableList<Int>, lIsland : MutableList<Island>, group : Int){
    for(i in 0..(s.size - 1)){
        t.add(s[0])
        lIsland[s[0]].group = group
        s.removeAt(0)
    }
}

fun main(args: Array<String>){
    val (n, m) = readLine()!!.split(" ").map(String::toInt)
    var lIsland = mutableListOf<Island>()
    var lGroup : MutableList<MutableList<Int>> = mutableListOf()
    for(i in 0..(n - 1)){
        lIsland.add(Island(i))
        val iLGroup = mutableListOf(i)
        lGroup.add(iLGroup)
    }
    var lBridge = mutableListOf<Bridge>()
    for(i in 0..(m - 1)){
        val(a, b) = readLine()!!.split(" ").map(String::toInt)
        lBridge.add(Bridge(a - 1, b - 1))
    }
    var lRet = mutableListOf<Long>()
    lRet.add(n.toLong() * (n - 1).toLong() / 2L)
    for(i in (m - 1) downTo 1){
        val groupA = lIsland[lBridge[i].a].group
        val groupB = lIsland[lBridge[i].b].group
        if(groupA == groupB){
            lRet.add(lRet[(m - 1) - i])
        }else{
            lRet.add(lRet[(m - 1) - i] - (lGroup[groupA].size.toLong() * lGroup[groupB].size.toLong()))
            if(lGroup[groupA].size >= lGroup[groupB].size) moveGroup(lGroup[groupB], lGroup[groupA], lIsland, groupA)
            else moveGroup(lGroup[groupA], lGroup[groupB], lIsland, groupB)
        }
    }
    for(i in (m - 1) downTo 0){
        println(lRet[i])
    }
}


Measured memory_bytes: 99452
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;

int main() {
  int A, B;
  cin >> A >> B;

  if (A * B % 2 == 1)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3516
#include <bits/stdc++.h>
using namespace std;

int main() {
  string w;
  cin >> w;
  for (char i = 'a'; i < 'z'; i++) {
    int temp = 0;
    for (int j = 0; j < w.size(); j++) {
      if (w[j] == i)
        temp++;
    }
    if (temp % 2 != 0) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(const auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define sar(a,n) {cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl;}

using namespace std;

template<typename S,typename T>auto&operator<<(ostream&o,pair<S,T>p){return o<<"{"<<p.fi<<","<<p.se<<"}";}
template<typename T>auto&operator<<(ostream&o,set<T>s){for(auto&e:s)o<<e<<" ";return o;}
template<typename S,typename T,typename U>
auto&operator<<(ostream&o,priority_queue<S,T,U>q){while(!q.empty())o<<q.top()<<" ",q.pop();return o;}
template<typename K,typename T>auto&operator<<(ostream&o,map<K,T>&m){for(auto&e:m)o<<e<<" ";return o;}
template<typename T>auto&operator<<(ostream&o,vector<T>v){for(auto&e:v)o<<e<<" ";return o;}
void ashow(){cout<<endl;}template<typename T,typename...A>void ashow(T t,A...a){cout<<t<<" ";ashow(a...);}
template<typename S,typename T,typename U>
struct TRI{S fi;T se;U th;TRI(){}TRI(S f,T s,U t):fi(f),se(s),th(t){}
bool operator<(const TRI&_)const{return(fi==_.fi)?((se==_.se)?(th<_.th):(se<_.se)):(fi<_.fi);}};
template<typename S,typename T,typename U>
auto&operator<<(ostream&o,TRI<S,T,U>&t){return o<<"{"<<t.fi<<","<<t.se<<","<<t.th<<"}";}

typedef pair<int, int> P;
typedef pair<ll,ll> pll;
typedef TRI<int, int, int> tri;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 200005;

vector<int> a[MAX_N], b[MAX_N];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int T;
    cin >> T;
    rep(pachico,T){
        int n, k, l, r, cnt = 0;
        cin >> n;
        ll ans = 0;
        rep(i,n) a[i].clear(), b[i].clear();
        rep(i,n){
            cin >> k >> l >> r;
            if(l >= r) ans += r, a[k-1].pb(l - r), ++cnt;
            else ans += l, b[k-1].pb(r - l);
        }
        priority_queue<int> qa, qb;
        rrep(i,n){
            for(const int e : a[i]) qa.push(e);
            if(i < cnt && !qa.empty()){
                ans += qa.top();
                qa.pop();
            }
        }
        rep(i,n){
            if(i >= cnt && !qb.empty()){
                ans += qb.top();
                qb.pop();
            }
            for(const int e : b[i]) qb.push(e);
        }
        cout << ans << "\n";
    }
    return 0;
}

Measured memory_bytes: 17764
#include <bits/stdc++.h> 
using namespace std; 
int main(){
  int i;
  cin >> i;
  int k = i % 10;
  
  if (k== 2 || k == 4 || k == 5 || k == 7 || k ==  9){
    cout << "hon" << endl;
  }
  
  else if (k == 0 || k == 1 || k == 6 || k == 8 ){
    cout << "pon" << endl;
  }
  else {
    cout << "bon" << endl;
  }
}

Measured memory_bytes: 3540
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

signed main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n;
  cin >> n;
  VI a(n);
  REP(i, n) cin >> a[i];

  int ret = 0;
  REP(i, n) ret += a[i]-1;
  cout << ret << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>

int n, m, k, cnt, ans = 1e9;
int a[15][1005], sum[15][1005], sumb[15], b[15], flag[1005];
char s[1005];

void dfs(int x) {
    if (x == n) {
        b[cnt + 1] = n + 1;
        int now = 0;
        memset(flag, 0, sizeof(flag));
        memset(sumb, 0, sizeof(sumb));
        for (int j = 1; j <= m; ++j) {
            int tag = 0;
            for (int i = 1, t = 1; t <= n; t == b[i] ? ++i : 0, ++t) {
                sumb[i] += a[t][j];
                if (sumb[i] > k) tag = 1;
            }
            if (tag) {
                if (j == 1) return;
                flag[++now] = j - 1;
                for (int i = 1, t = 1; t <= n; ) {
                    sumb[i] -= sum[t][j - 1] - sum[t][flag[now - 1]];
                    if (t == b[i]) {
                        if (sumb[i] > k) return;
                        ++i;
                    }
                    ++t;
                }
            }
        }
        ans = std::min(ans, cnt + now);
        return;
    } 
    dfs(x + 1);
    b[++cnt] = x;
    dfs(x + 1);
    --cnt;
}

int main() {
    scanf("%d%d%d", &n, &m, &k);
    for (int i = 1; i <= n; ++i) {
        scanf("%s", s);
        for (int j = 1; j <= m; ++j) a[i][j] = s[j - 1] - 48, sum[i][j] = sum[i][j - 1] + a[i][j];
    }
    dfs(1);
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
//containing t test cases
#include<bits/stdc++.h>
#define pb push_back
#define mod 1000000007
#define mkp make_pair
#define fi first
#define se second
#define ll long long
#define scan(n) ll a[n]; for(ll i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define pi 3.1415926535897932384626433832795028841971
//#define int long long
using namespace std;
//typedef vector<int>vi ;
typedef vector<ll>vi ;
typedef vector<vector<ll> >vvl ; 
typedef pair<ll,ll> pll ;
typedef vector<pair<ll,ll> > vpll;
/*vi adj[200005];
ll vis[200005];
ll parent[200005];
ll level[200005];
ll arr[200005];
ll size[200005];*/
//endl mut bhool!!
int main()
{
	fast;
	ll test=1;
	//cin>>test;
	while(test--)
	{
		double a,b,h,m;
		cin>>a>>b>>h>>m;
	//	ll ah,am;
		h+=m/60;
		double ah=(double)h*(2*pi)/12;
		double am=(double)m*(2*pi)/60;
		double a1=abs(ah-am);
		double a2=2*pi-a1;
		a1=min(a2,a1);
	//	cout<<a1<<endl;
	//	cout<<pi/3<<endl;
		//cout<<cos(a1)<<endl;
		double ans=sqrt(a*a+b*b-2*a*b*cos(a1));
		cout<<fixed<<setprecision(15)<<ans;
	}
	return 0;
}
/*
cout<<"YES"<<endl;
cout<<"NO"<<endl;
*/


Measured memory_bytes: 4244
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;


namespace SolutionCS
{
    class Program
    {
        class Entity : IComparable<Entity>
        {
            public long money;
            public long qty;

            public Entity(long money, long qty)
            {
                this.money = money;
                this.qty = qty;
            }

            public int CompareTo(Entity e)
            {
                return money.CompareTo(e.money);
            }

        }

        static void Main(string[] args)
        {
            string[] strs = Console.ReadLine().Split(' ');
            int N = int.Parse(strs[0]);
            long M = long.Parse(strs[1]);

            List<Entity> shopList = new List<Entity>();

            for (int i = 0; i < N; i++)
            {
                strs = Console.ReadLine().Split(' ');
                long mon = long.Parse(strs[0]);
                long qty = long.Parse(strs[1]);

                Entity e = new Entity(mon, qty);
                shopList.Add(e);
            }

            shopList.Sort();

            long ans = 0;
            for(int i = 0; i < N;i++)
            {
                Entity e = shopList[i];

                if ( e.qty >= M)
                {
                    ans += M * e.money;
                    break;
                }

                ans += e.qty * e.money;
                M -= e.qty;
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 24128
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

int dp1[3001][3000] = {};
int dp2[3002][3000] = {};

int main() {
  int n, t;
  cin >> n >> t;
  vector<pair<int, int>> ab(n + 1);
  REP(i, n) {
    int a, b;
    cin >> a >> b;
    ab[i + 1] = make_pair(a, b);
  }

  FOR(i, 1, n + 1) {
    FOR(j, 1, t) {
      if (j < ab[i].first) {
        dp1[i][j] = dp1[i - 1][j];
      } else {
        dp1[i][j] =
            max(dp1[i - 1][j], dp1[i - 1][j - ab[i].first] + ab[i].second);
      }
    }
  }

  for (int i = n; i >= 0; i--) {
    FOR(j, 1, t) {
      if (j < ab[i].first) {
        dp2[i][j] = dp2[i + 1][j];
      } else {
        dp2[i][j] =
            max(dp2[i + 1][j], dp2[i + 1][j - ab[i].first] + ab[i].second);
      }
    }
  }

  int ans = 0;
  FOR(i, 1, n + 1) {
    int tmp = 0;
    REP(j, t) { tmp = max(tmp, dp1[i - 1][j] + dp2[i + 1][t - j - 1]); }
    ans = max(ans, tmp + ab[i].second);
  }
  cout << ans << endl;
}


Measured memory_bytes: 70656
#include <bits/stdc++.h>
using namespace std;
vector<int> dx = {1, 0, -1, 0};
vector<int> dy = {0, -1, 0, 1};
int INF = 10000000;
int main(){
  vector<vector<int>> num(1000, vector<int>(1000, 0));
  int y = 500;
  int x = 499;
  int d = 0;
  int t = 0;
  for (int i = 0; i < 1000000; i++){
    num[y][x] = i + 1;
    y += dy[d % 4];
    x += dx[d % 4];
    t++;
    if (t == d / 2 + 1){
      t = 0;
      d++;
    }
  }
  vector<bool> prime(1000001, true);
  prime[0] = false;
  prime[1] = false;
  for (int i = 2; i <= 1000000; i++){
    if (prime[i]){
      for (int j = i * 2; j <= 1000000; j += i){
        prime[j] = false;
      }
    }
  }
  while (1){
    int m, n;
    cin >> m >> n;
    if (m == 0 && n == 0){
      break;
    }
    vector<vector<pair<int, int>>> dp(1000, vector<pair<int, int>>(1000, make_pair(-INF, 0)));
    for (int i = 0; i < 1000; i++){
      for (int j = 0; j < 1000; j++){
        if (num[i][j] == n){
          if (prime[num[i][j]]){
            dp[i][j] = make_pair(1, n);
          } else {
            dp[i][j] = make_pair(0, 0);
          }
        }
        if (i > 0){
          for (int k = -1; k <= 1; k++){
            if (0 <= j + k && j + k < 1000){
              if (prime[num[i][j]] && num[i][j] <= m){
                dp[i][j] = max(dp[i][j], make_pair(dp[i - 1][j + k].first + 1, num[i][j]));
              } else {
                dp[i][j] = max(dp[i][j], dp[i - 1][j + k]);
              }
            }
          }
        }
      }
    }
    pair<int, int> ans = make_pair(-INF, 0);
    for (int i = 0; i < 1000; i++){
      ans = max(ans, dp[999][i]);
    }
    cout << ans.first << ' ' << ans.second << endl;
  }
}


Measured memory_bytes: 14884
# -*- coding: utf-8 -*-
"""
Created on Mon Aug  6 17:34:40 2018

@author: Yuki
"""

ans = [0] * 100100
ans[0] = 0

n = int(input())
#n = 127
for i in range(1,n+1):
    cand1 = ans[i-1]
    cand2 = 100001
    cand3 = 100001
    x = 6
    while (x<=i):
        #cand2 = min(ans[i-x], cand2)
        cand2 = ans[i-x]
        x=6*x
    y = 9
    while (y<=i):
        #cand3 = min(ans[i-y], cand3)
        cand3 = ans[i-y]
        y=9*y
    ans[i] = min(cand1,cand2,cand3) + 1


print(ans[n])



Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vi = vector<int>;
using vvi = vector<vi>;
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)

int main(){
	string s; cin>>s;
	sort(all(s));
	ote(s=="abc"?"Yes":"No");
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <limits>
#include <iterator>
#include <cmath>
#include <numeric>
using namespace std;

int main()
{
	int a, b;
	cin >> a >> b;
	int ans = 0;
	for (int i = 0;i < 2;i++)
	{
		if (a > b)
		{
			ans += a;
			a--;
		}
		else {
			ans += b;
			b--;
		}
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()

ll gcd(ll &a,ll &b,ll &c) {
ll k=min(a,b);
  k=min(k,c);
  ll g;
  for(ll i=1;i<=k;i++) {
if(a%i==0&&b%i==0&&c%i==0) {
  g=i;
}
  }
  return g;
}




 
int main() {
 ll K;
  cin>>K;
  ll ans=0;
  for(ll i=1;i<=K-2;i++) {
for(ll j=i+1;j<=K-1;j++) {
for(ll h=j+1;h<=K;h++) {
  ans+=gcd(i,j,h);
}
}
  }
  
  ans*=6;
  ll t=0;
 for(ll i=1;i<=K;i++) {
for(ll j=1;j<=K;j++) {
  if(i==j) {
continue;
  }
t+=gcd(i,i,j);
}  
}

  
  t*=3;
  ans+=t;
 for(ll i=1;i<=K;i++) {
ans+=i;
 }
  
  cout<<ans<<endl;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>

#define inf 0x3f3f3f3f
#define pb push_back
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef vector <ll> vl;
typedef vector <ull> vu;
typedef vector <vector <int>> vvi;
typedef pair <int, int> pi;
typedef vector <pair <int, int>> vpi;

int n;

void read() {
  cin >> n;
}

void solve() {
  for(int d = 0; d <= n; d += 7)
    if ((n - d) % 4 == 0) {
      cout << "Yes";
      return;
    }
  cout << "No";
}

int main() {
  ios :: sync_with_stdio(false);
  cin.tie(nullptr);
  int t = 1;
  //cin >> t; //please do not forget to comment this if there are no queries
  while(t) {
    --t;
    read();
    solve();
  }
  return 0;
}


Measured memory_bytes: 256
n = int(input())
P = [int(input())-1 for _ in range(n)]
A = [0]*n
for i, p in enumerate(P):
    A[p] = i

#print(A)

m = 0
temp = 0
for i in range(1, n):
    if A[i-1] < A[i]:
        temp += 1
    else:
        m = max(m, temp)
        temp = 0
else:
    m = max(temp, m)
print(n-m-1)


Measured memory_bytes: 89588
#include <iostream>

using namespace std;

typedef long long ll;

int main() {
    cin.tie(NULL);
    ios::sync_with_stdio(false);

    ll x;
    ll money = 100;
    int cnt = 0;

    cin >> x;

    while (money < x) {
        ++cnt;
        money += money / 100;
    }

    cout << cnt;
    return 0;
}


Measured memory_bytes: 3692
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;

    if (n % 2 == 0) cout << n << endl;
    else cout << n * 2 << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
#define DL double
#define MLL map<LL,LL>::iterator
#define MSL map<string,L>::iterator
#define MLS map<LL,string>::iterator
#define MSS map<string,string>::iterator
#define MCL map<char,LL>::iterator
#define SL set<LL>::iterator
#define SS set<string>::iterator
#define VL V<LL>::iterator
#define G getline
#define SZ size()
#define IN insert
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM emptm()
#define V vector
#define Q queue
#define DQ deque
#define PQ prioritm_queue
#define ST stack
#define FI first
#define MAn 1e18
#define MIN -1e18
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
V<LL>v;
map<LL,LL>u;
void Y()
{
    cout<<"Yes"<<endl;
}
void N()
{
    cout<<"No"<<endl;
}
int main()
{
    FAST;
    LL n,m,i,j,k,p,q,o,l,s,t,z=0,r;
    string a,b,c;
    DL x,y;
    cin>>n>>m;
    n*=3;
    n+=m;
    cout<<n/2<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int H,W;
  cin>>H>>W;
  string A[H];
  REP(i,H)cin>>A[i];
  REP(i,W+2)cout<<'#';cout<<endl;
  REP(i,H)cout<<'#'<<A[i]<<'#'<<endl;
  REP(i,W+2)cout<<'#';cout<<endl;
  return 0;
}


Measured memory_bytes: 256