akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    string s;
    cin >> s;

    int N = s.length();
    assert(n * 2 == N);

    const long long MOD = 1000000007LL;
    long long res = 1;
    if (s[0] != 'B') {
        res = 0;
    } else {
        int cnt = 0;
        for (int i = 0; i < N; ++i) {
            int c = s[i] == 'B' ? 1 : 0;
            if (cnt == 0) {
                if (c == 0) {
                    res = 0;
                    break;
                }
                ++cnt;
                continue;
            }
            if ((c ^ (cnt & 1)) & 1) {
                ++cnt;
            } else {
                (res *= cnt) %= MOD;
                --cnt;
            }
        }
        if (cnt != 0) {
            res = 0;
        }

        for (int i = 0; i < n; ++i) {
            (res *= (i + 1)) %= MOD;
        }
    }

    cout << res << '\n';

    return 0;
}

Measured memory_bytes: 720
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
const int N=300010,mod=1e9+7;
long long ans=0;

int main(){
    int n;
    cin>>n;
    vector<long long> a(n);
    for(int i=0;i<n;i++) cin>>a[i];

    //位运算每一位互不影响，同一位可以一起算
    //只有1与0进行异或时才得到1，因此这一位上1的数目乘0的数目就是异或为1的所有可能情况数
    for(int i=0;i<60;i++){
        long long x=0;
        for(int j=0;j<n;j++) if(a[j]>>i &1 ) x++;//统计每个数第i位的1
        long long now = x*(n-x) %mod;//每个数第i位的1的个数乘0的个数
        for(int j=0;j<i;j++) now = now*2%mod;//把权重移回去
        ans += now;
        ans %=mod;

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

}


Measured memory_bytes: 2688
#include <iostream>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <float.h>
#include <limits>
#include <vector> 
#include <string.h>
#include <iomanip>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define INF 2147483647
#define ll long long
#define asort(a) sort(a.begin(),a.end());

using namespace::std;

int jo(ll int jxo, ll int jyo){//累乗
    ll int jhogeo = 1;
    rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
    return jhogeo;
}
char tobig(char toxbig){//char大文字化
  return (toxbig-0x20);
}
char tolow(char toxlow){//char小文字化
  return (toxlow+0x20);
}
int ctoi(char cctoi){//char->int
  if('0' <= cctoi && cctoi <= '9') return (cctoi-'0');
  return -1;
}

int gcd(int gcad, int gcbd) {//最大公約数
  if(gcad < gcbd) return gcd(gcbd, gcad);
  int gcrd;
  while ((gcrd=gcad%gcbd)) {
    gcad = gcbd;
    gcbd = gcrd;
  }
  return gcbd;
}
int lcm(int lcam, int lcbm){//最小公倍数
 return (lcam*lcbm)/gcd(lcam,lcbm);
}

int dp[3010][3010]={0};

int main(){
  int m1,d1,m2,d2; cin>>m1>>d1>>m2>>d2;
  if(d2==1) cout<<1;
  else cout<<0;

}
// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//cout<<fixed<<setprecision(n);  //小数点n桁まで表示

//  vector<pair<int,int>> data(N);  //2つのデータを格納、.first/.secondで参照
// pairのソートはfirst優先の昇順


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
int panduan(int a,int b,char ar[52][52])
{
    for(int i=1;i<=a;i++)
    {
        for(int j=1;j<=b;j++)
        {
            if(ar[i][j]=='#')
        {
            if(!((ar[i-1][j]=='#')||(ar[i+1][j]=='#')||(ar[i][j-1]=='#')||(ar[i][j+1]=='#')))
                return 0;
        }
        }
    }
    return 1;
}
int main()
{
    char arr[52][52]={'.'};
    int a,b;
    cin>>a>>b;
    for(int i=1;i<=a;i++)
    {
        for(int j=1;j<=b;j++)
            cin>>arr[i][j];
    }
    int c=panduan(a,b,arr);
    if(c)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}


Measured memory_bytes: 256
/*
  || Shree Ganeshay Namah ||

     || Jai Shree Ram ||
  || Nabh Sparsham Diptam ||
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007
#define block 180
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
#define f1 first
#define s1 second
#define pb push_back
// to floor a/b you can do a/b and to ceiling a/b you can do (a+b-1)/b
int jai_shree_ram()
{
    return 1;
}
int shree_ganeshay_namah()
{
    return 1;
}
ll power(ll x,ll y)
{
    ll r=1;
    while(y>0)
    {
        if(y%2!=0)
            r=(r%mod * x%mod)%mod;
        x=(x%mod * x%mod)%mod;
        y=y/2;
    }
    return r;
}
ll ncr(ll n,ll k)
{

    ll c[k+1];
    memset(c,0,sizeof(c));
    c[0]=1;
    for(ll i=1;i<=n;i++)
    {
        for(ll j=min(i,k);j>0;j--)
            c[j]=c[j]+c[j-1];
    }
    return c[k];
}

bool prime[500001];
void sieve()
{
    ll i,j;
    memset(prime,true,sizeof(prime));
    prime[0]=false;
    prime[1]=false;
    for(i=2;i<=sqrt(100001);i++)
    {
        if(prime[i])
        {
            for(j=i*i;j<=100001;j=j+i)
                prime[j]=false;
        }
    }
}
//Start of Matrix Exponentiation Code
void mat_mul(ll F[2][2],ll M[2][2]) {
   ll a = ((F[0][0]%mod * M[0][0]%mod)%mod + (F[0][1]%mod * M[1][0]%mod)%mod)%mod;
   ll b = ((F[0][0]%mod * M[0][1]%mod)%mod + (F[0][1]%mod * M[1][1]%mod)%mod)%mod;
   ll c = ((F[1][0]%mod * M[0][0]%mod)%mod + (F[1][1]%mod * M[1][0]%mod)%mod)%mod;
   ll d = ((F[1][0]%mod * M[0][1]%mod)%mod + (F[1][1]%mod * M[1][1]%mod)%mod)%mod;
   F[0][0] = a;
   F[0][1] = b;
   F[1][0] = c;
   F[1][1] = d;
}
void mpower(ll F[2][2], ll n) {
   if (n == 0 || n == 1)
      return;
   ll M[2][2] = {{1,1},{1,0}};
   mpower(F, n / 2);
   mat_mul(F, F);
   if (n % 2 != 0)
      mat_mul(F, M);
}
ll fib_mat(ll n) {
   ll F[2][2] = {{1,1},{1,0}};
   if (n == 0)
      return 0;
   mpower(F, n - 1);
   return F[0][0]%mod;
}
//End of Matrix Exponentiation
void fun(string s)
{
    ll n = s.size(),i,j;
    if(n%2==1)
    {
        for(i=n/2-1,j=n/2+1;;i--,j++)
        {
            if(i<0 || j>n)
                break;
            s[j]=s[i];
        }
        cout<<s<<"\n";
    }
    else
    {
        for(i=n/2-1,j=n/2;;i--,j++)
        {
            if(i<0 || j>n)
                break;
            s[j]=s[i];
        }
        cout<<s<<"\n";
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n,i,j,k;
    cin>>n;
    set<ll>s;
    ll f=0;
    map<ll,ll>m;
    map<ll,ll>::iterator it;
    for(i=1;i<=sqrt(n);i++)
    {
        for(j=1;j<=sqrt(n);j++)
        {
            for(k=1;k<=sqrt(n);k++)
            {
                if(i*i + j*j + k*k + i*j + j*k + k*i<=n)
                    {
                        ll x=i*i + j*j + k*k + i*j + j*k + k*i;
                        m[x]++;
                    }
            }
        }
    }
    for(i=1;i<=n;i++)
    {
        cout<<m[i]<<"\n";
    }
    return 0;

}



Measured memory_bytes: 4144
#include "bits/stdc++.h"
using ll = long long;
using namespace std;

void solve() {
   int n, d, x;
   cin >> n >> d >> x;
   vector <int> a(n);
   for(int i = 0; i < n; i++) {
      cin >> a[i];
   }
   int ans = 0;
   for(int i = 0; i < n; i++) {
      if(a[i] == 1) ans += d;
      else 
         for(int j = 1; j <= d; j++) {
            if(j % a[i] == 1) ans++;
         }
   }
   ans += x;
   cout << ans << endl;
}

int main() {
   cin.tie(0);
   cin.sync_with_stdio(0);
   int testcase = 1;
   // cin >> testcase;

   for(int i = 0; i < testcase; i++) {
      solve();
   } 
   return 0;
}


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

int main () {
     int N; cin >> N;
    vector<int> h(N);
     for ( int i = 0 ; i <N; i++) cin >> h[i];
    
    int ans = 0 ;
     while ( true ) {
         // Find the left edge of the interval. 
        // The first i that becomes h [i]! = 0 is the left end. 
        int s = -1 ;
         for ( int i = 0 ; i<N; i++) {
             if (h[i]!= 0 ) {
                s = i;
                break ;
            }
        }
        // All flowers are 0 when s = -1. 
        if (s ==-1 ) break ;

        // Find the right edge of the section. 
        // Starting from i = s, h [i] = 0. The right side next to i becomes i. 
        // Note that h [N-1] may be the right end. 
        int g = -1 ;
         for ( int i = s; i <N; i ++) {
             if (h[i] == 0 ) {
                g = i- 1 ;
                 break ;
            }
            if (i == N-1 ) g = N-1 ;
        }

        // The height can be lowered by the amount of the lowest flower in the section. 
        int hmin = 101 ;
         for ( int i = s; i <= g; i++) {
            hmin = min(hmin, h[i]);
        }
        for ( int i = s; i <= g; i++) {
            h[i]-= hmin;
        }
        ans += hmin;
    }
    cout << ans;
}


Measured memory_bytes: 256
n = int(input())
p = input()
q = input()

import itertools

l = []
for i in range(1, n+1):
    l.append(str(i))

ans = []
for v in itertools.permutations(l):
    ans.append(" ".join(v))

a = ans.index(p)
b = ans.index(q)
print(abs(a-b))

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

using namespace std;

#define LIMIT 100
#define PLIMIT 10000010
#define MOD 1000000007ll
#define INF 1e9
typedef long long ll;
typedef pair<ll, ll> ii;
int gcd(ll a, ll b) { return (b==0)?a:gcd(b, a%b); }
int lcm(ll a, ll b) { ll i=(a/gcd(a,b))*b; assert(i>0); return i; }
int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};

//  ***** MAIN *****
int main(){
  //ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n; cin >> n;
  int a[100007]={0};

  int t;
  for (int i = 0; i < n; ++i) {
    cin >> t;
    a[t]++;
  }

  int x = 0, counter = -1;
  for (int i = 1; i < 100003; ++i) {
    if(a[i-1] + a[i] + a[i+1]> counter){
      x = i;
      counter = a[i-1] + a[i] + a[i+1];
    }
  }
  std::cout << counter << std::endl;

  return 0;
}



Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,n;
  cin>>n;
  for(a=1;a<=9;a++) for(b=1;b<=9;b++){
    if(a*b==n){
      cout<<"Yes";
      return 0;
    }
  }
  cout<<"No";
  return 0;
}

Measured memory_bytes: 256
n = int(input())
s = input()

w_lst = [0] * n
e_lst = [0] * n

for i in range(1, n):
    if s[i - 1] == "W":
        w_lst[i] = w_lst[i - 1] + 1
    else:
        w_lst[i] = w_lst[i - 1]
for i in range(n - 2, -1, -1):
    if s[i + 1] == "E":
        e_lst[i] = e_lst[i + 1] + 1
    else:
        e_lst[i] = e_lst[i + 1]

ans = 10**10
for i in range(n):
    ans = min(ans, w_lst[i] + e_lst[i])
print(ans)

Measured memory_bytes: 17620
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function main()
    n=parseInt(readline())
    a=sort(parseMap(split(readline())))
    flg=true
    for i in 1:n-1
        if a[i]==a[i+1]
            flg=false
            break
        end
    end
    if flg
        println("YES")
    else
        println("NO")
    end
end
main()

Measured memory_bytes: 125584
#include<bits/stdc++.h>
using namespace std;
int main() {
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    if(k<=a) cout<<k;
    else if(k<=a+b) cout<<a;
    else{
        k = k-a-b;
        cout<<a-k;
    }
}

Measured memory_bytes: 3592
#include<stdio.h>
#include<iostream>
using namespace std;

int main() {
  int x, y;
  int F[50];
  F[0] = F[1] = 1;
  for ( int i = 2; i < 50; i++ ) F[i] = F[i-1] + F[i-2];

  cin >> x;
  cout << F[x] << endl;

  return 0;
}


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

#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DBG(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl

using uint=unsigned int;
using ll=long long;
using pii=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%d",&i);
	return i;
}

ll readLL(){
	ll i;
	scanf("%lld",&i);
	return i;
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(a>b)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

int Sub(const vi& a,const vi& b){
	map<int,int> c,d;
	int ret=0,e=0,f=0,p=a.size(),q=b.size();
	for(auto v:a)
		c[v]++;
	for(auto kv:c)
		if(kv.second%2==1)
			e++;
	for(auto v:b)
		d[v]++;
	for(auto kv:d)
		if(kv.second%2==1)
			f++;
	p-=e;
	q-=f;
	if(e<f){
		swap(e,f);
		swap(p,q);
	}
	ret+=f;
	e-=f;
	f=0;
	int k=min(e,q);
	ret+=k;
	q-=k;
	ret+=p/2+q/2;
	return ret;
}

int main(){
	int n=read(),m=read();
	vector<vi> x(m);
	REP(i,n){
		int v=read();
		x[v%m].PB(v);
	}
	int ans=0;
	REP(i,m){
		int j=(m-i)%m;
		if(i==j)
			ans+=(int)x[i].size()/2;
		else if(i<j)
			ans+=Sub(x[i],x[j]);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 5760
#include<iostream>
#include <math.h>
#include <iomanip>
typedef long long ll;

using namespace std;

int main()
{
    double pi = M_PI;
    double a,b,h,m;
    cin >> a >> b >> h >> m;
    double ax, ay, bx, by;
    ax = a*sin((h/6+m/360)*pi);
    ay = a*cos((h/6+m/360)*pi);
    bx = b*sin(m*pi/30);
    by = b*cos(m*pi/30);

    cout << std::fixed << std::setprecision(15) <<sqrt(pow(ax-bx, 2)+pow(ay-by, 2));
}


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

int c = 0, ans = 0;

int main() {

	while (true) {
		int x, y, s;
		cin >> x >> y >> s;
		if (x == 0 && y == 0 && s == 0)break;

		int s2 = s * 100 / (100 + x);
		for (int i = 1; i < s2;i++) {
			for (int j = 1; j < s2;j++) {
				if((int)(i*(100 + x) / 100)+(int)(j*(100 + x) / 100) == s){
					c = max(c, i + j);
					int a = i*(100 + y) / 100;
					int b = j*(100 + y) / 100;
					ans = max(ans, a + b);
				}
			}
		}
		cout << ans << endl;
		c = 0;
		ans = 0;
	}
}

Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

	string s, t;
	cin >> s >> t;

	int s_len = s.size(), t_len = t.size();
	vector<vector<int>> dp(s_len + 1, vector<int>(t_len + 1));

	for (int i = 1; i <= s_len; i++) {
		for (int j = 1; j <= t_len; j++) {

			if (s[i - 1] == t[j - 1]) dp[i][j] = dp[i - 1][j - 1] + 1;
			else dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);

		}
	}
	
	string ans;
	int x = s_len, y = t_len;
	while (x > 0 && y > 0) {

		if (dp[x][y] == dp[x - 1][y]) x--;
		else if (dp[x][y] == dp[x][y - 1]) y--;
		else {
			ans = s[x - 1] + ans;
			x--, y--;
		}
	}

	cout << ans << "\n";

	return 0;

}

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

int main(){
    int W,H,x,y,r;      
    cin >> W >> H >> x >> y >> r;
    
    if(0 <= x - r && x + r <= W && 0 <= y - r && y + r <= H){
     cout << "Yes" << endl;
    } else {           
     cout << "No" << endl;
    }

    return 0;
}

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

int main(){
	int n;
	cin >> n;
	vector<int> b(n-1);
	rep(i,n-1) cin >> b[i];
	ll ans(b[0]);
	for(int i(1);i<n-1;++i){
		ans += min(b[i-1],b[i]);
	}
	ans += b[n-2];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main(){
    int H, W, i, j;
    string s[55];

    cin >> H >> W;
    for (i = 0; i < H; ++i) cin >> s[i];

    int dx, dy, cnt, di, dj;
    for (i = 0; i < H; ++i){
        for (j = 0; j < W; ++j){
            if (s[i][j] == '#') cout << '#';
            else{
                cnt = 0;
                for (dx = -1; dx <= 1; ++dx){
                    for (dy = -1; dy <= 1; ++dy){
                        di = i + dx;
                        dj = j + dy;
                        if (di >= 0 && dj >= 0 && di < H && dj < W && s[di][dj] == '#') ++cnt;
                    }
                }
                cout << cnt;
            }
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(any{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

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

	string tl = S.substr(0, N);
	string tr = S.substr(N, N);
	reverse(tr.begin(), tr.end());

	ll ans = 0;
	for(int i=0; i<(1<<N); i++){
		string red, blue;
		for(int k=0; k<N; k++){
			if((i>>k)&1) red += tl[k];
			else blue += tl[k];
		}
		int nr = red.size();
		int nb = blue.size();
		vector<vector<ll>> dp(nr+1, vector<ll>(nb+1));
		dp[0][0] = 1;
		for(int k=0; k<nr; k++){
			if(red[k]==tr[k]) dp[k+1][0] = dp[k][0];
		}
		for(int j=0; j<nb; j++){
			if(blue[j]==tr[j]) dp[0][j+1] = dp[0][j];
		}
		for(int k=0; k<nr; k++) for(int j=0; j<nb; j++){
			if(tr[k+j+1] == red[k]) dp[k+1][j+1] += dp[k][j+1];
			if(tr[k+j+1] == blue[j]) dp[k+1][j+1] += dp[k+1][j];
		}
		//for(int k=0; k<=nr; k++) debugv(dp[k]);
		debug(red, blue, tr, dp[nr][nb]);
		ans += dp[nr][nb];
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
D = int(input())
C = [int(i) for i in input().split()]
S = []
for _ in range(D):
    s = [int(i) for i in input().split()]
    S.append(s)

L = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
sum = 0
for i in range(D):
    t = int(input())
    s = S[i]
    sum += s[t - 1]
    for j in range(26):
        if j == t - 1:
            L[t - 1] = i + 1
        else:
            sum -= C[j] * (i + 1 - L[j])
    print(sum)


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

int main()
{
  // 標準入力
  int a,b;
  cin >> a >> b;

  string ab(a, std::to_string(b)[0]);
  string ba(b, std::to_string(a)[0]);

  string answer = ab;
  if (ab > ba)
  {
    answer = ba;
  }


  cout << answer;

  return 0;

}

Measured memory_bytes: 256
import re
[print(re.sub(r'0.','',''.join([str(10000+sum([eval(i[0]+'0'*'ixcm'.find(i[1]))for i in['1'+i for i in''.join(re.split(r'\d\w',s))]+re.findall(r'\d\w',s)]))[i]+'1mcxi'[i]for i in range(5)]).replace('1','')))for s in[input().replace(" ","")for i in range(int(input()))]]

Measured memory_bytes: 6884
from math import ceil

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


cnt=[0]*100010
lst=[]

for i in a:
  cnt[i]+=1

for i in cnt:
  if i<=1:
    continue
  
  else:
    x=i-1
    lst.append(x)

print(n-ceil(sum(lst)/2)*2)

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

int main(){
  int N;
  cin >> N;
  
  int ans = 0;
  for (int i = 1; i <= N; i++) {
    if (i < 10) {
      ans++;
    }
    else if (i >= 100 && i < 1000) {
      ans++;
    }
    else if (i >= 10000 && i < 100000) {
      ans++;
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        int command_num = sc.nextInt();
        for(int i = 0; i < command_num; i++){
            String command = sc.next();
            if(command.equals("replace")) {
            	int a = sc.nextInt();
            	int b = sc.nextInt();
            	String re = sc.next();
            	String before = str.substring(0,a);
            	String after = str.substring(b+1);
            	str = before + re + after;
            }
            if(command.equals("print")) {
            	int a = sc.nextInt();
            	int b = sc.nextInt();
            	System.out.println(str.substring(a,b+1));
            }
            if(command.equals("reverse")) {
            	int a = sc.nextInt();
            	int b = sc.nextInt();
            	String before = str.substring(0,a);
            	String after = str.substring(b+1);
            	String temp = "";
            	for(int j = b; j >= a; j--) {
            		temp += str.charAt(j);
            	}
            	str = before + temp + after;
            }
                }
            }
        }


Measured memory_bytes: 46560
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<cassert>
#include<numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
const int INF = 1001001001;
const long long LINF = 1001002003004005006ll;
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; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
  string s;
  cin >> s;
  if(s[0]=='7')cout << "Yes" << endl;
  else if(s[1]=='7')cout << "Yes" << endl;
  else if(s[2]=='7')cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3136
#include <iostream>
#include<math.h>
#include<algorithm>
using namespace std;
int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	int answer = int(1e9);
	answer = max(10*a + b + c,10*b+a+c);
	answer = max(10*c + a + b, answer);
  cout << answer <<endl;
  return 0;

}

Measured memory_bytes: 256
#include<stdio.h>

int shou(int warareru1,int waru1){
    int kai1=warareru1/waru1;
    return kai1;
}
int amari(int warareru2,int waru2){
    int kai2=warareru2%waru2;
    return kai2;
}
double syousu(double warareru3,double waru3){
    double kai3=warareru3/waru3;
    return kai3;
}
int main(void){
    int ans[2]; //?§£????????\??????(?????¨????????¨)
    double answ;//?§£????????\??????(?°???°??¨)
    int i; //?????¨??????????????¨?????¨?????°?????????
    int warare,wari; //???????????????
    scanf("%d%d",&warare,&wari);
        ans[0]=shou(warare,wari);
        ans[1]=amari(warare,wari);
        answ=syousu(warare,wari);
        printf("%d %d %lf\n",ans[0],ans[1],answ);
    return 0;
}

Measured memory_bytes: 636
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int r = Integer.parseInt(in.next());
            int d = Integer.parseInt(in.next());
            int x_2000 = Integer.parseInt(in.next());
            int x = 0;

            // 出力
            x = x_2000;
            for (int i = 0; i < 10; i++) {
                x = r * x - d;
                out.println(x);
            }

        }

    }
}



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

int main() {
  int N,M;
  int a[110],b[110];
  cin >> N >> M;
  for (int i = 0; i < M; i++) cin >> a[i] >> b[i];
  
  int num1[110] = {0},num2[110] = {0};
  for (int i = 0; i < M; i++) {
    num1[a[i]]++;
    num2[b[i]]++;
  }
  
  for (int i = 1; i <= N; i++) {
    cout << num1[i] + num2[i] << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 500000
#define INFTY 1000000000

int n;
int cnt=0;
int L[N/2+2], R[N/2+2];

void merge(int A[], int left,int  mid, int right){
    int n1 = mid-left;
    int n2 = right-mid;
    
    int i,j=0;
    //L[0...n1], R[0...n2] を生成
    for (i=0; i<n1; i++){
         L[i]=A[left+i];
    }
    for(i=0; i<n2; i++){
        R[i]=A[mid+i];
    }
    L[n1]=INFTY;
    R[n2]=INFTY;
    i=0;j=0;
    for(int k=left; k<right; k++){
        cnt++;
        if(L[i]<=R[j]){
            A[k]=L[i];
            i++;
        }
        else{
            A[k]=R[j];
            j++;
        }
            }
    
}

void mergeSort(int A[],int left,int right){
    if(left+1 < right){
        int mid=(left + right)/2;
        mergeSort(A, left, mid);
        mergeSort(A, mid, right);
        merge(A, left, mid, right);
    }
    

}


int main(){
    int A[N];
    scanf("%d",&n);
    for(int i=0; i<n; i++){
        scanf("%d",&A[i]);
    }
    
    int left=0;
    int right=n;
    
    mergeSort(A, left, right);
    
  for(int i=0; i<n; i++){
        if(i) printf(" ");
        printf("%d",A[i]);
   }

    printf("\n%d\n",cnt);
    return 0;
}


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

using namespace std;

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

  int N, K, Q; cin>>N>>K>>Q;
  vector<int> anss(N, 0);
  for (int i = 0; i < Q; i++) {
    int a; cin>>a;
    anss[--a]++;
  }
  for (int i = 0; i < N; i++) {
    cout << (Q-anss[i] < K ? "Yes" : "No") << endl;
  }

  return 0;
}


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

using namespace std;

char s[200005];

int main(){
    cin>>s+1;
    int n=strlen(s+1);

    int res=0;
    for(int i=1;i<=n;++i){
        res+=s[i]-'0';
    }

    if(res%9==0){
        cout<<"Yes";
    }else{
        cout<<"No";
    }

    return 0;
}


Measured memory_bytes: 3816
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 2e+9 + 10;
typedef pair<ll, ll> P;

int main() {
    cin>>A>>B;
    (A += 11)%=13;
    (B += 11)%=13;
    S = (A == B ? "Draw" : A > B ? "Alice" : "Bob");
    cout<<S<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<functional>
#include<map>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define PII pair<int,int>
#define PLI pair<long long, int>
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define ctoi(x) (x - 'a') 
#define CTOI(x) (x - 'A')
#define BIT(x) (1 << (x))
using namespace std;
int main(){
    long long r, x, D;
    cin >> r >> D >> x;
    REP(i, 10){
        x = r * x - D;
        cout << x << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

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

bool isPalindrome(std::string s) {
  int n = s.length();
  for (int i = 0; i < n; ++i) {
    if (s[i] != s[n - i - 1]) return false;
  }

  return true;
}

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

  int n = S.length();
  if (isPalindrome(S) && isPalindrome(S.substr(0, n / 2)) &&
      isPalindrome(S.substr(n / 2 + 1))) {
    std::cout << "Yes" << '\n';
  } else {
    std::cout << "No" << '\n';
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

typedef long long ll;

#define INF 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { debug(itr); }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

int main() {
  int n, d;
  cin >> n >> d;
  int p = d * 2 + 1;
  int cnt = 0;
  int t = 0;
  while (t < n) {
    t += p;
    cnt += 1;
  }

  cout << cnt << endl;
}


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

int main(){
    string s;cin>>s;
    int sum=0;
    for(int i=0;i<s.length();i++){
        char si=s[i];
        sum+=s[i]-'o';
        sum%=9;
    }
    if(sum%9==0)cout<<"Yes";
    else cout <<"No";




    
}

Measured memory_bytes: 3724
class Combination:
    def __init__(self, n_max, mod=10**9+7):
        # O(n_max + log(mod))
        self.mod = mod
        f = 1
        self.fac = fac = [f]
        for i in range(1, n_max+1):
            f = f * i % mod
            fac.append(f)
        f = pow(f, mod-2, mod)
        self.facinv = facinv = [f]
        for i in range(n_max, 0, -1):
            f = f * i % mod
            facinv.append(f)
        facinv.reverse()

    def __call__(self, n, r):  # self.C と同じ
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def C(self, n, r):
        if not 0 <= r <= n: return 0
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def P(self, n, r):
        if not 0 <= r <= n: return 0
        return self.fac[n] * self.facinv[n-r] % self.mod

    def H(self, n, r):
        if n == 0 and r > 0: return 0
        return self.fac[n+r-1] * self.facinv[r] % self.mod * self.facinv[n-1] % self.mod

    def rising_factorial(self, n, r):  # 上昇階乗冪 n * (n+1) * ... * (n+r-1)
        return self.fac[n+r-1] * self.facinv[n-1] % self.mod

    def stirling_first(self, n, k):  # 第 1 種スターリング数  lru_cache を使うと O(nk)  # n 要素を k 個の巡回列に分割する場合の数
        if n == k: return 1
        if k == 0: return 0
        return (self.stirling_first(n-1, k-1) + (n-1)*self.stirling_first(n-1, k)) % self.mod

    def stirling_second(self, n, k):  # 第 2 種スターリング数 O(k + log(n))  # n 要素を区別のない k グループに分割する場合の数
        if n == k: return 1  # n==k==0 のときのため
        return self.facinv[k] * sum((-1)**(k-m) * self.C(k, m) * pow(m, n, self.mod) for m in range(1, k+1)) % self.mod

    def balls_and_boxes_3(self, n, k):  # n 要素を区別のある k グループに分割する場合の数  O(k + log(n))
        return sum((-1)**(k-m) * self.C(k, m) * pow(m, n, self.mod) for m in range(1, k+1)) % self.mod

    def bernoulli(self, n):  # ベルヌーイ数  lru_cache を使うと O(n**2 * log(mod))
        if n == 0: return 1
        if n % 2 and n >= 3: return 0  # 高速化
        return (- pow(n+1, self.mod-2, self.mod) * sum(self.C(n+1, k) * self.bernoulli(k) % self.mod for k in range(n))) % self.mod

    def faulhaber(self, k, n):  # べき乗和 0^k + 1^k + ... + (n-1)^k
        # bernoulli に lru_cache を使うと O(k**2 * log(mod))  bernoulli が計算済みなら O(k * log(mod))
        return pow(k+1, self.mod-2, self.mod) * sum(self.C(k+1, j) * self.bernoulli(j) % self.mod * pow(n, k-j+1, self.mod) % self.mod for j in range(k+1)) % self.mod

    def lah(self, n, k):  # n 要素を k 個の空でない順序付き集合に分割する場合の数  O(1)
        return self.C(n-1, k-1) * self.fac[n] % self.mod * self.facinv[k] % self.mod

    def bell(self, n, k):  # n 要素を k 個以下に分割する場合の数  O(k**2 + k*log(mod))
        return sum(self.stirling_second(n, j) for j in range(1, k+1)) % self.mod

mod = 10**9+7
comb = Combination(2000)
n, k = map(int, input().split())
print(comb.H(k, n))



Measured memory_bytes: 5776
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007

#A
def A():
    r = II()
    if r < 1200:
        print("ABC")
    elif r < 2800:
        print("ARC")
    else:
        print("AGC")
    return

#B
def B():
    return

#C
def C():
    d, g = LI()
    pc = LIR(d)
    ans = float("INF")
    tokumono = list(itertools.product((0, 1), repeat=d))
    for toku in tokumono:
        ansa = 0
        ansb = 0
        for i in range(len(toku)):
            if toku[i] == 1:
                ansa += pc[i][0]
                ansb += pc[i][0] * (i + 1) * 100 + pc[i][1]
        for k in range(len(toku) - 1, -1, -1):
            if toku[k] == 0:
                for i in range(pc[k][0] + 1):
                    if i == pc[k][0]:
                        ansb += pc[k][1]
                    if ansb >= g:
                        ans = min(ans, ansa)
                        break
                    ansa += 1
                    ansb += (k+1) * 100
                break
    print(ans)
    return

#D ? 
def D_():
    N, X = LI()
    def dfs(n, x):
        #print(n, x)
        if x == 1 and n > 0:
            return 0 
        elif x < 2 ** (n + 1) - 1:
            return dfs(n - 1, x - 1)
        elif x == 2 ** (n + 1) - 1:
            return 2 ** n 
        elif x == 2 ** (n + 2) - 3:
            return 2 ** (n + 1) - 1
        else:
            return dfs(n - 1, x - 2 ** (n + 1) + 1) + 2 ** n 
    a = dfs(N, X)
    print(a)
    return

def D():
    s = S()
    dp = [0] * 3
    s = s[::-1]
    x = 1
    for i, si in enumerate(s):
        if si == "A":
            dp[0] = (dp[0] + dp[1]) % mod
        elif si == "B":
            dp[1] = (dp[1] + dp[2]) % mod
        elif si == "C":
            dp[2] = (dp[2] + x) % mod
        else:
            dp[0] = (dp[0] * 3 + dp[1]) % mod
            dp[1] = (dp[1] * 3 + dp[2]) % mod
            dp[2] = (dp[2] * 3 + x) % mod
            x *= 3
            x %= mod
    print(dp[0])

#Solve
if __name__ == '__main__':
    D()


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

ll binExpIter(ll x, ll n){
	ll ans = 1;
	while(n > 0){
		if(n & 1)
			ans *= x;
		x = x * x;         
		n = n >> 1;	
	}
	return ans;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	ll n;
    cin >> n;
    string ans = "";
    for(int i = 1; i < 99; i++) {
    	if(n <= binExpIter(26, i)) {
    		n--;
    		for(int j = 0; j < i; j++) {
    			ans += (char)('a' + (int)(n % 26));
    			n /= 26;
    		}
    		break;
    	}
    	else
    		n -= binExpIter(26, i);
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3672
#include <cstdio>
#include <cstring>
using namespace std;

int main()
{
  int n, p;
  while (scanf("%d %d", &n, &p), n|p) {
    int hand[n];
    memset(hand, 0, sizeof(hand));
    int owan = p;
    for (int turn = 0;; turn = (turn + 1) % n) {
      if (owan == 1) {
        int i;
        for (i = 0; i < n; ++i) {
          if (i == turn)
            continue;
          if (hand[i] > 0)
            break;
        }
        if (i == n) {
          printf("%d\n", turn);
          break;
        }
      }
      if (owan > 0) {
        ++hand[turn];
        --owan;
      } else {
        owan += hand[turn];
        hand[turn] = 0;
      }
    }
  }
}

Measured memory_bytes: 764
#include <stdio.h>

int main(void)
{
	int n;
	int a, b, c;
	int aa, bb, cc;
	int i;
	
	scanf("%d", &n);
	
	for(i = 0; i < n; i++)
	{
		scanf("%d %d %d", &a, &b, &c);
		
		aa = a;
		bb = b;
		cc = c;
		
		if(b >= a && b >= c){
			aa = b;
			bb = a;
		}
		else if(c >= a && c >= b){
			aa = c;
			cc = a;
		}
		
		if((aa * aa) == (bb * bb) + (cc * cc))
			printf("YES\n");
		else
			printf("NO\n");
	}
	
	return 0;
}

Measured memory_bytes: 580
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){ 
    int n;
    cin >> n;
    vector<pair<string,pair<int,int> > >a(n);
    REP(i,n){
        string s;
        int p;
        cin >> s >> p;
        a[i].first = s;
        a[i].second.first = 100-p;
        a[i].second.second = i+1;
    }
    sort(a.begin(),a.end());
    REP(i,n){
        cout << a[i].second.second << endl;
    }
    return 0;
}

Measured memory_bytes: 256
///AJoy Sarker ,CSE JAHANGIRNAGAR UNIVERSITY 48 Batch
#include<bits/stdc++.h>
using namespace std;
#define SORT(c) sort((c).begin(),(c).end());
#define pb push_back
#define MP make_pair
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define pi 3.141592653589793
#define ll long long
#define ull unsigned long long
#define w(x) int x;cin>>x;while(x--)
#define fast ios_base::sync_with_stdio(0)
#define sz size()
typedef unsigned long long UL;
template<typename T>inline T  S(T a)
{
    return a*a;
}
template<class T>inline string tostring(T a)
{
    ostringstream os("");
    os << a;
    return os.str();
}
template<typename T>inline ll tolong(T a)
{
    ll res;
    istringstream os(a);
    os>>res;
    return res;
}
template<typename T>inline T gcd(T a, T b)
{
    if (b == 0)return a;
    else return gcd(b, a % b);
}
template<typename T>inline T bigmod(T a, T b, T m)
{
    if (b == 0)return 1;
    else if (b % 2 == 0)return S(bigmod(a, b / 2, m)) % m;
    else return (a % m*bigmod(a, b - 1, m)) % m;
}
const int inf = (int)1e9 + 5;
const ll linf = (ll)1e16 + 5;
const ll modd = (ll)1e9 + 7;
const int mod = 10000007;
/*#define N 20000009
bool prime[N];
vector<ll> prm;
void seive ()
{

    memset(prime, true, sizeof(prime));

    for( ll i=2; i*i<=N; i++)
    {
        if (prime[i] == true)
        {
            prm.pb(i);
            for (ll j=i*i; j<=N; j += i)
                prime[j] = false;
        }
    }
}*/
void pr (int f)
{
    if(f==1)
        cout<<"Yes\n";
    else
        cout<<"No\n";
}
map<int,int>mp;
multiset<string> st;
multiset<string> :: iterator it;

deque <char> q ;
int vis [1000];
int main()
{
    fast ;
   int h,w;
  cin >> h >> w;
  string s[h+1];
 for ( int i=0;i<h;i++)
{
  cin>> s[i];
 cout << s[i]<<endl;
cout << s[i]<<endl;
}
}







Measured memory_bytes: 3684
#include <stdio.h>

void trace(int A[], int N) {
	int i;
	for (i=0; i<N; i++) {
		if(i>0) printf(" ");
		printf("%d",A[i]);
		
	}
	printf("\n");
}

void insertionSort(int A[], int N) {
	int i, j, key;
	for (i=1; i<N; i++) {
		key = A[i];
		j=i-1;
		while (j>=0 && A[j]>key) {
			A[j+1] = A[j];
			j--;
		}
		A[j+1] = key;
		trace(A,N);
	}	
}

int main(void) {
	int N, i, j;
	int A[100];
	
	scanf("%d",&N);
	for (i=0; i<N; i++) scanf("%d",&A[i]);
	trace(A,N);
	insertionSort(A,N);
	
	return 0;
}

Measured memory_bytes: 604
#include <stdio.h>

int main(void){
  int a;
  int b;
  int x;
  int c;
  
  
  scanf("%d%d%d",&x,&a,&b);
  
  c = b-a;
  
  if(x<c){
   printf("dangerous");
  }else if(c<=0){
   printf("delicious");
  }else{
   printf("safe");
  }
}

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    vector<bool> judge(n, false);
    for(int i = 0;i < n;i++)cin >> a.at(i);
    int memo = 0;
    int count = 1;
    while(true){
        if(a.at(memo) == 2){
            cout << count << endl;
            return 0;
        }
        else if(judge.at(memo)){
            cout << -1 << endl;
            return 0;
        }
        else{
            count++;
            judge.at(memo) = true;
            memo = a.at(memo) - 1;
        }
    }
}

