akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define gcd(a,b)		__gcd(a,b)
#define lcm(a,b)		(a*b)/gcd(a,b)
#define ff              first
#define ss              second
#define int             long long
#define float			double
#define pb              emplace_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define vc				vector<char>
#define vb				vector<bool>
#define vf				vector<float>
#define vs				vector<string>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int>>
#define hashmap         unordered_map
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             INT64_MAX
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(x)			x.begin(),x.end()
#define digits(x)		floor(log10(x))+1
#define FIO				ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

template<class T>
void printV(vector<T> a) {for (auto v : a)cout << v << " ";}
template<class T>
void readV(vector<T>& a) {int n = a.size(); for (int i = 0 ; i < n ; i++)cin >> a[i];}
template<class T>
void printA(T* a , int n) {for (int i = 0; i < n  ; i++)cout << a[i] << " ";}
template<class T>
void readA(T* a , int n) {for (int i = 0 ; i < n ; i++)cin >> a[i];}
auto clk = clock();
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
void run_time() {cout << endl<<"Time elapsed: " << (double)(clock() - clk) / CLOCKS_PER_SEC << endl;}

void aryan_pandeya() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

  

int power(int x, unsigned int y, int p)  
{  
    int res = 1;     // Initialize result  
  
    x = x % p; // Update x if it is more than or  
                // equal to p 
   
    if (x == 0) return 0; // In case x is divisible by p; 
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}  

int32_t main() {
	aryan_pandeya();
	FIO;

	int n ;
	cin>>n ;

	if(n==1){
		cout<<0;
	}
	else if(n==2){
		cout<<2;
	}
	else{
		int ans = (power(10,n,mod)-2*power(9,n,mod)+power(8,n,mod)+2*mod)%mod;
		cout<<ans;
	}

}


Measured memory_bytes: 3592
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <deque>
#include <utility>
using namespace std;
typedef long long ll;
#define for1(i,n) for (ll i=0;i<(n);i++)
#define for2(i,m,n) for (ll i=(m);i<(n);i++)
#define for3(i,m,n,d) for (ll i=(m);i<(n);i+=(d))
#define INF (1LL << 60)

