akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;
int flag = 0;
int flag2 = 0;

void Transplant(Node u, Node v){
  if(u->parent == NIL){
    root = v;
  }else if(u == u->parent->left){
    u->parent->left = v;
  }else{
    u->parent->right = v;
  }
  if(v != NIL){
    v->parent = u->parent;
  }
}

Node treeMinimum(Node x){
  while(x->left != NIL){
    x = x->left;
  }
  return x;
}

Node treeMaximum(Node x){
  while(x->right != NIL){
    x = x->right;
  }
  return x;
}

Node treeSearch(Node u, int k){

  if(u == NIL || k == u->key){
    return u;
  }
  if(k < u->key){
    return treeSearch(u->left, k);
  }else {
    return treeSearch(u->right, k);
  }

}

Node treeSuccessor(Node x){

  Node y;
  if(x->right != NIL){
    return treeMinimum(x->right);
  }
  y = x->parent;
  while(y != NIL && x == y->right){
    x = y;
    y = y->parent;
  }
  return y;

}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
  if(z->left == NIL){
    Transplant(z, z->right);
  }else if(z->right == NIL){
    Transplant(z, z->left);
  }else {
    y = treeMinimum(z->right);
    if(y->parent != z){
      Transplant(y, y->right);
      y->right = z->right;
      y->right->parent = y;
    }
    Transplant(z, y);
    y->left = z->left;
    y->left->parent = y;
  }

}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
  
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  while(x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->left;
    }else {
      x = x->right;
    }
  }
  z->parent = y;
  
  if(y == NIL){
    root = z;
  }else if(z->key < y->key){
    y->left = z;
  }else {
    y->right = z;
  }
}

void inorder(Node u){
  if(u != NIL){
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
  }
  
}
void preorder(Node u){
  if(u != NIL){
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
  }
  

}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 20448
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		try {
			int x = sc.nextInt();
			int y = sc.nextInt();
			System.out.println((x * y) + " " + ((x + y) * 2));
		} finally {
			sc.close();
		}
	}
}

Measured memory_bytes: 26232
# ノードをtupleで渡す
from collections import defaultdict
from heapq import *
class MinCostFlow:
    def __init__(self):
        self.inf=10**9
        self.to = defaultdict(dict)

    def add_edge(self, u, v, cap, cost):
        self.to[u][v]=[cap, cost]
        self.to[v][u]=[0, -cost]

    # s...source,t...sink,f...flow
    # これが本体
    def cal(self,s,t,f):
        min_cost=0
        pot=defaultdict(int)
        while f:
            dist = {}
            pre_u={}   # 最短距離の遷移元の頂点
            # ダイクストラで最短距離を求める
            hp=[]
            heappush(hp,(0,s))
            dist[s]=0
            while hp:
                d,u=heappop(hp)
                if d>dist[u]:continue
                for v,[cap,cost] in self.to[u].items():
                    if cap==0:continue
                    nd=dist[u]+cost+pot[u]-pot[v]
                    dist.setdefault(v, self.inf)
                    if nd>=dist[v]:continue
                    dist[v]=nd
                    pre_u[v]=u
                    heappush(hp,(nd,v))
            # sinkまで届かなかったら不可能ということ
            if t not in dist:return -1
            # ポテンシャルを更新する
            for u,d in dist.items():pot[u]+=d
            # パスs-t上で最小の容量=流す量を求める
            u=t
            min_cap=f
            while u!=s:
                u,v=pre_u[u],u
                min_cap=min(min_cap,self.to[u][v][0])
            # フローから流す量を減らし、コストを加える
            f-=min_cap
            min_cost+=min_cap*pot[t]
            # パスs-tの容量を更新する
            u=t
            while u!=s:
                u,v=pre_u[u],u
                self.to[u][v][0]-=min_cap
                self.to[v][u][0]+=min_cap
        return min_cost

def main():
    n,m,f=map(int,input().split())
    mc=MinCostFlow()
    for _ in range(m):
        u,v,c,d=map(int,input().split())
        mc.add_edge(u,v,c,d)
    print(mc.cal(0,n-1,f))

main()



Measured memory_bytes: 6180
#include<iostream>
#include<string>
#include<set>

using namespace std;

int n;
string w[100];

int solve(){
	set<string> s;
	s.insert(w[0]);
	for(int i = 1; i < n; i++){
		if(*w[i - 1].rbegin() != *w[i].begin()) return 0;
		if(s.find(w[i]) != s.end()) return 0;
		s.insert(w[i]);
	}
	return 1;
}

