akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <unistd.h>

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
//const ll MOD = 1000000007;
const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
// #define mp make_pair
//#define endl '\n'

// 1825


int main() {
  int n, q;
  cin >> n >> q;
  using P = pair<int, pii>;
  vector<P> xst(n);
  rep (i, n) {
    cin >> xst[i].second.first >> xst[i].second.second >> xst[i].first;
  }
  sort(all(xst));

  map<int, int> d2i;
  set<int> d;
  rep (i, q) {
    int temp;
    cin >> temp;
    d.insert(temp);
    d2i[temp] = i;
  }
  
  vi ans(q, -1);
  rep (i, n) {
    int out_d = xst[i].second.first - xst[i].first;
    int safe_d = xst[i].second.second - xst[i].first;

    vi era;
    for (auto itr = d.lower_bound(out_d); itr != d.end(); itr++) {
      if (*itr >= safe_d) break;
      int temp = *itr;
      era.push_back(temp);
    }

    rep (j, era.size()) {
      d.erase(era[j]);
      ans[d2i[era[j]]] = xst[i].first;
    }
  }

  rep (i, q) {
    cout << ans[i] << endl;
  }
}
 


Measured memory_bytes: 24460
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin >> n;
	int m=n,t=0;
	while(m){
		m=m/10;
		t++;
	}
	int sum=0;
	if(t%2==1)
		sum=(n-pow(10,t-1)+1);
	if(t==6)
		sum+=90909;
	else if(t==5 || t==4)
		sum+=909;
	else if(t==2 || t==3)
		sum+=9;
	cout << sum << endl;
	return 0;
 } 

Measured memory_bytes: 384
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>


int main(void){
    long n,i,sum=0;
    scanf("%ld",&n);
    long a[n+1],b[n];
    for(i=0;i<n+1;i++){
        scanf("%ld",&a[i]);
    }
    for(i=0;i<n;i++){
        scanf("%ld",&b[i]);
    }
    for(i=0;i<n;i++){
        sum += a[i]>=b[i]?b[i]:(a[i]+a[i+1]>b[i]?b[i]:a[i]+a[i+1]);
        a[i+1] = a[i]>=b[i]?a[i+1]:(a[i]+a[i+1]>b[i]?a[i]+a[i+1]-b[i]:0);
    }
    printf("%ld\n",sum);
    return 0;
}


Measured memory_bytes: 1664
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner as = new Scanner(System.in);
		int n = as.nextInt();
		int l = n;
		int[] a;
		int b = 0;
		int c = (int)Math.pow(2, n);
		a = new int[c];
		for(int i=0;i<c;i++){
			a[i]  = as.nextInt();
		}
		for(int s=0;s<n;s++){
			for(int i=0;i<(int)(Math.pow(2, l));i+=2){
				if(a[i]<a[i+1]){
					a[i+1]-=a[i];
					a[b]=a[i+1];
					b+=1;
				}else if(a[i]>a[i+1]){
					a[i]-=a[i+1];
					a[b]=a[i];
					b+=1;
				}else{
					a[b]=a[i];
					b+=1;
				}
			}
			l-=1;
			b = 0;
		}
		System.out.println(a[0]);
	}
}

