akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <stdio.h>
#include <iostream>
#include <algorithm>

using namespace std;

int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
};
char ch[20];

int work(int tmp_len, int max_c, int len){
    if (tmp_len>len){
        for (int i=1;i<=len;++i)
            printf("%c",'a'+ch[i]);
        printf("\n");
        return 0;
    }
    for (int i=0;i<=max_c+1;++i){
        ch[tmp_len]=i;
        int tmp=i;
        if (max_c>tmp) tmp=max_c;
        work(tmp_len+1,tmp,len);
    }

}


int main()
{
    int len;scanf("%d",&len);
    ch[0]=-1;
    for (int i=len;i<=len;++i)
        work(1,-1,i);


}


Measured memory_bytes: 1536
import itertools
n, a, b, c = map(int, input().split())
NOT_USED = 0
USED_A = 1
USED_B = 2
USED_C = 3

ans = 10000
l = [0] * n

for i in range(n):
    l[i] = int(input())

for use in itertools.product([0, 1, 2, 3], repeat=n):
    cnt_a = 0
    cnt_b = 0
    cnt_c = 0
    len_a = 0
    len_b = 0
    len_c = 0

    for i in range(n):
        if use[i] == USED_A:
            cnt_a += 1
            len_a += l[i]

        if use[i] == USED_B:
            cnt_b += 1
            len_b += l[i]

        if use[i] == USED_C:
            cnt_c += 1
            len_c += l[i]

    if cnt_a == 0 or cnt_b == 0 or cnt_c == 0:
        continue
        
    ans = min(ans,
              10 * (cnt_a - 1) + abs(len_a - a) +
              10 * (cnt_b - 1) + abs(len_b - b) +
              10 * (cnt_c - 1) + abs(len_c - c))
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<utility>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) std::cout<<arg<<"\n"
#define prin2(arg1,arg2) std::cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) std::memset(arg,n,sizeof(arg))
#define mp(a,b) std::make_pair(a,b)
using std::cin;
typedef long long ll;
typedef std::pair<int,int> pi;
typedef std::vector<int> vi;
typedef std::string str;
const int INF=1e+9;
const ll INFLL=1e+17;
const ll MOD=1e+9+7;
int N,Ma,Mb;
int a[50],b[50],c[50];
int dp[50][410][410];//dp[i][j][k]:=iまで探索した時、溶液の量がそれぞれj,kとなる最小予算
int gcd(int x,int y){
  if(y==0) return x;
  else return gcd(y,x%y);
}
int main(){
  cin>>N>>Ma>>Mb;
  int amax=0,bmax=0;
  rep(i,N){
    cin>>a[i]>>b[i]>>c[i];
    amax+=a[i];bmax+=b[i];
  }
  //初期化
  rep(i,N+1){
    rep(j,amax+1){
      rep(k,bmax+1){
	dp[i][j][k]=INF;
      }
    }
  }
  dp[0][0][0]=0;
  rep1(i,N){
    rep(j,amax+1){
      rep(k,bmax+1){
	if(j-a[i-1]<0||k-b[i-1]<0) dp[i][j][k]=dp[i-1][j][k];
	else dp[i][j][k]=std::min(dp[i-1][j][k],dp[i-1][j-a[i-1]][k-b[i-1]]+c[i-1]);
      }
    }
  }
  int res=INF;
  rep1(j,amax){
    rep1(k,bmax){  
      int g=gcd(j,k);
      if(j/g==Ma&&k/g==Mb) res=std::min(res,dp[N][j][k]);
    }
  }
  if(res!=INF) prin(res);
  else prin(-1);
  return 0;
}


Measured memory_bytes: 28160
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部変数
static FILE *szpFpI;											// 入力

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
#endif

// 実行メイン
int
fMain(
	int piTNo					// <I> テスト番号 1～
)
{
	char lc1Buf[1024], lc1Out[1024];

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", piTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", piTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 条件 - 取得
	int liK, liA, liB;
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%d%d%d", &liK, &liA, &liB);

	// 最大値 - 取得
	long long llMax;
	if (liA + 2 >= liB) {
		llMax = 1 + liK;
	}
	else if (liK < liA - 1) {
		llMax = 1 + liK;
	}
	else {

		// 叩く回数
		liK -= liA - 1;
		if (liK % 2 == 0) {
			llMax = liA;
		}
		else {
			llMax = liA + 1;
			liK--;
		}

		// A->Bの変換
		int liCnt = liK / 2;
		llMax += (long long)(liB - liA) * (long long)liCnt;
	}

	// 結果 - セット
	sprintf(lc1Out, "%lld\n", llMax);

	// 結果 - 表示
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, lc1Out)) {
		siRes = -1;
	}
#else
	printf("%s", lc1Out);
#endif

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", piTNo);
	}
	else {
		printf("NG %d\n", piTNo);
	}
#endif

	return 0;
}

int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		fMain(i);
	}
#else
	fMain(0);
#endif

	return 0;
}



Measured memory_bytes: 128
import sys

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

n, s = nm()
a = nl()
mod = 998244353
dp = [0]*(s+1)
dp[0] = 1
for i in range(n):
    v = a[i]
    for j in range(s, -1, -1):
        if j >= v:
            dp[j] = (dp[j] * 2 + dp[j-v]) % mod
        else:
            dp[j] = dp[j] * 2 % mod
print(dp[s])

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

int main() {
  int a,b,c;cin >> a >> b >> c;
  vector<int> x(11);
  x[0] = c;
  for(int i=1;i<11;i++){
      x[i] = x[i-1]*a-b;
      cout << x[i] << endl;
  }
}

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

