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

typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,N) for(int i=1;i<=n;i++)

long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}
int N;
const int MAXN = 16;

int A[MAXN];
int x[MAXN][MAXN];
int y[MAXN][MAXN];

bool valid(bool truer[]) {
  rep(i,N) {
    if(!truer[i+1])continue;
    rep(j,A[i]) {
      if(truer[x[i][j]] != y[i][j]){
        return false;
      }
    }
  }
  return true;
}


int main(){
    cin >> N;
    rep(i,N) {
      cin >> A[i];
      rep(j,A[i]) {
        cin >> x[i][j] >> y[i][j];
      }
    }

    bool truerl[N+1] = {0,1,1,0};
    int ans = 0;
    for(int i=0;i<(1<<N);i++) {
      int num = 0;
      bool truer[N+1];
      for(int bit =0;bit < N ; bit++) {
        if(i&(1<<bit)){
          num++;
          truer[bit+1] = true;
        }else {
          truer[bit+1] = false;
        }
      }
      if(valid(truer)){
        ans = max(num,ans);
      }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3600
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(){
  int N;
  scanf("%d",&N);
  long long int lun[N],hiki,k=9;
  if(N<10){
    for(int i=0;i<N;i++){
      lun[i]=i+1;
    }
  }else{
    for(int i=0;i<9;i++){
      lun[i]=i+1;
    }
    for(int i=0;k<N;i++){
      hiki=lun[i];
      if(hiki%10!=0){
        lun[k]=hiki*10+hiki%10-1;
        k++;
      }else{}
      
      lun[k]=hiki*10+hiki%10;
      k++;
      
      if(hiki%10!=9){
        lun[k]=hiki*10+hiki%10+1;
      k++;
      }else{}
    }
  }
  printf("%lld",lun[N-1]);
  return 0;
}

Measured memory_bytes: 896
//https://atcoder.jp/contests/dp/tasks/dp_p
//shauryakr
#include<bits/stdc++.h>
using namespace std;
int n;
vector<int> v[100010];
long long int mod = 1e9+7;
long long int dp[100010][2];

void solve(int node, int prev)
{
    long long int ans0 = 1, ans1 = 1;
    for(auto child : v[node])
    {
        if(child != prev)
        {
            solve(child, node);
            ans0 = ans0 * (dp[child][0] + dp[child][1]);
            if(ans0 >= mod)
                ans0 %= mod;
            ans1 = ans1 * (dp[child][0]);
            if(ans1 >= mod)
                ans1 %= mod;
        }
    }
    dp[node][0] = ans0;
    dp[node][1] = ans1;
}

int main()
{
    cin >> n;
    for(int i=1; i<n; i++)
    {
        int a, b;
        cin >> a >> b;
        v[a].push_back(b);
        v[b].push_back(a);   
    }

    solve(1, 0);

    cout << (dp[1][0] + dp[1][1])%mod << endl;
    return 0;
}


Measured memory_bytes: 14208
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {
            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }
        public static long mand(long x1 ,long y1,long x2,long y2)
        {
            return Math.Abs(x1 - x2) + Math.Abs(y1 - y2);
        }

        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            const long inf = long.MaxValue;
            var input = Reads();
            var n = input[0];
            var m = input[1];
            var a = new long[n];
            var b = new long[n];
            var c = new long[m];
            var d = new long[m];
            var answer = new long[n];
            for (int i = 0; i < n; i++)
            {
                input = Reads();
                a[i] = input[0];
                b[i] = input[1];
                answer[i] = 0;
            }
            for (int i = 0; i < m; i++)
            {
                input = Reads();
                c[i] = input[0];
                d[i] = input[1];
            }
            for (int i = 0; i < n; i++)
            {
                long tmp =inf;
                for (int j = 0; j < m; j++)
                {         
                    if (tmp > mand(a[i], b[i], c[j], d[j]))
                    {
                        tmp = mand(a[i], b[i], c[j], d[j]);
                        answer[i] = j + 1;
                    }
                }
                Console.WriteLine(answer[i]);
            }
            

            Console.Out.Flush();
        }
    }
}

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

