akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
#include <functional>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<PII> VPI;
typedef vector<PLL> VPL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

int main(){
  int N;
  cin>>N;
  VI A(N),B(N);
  rep(i,N) cin>>A[i];
  rep(i,N) cin>>B[i];
  VI X(N);
  int tmp=0;
  int cnt=0;
  int C=0;
  int F=1;
  while(tmp<=N-1){
    if(A[C]!=B[tmp] and X[C]==0){
      X[C]=B[tmp];
      tmp++;
      cnt=0;
    }else{
      cnt++;
    }
    C=(C+1)%N;
    if(cnt>=N){
      F=0;
      break;
    }
  }
  if(F==0){
    reverse(all(B));
    rep(i,N) X[i]=0;
    tmp=0;
    cnt=0;
    C=0;
    F=1;
    while(tmp<=N-1){
      if(A[C]!=B[tmp] and X[C]==0){
        X[C]=B[tmp];
        tmp++;
        cnt=0;
      }else{
        cnt++;
      }
      C=(C+1)%N;
      if(cnt>=N){
        F=0;
        break;
      }
    }
  }
  if(F){
    cout<<"Yes"<<endl;
    rep(i,N) cout<<X[i]<<" ";
    cout<<endl;
  }else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 5644
# @author 

import sys

class NSlimes:
    def solve(self):
        n = int(input())
        a = [None] + [int(_) for _ in input().split()]

        dp = [[float('inf')] * (n + 1) for _ in range(n + 1)]
        for i in range(1, n + 1):
            dp[i][i] = 0
        for i in range(n + 1, 0, -1):
            for j in range(1, n + 1):
                s = sum(a[p] for p in range(i, j + 1))
                for k in range(i, j):
                    dp[i][j] = min(dp[i][k] + dp[k + 1][j] + s, dp[i][j])

        print(dp[1][n])


        # Greedy, not working

        # b = a[:]
        # ans = 0
        # for i in range(n - 1):
        #     idx = -1
        #     mn = float('inf')
        #     for j in range(n - 1 - i):
        #         if b[j] + b[j + 1] < mn:
        #             mn = b[j] + b[j + 1]
        #             idx = j
        #     assert(idx != -1)
        #     b[idx] += b[idx + 1]
        #     ans += b[idx]
        #     del b[idx + 1]
        # assert(len(b) == 1)
        # print(ans)

solver = NSlimes()
input = sys.stdin.readline

solver.solve()


Measured memory_bytes: 48864
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

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

#define fast        	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ordered_set 	tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update>

#define endl        	"\n"
#define pb          	push_back
#define mp          	make_pair
#define F           	first
#define S           	second
#define int             long long int

#define ALL(v)      	v.begin(),v.end()
#define ALLR(v)     	v.rbegin(),v.rend()
#define pii         	3.14159265358979323
#define inf     		LLONG_MAX
#define ones(x)     	__builtin_popcount(x)
#define fill(a,b)   	memset(a,b,sizeof(a))
#define mod 			998244353

ll mod_pow(ll a,ll b) 
{
    ll res = 1;
    while(b)	
    {
        if(b&1) 	
        {
        	res=(res*a)%mod;
        }
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}

ll mod_inverse(ll a) 
{
	return mod_pow(a , mod-2);
}

void solve()
{
	int x , n;
	
	cin >> x >> n;
	
	map<int , int> ff;
	
	int y , r1 , r2;
	
	for(int i = 0; i < n; ++i) {
		cin >> y;
		ff[y]++;
	}
	
	for(int i = x; i <= x+200; ++i) {
		if(ff[i] > 0) {
			continue;
		}
		else {
			r1 = i;
			break;
		}
	}
	
	for(int i = x; i >= x-200; --i) {
		if(ff[i] > 0) {
			continue;
		}
		else {
			r2 = i;
			break;
		}
	}
	
	if(abs(x-r1) >= abs(x-r2)) {
		cout << r2;
	}
	else {
		cout << r1;
	}
}

signed main() {
    fast;
    
    int t = 1;
    
    //cin >> t;
    
    while(t--) {
        solve();
    }
 
    return 0;
}


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


int main(void){
	string s;
	cin>>s;
	char lst = 0;
	int changes = 0;
	for (auto i:s){
		if(lst != i){
			changes++;
			lst = i;
		}
	}
	cout<<changes-1;
	return 0;
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REPR(i, n) for(int i = n - 1;i >= 0;i--)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define ll long long
#define INF 1e9
int main()
{
    int x, n;
    int p[105];
    cin >> x >> n;
    REP(i, n) cin >> p[i];

    int dif = INF;
    int newnumber = INF;
    int backnumber = -INF;
    bool judge = true;

    FOR(i, 0, 102) {
        if(abs(x - i) < dif){
            REP(j, n){ 
                if(p[j] == i) judge = false;
            }
            if(judge == true) {
                newnumber = i;
            //if(newnumber < backnumber) newnumber = backnumber;
            //else{
                dif = abs(x - i);
            }
            //    backnumber = newnumber;
               
            judge = true;
        }
    }
    cout << newnumber << endl;

    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <utility>
using namespace std;

typedef long long ll;

const int maxn = 200010;
const ll INF = 40000000010LL;

pair<ll,ll> seg[maxn * 4];
int n,q,a,b;
ll x[maxn];

void update(int l, int r, int k)
{
	seg[k].first = min(seg[k*2].first, seg[k*2+1].first);
	seg[k].second = min(seg[k*2].second, seg[k*2+1].second);
}

void build(int l, int r, int k)
{
	if (l==r)
	{
		if (l==b)
		{
			seg[k] = make_pair(-b,b);
			return;
		}
		seg[k] = make_pair(INF,INF);
		return;
	}
	int mid = (l+r)/2;
	build(l,mid,k*2);
	build(mid+1,r,k*2+1);
	update(l,r,k);
}

pair<ll,ll> query(int l, int r, int a, int b, int k)
{
	if (l>r) return make_pair(INF,INF);
	if (l==a && r==b) return seg[k];
	int mid = (a+b)/2;
	if (r<=mid) return query(l,r,a,mid,k*2);
	else if (l>mid) return query(l,r,mid+1,b,k*2+1);
	else
	{
		pair<ll,ll> tmp1 = query(l,mid,a,mid,k*2), tmp2 = query(mid+1,r,mid+1,b,k*2+1);
		return make_pair(min(tmp1.first,tmp2.first), min(tmp1.second, tmp2.second));
	}
}

void modify(int x, int a, int b, int k, ll num)
{
	if (a==b)
	{
		seg[k] = make_pair(num-a, num+a);
		return;
	}
	int mid = (a+b)/2;
	if (x<=mid) modify(x,a,mid,k*2,num);
	else modify(x,mid+1,b,k*2+1,num);
	update(a,b,k);
}

int main()
{
	//freopen("F.in","r",stdin);
	scanf("%d%d%d%d",&n,&q,&a,&b);
	build(1,n,1);
	x[0] = a;
	ll lazy = 0;
	for (int i=1;i<=q;i++)
	{
		scanf("%lld",&x[i]);
		ll tmp = min(query(1,x[i],1,n,1).first + x[i], query(x[i]+1,n,1,n,1).second - x[i]);
		lazy += abs(x[i]-x[i-1]);
		modify(x[i-1],1,n,1,tmp - abs(x[i]-x[i-1]));
	}
	
	ll ans = INF;
	for (int i=1;i<=n;i++) ans = min(ans, query(i,i,1,n,1).first + i);
	printf("%lld\n",ans + lazy);
	return 0;
}


Measured memory_bytes: 10496
N = int(input())

dp = [10 ** 9] * 100001
dp[0] = 1

for i in range(N):
    if dp[i] > 0:
        dp[i + 1] = min(dp[i] + 1, dp[i + 1])
        for j in range(1, 7):
            if 6 ** j + i <= N:
                dp[i + 6 ** j] = min(dp[i] + 1, dp[i + 6 ** j])
            if 9 ** j + i <= N:
                dp[i + 9 ** j] = min(dp[i] + 1, dp[i + 9 ** j])

print(dp[N] - 1)


Measured memory_bytes: 9632
use std::io;
use std::io::Read;
use std::collections::HashMap;

fn main() {
    // inputs
    let mut stdin = io::stdin();
    let mut lines_str = String::new();
    let _ = stdin.read_to_string(&mut lines_str);
    let mut lines = lines_str.lines();
    let n :usize = lines.next().expect("").trim().parse().unwrap();
    let mut v :Vec<usize> = Vec::new();
    let mut line2iter = lines.next().expect("").split_whitespace();
    for _ in 0..n {
        v.push(line2iter.next().expect("").trim().parse().unwrap());
    }
    let v = v;

    if n == 2 {
        if v[0] == v[1] {
            println!("1");
            return;
        } else {
            println!("0");
            return;
        }
    }

    let mut vodd_vallist :HashMap<usize,usize> = HashMap::new();
    for j in 0..(n/2) {
        let count = vodd_vallist.entry(v[2*j]).or_insert(0);
        *count += 1;
    }
    let mut vodd :Vec<(usize,usize)> = vodd_vallist.iter().map(|(&x,&y)| (x,y) ).collect();
    vodd.sort_by(|&y,&w| (w.1).cmp(&y.1));


    let mut veven_vallist :HashMap<usize,usize> = HashMap::new();
    for j in 0..(n/2) {
        let count = veven_vallist.entry(v[2*j+1]).or_insert(0);
        *count += 1;
    }
    let mut veven :Vec<(usize,usize)> = veven_vallist.iter().map(|(&x,&y)| (x,y) ).collect();
    veven.sort_by(|&y,&w| (w.1).cmp(&y.1));

    let answer;
    if vodd[0].0 == veven[0].0 {
        if vodd.len() == 1 {
            if veven.len() == 1 {
                answer = n/2;
            } else {
                answer = n - vodd[0].1 - veven[1].1;
            }
        } else if veven.len() == 1 {
            answer = n - vodd[1].1 - veven[0].1;
        } else if vodd[1].1 > veven[1].1 {
            answer = n - vodd[1].1 - veven[0].1;
        } else {
            answer = n - vodd[0].1 - veven[1].1;
        }
    } else {
        answer = n - vodd[0].1 - veven[0].1;
    }

    println!("{}",answer);
}


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

int a[10]={1,1,1,1,1,1,1,1,1,1};
int s[50],t[50],c[50],d[50];

int main(){
    int n,m,q; cin >> n >> m >> q;
    for(int i=0;i<q;i++){
        cin >> s[i] >> t[i] >> c[i] >> d[i];
    }
    bool flag=true;
    ll ans=-1;
    while(flag){
        ll score=0;
        for(int i=0;i<q;i++){
            if(a[t[i]-1]-a[s[i]-1]==c[i]) score+=d[i]; 
        }
        ans=max(ans,score);
        // for(int i=0;i<n;i++) cout << a[i];
        // cout << " " <<  ans << endl;
        for(int i=n-1;i>=0;i--){
            if(a[i]==m){
                if(i==0){
                    flag=false; break;
                }
                if(a[i-1]!=m){
                    a[i-1]++;
                    for(int j=i;j<n;j++){
                        a[j]=a[i-1];
                    }
                    break;
                }
            }else{
                a[i]++; break;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
 
typedef long long ll;
typedef long double ld;
 
#define REP(i,a,n) for(int (i)=(a); (i)<(int)(n); (i)++)
#define rep(i,n) REP(i,0,n)
#define vec vector 
 
const ll large_P = 1e9 + 7;
 
 
int main(){
  ll L;
  cin >> L;   
  ll L_prime;
  
  ll V;
  ll v = 0;  //27で割ったあまり
  
  if(L%3 == 0){
    V = (L/3)*(L/3)*(L/3);
  }else{
    if(L%3 == 1){
      L_prime = L - 1LL;
      V = (L_prime + 3LL)*L_prime*L_prime/27LL + (3LL*L_prime + 1LL)/27LL;
      v = (3LL*L_prime + 1LL)%27LL;
    }else{
      L_prime = L - 2LL;
      V = (L_prime + 6LL)*L_prime*L_prime/27LL + (12LL*L_prime + 8LL)/27LL;
      v = (12LL*L_prime + 8LL)%27LL;
    }
  }
  
  
  if(L%3 == 0) cout << V;
  else{
    cout << V;
    cout <<".";
    if(v*10 / 27 == 0) cout << '0';
    if(v*100 / 27 == 0) cout << '0';
    if(v*1000 / 27 == 0) cout << '0';
    ll res = v*1e14/27LL;
    cout << res;
  }
  
}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

vector<string> j = {"AC", "WA", "TLE", "RE" };

int main() {
    map<string, li> cnt;

    li n;
    cin >> n;
    rin{
        string s;
        cin >> s;
        cnt[s]++;
    }
    for (auto s : j) {
        cout << s << " x " << cnt[s] << endl;
    }



    return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <string>
using namespace std;
const string te[]={"AC","WA","TLE","RE"};
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t,ans1,ans2,ans3,ans4;
    cin>>t;
    ans1=ans2=ans3=ans4=0;
    while(t--){
        string s;cin>>s;
        if(s==te[0])ans1++;
        else if(s==te[1])ans2++;
        else if(s==te[2])ans3++;
        else if(s==te[3])ans4++;
    }
    cout<<"AC x "<<ans1<<endl;
    cout<<"WA x "<<ans2<<endl;
    cout<<"TLE x "<<ans3<<endl;
    cout<<"RE x "<<ans4<<endl;
    return 0;
}


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

using namespace std;

int main()
{
	int h, w;
	
	while(true)
	{
		scanf("%d %d", &h, &w);
		
		if(h == 0 && w == 0)
			break;
		else if(h == 1 && w == 1)
			cout << "#\n\n";
		else if(h == 2 && w == 2)
			cout << "#.\n.#\n\n";
		else
		{
			for(int i = 0; i < h; i++)
			{
				if(i % 2 == 0)
					for(int j = 0; j < w/2; j++)
						cout << "#.";
				else if( i % 2 != 0)
					for(int j = 0; j < w/2; j++)
						cout << ".#";
				if(w % 2 == 0)	
					cout << "\n";
				else
				{
					if(i % 2 == 0)
						cout << "#\n";
					else
						cout << ".\n";
				}		
			}
			printf("\n");
		}
			
	}
	return 0;
}


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

using namespace std;

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

int main() {
    int x,ans=1,res=1,i,j;
    cin>>x;
    for(i=2;i<=sqrt(x);i++){
        j=2;
        ans=1;
        while(ans<x){
          ans=pow(i,j);
          if(ans<=x)
          res=max(res,ans);
          j++;
        }
    }
    cout<<res;
return 0;
}



Measured memory_bytes: 256
def solve():
    n, m = list(map(int, input().split()))
    
    ac_list = [0 for i in range(n + 1)]
    wa_before_ac_list = [0 for i in range(n + 1)]
    
    for _ in range(m):
        p, s = input().split()
        p = int(p)
        
        if s == "AC":
            ac_list[p] = 1
        elif s == "WA" and ac_list[p] == 0:
            wa_before_ac_list[p] += 1

    wa_before_ac_num = 0
    for i in range(n+1):
        if ac_list[i] == 1:
            wa_before_ac_num += wa_before_ac_list[i]
    
    
    print("{} {}".format(sum(ac_list), wa_before_ac_num))
if __name__ == "__main__":
    solve()

Measured memory_bytes: 4760
import math
d, g = map(int, input().split())
p = []
c = []
su = []
ans = 1000
for i in range(d):
  a,b = map(int, input().split())
  p.append(a)
  c.append(b)
  su.append(a*100*(i+1)+b)
bit = [1,2,4,8,16,32,64,128,256,512]
for i in range(int(math.pow(2,d))):
  count = 0
  score = 0
  for j in range(d):
    if i & bit[j] == 0:
      continue
    score += su[j]
    count += p[j]
  if score < g:
    continue
  for j in range(d):
    if i & bit[j] == 0 or score - su[j] >= g:
      continue
    rest = g - (score - su[j])
    count_tmp = min(count , count - p[j] + math.ceil(rest / ((j+1)*100)))
    ans = min(ans, count_tmp)
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
	int d,s,t;
	cin >> d >> t >> s;
	int sum = t*s;
	if(sum>=d){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
	return 0;
}



Measured memory_bytes: 3632
M=998244353
n,s,*l=map(int,open(0).read().split())
dp=[[0]*(s+1) for _ in '01']
dp[0][0]=1
b=0
for i in range(n):
  b^=1
  for j in range(s+1):
    dp[b][j]=dp[b^1][j]*2
    if j>=l[i]: dp[b][j]+=dp[b^1][j-l[i]]
    dp[b][j]%=M
print(dp[n%2][s])

Measured memory_bytes: 68760
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;

vector<pair<ll,ll>> v[1010];
ll dist[1010];
vector<int> used(1010,0);

void bfs(){
  queue<int> q;
  q.push(0);
  dist[0]=0;
  while(q.size()){
    int x=q.front(); q.pop();
    if(used[x]>3000){ continue; }
    for(auto e:v[x]){
      if(dist[e.F] > dist[x] + e.S){
        dist[e.F] = dist[x] + e.S;
        used[e.F]++;
        q.push(e.F);
      }
    }
  }
}

int main(){
  int n,m;
  cin >> n >> m;
  rep(i,m){
    ll a,b,c;
    cin >> a >> b >> c; a--; b--;
    v[a].push_back({b,-c});
  }
  rep(i,n){ dist[i]=longinf; }
  
  bfs();
  
  if(used[n-1]>1000){ 
    cout << "inf" << endl; 
  } else {
    cout << -dist[n-1] << endl; 
  }
  return 0;
}


Measured memory_bytes: 1280
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<queue>
#include<map>
#include<math.h>
#include<string>
#include <cctype>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define INF 1ll<<60;

using namespace std;
using ll = long long;
typedef pair<int, int> P;

int main(){
    string s; cin >> s;
    rep(i, s.size()) cout << 'x';
    cout << endl;
}

Measured memory_bytes: 256
icase=0
if icase==0:
    n=int(input())
    a=[0]+list(map(int,input().split()))
elif icase==3:
    f=open(r"C:\Users\nishi\999atcoder\ABCD040-151\ABC134D\testcase_12.in")
    ll=f.readline()
    n=int(ll)
    ll=f.readline()
    a=[0]+list(map(int,ll.split()))
    f.close()
b=[0]*(n+1)
for i in range(n//2+1,n+1):
    b[i]=a[i]
#    print(i,a[i])
    
for i in range(n//2,0,-1):
    i2=i*2
    asum=0
    while i2<=n:
        asum+=b[i2]
        i2+=i
    b[i]=(asum+a[i])%2
#    print(i,b[i],a[i],asum)
    
print(sum(b))
for i in range(1,len(b)):
    if b[i]==1:
        print(i,end=" ")
print(" ")

Measured memory_bytes: 12384
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define IO_STREAM cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(int i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
const ll INF = 1000000000000000;
const ll MOD = 1000000007;
const double PI = acos(-1);
//||
#define DBG(a,b,c,d) //cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl
//DBG("","","","");

signed main(){
	IO_STREAM;
	int X,N;
	cin>>X>>N;
	if(N==0){
		cout<<X<<endl;
		return 0;
	}
	int near=110;
	vi p(N);
	rep(i,0,N){
		cin>>p[i];
		if(abs(p[i]-X)<near){
			near=p[i];
		}
	}
	rep(i,0,100){
		int ans1=X-i;
		int ans2=X+i;
		rep(j,0,N){
			if(ans1==p[j]) ans1=110;
			if(ans2==p[j]) ans2=110;
		}
		if(ans1!=110){
			cout<<ans1<<endl;
			return 0;
		}
		if(ans2!=110){
			cout<<ans2<<endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 3656
import java.util.*;
public class Main {
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
   
        int a = sc.nextInt();
        int b = sc.nextInt();

      System.out.println((a+b)%2==0 ? (a+b)/2 :(a+b+1)/2);
	}
}

Measured memory_bytes: 23764
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	int n,m,q;
	cin>>n>>m>>q;
	int mem[600][600]={},p,qq;
	FOR(i,0,m){
		int l,r;
		cin>>l>>r;
		mem[l][r]++;
	}
	FORQ(i,1,n){
		FORQ(j,1,n){
			mem[i][j]+=mem[i][j-1];
		}
	}
	FOR(i,0,q){
		cin>>p>>qq;
		LL cnt=0LL;
		FORQ(j,p,qq){
			cnt+=mem[j][qq];
		}
		cout<<cnt<<endl;
	}
    return 0;
}


Measured memory_bytes: 2304
S = input()
g = []
k = []
ans = 1
for i,s in enumerate(S):
    if i % 2 == 0:
        if s == "L":
            ans *= 0
    else:
        if s == "R":
            ans *= 0
if ans ==0:
    print("No")
else:
    print("Yes")

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

int num;
double w, h, BMI;
char cnm;

double BMIk(double w, double h){
	double ans = w / pow(h, 2);
	return ans;
}

int main(){
	while(cin >> num >> cnm >> w >> cnm >> h){
		BMI = BMIk(w, h);
		if(BMI >= 25){
			cout << num << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp(a, b) make_pair(a, b)
#define ls (rt << 1)
#define rs (rt << 1 | 1) 
typedef pair<int, int> pii; 
const ll mod = 1e9 + 7;
template <class T> T lowbit(T x){return ((x)&(-(x)));}
const int maxn = 2e5 + 10;
ll a, b;
int main()
{
	cin >> a >> b;
	a %= b;
	cout << min(a, b - a) << endl;
	return 0;
}

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; typedef pair<ll, ll> P;
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; }
template<typename A,size_t N,typename T>void Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);}
const int inf = INT_MAX / 2; const ll INF = LLONG_MAX / 2;
//template end



int main(){
    int x,k; scanf("%d%d",&x,&k);
    vector<P> que;
    rep(i,0,k){
    	int r; scanf("%d",&r);
    	que.push_back({r,-1});
    }
    int q; scanf("%d",&q);
    rep(i,0,q){
    	int t,a; scanf("%d%d",&t,&a);
    	que.push_back({t,a});
    }
    sort(ALL(que)); vector<int> ans;
    int pre=0,minn=0,maxx=x,drc=-1,diff=0;
    rep(i,0,que.size()){
    	int dy=que[i].first-pre; diff+=drc*dy;
    	minn=min(max(minn,-diff),x-diff);
    	maxx=min(max(maxx,-diff),x-diff);
    	if(que[i].second==-1)drc*=-1;
    	else{
    		int val=que[i].second;
    		ans.push_back(min(max(val,minn),maxx)+diff);
    	} pre=que[i].first;
    }
    rep(i,0,q)printf("%d\n",ans[i]);
    return 0;
}


Measured memory_bytes: 6384
#include <iostream>
#include <vector>
// #include <algorithm>
// #include <math.h>
#include <cmath>
using namespace std;

int main(){
  // 入力
  // unsigned long long a, b, c;
  long double a, b, c;
  cin >> a >> b >> c;

  string result = "No";

  // if ( sqrt(a) + sqrt(b) < sqrt(c) ) {
  // if (pow(a,static_cast<long double>(0.5)) + pow(b,static_cast<long double>(0.5)) < pow(c,static_cast<long double>(0.5))) {
  // if (static_cast<long double>(a*b) < pow(static_cast<long double>((c-a-b)/static_cast<long double>(2.0)), static_cast<long double>(2.0))) {
  // if (4.0*a*b < pow(c-a-b,2.0)) {
  if ( pow(static_cast<long double>(a*b), static_cast<long double>(0.5)) < (c-a-b)/static_cast<long double>(2.0) ) {
    result = "Yes";
  }

  // cout << pow(static_cast<long double>(c-a-b), static_cast<long double>(2.0)) << endl;
  // cout << sqrt(a) << " " << sqrt(b) << " " << sqrt(c) << " " << endl;
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main(){
  int n,a[1001]={};
  while(1){
    int min=1000000;
    cin>>n;
    if(n==0)break;

    for(int i=0;i<n;i++){
      cin>>a[i];
      if(i>0){
      for(int j=0;j<i;j++)
	  if(min>abs(a[i]-a[j]))min=abs(a[i]-a[j]);
      }
    }

    cout<<min<<endl;
  }
  return 0;
}

Measured memory_bytes: 3092
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
//#include <math.h>
#include <algorithm>
//#include <vector> 

const long MOD = 1000000007;

static long long st_factrial( long n )
{
    long long ans = 1;
    long i;
    for(i=1; i<=n; i++) {
        ans = ans * i % MOD;
    }
    return ans;
}

static long long st_pow( long long x, long n)
{
	long ans = 1;
	while (n > 0) {
		if ((n & 1) == 1) {
			ans = ans * x % MOD;
		}
		x = x * x % MOD; //一周する度にx, x^2, x^4, x^8となる
		n >>= 1; //桁をずらす n = n >> 1
	}
	return ans;
}

static long long st_inverse( long long n )
{
    return st_pow(st_factrial(n), MOD - 2) % MOD;
}

static long st_func( long count, long m )
{
    return st_factrial(count+m-1) * st_inverse(count) % MOD * st_inverse(m-1) % MOD;
}

int main(int argc, char* argv[])
{
    long n, m;
    scanf("%ld %ld", &n, &m);

    long long ans = 1;
    long flag[40000] = {0};
    long i;
    for(i=2; i<40000; i++) {
        if(flag[i]==0) {
            long tmp = i + i;
            while( tmp<40000) {
                flag[i] = 1;
                tmp += i;
            }
            long count = 0;
            while( m % i == 0 ) {
                count ++;
                m /= i;
            }
            if(count>0) {
                ans = ans * st_func(count, n) % MOD;
            }
        }
    }
    //printf("%d\n", m);
    if(m>1) {
        ans = ans * st_func(1, n) % MOD;
    }
    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <algorithm>
using namespace std;
char txt[1000003];
int dp[1000003][2]; //x , 10-x+1
int main(){
	scanf("%s",txt);
	int i=0;
	dp[0][0] = txt[i]-'0';
	dp[0][1] = 10-(txt[i]-'0')+1;
	for(i=1;txt[i];i++){
		int x = txt[i]-'0';
		dp[i][0] = min(dp[i-1][0],dp[i-1][1]) + x;
		dp[i][1] = min(dp[i-1][0] + 10-x+1,dp[i-1][1] + 10-x-1);
	}
	printf("%d",min(dp[i-1][0],dp[i-1][1]));
}

Measured memory_bytes: 8960
n, k = map(int, input().split())
hl = []
for i in range(n):
    hl.append(int(input()))

hl.sort()
ans = 10000000001

for j in range(n-k+1):
    s = hl[j+k-1] - hl[j]
    if s < ans:
        ans = s
    else:
        pass
print(ans)

Measured memory_bytes: 13220
#include <stdio.h>

/**
 *
 * 考え方
 * 与えられたKの中でA, Bに割ける分は全部割く
 * どうしても余った分をCに割く
 **/
int main() {
  int A /* 1と書かれたカードの枚数 */, B /* 0と書かれたカードの枚数 */, C /* -1と書かれたカードの枚数 */, K /* 取る枚数 */;
  scanf("%d%d%d%d", &A, &B, &C, &K);

  int output;
  int rest;
  if (A <= K) {
    output = 1 * A;
    rest = K - A;

    /* printf("%c", '\n'); */

    /* printf("%s", "rest: "); */
    /* printf("%d", rest); */
    /* printf("%c", '\n'); */
    /* printf("%s", "output: "); */
    /* printf("%d", output); */
    /* printf("%c", '\n'); */

    /* printf("%c", '\n'); */

    if (rest > 0) {
      if (B <= rest) {
        output = output + 0 * B;
        rest = rest - B;

        /* printf("%c", '\n'); */

        /* printf("%s", "rest: "); */
        /* printf("%d", rest); */
        /* printf("%c", '\n'); */
        /* printf("%s", "output: "); */
        /* printf("%d", output); */
        /* printf("%c", '\n'); */

        /* printf("%c", '\n'); */

        if (rest > 0) {
          /* printf("%c", '\n'); */
          /* printf("%s", "output: "); */
          /* printf("%d", output); */
          /* printf("%c", '\n'); */

          /* printf("%c", '\n'); */
          /* printf("%s", "-1 * rest: "); */
          /* printf("%d", -1 * rest); */
          /* printf("%c", '\n'); */

          output = output + (-1 * rest);

          /* printf("%c", '\n'); */

          /* printf("%s", "rest: "); */
          /* printf("%d", rest); */
          /* printf("%c", '\n'); */
          /* printf("%s", "output: "); */
          /* printf("%d", output); */
          /* printf("%c", '\n'); */

          /* printf("%c", '\n'); */

        }
      } else {
      }
    } else {}
  } else {
    output = 1 * K;
  }

  printf("%d", output);
  printf("%c", '\n');

  return 0;
}


Measured memory_bytes: 1728
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<cassert>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<bitset>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define str string
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll ari(ll a, ll b, ll c) {
	return (a + b)*c / 2;
}//等差数列の和
ll fact(ll x, ll k, ll p) {//最大値、個数、あまり
	ll sum = 1;
	for (int i = 0; i < k; i++) {
		sum *= (x--);
		sum %= p;
	}
	return sum;
}//階乗(正）
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res*x%p;
		x = x*x%p;
		n >>= 1;
	}
	return res;
}//x^n%p
short ctos(char a) {
	return (int)(a - '0');
}
#define int long long
const long long Inf = 4523372036854775807;
const int inf = 15000000000;
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
int n, k, m;
int a[300000];
vector<int>b;
int dat[300000];
void add(int x, int y) {
	while (x <= m) {
		dat[x] += y;
		x += x&-x;
	}
}
int sum(int x) {
	int sum = 0;
	while (x > 0) {
		sum += dat[x];
		x -= x&-x;
	}
	return sum;
}
signed main() {
	cin >> n >> k;
	n++;
	a[0] = k;
	for (int i = 0; i < n; i++) {
		if (i > 0)
			cin >> a[i];
		a[i] -= k;
		if (i > 0) {
			a[i] += a[i - 1];
		}
		b.push_back(a[i]);
	}
	sort(all(b));
	b.erase(unique(all(b)), b.end());
	for (int i = 0; i < n; i++) {
		a[i] = lower_bound(all(b), a[i]) - b.begin() + 1;
		m = max(m, a[i]);
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		ans += sum(a[i]);
		add(a[i], 1);
	}
	cout << ans << endl;
}

Measured memory_bytes: 5488
import java.util.*;
public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		Arrays.setAll(A, i -> sc.nextInt());
		TreeMap<Integer, Integer> b = new TreeMap<>();
		b.put(-1, 0);
		int ans = 0;
		for(int i = N-1; i >= 0; i--) {
			if(b.lastKey() <= A[i])
				ans++;
			else {
				int rk = b.higherKey(A[i]);
				if(b.get(rk) > 1)
					b.put(rk,b.get(rk)-1);
				else
					b.remove(rk);
			}
			if(b.containsKey(A[i])) {
				b.put(A[i],b.get(A[i])+1);
			}
			else
				b.put(A[i],1);
		}
		System.out.println(ans);

	}

}

Measured memory_bytes: 65024
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {

    public static void main(String[] args) throws Exception {

        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(is);

        List<String> mylist = new ArrayList<>();

        // 標準入力からの値を変数strinputに代入
        String strinput = reader.readLine();

        while (strinput != null) {

            mylist.add(strinput);
            strinput = reader.readLine();

        }

        String s = mylist.get(0);

        int x = Integer.valueOf(s);

        int cnt1 = x / 500;

        x -= cnt1 * 500;

        int cnt2 = x / 5;

        System.out.println(cnt1 * 1000 + cnt2 * 5);

    }

}


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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

    string a, b, c; cin >> a >> b >> c;
    if (a.back() == b.front() && b.back() == c.front()) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
import Foundation

func readInts() -> [Int] {
    readLine()!.split(separator: " ").map { Int($0)! }
}

func main() {
    let n = Int(readLine()!)!
    let table = readInts()
    var count = 0
    
    for i in 0..<n {
        if (i + 1) % 2 == 1 && table[i] % 2 == 1{
            count += 1
        }
    }
    print(count)
    
}

main()


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

int main(){
    long long x;
    cin >> x;
    vector<long long> res(10000000);
    res[0]=0;
    long long i=1;
    while(true){
        res[i]=res[i-1]+i;
        //cout << res[i] << endl;
        if(res[i]>=x) break;
        i++;
    }
    cout << i << endl;
}

Measured memory_bytes: 78464
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int ans=0;
  if(s[0]=='R'){
    if(s[1]=='R'){
      if(s[2]=='R'){
        ans=3;
      }else{
        ans=2;
      }
    }else{
      ans=1;
    }
  }else{
    if(s[1]=='R'){
      if(s[2]=='R'){
        ans=2;
      }else{
        ans=1;
      }
    }else{
      if(s[2]=='R'){
        ans=1;
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3616
Module Module1

    Sub Main()

        Dim S As String = Console.ReadLine()
        Dim T As String = Console.ReadLine()
        Dim i As Integer = 0
        Dim atari As Integer = 0

        For i = 1 To 3
            atari += IIf(Mid(S, i, 1) = Mid(T, i, 1), 1, 0)
        Next

        Console.WriteLine(atari)

        'Console.ReadLine()

    End Sub

End Module


Measured memory_bytes: 20304
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountl
#define m_p make_pair
#define inf 200000000000000
#define MAXN 1000001
#define eps 0.0000000001
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

//////////////

#define S second
#define F first
#define int long long  

///////////// 

signed main()
{
	fastio;
	#ifdef ANIKET_GOYAL
		freopen("inputf.in","r",stdin);
		freopen("outputf.in","w",stdout);
	#endif
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;++i)
	{
		cin>>a[i];
	}
	int ans[n]={};
	ans[1]=abs(a[1]-a[0]);
	for(int i=2;i<n;++i)
	{
		ans[i]=min(ans[i-1]+abs(a[i]-a[i-1]),ans[i-2]+abs(a[i]-a[i-2]));
	}
	cout<<ans[n-1];
}

Measured memory_bytes: 1792
// Problem : B - Voting Judges
// Contest : AtCoder - AtCoder Grand Contest 041
// URL : https://atcoder.jp/contests/agc041/tasks/agc041_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define db long double
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define mi map<int,int>
#define ml map<ll,ll>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define MAX 4294967295
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define MAXN 15000005
#define inf 1e10
#define PI acos(-1.0)
#define int long long

int n,m,v,p,a[100005];

bool check(int x){
    if(x<=p) return 1;
    if(a[x]+m < a[p]) return 0;
    int tot = 0;
    for(int i=1;i<=n;i++){
        if(i<p) tot += m;
        else if(i>=x) tot += m;
        else tot += a[x]+m-a[i];
    }
    if(tot < m*v) return 0;
    return 1;
}

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    cin>>n>>m>>v>>p;
    for(int i=1;i<=n;i++) cin>>a[i];
    sort(a+1,a+1+n,greater<int>());
    int lo = 1, hi = n, ans;
    while(lo<=hi){
        int mid = (lo+hi)/2;
        if(check(mid)) ans = mid, lo = mid+1;
        else hi = mid-1;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
package main

import (
	"fmt"
	"math"
)

func main(){
	var N,t,x,y int
	fmt.Scan(&N)

	var t0,x0,y0 int
	f:=true
	for n:=0;n<N;n++{
		fmt.Scan(&t, &x, &y)

		T := t-t0
		XY := int(math.Abs(float64(x-x0))+math.Abs(float64(y-y0)))

		if T<XY || T%2 != XY%2{
			f=false
			break
		}
		t0 = t
		x0 = x
		y0 = y
	}
	if f {
		fmt.Print("Yes")
	}else{
		fmt.Print("No")
	}
}

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

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ld long double
#define forn(low,high,i) for(i = low; i < high; i++)
#define forrev(high,low,i) for(i = high; i >= low; i--)
#define all(v) v.begin(),v.end()
#define decimal_digits cout << fixed << setprecision(15);

string to_string(string s) { return '"' + s + '"';}
string to_string(char s) { return string(1, s);}
string to_string(const char* s) { return to_string((string) s);}
string to_string(bool b) { return (b ? "true" : "false");}
template <typename A> string to_string(A);
template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}
template <typename A> string to_string(A v) {bool f = 1; string r = "{"; for (const auto &x : v) {if (!f)r += ", "; f = 0; r += to_string(x);} return r + "}";}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {cerr << " " << to_string(H); debug_out(T...);}
#define pr(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

#define GOOGLE 0
#define MULTIPLE_TC 0

const int inf = 1e9;
const long long INF = 1e18;
const int mod = 1e9 + 7;
const int bit32 = log2(inf) + 3;
const int bit64 = log2(INF) + 3;

inline int add(long long a, long long b){a += b; if(a >= mod) a -= mod; return a;}
inline int sub(long long a, long long b){a -= b; if(a < 0) a += mod; return a;}
inline int mul(long long a, long long b){a %= mod; b %= mod; return (int)((long long) a * b % mod);}
inline int modexpo(long long a, long long b){int res = 1; while(b > 0){ if(b & 1) res = mul(res, a); a = mul(a, a); b /= 2;} return res;}
inline int divide(long long a, long long b){return mul(a, modexpo(b, mod - 2));}
inline int inv(long long a){return modexpo(a, mod - 2);}

clock_t time_p = clock();

void ktj(){
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (float)(time_p)/CLOCKS_PER_SEC << "\n";
}

void pre(){ // Reset each global variable (esp. for graphs)
  
}

string s;

const int N = 1e5 + 5;
int cc[N][13];

int dp (int idx, int sum) {
  if (idx == s.size()) {
    return sum == 5;
  }
  int &ans = cc[idx][sum];
  if (~ans)
    return ans;
  ans = 0;
  if (s[idx] == '?') {
    for (int i = 0; i < 10; i++) {
      ans = add(ans, dp(idx + 1, (sum * 10 + i) % 13));
    }
  } else {
    ans = add(ans, dp(idx + 1, (sum * 10 + s[idx] - '0') % 13));
  }
  return ans;
}

void solve(){
  cin >> s;
  memset(cc, -1, sizeof cc);
  cout << dp(0, 0) << '\n';
}

int32_t main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);cout.tie(NULL); 

  pre();

  int t = 1, T;

  if(MULTIPLE_TC)
    cin >> t;

  for(T = 1; T <= t; T++){
    if(GOOGLE)
      cout << "Case #" << T << ": ";
      solve();
  }

  ktj();
}


Measured memory_bytes: 13740
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2005;
int dp[N][2];
int a[N],n;
int dfs(int pos,int f)
{
    if(dp[pos][f]!=-1)return dp[pos][f];
    int &ans=dp[pos][f];
    if(pos==n)return ans=abs(a[n-1]-a[n]);
    ans=abs(a[pos-1]-a[n]);
    for(int i=pos+1; i<=n; i++)
    {
        if(!f)ans=max(ans,dfs(i,f^1));
        else ans=min(ans,dfs(i,f^1));
    }
    return ans;
}
int main()
{
    int z;
    cin>>n>>z>>a[0];
    for(int i=1; i<=n; i++)
        cin>>a[i];
    memset(dp,-1,sizeof(dp));
    cout<<dfs(1,0);
    return 0;
}


Measured memory_bytes: 384
N=int(input())
from collections import defaultdict
data=defaultdict(int)
for i in range(N):
    s=input()
    data[s[0]]+=1
S="MARCH"
ans=0
for x in range(3):
    for y in range(x+1,4):
        for z in range(y+1,5):
            ans+=data[S[x]]*data[S[y]]*data[S[z]]
print(ans)

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

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

    vector<int> data(N);

    for (int i = 0; i<N; i++){
        cin >> data.at(i);       
    }
    int sum;

    sum = 0;
    int a;

    for(int i = 0; i<N; i++){
        for(int j = 0; j<N;j++){

            if(j < i+1)
            continue;

            else
        
             a = data.at(i)*data.at(j);

             sum +=a;


        }
    }
    cout << sum << endl;

    return 0;

}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigDecimal;

public class Main {
	public static void main(String[] args) throws Exception {
		InputStreamReader is = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(is);

		String str = br.readLine();

		BigDecimal r = new BigDecimal(str);
		BigDecimal pi = new BigDecimal(Math.PI);
		BigDecimal d = new BigDecimal("2");

		String area =r.multiply(r).multiply(pi).toPlainString();
		String circle =r.multiply(d).multiply(pi).toPlainString();

		System.out.println(area + " "+circle);
	}

	//?¬¬????????°???????????????????????????
	public static String SubStringStart(String str) {
		int index = str.indexOf(" ");
		return (str.substring(0, index));
	}

	//	?¬¬????????°???????????????????????????
	public static String SubStringEnd(String str) {
		int index = str.lastIndexOf(" ");
		return (str.substring(index + 1));
	}
}

Measured memory_bytes: 24536
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin>>N;
  int A=0;
  for (int i=0; i<N; i++) {
    int li,ri;
    cin>>li>>ri;
    A+=ri-li+1;
  }
  cout<<A<<endl;  
}

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

int main() {
  int card[5];
  while(scanf("%d,%d,%d,%d,%d", 
	      &card[0], &card[1], &card[2], &card[3], &card[4]) != EOF) {
    sort(&card[0], &card[4] + 1);

    int data1[5];
    int kumi = -1;
    int before = 0;
    int count = 1;

    for(int i = 0; i < 5; i++) {
      if(card[i] != before) {
	data1[++kumi] = 1;
      } else {
	data1[kumi]++;
      }
      before = card[i];
    }
    kumi++;
    if(kumi == 2) {
      if(data1[0] == 4 || data1[1] == 4) {
	cout << "four card" << endl;
      } else if(data1[0] == 3 || data1[1] == 3) {
	cout << "full house" << endl;
      }
    }
    if(kumi == 3) {
      if(data1[0] == 3 || data1[1] == 3 || data1[2] == 3) {
	cout << "three card" << endl;
      } else if(data1[0] == 1 || data1[1] == 1 || data1[2] == 1) {
	cout << "two pair" << endl;
      }
    }
    if(kumi == 4) {
      cout << "one pair" << endl;
    }
    if(kumi == 5) {
      bool flag = false;
      for(int i = 0; i+1 < 5; i++) {
	if(card[i+1] - card[i] != 1) {
	  break;
	}
	if((i+1)+1 == 5) flag = true;
      }
      if(card[0] == 1 && card[1] == 10 &&
	 card[2] == 11 && card[3] == 12 && card[4] == 13) flag = true;

      if(flag) {
	cout << "straight" << endl;
      } else {
	cout << "null" << endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include<iostream>
using namespace std;
int main(){
  int h,w;
  while(1){
    cin >> h >> w;
    if(h==0&&w==0){
      break;
    }
    for(int i=1;i<=h;i++){
      for(int j=1;j<=w;j++){
	if(i%2!=0){
	  if(j%2!=0){
	    cout << "#";
	  }else{
	    cout << ".";
	  }
	}else{
	  if(j%2!=0){
	    cout << ".";
	  }else{
	    cout << "#";
	  }
	}
      }
      cout << endl;
    }
    cout << endl;
  }
  return(0);
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#define ll long long
vector <int> adj[100009];
bool visited[100009]={0};
map <int,int> mp;
void bfs()
{
    queue <int> q;
    q.push(1);
    visited[1]=1;
    while(!q.empty())
    {
        int par=q.front();
        for(int i:adj[par])
        {
            if(!visited[i])
            {
                q.push(i);

                mp[i]=par;
                visited[i]=1;
            }
        }
        q.pop();

    }


}
int main()
{

    ll i,j,k,l,m,n,a,b,c,d,cnt=0;
    cin>>n>>k;

    for(i=0;i<k;i++)
    {
        cin>>a>>b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    bfs();
    if(mp.size()!=(n-1))
        cout<<"No"<<endl;
    else
    {
        cout<<"Yes"<<endl;
        for(i=2;i<=n;i++)
            cout<<mp[i]<<endl;
    }




}


Measured memory_bytes: 14760
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  string s;
  cin>>s;
  ll sum=0;
  ll len=s.size();
  for(int i=0; i<len; i++){
    sum+=(s[i]-'0');
  }
  if(sum%9==0)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}


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

int main(){
    int n, ans = -1;
    cin >> n;
    int x = (int)((double)n / 1.08);
    if((int)(x * 1.08) == n) ans = x;
    else if((int)((x + 1) * 1.08) == n) ans = x + 1;
    if(ans >= 0) cout << ans << endl;
    else cout << ":(" << endl;
    return 0;
}

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int A,B;
	cin >> A >> B;

	int count=0;
	for(int i=A;i<=B;i++){
		string target = to_string(i);
		string r_target = target;
		reverse(r_target.begin(),r_target.end());
		if(target == r_target) count++;
	}
	cout << count << "\n";
	return 0;
}

Measured memory_bytes: 256
def solve(a, b, c, d):
  for k in range(29, -1, -1):
    block_size = 3**k
    box_size = block_size * 3
    x1, y1, x2, y2 = map(lambda x:x//block_size, (a, b, c, d))
    x1, x2 = sorted([x1, x2])
    y1, y2 = sorted([y1, y2])
    if x1!=x2 and y1!=y2:
      return abs(a-c)+abs(b-d)
    if x1==x2 and x1%3==1 and (y1+1)//3*3+1<y2:
      a, c = map(lambda x:x%box_size, (a, c))
      return min(a+c-2*block_size+2, 4*block_size-a-c)+abs(b-d)
    elif y1==y2 and y1%3==1 and (x1+1)//3*3+1<x2:
      b, d = map(lambda x:x%box_size, (b, d))
      return min(b+d-2*block_size+2, 4*block_size-b-d)+abs(a-c)
  return abs(a-c)+abs(b-d)

for i in range(int(input())):
  print(solve(*map(lambda x:int(x)-1, input().split())))


Measured memory_bytes: 3316