akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))
 
using namespace std;
 
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
 
const ll mod=998244353;

struct mint {

  ll x; 

  mint(ll x=0):x((x%mod+mod)%mod){} //コンストラクタを呼んで自動的にmodを取っている。

  mint operator-() const { return mint(-x);}

  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    //メンバ関数にはthisポインタがある。メンバ変数の値を返す。
    return *this;
  }

  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }

  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }

  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }

  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }

  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }

  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1); //a=x/2
    a *= a; //繰り返し二乗法
    if (t&1) a *= *this; //tが奇数のときはxを1回かける
    return a;
  }



  // for prime mod

  mint inv() const {
    return pow(mod-2);
  }

  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }

  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
    
};

vector<ll> f;

mint choose(ll n,ll r){
  mint x=f[n];
  mint y=f[r];
  mint z=f[n-r];
  return x/(y*z);
}

int main(){
    ll n,m,k;
    cin >> n >> m >> k;
    vector<ll> a(n);
    ll aa=1;
    rep(i,n){
        a[i]=aa;
        aa*=(m-1);
        aa%=mod;
    }
    f.resize(n);
    ll ff=1;
    rep(i,n){
        if(i==0) f[i]=ff;
        else{
            ff*=i;
            ff%=mod;
            f[i]=ff;
        }
    }
    ll ans=0;
    for(ll i=0;i<=k;i++){
        mint s=choose(n-1,n-1-i);
        s*=m*a[n-1-i];
        ans+=s.x;
        ans%=mod;
    }
    cout << ans << endl;
    return 0;
} 

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


