akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n;
  cin >> n;
  
  vector<int> p(n);
  for (int i = 0; i<n; i++){
    cin >> p.at(i);
  }
  
  vector<int> a(n);
  for (int i=0; i<n; i++){
    a.at(i) = i+1;
  }
  
  int cnt = 0;
  for (int i=0; i<n; i++){
    if (a.at(i) != p.at(i)) cnt++;
  }
  
  if (cnt <= 2) cout << "YES" << endl;
  else cout << "NO" << endl;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll ; 
typedef long double ld ;
typedef pair<ll , ll> pll ;

const ll N = 2e5 + 30 , Mod = 1e9 + 7 ;
const ll SQ = 330 ;

ll d[N] ;
int main () {
    ios::sync_with_stdio(0), cin.tie(0) ;
    ll n , m ;
    cin >> n >> m ;
    while (m --) {
    	ll v,  u;
    	cin >> v >> u ;
    	d[v] ++ ;
    	d[u] ++ ;
	}
    for (int i = 1;  i <= n ; i ++) 
    	if (d[i] & 1)
    		return cout << "NO" , 0 ;
    cout << "YES" ;
    return (0) ;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n; cin>>n;
	string s; cin>>s;
	for(char c: s){
		char tmp;
		if(char(c + n) <= 'Z'){
			tmp = char(c + n);
		}
		else{
			tmp = char(char(int(c + n) - 26));
		}
		cout<<tmp;
	}
}


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

 int main() {
 int a ,b;
 cin >> a >> b;
 if((a + b) % 2 == 1){
 cout << (a + b + 1) / 2 << endl;
 }
 else{
 cout << (a + b) / 2 << endl;
}
}





Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int a[5003][5003];
int ln=1;int g;
void add(int k)
{
	int i;
	for(i=1;i<=ln;i++)
	a[k][i]=a[k-1][i]+a[k-2][i];
	for(i=1;i<=ln;i++)
	if(a[k][i]>=10)
	{
		a[k][i+1]+=a[k][i]/10;
	    a[k][i]=a[k][i]%10;
	    if(a[k][ln+1])ln++;
	}
}
int main()
{
	
	cin>>g;
    a[1][1]=2; a[2][1]=1;
    for(int i=3;i<=g+1;i++)
    {
    	add(i);
	}
	for(int i=ln;i>=1;i--)
	printf("%d",a[g+1][i]);
		
}

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

int main()
{
	int m, d, c = 0, i, j, uni, dec;
	scanf("%d %d", &m, &d);
	for (i = 1; i <= m; i++) {
		for (j = 10; j <= d; j++) {
			dec = j / 10;
			uni = j % 10;
			if (dec * uni == i and dec >= 2 and uni >= 2)
				c++;
		}
	}
	printf("%d\n", c);
	return 0;
}

Measured memory_bytes: 256
<?php
$A=array('S'=>array(),'H'=>array(),'C'=>array(),'D'=>array());
fscanf(STDIN,"%d",$x);
for($i=0;$i<$x;$i++){
    fscanf(STDIN,"%c %d",$c,$d);
    $A[$c][$d]=1;
}
while($C = current($A)){
    for($i=1;$i<=13;$i++){
        if(!array_key_exists($i,$C)){
            echo key($A)." ".$i."\n";
        }
    }
    next($A);
}
?>


Measured memory_bytes: 9260
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int T = scan.nextInt();
        int A = scan.nextInt();
        double min_abs = Double.MAX_VALUE;
        int answer = 0;
        for (int i = 0; i < N; i++) {
            int h = scan.nextInt();
            double x = (double) T - 0.006 * h;
            double abs = Math.abs(x - A);
            if (abs < min_abs) {
                min_abs = abs;
                answer = i + 1;
            }
        }
        System.out.println(answer);
    }
}


Measured memory_bytes: 22736
#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>
#include <vector>
#include <map>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define TRACE(x) cout << #x << " = " << x << endl
#define _ << " _ " <<

typedef long long llint;

int main(void) {
  int N;
  scanf("%d", &N);

  map<llint, int> cnt;
  llint pref = 0;
  cnt[pref]++;

  llint ret = 0;
  REP(i, N) {
    int x;
    scanf("%d", &x);
    pref += x;
    ret += cnt[pref];
    cnt[pref]++;
  }

  printf("%lld\n", ret);
  return 0;
}


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

 using namespace std;

 int main() {
   int N, M, i, j, min, ans;

   cin >> N >> M;

   vector<int> a(N + 1);
   vector<int> b(N + 1);
   vector<int> c(M + 1);
   vector<int> d(M + 1);

   for (i = 1; i <= N; i++) cin >> a.at(i) >> b.at(i);
   for (i = 1; i <= M; i++) cin >> c.at(i) >> d.at(i);

   vector<vector<int>> distance(N + 1, vector<int>(M + 1));

   for (i = 1; i <= N; i++) {
     for (j = 1; j <= M; j++) {
       distance.at(i).at(j) = abs(a.at(i) - c.at(j)) + abs(b.at(i) - d.at(j));
     }
   }

   for (i = 1; i <= N; i++) {
     min = 400000000;
     for (j = 1; j <= M; j++) {
       if (distance.at(i).at(j) < min) {
         min = distance.at(i).at(j);
         ans = j;
       }
     }
     cout << ans << endl;
   }
 }


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

using ll = long long;

template <typename T>
class node {
public:
	node<T> *l, *r;
	T val, add;
	node(T val_ = 0, node<T>* l_ = nullptr, node<T>* r_ = nullptr) :
		l(l_), r(r_), val(val_), add(0) {}
};