int gcd(int x, int y) {
	if (x == 0) return y;
	if (y == 0) return x;
	int mod = x % y;
	if (mod == 0) return y;
	return gcd(y, mod);
}

int main(){
	int N, K;
	cin >> N >> K;
	int G = 0;
	int M = 0;
	for (int i = 0; i < N; i++) {
		int x;
		cin >> x;
		G = ((x > G) ? gcd(x, G) : gcd(G, x));
		M = max(M, x);
	}
	if (K <= M && (K % G == 0)) cout << "POSSIBLE" << endl;
	else cout << "IMPOSSIBLE" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int c;
    int numz=0,numo=0;
    while((c = getchar()) != '\n'){
        if(c == '0'){
            numz++;
        }else{
            numo++;
        }
    }

    if(numz < numo){
        printf("%d",numz*2);
    }else{
        printf("%d",numo*2);
    }

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
const ll mod = 1000000007;
const ll INF = 9223372036854775807;
#define Sort(a) sort(a.begin(), a.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define Pi acos(-1)

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) {
    cin >> a[i];
  }
  Sort(a);
  Reverse(a);
  ll ans = 0;
  rep(i,n-1) {
    ans += a[(i+1)/2];
  }
  cout << ans << '\n';
}

Measured memory_bytes: 4776
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 1000000007;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
	int n; cin >> n;
	string s, t; cin >> s >> t;
	REP(i, n) cout << s[i] << t[i];
}

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

const int MAX_N = 13;
int N, M, X;
int C[MAX_N];
int A[MAX_N][MAX_N];

int cal(int f)
{
	int tot = 0;
	for(int i=0;i<N;++i)if(f>>i&1)tot+=C[i];
	return tot;
}

bool check(int f)
{
	vector<int> p(M,0);
	for(int i=0;i<N;++i)if(f>>i&1){
		for(int j=0;j<M;++j) p[j]+=A[i][j];
	}
	for(int i=0;i<M;++i)if(p[i]<X) return false;
	return true;
}

void solve()
{
	int ans = -1;
	for(int f=1;f<(1<<N);++f){
		if(check(f)){
			if(ans == -1) ans = cal(f);
			else ans=min(ans, cal(f));
		}
	}
	cout << ans << '\n';
}

