akhauriyash/Code-Regression huggingface dataset:
/*
* Note: This template uses some c++11 functions , so you have to compile it with c++11 flag.
*       Example:-   $ g++ -std=c++11 c++Template.cpp
*
* Author : Akshay Pratap Singh
* Handle: code_crack_01
*
*/
 
/********   All Required Header Files ********/
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;

/*******  All Required define Pre-Processors and typedef Constants *******/
#define SCD(t) scanf("%d",&t)
#define SCLD(t) scanf("%ld",&t)
#define SCLLD(t) scanf("%lld",&t)
#define SCC(t) scanf("%c",&t)
#define SCS(t) scanf("%s",t)
#define SCF(t) scanf("%f",&t)
#define SCLF(t) scanf("%lf",&t)
#define MEM(a, b) memset(a, (b), sizeof(a))
#define FOR(i, j, k, in) for(int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for(int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
typedef long long int ll;
typedef unsigned long long int  ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<ll> vll;
typedef vector<vi> vvi;

#define MAX 100005
#define NIL -1

struct Node{ int p, l, r; };
Node T[MAX];
int n, H[MAX], D[MAX];

void print(int u){
  
  int degree = 0;
  if( T[u].l != NIL and T[u].r != NIL )  degree = 2;
  else if( T[u].l != NIL )  degree = 1;
  else if( T[u].r != NIL )  degree = 1;

  int sibling = NIL;
  if( T[u].p != NIL ){
    int p = T[u].p;

    if( T[p].l != NIL and T[p].l != u ) sibling = T[p].l;
    if( T[p].r != NIL and T[p].r != u ) sibling = T[p].r;

  }

  cout << "node " << u << ": ";
  cout << "parent = " << T[u].p << ", ";
  cout << "sibling = " << sibling << ", ";
  cout << "degree = " << degree << ", "; 
  cout << "depth = " << D[u] << ", ";
  cout << "height = " << H[u] << ", ";

  if( T[u].p == NIL ) cout << "root";
  else if ( T[u].l == NIL and T[u].r == NIL ) cout << "leaf";
  else cout << "internal node";

  cout << endl;
}

int rec(int u, int p){
  int hl = 0, hr = 0;
  D[u] = p;
  if ( T[u].r != NIL ) hr = rec(T[u].r, p+1);
  if ( T[u].l != NIL ) hl = rec(T[u].l, p+1);
  H[u] = max(hl, hr);

  return H[u]+1;
}


int main(){
  int id, l, r;

  int N; SCD(N);
  REP(i, N) T[i].p = T[i].l = T[i].r = NIL;

  REP(i, N){
    SCD(id); SCD(T[id].l); SCD(T[id].r);
    T[T[id].l].p = id;
    T[T[id].r].p = id;
  }

  REP(i, N){
    if ( T[i].p == NIL ) r = i;
  }

  rec(r, 0);

  REP(i, N) print(i);

  return 0;
}



Measured memory_bytes: 3168
#include <bits/stdc++.h>
#define int long long
#define maxn 3005
using namespace std;

int arr[maxn], dp[maxn][maxn];
int n;

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n;
    for(int i = 1; i <= n; i++) {
        cin >> arr[i];
        dp[i][i] = (n & 1) ? arr[i] : -arr[i];
    }
    for(int len = 2; len <= n; len++) {
        int flag = (len & 1) == (n & 1) ? 1 : -1;
        for(int i = 1; i + len - 1 <= n; i++) {
            int l = i, r = i + len - 1;
            int A = dp[i + 1][r] + flag * arr[l];
            int B = dp[i][r - 1] + flag * arr[r];
            if(flag == 1) { // Taro
                dp[l][r] = A > B ? A : B;
            }
            else { // Jiro
                dp[l][r] = A < B ? A : B;
            }
        }
    }
    cout << dp[1][n] << '\n';
    return 0;
}


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

using namespace std;

string music;

int footstep(int idx, int foot, int left, int right)
{
  if(idx == music.size()) return 0;
  int step = ((music[idx]-'0')-1) % 3;
  int miss = 0;
  if(foot == 0){
    if(step <= right) miss = footstep(idx+1, 1, step, right);
    else miss = footstep(idx+1, 0, left, step) + 1;
  } else if(foot == 1){
    if(step >= left) miss = footstep(idx+1, 0, left, step);
    else miss = footstep(idx+1, 1, step, right) + 1;
  }
  return miss;
}

int main()
{
  while(cin >> music, music != "#"){
    cout << min(footstep(0, 0, -1, 3), footstep(0, 1, -1, 3)) << endl;
  }
  return 0;
}

Measured memory_bytes: 1316
#include<bits/stdc++.h>
#define ll long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const ll MAX = 1000000000000000;
static const int NIL = -1;
using namespace std;
const long double EPS = 0.0000000001;
const long double PI = (acos(-1));
const int MOD = 1000000007;

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

vector<ll> m(1001,0);

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

int main(){

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

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

    return 0;
}

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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
#define mins(x, y) (x = min(x, y))
#define maxs(x, y) (x = max(x, y))
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using P = pair<ll, int>;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

