akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for(int i=a;i<b;i++)
#define repds(i,a,b) for(int i=a+1;i<=b;i++)
#define rep(i,N) repd(i,0,N)
#define reps(i,N) repds(i,0,N)
#define debug(x) cout<<#x<<"="<<x<<endl
#define debugarr(arr,N,M){rep(i,N){rep(j,M){if(arr[i][j]==INF)printf(" INF");\
	else printf(" %3d",arr[i][j]);} cout<<endl;}}
#define pb push_back
#define pob pop_back
#define cint(a) int a;cin>>a
#define cint2(a,b) int a,b;cin>>a>>b
#define cint3(a,b,c) int a,b,c;cin>>a>>b>>c
typedef long long ll;
typedef pair<int,int> P;
const int INF=100000000;
const int dx[4]={ 0, 1, 0,-1};
const int dy[4]={ 1, 0,-1, 0};
//--------------------------------------//
int n;
bool b[100000];
int main(){
	cin>>n;
	queue<P> q;
	q.push(P(n,0));
	int ans=0;
	while(true){
		P p=q.front();
		int a=p.first;
		//cout<<a;
		//cout<<","<<p.second<<endl;
		q.pop();
		if(a<6){
			q.push(P(a-1,p.second+1));
			if(a-1==0){
				cout<<p.second+1<<endl;
				return 0;
			}
		}

		else{
			int i=2;
			while(true){
				if(a<pow(6,i)){
					int nex=a-(int)pow(6,i-1);
					if(!b[nex]){
						q.push(P(nex,p.second+1));
						//debug(nex);
						b[nex]=true;
					}
					if(nex==0){
						cout<<p.second+1<<endl;
						return 0;
					}
					break;
				}
				i++;
			}
			i=2;
			while(true){
				if(a<pow(9,i)){
					int ne=(a)-((int)pow(9,i-1));
					if(!b[ne]){
						q.push(P(ne,p.second+1));
						//debug(ne);
						b[ne]=true;
					}
					if(ne==0){
						cout<<p.second+1<<endl;
						return 0;
					}
					break;
				}
				i++;
			}
		}
	}
	cout<<ans<<"\n";
	return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16

#define PI acos(-1)

ll xx[2],yy[2];
ll n;
ll x[202020],y[202020];
ll dp[202020];

ll change(ll h){ return (ll)pow(10LL,8)-1-h; }

int main(){
	cin.sync_with_stdio(false);
  rep(i,2)cin>>xx[i]>>yy[i];
  cin>>n;
  rep(i,n)cin>>x[i]>>y[i];

  if(xx[0]==xx[1]){
    rep(i,n){
      if(xx[0]==x[i]&&min(yy[0],yy[1])<=y[i]&&y[i]<=max(yy[0],yy[1])){
        printf("%.10f",(double)PI*10.0+(double)abs(yy[0]-yy[1])*100.0-20.0);
        return 0;
      }
    }
    printf("%.10f\n", (double)abs(yy[0]-yy[1])*100.0);
    return 0;
  }
  if(yy[0]==yy[1]){
    rep(i,n){
      if(yy[0]==y[i]&&min(xx[0],xx[1])<=x[i]&&x[i]<=max(xx[0],xx[1])){
        printf("%.10f\n",(double)PI*10.0+(double)abs(xx[0]-xx[1])*100.0-20.0);
        return 0;
      }
    }
    printf("%.10f\n", (double)abs(xx[0]-xx[1])*100.0);
    return 0;
  }

  if(xx[0]>xx[1]){
    swap(xx[0],xx[1]); swap(yy[0],yy[1]);
  }
  if(yy[0]>yy[1]){
    xx[0]=change(xx[0]);
    xx[1]=change(xx[1]);
    rep(i,n)x[i]=change(x[i]);
    swap(xx[0],xx[1]);
    swap(yy[0],yy[1]);
  }

  /*
  rep(i,2){
    dbg(xx[i]);
    dbg(yy[i]);
  }
  rep(i,n){
    dbg(x[i]); dbg(y[i]);
  }*/
  vector<P> a;
  rep(i,n){
    if(xx[0]<=x[i]&&x[i]<=xx[1]&&yy[0]<=y[i]&&y[i]<=yy[1]){
      a.push_back(P(x[i],y[i]));
    }
  }
  sort(all(a));
  ll m=a.size();
  vector<ll> b;
  rep(i,m)b.push_back(a[i].se);

  bool dame=true;
  rep(i,m-1){
    if(b[i]>b[i+1]){
      dame=false;
      break;
    }
  }
  if(dame&&m>0&&(xx[1]-xx[0]+1==m||yy[1]-yy[0]+1==m)){
    printf("%.10f\n", (xx[1]-xx[0])*100.0+(yy[1]-yy[0])*100+(double)(m-1)*5*PI-(double)(m-1)*20.0+(double)PI*10-20.0);
    return 0;
  }

  rep(i,202020)dp[i]=INF;
  rep(i,m){
    *upper_bound(dp,dp+202020,b[i])=b[i];
  }
  ll cnt=0;
  rep(i,202020){
    if(dp[i]==INF){
      cnt=i;
      break;
    }
  }
  printf("%.10f\n", (xx[1]-xx[0])*100.0+(yy[1]-yy[0])*100+(double)cnt*5*PI-(double)cnt*20);
	return 0;
}


Measured memory_bytes: 13036
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <set>
#include <map>
#include <assert.h>

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)

typedef long long ll;

double const EPS = 1e-8;
typedef vector<double> vec;
typedef vector<vec> mat;