int main()
{
	cin >> N >> M >> X;
	for(int i=0;i<N;++i){
		cin >> C[i];
		for(int j=0;j<M;++j) cin >> A[i][j];
	}
	solve();
	return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define sl set<ll>
#define vs vector<string>
#define vl vector<ll>
#define vi vector<int>
#define vpl vector<pair<ll,ll>>
#define pb push_back
#define PI 3.14159265358979323846
#define ll long long
#define ld long double
#define endl "\n"
#define rep(i,a,b) for (ll i = (a); i < (b); i++)
#define repp(i,a,b) for (ll i = (a); i >= (b); i--)
#define rop(i,a,b)  for(ll i=(a); i>(b); i--)
#define min3(a, b, c) min(c, min(a, b))
#define min4(a, b, c, d) min(d, min(c, min(a, b)))
#define tt long long t; cin>>t; while(t--)
#define IOS ios::sync_with_stdio(0);cin.tie(0);
const int maxn=1e5+100;


int main()
{ int n;
 cin>>n;
 if(n>29) cout<<"Yes";
 else cout<<"No";
}

Measured memory_bytes: 3572
#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;
int main(){
	int a[5],n;
	char com;
	while(cin>>a[0]>>com>>a[1]>>com>>a[2]>>com>>a[3]>>com>>a[4]){
		sort(a,a+5);
		int n=0;
		for(int i=0;i<5;i++)
			for(int j=i+1;j<5;j++)
				if(a[i]==a[j])n++;
		switch(n){
			case 1:cout<<"one pair"<<endl;break;
			case 2:cout<<"two pair"<<endl;break;
			case 3:cout<<"three card"<<endl;break;
			case 4:cout<<"full house"<<endl;break;
			case 6:cout<<"four card"<<endl;break;
			default:
				bool f=true;
				if(a[0]==1&&a[4]==13)a[0]=14;
				sort(a,a+5);
				for(int i=1;i<5;i++)if(a[0]+i!=a[i])f=false;
				if(f)cout<<"straight"<<endl;
				else cout<<"null"<<endl;
		}
	}
	return 0;
}

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

int main() {
    int n, k;
    cin >> n >> k;
    int ans = k;
    rep(i,n-1) {
        ans *= k-1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<math.h>
using namespace std;
#include<stdio.h>
int main()
{
    int n,a[300],i,l;
    while(~scanf("%d%d",&n,&l))
    {
        int acm=0,sum=0,e=0,b=0,c=0,m=0,f=500000;
        for(i=1;i<=n;i++)
        {
            a[i]=l+i-1;
            acm+=a[i];
        }
        e=abs(acm);
        for(i=1;i<=n;i++)
        {
            sum=acm;
            sum-=a[i];
            b=abs(sum);
            c=abs(b-e);
            if(c<f)
            {
                f=c;
                m=i;
            }
        }
//        sort(a+1,a+n+1);
        acm-=a[m];
        printf("%d\n",acm);
    }
    return 0;
}


Measured memory_bytes: 128
h, w = map(int, input().split())
s = [input().strip() for _ in range(h)]
for i in range(h):
    for j in range(w):
        flg = False
        if s[i][j] == '#':
            if 0 < i and s[i - 1][j] == '#':
                flg = True
            if i < (h - 1) and s[i + 1][j] == '#':
                flg = True
            if 0 < j and s[i][j - 1] == '#':
                flg = True
            if j < (w - 1) and s[i][j + 1] == '#':
                flg = True
            if not flg:
                print('No')
                exit()
print('Yes')


Measured memory_bytes: 39152
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
using namespace std;
int n;
int L[300],R[300];
double cnt[300];
main()
{
	while(cin>>n,n)
	{
		for(int i=0;i<n;i++)cin>>L[i];
		int ansS,ansA,ansC;
		double m=1e9;
		for(int S=0;S<=15;S++)
		{
			for(int A=0;A<=15;A++)
			{
				for(int C=0;C<=15;C++)
				{
					double now=0;
					for(int i=0;i<n;i++)R[i]=(A*(i?R[i-1]:S)+C)%256;
					for(int i=0;i<300;i++)cnt[i]=0;
					for(int i=0;i<n;i++)cnt[(L[i]+R[i])%256]+=1;
					for(int i=0;i<300;i++)
					{
						if(cnt[i]<1)continue;
						now-=cnt[i]/n*logl(cnt[i]/n);
					}
					if((long long)(m*1e9)>(long long)(now*1e9))
					{
						m=now;
						ansS=S;
						ansA=A;
						ansC=C;
					}
				}
			}
		}
		cout<<ansS<<" "<<ansA<<" "<<ansC<<endl;
	}
}



Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int h, w; cin >> h >> w;
    vector<vector<int>> A(h, vector<int>(w));
    vector<tuple<int, int, int, int>> ans;
    rep(i,h)rep(j,w) cin >> A[i][j];
    for(int i = 0; i < h; ++i){
        for(int j = 0; j < w-1; ++j){
            if(A[i][j] % 2 == 1){
                A[i][j]--;
                A[i][j+1]++;
                ans.push_back(make_tuple(i,j,i,j+1));
            }
        }
    }
    for(int i = 0; i < h-1; i++){
        if(A[i][w-1] % 2 == 1){
            A[i][w-1]--;
            A[i+1][w-1]++;
            ans.push_back(make_tuple(i, w-1, i+1, w-1));
        }
    }
    cout << ans.size() << endl;
    for(auto elem : ans){
        cout << get<0>(elem)+1 << " " << get<1>(elem)+1 << " " << get<2>(elem)+1 << " " << get<3>(elem)+1 << endl;
    }
}

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

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORd(i, a, b) for (int i = (a); i >= (b); i--)
#define REP(i, n) FOR(i, 0, n)
#define ll long long
#define pdd pair <double, double>
#define X first
#define Y second

using namespace std;

const int OFF = (1 << 18);
ll tour[2 * OFF], prop[2 * OFF];
vector <pair <int, ll> > ve[OFF];

void update(int a, int b, ll v, int lo = 0, int hi = OFF, int x = 1) {
  if (b <= lo || hi <= a) return;
  if (a <= lo && hi <= b) {
    tour[x] += v;
    prop[x] += v;    
    return;
  }

  int mi = (lo + hi) / 2;
  update(a, b, v, lo, mi, x * 2);
  update(a, b, v, mi, hi, x * 2 + 1);
  tour[x] = max(tour[x * 2], tour[x * 2 + 1]) + prop[x];

  return;
}

int main() {
  ios_base::sync_with_stdio(false);

  int n, m;
  cin >> n >> m;
  REP(i, m) {
    int a, b; ll c;
    cin >> a >> b >> c;
    ve[b - 1].push_back({a - 1, c});
  }

  REP(i, n) {
    update(i, i + 1, tour[1]);

    for (auto tr : ve[i]) {
      update(tr.first, i + 1, tr.second);
    }
  }

  cout << tour[1] << "\n";

  return 0;
}

Measured memory_bytes: 20992
import java.util.*;

class Main {
    static Scanner scan = new Scanner(System.in);

    public static void main(String[] args) {
        int n = scan.nextInt();
        int m = scan.nextInt();
        int[] dist = new int[n];
        int[] weather = new int[m];
        int[][] dp = new int[n+1][m+1];
        for (int i = 0; i < n; i++) {
            dist[i] = scan.nextInt();
        }
        for (int i = 0; i < m; i++) {
            weather[i] = scan.nextInt();
        }
        for (int i = 1; i <= n; i++) {
            for (int j = 0; j <= m; j++) {
                dp[i][j] = 2100000000;
            }
        }
        solve(dist, weather, dp);
        int min = 2100000000;
        for (int i = 0; i <= m; i++) {
            if (min > dp[n][i]) {
                min = dp[n][i];
            }
        }
        System.out.println(min);
        /*
        for (int i = 0; i < n+1; i++) {
            for (int j = 0; j < m+1; j++) {
                System.out.print(dp[i][j] + " ");
            }
            System.out.println(" ");
        }
        */
    }

    public static void solve(int dist[], int weather[], int dp[][]) {
        for (int i = 1; i <= dist.length; i++) {
            for (int j = i; j <= weather.length - dist.length + i; j++) {
                for (int k = i-1; k < j; k++) {
                    dp[i][j] = 
                        min(dp[i][j], dp[i-1][k]+(dist[i-1]*weather[j-1]));
                }
            }
        }
    }

    public static int min(int a, int b) {
        if (a < b) {
            return a;
        } else {
            return b;
        }
    }
}

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

using namespace std;
const int maxn = 1e6 + 5;

char s[maxn];
int dp[maxn][2]; // 1~i位置 0表示减为0的总花费， 1表示向上补成10的花费
// 低位向高位的贡献最多为1

int main() {
    scanf("%s", s + 1);
    int n = strlen(s + 1), d;
    dp[1][0] = s[1] - '0';
    dp[1][1] = 10 - (s[1] - '0' - 1);
    for (int i = 2; i <= n; i++) {
        d = s[i] - '0';
        dp[i][0] = min(dp[i - 1][0], dp[i - 1][1]) + d;
        dp[i][1] = 10 - d + min(dp[i - 1][0] + 1, dp[i - 1][1] - 1);
    }
    printf("%d\n", min(dp[n][0], dp[n][1]));
    return 0;
}


Measured memory_bytes: 9088
/*
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
#define llMAX 9223372036854775807
#define llMIN -9223372036854775808
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,k,x,y;

int main(){
  ll ans=0;
  double d;
  cin >> d ;
  d*=3.14159265358979323846*2.0;

  //小数点表記
  cout << setprecision(16) << d<<endl;
  return 0;
}
*/

#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
#define llMAX 9223372036854775807
#define llMIN -9223372036854775808
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,k,x,y;

int main(){
  ll ans=0;
  cin >> n >> k;

  for(ll i=k;i<=n+1;i++){
    ans+=i*n%MOD-i*(i-1)%MOD+1;
    ans=(ans+MOD)%MOD;
  }

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

Measured memory_bytes: 3636
import numpy as np

d = int(input())

c = list(map(int, input().split()))

sd = np.zeros((d, 26), dtype=np.int)
for i in range(d):
  s = list(map(int, input().split()))
  s_array = np.array(s)
  sd[i, :] = s_array

pp = np.zeros(26, dtype=np.int)
  
for i in range(d):
  pp += c
  pp_max = np.argmax(pp)+1
  pp_max_val = np.max(pp)
  # print(np.sum(pp), pp_max, pp_max_val)
  sd_max = np.argmax(sd[i,:])+1
  sd_max_val = np.max(sd[i,:])
  # print(sd_max, sd_max_val)
  sorted_pp = np.sort(pp)
  if np.sum(pp[:5]) >= sd_max_val:
    t = pp_max
    pp[pp_max-1] = 0
  else:
    t = sd_max
  print(t)

Measured memory_bytes: 27376
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <sstream>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector <vector <int>> vii;
typedef vector <long long> vll;
typedef vector <string> vs;
typedef vector <char> vc;
typedef set <int> si;
typedef set <string> ss;
typedef queue <int> qi;
typedef queue <long long> qll;
typedef queue <string> qs;
typedef queue <char> qc;
typedef struct board board;
typedef pair <int, int> pi;
typedef pair <long long, long long> pll;
typedef pair <int, pair<int, int>> pii;

#define eb emplace_back
#define ppb pop_back
#define clr(a) a.clear()
#define F first
#define S second
#define mkp make_pair

#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()

#define left(x) x * 2
#define right(x) x * 2 + 1

#define meme(a, b, c) fill(a + 1, a + 1 + b, c)

#define max(a, b) (a > b ? a : b)
#define min(a, b) (a > b ? b : a)
#define abs(a) (a > 0? a : -(a))

#define move(s) s = "#" + s

#define fr(i, a, b) for (ll i = a; i <= b; ++ i)
#define rf(i, a, b) for (ll i = a; i >= b; -- i)

#define eprintf(...) fprintf(stderr, __VA_ARGS__);

void to_pray() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cerr << "Ready\n";
}

const int N = 4e7 + 10;
const int NN = 1e3 + 10;
const int NNN = 2e3 + 9;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const ll LLINF = 1e12 + 7;
const ll P = 53;
const int EPS = 1e-9 - 8;
const int vN = 2e4 + 10;
const int sz = (1 << 22) - 1;
const double PI = acos(-1);

int a[N];

int main () {
    to_pray();

    int n;
    cin >> n;
    
    for (int i = 0; i < n; ++ i)
    	cin >> a[i];
    	
    int cnt = 0;
    	
    for (int i = 0; i < n; ++ i) {
    	if (a[i] != (i + 1))
    		++cnt;
    }
    
    cout << (cnt <= 2 ? "YES" : "NO");
    //eprintf("%.18lf seconds\n", (double)clock() / CLOCKS_PER_SEC);
    cout << '\n';
    return 0;
}

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

const int MOD = 10007;
enum Person {J, O, I};
const int BIT = 1 << 3;

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

  vector<int> chair;
  for(auto c: s) {
    if(c == 'J') chair.push_back(J);
    if(c == 'O') chair.push_back(O);
    if(c == 'I') chair.push_back(I);
  }

  vector<int> cur(BIT);
  cur[1 << J] = 1;
  for(auto c: chair) {
    vector<int> nex(BIT);
    for(int bit = 1; bit < BIT; ++bit) {
      for(int nbit = 1; nbit < BIT; ++nbit) {
        if(!(bit & nbit)) continue;
        if(!((nbit >> c) & 1)) continue;
        nex[nbit] += cur[bit];
        nex[nbit] %= MOD;
      }
    }
    cur = nex;
  }

  cout << accumulate(begin(cur), end(cur), 0, [](int sum, int i){return (sum + i) % MOD;}) << endl;
}

Measured memory_bytes: 1240
import java.util.Scanner;

public class Main {
    static int[][] dp;
    static Scanner sc;

    public static void main(String[] args) {
        sc = new Scanner(System.in);
        int n = sc.nextInt();
        for (int i = 0; i < n; i++) {
            solve();
        }
    }

    static void solve() {
        char[] a = sc.next().toCharArray();
        char[] b = sc.next().toCharArray();
        if (a.length < b.length) {
            char[] c = a;
            a = b;
            b = c;
        }
        dp = new int[a.length + 1][b.length + 1];
        for (int i = 0; i < a.length; i++) {
            for (int j = 0; j < b.length; j++) {
                dp[i + 1][j + 1] = a[i] == b[j] ? dp[i][j] + 1 : Math.max(dp[i + 1][j], dp[i][j + 1]);
            }
        }
        System.out.println(dp[a.length][b.length]);
    }
}


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

int main(){
string N;
cin >> N;
for(int i = 0; i < 2; i++){ 
     if(N.at(i) == N.at(i + 1) && N.at(i + 1) == N.at(i + 2)) {
         cout << "Yes"<< endl;
         return 0; 
}
}
cout << "No"<< endl; 
}


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

using namespace std;

int main(){
	long n;
	cin >> n;
	long a[n];
	int idx;
	long minv=1000000000000;
	long sum = 0, ans = 0;

	for (int i = 0; i < n; ++i)
		cin >> a[i];
	for (int i = 0; i < n; ++i){
		a[i] -= i+1;
	}
	sort(a,a+n);
	long b = a[n/2];
	for (int i = 0; i < n; ++i)
		ans += abs(a[i]-b);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
#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##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

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

int main() {
    int H, W, h, w;
    cin >> H >> W >> h >> w;

    int x = 1;
    while (x < h) {
        if (H - H / h * h == h - x) break;
        x++;
    }
    int y = 1;
    while (y < w) {
        if (W - W / w * w == w - y) break;
        y++;
    }
    if (x == h && y == w) {
        write("No");
        return 0;
    }

    vv<int> ans = vvec(H, W, 0);
    if (x == h) {
        ll lcm = (w - y) * y / gcd(w - y, y);
        lcm = (W / w) / lcm * lcm + lcm;
        rep(i, H) rep(j, W) {
            if (j % w == w - y) {
                ans[i][j] = -lcm / y - 1;
            }
            else if (j % w > w - y) {
                ans[i][j] = -lcm / y;
            }
            else {
                ans[i][j] = lcm / (w - y);
            }
        }
    }
    else if (y == w) {
        ll lcm = (h - x) * x / gcd(h - x, x);
        lcm = (H / h) / lcm * lcm + lcm;
        rep(i, H) rep(j, W) {
            if (i % h == h - x) {
                ans[i][j] = -lcm / x - 1;
            }
            else if (i % h > h - x) {
                ans[i][j] = -lcm / x;
            }
            else {
                ans[i][j] = lcm / (h - x);
            }
        }
    }
    else {
        ll lcm = (ll)(h * w - x * y) * (x * y) / gcd(h * w - x * y, x * y);
        lcm = (H / h) * (W / w) / lcm * lcm + lcm;
        rep(i, H) rep(j, W) {
            if (i % h == h - x && j % w == w - y) {
                ans[i][j] = -lcm / (x * y) - 1;
            }
            else if (i % h >= h - x && j % w >= w - y) {
                ans[i][j] = -lcm / (x * y);
            }
            else {
                ans[i][j] = lcm / (h * w - x * y);
            }
        }
    }

    write("Yes");
    rep(i, H) {
        rep(j, W) cout << ans[i][j] << (j == W - 1 ? '\n' : ' ');
    }
}

Measured memory_bytes: 2816
n, y = [int(i) for i in input().split()]

for i in range(n+1):
    for j in range(n+1-i):
        if y == i*10000 + j*5000 + (n-i-j)*1000:
            print('{} {} {}'.format(i, j, n-i-j))
            break
    else:
        continue
    break
else:
    print('-1 -1 -1')


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

int main(){
  int n;
  cin >> n;
  int ans = (n%2)?(n/2+1):(n/2);
  cout << ans << endl;
}

Measured memory_bytes: 256
n = int(raw_input())
l = [raw_input().strip() for _ in xrange(n)]
t = raw_input().strip()
for i in xrange(n):
    l[i] += '0' * (20 - len(l[i]))
t += '0' * (20 - len(t))
a = b = p = 0
for s in l:
    c = 0
    for i in xrange(20):
        if s[i] != '?' and s[i] < t[i]:
            c |= 1
            break
        if s[i] != '?' and s[i] > t[i]:
            c |= 2
            break
        if s[i] == '0' and t[i] == '0':
            c |= 3
            break
        if s[i] == '0' and t[i] != '0':
            c |= 1
            break
        if s[i] != '0' and t[i] == '0':
            c |= 2
            break
        if s[i] == t[i]:
            continue
        if t[i] != 'a':
            c |= 1
        if t[i] != 'z':
            c |= 2
    else:
        c |= 3
    if c == 3:
        p += 1
    elif c == 1:
        a += 1
    elif c == 2:
        b += 1
r = range(a + 1, a + p + 2)
print ' '.join(map(str, r))


Measured memory_bytes: 3560
# -*- coding: utf-8 -*-
"""
C - Go Home
https://atcoder.jp/contests/abc056/tasks/arc070_a

"""
import sys


def solve(X):
    def is_reachable(n):
        if ((1+n)*n)//2 >= X:
            return True
        return False

    ub, lb = 10**5, 0
    while ub - lb > 0:
        mid = (ub + lb) // 2
        if is_reachable(mid):
            ub = mid
        else:
            lb = mid + 1
    return ub


def main(args):
    X = int(input())
    ans = solve(X)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 3064
fun main() {
    val (n, m) = next2Int()
    if (n % 2 == 1) {
        println(buildString {
            for (i in 1..m) {
                append("$i ${m * 2 + 1 - i}\n")
            }
        })
    } else {
        val half = n / 2
        println(buildString {
            for (i in 1..(m + 1) / 2) {
                append("$i ${half + 1 - i}\n")
            }
            for (i in 1..m / 2) {
                append("${half + i} ${n - i}\n")
            }
        })
    }
}

val scanner = java.util.Scanner(System.`in`)
fun next(): String = scanner.next()
fun nextInt() = scanner.nextInt()
fun next2Int() = Pair(scanner.nextInt(), scanner.nextInt())
fun next3Int() = Triple(scanner.nextInt(), scanner.nextInt(), scanner.nextInt())
fun nextLong() = scanner.nextLong()
fun nextLine(): String = scanner.nextLine()
fun nextList() = nextLine().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextIntArray(size: Int) = IntArray(size) { nextInt() }
fun nextLongList() = nextList().map(String::toLong)
fun printYesNo(isYes: Boolean) = println(if (isYes) "Yes" else "No")

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

int main() {
	long int a, b, k;
	cin >> a >> b >> k;
	if(a > k) {
	    a = a - k;
	    cout << a << " " << b << endl;
	} else {
	    k = k - a;
	    a = 0;
	    if(k > b) {
	        b = 0;
	        cout << a << " " << b << endl;
	    } else {
	        b = b - k;
	        cout << a << " " << b << endl;
	    }
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
long double EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
////////////////////////////////////////

int main(){fastio;
    ll n,m;cin>>n>>m;
    ll s,t;cin>>s>>t;
    s--;t--;
    vector<l_l>v[n];
    rep(i,1,m){
        ll u,q,d;cin>>u>>q>>d;u--;q--;
        v[u].pb(l_l(d,q));
        v[q].pb(l_l(d,u));
    }
    ll md[n];fill(md,md+n,inf);
    md[s]=0;
    priority_queue<l_l,vector<l_l>,greater<l_l>>q;
    q.push(l_l(0,s));
    while(!q.empty()){
        l_l t=q.top();q.pop();
        ll nowp=t.second;
        for(auto xx:v[nowp]){
            ll to=xx.second,cost=xx.first;
            if(md[nowp]+cost<md[to]){
                md[to]=md[nowp]+cost;
                q.push(l_l(md[to],to));
            }
        }
    }
    
    
    ll com[n];memset(com,0,sizeof(com));
    com[s]=1;
    vector<l_l>jun;
    rep(i,0,n-1){
        jun.pb(l_l(md[i],i));
    }
    sort(jun.begin(),jun.end());
    rep(i,0,n-1){
        for(auto x:v[jun[i].second]){
            if(md[x.second]==md[jun[i].second]+x.first){
                Add(com[x.second],com[jun[i].second]);
            }
        }
    }
    ll ans=mod(com[t]*com[t]);
    
    ll comb[n];memset(comb,0,sizeof(comb));
    comb[t]=1;
    priority_queue<l_l>qb;
    qb.push(l_l(md[t],t));
    reverse(jun.begin(),jun.end());
    rep(i,0,n-1){
        for(auto x:v[jun[i].second]){
            if(md[x.second]==md[jun[i].second]-x.first){
                Add(comb[x.second],comb[jun[i].second]);
            }
        }
    }
    
    rep(i,0,n-1){
        if(md[i]*2==md[t]){
            Add(ans,-powl(mod(com[i]*comb[i]),2));
        }
    }
    rep(i,0,n-1){
        for(auto x:v[i]){
            if(md[i]*2<md[t]&&md[t]<md[x.second]*2&&md[i]+x.first==md[x.second]){
                Add(ans,-powl(mod(com[i]*comb[x.second]),2));
            }
        }
    }
    
    /*rep(i,0,n-1){
        cout<<com[i]<<" "<<comb[i]<<endl;
    }*/
    cout<<mod(ans)<<endl;
    
    return 0;
}


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

#define int long long
#define endl '\n'

string s;
int k;

int dp[105][2][5];

int rec(int id, int tight, int left) {
    if (left < 0)   return 0;
    if (id == (int)s.size())    return left == 0;
    int &ans = dp[id][tight][left];
    if (ans != -1)  return ans;
    ans = 0;
    int lim = tight ? s[id] - '0' : 9;
    for (int i = 0; i <= lim; i++) 
        ans += rec(id + 1, (i < s[id] - '0') ? 0 : tight, left - (i > 0));
    return ans;
}

signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    cin >> s >> k;
    memset(dp, -1, sizeof dp);
    cout << rec(0, 1, k);
}

Measured memory_bytes: 256
n, b = map(int,input().split())
for i in range(1<<n):
    ans = []
    _i = i
    cnt = 0
    _cnt = 0
    while i and _cnt < b+1:
        if i&1:
            ans.append(cnt)
            _cnt += 1
        cnt += 1
        i=i>>1
    if _cnt == b:
        
        print(f'{_i}:',end = '')
        if _i == 0:
            print()
        else:print("",*ans)


Measured memory_bytes: 6204
$mul = <STDIN>; $mul =~ s/\s+$//;
$range = <STDIN>; $range =~ s/\s+$//; ($min, $max) = split (/ /, $range);

$m1 = $min / $mul;
$m2 = $max / $mul;

if ($m1 == int($m1) or $m2 == int($m2)) {
  $ans = "OK";
} elsif ($m1 <= int($m2)) {
  $ans = "OK";
} else {
  $ans = "NG";
}
print "$ans\n";


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

int main(void){
    int N;
    cin >> N;
    string s;
    int AB{0}, BA{0}, A{0}, B{0};

    for(int i{0}; i<N; ++i){
        cin >> s;
        for(int j{1}; j<s.size(); ++j){
            if(s[j-1]=='A' and s[j]=='B')
                ++AB;
        }
        if(s[0]=='B' and s[s.size()-1]=='A'){
            ++BA;
        }
        else if(s[0]=='B'){
            ++B;
        }
        else if(s[s.size()-1]=='A'){
            ++A;
        }
    }
    int sum{AB};

    if(A+B==0 and BA>2)
        sum += BA-1;
    else
        sum += BA+min(A, B);

    cout << sum << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define lli long long int
#define llu long long unsigned int
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define FOR(i,s,e) for(i=s; i<e; i++)
#define mod 1000000007
#define F first
#define S second
#define plli pair<lli,lli>
#define pqlli priority_queue<lli>
#define test(t) cin>>t; while(t--)
using namespace std;
 
lli power(lli a, lli b, lli M = mod)
{
	lli result = 1;
    for (;;)
    {
        if (b & 1)
            result = (result*a);
        b >>= 1;
        if (!b)
            break;
        a = (a*a);
    }
    return result;
}
int main()
{
	IOS;
	lli n,m;
	cin>>n>>m;
	cout<<min(m - n%m, n%m)<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		long X = sc.nextLong();
		long amount = 100;
		long res = 0;
		while(amount<X) {
			amount+=amount/100;
			res++;
		}
		System.out.println(res);
	}
}

Measured memory_bytes: 35844
import java.util.*;
import java.io.*;

import static java.lang.System.in;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char[] a = s.toCharArray();
        int n = a.length;
        long ans = 0;
        int black = 0;
        for(int i=0;i<n;i++){
            if(a[i]=='B') black++;
            else ans += black;
        }
        PrintWriter out = new PrintWriter(System.out);
        out.println(ans);
        out.flush();
    }
}


Measured memory_bytes: 30036
#%%
n, k = map(int, input().split())
v = list(map(int, input().split()))
vv = v.copy()[::-1]
ans = 0

for i in range(0, min(n+1, k+1)):
    for j in range(0, min(n+1-i, k+1-i)):
        x = k - i - j
        tmp = v[:i] + vv[:j]
        tmp.sort()
        #print(tmp, i, j, x)
        t = 0
        for q in range(len(tmp)):
            if tmp[q] < 0 and (q+1) <= x:
                pass
            else:
                t += tmp[q]
        #print(t)
        ans = max(ans, t)
print(ans)

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

ll N, ans;

int main()
{
	cin >> N;
	for (ll i = 2, M = N; i * i <= M; i++)
	{
		ll z = i;
		while (N % z == 0)
			ans++, N /= z, z *= i;
		while (N % i == 0)
			N /= i;
	}

	cout << ans + (N != 1) << "\n";
}


Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
#define ll long long
int main(){
    int n;
    int a[114514];
    int r=1;
    cin>>n;
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<n;i++){
        if(r==2){
            cout<<i<<endl;
            return 0;
        }
        r=a[r-1];
    }
    cout<<-1<<endl;
    return 0;
}



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