void solve() {
  int d, n;
  n = 26;
  cin >> d;
  vi c(n);
  rep(i, n) cin >> c[i];
  vvi s(d, vi(n));
  rep(i, d) rep(j, n) cin >> s[i][j];
  vi l(n, -1);
  vector<vector<P>> g(d, vector<P>(n));
  vi ans(d);
  rep(i, d) {
    rep(j, n) {
      g[i][j].first = s[i][j];
      g[i][j].second = j;
      rep(k, n) {
        if (j != k) g[i][j].first -= (ll)c[k] * (i - l[k]);
      }
    }
    sort(g[i].rbegin(), g[i].rend());
    // dump(g[i]);
    int mi = g[i][0].second;
    l[mi] = i;
    ans[i] = mi;
  }
  auto score = [&] (vi& sel) {
    ll sc = 0;
    l.assign(n, -1);
    rep(i, d) {
      sc += s[i][sel[i]];
      l[sel[i]] = i;
      rep(k, n) sc -= (ll)c[k] * (i - l[k]);
    }
    return sc;
  };
  ll msc = score(ans);
  dump(msc, ans);
  // rep(i, d) {
  for (int i = d - 1; 0 <= i; --i) {
    for (int j = 1; j < 26; j++) {
      vi sel = ans;
      sel[i] = g[i][j].second;
      ll ss = score(sel);
      dump(i, ss, sel);
      if (msc < ss) {
        ans = sel;
        msc = ss;
      }
    }
  }
  rep(i, d) cout << ans[i] + 1 << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 3828
#include<iostream>
#include<map>
#include<vector>
#include<queue>
using namespace std;
#define INF 1000000000
typedef struct {
	int to,cost;
} edge;
typedef pair<int,int> P;
typedef pair<int,P> Pi;
void dijkstre();
int n,m;
vector<edge> node[103];
int min_cost[103][2];
bool used[103][2];

int main(){
	while(1){
		cin >> n >> m;
		if(n == 0 && m == 0) break;
		for(int i=0;i<n+1;i++){
			node[i].clear();
			for(int j=0;j<2;j++){
				min_cost[i][j] = INF;
				used[i][j] = false;
			}
		}
		for(int i=0;i<m;i++){
			int a,b,c;
			cin >> a >> b >> c;
			edge e;
			e.to = b; e.cost = c;
			node[a].push_back(e);
			e.to = a;
			node[b].push_back(e);
		}
		dijkstre();
	}
}

void dijkstre(){
	priority_queue<Pi,vector<Pi>,greater<Pi> > que;
	que.push(Pi(0,P(1,0)));
	min_cost[1][0] = 0;
	while(!que.empty()){
		Pi p = que.top(); que.pop();
		int cost = p.first;
		int now = p.second.first;
		int k = p.second.second;
		if(now == n){
			cout << cost << endl;
			return;
		}
		if(used[now][k]) continue;
		used[now][k] = true;
		int len = node[now].size();
		for(int i=0;i<len;i++){
			edge e = node[now][i];
			if(cost+e.cost < min_cost[e.to][k]){
				min_cost[e.to][k] = cost+e.cost;
				que.push(Pi(min_cost[e.to][k],P(e.to,k)));
			}
			if(k==0){
				int ll = node[e.to].size();
				for(int j=0;j<ll;j++){
					edge ee = node[e.to][j];
					if(cost < min_cost[ee.to][1]){
						min_cost[ee.to][1] = cost;
						que.push(Pi(min_cost[ee.to][1],P(ee.to,1)));
					}
				}
			}
		}
	}
	cout << "NA" << endl;
	return;
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0;i<int(n);++i)
using namespace std;
template<class A>void pr(A a){cout << a << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
int INF=numeric_limits<int>::max();
// for(int j=0;j<N;++j) {}

int main(void) {
  int n;cin>>n;
  ll sum=0;
  for(int i=1;i<=n;++i) {
    if(i%3!=0&&i%5!=0) {
      sum+=i;
    }
  }
  pr(sum);
  return 0;
}


Measured memory_bytes: 3592
from collections import Counter
 
N = int(input())
S = [input() for _ in range(N)]

# 方針：各文字列の出現回数を数え、出現回数が最大なる文字列を昇順に出力する

# 各単語の出現回数を数える（辞書型を用いる！！）
dic = {}
for i in range(N):
  s = S[i]
  if s not in dic: dic[s] = 1
  else: dic[s] += 1

max_count = max(dic.values()) # 最大の出現回数

# 出現回数が最も多い単語を集計する
l = [key for key in dic.keys() if dic[key] == max_count]

# 昇順にソートして出力
for i in sorted(l):
  print(i)

Measured memory_bytes: 38824
from fractions import gcd

N, X = map(int, input().split())
xs = list(map(int, input().split()))
xs.append(X)
xs = sorted(xs)
m = 999999999999999999
diffs = []
for idx,e in enumerate(xs):
  if idx==0:
    continue
  diff = abs(e - xs[idx-1])
  diffs.append(diff)
diffs = sorted(diffs)
for idx,dif in enumerate(diffs):
  if idx == 0:
    continue
  if gcd(diffs[idx], diffs[idx-1]) < m:
    m = gcd(diffs[idx], diffs[idx-1])
if len(diffs) == 1:
  m = diffs[0]
print(m)


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

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (b)-1; i >= (a); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define RREP(i, n) for(int i = (n)-1; i >= 0; i--)
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = (n)-1; i >= 0; i--)
#define loop while(true)

#define PB push_back
#define pb push_back
#define MP make_pair
#define mp make_pair
#define ALL(a) (a).begin(),(a).end()
#define all(a) (a).begin(),(a).end()

#define PII pair<int, int>
#define pii pair<int, int>
#define VB vector<bool>
#define VVB vector<vector<bool> >
#define VI vector<int>
#define VVI vector<vector<int> >

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;


signed main()
{
    loop{
        int n, m, a;
        cin >> n >> m >> a;
        if(n == 0 && m == 0 && a == 0) break;

        vector<vector<PII> > h_line(1001);
        int h_max = 0;
        rep(i, m){
            int h, p, q;
            cin >> h >> p >> q;
            h_line[h].pb(mp(p, q));
            if(h > h_max){
                h_max = h;
            }
        }

        int pos = a;
        rrep(h, h_max+1){
            rep(i, h_line[h].size()){
                if(pos == h_line[h][i].first){
                    pos = h_line[h][i].second;
                    break;
                }
                else if(pos == h_line[h][i].second){
                    pos = h_line[h][i].first;
                    break;
                }
            }
        }
        cout << pos << endl;
    }
    
    return 0;
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

int n;
PL ps[111111];
ll cnt[111111];
ll a[111111];

int main(){
	cin.sync_with_stdio(false);
	cin>>n;
	rep(i,n){
		cin>>a[i];
		ps[i]=PL(a[i],i);
	}
	sort(ps,ps+n,greater<PL>());
	ll idx=n;
	rep(i,n){
		minch(idx,ps[i].se);
		cnt[idx]+=(i+1)*(ps[i].fi-ps[i+1].fi);
	}
	rep(i,n){
		cout<<cnt[i]<<endl;
	}
	return 0;
}


Measured memory_bytes: 4224
#include <stdio.h>

int main(void) {
	
	 int x,y,z,v;
	 scanf("%d %d\n",&x,&y);
	 z=x*y;
	 v=2*x+2*y;
	 printf("%d %d\n",z,v);
	 
	return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<cmath>

using namespace std;

// ある整数の約数の個数を返す
// Input: 整数 N
// Output: その約数の個数
int divisorQty(int);

int main()
{
    int count = 0;
    int N;

    cin >> N;

    for(int i = 1; i <= N; i += 2){
        if (divisorQty(i) == 8) count++;
    }
    cout << count << endl;
}

int divisorQty(int n)
{
    int m = (int)sqrt(n);
    int count = 0;

    for (int i = 1; i <= m; i++){
        if (n % i == 0) count++;
        if (n % i == 0 && n / i != i) count++;
    }

    return count;
}

Measured memory_bytes: 256
IDENTIFICATION                   DIVISION.
PROGRAM-ID.                      ABC_070_A.
ENVIRONMENT                      DIVISION.
DATA                             DIVISION.
WORKING-STORAGE                  SECTION.
    01 N      PIC X(3).

PROCEDURE                        DIVISION.
MAIN.
    ACCEPT N.

    IF N(1:1) = N(3:1) THEN
        DISPLAY "Yes"
    ELSE
        DISPLAY "No"
    END-IF.

    STOP RUN.


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

#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define size_of(a) (int)(a).size()
#define allof(a) (a).begin(),(a).end()

int main() {
	int T;
	cin >> T;
	
	for_(i,0,T) {
		int n, k, prv, sum = 0;
		cin >> n >> k;
		cin >> prv;
		
		priority_queue< int > que;
		
		for_(i,1,n) {
			int cur; cin >> cur;
			int diff = cur - prv;
			que.push(diff);
			sum += diff;
			prv = cur;
		}
		
		for_(i,1,k) {
			if (que.empty()) break;
			int t = que.top(); que.pop();
			sum -= t;
		}
		
		cout << sum << endl;
	}
}

Measured memory_bytes: 1864
import java.util.*;
import java.lang.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int d = sc.nextInt();
		int t = sc.nextInt();
		int s = sc.nextInt();

		double time = d*1.0/s;
		if(time > (double)t) {
			System.out.println("No");
		} else {
			System.out.println("Yes");
		}
	}
}

Measured memory_bytes: 27096
import java.util.*;
import java.util.Arrays;
import java.util.BitSet;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // int N = sc.nextInt();
        // int M = sc.nextInt();
        String[] N_M = sc.nextLine().split(" ");
        int N = Integer.valueOf(N_M[0]);
        int M = Integer.valueOf(N_M[1]);
        // System.out.println("\n\n");
        // System.out.println("N:"+N+" M:"+M);
        // System.out.println("\n\n");
        int[][] switchs = new int[M][N];
        int[] Ns = new int[N];

        for (int m = 0; m < M; m++){
            String line = sc.nextLine();
            String[] line_s = line.split(" ");
            int ki = Integer.valueOf(line_s[0]);
            for (int i = 0;i < ki; i++) {
                switchs[m][i] = Integer.valueOf(line_s[i + 1]);
            }
        }
        int[] P = new int[M];
        for (int m = 0;m < M; m++){
            P[m] = sc.nextInt();
        }

        int[] bits = new int[N];
        int light_conbination = 0;
        for (int i = 0;i<(1<<N); i++){

            int light_flg = 1;
            // for (int j = 0;j < N;j++){
                for (int m = 0; m < M; m++){
                    int cnt = 0;
                    for (int n = 0; n < N; n++){
                        if ((1 & (i >> (switchs[m][n] - 1) )) == 1){
                            cnt++;
                        }
                    }
                    if (cnt % 2 != P[m]) {
                        light_flg = 0;
                        break;
                    }
                }
                // if ((1&i>>j) == 1){
                //     cnt++;
                //     System.out.println(i+" "+j+" "+bits[j]+" "+cnt+" "+cnt%2);
                //     sb += Integer.toString(bits[j]);
                //     // System.out.println(sb);
                // }
                if (light_flg == 1){
                    light_conbination++;
                }
            // }
        }
        System.out.println(light_conbination);
    }
}


