akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=m-1; i>=n; i--)
#define SORT(v,n) do{sort(v,v+n);reverse(v,v+n);}while(0)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

ll POW(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW(x*x,n/2)%MOD;
  return x%MOD*POW(x,n-1)%MOD;
}

ll POW2(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW2(x*x,n/2);
  return x*POW2(x,n-1);
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll KAI2(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI2(m-1);
}

ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll COM2(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI2(m)/KAI2(n)/KAI2(m-n);
}

ll DEC(ll x,ll m,ll n)
{
  return x%POW(m,n+1)/POW(m,n);
}

ll keta(ll x,ll n)
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

ll DIV(ll x,ll n)
{
  if(x==0)return 0;
  return x/n+DIV(x/n,n);
}

ll ORD(ll x,ll n)
{
  if(x==0)return INF;
  if(x%n!=0)return 0;
  return 1+ORD(x/n,n);
}

int main()
{
  ll a,b;
  cin >> a >> b;
  if(a>0)printf("Positive");
  else if(a==0)printf("Zero");
  else if(b>=0)printf("Zero");
  else if((b-a)%2==0)printf("Negative");
  else printf("Positive");
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(dead_code)]
use std::cmp;
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, LinkedList, VecDeque};

fn main() {
    proconio::input! {
        a: i64
    }
    println!("{}", if a == 0 {1} else {0});
}


Measured memory_bytes: 2112
import java.util.Scanner;
 
class Main {
    public static void main(String[] args) {
 
        Scanner scan = new Scanner (System.in);
 
        boolean [][] cards = new boolean [4][13] ;
        //自分の手持ちカード枚数
        int myCards = scan.nextInt();
            //手持ちカード枚数まで入力する
        for(int i = 0 ; i < myCards ; i++){
 
        //マークと数字を入れる
        String mark = scan.next();   int number = scan.nextInt();
 
        //該当数るマークと数字の配列にtrueを入れる
        if(mark.equals("S")) cards [0][number-1] = true;
        else if(mark.equals("H")) cards [1][number-1] = true;
        else if(mark.equals("C")) cards [2][number-1] = true;
        else cards [3][number-1] = true;
 
        }
 
 
       //cards[i][j]==falseだったら、出力
        for(int i = 0 ; i < 4 ; i++){
            for(int j= 0 ; j < 13 ; j++){
                    if(!cards[i][j]) {if(i == 0) System.out.println("S "+ (j+1));
                                              else if(i == 1) System.out.println("H "+ (j+1));
                                              else if(i == 2) System.out.println("C "+ (j+1));
                                              else System.out.println("D "+ (j+1));
                }
            }
        }
 
    }
}

Measured memory_bytes: 18064
#include <string>
#include <stack>
#include <iostream>
#include <cstdlib>
using namespace std;
int main() 
{
	string word;
	stack<int> S;
	while (cin >> word) 
	{ // ??\??????????????????????????????
		if (word == "+") 
		{
		// ??°??? 2 ??? pop ??????????????? push ??????
			int a,b;
			a=S.top();
			S.pop();
			b=S.top();
			S.pop();
			S.push(a+b);
		}
		else if (word == "-") 
		{
		// ??°??? 2 ??? pop ??????????????? push ??????
			int a,b;
			a=S.top();
			S.pop();
			b=S.top();
			S.pop();
			S.push(b-a);
		}
		else if (word == "*") 
		{
		// ??°??? 2 ??? pop ??????????????? push ??????
			int a,b;
			a=S.top();
			S.pop();
			b=S.top();
			S.pop();
			S.push(a*b);
		}
		else 
		{
		// word ?????°???????????? push ??????
			S.push(atoi(word.c_str()));
		}
	}
	// S ?????????????´??????¨????????????
	cout<<S.top()<<endl;
}

Measured memory_bytes: 3168
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define repd(i,a,b) for (int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template
const int M = 401;

ll pow_mod(ll a, ll b, ll m){
    ll ret = 1;
    while (b > 0) {
        if (b & 1) {
            ret = ret * a % m;
        }
        a = a * a % m;
        b >>= 1;
    }
    return ret;
}

vector<vector<ll>> S(M, vector<ll>(M, 0));

// S[i][j]: iまでのjじょうわ
void make_sum(){
    rep(j, M){
        ll tmp = 0;
        repd(i, 1, M){
            tmp += pow_mod(i, j, mod);
            tmp %= mod;
            S[i][j] = tmp;
        }
    }
}



int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N, C;
    cin >> N >> C;
    vector<ll> A(N), B(N);
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> B[i];
    
    make_sum();
    
    // i人目のj乗わ
    vector<vector<ll>> ind_sum(N, vector<ll>(M, 0));
    
    rep(i, N){
        rep(j, M){
            ind_sum[i][j] = (S[B[i]][j] - S[A[i] - 1][j] + mod) % mod;
        }
    }
    // i人目まででj個とった時の幸福度
    vector<vector<ll>> sum(N + 1, vector<ll>(C + 1, 0));
    
    
    rep(i, N){
        if(i == 0){
            rep(j, C + 1) sum[i][j] = ind_sum[0][j];
        }
        else {
            rep(j, C + 1){
                rep(k, j + 1){
                    sum[i][j] += (sum[i - 1][j - k] * ind_sum[i][k]) % mod;
                    sum[i][j] %= mod;
                }
            }
        }
    }
    
    output(sum[N - 1][C], 0);

    return 0;
}

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

priority_queue<P2,vector<P2>,greater<P2> >q;
int dx[]={0,1,1,1,0,-1,-1,-1};
int dy[]={-1,-1,0,1,1,1,0,-1};
int dc[]={1,2,1,2,1,2,1,2};
int off[]={1,-1};
int h,w,A,B,dp[1005][1005];
int sx,sy,gx,gy;
char s[1005][1005];