template <typename T>
class RARS {
	const ll n;
	node<T> *root;
	ll size(ll n) {
		ll res = 1;
		while (res < n) res <<= 1;
		return res;
	}
	T sub(ll l, ll r, node<T>* n, ll lb, ll ub) {
		if (ub <= l || r <= lb) return 0;
		if (l <= lb && ub <= r) return n->val + n->add * (ub - lb);
		return n->add * (min(r, ub) - max(l, lb)) + (n->l != nullptr ? sub(l, r, n->l, lb, (lb + ub) / 2) : 0) + (n->r != nullptr ? sub(l, r, n->r, (lb + ub) / 2, ub) : 0);
	}
	void suc(ll l, ll r, node<T>* n, ll lb, ll ub, T val) {
		if (ub <= l || r <= lb) return;
		if (l <= lb && ub <= r) {
			n->add += val;
			return;
		}
		n->val += val * (min(r, ub) - max(l, lb));
		if (n->l == nullptr) {
			n->l = new node<T>();
		}
		if (n->r == nullptr) {
			n->r = new node<T>();
		}
		suc(l, r, n->l, lb, (lb + ub) / 2, val);
		suc(l, r, n->r, (lb + ub) / 2, ub, val);
	}
public:
	RARS(ll n_) :
		n(size(n_)) {
		root = new node<T>();
	}
	void add(ll l, ll r, T val) {
		suc(l, r + 1, root, 0, n, val);
	}
	T getSum(ll l, ll r) {
		return sub(l, r + 1, root, 0, n);
	}
};

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int n, q;
	cin >> n >> q;
	RARS<ll> lst(n);
	for (int i = 0, type, s, t, x; i < q; i++) {
		cin >> type >> s >> t; s--; t--;
		if (type) {
			printf("%lld\n", lst.getSum(s, t));
		}
		else {
			cin >> x;
			lst.add(s, t, x);
		}
	}
	return 0;
}

Measured memory_bytes: 10780
#include<stdio.h>

int N, K;

int main(void){
  int now = 1;
  int i, next;
  scanf("%d %d", &N, &K);

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

  printf("%d", now);

  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define x first
#define y second
#define ndl '\n'
#define mp make_pair
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)x.size()
#define bit __builtin_popcount
#define all(x) x.begin(),x.end()
#define show(x) cout<<(#x)<<" is "<<(x)<<endl

using namespace std;
using namespace __gnu_pbds;

template<typename T> using indexed_set=tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef vector<vector<int>> matrix;