int main() {
  int x,a;
  cin >> x >> a;
  if (x < a) {
	cout << "0" <<endl;
} else {
    cout << "10" <<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>
#include <bitset>
#include <tuple>
#include <set>
#include <map>
#define range(i, r) for(int i=0;i<r;i++)
#define ranges(i, l, r) for(int i=l;i<r;i++)
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
#define MODn 1000000009;
typedef long long int ll;


#define P 1000000007
#define N_MAX 2000000
ll fac[N_MAX+1];
ll inv[N_MAX+1];
ll finv[N_MAX+1];

ll comb(ll n, ll k){
    return (((fac[n]*finv[n-k])%P)*finv[k])%P;
}

void init(){
    fac[0] = finv[0] = fac[1] = finv[1] = inv[1] = 1;
    for(int i = 2; i <= N_MAX; i++){
        fac[i] = (fac[i-1]*i)%P;
        inv[i] = ((-(P/i)*inv[P%i])%P+P)%P;
        finv[i] = (finv[i-1]*inv[i])%P;
    }
}

using namespace std;

int main(int argc, char const *argv[]) {
  init();
  ll N, A, B, C, ans = 0;
  std::cin >> N >> A >> B >> C;
  std::vector<ll> as(N+1), bs(N+1);
  as[0] = bs[0] = 1;
  for(int i=1;i<=N;i++){
    as[i] = (as[i-1] * ((A*inv[100-C])%P))%P;
    bs[i] = (bs[i-1] * ((B*inv[100-C])%P))%P;
  }
  for(int i=0;i<N;i++){
    ans = (ans + ((((as[N]*bs[i])%P * (comb(N-1+i, N-1)%P))%P) * (((((N+i)*100)%P)*inv[100-C])%P))%P)%P;
    ans = (ans + ((((bs[N]*as[i])%P * (comb(N-1+i, N-1)%P))%P) * (((((N+i)*100)%P)*inv[100-C])%P))%P)%P;
  }
  std::cout << ans << '\n';
  return 0;
}


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

typedef long long ll;

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,l,n) for(int i=(l);i<(n);i++)

int main(){
	string s;
	string mae = string();
	string usiro = string();
	cin >> s;
	int Q;
	cin >> Q;
	int flag = 0;
	rep(i,Q){
		int t;
		cin >> t;
		if(t == 1) flag = abs(flag-1);
		else{
			int f;char c;
			cin >> f >> c;
			if((f == 1 && flag == 1) || (f == 2 && flag == 0)){
				usiro += c;
			} 
			else{
				mae += c;
			}
		}
	}
	reverse(mae.begin(),mae.end());
	string ans = mae + s + usiro;
	if(flag == 1){
		reverse(ans.begin(),ans.end());
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1348
n = int(input())
a = input()
b = input()
c = input()
count = 0
for i in range(0, n) :
    if a[i] == b[i] and b[i] == c[i] :
        pass
    elif a[i] == b[i] or b[i] == c[i] or c[i] == a[i] :
        count += 1
    else :
        count += 2
print(count)


Measured memory_bytes: 3060
#include<stdio.h>
#define N 100000
#define ROOT -1

typedef struct{
  int p;
  int left;
  int right;
}node;

node Tree[N];

int num;
/*??±???*/
int Depth(int);
/*??????*/
int Height(int);

/*main??¢??°*/
int main(){

  int i, a, b, id, tmp;
  int dep[N], hei[N], sib[N], deg[N];

  scanf("%d", &num);

  /*?????????*/
  for(i = 0; i < num; i++){
    Tree[i].left = ROOT;
    Tree[i].p =ROOT;
    Tree[i].right = ROOT;
    deg[i] = hei[i] = 0;
    sib[i] = deg[i] = ROOT;
  }

  /*????????????*/
  for(i = 0; i < num; i++){
    scanf("%d %d %d", &id, &a, &b);

    /*??????????????????*/
    if(a == ROOT && b == ROOT){
      deg[id] = 0;
    }
      /*???????????????*/
    else if (a != ROOT && b == ROOT){
      Tree[a].p = id;
      Tree[id].left = a;
      deg[id] = 1;
    }
      /*???????????????*/
    else if(a == ROOT && b != ROOT){
      deg[id] = 1;
      Tree[b].p = id;
      Tree[id].right = b;
    }
    /*??????????????????*/
    else{
      sib[a] = b;
      sib[b] = a;
      deg[id] = 2;
      Tree[a].p = id;
      Tree[b].p = id;
      Tree[id].left = a;
      Tree[id].right = b;

    }
  }


  /*??±?????¨??????????¨????*/
  for(i = 0; i < num; i++){
    dep[i] = Depth(i);
    hei[i] = Height(i);
  }


  /*??¨???*/
  for(i = 0; i < num; i++){
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ", i, Tree[i].p, sib[i], deg[i], dep[i], hei[i]);


    /*??????????¨????*/
    if(Tree[i].p == ROOT){printf("root\n");}
    else if(Tree[i].left == ROOT && Tree[i].right == ROOT){printf("leaf\n");}
else{printf("internal node\n");}
  }
  return 0;
}


/*??????*/
int Height(int p){
  int i;
  int cnt;
  int max = 0;

  for(i = 0; i < num; i++){
    if(Tree[i].p == p){
      cnt = Height(i) + 1;
      if(cnt > max) max = cnt;
    }
  }
  return max;
}
/*??±???*/

int Depth(int p){
  if(Tree[p].p == ROOT)return 0;
  else return Depth(Tree[p].p)+1;
}

Measured memory_bytes: 632
#include <stdio.h>
#include <stdlib.h>

int main(){
  int N;
  int A[1000];
  int v;
  int i,j;

  scanf("%d",&N);
  if(N <= 0 || 101 <= N) exit(0);
  
  for(i=0;i<N;i++)scanf("%d",&A[i]);

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



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

/*
レベルLバーガーの大きさは、
s[l]=3+2*s[l-1]で計算できる。
レベルLバーガーの下からy層までに含まれるパティの数をp[l][y]で定義する
y=1の時 p[l][y]=0
s[l-1]+1 >= y >= 2の時 p[l][y]=p[l-1][y-1]
y=s[l-1]+2の時 p[l][y]=1+p[l-1][s[l-1]]
y >= 2+s[l-1]の時 p[l][y]=1+p[l-1][s[l-1]]+p[l-1][y-2-s[l-1]]
*/

ll tmp[60];
ll tmp2[60];
ll num(ll i, ll j){
    //cout << "i:" << i << ", j:" << j << endl;
        if(i==0&&j<=0) return 0;
        else if(i==0&&j>=1) return 1;
        else if(j==1) return 0;
        else if(tmp[i-1]+1 >= j && j >= 2) return num(i-1,j-1);
        else if(j==tmp[i-1]+2) return 1+tmp2[i-1];
        else if(2+2*tmp[i-1] >= j && j >= 2+tmp[i-1]) return 1+tmp2[i-1] + num(i-1,j-2-tmp[i-1]);
        else if(3+2*tmp[i-1] == j) return 1+2*tmp2[i-1];
        else return 0;
    }


void solve(){
    ll n,x;
    cin >> n >> x;

    ll s[60];
    s[0]=1;
    for(ll i=1; i<=n; i++){
        s[i]=3 + 2 * s[i-1];
    }
    ll p[60];
    p[0]=1;
    for(ll i=1; i<=n; i++){
        p[i]=1 + 2*p[i-1];
    }

/*
    ll p[n+10][x+10];
    p[0][0]=0;
    p[0][1]=1;
    
    for(ll i=1; i<n+1; i++){
        for(ll j=1; j<x+1; j++){
            if(j==1) {
                p[i][j]=0; 
                cout << "1.i=" << i << ", j=" << j << ", p[i][j]=" << p[i][j] << endl;
            }
            else if(s[i-1]+1 >= j && j >= 2){
                p[i][j]=p[i-1][j-1];
                cout << "2.i=" << i << ", j=" << j << ", p[i][j]=" << p[i][j] << endl;
            }
            else if(j==s[i-1]+2) {
                p[i][j]=1+p[i-1][s[i-1]];
                cout << "3.i=" << i << ", j=" << j << ", p[i][j]=" << p[i][j] << endl;
            }
            else if(2+2*s[i-1] >= j && j >= 2+s[i-1]) {
                p[i][j]=1+p[i-1][s[i-1]] + p[i-1][j-2-s[i-1]];
                cout << "4.i=" << i << ", j=" << j << ", p[i][j]=" << p[i][j] << endl;
            }
            else if(3+2*s[i-1] >= j){
                p[i][j]=1+2*p[i-1][s[i-1]];
                cout << "5.i=" << i << ", j=" << j << ", p[i][j]=" << p[i][j] << endl;
            }
        }
        
    }
    */
    
    rep(i,60){
        tmp[i]=s[i];
        tmp2[i]=p[i];
    }
    cout << num(n,x) << endl;

}

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

Measured memory_bytes: 380
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit
#include <cstdio>	// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>	// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()
#define DEBUG 0

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
string FILE_NAME = "testcase.0095_";
string NAME;
string itos (int n )
{
	stringstream ss;
	ss << n;

	return ss.str();
}

int main()
{
//	cut here before submit 
#if DEBUG
	NAME = FILE_NAME;
	int CNT = 1;
	NAME += itos (CNT );
	while (freopen (NAME.c_str() , "r", stdin ) != NULL ) {
#endif
	ios_base::sync_with_stdio(0);
	int n; cin >> n;
	vector<P> av(n );
	rep (i, n ){
		int a, v; cin >> a >> v;
		av[i].first = -v;
		av[i].second = a;
	} // end rep

	sort (ALL (av ) );

	cout << av[0].second << ' ' << -av[0].first << endl;

#if DEBUG
	CNT++;	// cut here before submit
	NAME = FILE_NAME;
	NAME += itos (CNT );
	} // end loop; cut here before submit
#endif			
	return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define ff first
#define ss second
#define P 1000000007
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
 
using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii; 
typedef vector<int> vi;
  
void solve() {
	ll n, a, b, c, d;
	cin >> n >> a >> b >> c >> d;
	
	for(int m = 0; m < n; m++) {
		if(a - b >= -d * (m) + c * (n - m - 1) && a - b <= d * (n - m - 1) - c * m) {
			cout << "YES" << endl;
			return;
		}
	}
	
	cout << "NO" << endl;
}
 
int main(){
#define MULTITEST 0
#if MULTITEST   
 
    CASET {
        solve();
    }
    
#else
 
    solve();
    
#endif
 
    return 0;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
int main()
{
	int n,i,j,k;
	double t,A,b,dif=INT_MAX;
	cin>>n>>t>>A;
	int a[n];
	for (i=0;i<n;i++)
	cin>>a[i];
	for (i=0;i<n;i++)
	{
		if (abs(A-(t-0.006*a[i]))<dif)
		{
			dif=abs(A-(t-0.006*a[i]));
			j=i+1;
		}
	}
	cout<<j;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;

vector<pair<ll,ll>> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
 
#define MAX_N 100010
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
ll dp[100010];
int main(){
    ll n;
    cin >> n;
    ll x[n];
    for (ll i=0;i<n;i++)cin >> x[i];
    for (ll i=0;i<n;i++)dp[i]=INF;
    dp[0]=0;
    for (ll i=1;i<=n;i++){
        chmin(dp[i],dp[i-1]+abs(x[i-1]-x[i]));
        if (i>1)chmin(dp[i],dp[i-2]+abs(x[i-2]-x[i]));
    }
    cout << dp[n-1] << endl;
    return 0;
}



Measured memory_bytes: 1792
<?php
fscanf(STDIN, "%d %d", $N, $M);
$E = [];
$S = [];
for ($i = 1; $i <= $N; $i++) {
    $S[$i] = $i;
}
for ($i = 0; $i < $M; $i++) {
    fscanf(STDIN, "%d %d", $A, $B);
    $E[$A][$B] = 1;
    $E[$B][$A] = 1;
}
$visited = [];
for ($i = 1; $i <= $N; $i++) {
    if (!isset($visited[$i])) {
        $stack = [$i];
    }
    while($stack) {
        $cur = array_pop($stack);
        $visited[$cur] = 1;
        if (isset($E[$cur]) && is_array($E[$cur])) {
            foreach ($E[$cur] as $nxt => $dummy) {
                $S[$nxt] = $i;
                if (!isset($visited[$nxt])) {
                    $stack[] = $nxt;
                }
            }
        }
    }
}
printf("%d", count(array_unique($S)) - 1);


Measured memory_bytes: 61816
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int h, w; cin >> h >> w;
    vector<string> c(h);
    rep(i,h) cin >> c[i];
    vector<vector<char>> ans(2*h,vector<char>(w));
    rep(i,2*h)rep(j,w) ans[i][j] = c[i/2][j];
    rep(i,2*h) {
        rep(j,w) cout << ans[i][j];
        cout << endl;
    }
}

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

int main(){
  int n,i,j,s,sum=0;
  cin >> n;
  vector<int> a(n),b(n,0);
  for(i=0;i<n;i++){
    cin >> a.at(i);
  }
  for(i=n-1;i>=0;i--){
    s=0;
    for(j=1;j<=n/(i+1);j++){
      s += b.at(j*(i+1)-1);
    }
    b.at(i)=(s+a.at(i))%2;
    sum += b.at(i);
  }
  cout << sum << endl;
  for(i=0;i<n;i++){
    if(b.at(i)==1){
      cout << i+1 << ' ';
    }
  }
}

Measured memory_bytes: 4732
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <list>
#include <cstdint>
#include <bits/stdc++.h>
#include <queue>
#include <set>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for (int i = n - 1; i >= 0; i--)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

#define INF bit(60)
#define pb push_back
#define mod 1000000007

template <class T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
  if (b < a)
  {
    a = b;
    return 1;
  }
  return 0;
}

using namespace std;
using uif = uint_fast64_t;
using ll = long long int;

int qp(int a, ll b)
{
  int ans = 1;
  do
  {
    if (b & 1)
      ans = 1ll * ans * a % mod;
    a = 1ll * a * a % mod;
  } while (b >>= 1);
  return ans;
}
int qp(int a, ll b, int mo)
{
  int ans = 1;
  do
  {
    if (b & 1)
      ans = 1ll * ans * a % mo;
    a = 1ll * a * a % mo;
  } while (b >>= 1);
  return ans;
}

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

#define FACSIZE 2002

ll invfac[FACSIZE];
ll fac[FACSIZE];

ll mod_pow(ll, ll);
ll mod_add(ll, ll);
ll mod_mul(ll, ll);
ll mod_div(ll, ll);
void make_fact(ll);
void make_invfact(ll);

int main(void)
{

  ll n;
  cin >> n;
  string s;
  cin >> s;

  string ans = "";
  for (auto c : s)
  {
    ll diff = (ll)(c - 'A');
    ll next = (diff + n) % 26;
    ll ac = (char)('A' + next);
    ans += ac;
  }

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

ll mod_pow(ll x, ll r)
{
  if (r == 0)
    return 1;
  else if (r == 1)
    return x % mod;
  else if (r % 2 == 0)
  {
    ll t = mod_pow(x, r / 2) % mod;
    return t * t % mod;
  }
  else
  {
    ll t = mod_pow(x, r / 2) % mod;
    ll k = t * t % mod;
    return k * x % mod;
  }
}
ll mod_add(ll a, ll b)
{
  return (a + b) % mod;
}

ll mod_mul(ll a, ll b)
{
  return (a * b) % mod;
}

ll mod_div(ll a, ll b)
{
  return mod_mul(a, mod_pow(b, mod - 2));
}

void make_fact(ll n)
{
  fac[0] = 1;
  rep(i, n)
  {
    fac[i + 1] = mod_mul(fac[i], i + 1);
  }
}

void make_invfact(ll n)
{
  invfac[n] = mod_pow(fac[n], mod - 2);
  for (int i = n - 1; i >= 0; i--)
  {
    invfac[i] = mod_mul(invfac[i + 1], i + 1);
  }
}


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

int main(void){
  int n, a, b[100100], max=0, ans=0;
  for(int i=0;i<100100;++i){
    b[i] = 0;
  }
  cin >> n;
  for(int i=0;i<n;++i){
    cin >> a;
    ++b[a];
    ++b[a+1];
    ++b[a+2];
  }
  for(int i=0;i<100100;++i){
	if(max<b[i]) max = b[i];
  }
  cout << max << endl;
}

Measured memory_bytes: 640
N,D = map(int,input().split())

X = [0] * N
Y = [0] * N

for i in range(N):
    X[i],Y[i] = map(float,input().split())

count = 0

for i in range(N):
    d = (X[i])**2 + (Y[i])**2
    d = d**0.5
    if D >= d:
        count += 1
    if D < d:
        continue
        
print(count)

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

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

  if (A >= 13)
    cout << B << endl;
  else if (A >= 6 && A <= 12)
    cout << B/2 << endl;
  else
    cout << 0 << endl;
  
  return 0;
}


Measured memory_bytes: 256
N=int(input())
A = [int(input()) for i in range(N)]
maxval = max(A)
argmaxval = A.index(maxval)
for i,a in enumerate(A):
  if i==argmaxval:
    B = A[:]
    B[i]=0
    print(max(B))
  else:
    print(maxval)

Measured memory_bytes: 14080
if __name__ == '__main__':
    input_list = list(map(int, input().split()))
    N = input_list
    input_list = list(map(int, input().split()))
    V_list = input_list
    input_list = list(map(int, input().split()))
    C_list = input_list

    d_list = [v - c for (v, c) in zip(V_list, C_list)]

    answer = 0

    for d in d_list:
        if d > 0 :
            answer += d

    print(answer)

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

int main(){
    int n,k;
    cin >> n >> k;
    int a;
    int sum = 0;
    for (int i = 0; i < n; i++){
        cin >> a;
        sum += min(2*a,2*abs(a-k));
    }

    cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; (i) < (n); ++ (i))
#define loop(i,a,n) for (int i = (a); (i) < (n); ++ (i))
#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF (int)1e9
#define MOD 0
//#define int ll
using namespace std;
typedef vector<int> vi;
 
signed main(){
    string s;
    cin >> s;
    int c= 0,oc=0;
    rep(i,(int)s.size()) {
        if(s[i] != 'A' && s[i] != 'T' && s[i] != 'G' && s[i] != 'C') {
            if(oc < c ) {
                oc = c;
                c = 0;
            }
        } else {
            c++;
        }
    }
    if(oc < c ) {
        oc = c;
        c = 0;
    }
    cout << oc << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n,num=1,ans=0;
    cin>>n;
    while(n){
        n/=2;
        ans+=num;
        num*=2;
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long transport[6];
  long long n; cin >> n >> transport[1] >> transport[2] >> transport[3] >> transport[4] >> transport[5];
  long long res = ceil(n*1.0/min({transport[1], transport[2], transport[3], transport[4], transport[5]})*1.0) + 4;
  cout << res << "\n";
  return 0;
}


Measured memory_bytes: 256
import java.util.*;


public class Main {
    public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while (true) {
		    String str = sc.nextLine();
		    if ("0".equals(str)) {
		        break;
		    }
		    int sum = 0;
		    for (int i = 0; i < str.length(); i++) {
		        sum += str.charAt(i) - '0';
		        //System.out.println(str.charAt(i));
		        //System.out.println("数値は" + sum);
		    }
		    System.out.println(sum);
		}
		
    }
}


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


const long long int mod = 1e9 + 7;
long long int helper(long long int n, vector<long long int> &dp){
	if(n == 0) return 1;
    if(n < 3) return 0;
	// if(n == 3) return 1;
	if(dp[n] != 0) return dp[n];
	long long int ans = 0;
	for(long long int j = n; j >= 3; j--){
		ans += helper(n-j, dp)%mod;
	}
    ans = ans%mod;
	dp[n] = ans;
	return ans;
}

int main() {
    const long long int mod = 1e9 + 7;
    long long int s;
    cin >> s;
    vector<long long int> dp(s+1, 0);
    helper(s, dp);
    cout <<  dp[s] << endl;
}


Measured memory_bytes: 3136
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
inline int read(){
	int f=1,ans=0;char c;
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){ans=ans*10+c-'0';c=getchar();}
	return ans*f;
}
int a,b;
int main(){
	a=read(),b=read();
	if(a>=13) printf("%d\n",b);
	if(6<=a&&a<=12) printf("%d\n",b/2);
	if(a<=5) printf("0\n");
	return 0;
}


Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline().rstrip("\r\n")

n, k = map(int, input().split())
a = [int(x) for x in input().split()]

from collections import Counter

c = Counter(a)
need = len(c) - k
ans = 0

for i in sorted(c.values()):
    if need <= 0:
        break
    ans += i
    need -= 1

print(ans)

Measured memory_bytes: 120268
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 1001001001001001001;  // > 10^18
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

int main () {

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

    ll ans = b/x;
    ans -= a/x;

    if (a % x == 0) {
        ans++;
    } 

    cout << ans << endl;

    return 0;
}





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

int main( void )
{
    double input;
    double eps = 1e-12;

    while ( cin >> input && ( input < 0.0 == false ) )
    {
        int     p = static_cast <int>( floor( input ) );
        double  q = input - p;
        double  test = q;
        bool    NA = false;

        if ( p >= ( 1 << 8 ) ) NA = true;
        for ( int i = 0; i < 4; i++ ) test *= 2.0;
        if ( ( fabs( floor( test ) - ceil( test ) ) < eps ) == false ) NA = true;

        if ( NA )
        {
            cout << "NA" << endl;
        }
        else
        {
            for ( int i = 7; i >= 0; i-- ) cout << ( p & 1 << i ? 1 : 0 );
            cout << ".";
            test = q;
            for ( int i = 0; i < 4; i++ )
            {
                q *= 2.0;
                if ( ( q < 1.0 ) == false )
                {
                    cout << "1";
                    q -= 1.0;
                }
                else cout << "0";
            }
            cout << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b % mod; if (a < 0) a += mod; else if (a >= mod) a -= mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }

void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(11);
  int T;
  T = 1;
  while (T--) solve();
}

void solve() {
  ll l, r;
  cin >> l >> r;

  auto to_bit = [&](ll x) {
    vector<int> v;
    rep(i, 60) { v.eb(x % 2); x /= 2; } // 下の rep(i, 60) に合わせる
    reverse(all(v));
    return v;
  };
  vector<int> L = to_bit(l), R = to_bit(r);

  int dp[61][2][2][2];
  rep(i, 61) rep(j, 2) rep(k, 2) rep(l, 2) dp[i][j][k][l] = 0;
  dp[0][0][0][0] = 1;
  // 桁, L < x, y < R, 先頭 1 1 が現れた
  rep(i, 60) rep(j, 2) rep(k, 2) rep(l, 2) {
    rep(x, 2) rep(y, 2) {
      if (y == 0 && x == 1) continue;
      if (j == 0 && L[i] > x) continue;
      if (k == 0 && R[i] < y) continue;
      if (l == 0 && x != y) continue; // l = 1 になるまでは, (x, y) = (0, 0) or (1, 1)
      add(dp[i + 1][j | (L[i] < x)][k | (y < R[i])][l | (x + y == 2)], dp[i][j][k][l]);
    }
  }
  int ans = 0;
  rep(j, 2) rep(k, 2) add(ans, dp[60][j][k][1]);
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long cnt = 10000000000000000L;

		for(long i = 1; i * i <= N; i++){
			if(N % i == 0){
				long j = N / i;
				cnt = Math.min(cnt, i + j - 2);
			}
		}
		System.out.println(cnt);
		sc.close();
	}
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

int main(){
    ll n, c, k;
    cin >> n >> c >> k;
    VL t(n);
    rep(i, 0, n) cin >> t[i];
    sort(ALL(t));
    ll last = -1, cnt = 0, num = 0;
    rep(i, 0, n) {
        if(last < t[i] || num >= c) {
            cerr << t[i] << " " << num << endl;
            last = t[i] + k;
            cnt++;
            num = 1;
        }else{
            num++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 4032
extern crate core;

use std::io::{self, Read};

#[macro_export]
macro_rules! input {
  ($s:expr=>$($t:tt)*) => {
    let mut lines=$s.split("\n");
    $(
        line_parse!(lines,$t);
    )*
  };
}

macro_rules! line_parse {
  ($lines:expr,($($name:ident:$t:tt)*)) => {
    let mut line=$lines.next().unwrap().split_whitespace();
    $(value_def!(line,$name,$t);)*
  };

  //複数行
  ($lines:expr,{$n:expr;$name:ident:$t:tt}) => {
    values_def!($lines,$n,$name,$t);
  };
}

macro_rules! value_def {
    ($line:expr, $name:ident, $t:tt) => {
        let $name = value!($line, $t);
    };
}

macro_rules! values_def {
    ($lines:expr, $n:expr, $name:ident, $t:tt) => {
        let $name = {
            let mut vec = Vec::new();
            for i in 0..$n {
                let mut next = $lines.next().unwrap().split_whitespace();
                vec.push(value!(next, $t));
            }
            vec
        };
    };
}

macro_rules! value {
  //配列
  ($line:expr,[$t:tt]) => {
    $line.map(|x|{
      let mut iter=::std::iter::once(x);
      value!(iter,$t)
    }).collect::<Vec<_>>()
  };
  //タプル
  ($line:expr,($($t:tt),*)) => {
    ($(value!($line,$t),)*)
  };
  //文字列
  ($line:expr,#) => {
    $line.next().unwrap()
  };
  //インデックス(-1)
  ($line:expr,@) => {
    $line.next().unwrap().parse::<usize>().unwrap()-1
  };
  //単一値
  ($line:expr,$t:ty) => {
    $line.next().unwrap().parse::<$t>().unwrap()
  };
}

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = solve(input.trim().to_string());
    println!("{}", output);
}

fn solve(input: String) -> String {
    input!(input=>(n:i64));
    ((n / 2) * (n / 2 + if n % 2 == 0 { 0 } else { 1 })).to_string()
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output.trim().to_string(),super::solve($input.trim().to_string()));
                }
            )*
        }
    }
}

tests! {
    test1: "3" => "2",
    test2: "6" => "9",
    test3: "11" => "30",
    test4: "50" => "625",
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include<cstring>
#include<map>
#include<set>
#include<cstdlib>
#include<bitset>
using namespace std;
typedef long long ll;
int main(void)
{
	ll x;
	cin>>x;
	if(x<30) puts("No");
	else puts("Yes");
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
  int h,w,n;
  cin >> h >> w >> n;
  vector<pair<int,int>> v(n);
  for ( int i=0; i<n; i++ ) {
    cin >> v[i].first >> v[i].second;
    v[i].first--; v[i].second--;
  }
  map<pair<int,int>,ll> mp; 
  for ( int i=0; i<n; i++ ) {
    int x=v[i].first,y=v[i].second;
    for ( int j=-2; j<=0; j++ ) {
      for ( int k=-2; k<=0; k++ ) {
        if ( x+j>=0 && x+j<h-2 && y+k>=0 && y+k<w-2 ) {
          mp[make_pair(x+j,y+k)]++;
        }
      }
    }
  }
  vector<ll> ans(10);
  ll cnt=0;
  for ( auto &p:mp ) {
    // cout << "(" << p.first.first << ',' << p.first.second << ')' << ' ' << p.second << '\n';
    cnt++;
    ans[p.second]++;
  }
  ans[0]=(ll)(h-2)*(w-2)-cnt;
  // cout << cnt << ' ' << (h-2)*(w-2) << '\n';
  for ( int i=0; i<=9; i++ ) {
    cout << ans[i] << '\n';
  }
  return 0;
}


Measured memory_bytes: 57216
#include <bits/stdc++.h>
#define R register
#define mp make_pair
#define ll long long
#define pii pair<int, int>
using namespace std;
const int mod = 998244353, N = 2100;

int n, a[N];
pii b[N];
ll f[N][N];

inline int addMod(int a, int b) {
	return (a += b) >= mod ? a - mod : a;
}

inline ll quickpow(ll base, ll pw) {
	ll ret = 1;
	while (pw) {
		if (pw & 1) ret = ret * base % mod;
		base = base * base % mod, pw >>= 1;
	}
	return ret;
}

template <class T>
inline void read(T &x) {
	x = 0;
	char ch = getchar(), w = 0;
	while (!isdigit(ch)) w = (ch == '-'), ch = getchar();
	while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
	x = w ? -x : x;
	return;
}

int main() {
	read(n);
	for (R int i = 1; i <= n; ++i)
		read(a[i]), b[i] = mp(a[i], i);
	sort(b + 1, b + 1 + n);
	for (R int l = n - 1; ~l; --l)
		for (R int i = 1, j = l; j <= n; ++i, ++j) {
			int x = b[l + 1].first, y = b[l + 1].second;
			if (j < n) f[i][j] = max(f[i][j], f[i][j + 1] + (ll) x * abs(j + 1 - y));
			if (i > 1) f[i][j] = max(f[i][j], f[i - 1][j] + (ll) x * abs(i - 1 - y));
		}
	ll ans = 0;
	for (R int i = 1; i <= n + 1; ++i)
		ans = max(ans, f[i][i - 1]);
	cout << ans << endl;
	return 0;
}

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

namespace ABC135
{
    class C
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            string[] input = Console.ReadLine().Split(' ');
            int[] A = new int[N + 1];
            for (int i = 0; i < N + 1; i++)
            {
                A[i] = int.Parse(input[i]);
            }

            input = Console.ReadLine().Split(' ');
            int[] B = new int[N];
            for (int i = 0; i < N; i++)
            {
                B[i] = int.Parse(input[i]);
            }

            long beforeSum = 0;
            long afterSum = 0;

            for (int i = 0; i < N; i++)
            {
                beforeSum += B[i];
            }

            int tmp = 0;
            for (int i = 0; i < N; i++)
            {
                tmp = B[i] - A[i];
                if (tmp < 0) { B[i] = 0; A[i] = Math.Abs(tmp); }
                if (tmp == 0) { B[i] = 0; A[i] = 0; }
                if (tmp > 0) { B[i] = Math.Abs(tmp); A[i] = 0; }

                tmp = B[i] - A[i + 1];
                if (tmp < 0) { B[i] = 0; A[i + 1] = Math.Abs(tmp); }
                if (tmp == 0) { B[i] = 0; A[i + 1] = 0; }
                if (tmp > 0) { B[i] = Math.Abs(tmp); A[i + 1] = 0; }
            }

            for (int i = 0; i < N; i++)
            {
                afterSum += B[i];
            }
            Console.WriteLine(beforeSum - afterSum);
        }
    }
}


Measured memory_bytes: 34980
#include <iostream>
using namespace std;
int main(void){
    int N;
    double M;
    cin>>N>>M;
    double sum=0;
    double P[N];
    for(int i=0;i<N;i++){
        cin>>P[i];
        sum+=P[i];
    }
    int count=0;
    for(int i=0;i<N;i++){
        if(P[i]/sum >= 1/(4*M)){
            count++;
        }
    }
    if(count>=M){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 256
def cumulative_sum(array)
  array.inject([]) { |a, num| a << (a.last || 0) + num; a }
end

# def cumulative_sum(array)
#   array.each_with_object([]) { |num, obj| obj << (obj.last || 0) + num }
# end

n = gets.to_i
creatures = gets.split.map(&:to_i).sort
cumulative_sum = cumulative_sum(creatures)
ans = 1
(n - 2).downto(0) do |i|
  break if creatures[i + 1] > 2 * cumulative_sum[i]
  ans += 1
end
puts ans


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

const int N = 55;

int n, a[N], b[N];
int dest;
int start;
vector <long long> vec;
vector <long long> cand[N];

void brute(int x, int pos, long long mask) {
	if (x == dest) {
		vec.push_back(mask);
		return;
	}
	if (pos == 0) return;

	int y = x % pos;
	if (y != x && y >= dest) {
		brute(y, pos - 1, mask | (1LL << pos));
	}
	brute(x, pos - 1, mask);
}

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

	cin >> n;
	for (int i = 1; i <= n; ++i) cin >> a[i];
	for (int i = 1; i <= n; ++i) cin >> b[i];

	for (int i = 1; i <= n; ++i) {
		vec.clear();
		start = a[i]; dest = b[i];
		brute(start, 50, 0);
		cand[i] = vec;
	}

	long long res = 0;
	int t = -1;
	for (int j = 1; j <= 50; ++j) {
		long long biggest = (1LL << j + 1) - 2;
		bool ok = true;
		for (int i = 1; i <= n; ++i) {
			bool found = false;
			for (auto &mask : cand[i]) {
				if ((biggest & mask) == mask) {
					found = true;
				}
			}
			if (!found) {
				ok = false; break;
			}
		}

		if (ok) {
			t = j; 
			for (int i = 1; i <= n; ++i) {
				vec.clear();
				for (auto &mask : cand[i]) {
					if ((biggest & mask) == mask) vec.push_back(mask);
				}
				cand[i] = vec;
			}
			break;
		}
	}

	if (t == -1) return printf("-1\n"), 0;

	for (int j = t; j >= 1; --j) {
		bool ok = true;
		for (int i = 1; i <= n; ++i) {
			bool found = false;
			for (auto &mask : cand[i]) {
				if (!(mask >> j & 1)) found = true;
			}
			if (!found) {
				ok = false; break;
			}
		}

		if (!ok) { // we have to choose j
			res |= (1LL << j);
			for (int i = 1; i <= n; ++i) {
				for (auto &mask : cand[i]) {
					if (mask >> j & 1) mask ^= (1LL << j);
				}
			}
		} else {
			for (int i = 1; i <= n; ++i) {
				vec.clear();
				for (auto &mask : cand[i]) {
					if (!(mask >> j & 1)) vec.push_back(mask);
				}
				cand[i] = vec;
			}
		}
	}

	cout << res << endl;
}

Measured memory_bytes: 384
#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[i];
  int ans = 0;
  while(true){
    for(int i = 0; i < n; i++){
      if(a[i] % 2 == 1){
        cout << ans << endl;
        return 0;
      }
    }
    ans++;
    for(int i = 0; i < n; i++){
      a[i] /= 2;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
//naveen mall
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb               push_back
#define sz(c)            (int)c.size()
#define len(c)           (int)c.length()
#define vec              vector
#define int              long long int
#define all(c)           c.begin(), c.end()
#define rall(c)          c.rbegin(), c.rend()
#define trav(a,i)        for(auto& i: a)
#define fl(i,a,b) for(int i = (int)(a); i <= (int)(b); i++)
#define rfl(i,a,b) for(int i = (int)(a); i >= (int)(b); i--)
#define invect(v,n)       for(int i=0;i<n;i++ ){int arb;cin>>arb;v.pb(arb);}
#define inset(s,n)        forloop(n){int aset;cin>>aset;s.insert(aset);}
#define display(c)        trav(c,i) cout<<i<<" ";cout<<"\n";
#define F                 first
#define S                 second
#define pii               pair<int,int>
#define PB                pop_back
#define endl              "\n"
#define copy(a,b)         copy(all(a),back_inserter(b));
#define section(a,b,w)    set_intersection(a.begin(), a.end(),b.begin(), b.end(),back_inserter(w));
#define union(a,b,w)      set_union(a.begin(), a.end(),b.begin(), b.end(),back_inserter(w));
#define diff(a,b,w)       set_difference(a.begin(), a.end(),b.begin(), b.end(),back_inserter(w));
#define symdiff(a,b,w)    set_symmetric_difference(a.begin(), a.end(),b.begin(), b.end(),back_inserter(w));

const long long INF64 = 1e18;





void solve()
 { 
   int n,W;
   cin>>n>>W;
   vec<pair<int,int> >v;
   fl(i,0,n-1)
     {
     	int w,x;
     	cin>>w>>x;
     	v.pb({w,x});

     }
     int dp[n+1][W+1];
       memset(dp,-1,sizeof(dp));
       for(int i=0;i<=n;i++)
       	   {for(int j=0;j<=W;j++)
       	   	{ if(i==0||j==0)
       	   		   dp[i][j]=0;
       	   		  else if(v[i-1].F> j)
       	   		   	   dp[i][j]=dp[i-1][j];
       	   		   	else if(v[i-1].F<=j)
       	   		   		  dp[i][j]=max(v[i-1].S+dp[i-1][j-v[i-1].F],dp[i-1][j]);



       	   	}
       	   }
       	   cout<<dp[n][W];

 }



  








 



signed main()
{fast
	int t;
   //cin>>t;
	t=1;

	while(t--)
		 {
		 	solve();
		 }
}












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

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++) // repマクロ
#define all(v) v.begin(), v.end() // sort等の関数呼び出しを簡潔にする

using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

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

    int middle = ((int)S.size() - 1)/2;
    bool flag = true;
    for(int i = 0; i < middle; i++){
        if((S.at(i) == S.at(middle - i - 1)) && (S.at(middle + i + 1) == S.at((int)S.size() -i-1)) && (S.at(i) == S.at((int)S.size() - i-1)) ){
            ;
        }else{
            flag = false;
        }
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
return 0;
}

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    int N; cin >> N;
    int v[10][10];
    memset(v, 0, sizeof(v));
    rep1(i, N){
        string s = to_string(i);
        v[s[0]-'0'][s[s.size()-1]-'0']++;
    }
    ll res=0;
    rep1(i, 9){
        rep1(j, 9){
            res += v[i][j]*v[j][i];
        }
    }

    cout << res << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair < ll, ll > PLL;
#define rep(i,n) for (int i = 0; i < (n); ++i)
ll MOD = 1e4+7;
int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0;
    rep(i, 1000) {
        int tmp_num = i;
        vector<int> keta;
        while( tmp_num > 0 ) {
            keta.push_back(tmp_num % 10);
            tmp_num /= 10;
        }
        if ( i == 0 ) {
            rep(j, 3) keta.push_back(0);
        }
        else if ( i < 10 ) {
            rep(j, 2) keta.push_back(0);
        }
        else if ( i < 100 ) {
            keta.push_back(0);
        }
        int keta_index = 2;
        rep(j, n) {
            if ( keta_index < 0 ) break;
            if ( s[j] == keta[keta_index] + '0' ) {
                --keta_index;
                continue;
            }
        }
        if ( keta_index < 0 ) ++ans;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256