signed main(){
	r(i,1005)r(j,1005) dp[i][j] = 2000000000;

	cin>>h>>w>>A>>B;
	r(i,8) dc[i] = ( i%2? A*2:A );
	r(i,h) scanf("%s",s[i]);

	r(i,h)r(j,w){
		if( s[i][j] == 's' ) sx=j , sy=i;
		if( s[i][j] == 'g' ) gx=j , gy=i;
	}

	q.push(P2(0,P(sx,sy)));
	dp[sy][sx] = 0;

	while(!q.empty()){
		P2 p=q.top();q.pop();
		int x = p.second.first , y = p.second.second;
		int cost = p.first , f2 = (s[y][x]=='*');
		if( dp[y][x] < cost )continue;
		r(i,8){
			int nx = x+dx[i] , ny = y+dy[i];
			int ncos = cost+dc[i] , flag = 0;

			if( ny<0 || nx<0 || ny>=h || nx>=w )continue;
			if( s[ny][nx] == '*' )f2++;

			if(i%2)r(j,2){
				int T = (i+off[j]+8)%8;
				int tx = x+dx[T] , ty = y+dy[T];
				if( tx<0 || ty<0 || tx>=w || ty>=h || s[ty][tx]=='#' ) flag++;
			}

			if( flag == 2 )continue;
			if( dp[ny][nx] <= ncos )continue;
			if( s[ny][nx] == '#' )continue;

			dp[ny][nx] = ncos;
			q.push(P2(ncos,P(nx,ny)));
		}
		if( f2 )continue;
		r(i,8){
			int nx = x+dx[i] , ny = y+dy[i];
			int ncos = cost+dc[i]+B;

			if( ny<0 || nx<0 || ny>=h || nx>=w )continue;
			if( dp[ny][nx] <= ncos )continue;
			
			dp[ny][nx] = ncos;
			q.push(P2(ncos,P(nx,ny)));
		}
	}
	if( dp[gy][gx] == 2000000000 )cout<<"INF"<<endl;
	else cout<<dp[gy][gx]<<endl;
}


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

using namespace std;

//int func(int kyori);
//tikamiti -> x->yの道を使ったらtrue;
//int w_func(int start,int kyori,bool tikamiti,int saisyo);

int serch(int num);
int n,x,y;
int dp[2001][2001];

int main(void)
{
	cin>>n>>x>>y;
	for(int i = 1; i < n+1; i++){
		for(int j = 1; j < n+1; j++){
			if(i <= j) dp[i][j] = j-i;
			else dp[i][j] = i-j;
		}
	}
	for(int i = 1; i < n+1; i++){
		if(dp[i][y] > dp[i][x]+1) dp[i][y] = dp[i][x]+1;
	}
	
	int ans[n+1];
	for(int i = 0; i < n+1; i++) ans[i] = 0;
	for(int i = 1; i < n+1; i++){
		for(int j = 1; j < n+1; j++){
			if(i == j) dp[i][j] = 0;
			else if(i > j){
				dp[i][j] = dp[j][i];
			}
			else{
				int migi = j;
				int hidari = j;
				while(dp[i][migi] > dp[i][migi-1]+1){
					dp[i][migi] = dp[i][migi-1]+1;
					migi++;
					if(migi == n) break;
				}
				while(dp[i][hidari] > dp[i][hidari+1]+1 && hidari < n){
					//cout<<"hidari"<<endl;
					//cout<<"i = "<<i<<", hidari = "<<hidari<<endl;
					dp[i][hidari] = dp[i][hidari+1]+1;
					hidari--;
					if(hidari == 1) break;
				}
				
			}
		}
	}
	for(int i = 1; i < n+1; i++){
		for(int j = i; j < n+1; j++){
			ans[dp[i][j]]++;
		}
	}
	/*
	cout<<"\n"<<endl;
	cout<<"dp"<<endl;
	for(int i = 1; i < n+1; i++){
		for(int j = 1; j < n+1; j++){
			cout<<dp[i][j]<<" ";
		}
		cout<<endl;
	}
	*/
	for(int i = 1; i < n; i++){
		cout<<ans[i]<<endl;
	}
	
	/*
	int ans[n+1];
	for(int i = 1; i < n; i++){
		ans[i] = func(i);
	}
	for(int i = 1; i < n; i++){
		cout<<"i = "<<i <<", func(i) = "<<ans[i]<<endl;
		cout<<endl;
	}
	*/
	return 0;
}

int serch(int num){
	int re = 0;
	for(int i = 0; i <= n; i++){
		for(int j = i; j <= n; j++){
			if(dp[i][j] == num) re++;
		}
	}
	return re;
}

/*
int func(int kyori){
	int re = 0;
	if(kyori == 1){
		return n;
	}
	else if(kyori == n-1){
		return 0;
	}
	int num;
	for(int i = 1; i <= n-kyori; i++){
		num = w_func(i,kyori,false,i);
		cout<<"i = "<<i<<", kyori = "<<kyori<<", num = "<<num<<endl;
		re+=num;
	}
	return re;
}


int w_func(int start,int kyori,bool tikamiti,int saisyo){
	int re;
	if(kyori == 0){
		if(start <= n){
			if(tikamiti == false && start >= y && saisyo<=x) return 0;
			else return 1;
		}
		else return 0;
		
	}
	
	if(start == x){
		int re1 = w_func(start+1,kyori-1,tikamiti,saisyo);
		int re2 = w_func(y,kyori-1,true,saisyo);
		re = re1+re2;
	}
	else{
		re = w_func(start+1,kyori-1,tikamiti,saisyo);
	}
	return re;
}

*/