int main() {

    string s1,s2;
    cin>>s1>>s2;

    reverse(s2.begin(),s2.end());

    if(s1==s2)
      cout<<"YES"<<endl;
    else
      cout<<"NO"<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define ppb pop_back
#define ppf pop_front
#define umax(x,y) x=max(x,y)
#define umin(x,y) x=min(x,y)
#define ll long long
#define ii pair<int,int>
#define iii pair<ii,int>
#define iiii pair<ii,ii>
#define sz(x) ((int) x.size())
#define orta ((bas+son)>>1)
#define all(x) x.begin(),x.end()
#define dbgs(x) cerr<<(#x)<<" --> "<<(x)<<" "
#define dbg(x) cerr<<(#x)<<" --> "<<(x)<<endl;getchar()
#define pw(x) (1<<(x))
#define inf 2000000000
#define MOD 998244353
#define N 200005
#define M 1000005
#define LOG 1000000
#define KOK 32000
#define EPS 0.000000001
using namespace std;

int tot,mat,n,m,x,y,z;
int must[2][N*2],dp[N][2];
map<ii,int> plc[N*2];

int po(int x,ll y) {

	if(y==0) return 1;

	int res=po(x,y/2);

	res=1ll*res*res%MOD;

	if(y&1) res=1ll*res*x%MOD;

	return res;

}

ii getit(int now) {

	return {now/2,(now+1)/2+1};

}

ii getsym(int x,int y) {

	return {y,x};

}

int getdia(int x,int y) {

	int sh=abs(y-x)/2;

	if(x>y) return (y+sh)*2-1+(x-sh!=y+sh);

	return (x+sh)*2-1+(y-sh!=x+sh);

}

int get(int bef,int cur,int ind) {

	int prv=ind*2-2;

	int now=ind*2-1;

	if(must[!(bef^cur)][prv] || must[!cur][now]) return 0;

	return dp[ind][bef];

}

int main() {

	//freopen("input.txt","r",stdin);

	scanf("%d %d",&n,&m);

	for(int i=1;i<=m;i++) {

		scanf("%d %d %d",&x,&y,&z);

		int inw=getdia(x,y);

		if(x==y) {

			must[z][x*2-1]=1;

			continue ;

		}

		plc[inw][{x,y}]=z+1;

		ii sym=getsym(x,y);

		if(plc[inw].count(sym)) { 

			tot--;

			mat++;

			if((make_pair(x,y)==getit(inw)) || (sym==getit(inw))) {

				if(plc[inw][sym]!=z+1) must[1][inw]=1;
				else must[0][inw]=1;	

			}
			else if(plc[inw][sym]!=z+1) {

				printf("0");

				return 0;

			}

		}	
		else {

			tot++;

		}
 
	}

	ll rem=(1ll*n*n-tot*2-2*mat-n)/2;

	dp[1][0]=1;

	for(int i=1;i<=n;i++) {	

		dp[i+1][0]=(get(0,0,i)+get(1,0,i))%MOD;
		dp[i+1][1]=(get(0,1,i)+get(1,1,i))%MOD;

	}

	printf("%d",1ll*(dp[n+1][0]+dp[n+1][1])%MOD*po(2,rem)%MOD);

}

Measured memory_bytes: 25856
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<numeric>
#include<algorithm>
#include<complex>
#include<queue>
#include<stdlib.h>
#include<map>
#include<cmath>
#include<stdio.h>
#include<stdlib.h>
#include<set>

#define ll long long

using namespace std;

string S;

int main(){
    ll N,K;
    cin >> N >> K;
    vector<ll> x(N);
    for(int i=0;i<N;i++){
        cin >> x[i];
    }
    ll ans=0;
    for(int i=0;i<N;i++){
        if(x[i]<abs(K-x[i])){
            ans+=2*x[i];
        }
        else{
            ans+=2*abs(K-x[i]);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 764
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


using namespace std;
using ll = long long;
using ull = unsigned long long;

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


#define REP(i, n) for(ll i = 0; i < n; i++)
























ll gcd(ll a, ll b){
    return b? gcd(b, a % b) : a;
}

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    REP(i, n){
        cin >> a[i];
    }
    set<ll> st;
    bool ok = true;
    REP(i, n){
        ll t = a[i];
        for(ll j = 2; j <= sqrt(t); j++){
            if(t % j == 0){
                if(st.find(j) != st.end()){
                    ok = false;
                    break;
                }
                st.insert(j);
                while(t % j == 0){
                    t /= j;
                }
            }
        }
        if(t != 1){
            if(st.find(t) != st.end()){
                ok = false;
                break;
            }
            st.insert(t);
        }
        if(!ok) break;
    }
    if(ok){
        cout << "pairwise coprime" << endl;
        return 0;
    }
    ll t = a[0];
    REP(i, n){
        t = gcd(t, a[i]);
    }
    if(t == 1){
        cout << "setwise coprime" << endl;
        return 0;
    }
    cout << "not coprime" << endl;
}

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

int main() {
  string s;
  cin >> s;
  char a = s[0];
  bool flg = true;
  for(int i = 1; i < s.size(); i++){
    if(a == s[i]) flg =false;
    a = s[i];
  }
  if(flg) cout << "Good" << endl;
  else cout << "Bad" << endl;
  return 0;
}

Measured memory_bytes: 256
A,B,C,X,Y=map(int,input().split())
ans=0
if X < Y:
    X,Y = Y,X
    A,B = B,A
if A+B > 2*C:
    ans = Y * C * 2
    if A > 2*C:
       ans += (X-Y) * C * 2
    else:
       ans += (X-Y) * A
else:
    ans = A*X + B*Y
print(ans)


Measured memory_bytes: 38256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

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; }

typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//edit
class Solve {
public:
    Int N;
    Int K;
    vector<Int> A, F;

    bool check(Int x) {
        // x以下にできるか
//        Int rest = K;
        Int cnt = 0;

        for (int i = 0; i < N; ++i) {
            if (A[i] * F[i] > x) {
                Int y = (A[i] * F[i] - x + F[i] - 1) / F[i];
                cnt += y;
            }
        }
        return cnt <= K;
    }

    void solve() {
        cin >> N;
        cin >> K;
        A.resize(N);
        F.resize(N);
        for (int i = 0; i < N; ++i) {
            cin >> A[i];
        }
        for (int i = 0; i < N; ++i) {
            cin >> F[i];
        }
        sort(all(A));
        sort(F.rbegin(), F.rend());


        Int ng = -1;
        Int ok = INFl;
        while (ok - ng > 1) {
            Int mid = (ok + ng) / 2;
            if (check(mid)) {
                ok = mid;
            } else {
                ng = mid;
            }
        }
        cout << ok << endl;

//        for (int i = 0; i < N; ++i) {
//            Int dec = min(A[i], K);
//            K -= dec;
//            A[i] -= dec;
//        }
//
//        Int ans = 0;
//        for (int i = 0; i < N; ++i) {
////            ans += A[i] * F[i];
//            chmax(ans, A[i] * F[i]);
//        }
//        cout << ans << endl;


    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


Measured memory_bytes: 3328
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>
#include <cstdio>
#include <iomanip>
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define queint queue<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>//大きい順
#define pqg priority_queue<int,vec,greater<int>>//小さい順
#define pb push_back
#define vec vector<int>
#define vecvec vector<vector<int>>
#define vecll vector<ll>
#define vecvecll vector<vector<ll>>
#define bs binary_search
#define All(c) (c).begin(),(c).end()
#define mp make_pair
using namespace std;
int in(){int x;scanf("%d",&x);return x;}
//ll lin(){ll x;scanf("%d",&x);return x;}
int main(){
    int a=in();
    string s;
    cin>>s;
    if(a>=3200){
        cout<<s;
    }else{
        cout<<"red"<<endl;
    }
}


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


using namespace std;


int main() {
    string a;
    cin >> a;
    int size = a.length();
    if (a[size - 1] == 's') {
        a.append("es");
    }
    else {
        a.append("s");
    }
    cout << a;

    return 0;
}

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

using namespace std;

using ld = long double;
const ld PI = acos(-1);

int main() {
   ios_base::sync_with_stdio(false); cin.tie(nullptr);
   ld dir; cin >> dir;
   dir = dir / 180. * PI;
   ld cur = 0.;
   int cnt = 0;
   ld x = 0, y = 0;
   while (true) {
      cnt++;
      x += sin(cur);
      y += cos(cur);
      if (abs(x) < 1e-9 && abs(y) < 1e-9) {
         cout << cnt << "\n";
         return 0;
      }
      cur += dir;
   }
}


Measured memory_bytes: 4116
import java.util.*;

public class Main{
  //public static int v[]=new int[100001];
  public static int n,m;
  public static long dp[][]=new long[1001][1001];
  public static long func(String s[],int i,int j)
  {
    if(i==n-1 && j==m-1)  
    return (long)1;
    if(j>=m || i>=n)
    return 0;
    if(s[i].charAt(j)=='#')
    return 0;
    if(dp[i][j]!=-1)
    return dp[i][j];
    dp[i][j]=func(s,i,j+1)%1000000007+func(s,i+1,j)%1000000007;
    return dp[i][j]%1000000007;
  } 
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in); 
    n=sc.nextInt();
    m=sc.nextInt();
    String temp=sc.nextLine();
    String s[]=new String[n];
    for(int i=0;i<n;i++){
      s[i]=sc.nextLine();
    }
    for(int i=0;i<=n;i++){
      for(int j=0;j<=m;j++)  
      dp[i][j]=-1;
    }
    System.out.print(func(s,0,0));
  }
}

Measured memory_bytes: 53056
#include<iostream>
using namespace std;
int main() {
	long long int s;
	long long int ans = 0;
	cin >> s;
	if (s >= 1000000000) {
		ans += s / 1000000000 * 1124999936;
		s -= s / 1000000000 * 1000000000;
		ans += s / 100000000 * 224999936;
		s -= s / 100000000 * 100000000;
		ans += s / 10000000 * 44999936;
		s -= s / 10000000 * 10000000;
		ans += s / 1000000 * 8999936;
		s -= s / 1000000 * 1000000;
		ans += s / 100000 * 1799936;
		s -= s / 100000 * 100000;
		ans += s / 10000 * 359936;
		s -= s / 10000 * 10000;
		ans += s / 1000 * 71936;
		s -= s / 1000 * 1000;
		ans += s / 100 * 14336;
		s -= s / 100 * 100;
		ans += s / 10 * 2816;
		s -= s / 10 * 10;
		ans += s * 512;
	}
	else if (s >= 100000000) {
		ans += s / 100000000 * 112499968;
		s -= s / 100000000 * 100000000;
		ans += s / 10000000 * 22499968;
		s -= s / 10000000 * 10000000;
		ans += s / 1000000 * 4499968;
		s -= s / 1000000 * 1000000;
		ans += s / 100000 * 899968;
		s -= s / 100000 * 100000;
		ans += s / 10000 * 179968;
		s -= s / 10000 * 10000;
		ans += s / 1000 * 35968;
		s -= s / 1000 * 1000;
		ans += s / 100 * 7168;
		s -= s / 100 * 100;
		ans += s / 10 * 1408;
		s -= s / 10 * 10;
		ans += s * 256;
	}
	else if (s >= 10000000) {
		ans += s / 10000000 * 11249984;
		s -= s / 10000000 * 10000000;
		ans += s / 1000000 * 2249984;
		s -= s / 1000000 * 1000000;
		ans += s / 100000 * 449984;
		s -= s / 100000 * 100000;
		ans += s / 10000 * 89984;
		s -= s / 10000 * 10000;
		ans += s / 1000 * 17984;
		s -= s / 1000 * 1000;
		ans += s / 100 * 3584;
		s -= s / 100 * 100;
		ans += s / 10 * 704;
		s -= s / 10 * 10;
		ans += s * 128;
	}
	else if (s >= 1000000) {
		ans += s / 1000000 * 1124992;
		s -= s / 1000000 * 1000000;
		ans += s / 100000 * 224992;
		s -= s / 100000 * 100000;
		ans += s / 10000 * 44992;
		s -= s / 10000 * 10000;
		ans += s / 1000 * 8992;
		s -= s / 1000 * 1000;
		ans += s / 100 * 1792;
		s -= s / 100 * 100;
		ans += s / 10 * 352;
		s -= s / 10 * 10;
		ans += s * 64;
	}
	else if (s >= 100000) {
		ans += s / 100000 * 112496;
		s -= s / 100000 * 100000;
		ans += s / 10000 * 22496;
		s -= s / 10000 * 10000;
		ans += s / 1000 * 4496;
		s -= s / 1000 * 1000;
		ans += s / 100 * 896;
		s -= s / 100 * 100;
		ans += s / 10 * 176;
		s -= s / 10 * 10;
		ans += s * 32;
	}
	else if (s >= 10000) {
		ans += s / 10000 * 11248;
		s -= s / 10000 * 10000;
		ans += s / 1000 * 2248;
		s -= s / 1000 * 1000;
		ans += s / 100 * 448;
		s -= s / 100 * 100;
		ans += s / 10 * 88;
		s -= s / 10 * 10;
		ans += s * 16;
	}
	else if (s >= 1000) {
		ans += s / 1000 * 1124;
		s -= s / 1000 * 1000;
		ans += s / 100 * 224;
		s -= s / 100 * 100;
		ans += s / 10 * 44;
		s -= s / 10 * 10;
		ans += s * 8;
	}
	else if (s >= 100) {
		ans += s / 100 * 112;
		s -= s / 100 * 100;
		ans += s / 10 * 22;
		s -= s / 10 * 10;
		ans += s * 4;
	}
	else if (s >= 10) {
		ans += s / 10 * 11;
		s -= s / 10 * 10;
		ans += s * 2;
	}
	else {
		ans += s * 1;
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (abs(a-c) <= d || (abs(a-b) <= d && abs(b-c) <= d)){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
n = int(input())
dp = [float("Inf")]*(n+1)
for i in range(n+1):
    if i < 6:dp[i] = i
    power = 1
    while i >= 6 ** power:
        if dp[i] > dp[i-6**power]+1:dp[i] = dp[i-6**power] + 1
        power += 1
    power = 1
    while i >= 9 ** power:
        if dp[i] > dp[i-9**power]+1:dp[i] = dp[i-9**power] + 1
        power += 1
print(int(dp[n]))

Measured memory_bytes: 45008
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n,m;
	cin>>n>>m;
	int a,b;
	a=(double)n/0.08;
	b=(double)m/0.1;
	int k,l;
	k=a<b?a:b;
	l=a>b?a:b;
  k=k-1;
  l=l+1;
	// cout<<k<<" "<<l<<endl;
	for(int i=k;i<=l;i++) {
//		cout<<"test:"<<i<<endl;
		if(floor((double)i*(double)0.08)==n && floor((double)i*(double)0.1)==m) {
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<-1<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define DBG(x) cout<<#x<<":"<<x<<endl
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
const ll p = 1e9+7;
const ll INF = 1LL << 60;

int main(){
  ll n,a[111111],b[111111];
  PP p[111111];
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i]>>b[i];
    p[i]=MP(-a[i]-b[i],MP(-a[i],-b[i]));
  }
  sort(p,p+n);
  ll s=0,t=0;
  for(int i=0;i<n;i++){
    if(i%2==0)s+=-p[i].S.F;
    else t+=-p[i].S.S;
  }
  cout<<s-t<<endl;
  return 0;
}


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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
typedef long long ll;

int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int l=a+b,r=c+d;
  if(l<r)cout << "Right" << endl;
  else if(l>r)cout << "Left" << endl;
  else cout << "Balanced" << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
      int n = sc.nextInt();
      int[] a = new int[n];
      int attack = 0;
      for(int i = 0;i<n;i++){
         a[i] = sc.nextInt();
          attack += a[i];
      }
      if(h<=attack){
         System.out.println("Yes");
      }else{
         System.out.println("No");
      }        
   }
}

Measured memory_bytes: 59244
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
 
typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const ll mod = 1e9+7;


int main()
{
 
	//cin.tie(0); ios_base::sync_with_stdio(false);
	string s,t;
	cin >>s >>t;
	int n=sz(s), m=sz(t);
	VI ss(n);
	rep(i, n){
		bool ok=1;
		rep(j,m){
			if(i+j>n-1 ){ok=0; break;}
			if(s[i+j]!='?' && s[i+j] != t[j]){ok=0; break;}
		}
		if(ok) ss[i] = 1;
	}
	//for(auto x :ss) printf("%d, ",x); puts("");
	if(count(all(ss), 1)==0){
		cout <<"UNRESTORABLE\n";
		return 0;
	}
	
	string ans = "}}";
	rep(i,n) if(ss[i]==1){
		string w=s;
		rep2(j,ss[i]-1,m) w[i+j] = t[j];
		rep(j,n) if(w[j]=='?') w[j]='a';
		ans = min(ans, w);
	}
	
	
	cout <<  ans<<"\n";
	return 0;
 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr int INF = 2e9;

unsigned int randxor() {
  static unsigned int x=123456789,y=362436069,z=521288629,w=88675123;
  unsigned int t;
  t=(x^(x<<11));x=y;y=z;z=w; return( w=(w^(w>>19))^(t^(t>>8)) );
}




int main() {
  int D;
  cin >> D;
  vector<int> c(26);
  rep(i,26) cin >> c[i];
  vector<vector<int>> s(D, vector<int>(26));
  vector<int> last_day(26, 0);
  vector<int> t(D);
  rep(i,D) rep(j,26) cin >> s[i][j];

  int score = 0;
  int res = 0;
  auto Scoring = [&](int d, int id) {
    score += s[d - 1][id];
    last_day[t[d - 1]] = d;
    for (int i = 0; i < 26; i++) score -= c[i] * (d - last_day[i]); 
    res = max((int)1e6 + score, 0);
  };

  auto init = [&](){
    while (res < 10000) {
      for (int i = 0; i < D; i++) {
        int q = randxor() % 26;
        t[i] = q;
        Scoring(i + 1, q);
      }
    }
  };

  //計算  
  init();
  rep(p, 50000000) {

    int d = randxor() % D;
    int change_q = randxor() % 26;    
    int old_q = t[d];
    t[d] = change_q;
    int old_res = res;
    Scoring(d + 1, change_q);
    if (res < old_res) {
      t[d] = old_q;
      res = old_res;
    }
  }

  //cout << res << endl;
  rep(i,D) cout << t[i] + 1 << endl;
  return 0;
} 

Measured memory_bytes: 3688
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int a[100010],i,j,k,n,m;
    while(scanf("%d",&n)!=EOF)
    {
        memset(a,0,sizeof(a));
        a[n]++;
        for(i=1;i<1000100;i++)
        {
            if(n%2==0)
            {
                a[n/2]++;
                n=n/2;
                if(a[n]==2)
                {
                    printf("%d\n",i+1);
                    break;
                }
            }
            else
            {
                a[3*n+1]++;
                n=3*n+1;
                if(a[n]==2)
                {
                    printf("%d\n",i+1);
                    break;
                }

            }
        }
    }
    return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> int_pair;
typedef pair<ll,ll> ll_pair;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
int a=0,b=0,c=0,d=0,n;
char s;

int main(){
	cin>>n;
	FOR(i,0,n){
		cin>>s;
		if(s=='Y')a=1;
	}
	if(a)cout<<"Four"<<endl;
	else cout<<"Three"<<endl;
	
	return 0;
}


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

template<typename T>
istream& operator >> (istream& istr, vector<T>& vec){
    for(T& x: vec) istr >> x;
    return istr;
}

template<typename T>
ostream& operator << (ostream& ostr, vector<T>& vec){
    if(!vec.empty()){
        ostr << vec.front();
        for(auto itr = ++vec.begin(); itr != vec.end(); itr++)
            ostr << " " << *itr;
    }
    return ostr;
}

template<typename T>
ostream& operator << (ostream& ostr, vector<vector<T>>& mat){
    if(!mat.empty()){
        ostr << mat.front();
        for(auto itr = ++mat.begin(); itr != mat.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

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

template<typename T, typename U>
ostream& operator << (ostream& ostr, vector<pair<T,U>>& mat){
    if(!mat.empty()){
        ostr << mat.front();
        for(auto itr = ++mat.begin(); itr != mat.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

typedef long long ll;
typedef vector<ll> vll;
// vll x(n); x[i]=a;
typedef vector<pair<ll,ll>> vpll;
// vpll x(n); x[i]={a,b}; x[i].first/second;
typedef vector<vector<ll>> vvll;
// vvll x(m,vi(n)); x[i][j]=a;

#define REP(i,n) for(ll i=0; i<(n); i++)
#define RREP(i,n) for(ll i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORR(i,a,b) for(ll i=(b)-1; i>=(a); i--)
#define dump(x) cout << #x << " = " << (x) << endl
#define all(x) (x).begin(),(x).end()
// sort(all(x));

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


Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <stdio.h>

#define BUF_SIZE 20008

using namespace std;

int main(){

	char buf[BUF_SIZE];
	int heightTable[BUF_SIZE];
	int maxHeightTable[BUF_SIZE];

	fgets(buf,BUF_SIZE,stdin);

	int height = 0;
	int maxHeight = 0;
	char current,history = 's';
	int i;

	for(i = 0;;i++){
		current = buf[i];
		if(history == '/'){
			height += 1;
		}else if(history == '\\'){
			height -= 1;
		}else{
			//Do nothing
		}
		heightTable[i] = height;
		if(i == 0){
			if(buf[0] == '\\'){
				maxHeightTable[i] = 0;
			}else{
				maxHeightTable[i] = -1;
			}

		}else{
			maxHeightTable[i] = maxHeightTable[i-1];
		}

		if(maxHeight <= height && ((history == '/' && current == '\\')
				|| (history == '_' && current == '\\') || (history == '/' && current== '\n'))){
			maxHeightTable[i] = i;
			maxHeight = height;
		}
		history = current;

		if(current ==  '\n'){
			break;
		}
	}


	stack<int> ST;
	int total = 0;

	int left = 0;
	int baseHeight = 0;
	int S = 0;
	int tmp;

	int joutei = 0;
	int katei = 0;
	int k = 0;

	int pool_count = 0;

	for(; i > 0; ){

		if(maxHeightTable[i-1] == -1){
						break;
		}else{

			if(buf[i-1] == '/'){
				tmp = 0;

				if(maxHeightTable[i] == i || heightTable[i] > heightTable[maxHeightTable[i-1]]){
					left = maxHeightTable[i-1];
					baseHeight = heightTable[left];
					k = left;
					while(true){
						joutei = 10*(baseHeight - heightTable[k]);
						katei = 10*(baseHeight - heightTable[k+1]);
						tmp += (joutei+katei)/2;
						if(baseHeight ==  heightTable[k+1]){
							break;
						}
						k++;
					}
					S = tmp/10;
					if( S!= 0){
						total += S;
						ST.push(S);
						pool_count++;
					}
					i = left;
				}else{
					for(k = i-1; k >= 0; k--){
						if(heightTable[k] == heightTable[i]){
							break;
						}
					}
					left = k;
					baseHeight = heightTable[left];
					while(true){
							joutei = 10*(baseHeight - heightTable[k]);
							katei = 10*(baseHeight - heightTable[k+1]);
							tmp += (joutei+katei)/2;
							if(baseHeight ==  heightTable[k+1]){
								break;
							}
							k += 1;
					}
					S = tmp/10;
					if( S!= 0){
						total += S;
						ST.push(S);
						pool_count++;
					}
					i = left;
				}
			}else{
				i--;
			}
		}
	}

	printf("%d\n",total);
	printf("%d",pool_count);
	while(!ST.empty()){
		printf(" %d",ST.top());
		ST.pop();
	}
	printf("\n");
}

Measured memory_bytes: 1352
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#ifndef LOCAL
#define cerr if(0)cout
#endif
typedef long long ll;
const int mod = 1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it, len;
	fastio() {it=len=0;}
	inline char get()
	{
		if (it<len) return s[it++]; it=0;
		len=fread(s, 1, 100000, stdin);
		if (len==0) return EOF; else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while (c==' '||c=='\n') c=get();
		if (it>0) it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0; bool ng=0; char c; c=_buff.get();
	while (c!='-'&&(c<'0'||c>'9')) c=_buff.get();
	if (c=='-') ng=1, c=_buff.get();
	while (c>='0'&&c<='9') r=r*10+c-'0', c=_buff.get();
	return ng?-r:r;
}
template <class T> inline void putnum(T x)
{
	if (x<0) putchar('-'), x=-x;
	register short a[20]={}, sz=0;
	while (x) a[sz++]=x%10, x/=10;
	if(sz==0) putchar('0');
	for (int i=sz-1; i>=0; i--) putchar('0'+a[i]);
}
inline char getreal() {char c=_buff.get(); while (c<=32) c=_buff.get(); return c;}
ll qpow(ll x, ll k) {return k==0? 1: 1ll*qpow(1ll*x*x%mod,k>>1)*(k&1?x:1)%mod;}
const int maxn = 200111;
int H, W;
int N, X, Y;
char s[maxn], t[maxn];
void check(char c, char d, int L, int R, int x)
{
	int l = L, r = R;
	for (int i=N; i>=1; i--)
	{
		if (t[i]==c) r = min(r+1, R);
		if (t[i]==d) l = max(l-1, L);
		if (s[i]==c) l++;
		if (s[i]==d) r--;
		if (l>r)
		{
			puts("NO");
			exit(0);
		}
	}
	if (!(l<=x&&x<=r))
	{
		puts("NO");
		exit(0);
	}
}
int main()
{
	getii(H, W);
	geti(N);
	getii(X, Y);
	for (int i=1; i<=N; i++) s[i] = getreal();
	for (int i=1; i<=N; i++) t[i] = getreal();
	check('U', 'D', 1, H, X);
	check('L', 'R', 1, W, Y);
	puts("YES");
	return 0;
}


Measured memory_bytes: 768
#include <cstdio>

int N, K;
int a[100010];

void solve()
{
	int i;
	long long s1=0, s2=0, s3=0;
	for(i=0; i<K; i++)
		s2 += a[i];
	for(i=K; i<N; i++){
		if(a[i] > 0)
			s3 += a[i];
	}
	long long res;
	res = s1 + s3;
	if(s2 > 0)
		res += s2;
	
	for(i=0; i<N-K; i++){
		if(a[i] > 0)
			s1 += a[i];
		if(a[i+K] > 0)
			s3 -= a[i+K];
		s2 = s2 + a[i+K] - a[i];
		long long sum = s1 + s3;
		if(s2 > 0)
			sum += s2;
		if(sum > res)
			res = sum;
	}
	//printf("%I64d\n", res);
	printf("%lld\n", res);
}

int main()
{
	int i;
	scanf("%d%d", &N, &K);
	for(i=0; i<N; i++)
		scanf("%d", &a[i]);
	solve();
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s, t;
  cin >> s >> t;
  int slen = s.size();
  int tlen = t.size();
  int c = 0, m = 0;
  for(int i = 0; i <= slen - tlen; i++){
    for(int j = 0; j < tlen; j++){
    	if(s[j + i] == t[j])
          c++;
    }
    m = max(m, c);
    c = 0;
  }
  cout << tlen - m << '\n';
}

Measured memory_bytes: 3592
import sys
N = int(input())
if N == 1:
    print(int(input()) - 1)
    sys.exit()

A = [int(sys.stdin.readline()) for _ in range(N)]
ans = A[0] - 1
i = 2

for a in A[1:]:
    if i == a:
        i += 1
        continue
    ans += (a-1)//i
print(ans)
    

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

using namespace std;


#define MAXN 1000000
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, ans = 0;
  string a, b, c;
  cin >> n >> a >> b >> c;
  for (int i = 0; i < n; ++i) {
    int k = 2;
    if (a[i]==b[i] && b[i]==c[i]) k = 0;
    else if (a[i]==b[i] || b[i]==c[i] || a[i]==c[i]) k = 1;
    ans += k;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define dbg puts("It's Just Begining.Wait For The End!!!!!\n")
#define CHECK(x) cout << (#x) << " is " << (x) <<"\n";
#define endl printf("\n")
typedef pair<ll,ll> pii;
#define pb push_back
#define ms(a,b) memset(a, b, sizeof(a))
#define in(x) scanf("%lld",&x)
#define out(x) printf("%lld",x)
#define X first
#define Y second
#define sps printf(" ")
#define dou(x) cout<<fixed<<setprecision(6)<<x
#define all(v) v.begin(),v.end()
#define dis(it,it1) distance(it,it1)+1
#define MAX 100005
#define INF 9223372036854775807LL
#define MOD 1000000007
#define print(cs) printf("Case %lld: ",cs)
#define Yesno(ok) if(ok)puts("YES");else puts("NO")
#define yesno(ok) if(ok)puts("Yes");else puts("No")
ll lcm(ll a,ll b){return ((a*b)/__gcd(a,b));}
vector<ll>vt;
ll sz;
string ques;
vector<ll>ans;
bool chq(string a,string b)
{
//    cout<<a<<" "<<b;endl;
    ll num1,num2;
    stringstream ss;
    ss<<a;
    ss>>num1;
    ss.clear();
    ss<<b;
    ss>>num2;
//    cout<<num1<<" "<<num2;endl;
    return (num1>=num2?true:false);
}
void rec(ll idx,string s)
{
    if(idx==sz)
    {
        if(chq(s,ques))
        {
            stringstream ss;
            ss<<s;
            ll num;
            ss>>num;
            ans.pb(num);
        }
        return ;
    }
    if(idx==sz-1&&chq(s,ques))
    {
        stringstream ss;
        ss<<s;
        ll num;
        ss>>num;
        ans.pb(num);
        return ;
    }
    for(ll i=0;i<vt.size();i++)
    {
        s.pb(vt[i]+'0');
        rec(idx+1,s);
        s.pop_back();
    }
}
int main()
{
    ll i,j,k,l,n,m,r;
    cin>>ques>>k;
    ll arr[10];
    ms(arr,0);
    for(i=0;i<k;i++)
    {
        in(m);
        arr[m]=1;
    }
    for(i=0;i<10;i++)if(!arr[i])vt.pb(i);
    sz=ques.size()+1;
    rec(0,"");
    sort(all(ans));
    cout<<ans[0];endl;
}


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

int main()
{
    long N = 0;
    long long A[300001] = { 0 };

    /*入力*/
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    /*XOR処理*/
    long long ans = 0;
    for (int i = 0; i < 61; i++) {
        int count0 = 0, count1 = 0;
        for (int j = 0; j < N; j++) {
            if ( ( A[j] >> i ) & 1 ) {
                count1 += 1;
            }
            else {
                count0 += 1;
            }
        }
        if (i < 25) {
            ans = ans + ((long long)1 << i) * count1 * count0;
        }
        else {
            ans = ans + (( ( ( ((long long)1 << i) % 1000000007) * count1 ) % 1000000007 ) * count0 ) % 1000000007;
        }
        
        ans = ans % 1000000007;
    }


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

Measured memory_bytes: 2560
S = input()
L = len(S)

a = S[:(L-1)//2]
b = S[(L-1)//2+1:]

flg = S == S[::-1]
if flg: flg = a == a[::-1]
if flg: flg = b == b[::-1]

print("Yes" if flg else "No")


Measured memory_bytes: 3060
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
        static long Mod = (long)1e9 + 7;
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }
        static void Solve()
        {
            var s = ReadLine()[0];
            if (s == 'a' || s == 'i' || s == 'u' || s == 'e' || s == 'o')
                WriteLine("vowel");
            else
                WriteLine("consonant");
        }
    }
}

Measured memory_bytes: 25712
#define _GLIBCXX_DEBUG //エラーを出すためのおまじない
#include <bits/stdc++.h>
//#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()
using namespace std;
#define coYES cout << "YES" << endl
#define coNO cout << "NO" << endl
#define coYes cout << "Yes" << endl
#define coNo cout << "No" << endl
#define coyes cout << "yes" << endl
#define cono cout << "no" << endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  string s;
  cin >> s;
  string new_s;
  int size = s.size();
  rep(i, size) {
    if (i%2 == 0) {
      new_s += s.at(i);
    }
  }
  cout << new_s << endl;
}


Measured memory_bytes: 3632
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Numerics;

namespace abc164
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
            if (File.Exists("input.txt"))
            {
                Console.SetIn(new StreamReader("input.txt"));
            }
			solve_abc164A();
			Console.Out.Flush();

        }

        public static void solve_abc164B()
        {
        }

        public static void solve_abc164A()
        {
            int[] sw = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            if (sw[1] >= sw[0])
            {
                Console.WriteLine("unsafe");
            }
            else
            {
                Console.WriteLine("safe");
            }
        }
    }
}


Measured memory_bytes: 28484
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cstdint>   // int64_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iomanip>
#include <iostream> // cout, endl, cin
#include <map>      // map
#include <math.h>
#include <numeric>
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <string>        // string, to_string, stoi
#include <tuple>         // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define chmin(x, y) x = min(x, y)
const int INF = 1001001001;
const int BG = 1000000007;

int dp[1000005][2];

int main()
{
    string s;
    cin >> s;
    reverse(s.begin(), s.end());
    s += '0';
    int n = s.size();
    rep(i, n + 1)
    {
        rep(j, 2)
        {
            dp[i][j] = INF;
        }
    }
    dp[0][0] = 0;
    rep(i, n)
    {
        rep(j, 2)
        {
            int x = s[i] - '0';
            x += j;
            if (x < 10)
                chmin(dp[i + 1][0], dp[i][j] + x);
            if (x > 0)
                chmin(dp[i + 1][1], dp[i][j] + (10 - x));
        }
    }

    int ans = dp[n][0];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9220
#include <stdio.h>

int main(){

	int r, g, b;

	scanf("%d", &r);
	if(r >= 10 || r <= 0) return 0;
	
	scanf("%d", &g);
	if(g >= 10 || g <= 0) return 0;

	scanf("%d", &b);
	if(b >= 10 || b <= 0) return 0;


	if((r*100 + g*10 + b) % 4 == 0) printf("\nYES\n");
	else printf("\nNO\n");

  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>

using namespace std;

struct tochange{
 int operator()(int word){
   int result;

   if (isupper(word) != 0) {
     result=tolower(word);
   } else {
     result=toupper(word);
   }
   return result;
 }
};

int main(){
  string s;
  //cin >> s;
  getline(cin, s);
  transform(s.begin(), s.end(), s.begin(), tochange());
  cout << s << endl;
  return 0;
}



Measured memory_bytes: 3188
n, k = map(int, input().split())
a = list(map(int, input().split()))

if k > 200:
    k = 200

for i in range(k):
    new = [0] * n
    diff = [0] * n
    
    for j in range(n):
        diff[max(0, j - a[j])] += 1
        if j + a[j] + 1 < n:
            diff[j + a[j] + 1] -= 1

    for j in range(n):
        new[j] = diff[j] + new[j - 1]
    
    a = new
    
print(' '.join(map(str,a)))


Measured memory_bytes: 175844
#include<iostream>
#include<cstdlib>
#include<cmath>

using namespace std;

  long min4(long A, long B, long C, long D){
  long min =A;
  if(B<min) min =B;
  if(C<min) min =C;
  if(D<min) min =D;
    
  return min; 
}


int main(){
  long N, A, B, step;
  
  cin >> N >> A >> B;
  
  if((A+B)%2==0){
   step = abs(B-(A+B)/2);
  }else{
   long Ato1 = A-1;
   long Bto1 = B-1;
   long AtoN = N-A;
   long BtoN = N-B;
   long min = min4(Ato1,Bto1,AtoN,BtoN);
   if(min == Ato1){
     step= Ato1;
     A=1; B=B-step;
     if((A+B)%2==0){
       step = step+abs(A-B)/2;
     }else{
       step=step+1;
       A=1; B=B-1;
       step = step +abs(A-B)/2;
      }
    }else if(min == Bto1){
     step= Bto1;
     A=A-step; B=1;
     if((A+B)%2==0){
       step = step+abs(A-B)/2;
     }else{
       step=step+1;
       A=A-1; B=1;
       step = step +abs(A-B)/2;
      }
    }else if(min == AtoN){
     step= AtoN;
     A=N; B=B+step;
     if((A+B)%2==0){
       step = step+abs(A-B)/2;
     }else{
       step=step+1;
       A=N; B=B+1;
       step = step +abs(A-B)/2;
      }      
    }else{
     step= BtoN;
     A=A+step; B=N;
     if((A+B)%2==0){
       step = step+abs(A-B)/2;
     }else{
       step=step+1;
       A=A+1; B=N;
       step = step +abs(A-B)/2;
      }      
    }
  }
  
  cout << step << endl;

  return 0;
}

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

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)
#define ROP(i, n)       for(int i = 1 ; i <= n ; i++)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define VECOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define SORT(obj) sort(ALL(obj))
#define GSORT(obj) sort(ALL(obj) , greater<int>())
#define P pair<int , int>
#define V vector<int>
#define VLL vector<long long>
#define M map<int, int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

int main(void) {

	ios::sync_with_stdio(false);	cin.tie(0);
    ll X;  cin >> X;
    ll count = 100;
    ll ans = 0;
    while(count < X){
      ans += 1;
      count = (ll)(count * 1.01);
    }

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


Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

bool used[30];
string str;
vector<string> cand;

void dfs(int i){
	if(i==str.size()) cand.push_back(str);
	else{
		if(str[i]=='a' || used[str[i]-'a']) dfs(i+1);
		if(!used[str[i]-'a'+1] && str[i]!='z'){
			str[i]++;
			used[str[i]-'a'] = 1;
			dfs(i+1);

			used[str[i]-'a'] = 0;
			str[i]--;
		}
	}
}


int main(void){
	while(1){
		cin >> str;
		if(str == "#") break;

		fill(used, used+30, false);
		cand.clear();
		dfs(0);

		cout << cand.size() << endl;
		if(cand.size() <= 10){
			for(int i=0; i<cand.size(); i++){
				cout << cand[i] << endl;
			}
		} else{
			for(int i=0; i<5; i++){
				cout << cand[i] << endl;
			}
			for(int i=cand.size()-5; i<cand.size(); i++){
				cout << cand[i] << endl;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 4252
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define era(t) t.erase(unique(be(t)),t.end())
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
typedef long long ll;
using namespace std;
const ll mod=1000000007,mod9=1000000009;
template <class T>inline T lcm(T a,T b){return (a*b/__gcd(a,b));}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    char a;
    cin>>a;
    if(a=='A'){
        cout << 'T'<<endl;
    }
    else if(a=='T'){
        cout << 'A'<<endl;
    }
    else if(a=='C'){
        cout << 'G'<<endl;
    }
    else{
        cout << 'C'<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int i, j;
for ( i = 0; i < 9; i++ )
{
for ( j = 0; j < 9; j++ )
{
printf("%dx%d=%d\n", i+1, j+1, (i+1)*(j+1));
}
}
    return 0;
}

Measured memory_bytes: 524
// Template {{{
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
using namespace std;
typedef long long LL;

#ifdef LOCAL
#include "contest.h"
#else
#define dump(x) 
#endif

class range {
    struct Iterator {
        int val, inc;
        int operator*() {return val;}
        bool operator!=(Iterator& rhs) {return val < rhs.val;}
        void operator++() {val += inc;}
    };
    Iterator i, n;
    public:
    range(int e) : i({0, 1}), n({e, 1}) {}
    range(int b, int e) : i({b, 1}), n({e, 1}) {}
    range(int b, int e, int inc) : i({b, inc}), n({e, inc}) {}
    Iterator& begin() {return i;}
    Iterator& end() {return n;}
};

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
inline bool valid(int x, int w) { return 0 <= x && x < w; }

void iostream_init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.setf(ios::fixed);
    cout.precision(12);
}
//}}}

struct Result{
    int k;
    LL val;
};
string s;
map<char, int> ops;
Result expr(int k, int d) {
    // dump(k);
    // dump(d);
    if(d == 3) {
        if(s[k] == '(') {
            Result r = expr(k+1, 0);
            assert(s[r.k++] == ')');
            return r;
        } else if(isdigit(s[k])) {
            LL res = 0;
            while(k < s.size() && isdigit(s[k])) {
                res = res * 10 + s[k++] - '0';
            }
            return {k, res};
        } else {
            assert(false);
        }
    } else {
        Result r = expr(k, d+1);
        LL val = r.val;
        k = r.k;
        while(k < s.size()) {
            if(!(ops.count(s[k]) && ops[s[k]] == d)) {
                break;
            }
            Result p = expr(k+1, d+1);
            if(s[k] == '+') {
                val += p.val;
            } else if(s[k] == '-') {
                val -= p.val;
            } else if(s[k] == '*') {
                val *= p.val;
            }
            k = p.k;
        }
        return {k, val};
    }
}
int main(){
    iostream_init();
    while(cin >> s) {
        LL res = LLONG_MIN;
        REP(a, 3) REP(b, 3) REP(c, 3) {
            ops['+'] = a;
            ops['-'] = b;
            ops['*'] = c;
            res = max(res, expr(0, 0).val);
        }
        cout << res << endl;
    }
    return 0;
}

/* vim:set foldmethod=marker: */

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
typedef tuple<ll,ll,ll> Tu;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[8]={0,1,0,-1,1,1,-1,-1},mdy[8]={-1,0,1,0,1,-1,1,-1};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

ll n,k;
ll a[1010];
ll b[1010];
vector<ll> C;
vector<ll> D;
int main(){
	cin>>n>>k;
	REP(i,n)cin>>a[i];
	b[0]=0;
	for(ll i=1;i<=n;i++){
		b[i]=b[i-1]+a[i-1];
	}
	for(ll i=0;i<=n;i++){
		for(ll j=i+1;j<=n;j++){
			C.push_back(b[j]-b[i]);
		}
	}
	sort(C.begin(),C.end());
	ll ans=0;
	for(ll i=42;i>=0;i--){
		ll t1=pow(2,i);
		for(ll j=0;j<C.size();j++){
			if(C[j]>=t1&&C[j]-t1==(C[j]^t1)){
				D.push_back(C[j]);
			}
		}
		if(D.size()>=k){
			C.clear();
			ans+=t1;
			REP(j,D.size()){
				C.push_back(D[j]);
			}
			D.clear();
			/*cout<<t1<<endl;
			REP(j,C.size()){
				cout<<C[j]<<endl;
			}
			cout<<endl;*/
		}else{
			D.clear();
			//cout<<i<<endl;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 6384
#include "bits/stdc++.h"
using namespace std;

#define ul unsigned long int
#define ull unsigned long long
#define li long long int


int main()
{
  ul h,w;
  cin>>h>>w;

  while (h>0|w>0) {
    for (ul i = 0; i < h; i++)
    {
      for (ul j = 0; j < w; j++)
        cout << "#";
      cout << endl;
    }
    cout << endl;

    cin >> h >> w;
  }

  return 0;
}



Measured memory_bytes: 3116
#include<bits/stdc++.h>
#define R(i,n) for(int i=0;i<n;i++)
using namespace std;main(){int N,M,i,j;cin>>N>>M;vector<int>D(N);vector<int>C(M);R(i,N){cin>>D[i];}R(i,M){cin>>C[i];}vector<vector<int> >d(M+1,vector<int>(N+1,1<<30));d[0][0]=0;R(i,M){R(j,N+1){if(j==0){d[i+1][j]=d[i][j];}else{d[i+1][j]=min(d[i][j],d[i][j-1]+C[i]*D[j-1]);}}}printf("%d\n",d[M][N]);}

Measured memory_bytes: 6052