Measured memory_bytes: 78124
#include<bits/stdc++.h>
using namespace std;
int main(void) {
    std::ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int a, b;
    while(cin >> a >> b) {
        cout << (int)((a + b) / 2.0 + 0.5) << endl;
    }
}


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

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

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

    sort(A.begin(), A.end());

    int ans = 1;
    int bef = A[0];
    for(int i = 1; i < n; i++){
        if(bef < A[i]){
            ans++;
            bef = A[i];
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cstring>

using namespace std;

int main(){

  long long x;
  cin >> x;
  long long ansx,ansy;

  for(long long i = -1000; i <= 1000; i++){
    for(long long j = -1000; j <= 1000; j++){
      if ((i*i*i*i*i - j*j*j*j*j) == x) {
        ansx = i;
        ansy = j;
      }
    }
  }

  cout << ansx << " " << ansy << endl;

  return 0;
}

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

#define IOS                               \
	ios_base::sync_with_stdio(false); \
	cin.tie(0);                       \
	cout.tie(0);
#define int long long int
#define endl "\n"
#define sz(a) (int)((a).size())
#define all(a) a.begin(), a.end()

const int N = 500009;
const int mod = 1000000007;

int ans = LLONG_MAX;

void pre()
{
}

int32_t main()
{
	IOS;
	pre();
	int n;
	cin >> n;
	for (int i = 1; (i * i) <= n; i++)
	{
		if (n % i == 0)
		{
			ans = min(ans, i - 1 + (n / i) - 1);
		}
	}
	cout << ans << endl;
}

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

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    string s, t;
    cin >> s >> t;
    size_t n = s.length(), m = t.length();
    vector<vector<int>> dp(n+1, vector<int>(m+1, 0));
    vector<vector<Pii>> prev(n+1, vector<Pii>(m+1, {0, 0}));

    for(int i=1;i<=n;++i) {
        for(int j=1;j<=m;++j) {
            if(s[i-1] == t[j-1]) {
                dp[i][j] = dp[i-1][j-1] + 1;
                prev[i][j] = {i-1, j-1};
            }

            if(dp[i][j] < dp[i-1][j]) {
                dp[i][j] = dp[i-1][j];
                prev[i][j] = {i-1, j};
            }

            if(dp[i][j] < dp[i][j-1]) {
                dp[i][j] = dp[i][j-1];
                prev[i][j] = {i, j-1};
            }
        }
    }

    string ans = "";
    {
        int i = n, j = m, pi, pj;;
        while(i > 0 && j > 0) {
            tie(pi, pj) = prev[i][j];
            if(pi == i-1 && pj == j-1 && s[i-1] == t[j-1]) {
                ans += s[i-1];
            }
            i = pi;
            j = pj;
        }
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;

}


Measured memory_bytes: 106112
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

void WF(int n,vector<vector<LL>> &d) {
  for (int k = 0; k < n; k++){       // 経由する頂点
    for (int i = 0; i < n; i++) {    // 始点
      for (int j = 0; j < n; j++) {  // 終点
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
}

int main(){
    int N,M;cin >> N >> M;
    vector<int> a(M);
    vector<int> b(M);
    vector<int> c(M);

    vector<vector<LL>> G(N,vector<LL>(N,1 << 30));

    rep(i,M){
        cin >> a[i] >> b[i] >> c[i];
        a[i]--;b[i]--;
        G[a[i]][b[i]] = c[i];
        G[b[i]][a[i]] = c[i];
    }

    WF(N,G);
    int ans = 0;
    rep(i,M){
        if(G[a[i]][b[i]] < c[i])ans++;
    }
    cout << ans << endl;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  string s;
  cin >> s;
  int n = s.size();
  s = '0' + s;
  if (s[1] != '1')
    return cout << "-1\n", 0;
  for (int i = 0; i <= (n - 1) / 2; ++i)
    if (s[i] != s[n - i])
      return cout << "-1\n", 0;
  vector<int> v;
  for (int i = 1; i <= n / 2; ++i)
    if (s[i] == '1') v.push_back(i);
  int tot = (int)v.size();
  for (int i = 0; i < (int)v.size() - 1; ++i) {
    cout << i + 1 << ' ' << i + 2 << '\n';
    for (int j = 0; j < v[i + 1] - v[i] - 1; ++j)
      cout << ++tot << ' ' << i + 2 << '\n';
  }
  cout << (int)v.size() << ' ' << n << '\n';
  for (int i = tot + 1; i < n; ++i)
    cout << i << ' ' << n << '\n';
  return 0;
}


Measured memory_bytes: 1900
#include <stdio.h>
 
int count=0;
int stack[100];
 
void push(int x){
  count++;
  stack[count]=x;
}

int pop(){
  count--;
  return stack[count+1];
}
 
int main(){
  int x;
  char s[100];
  int a,b;
  
  while(scanf("%s",s) != EOF ){
    if(s[0]=='+'){
      a=pop();
      b=pop();
      push(a+b);
    } 
    else if(s[0]=='-'){
      a=pop();
      b=pop();
      push(b-a);
    } 
    else if(s[0]=='*'){
      a=pop();
      b=pop();
      push(a*b);
    } else {
      x = atoi(s);
      push(x);
    }
  }
  printf("%d\n",stack[count]);
  return 0;
}

Measured memory_bytes: 1828
#include<bits/stdc++.h>
using namespace std;
int H,W;
int si,sj,sd;
int ti,tj;
char t[60][60];
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};

void init(){
  for(int i=0;i<60;i++){
    for(int j=0;j<60;j++){
      t[i][j]='#';
    }
  }
}

int solve(){
  bool flg[60][60]={};
  bool visited[60][60][4]={};

  int y=si,x=sj,dir=sd;
  
  while(1){
    if(visited[y][x][dir])break;
    flg[y][x]=true;
    visited[y][x][dir]=true;
    
    if(y==ti&&x==tj){
      int res=0;
      for(int i=1;i<=H;i++)
        for(int j=1;j<=W;j++)
          res+=flg[i][j];
      return res;
    }
    
    int rdir=(dir+1)%4;
    int ry=y+dy[rdir];
    int rx=x+dx[rdir];
    
    if(t[ry][rx]=='#'){
      if(t[y+dy[dir]][x+dx[dir]]=='#'){
        dir=(dir+3)%4;
      }else{
        x+=dx[dir];y+=dy[dir];
      }
    }else{
      dir=(dir+1)%4;
      x+=dx[dir];y+=dy[dir];
    }
    
  }
  
  return -1;
}

int main(){
  while(cin>>H>>W){
    init();
    for(int i=1;i<=H;i++){
      for(int j=1;j<=W;j++){
        cin>>t[i][j];
        if(t[i][j]=='^'){
          si=i,sj=j,sd=0;
        }
        if(t[i][j]=='>'){
          si=i,sj=j,sd=1;
        }
        if(t[i][j]=='v'){
          si=i,sj=j,sd=2;
        }
        if(t[i][j]=='<'){
          si=i,sj=j,sd=3;
        }
        if(t[i][j]=='G'){
          ti=i,tj=j;
        }
        if(t[i][j]!='#')t[i][j]='.';
      }
    }
    cout<<solve()<<endl;
  }
  return 0;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
using namespace std;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

int n;double p[3000],dp[3000][3000];
signed main() {
  cin>>n;rep(i,n)cin>>p[i];
  rep(i,n+1)rep(j,n+1)dp[i][j] = 0;
  dp[0][0] = 1;
  repd(i,1,n+1){
    rep(j,i+1){
      if(j == 0)dp[i][j] = dp[i-1][j]*(1-p[i-1]);
      else dp[i][j] = dp[i-1][j-1]*p[i-1] + dp[i-1][j]*(1.0-p[i-1]);
    }
  }
  double ans = 0;
  repd(i,n/2+1,n+1)ans += dp[n][i];
  cout << setprecision(10) << ans << endl;
}

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

#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
#define INF 2000000000
typedef long long ll;
bool compare(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}
// 入力



int main() {
    
    ll H,W,K;
    
    cin >>H>>W>>K;

    vector<vector<char>> c(H,vector<char>(W));
    ll olg=0;
    ll ans = 0;
    rep(i,H){
        rep(j,W){
            cin>>c[i][j];
            if(c[i][j] == '#'){
                olg++;
            }
        }
    }

    ll n = H+W;
    ll now = olg;
    vector<vector<char>> c2(H,vector<char>(W));
    c2 = c;
    rep(i,(1<<n)){
        c = c2;
        vector<ll> S;
        rep(j,n){
            if(i&(1<<j)){
                S.pb(j);
            }
        }
        now = olg; 
        rep(j,S.size()){
            if(S[j]<H){
                rep(k,W){
                    if(c[S[j]][k] == '#'){
                        now--;
                        c[S[j]][k] = 'r';
                    }
                }
            }else{
                rep(k,H){
                    if(c[k][S[j]-H] == '#'){
                        now--;
                        c[k][S[j]-H] = 'r';
                    }
                }
            }
        }
   
        if(now == K){
            ans++;
        }
       
        
    }
  
    

    cout<<ans<<endl;
    
    
    return 0;
    

}

Measured memory_bytes: 3616
// template version 1.6
// {{{ define basic macro
using namespace std;
#include <iostream>
#include <bits/stdc++.h>
// varibable settings
#define int long long
#define INF 1000000000000000000LL
#define INF 2147483647
#define MOD 1000000007LL
#define MOD 998244353LL
#define infile "../test/sample-1.in"

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ten(n) ((int)1e##n)
template<class T, size_t N> size_t sza(const T (&array)[N]) { return N; }
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }
template<class T=int> T in() {T x; cin>>x; return (x);}
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

// dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
#define fi first
#define se second

// }}}

int solve(){
  string s;cin>>s;
  int n = sz(s);
  string res = "";
  rep(i, n){
    if (s[i]=='A') res += string(1, 'T');
    if (s[i]=='T') res += string(1, 'A');
    if (s[i]=='G') res += string(1, 'C');
    if (s[i]=='C') res += string(1, 'G');
  }
  cout << res << endl;

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


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

int main()
{
int A;
int B;

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

	cin >> A;
	cin >> B;

	if( A == B )
		cout << A * 2 << endl;
	else if( A > B )
		cout << A * 2 - 1 << endl;
	else
		cout << B * 2 - 1 << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define sqr(x) ((x)*(x))
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define ld long double
#define vi vector<int>
#define all(a) a.begin(),a.end()
#define HEAP(...) priority_queue<__VA_ARGS__ >
#define heap(...) priority_queue<__VA_ARGS__,vector<__VA_ARGS__ >,greater<__VA_ARGS__ > > 
#define pii pair<int,int> 
#define pb push_back
#define mp make_pair
#define debuge cerr<<"isok"<<endl
#define debug(x) cerr<<#x<<"="<<x<<endl
#define dprintf(...) fprintf(stderr,__VA_ARGS__)
#define SS second
#define FF first
#define ls (k<<1)
#define rs (k<<1|1)
#define clr(a,x) memset(a,x,sizeof(a))
#define cpy(a,x) memcpy(a,x,sizeof(a))
#define file(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout)
#define SZ(x) ((int)x.size())
using namespace std;
template<class T> inline void gmin(T &x,const T &y){x=x>y?y:x;}
template<class T> inline void gmax(T &x,const T &y){x=x<y?y:x;}
template<class T> inline bool Gmin(T &x,const T &y){return x>y?x=y,1:0;}
template<class T> inline bool Gmax(T &x,const T &y){return x<y?x=y,1:0;}
const int BufferSize=1<<16;
char buffer[BufferSize],*Bufferhead,*Buffertail;
bool Terminal;
inline char Getchar(){
	if(Bufferhead==Buffertail){
		int l=fread(buffer,1,BufferSize,stdin);
		if(!l){Terminal=1;return 0;}
		Buffertail=(Bufferhead=buffer)+l;
	}
	return *Bufferhead++;
}
template<class T>inline bool read(T &x){
	x=0;char c=Getchar(),rev=0;
	while(c<'0'||c>'9'){rev|=c=='-';c=Getchar();if(Terminal)return 0;}
	while(c>='0'&&c<='9') x=x*10+c-'0',c=Getchar();
	if(c=='.'){
		c=Getchar();double t=0.1;
		while(c>='0'&&c<='9') x=x+(c-'0')*t,c=Getchar(),t=t/10;
	}
	x=rev?-x:x;
	return 1;
}
template<class T1,class T2> inline bool read(T1 &x,T2 &y){return read(x)&read(y);}
template<class T1,class T2,class T3> inline bool read(T1 &x,T2 &y,T3 &z){return read(x)&read(y)&read(z);}
template<class T1,class T2,class T3,class T4> inline bool read(T1 &x,T2 &y,T3 &z,T4 &w){return read(x)&read(y)&read(z)&read(w);}
inline bool reads(char *x){
	char c=Getchar();
	while(c<33||c>126){c=Getchar();if(Terminal)return 0;}
	while(c>=33&&c<=126) (*x++)=c,c=Getchar();
	*x=0;return 1;
}
template<class T>inline void print(T x,const char c='\n'){
	if(!x){putchar('0');putchar(c);return;}
	if(x<0) putchar('-'),x=-x;
	int m=0,a[20];
	while(x) a[m++]=x%10,x/=10;
	while(m--) putchar(a[m]+'0');
	putchar(c);
}
//--------------------------------head---------------------------------------------

const int inf=0x3f3f3f3f;
const int N=200005,M=100005,mod=1e9+7;
template<class T,class S> inline void ch(T &x,const S y){x=(x+y)%mod;}
inline int exp(int x,int y,const int mod=::mod){
	int ans=1;
	while(y){
		if(y&1) ans=(ll)ans*x%mod;
		x=(ll)x*x%mod;y>>=1;
	}return ans;
}

int n,k;

inline int calc(int x,int k){
	if(x%k==0) return x/k;
	if(x<k) return 0;
	int p=x/k+1,to=(p-1)*k;
	x-=(x-to+p-1)/p*p;
	return calc(x,k);
}

int main(){
#ifdef rqgao2014
	assert(freopen("input.txt","r",stdin));
#endif
	scanf("%d",&n);
	int ans=0;
	for(int i=1;i<=n;i++){
		int x,k;scanf("%d%d",&x,&k);
		ans^=calc(x,k);
	}
	if(ans){puts("Takahashi");return 0;}
	puts("Aoki");
	return 0;
}

Measured memory_bytes: 256
/*-- ILSH  --*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back 
#define pop pop_back
#define mp make_pair
#define vii vector < int >
#define vll vector < ll > 
#define dt cout<<"HERE\n";
#define pii pair < int , int >
#define pll pair < ll , ll >
#define vpi vector < pll >
#define vpl vector < pll >
#define fi first
#define se second 
#define sz size 
#define len length 

const ll inf=1e18+1e17;
//const ll mod =1e9+7;
const ll mod = 998244353;

ll modInverse(ll a,ll m){ll m0=m;ll y=0,x=1;if(m == 1)return 0;while(a> 1){ll q=a/m;ll t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0)x+=m0;return x;}  
ll powm(ll a,ll b){a=a%mod;ll res=1;while(b){if(b&1)res=(res*a)%mod;a=(a*a)%mod;b>>=1;}return (res%mod);}


const ll N =5e5+5;



void solve(){
	int n;
	cin>>n;
	int arr[26][n];
	memset( arr,0,sizeof ( arr));
	for ( int i=0;i<n;i++){
		string s;
		cin>>s;
		for ( int j=0;j<s.len();j++){
			arr[s[j]-'a'][i]++;
		}
	}
	int brr[26];
	for ( int j=0;j<26;j++){
		int mi=1e9;
		for ( int i=0;i<n;i++)
			mi=min( arr[j][i],mi);
		brr[j]=mi;
	}
	for ( int i=0;i<26;i++){
		while ( brr[i]--)
			cout<<(char)(i+'a');
	}
cout<<'\n';

}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie( NULL);
	cout.tie(NULL);
	// #ifndef
	// 	freopen( "INPUT.txt", "r" , stdin);
	// 	freopen( "OUTPUT.txt","w", stdout);
	// #endif

	int t=1;

	//cin>>t;

	for ( int i=1;i<=t;i++){
   // 	cout<<"Case #"<<i<<": ";
    	solve();
 	}
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
#k,a,b = [int(i) for i in input().split()]

l = int(input())
a = [int(input()) for i in [0]*l]
asum=[0]*(l+1)
for i in range(1,l+1):
    asum[i] = asum[i-1]+a[i-1]    

reven=[0]*(l+1)
leven=[0]*(l+1)
rodd=[0]*(l+1)
lodd=[0]*(l+1)

for i in range(1,l+1):
    if a[i-1] != 0:
        leven[i]=leven[i-1] + a[i-1]%2
    else:
        leven[i]=min(2+leven[i-1],asum[i])

for i in range(l-1,-1,-1):
    if a[i] != 0:
        reven[i]=reven[i+1] + a[i]%2
    else:
        reven[i]=min(2+reven[i+1],asum[l]-asum[i])

for i in range(1,l+1):
    lodd[i]=min(leven[i], lodd[i-1]+(a[i-1]+1)%2, asum[i])

for i in range(l-1,-1,-1):
    rodd[i]=min(reven[i], rodd[i+1]+(a[i]+1)%2, asum[l]-asum[i])

#print(asum)
#print(reven)
#print(leven)
#print(rodd)
#print(lodd)

ans = 5*(l+2)
for i in range(l+1):
    ans = min(ans, leven[i]+rodd[i], lodd[i]+reven[i])

print(ans)




    





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

ll power(ll a,ll n,ll mod){
    ll ans=1;
    for(int i=1;i<=n;i++){
        ans=(ans*a)%mod;
    }
    return ans;
}

int main() {
	ll n,mod=1e9+7;
	cin>>n;
	ll a1,a2,a3;
	a2=power(10,n,mod);
	a1=power(8,n,mod);
	a3=power(9,n,mod);
	ll ans=((a2+a1-2*a3)%mod+mod)%mod;
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3632
module Main where
import Data.List
import qualified Data.Vector as V
 
main :: IO()
main = do    
  n <- (read <$> getLine) :: IO Int
  a <- (fmap read <$> words <$> getLine) :: IO [Int]
  let l = V.fromList $ scanl' gcd 0 a
  let r = V.fromList $ reverse $ scanl' gcd 0 (reverse a)
 
  --print $ foldl max 0 $
  --  fmap (\i-> gcd (l V.! i) (r V.! (i+1))) [0..(n-1)]
        
  --print $ maximum $
  --  zipWith gcd l r
 
  print $ foldl' max 0 $
     [ gcd (l V.! i) (r V.! (i + 1)) | i <- [0 .. ((fromIntegral n) - 1)] ]


Measured memory_bytes: 84348
#include <algorithm>
#include <cstdint>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using namespace std;

using lint=int64_t;
using uint=uint32_t;
using ulint=uint64_t;

template<class T>
using vector2d=vector<vector<T>>;

template<class T>
bool UpdateMax(T &a, const T &b){
  if(a<b){
    a=b;
    return true;
  }else{
    return false;
  }
}

template<class T>
bool UpdateMin(T &a, const T &b){
  if(a>b){
    a=b;
    return true;
  }else{
    return false;
  }
}

template <class T>
void OutVec(const vector<T>& vec){
  for(int i = 0; i < vec.size() - 1; ++i){
    cout<<vec[i]<<" ";
  }
  cout<<vec.back()<<endl;
}

template <class T>
void OutVec2d(const vector2d<T>& vec){
  for(auto v:vec){
    OutVec(v);
  }
}

int main(){
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  int n,m;
  cin>>n>>m;
  vector<int> a(n);
  int sigma=0;
  for(int i=0;i<n;i++){
    cin>>a[i];
    sigma+=a[i];
  }

  int count=0;
  int boarder=(sigma)/(4*m);
  if(sigma%(4*m)!=0){
    boarder++;
  }
  for(int i=0;i<n;i++){
    if(a[i]>=boarder){
      count++;
    }
  }
  if(count>=m){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }

  return 0;
}




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

int main(){
    ll n,z,w;
    cin >> n >> z >> w;
    ll a;
    for(int i = 0;i < n-1;i ++){
        ll a0;
        cin >> a0;
        a = a0;
    }
    ll b;cin >> b;
    if(n==1) cout << abs(b-w) << endl;
    else cout << max(abs(b-w),abs(b-a)) << endl;
    return 0;
}

Measured memory_bytes: 256
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;

procedure Solve is
   A : Integer;
   B : Integer;
   C : Integer;
begin
   Get (A);
   Get (B);
   Get (C);
   if C < A then
      Put_Line ("No");
   elsif C > B then
      Put_Line ("No");
   else
      Put_Line ("Yes");
   end if;
end Solve;

Measured memory_bytes: 3680
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long int LL;
typedef vector<int> ivec;
typedef vector<string> svec;

const int MOD=1000000007;

LL beki(LL a,LL b)
{
	if(b==0)return 1;
	
	LL x=beki(a,b/2);
	if(b%2==0)return (x*x)%MOD;
	else return (((a*x)%MOD)*x)%MOD;
	
}

LL w[100010];
int main(){
	LL n,k;
	LL ans=0;
	cin>>n>>k;
	
	for(LL i=k;i>=1;i--)
	{
		LL num=beki(k/i,n);
		for(LL j=i*2;j<=k;j+=i)
		{
			num=(num-w[j]+MOD)%MOD;
		}
		w[i]=num;
		ans=(ans+i*num)%MOD;
		//cout<<num<<"\n";
	}
	cout<<ans<<"\n";
	return 0;
}

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

int main(void) {
    int n, k;
    cin >> n >> k;

    int mx = (n - 1) * (n - 2) / 2;
    if (k > mx) {
        cout << -1 << endl;
        return 0;
    }

    vector<pii> star;
    for (int i = 2; i <= n; i++) {
        star.push_back({1, i});
    }
    int ii = 2, jj = 3;
    for (int ct = 1; ct <= mx - k; ct++) {
        star.push_back({ii, jj});
        jj++;
        if (jj == n + 1) {
            ii++;
            jj = ii + 1;
        }
    }

    cout << star.size() << endl;
    for (auto s : star) {
        cout << s.first << " " << s.second << endl;
    }
    return 0;
}

Measured memory_bytes: 384
// B - Addition and Multiplication

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

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

	int ans = 1;

	for (int i=0; i<N; i++) {
		if (ans * 2 < ans + K) ans *= 2;
		else ans += K;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
using namespace std;
int main(){
    //Seiranchan!
    string a,b,c;
    cin >> a >> b;

    c = a+b;
    
    int A = stoi(c);

    for(int i=0;i<(A/2);i++){
        if(A==i*i){
           cout << "Yes" << endl; 
           return 0;
        }
    }
    cout << "No" <<endl;
}


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

int main(void){
    long X, K, D;
    
    cin >> X >> K >> D;
    
    long now_place = X;
    long times = now_place / D;
    if(times < 0){
        times *= -1;
    }
    
    if(times > K){
        times = K;
    }
    
    if(now_place > 0){
        now_place -= D * times;
        K -= times;
    }else{
        now_place += D * times;
        K -= times;
    }
    
    if(K % 2 == 0){
        if(now_place > 0){
                cout << now_place << endl;
            }else{
                cout << now_place * -1 << endl;
            }
    }else{
        if(now_place < 0){
            now_place += D;
            if(now_place > 0){
                cout << now_place << endl;
            }else{
                cout << now_place * -1 << endl;
            }
        }else{
            
            now_place -= D;
            if(now_place > 0){
                cout << now_place << endl;
            }else{
                cout << now_place * -1 << endl;
            }
        }
    }
    
}


Measured memory_bytes: 3172
#include<iostream>
using namespace std;
int main()
{
int n;
long long mon[110][11];
bool opened[110][10];
int ns;
int i,j,k,f;
long long hif=-(1<<30),rnf=0;
bool ft=false;
cin>>n;
for(i=0;i<n;i++)
{
for(j=0;j<10;j++)
{
cin>>opened[i][j];
}
}
for(i=0;i<n;i++)
{
for(j=0;j<11;j++)
{
cin>>mon[i][j];
}
}
for(ns=1;ns<(1<<10);ns++){
rnf=0;
for(i=0;i<n;i++)
{
f=0;
for(j=0;j<10;j++)
{
if(opened[i][j]&&((ns>>j)&1))
{
f++;
}
}
rnf+=mon[i][f];
}
if((rnf>hif)&&ft)
{
hif=rnf;
}
ft=true;
}
cout<<hif;
return 0;
}


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

int n;

int solve(int a[],int b[], int c[])
{
	int dp[n][3];
	dp[0][0]=a[0];
	dp[0][1]=b[0];
	dp[0][2]=c[0];
	for(int i=1;i<n;i++)
	{
		dp[i][0] = a[i] + max(dp[i-1][1],dp[i-1][2]);
		dp[i][1] = b[i] + max(dp[i-1][0],dp[i-1][2]);
		dp[i][2] = c[i] + max(dp[i-1][1],dp[i-1][0]);
	}
	return max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));	
}
int main()
{
	cin>>n;
	int a[n],b[n],c[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i]>>b[i]>>c[i];
	}
	cout<<solve(a,b,c)<<endl;
	return 0;
}

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

class Graph {
  private:
    int n;
    vector<vector<pair<int, int>>> ad;

  public:
    Graph(int n) :
        n(n), ad(n + 1) { }

    void addEdge(int x, int y, int z) {
        static map<pair<int, int>, int> comp;
        if (!comp[{x, z}]) { comp[{x, z}] = ++n; ad.emplace_back(); }
        if (!comp[{y, z}]) { comp[{y, z}] = ++n; ad.emplace_back(); }

        ad[comp[{x, z}]].emplace_back(comp[{y, z}], 0);
        ad[comp[{y, z}]].emplace_back(comp[{x, z}], 0);

        ad[x].emplace_back(comp[{x, z}], 0);
        ad[y].emplace_back(comp[{y, z}], 0);

        ad[comp[{x, z}]].emplace_back(x, 1);
        ad[comp[{y, z}]].emplace_back(y, 1);
    }

    vector<int> dijkstra(int src) {
        vector<int> dp(n + 1, 1e9);
        dp[src] = 0;

        priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;
        pq.emplace(0, src);

        vector<bool> vis(n + 1);
        while (!pq.empty()) {
            int node = pq.top().second;
            pq.pop();

            if (vis[node])
                continue;
            vis[node] = true;

            for (auto arc : ad[node])
                if (dp[node] + arc.second < dp[arc.first]) {
                    dp[arc.first] = dp[node] + arc.second;
                    pq.emplace(dp[arc.first], arc.first);
                }
        }
        return dp;
    }
};

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

    Graph graph(n);
    for (int i = 0; i < m; i++) {
        int x, y, z; cin >> x >> y >> z;
        graph.addEdge(x, y, z);
    }

    int sol = graph.dijkstra(1)[n];
    cout << (sol == 1e9 ? -1 : sol) << '\n';
    return 0;
}


Measured memory_bytes: 60648
using System;
using CompLib.Util;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        int x = sc.NextInt();
        if (x >= 30)
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            if (_index >= _line.Length)
            {
                string s;
                do
                {
                    s = Console.ReadLine();
                } while (s.Length == 0);

                _line = s.Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public string ReadLine()
        {
            _index = _line.Length;
            return Console.ReadLine();
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            string s = Console.ReadLine();
            _line = s.Length == 0 ? new string[0] : s.Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 27512
def main():
    n = int(input())
    s = [input() for i in range(n)]
    res = {}
    for i in s:
        if i not in res:
            res[i] = 1
        res[i] += 1
    keys = max(res.values())
    max_keys = sorted([key for key in res if res[key] == keys])
    for k in max_keys:
        print(k)

if __name__ == "__main__":
    main()

Measured memory_bytes: 35216
#include<stdio.h>
main(){
int s[9000],n,m,t,f,i;
while(scanf("%d%d",&n,&m),i=t=f=1,n){
while(i<=n+m){
if(scanf("%d",&s[i]),i>n)if(t+=s[t+=s[i]],t>=n&f==1)
	printf("%d\n",i-n,f=0);
	i++;
}
}
}

Measured memory_bytes: 0
import java.util.*;

public class Main {
public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
		
		int N = keyboard.nextInt();
		int M = keyboard.nextInt();
		
		int[]den = new int[M]; 
		for(int i = 0; i<M; i++) {
			int K = keyboard.nextInt();
			for(int j =0; j<K; j++) {
				int S = keyboard.nextInt();
				den[i] += 1 << (S - 1);
			}
		}
		
		int[]amari = new int[M]; 
		for(int k = 0; k<M; k++) {
			amari[k] = keyboard.nextInt();
		}
		
		int ans = 0;
		for(int l = 0; l<(1<<N); l++) {
			boolean flag = true;
			for(int m = 0; m<M; m++) {
				if(amari[m] != Integer.bitCount(den[m]&l)%2) {
					flag = false;
					break;
				}
			}
			if(flag) {
				ans++;
			}
		}
		
		System.out.println(ans);
		keyboard.close();	
	}
}


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

int main(){
  string O,E;
  cin >> O >> E;
  for(int i = 0 ;i < E.size(); i++){
    cout << O.at(i) << E.at(i);
  } 
  if(O.size() > E.size()) cout << O.at(O.size() -1);
  return 0;
}


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

string solve() {
  int N;
  cin >> N;
  vector<vector<int>> G(N);
  for(auto i=0; i<N; ++i) {
    int p;
    cin >> p;
    G[p-1].emplace_back(i);
  }

  vector<int> A;

  function<int(int, int)> dfs = [&](auto u, auto d) {
    if(A[u]!=-1) return A[u];
    A[u] = N;
    set<int> S;
    for(auto v: G[u]) S.emplace(dfs(v, d));
    for(auto i=0; i<N; ++i) if(!S.count(i)) if(!S.count(N) || d--==0) return A[u] = i;
  };

  auto ok = [&]() {
    for(auto u=0; u<N; ++u) {
      set<int> S;
      for(auto v: G[u]) {
        if(A[u]==A[v]) return false;
        S.emplace(A[v]);
      }
      for(auto i=0; i<A[u]; ++i) if(!S.count(i)) return false;
    }
    return true;
  };

  for(auto d: {0, 1}) {
    A.assign(N, -1);
    for(auto v=0; v<N; ++v) dfs(v, d);
    if(ok()) return "POSSIBLE";
  }
  return "IMPOSSIBLE";
}

int main() {
  cout << solve() << endl;
}

Measured memory_bytes: 32256
iN,iK = [int(x) for x in input().split()]
aD = [int(x) for x in input().split()]
aUnList = sorted([x for x in range(10) if  x not in aD])
aUnList.sort()
sN = str(iN)
iF = int(sN[0])

def fCheckDigit(sTarget,iL,iPoint,aUnList,aRet,bRev):
    iF = int(sTarget[iPoint])
    aUpper = [x for x in aUnList if x >= iF]
    aUpper.sort()
    if bRev: #逆行
        #もうひとつ上があるかどうか
        if len(aUpper) == 1 : #==のとき。もうひとつ上はない
            if iPoint == 0:
                if aUnList[0] == 0:
                    return [str(aUnList[1])] + ["0"] * iL
                else:
                    return [str(aUnList[0])] * (iL + 1)
            else:
                return fCheckDigit(sTarget,iL,iPoint -1 , aUnList,aRet,True)
        else: #上の桁がある
            return aRet[0:iPoint]+[str(aUpper[1])]+[str(aUnList[0])]*(iL-1-iPoint)
    else: #順向
        if aUpper == []: #大きい数字がないときは逆行して調べる
            if iPoint == 0:
                if aUnList[0] == 0:
                    return [str(aUnList[1])] + ["0"] * iL
                else:
                    return [str(aUnList[0])]*(iL+1)
            else:
                return fCheckDigit(sTarget,iL,iPoint-1,aUnList,aRet,True) #逆行する
        else:
            if aUpper[0] != iF:
                return aRet[0:iPoint]+[str(aUpper[0])] + [str(aUnList[0])]*(iL-1- iPoint)
            else:
                aRet.append(str(iF))
                if iPoint  < iL -1 :
                    return fCheckDigit(sTarget,iL,iPoint+1,aUnList,aRet,False) #順行する
                else:
                    return aRet

print( ''.join(fCheckDigit(sN,len(sN),0,aUnList,[],False)))


Measured memory_bytes: 3188
# 逆元
# a^n mod を計算する
def modpow(a, n, mod):
    res = 1
    while n > 0:
        if n & 1:
            res = res * a % mod
        a = a * a % mod
        n >>= 1
    return res

# a^{-1} mod を計算する
def modinv(a, mod):
    return modpow(a, mod - 2, mod)


x, y = map(int, input().split())

mod = 10 ** 9 + 7

if (x + y) % 3 == 0 and min(x, y) * 2 >= max(x, y):
    a = (2 * y - x) // 3
    b = (2 * x - y) // 3
    x = 1
    for i in range(2, a + b + 1):
        x = x * i % mod
    for i in range(2, a + 1):
        x = x * modinv(i, mod) % mod
    for i in range(2, b + 1):
        x = x * modinv(i, mod) % mod
    print(x)
else:
    print(0)

Measured memory_bytes: 42876
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#ifdef _DEBUG_
	#define debug(...) printf(__VA_ARGS__)
#else
	#define debug(...) (void)0
#endif
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;

int main() {
	char str[15];
	scanf("%s", str);
	int n = strlen(str);
	ll ans = 0;
	for(int i = 0; i < 1<<(n-1); i++) {
		ll val = 0, tmp = str[0]-'0';
		for(int j = 0; j < n-1; j++) {
			if((i>>j)&1)
				val += tmp, tmp = 0;
			tmp = tmp*10 + (str[j+1]-'0');
		}
		val += tmp;
		ans += val;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 256
a,b,k=map(int, input().split())
turn=0
for i in range(k):
    if turn==0:
        if a%2!=0:
            a-=1
        b+=a//2
        a=a//2
        turn=1
    else:
        if b%2!=0:
            b-=1
        a+=b//2
        b=b//2
        turn=0
print(a,b)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
#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 ALL(v) (v).begin(), (v).end()
#define PUTS(x) cout << (x) << endl;
#define SZ(x) ((int)(x).size())
#define PB push_back
#define MP make_pair
#define F first
#define S second
vector<Int> IntsIn(int n) {
    auto v = vector<Int>(0);
    for (int i = 0; i < n; i++) {
        Int a;
        cin >> a;
        v.push_back(a);
    }
    return v;
}

int main() {
    function<void(int, int, string)> f = [&](int n, int k, string s) {
        //printf("n=%d, k=%d\n", n, k);
        for (int i = 0; i <= k + 1; i++) {
            auto t = s + ((char)('a' + i));
            if (n - 1 > 0) {
                f(n - 1, max(k, i), t);
            } else {
                PUTS(t);
            }
        }
    };
    Int n;
    cin >> n;
    auto s = "a";
    if (n - 1 >= 1) {
        f(n - 1, 0, s);
    } else {
        puts("a");
    }
}

Measured memory_bytes: 1536
// abc111_a
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif
    
    string n;
    cin >> n;
    
    REP(i, n.size()){
        n[i] = n[i] == '1' ? '9' : '1';
    }
    print(n);


    return 0;
}





Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n,k=map(int,input().split())
    r=(n-1)*(n-2)//2-k # star graphに追加する必要のある辺の数
    if(r<0):
        print(-1)
        return

    print(n-1+r)
    # centerを0とした star の辺を出力
    for i in range(2,n+1):
        print(1,i)

    # 残り r を出力
    if(r==0): return
    from itertools import product
    for i,j in product(range(2,n+1),repeat=2):
        if(i>=j): continue # i < j
        print(i,j)
        r-=1
        if(r==0): return
resolve()

Measured memory_bytes: 44528
data Rank = AAA | AA | A | B | C | D | E | NA deriving (Show,Eq,Ord)

main :: IO ()
main = do
  ls <- getContents
  let ls' = map (map read) (map words  (lines ls))
  mapM_ print $ solve ls'

solve :: [[Double]] -> [Rank]
solve [] = []
solve ([x,y]:r) = (max (check1 x) (check2 y)):(solve r)
  where
    check1 :: Double -> Rank
    check1 d
      | d < 35.50 = AAA
      | d < 37.50 = AA
      | d < 40.00 = A
      | d < 43.00 = B
      | d < 50.00 = C
      | d < 55.00 = D
      | d < 70.00 = E
      | otherwise = NA
    check2 :: Double -> Rank
    check2 d
      | d < 71.00 = AAA
      | d < 77.00 = AA
      | d < 83.00 = A
      | d < 89.00 = B
      | d < 105.00 = C
      | d < 116.00 = D
      | d < 148.00 = E
      | otherwise = NA

Measured memory_bytes: 4272
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

typedef long long ll;

using namespace std;

int main(int argc, const char * argv[]) {
  ll a;
  cin >> a;
  cout << a*a*a;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using pairll=pair<ll,ll>;
#define LLINF 1LL<<60
#define ABS(x) ( (x)>0 ? (x) : -(x) )

ll gcd(ll a, ll b) {
	if(a==0||b==0) return 0;
	if(a<b) swap(a,b);
	ll tmp = a%b;
	while(tmp!=0) {
		a = b;
		b = tmp;
		tmp = a%b;
	}
	return b;
}

ll factorial(ll x) {
	ll f=1;
	for(ll i=2; i<x; i++) {
		f*=i;
	}
	return f;
}

ll npr(ll n, ll r) {
	ll result=1;
	for(ll i=r+1; i<=n; i++) result*=i;
	return result;
}

bool IsPrime(ll num) {
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (ll i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

ll GreaterBinarySearch(ll *array, ll key, ll max, ll min) {
	if(array[max]<array[min]) {
		return NULL;
	} else {
		ll mid = max + (min-max)/2;
		if(array[mid]<key) {
			return GreaterBinarySearch(array,key,max,mid-1);
		} if(array[mid]>key) {
			return GreaterBinarySearch(array,key,mid+1,min);
		} else {
			return mid;
		}
	}
}

int main() {
	int n,m; cin>>n>>m;
	int p;
	string str;
	pair<int,int> pena[n]={make_pair(0,0)};
	for(int i=0; i<m; i++) {
		cin>>p>>str;
		if(str=="WA") {
			if(pena[p-1].second==0) pena[p-1].first++;
		}
		else {
			pena[p-1].second=1;
		}
	}

	int sumAC=0,sumWA=0;
	for(int i=0; i<n; i++) {
		sumAC+=pena[i].second;
		if(pena[i].second) sumWA+=pena[i].first;
	}
	cout<<sumAC<<" "<<sumWA<<endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
int main()
{

    LL N;
    cin>>N;
    if(N%2==0)
        cout<<"-1";
    else
    {
        LL num=7;
        LL temp=N;
        bool flag=false;
        for(LL i=1;i<=(LL)(1e7);i++)
        {
            if(num%N==0)
            {
                cout<<i;
                flag=true;
                break;
            }
            num=( (num*10)%N +7 )%N; 
        }
        if(flag==false)
            cout<<-1;
    }
}


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

int ord(int n){
  int a=0;
  for(;;){
    if(n%2!=0){
      break;
    }
    n=n/2;
    a++;
  }
  return a;
}

int main(){
  int N,s=0;
  cin>>N;
  int a[N];
  for(int i=0;i<N;i++){
    cin>>a[i];
    s+=ord(a[i]);
  }
  cout<<s<<endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var H int
	fmt.Scanf("%d\n", &H)

	sum := 0
	cnt := 1
	for H > 1 {
		H /= 2
		cnt *= 2
		sum += cnt
	}

	fmt.Println(sum + 1)
}


Measured memory_bytes: 512
#include <iostream>
#include <cmath>
#include <algorithm>
#include <deque>
#include <vector>
using namespace std;


int main(){
  int n, m, a, b;
  string str;
  cin >> n;
  int fijk[10][n];
  long long p[11][n];
  int wa[10]={0};
  long long eki[10];
  int i, j, k;
  int ans;

  for(i = 0; i < n; i++){
    for(j = 0; j < 10; j++){
      cin >> fijk[j][i];
    }
  }
  for(i = 0; i < n; i++){
    for(j = 0; j < 11; j++){
      cin >> p[j][i];
    }
  }

  const int MAX_COLORS = 10;
	long long result = -1000000000;
  int sum = 0;
  int waa = 0;

	for (int all = 1; all < (1<<MAX_COLORS); all++){
		int num_colors = 0;
    sum = 0;
    for ( i = 0; i < n; i++){
      waa = 0;
  		for (int j = 0; j < MAX_COLORS; j++){

			  if( all & (1<<j) ){
				  waa += fijk[j][i];
        }
			}
      sum += p[waa][i];

    }
    if(result < sum){
      result = sum;
      k = all;
    }
	}



  cout << result << endl;

  // cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <cstring>
#include <deque>

using namespace std;

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

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main()
{
	int n;
	scanf("%d", &n);
	rep(i, n){
		char str[2048];
		scanf("%s", str);
		deque<int> train;
		int pos = 0;
		train.push_front(str[0]);
		reep(i, 1, strlen(str)){
			if(str[i+1] == '>')
				++pos;
			else
				--pos;
			i += 2;
			if(pos < 0){
				train.push_front(str[i]);
				pos = 0;
			}else if(train.size() <= pos){
				train.push_back(str[i]);
			}
		}
		
		rep(i, train.size())
			putchar(train[i]);
		puts("");
	}
	return 0;
}

Measured memory_bytes: 0