int main(){
	cin >> n;
	for(int i = 0; i < n; i++) cin >> w[i];
	cout << (solve() ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
        int N;
        cin >> N;
        string s = "0";
        int Ans = 0;

        for(int i = 1; i <= N; i++){
                s = to_string(i);
                if(s.size()%2 == 1){
                        Ans++;
                }
        }
        cout << Ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
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; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる





int main() {
  int n,m;
  cin>>n;

  map<string,int> p;
  string s;
  rep(i,n){
    cin>>s;
    if(p.count(s))p.at(s)++;
    else p[s]=1;
  }

  cin>>m;

  rep(i,m){
    cin>>s;
    if(p.count(s))p.at(s)--;
  }

  int ans=0;
  for(auto x : p){
    chmax(ans,x.se);
  }


  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, a, b;
  cin >> n >> a >> b;
  
  int p1 = a * n;
  int p2 = b;
  
  if (p1 < p2)
    cout << p1 << endl;
  else
    cout << p2 << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
/*#pragma GCC target("avx,avx2,fma")
#pragma GCC target ("sse4")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define ld double 
#define rep(i,a,b) for(ll i=a; i<b; ++i)
#define BOOST std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define all(v) v.begin(),v.end()
#define sl(a) a.size()
#define mod 1000000007 
#define lcm(a,b) (a*b)/__gcd(a,b)
#define MAX1 100006
#define f first
#define s second
#define pi 2*acos(0.0)
bool isPowerOfTwo (int x) {  return x && (!(x&(x-1)));  }
void solve()
{
    ll x;  cin>>x;
    if(x==0) cout<<1;
    else cout<<0;
}
int main()
{
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt","r",stdin);
    //for getting error from error.txt
    freopen("error.txt", "w", stderr);
    // for writing output to output.txt
    freopen("output.txt","w",stdout);
    #endif
    BOOST
    int T=1;  //cin>>T;
    while(T--) solve();
    cerr<<"Time taken : "<<fixed<<setprecision(5)<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<"\n";
    cerr<<"My CLOCKS_PER_SEC= "<<CLOCKS_PER_SEC<<"\n";
    return 0;
}

Measured memory_bytes: 3800
#include <bits/stdc++.h>
#include <queue>
using namespace std;
int main(void){
    int N,Y;
    cin >> N >> Y;
    int x,y,z;
    x = y = z = 0;
    while(x <= Y / 10000){
        y = z = 0;
        
        if(z == (5000 * (x+N) - Y) % 4000){
            z = abs((5000*(x+N) - Y) / 4000);
            
            
            
            while(y <= Y / 5000){
            if( x + y + z == N && 10000 * x + 5000 * y + 1000 * z == Y){
                cout << x << " " << y << " " << z << endl;
                return 0;
            }
            y++;
        }
        }
        
        x++;
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import math
import collections
#sys.setrecursionlimit(100000)

n=int(input())
tmp = input().split()
p = list(map(lambda a: int(a), tmp))


min = p[0]
ans = 0
#print(min)

for i in range(n):
	if(p[i]<=min):
		ans+=1
		min=p[i]
print(ans)



Measured memory_bytes: 25120
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <map>
#define ll long long
using namespace std;


int main(){
 // cout<<123<<endl;
 int a,b;
  cin>>a>>b;
  cout<<a*b/2<<endl;
  
  
 
  return 0;
}


Measured memory_bytes: 256
N,K=map(int,input().split())
P=list(map(int,input().split()))

E=[0]*(N+1)
for i in range(N):
  E[i+1]=E[i]+(P[i]+1)/2

ans=0
for i in range(N-K+1):
  val=E[i+K]-E[i]
  ans=max(ans,val)
print(ans)

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

#define fi first
#define se second
#define pb push_back
#define sz(a) (int)(a).size()
#define mp(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;

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

const int N = 1e7 + 5;
int lpf[N];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    lpf[1] = 1;
    for (ll i = 2; i <= n; i++) {
        if (lpf[i] == 0) {
            lpf[i] = i;
            for (ll j = 2 * i; j <= n; j += i){
                if (lpf[j] == 0) lpf[j] = i;
            }
        }
    }
    ll ans = 1;
    map<int, ll> cnt;
    for (int i = 2; i <= n; i++) {
        ll t = i;
        while (t != 1) {
            cnt[lpf[t]]++;
            t /= lpf[t];
        }
        ll tot = 1;
        for (auto it: cnt) {
            tot *= it.se + 1;
        }
        ans += i * tot;
        cnt.clear();
    }
    cout << ans << '\n';
    return 0;
}

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

int main()
{
    int a, b;
    cin >> a >> b;
    if (a * b % 2 == 0)
    {
        cout << "Even" << endl;
    }
    else
    {
        cout << "Odd" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
def ncr(n, r, p):
    num = 1
    den = 1

    for i in range(r):
        num = (num*(n-i)) % p
        den = (den*(i+1)) % p

    return (num*pow(den, p-2, p)) % p

n, a, b = list(map(int, input().split()))

m = 1000000007
print((pow(2, n, m) - 1 - ncr(n, a, m) - ncr(n, b, m)) % m)

Measured memory_bytes: 9208
#include <bits/stdc++.h>
using namespace std;
#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;

int main() {
    int n;
    cin >> n;
    deque<ll>ans;
    rep(i, 0, n){
        ll a;
        cin >> a;
        if(i%2==0)ans.push_back(a);
        else ans.push_front(a);
    }
    if(n%2==0){
        rep(i, 0, n){
            cout << ans[i] << " ";
        }
        cout << endl; 
    }else{
        reverse(ans.begin(), ans.end());
        rep(i, 0, n){
            cout << ans[i] << " ";
        }
        cout << endl; 
    }
}

Measured memory_bytes: 3840
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
#define inf 1e9
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

int dfsw(int i,int j,int cnt,vector<vector<int> > &ww,vector<vector<bool> > &usew){
	usew[i][j] = false;
//	cout<<i<<' '<<j<<' '<<cnt<<endl;
	int cost = cnt;
	if(usew[i][j+1])cost = dfsw(i,j+1,cnt+1,ww,usew);
	ww[i][j] = cost;
//	cout<<i<<' '<<j<<' '<<cost<<endl;
	return cost;
}

int  dfsh(int i,int j,int cnt,vector<vector<int> > &hh,vector<vector<bool> > &useh){
	useh[i][j] = false;
	int cost = cnt;
	//cout<<i<<' '<<j<<' '<<cnt<<endl;
	if(useh[i+1][j])cost = dfsh(i+1,j,cnt+1,hh,useh);
	hh[i][j] = cost;
//	cout<<i<<' '<<j<<' '<<cost<<endl;
	return cost;
}
int main(){
	int h,w;
	cin>>h>>w;
	vector<vector<int> > dp(h+2,vector<int>(w+2,0) );
	vector<vector<int> > hh(h+2,vector<int>(w+2,0) );
	vector<vector<int> > ww(h+2,vector<int>(w+2,0) );
	vector<vector<bool> > used(h+2,vector<bool> (w+2,false) );
	vector<vector<bool> > useh(h+2,vector<bool> (w+2,false) );
	vector<vector<bool> > usew(h+2,vector<bool> (w+2,false) );
	for(int i=1;i<=h;i++)
		for(int j =1;j<=w;j++){
			char tmp ;
			cin>>tmp;
			if(tmp == '#'){

			}else{
				used[i][j] = true;
				useh[i][j] = true;
				usew[i][j] = true;
			}
		}
	for(int i=1;i<=h;i++)
		for(int j=1;j<=w;j++){
			if(usew[i][j] ){
				dfsw(i,j,1,ww,usew);
			}
			if(useh[i][j]){
				dfsh(i,j,1,hh,useh);
			}
		}
		int res = 0;
	for(int i=1;i<=h;i++)
		for(int j = 1;j<=w;j++){
			res = max(res,hh[i][j]+ww[i][j]-1);
		}
	/*cout<<"hh"<<endl;
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			cout<<hh[i][j]<<' ';
		}
		cout<<endl;
	}
	cout<<"ww"<<endl;
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			cout<<ww[i][j]<<' ';
		}
		cout<<endl;
	}*/
	cout<<res<<endl;

	return 0;
}


Measured memory_bytes: 49280
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll binpow(ll x,ll y){
    ll res=1;
    while(y>0){
        if(y&1)
            res*=x;
        y>>=1;
        x*=x;
    }
    return res;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n,i,m,temp;
    double ans,sum=0,temp1,num,l=1.0,k,ii;
    cin>>n>>k;
    num=n;
    for(i=1;i<=n;i++){
        ii=i;
        if(i>=k)
            m=0;
        else
            m=ceil(log2(k/ii));
        temp=binpow(2,m);
        temp1=temp;
        ans=num*temp1;
        sum+=(l/ans);
    }
    cout<<fixed<<setprecision(12)<<sum<<endl;
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define sz 100010
#define BeatMeScanf ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

#define pii pair<int,int>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair

int const mod = 1e9;
int const N = 1e7+5;

ll d[N+5];
void sieve() {
    int i, j;
    for(i=1;i<=N;i++) {
        for(j=i;j<=N;j+=i){
            d[j]++;
        }
    }
}

int main()
{
    BeatMeScanf;
    sieve();
    ll n,sum=0;
    cin>>n;
    for(ll i=1;i<=n;i++) {
        sum += i*d[i];
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 81772
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long ll;
int main() {
    ll A,B,t,k;
    cin>>A>>B;
    if(A==B) return puts("1"),0;
    for(t=59;~t&&(A>>t&1)==(B>>t&1);t--);
    A&=(1LL<<t+1)-1,B&=(1LL<<t+1)-1;
    for(k=t-1;~k&&~B>>k&1;k--);
    cout<<(1LL<<t+1)-A-max(0LL,A-(1LL<<k+1));
    return 0;
}

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

// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}

int main(){
  int k;
  int n[32]={1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cin >> k;
  cout << n[k-1] << endl;;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
ll powmod(ll x,ll n){
    if(n == 0)return 1;
    ll ans = powmod(x*x%MOD,n/2);
    if(n % 2)ans = ans * x % MOD;
    return ans;
}
ll divmod(ll a,ll b){
    return ((a%MOD) * (powmod(b,MOD-2)%MOD)) % MOD;
}

main(){
    ll N,K;
    cin >> N >> K;
    vector<ll> V(N), cnt(2010), cnt2(2010), accum(2010);
    
    rep(i,0,N)cin >> V[i];
    rep(i,0,N){
        cnt[V[i]]++;
    }
    rep(i,1,2001)accum[i] = accum[i-1] + cnt[i];
    //for(int i = 2000;i >= 0;i--)accum[i] = accum[i+1] + cnt[i];
    //rep(i,0,10)cout << accum[i] << endl;
    ll ans = 0;
    ll sub = divmod((K-1) * K, 2);
    
    rep(i,0,N){
        ans += accum[V[i]-1] * sub;
        //ans += accum[V[i]-1] * K * (K-1) / 2;
        rep(j,i+1,N)if(V[i] > V[j])ans += K;
        ans %= MOD;
    }
    ans %= MOD;
    //ans = divmod(ans, 4);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main() {
	string w;
	cin >> w;
	vector<int> count(26);
	for(int i = 0; i < w.size(); i++){
		count[(int)w[i] - 97]++;
	}
	for(int i : count){
		if(i % 2 != 0){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}


Measured memory_bytes: 3568
#include<bits/stdc++.h>
#define PI 3.141592653589793238462L
using namespace std;

int main(){
	cout << setprecision(12) << fixed;
	long double a , b;
	cin >> a >> b;

	long double hour , minute;
	cin >> hour >> minute;

	long double temp= 2 * PI * ((hour/12) + ((minute/12)/60) - (minute/60));
	long double ans = (a*a) + (b*b) - (2*a*b*cos(temp));
	
	cout << sqrt(ans) << endl;
	return 0;
}


Measured memory_bytes: 4112
A = []
N = gets.to_i
Ai = gets.split.map(&:to_i)

oddFlag = false
time = 0
while oddFlag == false do
    Ai.each_with_index do |a,index|
        if a % 2 != 0
            oddFlag = true
        end
        a /= 2
        Ai[index] = a
    end
    if oddFlag == false
        time += 1
    end
end
p time


Measured memory_bytes: 1788
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
# from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint

def myinput():
    return map(int,input().split())

def mylistinput(n):
    return [ list(myinput()) for _ in range(n) ]

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

s = input()

if s[1]=="B":
    print("ARC")
else:
    print("ABC")

Measured memory_bytes: 68332
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,a) for(int i=0;i<(a);i++)
#define MOD 1000000007
const string vacant="Vacant";

string query(int x){
  cout<<x<<endl;
  string res;
  cin>>res;
  fflush(stdout);
  return res;
}

int main(){
  int N;
  cin>>N;
  string t0=query(0);
  if(t0==vacant){
    return 0;
  }
  int ub=N, lb=1;
  rep(i,19){
    int mid=(lb+ub)/2;
    string x=query(mid);
    if(x==vacant){
      return 0;
    }
    if((mid%2==1 and t0!=x) or (mid%2==0 and t0==x)){
      lb=mid+1;
    }else{
      ub=mid;
    }
  }
  return 0;
}


Measured memory_bytes: 852
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
int N,Q;
int V[1<<18],W[1<<18];
int depth[1<<18];
int pre[1<<9][100010];
void dfs(int u,vector<int>&now)
{
	if(depth[u]==9)
	{
		int id=u-511;
		for(int j=0;j<1<<9;j++)
		{
			int sW=0,sV=0;
			for(int k=0;k<9;k++)if(j>>k&1)
			{
				sW+=W[now[k]];
				sV+=V[now[k]];
				if(sW>100000)break;
			}
			if(sW<=100000)pre[id][sW]=max(pre[id][sW],sV);
		}
		for(int i=1;i<=100000;i++)pre[id][i]=max(pre[id][i],pre[id][i-1]);
	}
	else
	{
		now.push_back(u);
		if(2*u+1<N)dfs(2*u+1,now);
		if(2*u+2<N)dfs(2*u+2,now);
		now.pop_back();
	}
}
main()
{
	scanf("%d",&N);
	for(int i=0;i<N;i++)scanf("%d%d",&V[i],&W[i]);
	depth[0]=0;
	for(int i=1;i<N;i++)
	{
		depth[i]=depth[(i-1)/2]+1;
	}
	vector<int>tmp;
	dfs(0,tmp);
	scanf("%d",&Q);
	for(;Q--;)
	{
		int v,L;scanf("%d%d",&v,&L);
		v--;
		vector<pair<int,int> >now(1,make_pair(0,0));
		while(true)
		{
			vector<pair<int,int> >nxt;
			for(pair<int,int>&p:now)
			{
				nxt.push_back(p);
				if(p.first+W[v]<=L)
				{
					nxt.push_back(make_pair(p.first+W[v],p.second+V[v]));
				}
			}
			now.swap(nxt);
			if(depth[v]%9==0)break;
			v=(v-1)/2;
		}
		int ans=0;
		for(pair<int,int>&p:now)
		{
			if(v==0)ans=max(ans,p.second);
			else
			{
				ans=max(ans,p.second+pre[v-511][L-p.first]);
			}
		}
		printf("%d\n",ans);
	}
}


Measured memory_bytes: 206332
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <iterator>
#include <unordered_map>
#include <unordered_set>
#include <tuple> 
#include<memory>

using namespace std;

int main() {
	int start;
	int end;
	cin >> start;
	cin >> end;

	int num = 0;

	for (; start <= end; start++) {
		string str = to_string(start);
		string rev = str;
		reverse(rev.begin(), rev.end());

		if (str == rev) {
			num++;
		}
	}

	cout << num;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <queue>
#include <list>
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define crep(i) for(char i='a';i<='z';i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define ALL(x) (x).begin(),(x).end()
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

map<char,vector<ll>> M;

int main() {
  ll Length=0,m,Point=0,Hakken=0;
  string S,T;
  cin >> S >> T;
  rep(i,S.size()){
    M[S[i]].push_back(i+1);
  }
  rep(i,T.size()){
    if(M[T[i]].size()==0){
      cout << -1 << endl;
      return 0;
    }
    if(M[T[i]][M[T[i]].size()-1]<=Point){
      Length+=S.size()-Point+M[T[i]][0];
      Point=M[T[i]][0];
    }
    else{
      m=upper_bound(ALL(M[T[i]]),Point)-M[T[i]].begin();
      Length+=M[T[i]][m]-Point;
      Point=M[T[i]][m];
    }
  }
  cout << Length << endl;
}

Measured memory_bytes: 1664
#include <stdio.h>
#include <stdint.h>
#include <math.h>

#define __STDC_FORMAT_MACROS
#include <inttypes.h>

int main()
{
    uint64_t N;
    scanf("%"PRIu64, &N);

    uint64_t i, r, l=sqrt(N);
    for(i=1; i<=l; i++){
        if(N%i == 0){
            r = i;
        }
    }

    printf("%"PRIu64"\n", r + N/r - 2);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(), x.end()
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5 << 28, MOD = 1e9 + 7;

int N, M, K;
vi A, B;
string S, T;

void input() {
  int x, y, z;
  cin >> N;
  A.resize(N);
  rep(i, 0, N - 1) { cin >> A[i]; };
}
void solve() {
  int a = 0;
  for (auto x : A) a += x;
  debug(a);
  int b = round((double(a)) / (double)N);
  debug(b);

  int ans = 0;
  for (auto x : A) {
    ans += (b - x) * (b - x);
  }
  cout << ans << endl;
  ;
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 256
import math

a,b,h,m = map(int, input().split())



h_rad = ((12-h)/6 - m/(30*12) )*math.pi
m_rad = ((60-m)/30)*math.pi


x = a * math.cos(h_rad) - b * math.cos(m_rad)
y = a * math.sin(h_rad) - b * math.sin(m_rad)
ans = math.sqrt(x**2 + y**2)

print(ans)

Measured memory_bytes: 9476
sx,sy,tx,ty = map(int,input().split())

res = ""

res += "R"*(tx-sx) + "U"*(ty-sy)
res += "L"*(tx-sx) + "D"*(ty-sy)

res += "L" + "U"*(ty-sy+1) + "R"*(tx-sx+1) + "D"
res += "R" + "D"*(ty-sy+1) + "L"*(tx-sx+1) + "U"

print(res)


Measured memory_bytes: 3060
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
  input! {
    n : usize,
    a : [i64; n]
  };
  let s : i64 = a.iter().sum();
  let mut b = vec![0; n];
  for i in 0..n {
    b[i] = a[(i + 1)%n] - a[i];
  }
  //println!("{:?} {:?}", s, b);
  let ao = (n*(n+1)/2) as i64;
  if s % ao != 0 {
    println!("NO");
    return;
  }
  let k = s / ao;
  let b : Vec<i64> = b.iter().map(|x| x - k).collect();
  if b.iter().all(|&x| x <= 0 && x % n as i64 == 0) {
    println!("YES");
  } else {
    println!("NO");
  }
}

Measured memory_bytes: 6396
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp>
//#include <functional> // for less
#define PI acos(-1.0)
#define eps 1e-9
#define ll long long
#define ull unsigned long long
#define nl printf("\n")
#define sf scanf
#define pf printf
#define INF (ll)1e15
#define mod 1000000007

///#define isValid(n,m,nx,ny)nx>=0&&nx<n&&ny>=0&&ny<m
///int kx[]={1, 1, -1, -1, 2, 2, -2, -2}; //knight moves
///int ky[]={2,-2,  2, -2, 1,-1,  1, -1}; //knight moves
///int dx[]={1,-1,0,0,1,-1,1,-1};//eight direction
///int dy[]={0,0,1,-1,1,-1,-1,1};//eight direction
 
///using namespace __gnu_pbds;
using namespace std;
 
///inline double toRad(double deg){return deg*PI/180;}
///inline double toDeg(double rad){return rad*180/PI;}
///typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set;
 
const int S=123456;
int main()
{
    #ifndef ONLINE_JUDGE
    //freopen("input.txt","r",stdin);
    #endif
    int n;
    while(sf("%d",&n)==1)
    {
        int a[n+5],b[n+5],c[n+5];
        for(int i=0;i<n;i++)sf("%d",&a[i]);
        for(int i=0;i<n;i++)sf("%d",&b[i]);
        for(int i=0;i<n;i++)sf("%d",&c[i]);

        sort(a,a+n);
        sort(b,b+n);
        sort(c,c+n);

        ll ans=0;
        for(int i=0;i<n;i++)
        {
            ll u=lower_bound(a,a+n,b[i])-a;
            ll l=upper_bound(c,c+n,b[i])-c;
            l=n-l;
            ans+=(u*l);
        }
        pf("%lld\n",ans);
    }
    return 0;
}
 









 




























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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int N,K;
    Scd2(N,K);
    int a;
    int ans = 0;
    Rep(i,N){
        Scd(a);
        ans += a>=K;
    }

    printf ("%d\n", ans );

    return 0;
}





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

string arr[7] = {};

int main()
{
	int a, b, k, answer=0;
	cin >> a >> b >> k;
	for(int i=0; i<a; i++)
	{
		cin >> arr[i];
	}
	for(int i=0; i<(1<<a); i++)
	{
		for(int j=0; j<(1<<b); j++)
		{
			int p=i, l=j;
			int arr2[a]={0};
			int arr3[b]={0};
			for(int u=0; u<a; u++)
			{
				arr2[u] = p%2;
				p /= 2;
			}
			for(int u=0; u<b; u++)
			{
				arr3[u] = l%2;
				l/=2;
			}
			int t=0;
			for(int u=0; u<a; u++)
			{
				for(int y=0; y<b; y++)
				{
					if(arr[u][y]=='#' && arr2[u]==0 && arr3[y]==0)
					{
						t ++;
					}
				}
			}
			if(t==k)
			{
				answer++;
			}
		}
	}
	cout << answer;
}



Measured memory_bytes: 3628
import sys, collections
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**20
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

def resolve():
    ABC = LI()

    cnt = collections.Counter(ABC)
    ans = [k for k, v in cnt.items() if v == 1]
    print(ans[0])

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9456
package main

import "fmt"

func main() {
	var n int
	var s string
	fmt.Scan(&n, &s)
	maxCount := 0
	for i := 1; i < n; i++ {
		count := sameKindCount(s[:i], s[i:])
		maxCount = max(count, maxCount)
	}
	fmt.Println(maxCount)
}

func sameKindCount(a, b string) int {
	m1 := make(map[rune]bool, len(a))
	for _, c := range a {
		m1[c] = true
	}
	m2 := make(map[rune]bool, len(b))
	for _, c := range b {
		m2[c] = true
	}
	count := 0
	for v := range m1 {
		if _, ok := m2[v]; ok {
			count++
		}
	}
	return count
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

Measured memory_bytes: 640
s = str(input())
t = str(input())
alp_s = [0]*26
alp_t = [0]*26
for i in range(len(s)):
    a = ord(s[i])-ord("a")
    b = ord(t[i])-ord("a")
    alp_s[a]+=1
    alp_t[b]+=1
alp_s.sort()
alp_t.sort()
for i in range(26):
    if alp_s[i]!=alp_t[i]:
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 3632
from math import gcd


def lcm(x, y):
    return (x * y) // gcd(x, y)


N = int(input())
A = list(map(int, input().split()))
X = A[0]

for a in A[1:]:
    X = lcm(X, a)
X -= 1
ans = 0
for a in A:
    ans += X % a
print(ans)

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

int main(){
    int s;cin>>s;
    int a=s;
    vector<int> b;
    b.push_back(a);
    while(true){
        bool is_same=false;
        if(a%2==0) a=a/2;
        else a=a*3+1;
        for(int i=0;i<b.size();i++){
            if(a==b[i]){
                is_same=true;
                break;
            }
        }
        b.push_back(a);
        if(is_same) break;
    }
    cout<<b.size()<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
 
typedef struct{
    char c;
    int d;
}Card;
 
void setCard(Card *card, char a, int b){
    card->c = a;
    card->d = b;
    return;
}
 
void swapCard(Card *a1, Card *a2){
    Card temp;
    setCard(&temp, a1->c, a1->d);
    setCard(a1, a2->c, a2->d);
    setCard(a2, temp.c, temp.d);
    return;
}
 
int partition(Card A[], int p, int r){
    int x = A[r-1].d;
    int i = p-1, j;
    for( j = p; j < r-1; j++ ){
        if( A[j].d <= x ){
            i++;
            swapCard(&A[i], &A[j]);
        }
    }
    swapCard(&A[i+1], &A[r-1]);
    return i+1;
}
 
void quick(Card A[], int p, int r){
    if( p < r ){
        int q = partition(A, p, r);
        quick(A, p, q);
        quick(A, q+1, r);
    }
    return;
}
 
int main(){
    int n, i, j, isStable = 1;
    char t;
    Card card[100000], iCard[100000];
    scanf("%d", &n);
    scanf("%c", &t);
    for( i = 0; i < n; i++ ){
        scanf("%c %d", &card[i].c, &card[i].d);
        setCard(&iCard[i], card[i].c, card[i].d);
        scanf("%c", &t);
    }
    quick(card, 0, n);
    int bv = -1;
    for( i = 0; i < n; i++ ){
        if( card[i].d != bv ){ j = 0; }
        bv = card[i].d;
        for( ; j < n; j++ ){
            if( card[i].d == iCard[j].d ){
                if( card[i].c == iCard[j].c ){
                    j++;
                    break;
                }else{
                    isStable = 0;
                    break;
                }
            }
        }
    }
    printf("%s\n", (isStable?"Stable":"Not stable"));
    for( i = 0; i < n; i++ ){
      printf("%c %d\n", card[i].c, card[i].d);
    }
    return 0;
}

Measured memory_bytes: 2168
#pragma region cp-helper
#include <bits/stdc++.h>
using namespace std;
#define AC ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define ull unsigned long long
#define ii pair<int, int>
#define lll pair<ll, ll>
#define vi vector<int>
#define vvi vector<vi>
#define vl vector<ll>
#define vll vector<lll>
#define vvl vector<vl>
#define vii vector<ii>
#define all(a) a.begin(), a.end()
#define qsort(a) sort(all(a))
#define qsortd(a) sort(all(a), greater<>())
#define qsortf(a, f) sort(all(a), f)
#define pb(n) push_back(n)
#define eb(n) emplace_back(n)
#define pp(a, b) emplace_back(a, b)
#define umap unordered_map
#define nl '\n'
#define fileio(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout)
#define qmod %mod
#define pls int
#define give main()
const int mod = 1000000007;
#pragma endregion

pls give {
    AC;
    int m;
    cin >> m;
    cout << (24-m)+24;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printInt(a) printf("%d\n", a)
#define scanInt(a) scanf("%d", &a)
#define scan2Int(a, b) scanf("%d %d", &a, &b)
#define scan3Int(a, b, c) scanf("%d %d %d", &a, &b, &c)
using namespace std;

int main() {
    char s[4];
    scanf("%s", s);
    if (s[1] == 'B') printf("ARC");
    else printf("ABC");
    return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  string S;
  string V;
  bool trans=false;
  cin>>S;
  ll Q;
  cin>>Q;
  for(int i=0; i<Q; i++){
    int a;
    cin>>a;
    if(a==1){
      if(trans==true)
        trans=false;
      else
        trans=true;
    }
    else if(a==2){
      int b;
      string X;
      cin>>b>>X;
      if(trans==true){
        if(b==1)
          S+=X;
        else{
          X+=V;
          V=X;
        }
      }
      else{
        if(b==1){
          X+=V;
          V=X;
        }
        else
          S+=X;
      }
    }
  }
  V+=S;
  ll s=V.size();
  if(trans==true){
    for(int i=0; i<s/2; i++){
      char tmp;
      tmp=V[i];
      V[i]=V[s-1-i];
      V[s-1-i]=tmp;
    }
  }
  cout<<V<<endl;
}


Measured memory_bytes: 1396
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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 INFLL = 1LL<<62;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int k;
	ll ans=0;
	cin >>k;
	queue<ll>list;
	for(int i=1;i<=9;i++){
	list.push((ll)i);
	}
	for(int i=0;i<k;i++){
		ans=list.front();
		//clog<<ans<<endl;
		list.pop();
		if(ans%10!=0){
		list.push(ans*10+(ans%10)-1);
		}
		list.push(ans*10+ans%10);
		if(ans%10!=9){
		list.push(ans*10+1+ans%10);
		}
	}
	cout<<ans<<endl;
}

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

#pragma region Macros
using ll = long long;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
#define int ll
#define IOS\
    ios::sync_with_stdio(false);\
    cin.tie(0);\
    cout.tie(0);
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(ll i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define SORT(name) sort(name.begin(), name.end())
#define RSORT(name)\
    SORT(name);\
    reverse(all(name));
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
template <class T> inline void print(T x){ cout << x << '\n';}
template<typename T1,typename T2> inline void chmin(T1 &a, T2 b){ if(a > b) a = b; }
template<typename T1,typename T2> inline void chmax(T1 &a, T2 b){ if(a < b) a = b; }

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#pragma endregion

vector<int> GetDivisor(int n) {
    vector<int> v;
    for(int i = 1; i*i <= n; ++i) {
        if(n % i == 0) {
            v.push_back(i);
            if(i != n / i) { v.push_back(n / i); }
        }
    }
    sort(v.begin(), v.end());
    return v;
}

int func(int n, int k) {
    while(n >= k) {
        if(n % k == 0) { n /= k; }
        else { n %= k; }
    }
    return n;
}

signed main() {
    IOS;

    int N;
    cin >> N;

    int ans = GetDivisor(N-1).size() - 1;

    auto res = GetDivisor(N);
    for(auto val : res) {
        if(val == 1) { continue; }
        if(func(N, val) == 1) { ans++; }
    }
    print(ans);

    return 0;
}


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

int main(){
    string s;
    cin >> s;
    int a=0;
    for(int i=0;i<s.size()/2;i++){
        if(s[i]!=s[s.size()-i-1])
        a++;
    }
    cout<<a<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
using namespace std;
int main() {
	int i,n, sum1, sum2;
	sum1 = 0; sum2 = 0;
	string s, t;
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> s; cin >> t;
		if (s < t) {
			sum2 += 3;
		}
		else if (s > t) {
			sum1 += 3;
		}
		else if (s == t) {
			sum1 += 1; sum2 += 1;
		}
	}
	cout << sum1 << " " << sum2 << endl;
	return 0;
}


Measured memory_bytes: 3212
#include<bits/stdc++.h>
using namespace std;
const int N = 2e5+5;
typedef long long ll;
const int inf = 1e9;

ll h,level=0,ans;


int main(){
  ios::sync_with_stdio(false);
  // freopen("input.txt","r",stdin);
  cin>>h;
  while(h > 0){
    ans += pow(2,level++);
    h/=2;
  }
  cout<<ans<<endl;
  return 0;
}




Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
3 4 6
0 0
0 2
0 3
1 1
2 1
2 3

output:
3
"""

import sys


def generate_adj_table(_edges):
    for edge in _edges:
        vx, vy = map(int, edge)
        init_adj_table[vx].add(vy)

    return init_adj_table


def graph_dfs(current, matching, visited):
    for adj in range(y_num):
        if (not visited[adj]) and (adj in adj_table[current]):
            visited[adj] = True
            # matching[adj] = -1: target in y not assigned to any of x
            # matching[adj] -> an assigned source in x
            # graph_dfs(matching[adj], matching, visited) = True indicates that source has been
            if matching[adj] == -1 or graph_dfs(matching[adj], matching, visited):
                matching[adj] = current
                return True
    return False


def mbm():
    matching = [-1] * y_num
    res = 0
    for v in range(x_num):
        visited = [False] * y_num
        if graph_dfs(v, matching, visited):
            res += 1
    # print(matching)
    return res


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    x_num, y_num, e_num = map(int, _input[0].split())
    edges = map(lambda x: x.split(), _input[1:])

    init_adj_table = [set() for _ in range(x_num)]
    adj_table = generate_adj_table(edges)
    print(mbm())

Measured memory_bytes: 9260
#pragma GCC optimize("Ofast,fast-math,unroll-loops")
 
#include <bits/stdc++.h>
 
#define int ll
//#define double long double
#define endl '\n'
#define all(C) (C).begin(), (C).end()
#define rall(C) (C).rbegin(), (C).rend()
#define mp make_pair 
#define pb emplace_back
#define dbg(x) cerr << #x << " : " << x << endl
#define PI 3.1415926535
 
using namespace std;
        
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair <int, int>;
using pld = pair <ld, ld>;

/*
const ll MAX_MEM = 3e6;
char MEM[MAX_MEM];
ll MEM_POS = 0;
void* operator new(size_t x)
{
    auto ret = MEM + MEM_POS;
    MEM_POS += x;
    assert(MEM_POS < MAX_MEM);
    return ret;
}
void operator delete(void*)
{}
*/
        
template <class T>
istream& operator>> (istream &in, vector <T> &a)
{
    for (auto &i : a)
        in >> i;
    return in;
}
        
template <class T> 
ostream& operator<< (ostream &out, vector <T> a)
{
    for (auto &i : a)
        out << i << ' ';
    return out;
}
        
template <class T, class U>
istream& operator>> (istream &in, pair <T, U> &p)
{
    in >> p.first >> p.second;
    return in;
}
        
template <class T, class U>
ostream& operator<< (ostream &out, pair <T, U> p)
{
    out << p.first << " " << p.second << " ";
    return out;
}
        
inline void Start()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    //freopen("lol.in", "r", stdin);
    //freopen("lol.out", "w", stdout);
}

signed main()
{
    Start();
    int n;
    string s, t;
    cin >> n >> s >> t;
    for (int len = n; len <= 2 * n; ++len)
    {
        string x(len, ' ');
        for (int i = 0; i < n; ++i)
            x[i] = s[i], x[len - i - 1] = t[n - i - 1];
        int flag = 1;
        for (int i = 0; i < n; ++i)
            flag = flag && (x[i] == s[i] && x[len - i - 1] == t[n - i - 1]);
        if (flag)
            return cout << x.size(), 0;
    }
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#include <unistd.h>
//#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll INF = 1LL << 60;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}

ll fac[510000], finv[510000], inv[510000];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < 510000; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logN)
ll modpow(ll n,ll m,ll MOD){
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}

//printf("%.10f\n", N);
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/
/*
    cout << fixed << setprecision(15);
*/

int main(){
    ll N,M,K;
    cin >> N >> M >> K;
    vector<ll> a(N),b(M);
    rep(i,N)cin >> a[i];rep(i,M)cin >> b[i];
    vector<ll> waa(N + 1),wab(M + 1);
    waa[0] = 0;
    wab[0] = 0;
    for(ll i = 1;i <= N;i++)waa[i] = a[i - 1] + waa[i - 1];
    for(ll i = 1;i <= M;i++)wab[i] = b[i - 1] + wab[i - 1];
    ll ans = 0;
    rep(i,N + 1){//A isatu
        ll rem = K - waa[i];
        if(rem < 0)continue;
        auto itr = upper_bound(all(wab),rem);
        ans = max(ans,itr - wab.begin() - 1 + i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 9592