const ll INF=1e18+123;
const ld EPS=1e-9;
const int inf=1e9+123;
const int MOD=1e9+7;
const int N=5e5+123;
const int M=1e6+123;
const int dx[]={0,0,1,-1};
const int dy[]={1,-1,0,0};

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll n,p;
    cin>>n>>p;
    if(n==1){
        cout<<p;
        return 0;
    }
    ll ans=1;
    for(ll i=2;i*i<=p;i++){
        if(p%i==0){
            ll d=i;
            ll x=p;
            int cnt=0;
            while(x%d==0){
                cnt++;
                x/=d;
            }
            if(cnt>=n){
                ans=max(ans,i);
            }
            d=p/i;
            x=p;
            cnt=0;
            while(x%d==0){
                cnt++;
                x/=d;
            }
            if(cnt>=n){
                ans=max(ans,i);
            }
        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define turbo cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
#define ll long long
#define pii pair<int,int>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define inf 99999999

using namespace std;

int dp[100015];
int tab[115];


int main(){
    turbo
    int n,k;
    cin >> n >> k;
    for(int i=1;i<=n;i++){
      cin >> tab[i];
    }
    for(int i=1;i<=k;i++){
      for(int j=1;j<=n;j++){
        if(i-tab[j] >= 0){
          if(dp[i-tab[j]] == 0){
            dp[i] = 1;
            break;
          }
        }
      }
    }
    if(dp[k]){
      cout << "First" << "\n";
    }
    else{
      cout << "Second" << "\n";
    }
    return 0;
}


Measured memory_bytes: 640
s=input()
if s[0]!='A' or s[1]=='C' or s[-1]=='C' or s[1].isupper() or s[2:-1].count('C')!=1:
  print('WA')
  exit()
  
s=''.join([c for c in s[1:] if c!='C'])
if s.islower():
  print('AC')
else:
  print('WA')

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>
#include <tuple>
#include <array>

#ifdef _MSC_VER
#include <agents.h>
#endif

#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define REV(v) v.rbegin(), v.rend()
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define X first
#define Y second

using namespace std;

typedef long long ll;

// Verified: AOJ 0502

#include <vector>

struct Dice{
private:
	static const int _roll[4][6], _turn[2][6];
public:
	vector<int> value;
	// 1-6 : top, near, right, left, far, bottom 

	Dice(){
		value.resize(6);
		for (int i = 0; i < 6; ++i) value[i] = i;
	}
	Dice(initializer_list<int> il){
		value.resize(6, -1);
		int cnt = 0;
		for (auto &e : il){
			value[cnt++] = e;
			if (cnt >= 6) break;
		}
		for (int i = 0; i < 6; ++i) if(value[i] < 0) value[i] = 5-value[5-i];
	}

	void roll(int dir){ // N, E, W, S
		vector<int> nxt(6);
		for (int i = 0; i < 6; ++i){
			nxt[i] = value[_roll[dir][i]];
		}
		value = nxt;
	}

	void turn(int dir){ // L, R
		vector<int> nxt(6);
		for (int i = 0; i < 6; ++i){
			nxt[i] = value[_turn[dir][i]];
		}
		value = nxt;
	}

	int &operator[](int i){
		return value[i];
	}
};

const int Dice::_roll[4][6] = {
	{ 1, 5, 2, 3, 0, 4 }, // North
	{ 3, 1, 0, 5, 4, 2 }, // East
	{ 2, 1, 5, 0, 4, 3 }, // West
	{ 4, 0, 2, 3, 5, 1 }, // South
};

const int Dice::_turn[2][6] = {
	{ 0, 3, 1, 4, 2, 5 }, // Left
	{ 0, 2, 4, 1, 3, 5 }, // Right
};



int main(){
	int dir[256];
	rep(i, 4) dir["news"[i]] = i;

	int n;
	while (cin >> n, n){
		Dice d({ 0, 4, 3 });
		rep(i, n){
			string s;
			cin >> s;
			d.roll(dir[s[0]]);
		}
		cout << d[0] + 1 << endl;
	}

	return 0;
}

Measured memory_bytes: 1220
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int n,i,j,k,l,count=0;
    while(scanf("%d",&n)!=EOF){
        count=0;
        if(n>=37)
            printf("%d\n",count);
        else{
            for(i=0;i<=9;i++)
                for(j=0;j<=9;j++)
                    for(k=0;k<=9;k++)
                        for(l=0;l<=9;l++)
                            if(i+j+k+l==n){
                                //printf("(%d,%d,%d,%d)\n",i,j,k,l);
                                count++;
                            }
        printf("%d\n",count);
        }
        
    }
    return 0;
}

Measured memory_bytes: 596
import itertools

n, m, q = map(int, input().split())
abcd = []
a_pre = [] 


for i in range(q):
  abcd.append(list(map(int, input().split())))

lis = [i for i in range(1, m + 1)]
for pair in itertools.combinations_with_replacement(lis, n):
  a_pre.append(list(pair))

sum = 0
for i in range(len(a_pre)):
  sum_pre = 0
  for j in range(len(abcd)):
    if a_pre[i][abcd[j][1] - 1] - a_pre[i][abcd[j][0] - 1] == abcd[j][2]:
      sum_pre = sum_pre + abcd[j][3]
  if sum_pre > sum:
    sum = sum_pre

print(sum)

Measured memory_bytes: 22908
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  int n;
  cin>>n;
  ll a[n+1]={};
  ll p[n+1]={};
  p[0]=0;
  for(int i=1;i<=n;i++){
    cin>>a[i];
    p[i]=p[i-1]+a[i];
  }
  ll ans=1e16;
  ll dif[4];
  int l=1,r=3;
  for(int i=2;i<=n-2;i++){
    while(l<i&&abs(p[l]-(p[i]-p[l]))>=abs(p[l+1]-(p[i]-p[l+1])))
    l++;
    while(r<n&&abs(p[r]-p[i]-(p[n]-p[r]))>=abs(p[r+1]-p[i]-(p[n]-p[r+1])))
    r++;
    dif[0]=p[l];dif[1]=p[i]-p[l];dif[2]=p[r]-p[i];dif[3]=p[n]-p[r];
    sort(dif,dif+4);
    ans=min(ans,dif[3]-dif[0]);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3328
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<math.h>
#include<tuple>
#include<string.h>
#include <numeric> 
#include<unordered_map>
using namespace std; 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define pp(...) "\033[94m [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define pp1(...) "\033[1;47;35m" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define dg(x) debug() << pp1(x)
#define dg1(x) debug() << "[line : " << __LINE__ <<"]"<< pp(x)
#define dg2(x,y) debug() << "[line : " << __LINE__ <<"]"<< pp(x) pp(y)
#define dg3(x,y,z) debug() << "[line : " << __LINE__ <<"]"<< pp(x) pp(y) pp(z)
#define dg4(w,x,y,z) debug() << "[line : " << __LINE__ <<"]"<< pp(w) pp(x) pp(y) pp(z)
template<typename T> void db(T x ){ debug() <<">>> " <<  x; }
template<typename T> void db(T x , T y){ debug() <<">>> " <<  x <<" , "<< y; }
template<typename T> void db(T x , T y , T z){ debug() <<">>> "<< x <<" , "<< y <<" , "<< z; }
template<typename T> void db(T x , T y , T z , T a){ debug() <<">>> "<< x <<" , " << y <<" , "<< z <<" , "<< a; }
#define int long long
#define all(x) x.begin() , x.end()
#define clr(x , y) memset(x , y , sizeof x);
#define sz(x) (int)x.size()

const int Mod = 1e9 + 7;
const int inf = 1e18;

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  string s;
  cin >> s;
  int open = 0 , close = 0;
  for(int i = 0; i < n; i++) {
    if(s[i] == '(') open++;
    else if(s[i] == ')') {
      if(open > 0) open--;
    }
  } 
  for(int i = 0; i < open; i++) {
    s += ')';
  }
  open = 0;
  for(int i = 0; i < sz(s); i++) {
    if(s[i] == '(') open++;
    else if(s[i] == ')') {
      if(open > 0) open--;
      else if(open == 0) close++;
    }
  }
  for(int i = 0; i < close; i++) {
    s = '(' + s;
  }
  cout << s << '\n';
}

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

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

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

int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};

int main(){
    int n, a, b; cin>>n>>a>>b;
    if((b-a-1)%2 == 0) cout << "Borys" << endl;
    else cout << "Alice" << endl;
}

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

int read()
{
	int f = 1 , x = 0 ; char s = getchar() ;
	while ( s < '0'  || s > '9') { if ( s == '-' ) f = -1 ; s = getchar() ; } 
	while ( s >= '0' && s <= '9' ) x = x * 10 + s - '0' , s = getchar() ;
	x *= f ;
	return x ;
 }  
 
void put ( int x )
{
	if ( x < 0 ) putchar ( '-' ) , x = -x ;
	if ( x > 9 ) put ( x / 10 ) ; 
	putchar ( x % 10 + '0' ) ;
}

int main () 
{
    int a , b ;
    a = read() ; b = read() ;
    if ( a * b % 2 == 1 ) cout << "Yes" ;
     else cout << "No" ;
	return 0 ;  
}


Measured memory_bytes: 256
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;

public class Main {
    static Input in = new Input(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int A = in.nextInt();
        int B = in.nextInt();
        int H = in.nextInt();
        int M = in.nextInt();

        double r = 2 * Math.PI * ((H / 12d) + (M / 60d / 12d) - (M / 60D));
        out.println(Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(r)));

        out.flush();
    }

    static class Input {
        private BufferedReader br;
        private String[] buff;
        private int index = 0;

        Input(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
        }
        String nextLine() {
            try {
                return br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return null;
        }
        String next() {
            while (buff == null || index >= buff.length) {
                buff = nextLine().split(" ");
                index = 0;
            }
            return buff[index++];
        }
        byte nextByte() {
            return Byte.parseByte(next());
        }
        short nextShort() {
            return Short.parseShort(next());
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        float nextFloat() {
            return Float.parseFloat(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        BigInteger nextBigInteger() {
            return new BigInteger(next());
        }
        BigDecimal nextBigDecimal() {
            return new BigDecimal(next());
        }
    }
}



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

using namespace std;

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

    #ifndef ONLINE_JUDGE
//        freopen("in.txt", "r", stdin);
//        freopen("out.txt", "w", stdout);
    #endif // ONLINE_JUDGE
    int x; cin>>x;
    int temp = x /500;
    int ans = 1000*(temp);
    x -= 500*temp;
    x /= 5;
    ans += 5*(x);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		if (n == 5 || n == 7 || n == 3) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}

}


Measured memory_bytes: 21460
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int N=sc.nextInt();
        int K=sc.nextInt();
        int num=0;
        Integer h[]=new Integer[N];
        for(int i=0;i<N;i++){
            h[i]=sc.nextInt();
            if(h[i]>=K)num++;
        }
        System.out.println(num);
    }
}