void solve()
{
    ll L,R;
    cin >> L >> R;
    // 2019 = 3 * 673
    ll L2 = L / 2019;
    ll R2 = R / 2019;
    if (L2 != R2) {
        cout << 0 << endl;
        return;
    }
    ll ans = INF;
    for2(i,L,R) {
        for2(j,i+1,R+1) {
            ans = min(ans, (i*j)%2019);
        }
    }

    cout << ans << endl;
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int SIZE=(1<<20);
int n,m,root,deg[SIZE];
vector<int> adj[SIZE];
void read()
{
	cin>>n>>m;
	for(int i=0;i<n-1+m;i++)
	{
		int u,v;
		cin>>u>>v;
		adj[u].push_back(v);
		deg[v]++;
	}
}
bool vis[SIZE];
int ans[SIZE];
void dfs(int u,int pr)
{
	vis[u]=1;
	ans[u]=pr;
	for(int v=0;v<adj[u].size();v++)
		deg[adj[u][v]]--;
	for(int v=0;v<adj[u].size();v++)
		if(!vis[adj[u][v]]&&deg[adj[u][v]]==0)
			dfs(adj[u][v],u);
}
int main()
{
	read();
	for(int i=1;i<=n;i++)
		if(!deg[i])
			root=i;
	dfs(root,0);
	for(int i=1;i<=n;i++)
		cout<<ans[i]<<endl;
	return 0;
}

Measured memory_bytes: 35584
<?php
$S = str_split(trim(fgets(STDIN)));
$count = count($S);

if($count == 1){
echo $S[0] . PHP_EOL ;
}else{
$ans = 0;
for($i = 0;$i < $count;$i++){
$copy = $S;
$n = $count - 1 - $i;
$copy[$n] *= 2;
$sum = array_sum($copy);
$pow = pow(2,$n - 1);
$rank = pow(10,$i);
$sum_i = $sum * $pow * $rank;
$ans += $sum_i;
unset($S[$n]);
}
echo $ans . PHP_EOL ;
}

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

int main () {
  int a,b;
  cin >> a>>b;
  for (int i = 0; i < 1000; i++) {
    if( b-a == i) {
      
   std::cout << (i-1)*i/2 -a << '\n';
      
      return 0;
    }
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
using namespace std;

void input_vector(int &x);
void show(int x);

/* ユークリッドの互除法 */
/* 2個の最大公約数 */
int gcd(int a, int b){
    if(a < b) std::swap(a, b);
    if(b == 0) return a;
    else
    {
        return gcd(b, a % b);
    }
}

int main(){
    int n;
    cin >> n;
    vector<int> a(n);

    for_each(a.begin(), a.end(), input_vector);

    int ans = 0;

    vector<int> L(n, 0);
    vector<int> R(n, 0);

    for(int i = 0; i < n-1; i++){
        L.at(i+1)  = gcd(L.at(i), a.at(i));
    }

    for(int i = n-1; i >= 1; i--){
        R.at(i-1) = gcd(R.at(i), a.at(i));
    }

    for(int i = 0; i < n; i++){
        ans = max(ans, gcd(L.at(i), R.at(i)));
    }

    cout << ans << endl;
}

void input_vector(int &x){
    cin >> x;
}
void show(int x){
    cout << x << " ";
}

Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <queue>

typedef long long ll;
const ll LL_MAX (1LL<<60);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

ll gcd (ll a, ll b)
{
    if (b == 0) return a; 
    return gcd(b, a%b);
}

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

    ll a, b;
    cin >> a >> b;

    //cout << gcd(a, b) << endl;    
    cout << a * b / gcd(a, b) << endl;

    return 0;
}


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

int getdigit(int N){
  int digit = 0;
  while (N>0) {
    N/=10;
    digit++;
  }
  return digit;
}

int main(){
  int N;
  cin >> N;
  int ans = getdigit(N);

  if (ans == 2) {
    cout << 9 << endl;
  }
  if (ans == 4) {
    cout << 909 << endl;
  }

  if (ans == 1) {
    cout << N << endl;
  }

  if (ans == 3) {
    cout << 9 + N - 99 << endl;
  }

  if (ans == 5) {
    cout << 909 + N - 9999 << endl;
  }

  if (ans ==  6) {
    cout << 90909 << endl;
  }



}


Measured memory_bytes: 256
import bisect
n = int(input())
l = sorted(list(map(int,input().split())))
cou =0
for i in range(0,n-2):
  for j in range(i+1,n-1):
    #iがaの長さ、jがbの長さ
    m = l[i]
    u = l[j]
    c =bisect.bisect_left(l,m+u)
    if c>j+1:
      cou += c-j-1
print(cou)
    

Measured memory_bytes: 3188
n=int(input())

dp=[set([0]) for i in range(101)]
dp[0]=set([0])
for i in range(n):
    s=int(input())
    for l in dp[i]:
        dp[i+1].add(l+s)
        dp[i+1].add(l)
A=sorted(list(dp[n]),reverse=1)
#print(A)
#print(dp)
for i in A:
    if i%10!=0:
        print(i);exit()
else:
    print(0)


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

#define REP(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
#define LINF LLONG_MAX/3
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(v) (v).begin(),(v).end()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
#define CININIT cin.tie(0),ios::sync_with_stdio(false)
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;


char f(char c){
    char nc = c+1;
    if(nc>'z') nc='a';
    return nc;
}

int t = 'z'-'a';

int main(){
    CININIT;

    string s;
    cin >> s;
    ll K;
    cin>>K;

    int N=s.size();
    for(int i=0;i<N;i++){
        if(s[i]=='a') continue;
        char c = s[i];
        ll num1 = 'z'+1-c;     // to 'a'
        int num = min(K,num1);
        if(num1 <= K){
            s[i] = 'a';
            K -= num1;
        }else{
            continue;
        }
    }


    debug(s);

    if(K>0){
        for(int i=0;i<N;i++){
            if(s[i]=='a'){
                K %= t+1;
                break;
            }
        }

        for(int i=N-1;i>=0;i--){
            int num = 'z'-s[i];
            if(num <= K){
                K -= num;
                s[i] = 'z';
            }else{
                s[i] += K;
                break;
            }
        }
    }

    cout << s << endl;
}


Measured memory_bytes: 592
def resolve():
    s = input()
    t = input()
    ans = 10**4

    for i in range(len(s)-len(t)+1):
        ch = 0
        for j in range(len(t)):
            if s[i+j] != t[j]:
                ch += 1
        ans = min(ch, ans)
    print(ans)

resolve()

Measured memory_bytes: 67672
import itertools

def divisor(n):
    ass = []
    for i in range(1,int(n**0.5)+1):
        if n%i == 0:
            ass.append(i)
            if i**2 == n:
                continue
            ass.append(n//i)
    return ass

def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

def main():
    A, B = map(int, input().split())

    div_A = divisor(A)
    div_B = divisor(B)
    C = list(set(div_A) & set(div_B))
    cnt = 1
    for c in C:
        if is_prime(c):
            cnt += 1

    print(cnt)

main()

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

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define int long long

int dx[6] = {-1, -1, 0, 0, 1, 1};
int dy[6] = {-1, 0, -1, 1, 0, 1};
int A[15][15];
int N, C;
int B[15][15];
bool notdel[15][15];
bool vis[15][15];
using pii = pair<int, int>;
int calc() {
    int ret = 0;
    REP(i, N + 1) REP(j, N + 1) {
        vis[i][j] = false;
        notdel[i][j] = false;
    }
    queue<pii> que;
    REP(i, N) {
        REP(j, i + 1) {
            if (vis[i][j]) continue;
            if (B[i][j] == 0) {
                notdel[i][j] = true;
                // queue<pii> que;
                REP(k, 6) {
                    int nx = i + dx[k];
                    int ny = j + dy[k];
                    if (nx < 0 || nx >= N || ny < 0 || ny > nx) continue;
                    if (B[nx][ny] == 0) continue;
                    if (vis[nx][ny]) continue;
                    que.push({nx, ny});
                    notdel[nx][ny] = true;
                }
            }
        }
    }
    while (!que.empty()) {
        pii p = que.front();
        que.pop();
        int x = p.first, y = p.second;
        // if (vis[x][y]) continue;
        vis[x][y] = true;
        notdel[x][y] = true;
        REP(k, 6) {
            int nx = x + dx[k];
            int ny = y + dy[k];
            if (nx < 0 || nx >= N || ny < 0 || ny > nx) continue;
            if (vis[nx][ny]) continue;
            if (B[nx][ny] == B[x][y]) {
                que.push({nx, ny});
            }
        }
    }
    // REP(i, N) {
    //     REP(j, i + 1) {
    //         cerr << B[i][j];
    //         if (notdel[i][j])
    //             cerr << "!";
    //         else
    //             cerr << " ";
    //     }
    //     cout << endl;
    // }

    REP(i, N) {
        REP(j, i + 1) {
            if (notdel[i][j]) continue;
            if (B[i][j] == C)
                ret--;
            else
                ret++;
        }
    }

    return ret;
}
bool solve() {
    cin >> N >> C;
    if (N == 0) return false;
    REP(i, N + 1) REP(j, N + 1) A[i][j] = 0;
    REP(i, N) {
        REP(j, i + 1) { cin >> A[i][j]; }
    }
    int ans = -1e9;
    REP(i, N) {
        REP(j, i + 1) {
            if (A[i][j] == 0) {
                REP(k, N + 1) REP(l, N + 1) B[k][l] = A[k][l];
                B[i][j] = C;
                ans = max(ans, calc());
            }
        }
    }
    cout << ans << endl;
    return true;
}
signed main() {
    while (solve())
        ;
}


Measured memory_bytes: 3000
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
using namespace std;
struct P {
	long long cost, pos;
};
struct B {
	long long to, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
long long a[3001];
vector<B>e[3001];
long long shop[3001];
const long long inf = 8000000000;
int main() {
	long long n, m, k;
	cin >> n >> m >> k;
	fill(a, a + n + 1, inf);
	for (int i = 0; i < m; i++) {
		int a, b, cost;
		cin >> a >> b >> cost;
		e[a].push_back(B{ b,cost });
		e[b].push_back(B{ a,cost });
	}
	for (int i = 0; i < k; i++) {
		cin >> shop[i];
		a[shop[i]] = 0;
	}
	for (int z = 0; z < k; z++) {
		priority_queue<P, vector<P>, greater<P>>p;
		p.push(P{ 0,shop[z] });
		while (!p.empty()) {
			P t = p.top(); p.pop();
			for (int i = 0; i < (int)e[t.pos].size(); i++) {
				if (a[e[t.pos][i].to] > a[t.pos] + e[t.pos][i].cost) {
					a[e[t.pos][i].to] = a[t.pos] + e[t.pos][i].cost;
					p.push(P{ a[e[t.pos][i].to],e[t.pos][i].to });
				}
			}
		}
	}
	double sum = 0, sum2,f;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j < (int)e[i].size(); j++) {
			sum = max(max(sum,(double)a[i]), (double)(a[i] + a[e[i][j].to] + e[i][j].cost)/2.0);
		}
	}
	cout << round(sum) << endl;
}

Measured memory_bytes: 8988
#include <stdio.h>
#include <string.h>
#include <math.h>
int main(){
	int n, a,b;
	scanf("%d %d %d", &n, &a, &b);
	if(n*a < b){
		printf("%d\n", a*n);
	}else{
		printf("%d\n", b);
	}
	return 0;
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws NumberFormatException,
			IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));
		StringBuilder builder = new StringBuilder();
		int[] yama = new int[10];
		for (int i = 0; i < 10; i++) {
			yama[i] = Integer.parseInt(reader.readLine());
		}
		Arrays.sort(yama);
		for (int i = 9; i > 6; i--) {
			builder.append(yama[i]).append('\n');
		}
		System.out.print(builder);
	}
}