Measured memory_bytes: 22736
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;


int main() {
 int a,b,c;
 cin >> a >> b >> c;
 if (c>=a && c<=b) cout << "Yes" << endl;
 else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

int main(){
    int h, w, k;
    cin >> h >> w >> k;
    vl y(k), x(k), v(k);
    rep(i, k) {
        cin >> y[i] >> x[i] >> v[i];
        x[i]--;
        y[i]--;
    }
    vector<vl> a(h, vl(w));
    rep(i, k) a[y[i]][x[i]] = v[i];
    using AR = array<ll, 4>;
    vector<vector<AR>> dp(h, vector<AR>(w));
    if(a[0][0] > 0) dp[0][0][1] = a[0][0];
    rep(y, h) rep(x, w) rep(i, 4) {
        if(x+1 < w) {
            chmax(dp[y][x+1][i], dp[y][x][i]);
            if(i != 3) chmax(dp[y][x+1][i+1], dp[y][x][i]+a[y][x+1]);
        }
        if(y+1 < h) {
            chmax(dp[y+1][x][0], dp[y][x][i]);
            chmax(dp[y+1][x][1], dp[y][x][i]+a[y+1][x]);
        }
    }
    cout << (*max_element(all(dp[h-1][w-1]))) << '\n';
    return 0;
}

Measured memory_bytes: 359920
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define allR(x) (x).rbegin(), (x).rend()
using ll = long long;
using P = pair<int, int>;
const int INF (1<<30);

int main() {
  int N;
  cin >> N;
  vector<ll> A(N+1);
  rep(i, N+1) cin >> A[i];
  vector<ll> Amax(N+1);
  Amax[N] = A[N];
  for (int i = N-1; i >= 0; i--) {
    Amax[i] = Amax[i+1] + A[i];
  }

  bool isOk = true;
  if (N == 0) {
    if (A[0] == 1) cout << 1 << endl;
    else cout << -1 << endl;
    return 0;
  }

  if (A[0] != 0LL) {
    isOk = false;
  }


  ll ans = 1LL;
  ll parent = 1LL;
  for (int i = 1; i < N; i++) {
    if (parent > Amax[i]) isOk = false;
    ll now = min(2LL*parent, Amax[i]);
    ans += now;

    //cout << i << " " << now << endl;

    parent = now - A[i];
    if (parent <= 0LL) isOk = false;
  }

  //cout << "last;" << parent << endl;

  if (parent <= A[N] && A[N] <= (2LL*parent)) {
    ans += A[N];
  }
  else {
    isOk = false;
  }


  if (isOk) cout << ans << endl;
  else cout << -1 << endl;


  return 0;
}


Measured memory_bytes: 4848
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define req(i,n) for(int i = 1;i <=n;i++)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
typedef pair<int,int> P;

//最大公約数
int gcd(int a,int b){
	if (a%b == 0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}

}

//最小公倍数
int lcm(int a,int b){
	return a /gcd(a,b) * b;
}

//素数判定
bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}