Measured memory_bytes: 60208
n, a, b = map(int, input().split())

participants = input()

count = 0
b_count = 1
for participant in participants:

    if participant == "a" and count < a+b:
        print("Yes")
        count += 1
    elif participant == "b" and count < a+b:
        if b_count <= b:
            count += 1
            b_count += 1
            print("Yes")
        else:
            print("No")
    else:
        print("No")
    

Measured memory_bytes: 4016
n,m,k=map(int,input().split())
mod=pow(10,9)+7


# コンビネーション、さらに高速。あらかじめO(N)の計算をすることでのちの計算が早くなる
def cmb(n,r,mod):
  if (r<0 or r>n):
    return 0
  r=min(r,n-r)
  return g1[n]*g2[r]*g2[n-r]%mod
g1=[1,1] # g1[i]=i! % mod　:階乗
g2=[1,1] # g2[i]=(i!)^(-1) % mod　:階乗の逆元
inverse=[0,1]
for i in range(2,n*m+1):
  g1.append((g1[-1]*i)%mod)
  inverse.append((-inverse[mod%i]*(mod//i))%mod)
  g2.append((g2[-1]*inverse[-1])%mod)

ans=0
for d in range(1,n):
  tmp=d*(n-d)*m**2
  tmp%=mod
  tmp*=cmb(n*m-2,k-2,mod)
  ans+=tmp
  ans%=mod
for d in range(1,m):
  tmp=d*(m-d)*n**2
  tmp%=mod
  tmp*=cmb(n*m-2,k-2,mod)
  ans+=tmp
  ans%=mod
print(ans)

Measured memory_bytes: 33164
#include <stdio.h>

int main(void)
{
	int H,W,i,a;
	
	while(1){
	
	scanf("%d%d\n",&H,&W);
	
	if(W==0 && H==0){
		break ;
	}
	
	for( i=0 ; i<H ;i++){
		
		for( a=0 ; a<W ; a++){
			
			printf("#");
		}
		printf("\n");
	}
	printf("\n");
	
	}
	return 0;
}

Measured memory_bytes: 576
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
int main() {
  int N, K, R, S, P;
  string T;
  cin >> N >> K >> R >> S >> P;
  cin >> T;
  vector<vector<ll> > dp(N, vector<ll>(3));
  int point[3] = {R, S, P};
  char rsp[3] = {'r', 's', 'p'};
  rep(i, N) rep(j, 3) {
    if(T[i] == rsp[j]) {
      T[i] = rsp[(j+2)%3];
      break;
    }
  }
  rep(i, N) {
    if(i < K) {
      rep(j, 3) {
        if(T[i] == rsp[j])
          dp[i][j] = point[j];
      }
    } else {
      rep(j, 3) {
        rep(k, 3) {
          if(j == k) continue;
          if(T[i] == rsp[j])
            dp[i][j] = max(dp[i-K][k]+point[j], dp[i][j]);
          else
            dp[i][j] = max(dp[i-K][k], dp[i][j]);
        }
      }
    }
  }
  ll ans = 0;
  RREP(i, N-1, N-K) {
    ll mx = 0;
    rep(j, 3) mx = max(dp[i][j], mx);
    ans += mx;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5760
#include <math.h>
#include <utility>
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;

int a[1000][1000];
int b[1001][1001];

int main(){
	int h;
	int w;
	int n;
	int x;
	int y;
	while(true) {
		cin >> h >> w >> n;
		if ( h == 0 ) break;
		for ( int i = 0; i < h; i++ ) {
			for ( int j = 0; j < w; j++ ) {
				int k;
				cin >> k;
				a[j][i] = k;
				b[j][i] = 0;
			}
		}
		b[0][0] = n - 1;
		for ( int i = 0; i < h + w - 1; i++ ) {
			for ( int j = 0; j < i + 1; j++ ) {
				x = i - j;
				y = j;
				if ( x >= w || y >= h ) continue;
				if ( b[x][y] % 2 == 1 ) {
					a[x][y] = 1 - a[x][y];
					if ( a[x][y] == 0 ) {
						b[x+1][y] += b[x][y] / 2 + 1;
						b[x][y+1] += b[x][y] / 2;
					}else {
						b[x+1][y] += b[x][y] / 2;
						b[x][y+1] += b[x][y] / 2 + 1;
					}
				}else {
					b[x+1][y] += b[x][y] / 2;
					b[x][y+1] += b[x][y] / 2;
				}
			}
		}
		x = 0;
		y = 0;
		while(true) {
			if ( a[x][y] == 1 ) {
				x++;
			}else {
				y++;
			}
			if ( x == w || y == h ) break;
		}
		cout << y+1 << " " << x+1 << endl;
	}
	return 0;
}

Measured memory_bytes: 8980
/*"Success isn't permanent, failure isn't fatal,
                                      it's the courage to continue that counts"*/
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define ll long long 
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define pb push_back     
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN
const int mod=1e9+7;         
const int N=2e5+4;

int main()
{
	ll a,b,n;

	lscn(a); lscn(b); lscn(n);

	ll c;

	if(n<b)
	c=n;
	else
	{
		c=(n/b)*b;

		c--;
	}

	ll ans=(a*c)/b;

	ans-=a*(c/b);

	lpri(ans);
	

    return 0;
}

Measured memory_bytes: 3812
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
const int INF = 1e6;
using namespace std;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
int main(){
    while(true){
        int a,b; char op;
        cin >> a >> op >> b;
        if(op == '+') cout << a+b << endl;
        else if(op == '-') cout << a-b << endl;
        else if(op == '*') cout << a*b << endl;
        else if(op == '/') cout << a/b << endl;
        else break;
    }
}


Measured memory_bytes: 3088
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cstring>
#include <map>

using namespace std;

int main(int argc, char const *argv[])
{
    string S;
    int mod=0,cnt=0,idx=1;
    cin >> S;
    vector<int> mods(2019,0);
    mods[0]=1;
    for (int i = S.length()-1; i >= 0; i--)
    {
        int a = S[i]-'0';
        mod = (idx*a+mod)%2019;
        idx = idx *10%2019;
        mods[mod]++;
    }
    for (int i = 0; i < mods.size(); i++)
    {
        cnt += mods[i]*(mods[i]-1)/2;
    }
    cout << cnt;
    return 0;
}


Measured memory_bytes: 3728
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define FOR( v, c ) for ( auto &v : c )

#define EACH( it, c ) for ( auto it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()
#define DRANGE( c, p ) (c).begin(), (c).begin() + p, (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

int solve( int num )
{
	int res = 0;
	set<int> visited;
	while ( 10 <= num )
	{
		OSS oss;
		oss << num;
		string str = oss.str();

		int next = 0;
		REP( i, 1, str.size() )
		{
			string left = str.substr( 0, i );
			string right = str.substr( i );

			ISS iss1( left ), iss2( right );
			int a, b;
			iss1 >> a;
			iss2 >> b;
			next = max( next, a * b );
		}

		if ( EXIST( visited, next ) )
		{
			return -1;
		}
		visited.insert( next );
		num = next;
		res++;
	}

	return res;
}


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

	int q;
	cin >> q;

	REP( case_num, 0, q )
	{
		int num;
		cin >> num;

		cout << solve( num ) << endl;
	}

	return 0;
}

Measured memory_bytes: 1228
import java.util.*

fun main(args: Array<String>) {
    val scn = Scanner(System.`in`)
    val N = scn.nextInt()
    val R = scn.nextInt()

    if(N>=10){
        println(R)
        return
    }

    var ans = 0
    ans =  R+ 100*(10-N)
    println(ans)
}

Measured memory_bytes: 29352
import sys

def main():
    input = sys.stdin.readline
    H, W = map(int, input().split())
    C = [[int(c) for c in input().split()] for _ in range(10)]
    A = [list(map(int, input().split())) for _ in range(H)]

    dp = [[10**4] * 10 for _ in range(10)]
    for i in range(10):
        for j in range(10):
            for k in range(10):
                C[j][k] = min(C[j][k], C[j][i] + C[i][k])

    ans = 0
    for a in A:
        for i in a:
            if i == -1:
                continue
            ans += C[i][1]

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3444
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>
#include<stdio.h>

using namespace std;



long long n,x,re;
int main()
{
    cin>>n;
    vector<long long>v; 
    while(n--)
    {
        cin>>x;
        if(x%2==0)
        v.push_back(x);
    }
    for(long long i=0;i<v.size();i++)
    {
        while(v[i]%2==0)
        {v[i]=v[i]/2;
        re++;}
    }
    cout<<re;
    //system("pause");
    return 0;
}  

Measured memory_bytes: 896
#include<map>
#include<cstdio>
#include<iostream>
using namespace std;
map<string,int> mp;
string s,t;
int a,b;
string u;
int main()
{
	cin>>s>>t>>a>>b>>u;
	mp[s]=a,mp[t]=b;
	--mp[u];
	printf("%d %d\n",mp[s],mp[t]);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn = 200001;
int len, fid, dis;
vector < int > edge[maxn];
void dfs(int now, int last, int d = 1){
	if(d > dis){
		dis = d;
		fid = now;
	}
	for(auto &i : edge[now]){
		if(last != i){
			dfs(i, now, d + 1);
		}
	}
}
bool win[maxn];
int main(){
	cin >> len;
	win[1] = true;
	win[2] = false;
	for(int i = 3;i < maxn;++i)
		(win[i] = !win[i - 1] || !win[i - 2]);
	for(int i = 1;i < len;++i){
		int a, b;
		cin >> a >> b;
		edge[a].push_back(b);
		edge[b].push_back(a);
	}
	fid = 1;
	dfs(fid, fid);
	dis = 0;
	dfs(fid, fid);
	if(win[dis]){
		cout << "First\n";
	}
	else{
		cout << "Second\n";
	}
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using P = pair<ll, int>;

#define INF 1e18

struct Edge {
  int to;
  ll cost;
  Edge(int to, ll cost) : to(to), cost(cost) {}
};

string rev(string s) {
  reverse(s.begin(), s.end());
  return s;
}

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  vector<int> c(n);
  rep(i,n) cin >> s[i] >> c[i];
  rep(i,n) {
    s.push_back(rev(s[i]));
    c.push_back(c[i]);
  }
  int idcnt = 1;
  vector< vector<int> > id(n*2);
  rep(i,n*2) {
    int l = s[i].size();
    id[i].resize(l);
    rep(j,l) id[i][j] = idcnt++;
  }

  vector< vector<Edge> > G(idcnt);
  rep(i1,n*2) {
    int l1 = s[i1].size();
    rep(j,l1) {
      int v = id[i1][j];
      rep(i2,n*2) {
        if (i1/n==i2/n) continue;
        int l2 = s[i2].size();
        int w = min(l2,l1-j);
        if (s[i1].substr(j,w) != s[i2].substr(0,w)) continue;
        int u;
        if (l2 > w) u = id[i2][w];
        else if (l1-j > w) u = id[i1][j+w];
        else u = 0;
        G[v].emplace_back(u,c[i2]);
      }
    }
  }

  vector<ll> dist(idcnt,INF);
  priority_queue<P, vector<P>, greater<P>> q;
  auto push = [&] (int v, ll x) {
    if (dist[v] <= x) return;
    dist[v] = x;
    q.emplace(x,v);
  };

  rep(i,n) push(id[i][0],c[i]);
  while (!q.empty()) {
    int v;
    ll c;
    tie(c,v) = q.top(); q.pop();
    if (c != dist[v]) continue;
    for (auto e : G[v]) push(e.to,c+e.cost);
  }

  ll ans = dist[0];
  rep(i,n*2) {
    int l = s[i].size();
    rep(j,l) {
      string t = s[i].substr(j);
      if (t == rev(t)) ans = min(ans, dist[id[i][j]]);
    }
  }
  if (ans == INF) ans = -1;

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3792
import java.io.*;
import java.util.*;
import java.lang.Math.*;

public class Main {
    public static void main(String[] args) {
        new Main().main();
    }

    private void main() {
        int N, C, K;
        MyScanner scanner = new MyScanner();
        N = scanner.nextInt();
        C = scanner.nextInt();
        K = scanner.nextInt();
        List<Integer> list = new ArrayList<Integer>();
        for (int i = 0; i < N; i++) {
            list.add(scanner.nextInt());
        }
        Collections.sort(list);
        int busCount = 0;
        int current = 0;
        int time = -1;
        for (int i: list) {
            if (time == -1) {
                time = i;
                busCount++;
            }
            if ((time + K) < i) {
                busCount++;
                current = 0;
                time = i;
            }
            if (current >= C) {
                current = 0;
                busCount++;
                time = i;
            }
            current++;
        }
        System.out.println(busCount);
    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";

        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public String next() throws IOException {
            if (i < s.length) return s[i++];
            String line = br.readLine();
            while (line.equals("")) {
                line = br.readLine();
            }
            s = line.split(reg, 0);
            i = 0;
            return s[i++];
        }

        public int nextInt() {
            try {
                return Integer.parseInt(next());
            } catch (Exception e) {
                e.printStackTrace();
            }
            return 0;
        }

        public double nextDouble() {
            try {
                return Double.parseDouble(next());
            } catch (Exception e) {
                e.printStackTrace();
            }
            return 0;
        }

        public long nextLong() {
            try {
                return Long.parseLong(next());
            } catch (Exception e) {
                e.printStackTrace();
            }
            return 0;
        }
    }
}


Measured memory_bytes: 39212
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){

	int n;
	cin>>n;

	for(int i = 0; i < n; i++){
		int B=0,C=0;
		bool f=false;
		vector<int> numList;
		for(int j = 0; j < 10; j++){
			int t;
			cin>>t;
			numList.push_back(t);
		}

		for(int j = 0; j < 10; j++){
			int num=numList[j];
			if(num>B&&num>C){
				if(num-B>num-C){
					C=num;
				}
				else
					B=num;
			}
			else if(num>B){
				B=num;
			}
			else if(num>C)
				C=num;
			else{
				f=true;
				cout<<"NO"<<endl;
				break;
			}
		}
		if(!f)
			cout<<"YES"<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
string s1, s2;
const int N = 3010;
int f[N][N], fl[N][N];
void pr(int x, int y)
{
    if(x == 0 || y == 0) return;
    if(fl[x][y] == 0)
    {
        pr(x - 1, y - 1);
        printf("%c", s1[x - 1]);
    }
    else if(fl[x][y] == 1) pr(x - 1, y);
    else pr(x, y - 1);
}
int main()
{
    cin >> s1 >> s2;
    int n = s1.length(), m = s2.length();
    memset(f, 0, sizeof f);
    for(int i = 1; i <= n; i ++)
    {
        for(int j = 1; j <= m; j ++)
        {
            if(s1[i - 1] == s2[j - 1]) f[i][j] = f[i - 1][j - 1] + 1, fl[i][j] = 0;
            else if(f[i - 1][j] >= f[i][j - 1]) f[i][j] = f[i - 1][j], fl[i][j] = 1;
            else f[i][j] = f[i][j - 1], fl[i][j] = -1;
        }
    }
    if(f[n][m] == 0)
    {
        puts("");
        return 0;
    }
    pr(n, m);
    return 0;
}

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

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

Measured memory_bytes: 1024
#include <stdio.h>
#define N 100
#define INFTY 1000000
#define NO 0
#define DISCOVERY 1
#define FINISHING 2

int n,ans[N][N];

int prim() {
  int u,minv;
  int discover[N],parent[N],check[N];
  for(int i=0;i<n;i++){
    discover[i]=INFTY;
    parent[i]=-1;
    check[i]=NO;
  }
  discover[0]=0;
  while(1){
    minv=INFTY;
    u=-1;
    for(int i=0;i<n;i++){
      if(minv > discover[i] && check[i] != FINISHING){
	u=i;
	minv=discover[i];
      }
    }
    if(u==-1)break;
    check[u]=FINISHING;
    for(int v=0;v<n;v++){
      if(check[v]!=FINISHING && ans[u][v]!=INFTY){
	if(discover[v] > ans[u][v]){
	  discover[v]=ans[u][v];
	  parent[v]=u;
	  check[v]=DISCOVERY;
	}
      }
    }
  }
  int sum=0;
  for(int i=0;i<n;i++){
    if(parent[i]!=-1)sum+=ans[i][parent[i]];
  }
  return sum;
}

int main() {
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      int e;
      scanf("%d",&e);
      ans[i][j]=(e==-1)?INFTY:e;
    }
  }
  printf("%d\n",prim());
  return 0;
}



Measured memory_bytes: 2048
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#define F first
#define S second
using namespace std;

typedef long long ll;
ll s, d, b[5], c[5];
vector<pair<ll, ll> > a;
int main()
{
	ll i, t;
	cin >> b[0] >> b[1] >> c[0] >> c[1] >> c[2];
	b[2] = 1e9;
	d = b[0] + b[1];
	for (i = 0; i < c[0]; i++) scanf("%lld", &t), a.push_back({t, 0});
	for (i = 0; i < c[1]; i++) scanf("%lld", &t), a.push_back({t, 1});
	for (i = 0; i < c[2]; i++) scanf("%lld", &t), a.push_back({t, 2});
	sort(a.begin(), a.end());
	for (i = a.size() - 1; i >= 0; i--) {
		if (b[a[i].S] <= 0) continue;
		s += a[i].F;
		b[a[i].S]--;
		d--;
		if (d == 0) break;
	}
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 10348
import sys
sys.setrecursionlimit(200000)
def dfs(x,y):
  vis[x][y]=1
  now=s[x][y]
  b=now=='#'
  w=now=='.'
  for i in range(4):
    nx=x+dx[i]
    ny=y+dy[i]
    if not(0<=nx<r and 0<=ny<c) or vis[nx][ny] or s[nx][ny]==now:continue
    black,white=dfs(nx,ny)
    b+=black
    w+=white
  return b,w
r,c=map(int,input().split())
s=[input() for _ in range(r)]
vis=[[0]*c for _ in range(r)]
ans=0
dx=(-1,0,1,0)
dy=(0,-1,0,1)
for i in range(r):
  for j in range(c):
    if vis[i][j]:continue
    b,w=dfs(i,j)
    ans+=b*w
print(ans)

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

static const int lim = 1<<15+1;

int main(){
	
	int dp[1<<15+1]={0};
	int n, k;
	
	for(int a=0; a*a<lim; ++a){
	for(int b=a; b*b<lim; ++b){
	for(int c=b; c*c<lim; ++c){
	for(int d=c; d*d<lim; ++d){
	
		k = a*a+b*b+c*c+d*d;
		
		if(k<lim)
			dp[k]++;
	}}}}
	
	while(cin >> n, n){
	
		cout << dp[n] << endl;
	}
		
	return 0;
		
}

Measured memory_bytes: 1424
INF = 10000
n,k = map(int,input().split())
stair = list(map(int,input().split()))
dp = [0] *n
for i in range(1,n):
    dp[i] = dp[i-1]+abs(stair[i]-stair[i-1])
    for j in range(1,k+1):
        if(i - j >= 0):
            # print(i,i-j)
            dp[i] = min(dp[i], dp[i-j]+abs(stair[i]-stair[i-j]))
        # print(dp)



print(dp[-1])

Measured memory_bytes: 84840
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long x;
    cin >> x;
    if(x) cout << 0 << endl;
    else cout << 1 << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 3608
#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 k, x;
    cin >> k >> x;
    for (int i = x-k+1; i<= x+k-1; i++) {
        if (i != x+k-1) printf("%d ", i);
        else printf("%d\n", i);
    }
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double dlb;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;
typedef pair<ll, pair<ll,ll> > iii;

const int kn = 2e5 + 5;
const ll mod = 1e9 + 7;

#define x first
#define y second
#define _it iterator
#define pb push_back
#define pf push_front
#define ms(val,a) memset(a,val,sizeof(a))
#define ff(i,n) for(int i=1;i<=n;i++)
#define _ff(i,n) for(int i=n;i>=1;i--)
#define f(i,a,b) for(int i = a; i <=b; i++)
#define _f(i,a,b) for(int i = b; i>=a;i--)
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

ll n, par[kn];
ll ans = 0;

struct data{
	int x, y;
	int id;
};

bool option(data cac, data lon)
{
	if(cac.x != lon.x) return cac.x < lon.x;
	return cac.y < lon.y;
}

data a[2][kn];

int Find(int i)
{
	if(par[i] == i) return i;
	return par[i] = Find(par[i]);
}

void dj(int i, int j, int cost)
{
	int pi = Find(i), pj = Find(j);
	if(pi == pj) return;
	par[pi] = pj;
	ans += cost;
}

int la[2][kn], ra[2][kn];

set< iii > pq;

int main() {
	//freopen("a.inp","r",stdin);
	//freopen("a.out","w",stdout);
	cin >> n;
	ff(i,n) par[i] = i;
	ff(i,n)
	{
		cin >> a[0][i].x >> a[0][i].y;
		a[1][i].x = a[0][i].y; a[1][i].y = a[0][i].x;
		a[0][i].id = a[1][i].id = i;
		la[0][i] = la[1][i] = i-1;
		ra[0][i]=ra[1][i] = i+1;
	}
	la[0][1] = la[1][1] = -1;
	ra[0][n] = ra[1][n] = -1;
	sort(a[0]+1,a[0]+n+1,option);
	sort(a[1]+1,a[1]+n+1,option);
	for(int i = 2; i<=n; i++)
	{
		pq.insert(iii(a[0][i].x - a[0][i-1].x, ii(i,0)));
		pq.insert(iii(a[1][i].x - a[1][i-1].x, ii(i,1))); // 0 la day 1, 1 la day 2
	}
	while(pq.size())
	{
		iii tmp = *pq.begin();
		pq.erase(pq.begin());
		dj(a[tmp.y.y][tmp.y.x].id, a[tmp.y.y][tmp.y.x-1].id, a[tmp.y.y][tmp.y.x].x - a[tmp.y.y][tmp.y.x-1].x);
	}
	cout << ans;
}
//hahahahahahahahahhahahahahahaahahahahhahahahahahahah


Measured memory_bytes: 20480
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <sstream>

#include <memory>
#include <string>
#include <vector>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>
#include <algorithm>
#include <random>
#include <iomanip>
using namespace std;



int main(int argc, char *argv[]) {
    int n, k;
    vector<long long int> v;
    cin >> n >> k;
    int zeros = 0;
    for (int i = 0; i < n; i++) {
        long long int t;
        cin >> t;
        if (t == 0) zeros++;
        v.push_back(t);
    }
    v.push_back(0);
    if (k + zeros >= v.size()) {
        cout << 0 << endl;
        return 0;
    }
    unordered_map<int, unordered_map<int, long long int>> um1, um2;
    // [times][index]
    um1[0][0] = v[0];
    for (int i = 1; i < n; i++) {
        if (v[i] != v[0])
            um1[1][i] = v[i];
        else
            um1[0][i] = v[i];
    }
    um1[1][n] = 0;
    for (int i = 1; i < n; i++) {
        um2.clear();
        for (auto p1 : um1) {
            for (auto p2 : p1.second) {
                int times = p1.first;
                int index = p2.first;
                long long int c = p2.second;
                
                // change with last height
                if (times < k) {
                    if (um2[times + 1].find(index) == um2[times + 1].end())
                        um2[times + 1][index] = p2.second;
                    else
                        um2[times + 1][index] = min(p2.second, um2[times + 1][index]);
                }
                // not change
                if (um2[times].find(i) == um2[times].end())
                    um2[times][i] = max((long long int)0, v[i] - v[index]) + p2.second;
                else
                    um2[times][i] = min(um2[times][i], max((long long int)0, v[i] - v[index]) + p2.second);

                if (v[i] > 0 && times < k && 0) {
                    if (um2[times + 1].find(n) == um2[times + 1].end())
                        um2[times + 1][n] = p2.second;
                    else
                        um2[times + 1][n] = min(um2[times + 1][n], p2.second);
                }
            }
        }
        um1 = um2;

    }
    long long int res = -1;
    for (auto p1 : um1) {
        if (p1.first > k)
             continue;
        for (auto p2 : p1.second) {

            if (res == -1 || res > p2.second)
                res = p2.second;
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 4676
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)
MOD = 10 ** 9 + 7

H, W = map(int, input().split())
N = int(input())
A = list(map(int, input().split())) + [-1]

G = [[0] * W for _ in range(H)]

flag = True #右向き
h = 0
w = 0
k = 1
next_ = A[0]

while next_ > 0:
    G[h][w] = k
    next_ -= 1
    if flag:
        if w == W - 1:
            flag = False
            h += 1
        else:
            w += 1
    else:
        if w == 0:
            flag = True
            h += 1
        else:
            w -= 1


    if next_ == 0:
        next_ = A[k]
        k += 1

for g in G:
    print (*g)

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

vector<ll> factor(101,0);

void factorise( const ll x )
{
  ll y = x;
  ll cur = 2;
  while( y != 1 )
  {
    while ( y%cur == 0 && y != 1 )
    {
      y = y / cur;
      factor[cur]++;
    }
    cur++;
  }
}

void print_fact()
{
  for (ll i = 2; i < 101; i++)
  {
    if (factor[i]!=0) cout << i << " " << factor[i] << endl; 
  }
}

void comp_fact(ll n)
{
  for (ll i = 2; i <= n; i++)
  {
    factorise(i);
  }
}

ll cnt_fact(ll a)
{
  ll tmp = 0;
  for (ll i = 1; i < 101; i++)
  {
    if (factor[i]>=a) tmp++;
  }
  return tmp;
}

int main()
{
  ll n;
  cin >> n;

  if (n==1)
  {
    cout << 0 << endl;
    return 0;
  }

  comp_fact(n);

  ll a = cnt_fact(2);
  ll b = cnt_fact(4);
  ll c = cnt_fact(14);
  ll d = cnt_fact(24);
  ll e = cnt_fact(74);

  cout << e + d * (a-1) + b * (b-1) * (a-2) / 2 + c * (b-1) << endl;

  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
typedef long long ll;

const int INF = 1e9;
const long long LLINF = 1e18;

int k, s;
int main() {
    cin>>k>>s;

    ll ans=0;
    REP(i, 0, k+1){
        REP(j, 0, k+1){
            int n=s-i-j;

            if(n>=0 && n<k+1) ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
	int num;
	bool hasYellow = false;

	std::cin >> num;

	for (int i = 0; i < num; i++) {
		char ara;
		std::cin >> ara;

		if (ara == 'Y') {
			hasYellow = true;
		}
	}

	std::cout << (hasYellow ? "Four" : "Three") << std::endl;

	return 0;
}

Measured memory_bytes: 256