Measured memory_bytes: 640
/*
	
	@Raghul
*/
#include <bits/stdc++.h> 
using namespace std; 
#define ll long long
ll ans[100005];
map <char,ll> m;
ll fastpow(ll a,ll b){
	if(b==0)
		return 1LL;
	ll temp=fastpow(a,b/2);
	temp=temp*temp;
	if(b%2==1)
		temp=temp*a;
	return temp;
}	
bool comp(string s1, string s2){
	for(int i=0;i<min(s1.length(),s2.length());i++){
		if(m[s1[i]]!=m[s2[i]]){
			return m[s1[i]]<m[s2[i]];
		}
	}
	return 1;
}
void solve(){
	string s;
	cin>>s;
	ll cnt = 0;
	for(int i=0;i<s.length();i++){
		if(s[i]=='2')	cnt++;
	}
	cout<<cnt;
}
int main(){ 
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T;
    T = 1;
    while(T--){
    	solve();
    }
	return 0; 
} 

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

int main(){
  long long int n,a,b,count = 0,cnt = 0;
  cin >> n;      //街の数を入力
  vector<long long int> enemy,brave;
  while(cnt < n+1 and cin >> a){  //敵の数を入力
    enemy.push_back(a);
    cnt++;
  }
  while(cin >> b){    //勇者の数を入力
    brave.push_back(b);
  }

  for(int i = 0; i < n; i++){       //街の数まで繰り返す
    if(enemy[i] > 0 and brave[i] > 0){   //同じ町に関して敵と
      if(enemy[i] > brave[i]){           //勇者の数を比較して処理
        count += brave[i];
        brave[i] = 0;
      }else{
        count += enemy[i];
        brave[i] -= enemy[i];
      }
    }
    if(enemy[i+1] > 0 and brave[i] > 0){
      if(enemy[i+1] > brave[i]){
        count += brave[i];
        enemy[i+1] -= brave[i];
      }else{
        count += enemy[i+1];
        enemy[i+1] = 0;
      }
    }
  }
  cout << count << "\n";
  return 0;
}