// 素因数分解
vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

// 10進数から2進数
int binary(int bina){
    int ans = 0;
    for (int i = 0; bina>0 ; i++)
    {
        ans = ans+(bina%2)*pow(10,i);
        bina = bina/2;
    }
    return ans;
}




int main() {
 ll n,m;
 cin >> n >> m;
 ll ans;
 if (m <= n * 2){
   cout << m / 2 << endl;
   return 0;
 }
 ans = n;
 m -= n * 2;
 //cout << m << endl;
 ans += m/4;
 cout << ans << endl;

}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E18;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int main(){fastio
    ll k,a,b;cin>>k>>a>>b;
    rep(i,a,b){
        if(i%k==0){
            cout<<"OK"<<endl;
            return 0;
        }
    }
    cout<<"NG"<<endl;
    
    
    return 0;
}


Measured memory_bytes: 3652
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<iostream>
#include<fstream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<functional>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n;
    cin>>n;
    ll a[100010],b[100010];
    ll cnt=0,now=0;
    rep(i,n){
        cin>>a[i]>>b[i];
        if(cnt<a[i]){
            cnt=a[i];
            now=i;
        }
    }
    cout<<a[now]+b[now]<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define myPair pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define qmax priority_queue<int>
#define qmin priority_queue<int,vector<int>,greater<int>>
#define all(x) x.begin(),x.end()
#define FOR(i,a,b) for(int i = a; i <= b; i++)
#define FORR(i,a,b) for(int i = a; i >= b; i--)

const int mxn = 1e5 + 10;
int dp[101][mxn];
// dp[i][j] = maximum profit with j amount of weight and first i items are to be processed
bool c[101][mxn];
int W, w[mxn], v[mxn];
int n;

int f(int i,int j)
{
	if(c[i][j])
		return dp[i][j];
	if(i == 0 || j == 0)
		dp[i][j] = 0;
	else
	{
		dp[i][j] = f(i - 1, j);
		if(j >= w[i])
			dp[i][j] = max(dp[i][j], v[i] + f(i - 1, j - w[i]));
	}
	c[i][j] = 1;
	return dp[i][j];
}

int32_t main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> n >> W;
	FOR(i,1,n)
		cin >> 	w[i] >> v[i];
	memset(c,0,sizeof(c));
	cout << f(n,W);

	return 0;
}

Measured memory_bytes: 85748
#include<iostream>

using namespace std;

int main(void) {
  int n;
  cin >> n;
  int v[n], c[n];
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> c[i];
  }
  int result = 0;
  for (int i = 0; i < n; i++) {
    if (v[i] > c[i]) result += v[i] - c[i];
  }
  cout << result << endl;

  return 0;
}


Measured memory_bytes: 256
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a +  b >= c)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define L_MAX 1001
int max(int ,int);
int lcs(char *,char *);

int main(){
  int c;
  char x[L_MAX];
  char y[L_MAX];
  
  scanf("%d",&c);
  while(c>0){
    scanf("%s",x);
    scanf("%s",y);

    printf("%d\n",lcs(x,y));
    c--;
  }
  return 0;
}

int max(int a,int b){
  if(a<b)return b;
  else return a;
}