Measured memory_bytes: 16872
using System.Linq;
using System.Collections.Generic;
using System;

public class P
{
    public List<int> from { get; set; }
    public List<int> to { get; set; }
}

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var e = int.Parse(line[1]);
        var d = new Dictionary<int, P>();
        for (int i = 0; i < n; i++) d[i] = new P { from = new List<int>(), to = new List<int>() };
        for (int i = 0; i < e; i++)
        {
            line = Console.ReadLine().Trim().Split(' ');
            var s = int.Parse(line[0]);
            var t = int.Parse(line[1]);
            d[s].to.Add(t);
            d[t].from.Add(s);
        }
        Console.WriteLine(checkCycle(d, n) ? 1 : 0);
    }
    public static bool checkCycle(Dictionary<int, P> d, int n)
    {
        var q = new Queue<int>();
        var check = new int[n];
        for (int i = 0; i < n; i++) q.Enqueue(i);
        while (q.Count() > 0)
        {
            var w = q.Dequeue();
            if (d[w].from.Count == 0)
            {
                foreach (var x in d[w].to) d[x].from.Remove(w);
            }
            else
            {
                check[w]++;
                if (check[w] == 20) return true;
                else q.Enqueue(w);
            }
        }
        return false;
    }
}




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

int main()
{
  int n;
  cin >> n;
  vector <int> a(n);
  for (int i = 0; i < n; i++){
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  int score_a = 0, score_b = 0, ans = 0;
  for (int i = 0; i < n; i += 2){
    score_a += a.at(i);
  }
  for (int i = 1; i < n; i += 2){
    score_b += a.at(i);
  }
  cout << score_a - score_b << endl;
}

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


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int s = sc.nextInt();

		Set<Integer> hs = new HashSet<>();
		hs.add(s);
		for (int i = 2, prev = s; true; i++) {
			int a = prev % 2 == 0 ? prev / 2 : 3 * prev + 1;
			if (!hs.add(a)) {
				pr.println(i);
				break;
			}
			
			prev = a;
		}
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);
			
		solve();
			
		pr.close();
		sc.close();
	}

	static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 21844
/** Which of the favors of your Lord will you deny ? **/

#include<bits/stdc++.h>
using namespace std;

#define LL long long
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define F first
#define S second

#define ALL(x)      (x).begin(), (x).end()
#define READ        freopen("alu.txt", "r", stdin)
#define WRITE       freopen("vorta.txt", "w", stdout)