Measured memory_bytes: 16000
#include <bits/stdc++.h>
using namespace std;
class dice{
public:
	int d1;
	int d2;
	int d3;
	int d4;
	int d5;
	int d6;
	int kaisi(int s1, int s2, int s3, int s4 ,int s5,int s6);
	int kakunin(int x,int y);
};
int dice::kaisi(int s1,int s2,int s3,int s4,int s5,int s6){
  d1 = s1;
  d2 = s2;
  d3 = s3;
  d4 = s4;
  d5 = s5;
  d6 = s6;
}
int miru(int r1,int r2,int r3,int r4, int r5,int r6,int b1, int b2,int b3,int b4,int b5,int b6){
 	dice iti, ni;
 	iti.d1 = r1;
 	iti.d2 = r2;
 	iti.d3 = r3;
 	iti.d4 = r4;
 	iti.d5 = r5;
 	iti.d6 = r6;
 	 ni.d1 = b1;
 	 ni.d2 = b2;
 	 ni.d3 = b3;
 	 ni.d4 = b4;
 	 ni.d5 = b5;
 	 ni.d6 = b6;
	int a1,a2,a3,a4,a5,a6;
	int aho = 0;
	a1 = ni.d1;
	a2 = ni.d2;
	a3 = ni.d3;
	a4 = ni.d4;
	a5 = ni.d5;
	a6 = ni.d6;

	
	if(iti.d1 == ni.d2){
		ni.d1 = a2;
		ni.d2 = a6;
		ni.d3 = a3;
		ni.d4 = a4;
		ni.d5 = a1;
		ni.d6 = a5;        
	}
	else if(iti.d1 == ni.d3){
		
		ni.d1 = a3;
		ni.d2 = a2;
		ni.d3 = a6;
		ni.d4 = a1;
		ni.d5 = a5;
		ni.d6 = a4;
	}
	else if(iti.d1 == ni.d4){
		
		ni.d1 = a4;
 		ni.d2 = a2;
		ni.d3 = a1;
		ni.d4 = a6;
		ni.d5 = a5;
		ni.d6 = a3;
	}
	else if(iti.d1 == ni.d5){
		
		ni.d1 = a5;
		ni.d2 = a1;
		ni.d3 = a3;
		ni.d4 = a4;
		ni.d5 = a6;
		ni.d6 = a2;  
	}
	else if(iti.d1 == ni.d6){
		
		ni.d1 = a6;
		ni.d2 = a5;
		ni.d3 = a3;     
		ni.d4 = a4;
		ni.d5 = a2; 
		ni.d6 = a1;
	}
	
    for(int i = 0;i< 4;i++){
    	int b;
    	b = ni.d4;
    	ni.d4 = ni.d2;
    	ni.d2 = ni.d3;
    	ni.d3 = ni.d5;
    	ni.d5 = b;
    	if(iti.d1 == ni.d1 && iti.d2 == ni.d2 && iti.d3 == ni.d3 && iti.d4 == ni.d4 && iti.d5 == ni.d5 && iti.d6 == ni.d6){
   			aho +=1;
    	}
    }
    for(int i = 0;i< 4;i++){
    	int b;
    	b = ni.d1;
    	ni.d1 = ni.d5;
    	ni.d5 = ni.d6;
    	ni.d6 = ni.d2;
    	ni.d2 = b;
    	if(iti.d1 == ni.d1 && iti.d2 == ni.d2 && iti.d3 == ni.d3 && iti.d4 == ni.d4 && iti.d5 == ni.d5 && iti.d6 == ni.d6){
   			aho +=1;
    	}
    }
    	
    if(aho == 0){
    	return 1;
	}
	return 0;
}
int main(){
	int s1,s2,s3,s4,s5,s6,e1,e2,e3,e4,e5,e6,kai;
	cin>>kai;
	int yama = 0;
	cin>>s1>>s2>>s3>>s4>>s5>>s6;
	for(int i = 0;i <kai-1;i++){
		cin>>e1>>e2>>e3>>e4>>e5>>e6;
		yama += miru(s1,s2,s3,s4,s5,s6,e1,e2,e3,e4,e5,e6);
	

	}
	if(yama == kai-1){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 3100
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iterator>
#include <fstream>
#include <cstddef>
#include <cstring>
//#include <chrono> //正確な時間計測のため
using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define PB push_back
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(),v.end()
#define FF first
#define SS second
#define mp make_pair
#define INT int_64
#define MOD 998244353
const ll INF = (1<<30);
const ll NEGA=-INF*10000; 

//階乗
ll Kaijou(ll a) {
if (a < 2) return 1;
return a * Kaijou(a - 1)%MOD;
}

//逆元の計算用(pは素数のときb=p-2で逆元)
ll calc(ll a, ll b, ll p) {
	if (b == 0) return 1;
	if (b % 2 == 0) {
		ll d = calc(a, b / 2, p);
		return (d*d) % p;
	}
	else {
		return (a*calc(a, b - 1, p)) % p;
	}
}


//ユークリッドの互除法
ll gcd(ll x, ll y) {
	if (x < y) swap(x, y);
	if (y == 0) return x;
	return gcd(y, x%y);
}

ll CCC(ll all,ll a,ll b,ll c){
  all=Kaijou(all)%MOD;
  a=Kaijou(a);
  b=Kaijou(b);
  c=Kaijou(c);
  ll sita=((a*b)%MOD*c)%MOD;
  return all*calc(sita,MOD-2,MOD)%MOD;
}

 ll ans=INF;

 ll cc[501][501];
 ll D[31][31];
 
 ll pdmin[3];

//再帰なし累乗
ll iPOW(ll x, ll p){
  ll result;
	for(result=1;p!=0;p>>=1)
	{
    if(p&1) result*=x;
	  x*=x;
  }
  return result;
}


int main(){  
 int d,n;
 cin>>d>>n;
 int t=1;
 rep(i,d) t*=100;
 if(n<100) cout<<n*t<<endl;
 else cout<<n*t+t<<endl;
}

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

int main() {
  string s,t;
  cin >> s >> t;
  ll cnt = 0;
  
  if(s.at(0) == t.at(0))
    cnt++;
  if(s.at(1) == t.at(1))
    cnt++;
  if(s.at(2) == t.at(2))
    cnt++;
  
  cout << cnt << endl;
}

Measured memory_bytes: 3588
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
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 main(){
  string S;
  ll N,K;
  cin>>S>>K;
  N=S.size();
  
  //桁DP[i][j][k]=i番目まで見てj個の0でない数がある数字の総数 k=1ならS未満確定
  ll DP[N][K+2][2];
  
  for(int i=0; i<N; ++i){
    for(int j=0; j<=K; ++j){
      for(int k=0; k<2; ++k){
        DP[i][j][k]=0;
      }
    }
  }
  
  DP[0][1][1]=S[0]-'0'-1;
  DP[0][1][0]=1;
  DP[0][0][1]=1;
  
  for(int i=1; i<N; ++i){
    for(int j=0; j<=K; ++j){
      if(S[i]=='0'){
        DP[i][j][0]+=DP[i-1][j][0];
        DP[i][j][1]+=DP[i-1][j][1];
        DP[i][j+1][1]+=DP[i-1][j][1]*9;
      }
      else{
        DP[i][j+1][0]+=DP[i-1][j][0];
        DP[i][j][1]+=DP[i-1][j][1]+DP[i-1][j][0];
        DP[i][j+1][1]+=DP[i-1][j][1]*9+DP[i-1][j][0]*(S[i]-'0'-1);
      }
    }
  }
  
  co(DP[N-1][K][0]+DP[N-1][K][1]);
  return 0;
}

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

int main()
{
    int k;
    cin >> k;
    vector<ll> a(k);
    for (int i = 0; i < k; i++)
        cin >> a[i];
    ll mn = 2, mx = 2;
    for (int i = k - 1; i >= 0; i--)
    {
        ll min_num = ((mn + a[i] - 1) / a[i]) * a[i];
        ll max_num = (mx / a[i]) * a[i] + a[i] - 1;
        if (min_num > mx || max_num < mn)
        {
            cout << -1 << endl;
            return 0;
        }
        mn = min_num;
        mx = max_num;
    }
    cout << mn << " " << mx << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
ll a[2],b[2],c[2],k;
int main(){
	scanf("%lld%lld%lld%lld",&a[0],&b[0],&c[0],&k);
	a[1]=b[0]+c[0],b[1]=a[0]+c[0],c[1]=a[0]+b[0];
	printf("%lld\n",a[k&1]-b[k&1]);
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int S[30],ST[9],N[7]={0,0,0,0,43,45,42},i,p,F[4]={0};

int calc()
{
	int i=p=0;
	for(i=0;i<7;i++)
	{
		if(S[i]>9)
		{
			if(p<2)return 0;
			else if(S[i]==43)ST[p-2]=ST[p-2]+ST[p-1];
			else if(S[i]==45)ST[p-2]=ST[p-2]-ST[p-1];
			else if(S[i]==42)ST[p-2]=ST[p-2]*ST[p-1];
			p-=1;
		}
		else ST[p++]=S[i];
	}
	return ST[0];
}
int dfs(int d,int f[4])
{
	int i;
	if(d==7)
	{
		if(calc()==10)
		{
			if(S[4]>9&&S[5]>9&&S[6]>9)return 0;
			else if(S[0]<10&&S[1]<10&&S[2]<10)return 0;
			else if(S[4]>9)
				printf("(((%d %c %d) %c %d) %c %d)\n",S[0],S[2],S[1],S[4],S[3],S[6],S[5]);
			else
				printf("((%d %c %d) %c (%d %c %d))\n",S[0],S[2],S[1],S[6],S[3],S[5],S[4]);
			return 1;
		}
		return 0;
	}
	for(i=0;i<7;i++)
	{
		if((i<4&&!f[i])||i>3)
		{
			f[i]=1;
			S[d]=N[i];
			if(dfs(d+1,f))return 1;
			f[i]=0;
		}
	}
	return 0;
}
int main()
{
	for(;~scanf("%d%d%d%d",&N[0],&N[1],&N[2],&N[3]),N[0];)
	{
		memset(F,0,16);
		if(dfs(0,F)==0)
			puts("0");
	}
	return 0;
}

Measured memory_bytes: 612
import Control.Monad
import qualified Data.ByteString.Char8 as BS
import Data.List
import Data.Maybe
import Data.Ord
import qualified Data.Vector as VC
import qualified Data.Vector.Mutable as VM

readNums :: IO [Integer]
readNums = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

readNumLists :: Int -> IO [[Integer]]
readNumLists n = replicateM n (map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine)

readStrings :: IO [String]
readStrings = map BS.unpack . BS.words <$> BS.getLine

readStringLists :: Int -> IO [[String]]
readStringLists n = replicateM n (map BS.unpack . BS.words <$> BS.getLine)

toTuple :: [a] -> (a, a)
toTuple (x:y:_) = (x, y)

p s = putStr (show s ++ " ")

main :: IO ()
main = do
  (n:_) <- readNums
  a <- readNums
  print $ solve a

solve a = f lcmOfList 0 a
  where
    lcmOfList = foldl1' lcm a
    myMod = (`mod` 1000000007)
    f l acc [] = myMod acc
    f l acc (x:xs) = f l (myMod (acc + l `div` x)) xs

Measured memory_bytes: 2428
def main():
    N = int(input())
    A = [int(a) for a in input().split()]
    current = 0
    res = 0
    for i in range(N):
        if A[i] == current+1:
            current += 1
        else:
            res += 1
    if current == 0:
        print(-1)
    else:
        print(res)
main()

Measured memory_bytes: 77644
package main
import "fmt"
func main() {
  var s,t,u string
  fmt.Scan(&s)
  t = s[0:2]
  u = s[2:4]
  if ("01" <= t && t <= "12") && ("01" <= u && u <= "12") {
    fmt.Println("AMBIGUOUS")
  } else if ("01" > t || t > "12") && ("01" > u || u > "12") {
    fmt.Println("NA")
  } else if "01" <= t && t <= "12" {
    fmt.Println("MMYY")
  } else {
    fmt.Println("YYMM")
  }
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define ll long long
#define MOD (ll)1e9+7
#define REP(i,b,e) for(int (i)=b;(i)<e;(i)++)
const ll INF= 1LL << 60;

class UnionFind {
	vector<int> data;
public:
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};


//入力
int Q;
ll A[110];
ll B[110];
int main(){
  cin >> Q;
  REP(i,0,Q){
    ll a,b;
    cin >> a>>b;
    if(a<b){
      A[i]=a;
      B[i]=b;
    }else{
      A[i]=b;
      B[i]=a;
    }
  }
  ll ans=0;
  REP(i,0,Q){
    if(A[i]==B[i]|A[i]==B[i]-1){
      ans=2*A[i]-2;
    }else{
      ll C=(ll)sqrt(A[i]*B[i]);
      if(C*(C+1)>=A[i]*B[i]){
        ans=2*C-2;
      }else{
        ans=2*C-1;
      }
      if(A[i]*B[i]==C*C){
        ans--;
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
/////////////////// TYPES & MACROS ///////////////////////////////
#define mp make_pair
#define eb emplace_back
#define pb push_back
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define vv vector
#define exist(s,e) (s.find(e)!=s.end())
#define sz(x) ((int)(x).size())
#define int ll
typedef long long ll; typedef long double ld; typedef double dd;typedef vector<int> vi; typedef pair<int, int> pii;typedef pair<ll,ll> pll;
ll INFLL=(ll)4e18, MOD=1e9+7; const int INF=0x3f6f6f6f;
//////////////////// DEBUG /////////////////////////////////////////
#define D(x) cerr<<#x<<" is:\t"<<x<<'\n';
#define DD(x,y) cerr<<'('<<#x<<','<<#y<<") are:\t"<<x<<' '<<y<<'\n';
#define DDD(x,y,z) cerr<<'('<<#x<<','<<#y<<','<<#z<<") are:\t"<<x<<' '<<y<<' '<<z<<'\n';
/////////////////// VARIABLES & FUNCTIONS//////////////////////////
vv<vv<int>> adj; vi vis, color, level; int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1},dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};
inline ll mexp(ll x,ll n,ll m=MOD){ll res=1;x%=m;while(n){if(n&1)res=(res*x)%m;n>>=1;x=(x*x)%m;}return res;}
inline ll gcd(ll a, ll b){while (a>0 && b>0){if(a>b)a%=b;else b%=a;}return a+b;}



///////////////////// MAIN STARTS //////////////////////////////////
int32_t main(void){
ios_base::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
cout<<fixed;cerr<<fixed; cout<<setprecision(1); cerr<<setprecision(3);
mt19937 genr(chrono::high_resolution_clock::now().time_since_epoch().count());

int n,m; cin>>n>>m;
adj.resize(n);
for(int i=0;i<m;++i){
    int u,v; cin>>u>>v;
    adj[u-1].eb(v-1);
}
vi order;
vis.assign(n,false);
function<void(int)> dfs=[&](int u){
    vis[u]=true;
    for(auto& v : adj[u]){
        if(vis[v]) continue;
        dfs(v);
    }
    order.pb(u);
};
vv<ll> dp(n,0);
for(int i=0;i<n;++i){
    if(!vis[i]) dfs(i);
}
reverse(all(order));
for(auto& e: order) cerr<<e+1<<' '; cerr<<'\n'; 
for(auto& u : order){
    for(auto& v : adj[u]){
        dp[v]=max(dp[v], dp[u]+1);
    }
}
cout<< *max_element(all(dp)) <<'\n'; 

return 0;
}


Measured memory_bytes: 10488
#include <algorithm>
#include <iostream>
#include <math.h>
#include <cstdio>
#include <string.h>
#include <vector>
using namespace std;
int main(void){
	int n,i,j,k,c3,c4,f=0,t,ans=1000000;
	string s;
	cin>>n>>s;
	int d1[n]={0},d2[n]{0};
	t=0;
	for(i=0;i<n;i++){
		if(s[i]=='W'){
			t++;
		}
		d1[i]=t;
	}
	t=0;
	for(i=n-1;i>=0;i--){
		if(s[i]=='E'){
			t++;
		}
		d2[i]=t;
	}
	for(i=0;i<n;i++){
      //cout<<d1[i]<<" "<<d2[n-1-i]<<endl;
      ans=min(ans,d1[i]+d2[i]);
    }
	cout<<ans-1<<endl;

	return 0;
}

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

int main(){
    int D, N;
    cin >> D >> N;
  
    if(D == 0 && N < 100){
    cout << N << endl;
    }
 
    if(D == 0 && N == 100){
    cout << N+1 << endl;
    }
  
    if(D == 1 && N < 100){
    cout << 100*N << endl;
    }
   
    if(D == 1 && N == 100){
    cout << 100*(N+1) << endl;
    }
  
    if(D == 2 && N < 100){
    cout << (100*100*N) << endl;
    }
  
    if(D == 2 && N == 100){
    cout << 100*100*(N+1) << endl;
    }
}

Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>

using namespace std;

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	string s;
	cin >> s;
	for (auto t : s) {
		cout << 'x';
	}
	cout << endl;
}


Measured memory_bytes: 256
#define ll long long
#define ffor(i,a,b) for (int i=(a);i<(b);i++)
#define rfor(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define rep(i,n) for (int i=0;i<(n);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#define SIZE 100001
#define MOD 1000000007
#define INF 100000000
using namespace std;

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

	int n;
	cin >> n;
	int a[1000];
	rep(i,n) cin >> a[i];

	int len_max = -1000;
	int len_min = 1001;

	rep(i,n){
		if(len_max < a[i]) len_max = a[i];
		if(len_min > a[i]) len_min = a[i];
	}

	cout << len_max - len_min << endl;


	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	if(s.size()>n){
		for(int i=0;i<n;i++)
			cout<<s[i];
		cout<<"...";
	}else{
		for(int i=0;i<s.size();i++)
			cout<<s[i];
	}
	return 0;
}

Measured memory_bytes: 3624
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
multiset<int> s;
int main()
{
	int n,a,out=0;
	cin>>n;
	rep(i,n){
		cin>>a;s.insert(a);
	}
	while(s.size()>0){
		//auto it=s.end();it--;
		multiset<int>::iterator it=s.end();it--;
		int t=(*it),u;
		s.erase(it);
		for(lint i=2;i<1234567890L;i*=2){
			if(i>t && i-t<=t) u=i-t;
		}
		//cout<<t<<u<<endl;
		multiset<int>::iterator i2=s.find(u);
		if(i2!=s.end()){
			out++;s.erase(i2);
		}
	}
	cout<<out<<endl;
}


Measured memory_bytes: 9600
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(int i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

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

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N,X,T;
    cin >> N >> X >> T;
    cout << T*(1+(N-1)/X) << endl;
}
/*
overflow checked?
corner case checked?
boundary checked?
not TLE in worst case checked?
*/

Measured memory_bytes: 3608
N,Y = list(map(int,input().split()))
flag=False
for i in range(N+1):
    for j in range(N+1-i):
        if 10000*i+5000*j+1000*(N-i-j)==Y:
            flag=True
            break
    if flag:
        break
if flag:
    print(str(i)+" "+str(j)+" "+str(N-i-j))
else:
    print("-1 -1 -1")

Measured memory_bytes: 3064
n,m = list(map(int, input().split()))

ac = [0]*n
wa = [0]*(n+1)
pena = 0

for i in range(m):
  ques, state = input().split()
  ques = int(ques)-1
  
  if (state=="AC") and (ac[ques]==0):
    ac[ques] = 1
    pena += wa[ques]
  elif (state=="WA") and (ac[ques]==0):
    wa[ques] += 1
    
print(sum(ac), pena)

Measured memory_bytes: 4724
#include<bits/stdc++.h>
using namespace std;
int a[1000005];
int n,x,ans=1e9;
int main()
{
	cin>>n>>x;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		a[i]=abs(a[i]-x);
		ans=min(ans,a[i]);
	}
	for(int i=1;i<=n;i++)
		ans=__gcd(ans,a[i]);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000000000000



int main(){
	
	string s;
	cin>>s;
	
	int K;
	cin>>K;
	
	for(int i=0;i<s.size();i++){
		if(s[i]=='a')continue;
		int x = 'z' - s[i] + 1;
		if(x<=K){
			K-=x;
			s[i] = 'a';
		}
	}
	
	K%=26;
	for(int i=0;i<K;i++){
		s.back()++;
		if(s.back()>'z')s.back()='a';
	}
	
	cout<<s<<endl;

	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
using namespace std;

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

    s.erase(remove(s.begin(),s.end(),'/'),s.end());

    int d = stoi(s);
    
    if (d <= 20190430) {
        cout << "Heisei" << endl;
    }else {
        cout << "TBD" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
S = str(input())
check = 0
ans = 0
need_cng = 0
for i in range(0,N-1):
    if (S[i] != S[i+1]):
        check = check +1
if(check%2 ==0):
    need_cng = check/2
else:
    need_cng = check//2+1

if (need_cng > K):
    ans = N - (check - 2*K) -1
else:
    ans = N-1
print(ans)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
struct dice {
	P x[3];
	dice(int x_[6]) {
		x[0] = P(x_[0], x_[5]);
		x[1] = P(x_[1], x_[4]);
		x[2] = P(x_[2], x_[3]);
	}
	int X(int n) {
		return n < 3 ? x[n].first : x[5 - n].second;
	}
	void N() {
		swap(x[0], x[1]);
		swap(x[1].first, x[1].second);
	}
	void E() {
		swap(x[0], x[2]);
		swap(x[0].first, x[0].second);
	}
	void W() {
		swap(x[0], x[2]);
		swap(x[2].first, x[2].second);
	}
	void S() {
		swap(x[0], x[1]);
		swap(x[0].first, x[0].second);
	}
};

int main()
{
	int x[6];
	string s;
	for (int i = 0; i < 6; i++) {
		cin >> x[i];
	}
	dice d(x);
	cin >> s;
	for (auto c : s) {
		switch (c)
		{
		case 'N':
			d.N();
			break;
		case 'E':
			d.E();
			break;
		case 'W':
			d.W();
			break;
		case 'S':
			d.S();
			break;
		}
	}
	cout << d.X(0) << endl;
	return 0;
}

Measured memory_bytes: 3132
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL  0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

signed main(){
	//~ int T;cin>>T;
	//~ rep(Case,T){
		//~ ll a,b,c,d;cin>>a>>b>>c>>d;
		
	//~ }
	int n;string s;cin>>n>>s;
	map<pair<string,string>,int>mp;
	rep(i,1<<n){
		string a,b;
		rep(j,n){
			if(i>>j&1)a+=s[j+n];
			else b+=s[j+n];
		}
		mp[{a,b}]++;
		mp[{b,a}]++;
	}
	ll ans=0;
	rep(i,1<<n){
		string a,b;
		rep(j,n){
			if(i>>j&1)a+=s[j];
			else b+=s[j];
		}
		reverse(a.begin(),a.end());
		reverse(b.begin(),b.end());
		ans+=mp[{b,a}];
	}
	cout<<ans/2<<endl;
}

Measured memory_bytes: 72320
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>

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

using namespace std;

int R;

int main() {
    cin >> R;

    if (R < 1200) {
        cout << "ABC" << endl;
    } else if (R < 2800) {
        cout << "ARC" << endl;
    } else {
        cout << "AGC" << endl;
    }
}


Measured memory_bytes: 256
import sys
import math  # noqa
import bisect  # noqa
import queue  # noqa


def input():
    return sys.stdin.readline().rstrip()


def main():
    N = int(input())
    F = []
    for _ in range(N):
        f = list(map(int, input().split()))
        F.append(f)
    P = []
    for _ in range(N):
        p = list(map(int, input().split()))
        P.append(p)

    ans = -1000000000
    for am in range(2 ** 5):
        for pm in range(2 ** 5):
            opens = [0 for _ in range(10)]
            for i in range(5):
                if ((am >> i) & 1):
                    opens[2 * i] = 1
                if ((pm >> i) & 1):
                    opens[2 * i + 1] = 1
            if sum(opens) == 0:
                continue
            res = 0
            for i, fs in enumerate(F):
                cnt = 0
                for f, o in zip(fs, opens):
                    if f == 1 and o == 1:
                        cnt += 1
                res += P[i][cnt]
            ans = max(ans, res)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 45032
// finish date: 2018/02/03
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi vector<vector<vector<int>>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define bigmod 1000000007
#define INF 1050000000

#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>

using namespace std;

// finish date: 2018/01/31
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define bigmod 1000000007
#define INF 1050000000

#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>

using namespace std;


int main() {
    int N;
    cin >> N;
    if (N < 20) {
        string in;
        rep(i, 20) {
            cout << i << endl;
            cin >> in;
            if (in == "Vacant") return 0;
        }
    }
    vector<string> A(N);
    int res;
    string s;
    cout << 0 << endl;
    cin >> s;
    if (s == "Vacant") return 0;
    A[0] = s;
    int l = 0, r = 0;
    int m = N / 2;
    int disL, disR;
    rep(i, 19) {
        cout << m << endl;
        cin >> s;
        if (s == "Vacant") return 0;
        A[m] = s;
        disL = (l < m) ? m - l : (m + N) - l;
        disR = (m < r) ? r - m : (r + N) - m;
        disL--;
        disR--;
        if ((A[m] == A[r] && disR % 2 == 0) || (A[m] != A[r] && disR % 2 == 1)) {
            l = m;

        } else {
            r = m;
        }
        m = (r > l) ? (r + l) / 2 : (r + N + l) / 2;
    }


    return 0;

}



Measured memory_bytes: 1620
/*
      author  : nishi5451
      created : 15.08.2020 11:25:10
*/

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


int main(){
    int n,d;
    cin >> n >> d;
    if(n%(2*d+1)==0)   cout << n/(2*d+1) << endl;
    else cout << n/(2*d+1) + 1 << endl;
    return 0;
}

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

int main(){
  int D, G; cin >> D >> G;
  vector<int> p(D), c(D);
  for(int i = 0; i < D; i++){
    cin >> p[i] >> c[i];
  }
  int solve = 1e9;
  for(int bit = 0; bit < (1 << D); bit++){
    int point = 0;
    int solve1 = 0, id;
    for(int j = 0; j < D; j++){
      if(bit >> j & 1){
        point += 100*(j + 1)*p[j] + c[j];
        solve1 += p[j];
      }
      else id = j;
    }
    if(point < G){
      int res = 100*(id + 1);
      int need = (G - point + res - 1)/res;
      if(need >= p[id]) continue;
      solve1 += need;
    }
    solve = min(solve, solve1);
  }
  cout << solve << endl;
} 

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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define ALL(x) x.begin(),x.end()
#define LL long long

const int maxn = 2e5 + 5;
int A[maxn];

int main()
{
    int N;scanf("%d",&N);
    _rep(i,1,N){
        int num;scanf("%d",&num);
        num-=i;
        A[i-1] = num;
    }

    sort(A,A+N);
    int b = A[N/2];
    LL ans = 0;
    _for(i,0,N){
        ans += abs(b-A[i]);
    }
    cout << ans << endl;
    /*
    int min_num = 1e9+1;
    int max_num = 1;
    _for(i,0,N){
        min_num = min(min_num,A[i]);
        max_num = max(max_num,A[i]);
    }
    int l = min_num;
    int r = max_num+1;

    LL min_sad = 1e14+5;

    while(r - l < 1){
        int mid = (r+l)/2;

    }
    */
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
#include <string.h>
#define ll long long int

int cont(char *s,char *res)
{
    int count = 0;
    int max = 0;
    for (int i = 0; i<strlen(s); i++)
    {
        for (int j=0; j<strlen(res); j++)
        {
            if (s[i]==res[j])
            {
                count++;
                if (max<count)
                    max=count;
                break;
            }
            else if (s[i]!=res[j] && j==strlen(res)-1)
            {
                count = 0;
            }
        }
    }

    return max;
}




int main()
{
    char res[4]= "ACGT";
    char s[11]= {'\0'};
    scanf("%s",&s);

    int max = 0;

    printf("%d",cont(s,res));



    return 0;
}


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


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

    double s = (a+b+c)/2;
    int ans = sqrt(s*(s-a)*(s-b)*(s-c));

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



Measured memory_bytes: 256
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
from heapq import heappop, heappush
def resolve():
    n, m = map(int, input().split())
    N = 1 << (n - 1).bit_length()
    N2, N3 = N * 2, N * 3
    E = [[] for _ in range(N * 3 + m)]
    ref = lambda v : v if v < 3 * N else v - N2

    # build range-edge graph
    for i in range(N - 1, 0, -1):
        cl, cr = i << 1, i << 1 | 1
        E[i].append((cl, 0))
        E[i].append((cr, 0))
        E[ref(cl + N2)].append((ref(i + N2), 0))
        E[ref(cr + N2)].append((ref(i + N2), 0))

    # add range-edge
    for i in range(m):
        u, v, w = map(int, input().split())
        u -= 1
        # lower
        l, r = u + N, v + N
        while l < r:
            if l & 1:
                E[ref(l + N2)].append((N3 + i, w))
                l += 1
            if r & 1:
                r -= 1
                E[ref(r + N2)].append((N3 + i, w))
            l >>= 1
            r >>= 1
        # upper
        l, r = u + N, v + N
        while l < r:
            if l & 1:
                E[N3 + i].append((l, 0))
                l += 1
            if r & 1:
                r -= 1
                E[N3 + i].append((r, 0))
            l >>= 1
            r >>= 1

    # Dijkstra (source : N, termination : N + n - 1)
    dist = [INF] * (N3 + m)
    dist[N] = 0
    heap = [(0, N)]
    while heap:
        d, v = heappop(heap)
        if dist[v] != d:
            continue
        for nv, w in E[v]:
            if dist[nv] > d + w:
                dist[nv] = d + w
                heappush(heap, (d + w, nv))

    ans = dist[N + n - 1]
    if ans == INF:
        ans = -1
    print(ans)
resolve()

Measured memory_bytes: 271424
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;


int main(){
    int x;
    cin >> x;
    cout << (x?0:1) <<endl;
    return 0;
}

Measured memory_bytes: 3648
/*
ID: wangjun30
LANG: C++11
TASK:
*/
#include<iostream>
#include<algorithm>
#include<array>
#include<unordered_map>
#include<map>
#include<set>
#include<list>
#include<stack>
#include<unordered_set>
#include<vector>
#include<bitset>
#include<queue>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<climits>
//#include<fstream>
#define int long long
using namespace std;
//ifstream cin(".in");
//ofstream cout(".out");
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int n;
	cin>>n;
	int ans=0;
	for(int i=1;i<=n;i++){
		int x;
		cin>>x;
		if(x%2==1 && i%2==1)
			ans++;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3648
#116-B（Collatz Problem）
a = []
s = input()
s = int(s)
a.append(s)

i = 0
while i <= 1000000:
    n = a[-1]
    n = int(n)
    if n % 2 == 0:
        C = n / 2
    else:
        C = n * 3 + 1
    if C in a:
        a.append(C)
        break
    a.append(C)
print(len(a))

Measured memory_bytes: 3064
ss = input().split()
N = int(ss[0])
K = int(ss[1])
Q = int(ss[2])
As = []

SCORE = [0] * N

for i in range(Q):
  SCORE[int(input())-1] += 1
for i in range(N):
  if(SCORE[i]<= Q-K):
    print("No")
  else:
    print("Yes")

Measured memory_bytes: 50520
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define sz(a) a.size()
#define INF 0x3f3f3f3f
#define de(x) cout<<#x<<"="<<x<<endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
using namespace std;
const int maxn=100005;
int main()
{
	int n,i,l,r,j;
	int sum=0,vis[maxn];
	
	memset(vis,0,sizeof(vis));
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d%d",&l,&r);
		for(j=l;j<=r;j++){
			if(vis[j]==0){
				vis[j]=1;
			}
			else if(vis[j]==1){
				vis[j]=-1;
			}
		}
	}
	
	
	for(i=1;i<=maxn;i++){
		if(vis[i]==1){
			sum++;
//			cout<<i<<endl;
		}
	}
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll x;
  cin >> x;
  cout << (x >= 30 ? "Yes" : "No") << endl;
}

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

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

    string X;
    cin >> X;
    stack<char> stk;
    int cnt = 0;
    for (int i = 0; i < X.length(); i++) {
        if (stk.empty()) {
            stk.push(X[i]);
            continue;
        }
        if (X[i] == 'T') {
            if (stk.top() == 'S') {
                cnt += 2;
                stk.pop();
                continue;
            }
        }
        stk.push(X[i]);
    }
    cout << X.length() - cnt << endl;
}

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

typedef long long ll;
ll n, m, z, t1[2005],t2[2005],t3[2005], d[1005];
int main()
{
	ll i,j;
	cin >> n >> m;
	for (i = 0; i < m; i++) {
		scanf ("%lld %lld %lld", &t1[i], &t2[i], &t3[i]);
		t3[i] *= -1;
	}
	for (i = 2; i <= n; i++) d[i] = 9e15;
	for (i = 1; i <= n; i++) {
		for (j = 0; j < m; j++) {
			if (d[t2[j]] > d[t1[j]] + t3[j]) {
				d[t2[j]] = d[t1[j]] + t3[j];
				if (i==n && t2[j]==n) z = 1;
			}
		}
	}
	if (z) cout << "inf";
	else cout << -d[n];
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>							
typedef long long ll;
#define pb push_back
#define mod 1000000007ll
const ll maxn = 9e18;
using namespace std;
const ll maxsize = 100000009;



void solve() {
	int n;
	cin >> n; 
	int cnt = 0;
	for(int i = 1; i <= n; ++i) {
		int x;
		cin >> x;
		if(x != i) cnt++;
		}
		if(cnt == 2 || cnt == 0) cout << "YES" << endl;
		else cout << "NO" << endl;
		return;
}
	
	

int main() {
	ios_base :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cout.precision(35);
	int t;
	solve();
	return 0;
}
 
 
 
 


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

using namespace std;

int main() {
    int n;
    cin >> n;
    int vec[n];
    for(int i = 0; i < n; i++) {
        cin >> vec[i];
        }
    sort(vec, vec+n);

    int max = vec[n-1];
    int sum = 0;
    
    for(int i = 0; i < n-1; i++) {
        sum = sum + vec[i];
    }

    if(max < sum){
        cout << "Yes" << endl;
    }
    if(max >= sum){
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <bitset>
using namespace std;
 
int n, sum;
 
bitset<4000005> B;
 
int main() {
	int i, x; 
	scanf("%d", &n);
	B[0]=1;
	for(i = 1; i <= n; ++i) {
		scanf("%d", &x); sum += x;
		B |= B<<x;
	}
	for(i = sum/2+sum%2; !B[i]; ++i);
	printf("%d\n", i);
}

Measured memory_bytes: 1664
using System;

public class Program
{
  public static void Main(string[] args)
  {
    string[] nml = Console.ReadLine().Split(' ');
    int n = int.Parse(nml[0]);
    int m = int.Parse(nml[1]);
    int l = int.Parse(nml[2]);
    int[,] A = new int[n,m];
    int[,] B = new int[m,l];
    long[,] C = new long[n,l];
    for(int i = 0;i < n;i++)
    {
      string[] readA = Console.ReadLine().Split(' ');
      for(int j = 0;j < m;j++)
      {
        A[i,j] = int.Parse(readA[j]);
      }
    }
    for(int i = 0;i < m;i++)
    {
      string[] readB = Console.ReadLine().Split(' ');
      for(int j = 0;j < l;j++)
      {
        B[i,j] = int.Parse(readB[j]);
      }
    }
    for(int i = 0;i < n;i++)
    {
      for(int j = 0;j < l;j++)
      {
        for(int k = 0;k < m;k++)
        {
          C[i,j] += A[i,k] * B[k,j];
        }
      }
    }
    for(int i = 0;i < n;i++)
    {
      for(int j = 0;j < l;j++)
      {
        Console.Write(C[i,j]);
        if(j != l - 1) Console.Write(" ");
      }
      Console.WriteLine();
    }
  }
}

Measured memory_bytes: 9592