int lcs(char *x,char *y){
  int i,j;
  int xlen,ylen;
  int dp[L_MAX][L_MAX];
  
  xlen = strlen(x);
  ylen = strlen(y);
  
  for(i=0;i<=xlen;i++)
    for(j=0;j<=ylen;j++)
      dp[i][j]=0;
   
  for(i=0;i<xlen;i++){
    for(j=0;j<ylen;j++){
      if(x[i]==y[j]) dp[i+1][j+1]=dp[i][j]+1;//値が同じだったら、左上のマスに１加える
      else dp[i+1][j+1]=max(dp[i+1][j],dp[i][j+1]);//値が異ったら、上か左の大きいほうの値を書く
    }
  }
  return dp[xlen][ylen];
}





Measured memory_bytes: 5648
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <sstream>
using namespace std;

struct Obj {
  bool isStr;
  string str;
  map<string, Obj*> pro;
};


vector<pair<int,string> > v;
int pos;

void make(Obj *obj) {
  for(int i = 0, ppos; pos < v.size(); ++i) {
    if(i && v[ppos].first != v[pos].first) break;
    Obj *nobj = new Obj();
    string &target = v[pos].second;
    ppos = pos++;

    int j;
    for(j = 0; target[j] != ':'; ++j);
    string key = target.substr(0,j);

    if(j+1== target.size()) {
      nobj->isStr = false;
      make(nobj);
    } else {
      nobj->isStr = true;
      nobj->str = target.substr(j+2);
    }
    obj->pro[key] = nobj;
  }
}

int main() {
  string p;
  getline(cin, p);
  string line;
  while(getline(cin, line)) { 
    int sp = 0;
    while(line[0] == ' ') {
      ++sp;
      line = line.substr(1);
    }
    v.push_back(make_pair(sp, line));
  }

  Obj *root = new Obj();
  root->isStr = false;
  pos = 0;
  make(root);

  vector<string> ps;
  {
    replace(p.begin(), p.end(), '.', ' ');
    stringstream ss(p);
    string s;
    while(ss >> s) ps.push_back(s);
  }

  Obj *obj = root;
  for(int i = 0; i < ps.size(); ++i) {
    if(obj->pro.count(ps[i])) {
      obj = obj->pro[ps[i]];
    } else {
      obj = 0;
      break;
    }
  }
  if(obj) {
    if(obj->isStr) cout << "string \"" << obj->str << "\"" << endl;
    else cout << "object" << endl;
  } else {
    cout << "no such property" << endl;
  }

  return 0;
}