#ifndef ONLINE_JUDGE
#define DBG(x)      cout << __LINE__ << " says: " << #x << " = " << (x) << endl
#else
#define DBG(x)
#define endl "\n"
#endif

template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p);
template <class T>
ostream &operator <<(ostream &os, vector<T>&v);
template <class T>
ostream &operator <<(ostream &os, set<T>&v);

inline void optimizeIO()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

const int nmax = 2e5+7;

int main()
{
    optimizeIO();

    int n;
    cin>>n;

    vector<int>v(n);
    for(int i=0;i<n;i++) cin>>v[i];

    int m;
    cin>>m;

    int s = 0;
    for(int x:v) s +=x;

    while(m--)
    {
        int pos,val;
        cin>>pos>>val;

        pos--;

        int ts = s;
        ts -= v[pos];
        ts += val;
        cout<<ts<<endl;
    }

    return 0;
}

/**

**/

template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p)
{
    os<<"{"<<p.first<<", "<<p.second<<"} ";
    return os;
}
template <class T>
ostream &operator <<(ostream &os, vector<T>&v)
{
    os<<"[ ";
    for(T i:v)
    {
        os<<i<<" " ;
    }
    os<<" ]";
    return os;
}

template <class T>
ostream &operator <<(ostream &os, set<T>&v)
{
    os<<"[ ";
    for(T i:v)
    {
        os<<i<<" ";
    }
    os<<" ]";
    return os;
}


Measured memory_bytes: 3656
#include <iostream>
using namespace std;

int main() {
    int N;
    cin >> N;
    bool can = true;
    int pt = 0, px = 0, py = 0; // 前回の時刻と座標
    for (int i = 0; i < N; ++i) {
        int t, x, y;
        cin >> t >> x >> y;
        int T = t - pt, X = abs(x - px), Y = abs(y - py);
        if (T < X + Y) can = false;
        if (T % 2 != (X + Y) % 2) can = false;
        pt = t, px = x, py = y;
    }
    if (can) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3576
#include<stdio.h>

int A[1000000], n;

int binarySearch(int key) {
    int left = 0;
    int right = n;
    int mid;
    while (left < right) {
        mid = (left + right) / 2;
        if (key == A[mid]) return 1;
        if (key > A[mid]) left = mid + 1;
        else if (key < A[mid]) right = mid;
    }
    return 0;
}

int main() {
    int i, q, k, sum = 0;
    
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%d", &A[i]);
    }
    
    scanf("%d", &q);
    for (i = 0; i < q; i++) {
        scanf("%d", &k);
        if (binarySearch(k)) sum++;
    }
    printf("%d\n", sum);
    
    return 0;
}


Measured memory_bytes: 2104
n = int(input())
A = [0] + list(map(int, input().split())) + [0]
C = []
c = 0
for i in range(n+1):
  c += abs(A[i+1] - A[i])
for i in range(1, n+1):
  if A[i-1] <= A[i] <= A[i+1] or A[i+1] <= A[i] <= A[i-1]:
    print(c)
  elif A[i] <=A[i-1] <= A[i+1] or A[i] <= A[i+1] <= A[i-1]:
    print(c - abs(min(A[i-1], A[i+1]) - A[i])*2)
  else:
    print(c - abs(A[i] - max(A[i+1], A[i-1]))*2)

Measured memory_bytes: 13920
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
    while(1){
        ll w,h; cin >> w >> h;
        if(w+h == 0) break;
        vs s(h);
        rep(i,h) cin >> s[i];
        vector<vs> dp(h,vs(w,""));
        rep(i,h){
            rep(j,w){
                if('A'<=s[i][j] && s[i][j]<='Z') continue;
                if(j>0){
                    if(dp[i][j].size() < dp[i][j-1].size()) dp[i][j] = dp[i][j-1];
                    else if(dp[i][j].size()==dp[i][j-1].size()){
                        chmax(dp[i][j], dp[i][j-1]);
                    }
                }
                if(i>0){
                    if(dp[i][j].size() < dp[i-1][j].size()) dp[i][j] = dp[i-1][j];
                    else if(dp[i][j].size()==dp[i-1][j].size()){
                        chmax(dp[i][j], dp[i-1][j]);
                    }
                }
                if(dp[i][j]=="" && s[i][j]=='0') continue;
                dp[i][j].push_back(s[i][j]);
            }
        }
        string ans = "";
        rep(i,h) rep(j,w){
            if(ans.size() < dp[i][j].size()) ans = dp[i][j];
            else if(ans.size() == dp[i][j].size()) chmax(ans, dp[i][j]);
        }
        cout << ans << "\n";
    }
}


Measured memory_bytes: 3248
/**
* Author : zzy
* Date : 2020-04-19-20.11.10 Sunday
*/
#include <bits/stdc++.h>

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, a, b) for (int i = (int)(a); i >= (int)b; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, r, l) for (int i = (r); i >= (l); i--)
#define ms(x, y) memset(x, y, sizeof(x))
#define SZ(x) ((int)(x).size())

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

const i64 maxn = 2*(int)1e5+1000;
const i64 mod = (int)1e9+7;

i64 fac[maxn],inv[maxn];
i64 pow_mod(i64 a,i64 n)
{
    i64 ret =1;
    while(n)
    {
        if(n&1) ret=ret*a%mod;
          a=a*a%mod;
          n>>=1;
    }
    return ret;
}
void init()
{
    fac[0]=1;
    for(i64 i=1;i<maxn;i++)
    {
        fac[i]=fac[i-1]*i%mod;
    }
}
i64 CC(i64 x, i64 y)
{
    return fac[x]*pow_mod(fac[y]*fac[x-y]%mod,mod-2)%mod;
}