Measured memory_bytes: 2548
n  = int(input())
X = list(map(int, input().split()))
X_sort = sorted(X)

mid1 = X_sort[n//2 - 1]
mid2 = X_sort[n//2]

for x in X:
    if x <= mid1:
        print(mid2)
    else:
        print(mid1)


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


int main() {
	int A,B,a;
    a=0;
	cin>>A;
	vector<int> K(A);
	for(int i=0;i<A-1;i++){
		cin>>B;
		(K.at(B-1))++;
        
	}
	for(int i=0;i<A;i++){
		cout<<K.at(i)<<endl;
	}
		

}


Measured memory_bytes: 4052
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
typedef long long int ll;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T>
bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false;}
template<typename T>
bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false;}
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, a, b;
    cin >> n >> a >> b;
    vector<int> ans(n);
    iota(ans.begin(), ans.end(), 1);
    if ((n + b - 1) / b <= a && a <= n - b + 1) {
        int res = n;
        int pos = 0;
        while (res > a) {
            int diff = min(b - 1, res - a) + 1;
            reverse(ans.begin() + pos, ans.begin() + pos + diff);
            res -= (diff - 1);
            pos += diff;
        }
        REP(i, 0, ans.size()) {
            cout << ans[i] << " \n"[i + 1 == ans.size()];
        }

    } else {
        cout << -1 << endl;
    }

    return 0;
}


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