// macros
#define overload_rep(va_0, va_1, va_2, name, ...) name
#define rep_0(i, n) for(int i = 0; i < (n); ++i)
#define rep_1(i, x, y) for(int i = (x); i <= (y); ++i)
#define rep(...) overload_rep(__VA_ARGS__, rep_1, rep_0)(__VA_ARGS__)
#define all(a) a.begin(), a.end()
#ifndef STOP_DEBUG
#define debug(...)\
    do { cerr << boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_cerr(__VA_ARGS__); cerr << noboolalpha; } while (0)
#else
#define debug(...)
#endif

// functions
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; }
void debug_cerr(){ cerr << '\n'; }
template<class Head, class... Tail>
void debug_cerr(Head head, Tail... tail){
    cerr << ' ' << head;
    debug_cerr(tail...);
}

// cin/cout setup
struct IoSetup{
    IoSetup(){
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} iosetup;

// libraries

// declarations
int N;
bool ans[198];

vector<int> make_vector(const int& st, const int sz){
    int pos = st;
    if((pos %= (2 * N)) < 0)pos += (2 * N);
    vector<int> res(sz);
    rep(i, sz){
        res[i] = pos;
        if(++pos >= (2 * N))pos -= (2 * N);
    }
    return res;
}

bool inquire(const vector<int>& vec){
    cout << "?";
    for(const int &x : vec)cout << " " << x + 1;
    cout << endl;
    string s;
    cin >> s;
    if(s == "-1")exit(0);
    return s == "Blue";
}

void answer(){
    cout << "! ";
    rep(i, 2 * N)cout << (ans[i] ? "B" : "R");
    cout << endl;
}

// solve
int main(){

    cin >> N;

    bool fir_blue = inquire(make_vector(0, N));
    int lb = 0, ub = N;
    while(ub - lb > 1){
        int md = (lb + ub) / 2;
        (fir_blue == inquire(make_vector(md, N)) ? lb : ub) = md;
    }
    
    ans[lb] = fir_blue;
    ans[lb + N] = !fir_blue;
    vector<int> use = make_vector(ub, N - 1);

    rep(i, 0, lb - 1){
        use.push_back(i);
        ans[i] = inquire(use);
        use.pop_back();
    }

    rep(i, ub + N, 2 * N - 1){
        use.push_back(i);
        ans[i] = inquire(use);
        use.pop_back();
    }

    use = make_vector(ub + N, N - 1);
    rep(i, ub, lb + N - 1){
        use.push_back(i);
        ans[i] = inquire(use);
        use.pop_back();
    }

    answer();

}


Measured memory_bytes: 724
import sys
sys.setrecursionlimit(10**6)
f=lambda:map(int,sys.stdin.readline().split())
n,q=f()
g=[[] for _ in range(n)]
for i in range(n-1):
  a,b=f()
  g[a-1]+=[b-1]
  g[b-1]+=[a-1]
l=[0]*n
for i in range(q):
  p,x=f()
  l[p-1]+=x
def dfs(v,p=-1):
  for c in g[v]:
    if c==p: continue
    l[c]+=l[v]
    dfs(c,v)
dfs(0)
print(*l)

Measured memory_bytes: 268432
#include <bits/stdc++.h>
using namespace std;
int main() {
    int x, y; cin >> x >> y;
    for (int i = 0; i <= x; i++) {
    	int j = x - i;
        if (2 * i + 4 * j == y) {
            cout << "Yes" << "\n";
            return 0;
        }
    }
    cout << "No" << "\n";
}


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

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

Measured memory_bytes: 512
import java.util.Scanner;

public class Main
{
	static Scanner sc = new Scanner(System.in);
	