i64 n, k;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "r", stdin);
#endif

    init();
    cin >> n >> k;
    i64 ans = 0;
    for (i64 i = k; i <= n+1; ++i) {
        i64 lf, rt;
        lf = (i-1)*i/2;
        rt = (n+n-i+1)*i/2;
        ans = (ans+(rt-lf+1))%mod;
    }
    //if (k <= 2) ans = (ans-(n+1-4+1)+mod)%mod;
    cout << ans << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 5224
#include <iostream>
using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	int ans = a + b;
	if (ans % 2 == 0) {
		ans = ans / 2;
		cout << ans << endl ;
		return 0;
	}
	else {
		ans = ans / 2;
		cout << ans + 1 << endl;
		return 0;
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MAX_NODE 100

int allOK(int* begin, int* end) {
	for (;begin < end; begin++) {
		if ((*begin) & 1) {
			return 0;
		}
	}
	return 1;
}

int main() {
	int nodes[MAX_NODE + 1];
	int last = 0, from, to;
	memset(nodes, 0, sizeof(nodes));
	
	while (scanf("%d %d", &from, &to) != EOF) {
		if (from == 0 && to == 0) {
			if ((nodes[1] & 1) && (nodes[2] & 1)
					&& allOK(nodes + 3, nodes + last + 1)) {
				puts("OK");
			}
			else {
				puts("NG");
			}
			
			last = 0;
			memset(nodes, 0, sizeof(nodes));
		}
		else {
			nodes[from]++;
			nodes[to]++;
			last = MAX(last, MAX(from, to));
		}
	}
	return 0;
}

Measured memory_bytes: 584
from collections import defaultdict
L = int(input())
ans = 0
def prime_factorize(n):
    a = defaultdict(int)
    while n % 2 == 0:
        a[2] += 1
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a[f]+=1
            n //= f
        else:
            f += 2
    if n != 1:
        a[n]+=1
    return a

L_f = prime_factorize(L)
for p in L_f.values():
    k = 1
    while p  >= k :
        p -= k
        k += 1
        ans += 1
print(ans)


Measured memory_bytes: 65968
#テストファイルで実行する時
import sys
if sys.platform =='ios':
    sys.stdin=open('input_file.txt')

n,m = map(int,input().split())
a = [list(map(int,input().split()))  for i in range(n) ]

#指定した場所のリストを削除
for i in range(n):
	del a[i][0]

#2次元のリストaを1次元のリストbに変換
b = sum(a,[])

c = list(set(b))
#print(c)

ans = 0
check = 0

for i in range(len(c)):
	check = b.count(c[i])
	if check == n:
		ans = ans + 1

print(ans)



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

int main() {
	int a, b, cost;
	scanf("%d %d", &a, &b);
	if (a >= 13)
		cost = b;
	else if (a >= 6)
		cost = b / 2;
	else
		cost = 0;

	printf("%d\n", cost);
}

Measured memory_bytes: 256
# include<iostream>
# include<algorithm>
using namespace std;

int main(void)
{
    int n, x;
    int a[103];
    while(cin >> n >> x && n!=0)
    {
        int sum = 0;
        int i;
        for(i = 0; i < n; ++i)
        {
            cin >> a[i];
            sum+=a[i];
        }
        int z;
        x = x-sum;
       // cout << "x=" << x<<endl;
        z = n;
        i = 0;
        sort(a, a+n);
        while(x >= a[i])
        {
           // cout << "x=" << x <<" a[i]=" << a[i] << endl;
            z = z+(x/a[i]);
            x = x - x/a[i]*a[i];
           //  cout << "x=" << x <<" z=" << z << endl;
            i++;
        }
        cout << z << endl;
    }
    return 0;
}


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

using namespace std;

using ll = long long;

constexpr char newl = '\n';

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

    int a;
    cin >> a;
    cout << a + a * a + a * a * a << newl;

    return 0;
}

Measured memory_bytes: 3636
from bisect import bisect_left as bl


A, B, Q = list(map(int, input().split()))
S = [int(input()) for _ in range(A)]
T = [int(input()) for _ in range(B)]

for _ in range(Q):
    x = int(input())
    i = bl(S, x)
    j = bl(T, x)
    d = set()
    if i < A:
        a = S[i]
        if j < B:
            if T[j] <= a:
                d.add(a - x)
            else:
                d.add(T[j] - x)
                if j > 0:
                    k, l = a - x, x - T[j-1]
                    if k < l:
                        d.add(2 * k + l)
                    else:
                        d.add(2 * l + k)
        else:
            k, l = a - x, x - T[j-1]
            if k < l:
                d.add(2 * k + l)
            else:
                d.add(2 * l + k)
    if i > 0:
        a = S[i-1]
        if j > 0:
            if T[j-1] >= a:
                d.add(x - a)
            else:
                d.add(x - T[j-1])
                if j < B:
                    k, l = x - a, T[j] - x
                    if k < l:
                        d.add(2 * k + l)
                    else:
                        d.add(2 * l + k)
        else:
            k, l = x - a, T[j] - x
            if k < l:
                d.add(2 * k + l)
            else:
                d.add(2 * l + k)
    print(min(d))

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