int main()
{
    int N, T, i;
    cin >> N >> T;
    vector<int> t(N);
    for (i = 0; i < N; ++i)
    {
        cin >> t[i];
    }
    ll ans = 0;
    for (i = 0; i < N - 1; ++i)
    {
        if (T < t[i + 1] - t[i])
        {
            ans += T;
        }
        else
        {
            ans += t[i + 1] - t[i];
        }
    }
    ans += T;
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1024
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/rope>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
//using namespace __gnu_pbds;
//using namespace __gnu_cxx;


using ll = long long;

//#define int ll

using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;



const int N = 2e5 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 1e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 6e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);


//template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
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; }


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

int s, w;
main() {
  file("threesum");
  ios;
  cin >> s >> w;
  if (w >= s) cout << "unsafe";
  else cout << "safe";
  return 0;
}
/**

*/


Measured memory_bytes: 3668
#include <stdio.h>
#include <string.h>
int main()
{
    char str[10];
    scanf("%s", str);
    if(strcmp(str, "Sunny")==0)
        printf("Cloudy\n");
    else if (strcmp(str, "Cloudy")==0)
        printf("Rainy\n");
    else
        printf("Sunny\n");
    return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;

#define st first
#define nd second

const int MAXN = 1e6 + 5, inf = 1e9, mod = 1e9 + 7;
const ll INF = 1e18, MOD = 1e15 + 37;
const ld PI = acos(-1);

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout << setprecision(13) << fixed;

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

    int n;
    cin >> n;


    vector<int> cnt(MAXN);
    int gcd_all = 0;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        cnt[a]++;
        gcd_all = __gcd(gcd_all, a);
    }

    bool pairwise_coprime = true;

    for (int i = 2; i < MAXN; ++i) {
        int ctr = 0;
        for (int j = i; j < MAXN; j += i) {
            ctr += cnt[j];
        }
        if (ctr > 1) {
            pairwise_coprime = false;
            break;
        }
    }

    cout << (pairwise_coprime ? "pairwise coprime" : gcd_all == 1 ? "setwise coprime" : "not coprime") << "\n";
}


Measured memory_bytes: 7152