vec gauss_jordan(mat const& A, vec const& b) {
  int n = A.size();
  mat B(n, vec(n+1));
  rep(i, n) rep(j, n) B[i][j] = A[i][j];
  rep(i, n) B[i][n] = b[i];

  rep(i, n) {
    int pivot = i;
    REP(j, i, n) {
      if(abs(B[j][i]) > abs(B[pivot][i])) { pivot = j; }
    }
    swap(B[i], B[pivot]);

    if(abs(B[i][i]) < EPS) { return vec(); }

    REP(j, i+1, n+1) B[i][j] /= B[i][i];
    rep(j, n) {
      if(i != j) {
        REP(k, i+1, n+1) B[j][k] -= B[j][i] * B[i][k];
      }
    }
  }

  vec x(n);
  rep(i, n) x[i] = B[i][n];
  return x;
}


int D;

int main() {

  for(; cin >> D && D;) {
    double v[D+3]; rep(i, D+3) cin >> v[i];
    map<vector<long long>, int> counter;
    rep(i, D+3) {
      REP(j, i+1, D+3) {
        mat A(D+1, vec(D+1));
        int p = 0;
        vec b;
        rep(x, D+3) {
          if(x == i || x == j) { continue; }
          rep(l, D+1) {
            A[p][l] = pow(double(x), D-l);
          }
          p++;
          b.push_back(v[x]);
        }

        auto s = gauss_jordan(A, b);
        vector<long long> ss(D+1);
        int sz = s.size(); rep(ii, sz) {
          ss[ii] = ceil(s[ii]*10);
        }
        auto tt = ss;
        ss.push_back(i); tt.push_back(j);
        counter[ss]++; counter[tt]++;
      }
    }
    for(auto e: counter) {
      /*
      rep(i, e.first.size()) {
        cout << e.first[i] << endl;
      }
      cout << endl;
      */
      if(e.second >= D+2) {
        cout << e.first.back() << endl;
        goto exit;
      }
    }
    cout << "EPS DEAD\n";
  exit:;
  }

  return 0;
}

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