#define int long long
using ll = long long;
using ull = unsigned long long;
#define repi(n) for (long long i = 0; i < (n); ++i)
#define repj(n) for (long long j = 0; j < (n); ++j)
#define repk(n) for (long long k = 0; k < (n); ++k)
#define rep(i, a, b) for (auto i = (a); i < (b); ++i)
#define itr(itr) for (auto&& v : (itr))
#define updatemax(t, v) (t = std::max(t, (v)))
#define updatemin(t, v) (t = std::min(t, (v)))

signed main() {
  ll x, k, d;
  cin >> x >> k >> d;
  x = abs(x);
  ll c = min(x / d, k);
  x -= c * d;
  k -= c;
  if (k > 0 && abs(x) > abs(x - d)) {
    x -= d;
    --k;
  }
  cout << (k % 2 ? min(abs(x + d), abs(x - d)) : abs(x)) << endl;
}


Measured memory_bytes: 3640
/* ***********************************************
Author        :yang12138
Created Time  :2017/8/8 16:12:40
File Name     :E.cpp
************************************************ */
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdlib>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
typedef long long ll;
typedef pair<int,int>pii;
#define lson (root<<1)
#define rson (root<<1|1)

const int N=2e5+10;
const int INF=1e9;

struct Seg_Tree{

	int x[N];
	int val[N<<2],id[N<<2];

	void build(int root,int l,int r){
		if(l==r){
			val[root]=x[l],id[root]=l;
			return ;
		}
		int m=(l+r)>>1;
		build(lson,l,m);
		build(rson,m+1,r);
		if(val[lson]>val[rson]) id[root]=id[rson];
		else id[root]=id[lson];
		val[root]=min(val[lson],val[rson]);
	}

	int query(int root,int l,int r,int a,int b){
		if(l==a && r==b) return id[root];

		int m=(l+r)>>1;
		if(b<=m) return query(lson,l,m,a,b);
		else if(a>m) return query(rson,m+1,r,a,b);
		else{
			int L=query(lson,l,m,a,m);
			int R=query(rson,m+1,r,m+1,b);
			if(x[L]>x[R]) return R;
			else return L;
		}
	}
}t[2];
int a[N],n;

struct Node{
	pii x,y,z;
	Node(){}
	Node(pii x,pii y,pii z){
		this->x=x;
		this->y=y;
		this->z=z;
	}
	bool operator < (const Node& tmp) const{
		return x>tmp.x;
	}
};

pii getfuck(int l,int r){
	int lid=t[l&1].query(1,1,n,l,r);
	int rid=t[!(l&1)].query(1,1,n,lid+1,r);
	return pii(lid,rid);
}

vector<pii>ans;
priority_queue<Node>que;
void solve(){

	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",a+i);

	for(int i=1;i<=n;i+=2) t[1].x[i]=a[i],t[1].x[i+1]=INF;
	for(int i=2;i<=n;i+=2) t[0].x[i]=a[i],t[0].x[i-1]=INF;

	t[0].build(1,1,n),t[1].build(1,1,n);

	pii tmp=getfuck(1,n);
	Node cur=Node(pii(a[tmp.first],a[tmp.second]),tmp,pii(1,n));
	que.push(cur);

	while(!que.empty()){
		cur=que.top();
		que.pop();

		ans.push_back(cur.x);
		pii l=cur.y,r=cur.z;

		if(r.first<l.first-1){
			tmp=getfuck(r.first,l.first-1);
			que.push(Node(pii(a[tmp.first],a[tmp.second]),tmp,pii(r.first,l.first-1)));
		}

		if(l.first+1<l.second-1){
			tmp=getfuck(l.first+1,l.second-1);
			que.push(Node(pii(a[tmp.first],a[tmp.second]),tmp,pii(l.first+1,l.second-1)));
		}

		if(l.second+1<r.second){
			tmp=getfuck(l.second+1,r.second);
			que.push(Node(pii(a[tmp.first],a[tmp.second]),tmp,pii(l.second+1,r.second)));
		}
	}

	for(int i=0;i<(int)ans.size();i++){
		printf("%d %d ",ans[i].first,ans[i].second);
	}
	printf("\n");

}

int main(){
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    
	solve();
    return 0;
}


Measured memory_bytes: 18612
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        String in = s.nextLine();
        int n = Integer.parseInt(in.split(" ")[0]);

        for (int i = 1; i <= 9; i++) {
            for (int o = 1; o <= 9; o++) {
                if (i * o == n) {
                    System.out.println("Yes");
                    return;
                }
            }
        }

        System.out.println("No");
    }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#include <set>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

#define INF 100000000

#define writeln(n) cout<<n<<endl

using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
//vector<tuple<long long, long long, long long>>vec;

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;
}

llong pownew(llong m, llong n) {
    if (n == 0) { return 1; }
    if (n % 2 == 0) { return pow(m*m, n/2); }
    return pow(m, n-1) * m;
}

bool isprime(int p) {
    if (p == 1) return false;
    for (int i = 2; i < p; i++) {
        if (p%i == 0) return false;
    }
    return true;
}

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

const int inf=100000000;