Measured memory_bytes: 1424
function main(input) {
  var nums = input.split('\n')[1].split(' ').map((n) => parseInt(n, 10));
  var resultArray=[];
for(var i=0; i<nums.length; i++){
  var temp=0;
  while(nums[i]%2==0 && nums[i]>=1){
    nums[i]=nums[i]/2;
    temp++;
  };
  resultArray.push(temp);
}
console.log(Math.min.apply(null, resultArray));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7624
#include<iostream>
#include<vector>
#include<map>
#include<tuple>
#include<set>
#include<cmath>
#include<numeric>
#define ll long long
#define MOD = 1e9+7
 
using namespace std;

int main(){
  string S,T;
  cin >> S >> T;
  string ans = "Yes";
  for(int i=0;i<S.size();i++){
    if(S[i] != T[i]){
      ans = "No";
      break;
    }
  }
  cout << ans <<endl;
}


Measured memory_bytes: 3040
#include<stdio.h>
int main(){

  int i,j,v,N,a[1000];

  scanf("%d",&N);

  for(i=0;i<N;i++){
    scanf("%d",&a[i]);
  }

  for(i=1;i<=N;i++){ 
    for(j=0;j<N;j++){
      printf("%d",a[j]);
      if(j<N-1){
	printf(" ");
      }
    }
    puts("");
    v=a[i];
    j=i-1;
    while(j >= 0 && a[j]>v){
      a[j+1]=a[j];
      j--;
      a[j+1]=v;
    }
  }
  return 0;
}

Measured memory_bytes: 616
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod= 1e+9+7;

int main(){
    ll N; cin>>N;
    ll sum=0;
    for(int i=1;i<=N;i++){
        if(i%3==0||i%5==0)continue;
        sum+=i;
    }
    cout<<sum<<endl;
}


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

using namespace std;
using ll = long long;
using ld = long double;

#define ALL(a) (a).begin(),(a).end()
#define CHMIN(a, b) a = min((a),(b))
#define CHMAX(a, b) a = max((a),(b))
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main() {
    int x, y;
    cin >> x >> y;
    cout << (x - 1) * (y - 1) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int A,B,T;
    scanf("%d %d %d",&A,&B,&T);
    float t;
    t=T+0.5;
    int n=0;
    for(int first=A;first<t;first+=A){
        n+=B;
    }
    printf("%d",n);
}

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

#define MOD 1000000007

// define
int dp[100010][13];

int main() {
  string s;
  cin >> s;

  // init
  dp[0][0] = 1;

  // update
  for (int i = 0; i < s.size(); i++) {
    for (int j = 0; j < 13; j++) {
      if (s[i] == '?') {
        for (int d = 0; d < 10; d++) {
          dp[i + 1][(j*10 + d)%13] += dp[i][j];
          dp[i + 1][(j*10 + d)%13] %= MOD;
        }
      }
      else {
        int d = s[i] - '0';
        dp[i + 1][(j*10 + d)%13] += dp[i][j];
        dp[i + 1][(j*10 + d)%13] %= MOD;
      }
    }
  }

  // ans
  int ans = dp[s.size()][5];

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

Measured memory_bytes: 5504
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>
#include <queue>
#include <cctype>
#include <stack>
#include <random>
#include <list>
#include <numeric>



#define rep(i,p,q) for(ll i = p;i < q;i++)
#define ll long long

using namespace std;

//39 A
int main(void) {
	string s;
	ll k;
	cin >> s >> k;

	char chr = s[0];
	ll ans = 0;
	ll index = 0;
	rep(i, 1, s.size()+1) {
		if (i == s.size() || chr != s[i]) {
			ans += (i - index) / 2;
			chr = s[i];
			if (i < s.size()) {
				index = i;
			}	
		}
	}
	
	ll fIndex = 1;//[0,fIndex)
	char lastChr = s[0];
	while (fIndex < s.size() && lastChr == s[fIndex]) {
		fIndex++;
	}
	ll lIndex = s.size() - 2;
	lastChr = s[s.size()-1];
	while (fIndex <= lIndex && lastChr == s[lIndex]) {
		lIndex--;
	}
	
	if (index == 0 && s.size() % 2 == 1) {
		if (k % 2 == 1) {
			ans = s.size() * (k / 2) + s.size() / 2;
		}
		else {
			ans = s.size() * (k / 2);
		}
	}
	else if (fIndex <= lIndex && s[0] == s[s.size() - 1] && fIndex % 2 == 1 && (s.size() + 1 - lIndex) % 2 == 1) {
		ans++;
		ans = ans * k - 1;
	}
	else {
		ans *= k;
	}
	
	cout << ans << endl;

}

Measured memory_bytes: 256
import numpy as np
N, A, B, C = (int(i) for i in input().split())  
l = [int(input()) for i in range(N)] 

def dfs(cur, a, b, c):
  if cur == N:
    return abs(a-A) + abs(b-B) + abs(c-C) - 30 if min(a, b, c) > 0 else np.inf
  
  ret0 = dfs(cur + 1, a, b, c)
  ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
  ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
  ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
  return min(ret0, ret1, ret2, ret3)

print(dfs(0, 0, 0, 0))

Measured memory_bytes: 12260
#include <bits/stdc++.h>
#define DEBUG 1

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

using namespace std;

int main(){

	lli n;
	cin>>n;
	vector<lli> a(3);
	for(auto& e:a){
		cin>>e;
	}
	vector<lli> l(n);
	for(auto& e:l){
		cin>>e;
	}
	lli r = 1e9;

	vector<lli> b(3);
	for(b[0]=1;b[0] < (1<<n) ;b[0]++){
	for(b[1]=1;b[1] < (1<<n) ;b[1]++){
	if(b[0] & b[1])continue;
	for(b[2]=1;b[2] < (1<<n) ;b[2]++){
	if( (b[0] & b[2]) || (b[1] & b[2]))continue;
		lli rt = 0;
		for(lli i=0;i<3;i++){
			lli s = 0;
			for(lli j=0;j<n;j++){
				if(b[i] & (1<<j)){
					if(s)rt+=10;
					s += l[j];
				}
			}
			rt += abs(a[i]-s);
		}
		r = min(r,rt);
	}
	}
	}
	cout<<r<<endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int A[3][10][4]={0};
	int n,b,f,r,v;
	int i,j,k;
	
	cin >> n ;
	for(int  i=0;i<n;i++){
		
		cin >> b >> f >> r >> v ;
			A[f-1][r-1][b-1]=A[f-1][r-1][b-1]+v;
	}
	
	for(i=0;i<4;i++){
		for(j=0;j<3;j++){
			for(k=0;k<10;k++){
				cout << " " << A[j][k][i]  ;
			}
		cout << endl;
		}
	if(i==3){}
		else{
			cout << "####################" << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
    int H, W;
    cin >> H >> W;
    vector<string> S(H+2);
    for (int i = 0; i < W+2; ++i) S[0]+='.';
    for (int i = 0; i < H; ++i){
        string s;
        cin >> s;
        S[i+1] = '.' + s + '.';
    }
    for (int i = 0; i < W+2; ++i) S[H+1]+='.';
 
    vector<string> ans(H);
    for (int i = 1; i < H+1; ++i) {
        for (int j = 1; j < W+1; ++j) {
            if(S[i][j] == '#') {
                ans[i-1] += '#';
            }else {
                int cnt = 0;
                for (int dx = -1; dx <= 1; ++dx) {
                    for (int dy = -1; dy <= 1; ++dy) {
                        if(S[i+dx][j+dy] == '#') cnt++;
                    }
                }
                ans[i-1] += to_string(cnt);
            }
        }
    }
 
    for (int i = 0; i < H; ++i) {
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define NIL -1

typedef struct{
  int p;
  int l;
  int r;
} Node;

Node T[10000];
int n;

void pre(int u){
  if(u==NIL) return;
  printf(" %d",u);
  pre(T[u].l);
  pre(T[u].r);
}
void in(int u){
  if(u==NIL) return;
  in(T[u].l);
  printf(" %d",u);
  in(T[u].r);
}
void post(int u){
  if(u==NIL) return;
  post(T[u].l);
  post(T[u].r);
  printf(" %d",u);
}

int main(){
  int i,v1,v2,v3,root;
  scanf("%d",&n);
  for(i=0;i<n;i++){T[i].p=NIL;}

  for(i=0;i<n;i++){
    scanf("%d %d %d",&v1,&v2,&v3);
    T[v1].l=v2;
    T[v1].r=v3;
    if(v2!=NIL){T[v2].p=v1;}
    if(v3!=NIL){T[v3].p=v1;}
  }

  for(i=0;i<n;i++) if(T[i].p==NIL) root=i;
  printf("Preorder\n");
  pre(root);
  printf("\n");
  printf("Inorder\n");
  in(root);
  printf("\n");
  printf("Postorder\n");
  post(root);
  printf("\n");
  return 0;
}


Measured memory_bytes: 2088
m = [0,2,5,5,4,5,6,3,7,6]

N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)
for i in range(len(A)-1, 0, -1):
    for j in range(i-1, -1, -1):
        if m[A[i]] == m[A[j]]:
            del A[i]
            break

dp = [-1] * (N+1)
dp[0] = 0

for i in range(N):
    if dp[i]==-1: continue
    for j in range(len(A)):
        ind = i + m[A[j]]
        if ind <= N:
            dp[ind] = max(dp[ind], dp[i] * 10 + A[j])

print(dp[-1])


Measured memory_bytes: 14836
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0); 
  int h,w,k;
  cin>>h>>w>>k;
  vector<string> t(h);
  for(auto&& e:t)cin>>e;
  int ans = h+w;
  REP(i,1<<(h-1)) {
    vecint split;
    split.push_back(0);
    int cnt = 0;
    REP(j,h-1) {
      if ((i>>j)&1) {
        split.push_back(j+1);
        ++cnt;
      }
    }
    split.push_back(h);
    int m = split.size() - 1;
    vecint idx(h);
    REP(j,m) {
      FOR(a,split[j],split[j+1]) {
        idx[a] = j;
      }
    }
    vecint subcnt(m);
    REP(j,w) {
      vecint vcnt(m);
      REP(a,h) {
        if (t[a][j] == '1') {
          ++vcnt[idx[a]];
        }
      }
      bool ok = true;
      bool bad = false;
      REP(a,m) {
        if (vcnt[a] > k) bad = true;
        if (subcnt[a] + vcnt[a] > k) ok = false;
      }
      if (bad) cnt += h+w;
      if (ok) {
        REP(a,m) {
          subcnt[a] += vcnt[a];
        }
      } else {
        ++cnt;
        subcnt = vcnt;
      }
    }
    ans = min(ans, cnt);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ALL(x) (x).begin(),(x).end()
#define ll long long
#define ull unsigned long long
#define pii_ pair<int,int>
#define mp_ make_pair
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define show1(a) cout<<#a<<" = "<<a<<endl
#define show2(a,b) cout<<#a<<" = "<<a<<"; "<<#b<<" = "<<b<<endl
using namespace std;
const ll INF = 1LL<<60;
const int inf = 1<<30;
const int maxn = 2e5+5;
const ll M = 1e9 + 7;
inline void fastio() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
ll qpow(ll a,ll b) {ll s=1;while(b){if(b&1)s=(s*a)%M;a=(a*a)%M;b>>=1;} return s;}
ll C(ll a,ll b)
{
    ll res = 1;
    for(int i = a;i >= a-b+1 ;i--){
        res = res * i % M;
    }
    for(int i = b;i >= 2;i--){
        res = res * qpow(i,M-2) % M;
    }
    return res;
}
int main()
{
    fastio();
    int _,n;
    for(cin>>_;_;_--){
        cin>>n;
        if(n<5) cout<<0<<endl;
        else{
            ll ans =  0;
            rep(i,0,11){
                if(n-5-i<0 || (n-5-i)%2) continue;
                int r = (n-5-i)/2;
                ans = (ans + C(15+r,15)*C(11,i)%M) % M;
            }cout<<ans<<endl;
        }

    }
    return 0;
}


Measured memory_bytes: 3660
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long LL;
#define N 100000 + 5

int n, m, Next[N << 1][26];
char s[N << 1], t[N];
LL ans;

int main()
{
	scanf("%s%s", s + 1, t);
	n = strlen(s + 1), m = strlen(t);
	for (int i = 1; i <= n; i ++)
		s[i + n] = s[i];
	for (int j = 0; j < 26; j ++)
		Next[2 * n][j] = 2 * n + 1;
	for (int i = 2 * n - 1; i >= 0; i --)
	{
		for (int j = 0; j < 26; j ++)
			Next[i][j] = Next[i + 1][j];
		Next[i][s[i + 1] - 'a'] = i + 1;
	}
	int pos = 0;
	for (int i = 0; i < m; i ++)
	{
		pos = Next[pos][t[i] - 'a'];
		if (pos == 2 * n + 1)
		{
			ans = -1;
			break ;
		}
		if (pos > n)
			pos -= n, ans += n;
	}
	if (ans != -1)
		ans += pos;
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 20736
#include <bits/stdc++.h>
#define LL long long
using namespace std;
map<LL,LL>Map;
LL N,M,Sum,Ans;
int main(){
	LL I,J,K;
	scanf("%lld%lld",&N,&M);
	Map[0]++;
	for(I=1;I<=N;I++){
		LL Num;
		scanf("%lld",&Num);
		Sum=(Num+Sum)%M;
		Ans+=Map[Sum]++;
	} 
	printf("%lld",Ans);
	return 0;
}


Measured memory_bytes: 4224
#include<bits/stdc++.h>
#define ios ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std ;
typedef long long int ll ;


int main(){
	ios;
	int n,k,R,S,P;
	cin>>n>>k>>R>>S>>P;
	string t;

	cin>>t;
	
	map<char,int> m;
	int cnt=0;
	m['r']=P;
	m['s']=R;
	m['p']=S; 
	for(int i=0; i<n; i++){
	//	cout<<t[i]<<'\n';
		if(i+1>=k){
			if(t[i]-t[i-k]==5)continue;
			else {
				cnt+=m[t[i]];
				t[i]=t[i]-5;
			}
		}
		else{
			cnt+=m[t[i]];
			t[i]=t[i]-5;
		}
	}
	cout<<cnt<<'\n';
	return 0;
}




Measured memory_bytes: 512
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>

#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>

#include <algorithm>

using namespace std;
const int mod = 1000000007;
	

int main(int argc, char *argv[]) {
	string s;
	cin >> s;
	long long int res = 0;
	long long int count = 1;
	vector<int> v;
	long long int t = 1;
	for (int i = 0; i <= 1000001; i++) {
		v.push_back(t);
		t *= 3;
		t %= mod;
	}

	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '1') {
			res += (count * v[s.size() - i - 1]) % mod;
			res %= mod;
			count *= 2;
			count %= mod;
			
		}
	}
	res = (res + count) % mod;
	cout << res << endl;
}














Measured memory_bytes: 6640
#include <bits/stdc++.h>
using namespace std;
int main(){
string S;
  cin>>S;
  
  if(S.at(0)==S.at(3)&&S.at(3)!=S.at(1)&&S.at(1)==S.at(2)){
  cout<<"Yes"<<endl;
  }
  else if(S.at(0)==S.at(1)&&S.at(1)!=S.at(2)&&S.at(2)==S.at(3)){
  cout<<"Yes"<<endl;
  }
  else if(S.at(0)==S.at(2)&&S.at(2)!=S.at(1)&&S.at(1)==S.at(3)){
  cout<<"Yes"<<endl;
  }
  else{
  cout<<"No"<<endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll i = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll i = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll i = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll i = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void co(void){cout << '\n';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); co();}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); co();}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
// constexpr ll MOD = 998244353;
constexpr ld EPS = 1e-11;
const ld PI = acos(-1);

int main(void){
	ll n;
	cin >> n;
	Vec a(n);
	rep(i, n) cin >> a[i];

	unordered_map<ll, ll> ump;
	rep(i, n) ump[a[i]]++;

	ll ans = n;
	rep(i, n){
		if(ump[a[i]] >= 2){
			ans--;
			continue;
		}
		if(a[i] != 1 && ump.find(1LL) != ump.end()){
			ans--;
			continue;
		}
		for(ll j = 2; j * j <= a[i]; ++j){
			if(a[i] % j == 0){
				if(ump.find(j) != ump.end() || ump.find(a[i] / j) != ump.end()){
					ans--;
					break;
				}
			}
		}
		// co(ans);
	}
	co(ans);

	return 0;
}


Measured memory_bytes: 12944
/// b.cpp

# include <stdio.h>
# include <bits/stdc++.h>
using namespace std;
const pair < int , int > DD[] = {{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};
# define fi cin
# define fo cout
# define x first
# define y second
# define ll long long
# define IOS ios_base :: sync_with_stdio(0);cin.tie(0)
# define p(v) cerr << #v << " = " << v << '\n'
# define p2(v) cerr << #v << " = " << (complex < __typeof(v.x) > (v.x,v.y)) << '\n'
# define vi vector < int >
# define vl vector < ll >
# define pll pair < ll , ll >
# define pii pair < int , int >
# define mp make_pair
# define db long double
# define fail puts("-1")
# define yes puts("YES")
# define no puts("NO")
# define PP puts("Possible")
# define II puts("Impossible")
# define vii vector < pii >
# define vll vector < pll >
# define pb push_back
# define pdd pair < db , db >
template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;}
template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}
int main(void)
{
    #ifdef CF
    freopen("input","r",stdin);
    #endif // CF
    srand(time(0));
    fo << fixed << setprecision(7);
    cerr << fixed << setprecision(7);
    int n,m,q;
    fi>>n>>m>>q;
    static int s1[1 << 11][1 << 11];
    static int s2[1 << 11][1 << 11];
    static int s3[1 << 11][1 << 11];
    static char s[1 << 11][1 << 11];
    for (int i = 1;i <= n;++i)
        fi>>(s[i] + 1);
    auto Q1 = [&](int x1,int y1,int x2,int y2)
    {
        if (x1 > x2 || y1 > y2)
            return 0;
        return s1[x2][y2] + s1[x1 - 1][y1 - 1] - s1[x1 - 1][y2] - s1[x2][y1 - 1];
    };
    auto Q2 = [&](int x1,int y1,int x2,int y2)
    {
        if (x1 > x2 || y1 > y2)
            return 0;
        return s2[x2][y2] + s2[x1 - 1][y1 - 1] - s2[x1 - 1][y2] - s2[x2][y1 - 1];
    };
    auto Q3 = [&](int x1,int y1,int x2,int y2)
    {
        if (x1 > x2 || y1 > y2)
            return 0;
        return s3[x2][y2] + s3[x1 - 1][y1 - 1] - s3[x1 - 1][y2] - s3[x2][y1 - 1];
    };
    for (int i = 1;i <= n;++i)
        for (int j = 1;j <= m;++j)
        {
            s1[i][j] = s1[i - 1][j] + s1[i][j - 1] - s1[i - 1][j - 1] + (s[i][j] == '1');
            s2[i][j] = s2[i - 1][j] + s2[i][j - 1] - s2[i - 1][j - 1] + (s[i][j] == '1' && s[i - 1][j] == '1');
            s3[i][j] = s3[i - 1][j] + s3[i][j - 1] - s3[i - 1][j - 1] + (s[i][j] == '1' && s[i][j - 1] == '1');
        }
    while (q --)
    {
        int x1,y1,x2,y2;
        fi>>x1>>y1>>x2>>y2;
        fo << (Q1(x1,y1,x2,y2) - Q2(x1 + 1,y1,x2,y2) - Q3(x1,y1 + 1,x2,y2)) << '\n';
    }
    cerr << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
    return 0;
}


Measured memory_bytes: 55040
//TLE
#include <iostream>
using namespace std;

int m, n;
int max_ans = 8000000;

void solve() {
	int i, j;
	int cnt = 0;
	static bool used[8000000];
	
	for (i = 0; i < max_ans; i++) used[i] = false;
	
	for (i = m; ; i++) {
		if (used[i]) continue;
		if (cnt == n) break;
		cnt++;
		for (j = i; j < max_ans; j += i) {
			used[j] = true;
		}
	}
	cout << i << endl;
}

int main() {
	while (cin >> m >> n) {
		if (!m) break;
		solve();
	}
	return 0;
}

Measured memory_bytes: 10804