	public static void main(String[] args)
	{
		long t = sc.nextLong();
		long n = sc.nextLong();
		long h = sc.nextLong();
		
		long k =sc.nextLong();
		
		long p,q,r;
		long hh = 0;
		
		
		//System.out.println("hiii");
		
		long answer;
		
		if(k%2==0)
		{
			answer = t-n;
		}
		else
		{
			answer = n-t;
		}
		
		long absolute = Math.abs(answer);
		
		if(absolute>(int)(Math.pow(10, 18)))
		{
			System.out.println("Unfair");
		}
		else
		{
			System.out.println(answer);
		}
		
	}
}


Measured memory_bytes: 24148
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;

void main() {
    foreach(int i;1..10) foreach(int j; 1..10) {
        writeln(i, "x", j, "=", i*j);
    }
}

Measured memory_bytes: 2364
import java.util.*;
//import java.util.stream.Collectors;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int c = Integer.parseInt(sc.next());
		System.out.println(Math.min(a, b) + Math.min(Math.max(a, b), c));
	}
}


Measured memory_bytes: 35580
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;

int main(void){
    lint N,M;
    cin >> N >> M;
    bool AC[N]={};
    int p[M];
    string S[M];
    rep(i,M) cin >> p[i] >> S[i];
    rep(i,M) p[i]--;
    lint A=0,W=0;
    lint Wstock[N]={};
    rep(i,M){
        if(S[i]=="AC"){
            if(AC[p[i]]==false) A++,AC[p[i]]=true;
        }
        if(S[i]=="WA"){
            if(AC[p[i]]==false) Wstock[p[i]]++;
        }
    }
    rep(i,N) if(AC[i]==true) W+=Wstock[i];
    cout << A << " " << W << endl;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    string S;
    cin >> S;
    if(S.front() != 'A') {
        cout << "WA" << endl;
    } else {
        bool flag = false;
        rep2(i, 2, S.size() - 1) {
            if(S[i] == 'C') {
                if(flag) {
                    cout << "WA" << endl;
                    return 0;
                } else {
                    flag = true;
                }
            } else if(isupper(S[i])) {
                cout << "WA" << endl;
                return 0;
            }
        }
        if(flag && islower(S[1]) && islower(S[S.size() - 1])) {
            cout << "AC" << endl;
        } else {
            cout << "WA" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
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 INF = 1e9;
const ll MOD = 1e9 + 7;


int main(){
    string s;
    cin >> s;

    string t = s;
    reverse(all(t));
    if(s != t){
        cout << "No" << endl;
        return 0;
    }

    int n = s.size();
    string x = s.substr(0, (n-1)/2);
    string y = x;
    reverse(all(x));
    if(x != y){
        cout << "No" << endl;
        return 0;
    }

    x = s.substr((n+3)/2-1, n/2);
    y = x;
    reverse(all(x));
    if(x != y){
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <iostream>
#include <limits>
#include <numeric>
#include <type_traits>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define MOD 1000000007
#define SORT(s) sort(s.begin(), s.end());
#define REVERSE(s) reverse(s.begin(), s.end());
#define SUM(s) accumulate(s.begin(), s.end(), 0LL);
#define P pair<int,int>
#define mp make_pair
#define valid(x,y,h,w) (0<=x&&x<h&&0<=y&&y<w)
//#define int ll
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int ndx[8] = { 0,1,0,-1, 1,1,-1,-1 };
int ndy[8] = { 1,0,-1,0, 1,-1,-1,1 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }



int main() {
	int a, b, k;;
	cin >> k >> a >> b;;

	FOR(i, a, b + 1) {
		if (i % k == 0) {
			cout << "OK" << endl;
			return 0;
		}
	}

	cout << "NG" << endl;
	return 0;
}




Measured memory_bytes: 3560