long long modpow(long long a, long long n, long long mod) //a^n
{
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

llong gcd(llong a, llong b) {
        return b != 0 ? gcd(b, a % b) : a;
}
//setprecision(10);
string str;
string target = "keyence";


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>str;
    if(str == target){
        puts("YES");
        return 0;
    }
    int n = str.size();
    for(int i=0;i<n;i++){
        for(int j=i;j<n;j++){
            //because delete [i,j]
            string S = "";
            for(int k=0;k<n;k++)
            {
                if(i<=k && k<=j)
                {
                    continue;
                }
                else S.push_back(str[k]);
            }
            if(S == target)
            {
                puts("YES");
                return 0;
            }
        }
    }
    puts("NO");
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int N = Integer.parseInt(br.readLine());
		StringBuilder sb = new StringBuilder();

		String[] set = br.readLine().split(" ");
		long[] num = new long[N];

		for(int i = 0; i < N; i++){
			num[i] = Long.parseLong(set[i]);
		}

		long min = num[0];
		long max = num[0];
		long sum = num[0];
        for (int index = 1; index < N; index++) {
            min = Math.min(min, num[index]);
            max = Math.max(max, num[index]);
            sum += num[index];
        }
        System.out.print(sb.append(min).append(" ").append(max).append(" ").append(sum).append("\n"));
	}

}

Measured memory_bytes: 28400
'use strict';

const input = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
let Nums = input.shift();
let N = Nums.split(" ")[0];
let K = Nums.split(" ")[1];
let Q = Nums.split(" ")[2];
let Aarr = input.map(x => x*1);
// この人数分だけyesの数は出るっぽい
let diff = Q - K;
if(diff < 0){
  for(let i = 1; i <= N; i++){
     console.log("Yes");
  }
  return;
}

// 出てくる頻度順に並べる？
// これは借り物のロジック
// 頻度のオブジェクト
let obj = {};
for (let i = 0, j = Aarr.length; i < j; i++) {
   obj[Aarr[i]] = (obj[Aarr[i]] || 0) + 1;
}

// 多分出てきたvalueがdiffより大きかったらそれは勝ち残れるっぽい
for(let i = 1; i <= N; i++){
	if(obj[i]*1 > diff){
    	console.log("Yes");
    } else {
    	console.log("No");
    }
}


Measured memory_bytes: 31652
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int max = Math.max(a+b, a-b);
		System.out.print(Math.max(max,a*b));
	}

}


Measured memory_bytes: 21844
using System;

class Program {
  const int bomb = -1;
  static void Main(string[] args) {
    string[] val = Console.ReadLine().Split();
    int H = int.Parse(val[0]);
    int W = int.Parse(val[1]);

    char[,] M = new char[H + 2, W + 2];
    int[,] A = new int[H,W];

    for (int i = 0; i < H + 2; ++i) {
      M[i, 0] = M[i, W + 1] = '.';
    }
    for (int i = 0; i < W + 2; ++i) {
      M[0, i] = M[H + 1, i] = '.';
    }

    for (int i = 0; i < H; ++i) {
      string str = Console.ReadLine();
      for (int j = 0; j < W; ++j) {
        M[i + 1, j + 1] = str[j];
      }
    }

    for (int i = 0; i < H; ++i) {
      for (int j = 0; j < W; ++j) {
        if (M[i + 1, j + 1] == '#') {
          A[i,j] = bomb;
          continue;
        }

        int count = 0;
        for (int k = -1; k <= 1; ++k) {
          for (int s = -1; s <= 1; ++s) {
            if (k == 0 && s == 0) {
              continue;
            }
            if (M[i + k + 1, j + s + 1] == '#') {
              ++count;
            }
          }
        }
        A[i, j] = count;
      }
    }

    for (int i = 0; i < H; ++i) {
      for (int j = 0; j < W; ++j) {
        if (A[i,j] == bomb) {
          Console.Write("#");
        }
        else {
          Console.Write(A[i,j].ToString());
        }
      }
      Console.WriteLine();
    }
  }
}


Measured memory_bytes: 13248
let n = (Scanf.scanf "%d " (fun x -> x));;
let xs =
    let rec loop i = 
        if i = 0
        then
            []
        else
            (Scanf.scanf "%d " (fun x -> x)) :: (loop (i-1))
    in
            List.sort compare (loop (n*2));;


let solve () = 
    let rec loop ls = 
        match ls with
        |a::b::z -> (begin a + (loop z) end )
        |_ -> 0
    in
        loop xs;;
        

Printf.printf "%d\n" (solve ())

Measured memory_bytes: 512
K = int(input())
dp = [['1','2','3','4','5','6','7','8','9'],[]]

cnt = 9
keta = 0
dp_num = 0
while True:
    num = 2
    current_base_num_str = dp[keta][dp_num][-1]
    current_base_num_int = int(current_base_num_str)
    break_flag = False
    for i in range(-1,num):
        if current_base_num_int + i > 9 or current_base_num_int + i < 0:
            continue
        dp[keta+1].append(dp[keta][dp_num] + str(current_base_num_int + i))
        cnt += 1
        if cnt >= K:
            break_flag = True
            break
    if break_flag:
        break
    if dp_num < len(dp[keta])-1:
        dp_num += 1
    else:
        dp_num = 0
        keta += 1
        dp.append([])
if K < 10:
    print(K)
else:
    if len(dp[keta+1]) == 0:
        print(dp[keta][-1])
    else:
        print(dp[keta+1][-1])

Measured memory_bytes: 48476
#include <bits/stdc++.h>
using namespace std;
#define SZ(v) int((v).size())
#define ALL(vec) begin(vec), end(vec)
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;}
#ifdef Rahul
# define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
  stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#else