int main() {
  int n;
  int ans;
  cin >> n;
  if ( n < 10 ) { ans = n; }
  else if ( n < 100 ) { ans = 9; }
  else if ( n < 1000 ) { ans = n-90; }
  else if ( n < 10000 ) { ans = 909; }
  else if ( n < 100000 ) { ans = n-9090; }
  else if ( n == 100000 ) { ans = 90909; }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
readline = sys.stdin.readline
write = sys.stdout.write
class RollingHash():
    def __init__(self, s, base, mod):
        self.mod = mod
        self.pw = pw = [1]*(len(s)+1)

        l = len(s)
        self.h = h = [0]*(l+1)

        v = 0
        for i in range(l):
            h[i+1] = v = (v * base + ord(s[i])) % mod
        v = 1
        for i in range(l):
            pw[i+1] = v = v * base % mod
    def get(self, l, r):
        return (self.h[r] - self.h[l] * self.pw[r-l]) % self.mod

def solve():
    MOD = 10**9 + 7
    A, B, C = readline().strip().split()
    L = max(len(A), len(B))
    pw10 = [1]*(L+1)
    r = 1
    for i in range(1, L+1):
        pw10[i] = r = r * 10 % MOD
    def calc(X, Y):
        mod = 10**9 + 9
        N = len(X)
        M = len(Y)
        if N < M:
            return 0
        hx = RollingHash(X, 37, mod)
        hy = RollingHash(Y, 37, mod)
        hY = [hy.get(0, i) for i in range(M+1)]
        res = cur = 0
        for i in range(N):
            v = int(X[i])
            res += cur * v * pw10[N - (i+1)] % MOD
            for j in range(i-M+1, i+1):
                if j+M > N:
                    break
                l = i-j
                if (0 < l and hx.get(j, j+l) != hY[l]) or v <= int(Y[i-j]):
                    continue
                res += pw10[N - (j+M)]
            if M + (i+1) <= N:
                res += v * pw10[N - (M + i+1)] * (N - (i+1) - M + 1) % MOD
            if i-M+1 >= 0 and hx.get(i-M+1, i+1) == hY[M]:
                cur += 1
        for j in range(N-M+1):
            if hx.get(j, j+M) != hY[M]:
                continue
            res += 1
        if Y == "0":
            for i in range(1, N):
                res -= 9 * pw10[N - i - 1] * i % MOD
            res -= N - 1
        return res % MOD
    ans = calc(B, C)
    a = int(A)
    if a > 0:
        A = str(a-1)
        ans -= calc(A, C)
    write("%d\n" % (ans % MOD))
solve()


Measured memory_bytes: 6824
N,D=map(int,input().split())
X=[list(map( int , input().split())) for i in range(N)]

ans=0
for i in range(N):
    for j in range(i+1,N):
        distance2=0
        for k in range(D):
            distance2+=(X[i][k]-X[j][k])**2
        distance=(distance2)**0.5
        if distance%1==0:
            ans+=1

print(ans)

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

int main(){
    long long n;
    cin >> n;
    
    vector<long long> a(5);
    rep(i, 5){
        cin >> a.at(i);
    }
    sort(a.begin(), a.end());
    
    long long res;
    res = n/a.at(0) + 4;
    if(n%a.at(0)) res++;

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = numeric_limits<ll>::max();;
const int INT_INF = 1 << 30;
const double PI = acos(-1.0);
#define MOD 1000000007LL
#define endl "\n"

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll T;
  cin >> T;
  
  while(T--){
    ll N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    map<ll, ll> memo;
    memo[0LL] = 0LL;
    function<ll(ll)> func = [&](ll NN){
      if(memo.count(NN)) return memo[NN];
      if(NN == 1) return memo[1] = D;

      ll ans;
      if(INF / NN <= D) ans = INF;
      else ans = NN * D;
      if(NN % 2LL == 0LL){
        ll res = A + func(NN/2LL);
        chmin(ans, res);
      }
      else{
        ll res1 = D + A + func((NN+1LL)/2LL);
        chmin(ans, res1);
        ll res2 = D + A + func((NN-1LL)/2LL);
        chmin(ans, res2);
      }

      if(NN % 3LL == 0LL){
        ll res = B + func(NN/3LL);
        chmin(ans, res);
      }
      else if(NN % 3LL == 1LL){
       ll res1 = 2LL * D + B + func((NN+2LL)/3LL);
        chmin(ans, res1);
        ll res2 = 1LL * D + B + func((NN-1LL)/3LL);
        chmin(ans, res2);
      }
      else{
        ll res1 = D + B + func((NN+1LL)/3LL);
        chmin(ans, res1);
        ll res2 = 2LL * D + B + func((NN-2LL)/3LL);
        chmin(ans, res2);
      }

      if(NN % 5LL == 0LL){
        ll res = C + func(NN/5LL);
        chmin(ans, res);
      }
      else if(NN % 5LL == 1LL){
        ll res1 = 4LL * D + C + func((NN+4LL)/5LL);
        chmin(ans, res1);
        ll res2 = 1LL * D + C + func((NN-1LL)/5LL);
        chmin(ans, res2);
      }
      else if(NN % 5LL == 2LL){
        ll res1 = 3LL * D + C + func((NN+3LL)/5LL);
        chmin(ans, res1);
        ll res2 = 2LL * D + C + func((NN-2LL)/5LL);
        chmin(ans, res2);
      }
      else if(NN % 5LL == 3LL){
        ll res1 = 2LL * D + C + func((NN+2LL)/5LL);
        chmin(ans, res1);
        ll res2 = 3LL * D + C + func((NN-3LL)/5LL);
        chmin(ans, res2);
      }
      else{
        ll res1 = 1LL * D + C + func((NN+1LL)/5LL);
        chmin(ans, res1);
        ll res2 = 4LL * D + C + func((NN-4LL)/5LL);
        chmin(ans, res2);
      }

      return memo[NN] = ans;
    };
    cout << func(N) << endl;
  }
}


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

using namespace std;

int main()
{
	int w, h;
	string c;
	cin >> w >> h >> c;
	for (int i = 0; i < h; i++)
	{
		for (int j = 0; j < w; j++)
			if ((i == 0 && j == 0) || (i == h - 1 && j == 0) || (i == 0 && j == w - 1) || (i == h - 1 && j == w - 1))
				cout << "+";
			else if (i == 0 || i == h - 1)
				cout << "-";
			else if (j == 0 || j == w - 1)
				cout << "|";
			else if (i == (h - 1) / 2 && j == (w - 1) / 2)
				cout << c;
			else
				cout << ".";
		cout << endl;
	}

	return 0;
}


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

int main() {
    vector<int> v(5);
    
    int ans = 0;
    rep(i, 5) {
        cin >> v[i];
        if (v[i] == 0) ans = i + 1;
    }

    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 3620
#encoding:utf-8

n,m = map(int, input().split())
P = []
Y = []
city_tb = []
for i in range(m):
    p,y = map(int,input().split())
    P.append(p)
    Y.append(y)
    city_tb.append([p,y])

city_tb_ = sorted(city_tb,key=lambda x:x[1])
# print(city_tb_)

count_cities = [0 for i in range(n+1)]
city_cla = {}
for i in range(m):
    count_cities[city_tb_[i][0]] += 1
    city_cla[str(city_tb_[i][0])+str(city_tb_[i][1])]='{:06d}'.format(city_tb_[i][0])+'{:06d}'.format(count_cities[city_tb_[i][0]])

for i in range(m):
    print(city_cla[str(P[i])+str(Y[i])])


Measured memory_bytes: 43208
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let mut vec: Vec<i32> = read_split_line();
    loop {
        vec[2] -= vec[1];
        vec[0] -= vec[3];
        if vec[2] <= 0 {
            println!("{}", "Yes");
            break;
        }
        if vec[0] <= 0{
            println!("{}", "No");
            break;
        }
    }
}

#[allow(dead_code)]
fn read_elem<T: FromStr>() -> T {
    let mut l = String::new();
    stdin().read_line(&mut l).unwrap();
    l.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_n_elems<T: FromStr>() -> Vec<T> {
    let n = read_elem::<u32>();
    let mut vec: Vec<T> = vec![];
    for _i in 0..n {
        vec.push(read_elem::<T>());
    }
    vec
}

#[allow(dead_code)]
fn read_split_line<T: FromStr>() -> Vec<T> {
    let mut l = String::new();
    stdin().read_line(&mut l).unwrap();
    l.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}


Measured memory_bytes: 2108
import sys
input = sys.stdin.readline
n,m = map(int, input().split())
es = [[] for _ in range(n)]
for i in range(m):
    a,b=map(int, input().split())
    es[a].append(b)

# Strongly Connected Component
def scc(n_node,es): # DFSを2回行う
    esinv = [[] for _ in range(n_node)]
    for i in range(n_node):
        for e in es[i]:
            esinv[e].append(i)
    used = [False]*n_node
    dim = [len(es[i]) for i in range(n_node)]
    order = []
    for st in range(n_node): # DFS 1回目, postorderを求める
        if not used[st]:
            stack = [(st, 0)] # [(index, 既に辿ったエッジの数)]
            while stack:
                now, i = stack.pop() 
                if not i and used[now]:
                    continue
                else:
                    used[now] = True
                    if i < dim[now]: # nowから延びるエッジを辿りきってない
                        stack.append((now,i+1))
                        stack.append((es[now][i],0))
                    else: # nowから延びる全てのエッジを辿った
                        order.append(now)
    res = [-1]*n_node # 各ノードが所属するグループのidを保存
    used = [False]*n_node 
    cnt = -1 # idカウンター
    for st in order[::-1]:  # DFS 2回目, postorderの逆順から
        if not used[st]:    # 逆向き矢印を辿って通れるノードを記録していく
            cnt += 1
            stack = [st]
            res[st] = cnt
            used[st] = True
            while stack:
                now = stack.pop()
                for e in esinv[now]:
                    if not used[e]:
                        used[e] = True
                        res[e] = cnt
                        stack.append(e)
    n_group = cnt+1
    components = [[] for _ in range(n_group)]
    for i in range(n_node):
        components[res[i]].append(i)
    return components # 各グループのノード

comp=scc(n,es)
row=len(comp)
print(row)
for i in range(row):
    length = len(comp[i])
    print(length, *comp[i])


Measured memory_bytes: 250332
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>
#include <queue>

using namespace std;
typedef long long ll;
using Graph = vector<vector<ll>>;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

int main() {
    ll A,B,C;
    cin >> A >> B >> C;
    cout << A*B/2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>

using namespace std;

int main(){
  int a,b;
  cin >> a >> b;
  
  int diff=b-a;
  int A_tall=0;
  for(int i=1;i<diff;i++){
    A_tall+=i;
  }
  cout << A_tall - a << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int a,b,c,d;
  scanf("%d%d%d",&a,&b,&c);
  for(a;a<b+1;a++)
    {
      if(c%a==0)d++;
    }
  printf("%d\n",d);
  return 0;
}



Measured memory_bytes: 2080
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include <iostream>
using namespace std;
 
struct Node
{
    int key;
    Node *right, *left, *parent;        
};
 
Node *root, *NIL;
 
Node * find(Node *u, int k)
{
    while(u != NIL && k != u->key)
    {
        if(k < u->key)
        {
            u = u->left;
        }
        else
        {
            u = u->right;
        }
    }
 
     return u;
}
 
void insert(int k)
{
    Node *y=NIL;
    Node *x=root;
    Node *z;
 
    z=(Node *)malloc(sizeof(Node));
    z->key=k;
    z->left=NIL;
    z->right=NIL;
 
    while(x !=  NIL)
    {
        y=x;
        if(z->key < x->key)
        {
            x= x->left;
        }
        else
        {
            x= x->right;
        }
    }
 
    z->parent=y;
    if(y==NIL)
    {
        root=z;
    }
    else
    {
        if(z->key < y->key)
        {
            y->left=z;
        }
        else
        {
            y->right=z;
        }
    }
}
 
void inorder(Node *u)
{
    if(u == NIL) return;
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
}
 
void preorder(Node *u)
{
    if(u == NIL) return;
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
}
 
int main()
{
    int n,i,x;
    string com;
 
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        cin >> com;
        if(com == "find")
        {
            scanf("%d",&x);
            Node *t = find(root ,x);
            if(t != NIL)
            {
                printf("yes\n");
            }
            else
            {
                printf("no\n");
            }
        }
        else if(com == "insert")
        {
            scanf("%d", &x);
            insert(x);
        }
        else if(com == "print")
        {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }
 
    return 0;
}


Measured memory_bytes: 22020
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;

int D,G;
vector<int> p(10,0);
vector<int> c(10,0);
int search(vector<int> vec, int pnt, int cnt){
    int size = vec.size();
    if(size==D){
        int min_=100000;
        for(int i=0; i<size; i++){
            int tmp=G-pnt;
            if(tmp<=0){
                return cnt;
            }
            if(vec[i]==0){
                for(int j=0; j<p[i]-1; j++){
                    tmp-=100*(i+1);
                    if(tmp<=0){
                        min_=min(min_,j+1);
                        break;
                    }
                }
            }
        }
        return cnt+min_;
    }

    vec.push_back(0);
    int min_=search(vec, pnt, cnt);
    vec.pop_back();
    vec.push_back(1);
    min_=min(min_,search(vec, pnt+100*p[size]*(size+1)+c[size], cnt+p[size]));
    return min_;

}

int main(){
    cin >> D >> G;

    for(int i=0; i<D; i++){
        cin >> p[i] >> c[i];
    }

    int ans = search({}, 0, 0);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  int n, a; cin >> n >> a;
  V<> x(n); for (int i = 0; i < n; i++) cin >> x[i];
  V<> y(n);
  for (int i = 0; i < n; i++) y[i] = abs(x[i] - a);
  auto gcd = [](int a, int b) { return __gcd(a, b); };
  int res = accumulate(y.begin(), y.end(), 0, gcd);
  cout << res << '\n';
}

Measured memory_bytes: 1024
import sys
def input(): return sys.stdin.readline().rstrip()
import heapq
def main():
    n,m=map(int,input().split())
    A=[int(_) for _ in input().split()]
    A=list(map(lambda x:-x,A))
    heapq.heapify(A)
    for _ in range(m):
        x=heapq.heappop(A)
        heapq.heappush(A,-(-x//2))
    print(-sum(A))

if __name__=='__main__':
    main()

Measured memory_bytes: 14180
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub


import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


def eratosthenes(n):
    p = []
    t = [0] * n

    for i in range(2, int(math.ceil(math.sqrt(n)))):
        if t[i] == 0:
            p.append(i)
            t[i] = i
            for j in range(2*i, n, i):
                if t[j] == 0:
                    t[j] = i

    for j in range(i+1, n):
        if t[j] == j or t[j] == 0:
            p.append(j)
            t[j] = j

    return p, t


@mt
def slv(N, A):
    P, T = eratosthenes(10**6+1)
    P = set(P)

    used = set()
    for a in A:
        while a != 1:
            p = T[a]
            if p in used:
                break
            while a % p == 0:
                a //= p
            used.add(p)
        if a != 1:
            break

    else:
        return 'pairwise coprime'

    g = 0
    for a in A:
        g = math.gcd(a, g)
    return 'setwise coprime' if g == 1 else 'not coprime'


def main():
    N = read_int()
    A = read_int_n()
    print(slv(N, A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 204032
N,C = map(int,input().split())
DP = [[0]*C for i in range(10**5+1)]
for i in range(N):
    s,t,c = map(int,input().split())
    DP[s][c-1] = t-s+1
ans = 0
for i in range(10**5):
    hoge = 0
    for j in range(C):
        DP[i+1][j] = max(DP[i][j]-1,DP[i+1][j])
        if DP[i][j]: hoge += 1
    ans = max(ans,hoge)

print(ans)


Measured memory_bytes: 79836
#include "bits/stdc++.h"
using namespace std;

#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); 

#define int  long long int
#define pb push_back
#define fe first
#define lb lower_bound 
#define ub upper_bound
#define pii pair<pair<int,int>,pair<int,int> >
#define se second
#define endl "\n"
#define pi pair<int, int>
#define vi vector<int> 
#define vvi vector<vi>
#define bs   binary_search
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,a,b) for(int i=a;i<=b;i++)	
#define all(c) (c).begin(),(c).end()
#define sz(x)       (int)x.size() 
#define PI 3.14159265358979323846

const int N =1e3;

int mod= 1e9+7;
int dx[4]={0,0,+1,-1};
int dy[4]={+1,-1,0,0};



void solve(){
   int n;
   cin>>n;

   vector<vi> a(n,vi (3,0)),dp(n,vi (3,0));

     rep(i,0,n){
	    rep(j,0,3){
		  cin>>a[i][j];
		}
	 }

	 rep(i,0,3){
	  dp[n-1][i]=a[n-1][i];
	 }

	 for(int i=n-2;i>=0;i--){
		
		rep(j,0,3){
			int ans=0;
		  rep(k,0,3){
		    if(k!=j)
			 ans = max(dp[i+1][k]+a[i][j],ans); 
		  }
		  dp[i][j]=ans;
		}
	 }

    int maxi = 0;

	rep(i,0,3){
       maxi=max(dp[0][i],maxi);
	}
	cout<<maxi<<endl;

}



int32_t main() {
	cool;
	int t=1;
	//cin>>t;
	while(t--)
		solve();


	return 0;	   
}


Measured memory_bytes: 11264
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()

#define endl "\n"
#define pb push_back
#define elif else if
#define cout_db cout << fixed

#define MOD 1000000007LL
#define PI 3.1415926

typedef long long ll;

template <typename T>
inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T>
inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T>
inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T>
inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T>
inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

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

	int n[4];
	cin >> n[0] >> n[1] >> n[2] >> n[3];
	bool a[4] = {0,0,0,0};
	for (int i = 0; i < 4; i++) {
		if(n[i] == 1) a[0]=1;
		if(n[i] == 9) a[1]=1;
		if(n[i] == 7) a[2]=1;
		if(n[i] == 4) a[3]=1;
	}
	for (int i = 0; i < 4; i++) {
		if(!a[i]){
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <cmath>
#include <complex>
#include <map>
using namespace std;

#define rep(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second

static const double PI=6*asin(0.5);
typedef pair<double,double> P;
typedef complex<double> CP;
typedef long long ll;

int n;
double x,y;
double co=1;
double si;
double ang;
int main(){
	while(cin>>n,n!=-1){
		n--;
		x=1.0; y=0.0;
		ang=0;
		co=1;
		rep(i,n){
			int pos;
			if(x>=0&&y>=0) pos=1;
			else if(x<0&&y>=0) pos=2;
			else if(x<0&&y<0) pos=3;
			else pos=4;
			double co1;
			double dist1=sqrt(x*x+y*y);
			double dist2=sqrt(1+x*x+y*y);
			co1=dist1/dist2;
			ang+=acos(co1);
			co=cos(ang);
			si=sin(ang);
			x=dist2*co;
			y=dist2*si;
			//cout<<dist1<<" "<<dist2<<" "<<co<<" "<<si<<" x "<<x<<" y "<<y<<endl;
		}
		printf("%.2f\n%.2f\n",x,y);
		//cout<<x<<endl<<y<<endl;
	}
	return 0;
}

Measured memory_bytes: 1248
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void){
	int a=0, b=0;
	char c;
	while((c=getchar())!=10) if(c=='0') a++; else b++;
	printf("%d\n", (a<b?a:b)*2);
}


Measured memory_bytes: 128
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc= new Scanner(System.in);
        int n = sc.nextInt();
        int a[][] = new int[n][2];
        for(int i=0;i<n;i++){
        		a[i][0] = sc.nextInt();
        		a[i][1] = sc.nextInt();	
        }
        String b = "No";
        for(int i=0;i<n-2;i++){
        	if(a[i][0] == a[i][1] && a[i+1][0] == a[i+1][1]&&a[i+2][0] == a[i+2][1]){
        		b = "Yes";
        		break;
        	}
        }
        System.out.println(b);
    }
}

Measured memory_bytes: 36024
#include <bits/stdc++.h>
using namespace std;
#define int long long int
char grid[105][105];
int r[105];
int c[105];
int32_t main(){
	int h,w;cin>>h>>w;
	for(int i=1;i<=h;i++){
		cin>>grid[i]+1;
	}
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			if(grid[i][j]=='#'){
				r[i]=1;
				c[j]=1;
			}
		}
	}
	for(int i=1;i<=h;i++){
		if(r[i]){
			for(int j=1;j<=w;j++){
				if(c[j]) cout<<grid[i][j];
			}
			cout<<"\n";
		}
	}
}


Measured memory_bytes: 256
#pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
#define dbg(x) cout << #x"=" << x << endl; 
const int MAX_N = 1e5+100;
int N;
int A[MAX_N];

int main(){ 
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0); cin.tie(0);
    cin >> N;
    for(int i = 1; i <= N; ++i){
        cin >> A[i];
    }
    A[0] = -2*1e9;
    for(int i = 1; i < N; ++i){
        if(A[i]-1 <= A[i+1] && A[i]-1 >= A[i-1]){
            --A[i];
        }
    }
    bool ok = true;
    for(int i = 2; i <= N; ++i){
        if(A[i] < A[i-1]) {
            ok = false;
            break;
        }
    }
    cout << (ok ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 640
#coding:utf-8
#1_5_B 2015.4.1
while True:
    length,width = map(int,input().split())
    if (length,width) == (0,0):
        break

    for i in range(length):
        for j in range(width):
            if j == width - 1:
                print('#')
            elif i == 0 or i == length - 1 or j == 0:
                print('#', end='')
            else:
                print('.', end='')
    print()

Measured memory_bytes: 6808
import sys


def resolve(in_):
    N, X, T = map(int, next(in_).split())

    minute = 0
    tako = 0
    while tako < N:
        tako += X
        minute += T

    return minute

def main():
    answer = resolve(sys.stdin)
    print(answer)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9132
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000
	

int main(){
	
	long long A,B,V,W;
	cin>>A>>V>>B>>W;
	long long T;
	cin>>T;
	
	if(A>B)swap(A,B);
	B += T*W;
	A += T*V;
	if(B<=A){
		cout<<"YES"<<endl;
	}
	else{
		cout<<"NO"<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 3624
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)

# l[i] = (a[j] >= i を満たすjの個数)
l = [n for i in range(a[0]+1)]
for i in range(2, n+1):
    for j in range(a[-i], a[-i+1], -1):
        l[j] = n - i + 1

# 二分探索
# a[i] + a[j] >= x を満たす(i, j)がm組以上存在する最小のxを求める
start = 2 * a[-1]
stop = 2 * a[0]
while start < stop:
    i = (start + stop + 1) // 2
    num = 0
    for j in a:
        if i - j < 0:
            num += n
        elif i - j <= a[0]:
            num += l[i - j]
        else:
            break

    if num >= m:
        start = i
    else:
        stop = i - 1

num = 0
for i in a:
    if start - i < 0:
        num += n
    elif 0 <= start - i <= a[0]:
        num += l[start - i]
    else:
        break

# start <= a[i]+a[j] を満たす a[i]+a[j] を全て足す
ans = 0
for i in a:
    if start - i < 0:
        ans += 2 * i * n
    elif start - i <= a[0]:
        ans += 2 * i * l[start - i]
    else:
        break
ans -= (num - m) * start
print(ans)

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

using namespace std;

using i64 = int64_t;

const i64 MOD = 1e9+7;

const i64 INF = 1e18+7;


signed main(){
    vector<int> a(2), b(2);
    vector<int> r(1e7 + 1, 0);
    for(int  i= 0; i < 2; ++i){
        cin >> a[i] >> b[i];
        ++r[a[i]];
        --r[b[i]];
    }
    int c = 0;
    for(int i = 0; i < 1e7; ++i){
        c += (r[i] == 2);
        r[i + 1] += r[i];
    }
    cout << c << endl;
}


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

int main()
{
    int i, uniq=1;
    char s[4];

    for(i=0; i<4; i++)
    {
        cin >> s[i];
    }

    sort(s, s+4);

    for(i=0; i<3; i++)
    {
        if(s[i]!=s[i+1]) uniq++;
    }

    if(uniq==2) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <unordered_map>
using namespace std;


vector<string> split(const string &s, char delim) {
    vector<string> elems;
    string item;
    for (char ch: s) {
        if (ch == delim) {
            if (!item.empty())
                elems.push_back(item);
            item.clear();
        }
        else {
            item += ch;
        }
    }
    if (!item.empty())
        elems.push_back(item);
    return elems;
}

bool compare_by_b(tuple<int, string, int> a, tuple<int, string, int> b) {
    if(get<2>(a) != get<2>(b)){
        return get<2>(a) > get<2>(b);
    }
}

bool compare_by_string(tuple<int, string, int> a, tuple<int, string, int> b) {
    if(get<1>(a) != get<1>(b)){
        return get<1>(a) < get<1>(b);
    }else{
      	return get<2>(a) > get<2>(b);
    }
}


int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
  	cin >> n;
  	unordered_map<string, int> S;
  	int idx=0;
  	string instruction, str;
  
  	while(cin >> instruction >> str)
    {
      if(instruction == "insert") S[str] = 1;
      else
      {
        if(S[str] ==1 ) cout << "yes" << endl;
        else cout << "no" << endl;
      }
      idx++;
      if(idx == n) break;
    }
  	return 0;
}



Measured memory_bytes: 45704
s=list(input())
import math
n=len(s)
app=s[0:(n-1)//2]
down=s[(n-1)//2+1:]
a=len(app)
d=len(down)
ans="No"
cnt=0
check1=0
check2=0
if n%4==3:
	for i in range((n-1)//2):
		if s[i]==s[n-1-i]:
			cnt+=1
	for j in range((d-1)//2):
		if down[j]==down[d-1-j]:
			check1+=1
	for k in range((a-1)//2):
		if down[k]==down[a-1-k]:
			check2+=1   
	if cnt==(n-1)//2 and check1==check2==(d-1)//2:
		ans="Yes"
if n%4==1:
	for i in range((n-1)//2):
		if s[i]==s[n-1-i]:
			cnt+=1
	for j in range(d//2):
		if down[j]==down[d-1-j]:
			check1+=1
	for k in range(a//2):
		if down[k]==down[a-1-k]:
			check2+=1   
	if cnt==math.ceil((n-1)/2) and check1==check2==math.ceil((d-1)/2):
		ans="Yes"
print(ans)  

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int x, y, z;
    cin >> x >> y >> z;

    swap(x, y);
    swap(x, z);
    cout << x << ' ' << y << ' ' << z << endl;
    return 0;
}
 
 


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<list>
#include<queue>
#include<functional>
#include<limits.h>
#include<string.h>
#include<algorithm> 
using namespace std;

signed main() {
	int a, b; cin >> a >> b;
	if ((a*b) % 2)puts("Yes");
	else  puts("No");
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main()
{
  int n,i,p=0,j,s=0,r=0;
  cin>>n;
  vector<int> V(n);
  for(i=0;i<n;i++)
  {
    cin>>V[i];
    if(V[i]==1)
      ++r;
      p=max(p,V[i]);
  }
  if(r>1)
    cout<<0;
  else if(r==1)
    cout<<1;
  else
  {
  vector<int> sieve(p+1,0);
  for(i=0;i<n;i++)
  {
    if(sieve[V[i]]==0)
    {
    	sieve[V[i]]=-1;
      for(j=V[i]*2;j<=p;j+=V[i])
        sieve[j]=1;
    }
    else if(sieve[V[i]]==-1)
    sieve[V[i]]=1;
  }
  for(i=0;i<n;i++)
  {
    if(sieve[V[i]]==-1)
      ++s;
  }
  cout<<s;
  }
}

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

int main() {
    vector<bool> vis(2e6, false);
    auto f = [](int n) {
        if(n % 2) return 3 * n + 1;
        else      return n / 2;
    };
    int s;
    cin >> s;
    vis[s] = true;
    for(int i = 2; i <= 1e6; ++i) {
        s = f(s);
        if(vis[s]) {
            cout << i << endl;
            return 0;
        } else {
            vis[s] = true;
        }
    }
}

Measured memory_bytes: 512
-- https://github.com/minoki/my-atcoder-solutions
{-# LANGUAGE BangPatterns #-}
import Data.Char (isSpace)
import Data.List (unfoldr)
import Control.Monad
import Control.Monad.ST
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import qualified Data.ByteString.Char8 as BS

warshallFloyd1 :: Int -> U.Vector (Int, Int, Int) -> V.Vector (U.Vector Int)
warshallFloyd1 !n !edges = runST $ do
  !arr <- V.replicateM n (UM.replicate n (10^9+1))
  U.forM_ edges $ \(a,b,c) -> do
    UM.write (arr V.! a) b c
    UM.write (arr V.! b) a c
  forM_ [0..n-1] $ \a -> do
    UM.write (arr V.! a) a 0
  forM_ [0..n-1] $ \k -> do
    let !a_k = arr V.! k
    forM_ [0..n-1] $ \i -> do
      let !a_i = arr V.! i
      forM_ [0..n-1] $ \j -> do
        a_ik <- UM.read a_i k
        a_kj <- UM.read a_k j
        UM.modify a_i (min (a_ik + a_kj)) j
  V.mapM U.unsafeFreeze arr

warshallFloyd2 :: Int -> Int -> V.Vector (U.Vector Int) -> V.Vector (U.Vector Int)
warshallFloyd2 !n !l !graph = runST $ do
  !arr <- V.replicateM n (UM.replicate n (10^9+1))
  forM_ [0..n-1] $ \a -> do
    forM_ [0..n-1] $ \b -> do
      let v = graph V.! a U.! b
      when (v <= fromIntegral l) $ do
        UM.write (arr V.! a) b 1
    UM.write (arr V.! a) a 0
  forM_ [0..n-1] $ \k -> do
    let !a_k = arr V.! k
    forM_ [0..n-1] $ \i -> do
      let !a_i = arr V.! i
      forM_ [0..n-1] $ \j -> do
        a_ik <- UM.read a_i k
        a_kj <- UM.read a_k j
        UM.modify a_i (min (a_ik + a_kj)) j
  V.mapM U.unsafeFreeze arr

main = do
  [n,m,l] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  edges <- U.replicateM m $ do
    [a,b,c] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
    return (a-1,b-1,c)
  let !w1 = warshallFloyd1 n edges
      !w2 = warshallFloyd2 n l w1
  q <- readLn
  queries <- U.replicateM q $ do
    [s,t] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
    return (s,t)
  U.forM_ queries $ \(s,t) -> do
    let d = w2 V.! (s-1) U.! (t-1)
    print $ if d > 10^9 then -1 else d - 1
  -- BSB.hPutBuilder stdout $ mconcat [ BSB.intDec (if d > 10^9 then -1 else d - 1) <> BSB.char7 '\n' | (s,t) <- U.toList queries, let d = w2 V.! (s-1) U.! (t-1) ]


Measured memory_bytes: 7292
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let n = get!(usize);
    let aa = get!(String).split_whitespace().map(|a| a.parse::<i32>().unwrap()).collect::<Vec<_>>();

    let mut max_i = 0;
    let mut max_a = 0;
    for (i, a) in aa.iter().enumerate() {
        if a.abs() > max_a {
            max_i = i;
            max_a = a.abs();
        }
    }

    let mut rs = Vec::new();
    for i in 0..n {
        if i != max_i {
            rs.push((max_i+1, i+1));
        }
    }

    if aa[max_i] < 0 {
        for i in (1..n).rev() {
            rs.push((i+1, i));
        }
    } else {
        for i in 0..n-1 {
            rs.push((i+1, i+2));
        }
    }

    println!("{}", rs.len());
    for (x, y) in rs {
        println!("{} {}", x, y);
    }
}

Measured memory_bytes: 2120
#include <bits/stdc++.h>
#define SZ(v) int((v).size())
#define ALL(vec) begin(vec), end(vec)
using namespace std;
typedef long long i64;
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
  stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
string to_string(char c) { return "'" + string(1, c) + "'";}
string to_string(string s) { return '"' + s + '"';}
string to_string(const char* s) { return to_string((string) s);}
template<typename A> string to_string(A);
template<typename A, typename B> string to_string(pair<A, B> p){
  return "(" + to_string(p.first) + ": " + to_string(p.second) + ")";}
template<typename A> string to_string(A v) {bool f = false; string r = "{"; 
  for (auto x: v) {if (f) r += ", "; r += to_string(x); f = true;} return r += "}";}
template<typename A> string to_string(vector<vector<A>> v) {string r; 
  for (auto x: v) r += "\n" + to_string(x); return r;}
void err(istream_iterator<string>) { cerr << endl; }
template<typename T,typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " =: " << to_string(a) << "; "; err(++it, args...); }
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
int const MOD = 1e9 + 7;
long long const INF = 1e18 + 42;
/*************************************/

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  
  i64 a, b;
  cin >> a >> b;
  kek(a * b / __gcd(a, b));
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007

int main(){


	int t = 1;
	//cin >> t;
	while(t--){
		int n;
		cin >> n;
		string s;
		std::vector<int> v(4, 0);
		for(int i = 0; i < n; ++i){
			cin >> s;
			if(s == "AC") v[0]++;
			if(s == "TLE") v[1]++;
			if(s == "WA") v[2]++;
			if(s == "RE") v[3]++;
		}
		cout << "AC x " << v[0] << '\n';
		
		cout << "WA x " << v[2] << '\n';
		cout << "TLE x " << v[1] << '\n';
		cout << "RE x " << v[3] << '\n';
	}
	return 0;
}

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

int main(){
    int K,A,B;
    cin>>K>>A>>B;
    bool ans=false;
    for(int i=A;i<B+1;i++){
        if(i%K==0) ans=true;
    } 
    if(ans) cout<<"OK"<<endl;
    else cout<<"NG"<<endl;   
}

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define what_is(x) cerr << #x << " is " << x << endl;
#define MT make_tuple
#define eb emplace_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define FOR(i,n) for (int i=0;i < n ; i++)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

int main(){
	string s;
	bool e[26];
	FOR(i,26) e[i]=false;
	cin >> s;
	FOR(i,s.length()){
		e[s[i]-'a']=true;
	}
	//FOR(i,26)cout <<e[i]<<"\n";
	FOR(i,26){
		if(!e[i]){
			cout << (char)(i+97);
			return 0;
		}
	}
	cout << "None";
	return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<malloc.h>
#include<math.h>
#include<x86intrin.h>


int my_gets(char *buf,int nBuf,FILE *fp){
    int ch;

    while(--nBuf >0){
        ch=getc(fp);
        if(ch==EOF || ch=='\n')
            break;
        *(buf++)=(char)ch;
    }
    *(buf)='\0';

    return nBuf;
}

void InputIntAry(int *a,int nDigit,int N){      //nDigitは想定される最大桁数
    char *buf,*ptr;

    buf=(char*)malloc( (N*(nDigit+2)) * sizeof(char) );
    my_gets(buf,N*(nDigit+2),stdin);

    ptr=strtok(buf," ");
    while(ptr!=NULL && N-->0){
        *(a++)=atoi(ptr);
        ptr=strtok(NULL," ");
    }
    free(buf);
}

int CmpInt(const void *a, const void *b){        //b-aを返す(qsortなら4321)
    return *((int*)b)- *((int*)a);
}


int main(){
    int N,Satis=0;
    int A[20]={},B[20]={},C[20]={};

    scanf("%d%*c",&N);
    InputIntAry(A,10,N);
    InputIntAry(B,10,N);
    InputIntAry(C,10,N-1);

    int Prev=-100;
    for(int i=0;i<N;i++){
        Satis += B[A[i]-1];
        if(Prev == A[i]-1){
            Satis += C[Prev-1];
        }
        Prev = A[i];
    }
    printf("%d\n",Satis);

    return 0;
} 

Measured memory_bytes: 128
import java.util.*;

public class Main{
 	public static void main(String args[]){
    	Scanner sc = new Scanner(System.in);
      	int mod = sc.nextInt();
      	int val = 7%mod;
      	for(int i =1;i<1e7; i++){
         	if(val==0){
              	System.out.println(i);
          		return;
            }
          	val = (val*10+7)%mod;
  
          
        }
      
      	System.out.println("-1");
    } 
}


Measured memory_bytes: 35740
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define endl "\n"
const int MAX= 100005 ;
const long long mod = 1.0e9+7;
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    #endif
    int n,m,i,j,x,y;
    cin>>n;
    int f=0;
    for(i=-400;i<=400;i++)
    {
        for(j=-400;j<=400;j++)
        {
            x=(int)((int)pow(i,5)-(int)pow(j,5));
            if(x==n)
            {
                cout<<i<<" "<<j<<endl;
                f++;
                break;
            }
        }
        if(f>0)
            break;
    }
    return 0;
}

Measured memory_bytes: 4076
n = int(input())
a = list(map(int, input().split()))
sum_a = sum(a)
calc = 0
for i in range(n):
    sum_a -= a[i]
    calc += ((sum_a % 1000000007) * a[i]) % 1000000007
calc %= 1000000007
print(calc)

Measured memory_bytes: 31572
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.util.Collection;
import java.io.IOException;
import java.io.BufferedReader;
import java.util.Deque;
import java.util.LinkedList;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            boolean end = true;
            Deque<Integer> dq = new LinkedList<>();
            for (int i = 0; i < n; i++) {
                if (end) {
                    dq.addLast(in.nextInt());
                } else dq.addFirst(in.nextInt());
                end = !end;
            }
            if (end) while (!dq.isEmpty()) out.print(dq.pollFirst() + " ");
            else while (!dq.isEmpty()) out.print(dq.pollLast() + " ");
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 77892