# define error(...) 42;
#endif
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;}
int Nerr;
template<typename A> string to_string(A *p) {return to_string(vector<A>(p, p + Nerr));}
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);}
#define Lu(...) [&] (auto &&u) { return __VA_ARGS__; }
#define Luv(...) [&] (auto &&u, auto &&v) { return __VA_ARGS__; }
int const MOD = 1e9 + 7;
i64 const INF = 1e18 + 42;
/***********************************************************************/
int32_t main() {
  cin.tie(nullptr) -> sync_with_stdio(false);
  
  int n; cin >> n;
  n %= 10;
  if (n == 2 or n == 4 or n == 5 or n == 7 or n == 9) kek("hon");
  if (n == 3) kek("bon");
  kek("pon");
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
    int N, M; cin >> N >> M;
 
    ll K; cin >> K;
    ll A[N], B[M]; F0R(i, N) cin >> A[i];
    F0R(i, M) cin >> B[i];
 
    ll as = 0; F0R(i, N) as += A[i];
    ll bs = 0;
    int bp = 0;
    int ans = 0;
    F0Rd(i, N+1) {
        if (i < N) as -= A[i];
        if (as <= K) {
            while (bp < M && as + bs + B[bp] <= K) {
                 bs += B[bp]; bp++;
            }
            ckmax(ans, i + bp);
        }
//        cout << as << " " << bs << " " << bp << nl;
    }
    cout << ans << nl;
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343


Measured memory_bytes: 6776
#include <iostream>
using namespace std;

int main() {
    int n;
    cin >> n;
    int list[n];
    for(int i = 0; i < n; i++){
        cin >> list[i];
    }
    for(int j = n-1; j >= 0; j--){
        if(j == 0)cout << list[j];
        else cout << list[j] << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3104
#include<stdio.h>
#include<string.h>
#define rep(i,j) for(int i=0;i<(j);i++)
int main(){
	int n,k[1000],l;
	char s[101];
	for(;;){
	    scanf("%d",&n);
	    if(!n)break;
	    rep(i,n){
	        scanf("%d",k+i);
	        k[i] = 52 - k[i];
	    }
	    scanf("%s",s);
        l = strlen(s);
        rep(i,l){
            s[i] = s[i]>='a' ? s[i]-'a':s[i]-'A'-26;
            s[i] = (s[i]+k[i%n]+52)%52;
            s[i] = s[i]>25?s[i]+'A'-26:s[i]+'a';
        }
        puts(s);
	}

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int n,a[21],num;

bool saiki(int i,int sum){
  if(sum==num)return 1;
  if(i==n)return 0;
  if(saiki(i+1,a[i]+sum))return 1;
  if(saiki(i+1,sum))return 1;
  return 0;  
}

int main(){
  cin>>n;
  for(int i=0;i<n;i++) cin>>a[i];
  int q;
  cin>>q;
  while(q--){
    cin>>num;
    if(saiki(0,0)) cout <<"yes"<<endl;
    else cout <<"no"<<endl;
  }
  return 0;
}

Measured memory_bytes: 1156
import sys,time

n = 104730
a = [True] * n
a[0] = a[1] = False
for i in range(2,n):
	if(a[i]):
		for j in range(i+i, n, i):
			a[j] = False
a = [i[0] for i in enumerate(a) if i[1]]

for s in sys.stdin:
	n = int(s)
	if n == 0:
		exit()
	print(sum(a[:n]))

Measured memory_bytes: 10148
#include <stdio.h>

int main(void){
  int i, j, k;
  for(i = 1; i <= 9; i++){
    for(j = 1; j <= 9; j++){
      k = i * j;
      printf("%dx%d=%d\n", i, j, k);
	}
  }
  return 0;
}

Measured memory_bytes: 916
nm = input().split()
n = int(nm[0])
m = int(nm[1])
a = []
b = []
for i in range(m):
	ab = input().split()
	a.append(int(ab[0]))
	b.append(int(ab[1]))


for i in range(1, n+1):
	print(a.count(i) + b.count(i))

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main(){
    int N,M,a[100],i,b,score[100];
    cin>>N>>M;
    for(i=0;i<M;i++){
        cin>>a[i];
    }
    for(i=0;i<N;i++){
        score[i]=0;
    }
    for(int j=0;j<M;j++){
        for(i=0;i<N;i++){
            cin>>b;
            int ans=a[j];
            if(a[j]==b){
                score[i]++;
            }else{
                score[ans-1]++;
            }
        }
    }
    for(i=0;i<N;i++){
        cout<<score[i]<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 3048
#include<bits/stdc++.h>
#define N 100005
#define ll long long
using namespace std;
int n;
int a[N],b[N];
int main()
{
	ll x,y;
	cin>>x>>y;
	if(x%y!=0)cout<<x<<endl;
	else cout<<"-1"<<endl;
	return 0;
}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = 1000000000;
const double PI = acos(-1);


int main() {
	vector<pair<int, int>>v;
	int n;
	cin >> n;
	int a, b;
	for (int i = 0; i < n; i++) {
		cin >> a >> b;
		v.emplace_back(a, b);
	}
	sort(v.begin(), v.end());
	int ans = v[0].first - 1;
	for (int i = 1; i < n; i++) {
		ans += min(v[i].first - v[i - 1].first, v[i - 1].second - v[i].second);
	}
	ans += v[n - 1].second;
	cout << ans + 1 << endl;
}

Measured memory_bytes: 1400
#include <stdio.h>

int main()
{
  int x, y, r, di;
  scanf("%d %d", &x, &y);
  if (x > y)  {
    while (y > 0)  {
      r = x % y;
      x = y;
      y = r;
    }
    di = x;
  }
  else {
    while (x > 0)  {
      r = y % x;
      y = x;
      x = r;
    }
    di = y;
  }
  printf("%d\n", di);

  return 0;
}

Measured memory_bytes: 592