akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<utility>
#include<vector>
#include<algorithm>

using namespace std;

const long long mod=1000000007;

struct Cat{
	int c,w;
	int which;
	Cat(){}
	Cat(int a,int b,int x):c(a),w(b),which(x){}
};

bool operator<(const Cat &c1,const Cat &c2){
	return c1.c<c2.c;
}

vector<Cat> cats;
int N;

long long dp[2][10100];
long long tmp[10100];
int W;

void ins(Cat cat){
	int w=cat.w,c=cat.c;
	int id=cat.which;
//	printf("ins %d %d %d\n",c,w,id);
	for(int i=0;i<=W;i++){
		tmp[i]=0;
	}
	for(int i=0;i<=W;i++){
		tmp[i]=(tmp[i]+dp[id][i])%mod;;
		if(i+w<=W) tmp[i+w]=(tmp[i+w]+dp[id][i])%mod;
	}
	for(int i=0;i<=W;i++) dp[id][i]=tmp[i];
//	for(int i=0;i<=W;i++) printf("%d ",dp[id][i]);
//	printf("\n");
}

void del(Cat cat){
	int w=cat.w,c=cat.c;
	int id=cat.which;
//	printf("del %d %d %d\n",c,w,id);
	for(int i=0;i<=W;i++) tmp[i]=0;
	for(int i=0;i<=W;i++){
		tmp[i]=dp[id][i];
		if(i-w>=0){
		//	tmp[i]-=tmp[i-w];
			tmp[i]=(tmp[i]-tmp[i-w])%mod;
		}
	}
	for(int i=0;i<=W;i++) dp[id][i]=tmp[i];
//	for(int i=0;i<=W;i++) printf("%d ",dp[id][i]);
//	printf("\n");
}

long long sum[2][10100];
bool check2(int D){
//	printf("CHECK\n");
	for(int i=0;i<2;i++){
		sum[i][0]=dp[i][0];
		for(int j=1;j<=W;j++){
			sum[i][j]=sum[i][j-1]+dp[i][j];
			sum[i][j]%=mod;
		}
	}
	for(int x=1;x<=W;x++){
		if(dp[0][x]==0) continue;
		int l=max(1,x-D);
		int r=min(W,x+D);
	//	if(sum[1][r]-sum[1][l-1]>0){
		if(sum[1][r]!=sum[1][l-1]){
//			printf("ok %d\n",x);
			return true;
		}
	}
	return false;
}

bool check(int D){
//	printf("check %d\n",D);
	int le=0,ri=0;
	for(int i=0;i<=W;i++){
		dp[0][i]=0;
		dp[1][i]=0;
	}
	dp[0][0]=1,dp[1][0]=1;
	for(;ri<N;ri++){
		ins(cats[ri]);
		for(;cats[ri].c-cats[le].c>D;le++){
	//		printf("le=%d,dif=%d\n",le,cats[ri].c-cats[le].c);
			del(cats[le]);
		}
		bool flg=check2(D);
		if(flg) return true;
	}
	return false;
}

int main(){
	int NA,NB;
	scanf("%d%d%d",&NA,&NB,&W);
	for(int i=0;i<NA;i++){
		int m,c;
		scanf("%d%d",&m,&c);
		if(m>W) continue;
		cats.push_back(Cat(c,m,0));
	}
	for(int i=0;i<NB;i++){
		int m,c;
		scanf("%d%d",&m,&c);
		if(m>W) continue;
		cats.push_back(Cat(c,m,1));
	}
	sort(cats.begin(),cats.end());
	N=cats.size();
	int lb=-1,ub=1010010010;
	while(ub-lb>1){
		int mid=(ub+lb)/2;
		bool flg=check(mid);
		if(flg) ub=mid;
		else lb=mid;
	}
	printf("%d\n",ub);
	return 0;
}

Measured memory_bytes: 1448
#include<iostream>
using namespace std;
int main(){
    int j,i;
    cin>>j;
    char a[100];
    char b;
    for(i=0;i<j;i++){
        cin>>a[i];
    }
    for(i=0;i<j+1;i++)
        if(a[i]=='Y'){
            cout<<"Four"<<endl;
            return 0;}
        cout<<"Three"<<endl;
    return 0;
}


Measured memory_bytes: 256
N,M = [int(s) for s in input().split()]
ABs = [[int(s) for s in input().split()] for i in range(N)]
n = M
p = 0

for A, B in sorted(ABs, key=lambda AB: AB[0]):
    nbuy = B if n-B >= 0 else n
    p += A*nbuy
    n -= nbuy
    if n <= 0:
        break
print(p)

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

typedef long long int ll;
typedef vector<int> vi;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define pvec(v) for(auto e: v) cout << e << " ";
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define rep(i, a, b) for(int i = (a); i<(b); ++i)
#define pb push_back
#define INF 1000000005
#define MOD 1000000007
#define all(v) v.begin(), v.end()

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

ll power(ll x, ll y, ll p = MOD){  
    ll res = 1LL; 
    x = x % p;
    if (x == 0) return 0;
    while (y > 0){
        if (y & 1LL)  
            res = (res*x) % p;
        y = y>>1LL; 
        x = (x*x) % p;  
    }  
    return res;  
} 

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

	vector<int> adj[n + 1];
	int u, v, indegree[n + 1] = {0};
	for(int i = 0; i<m; ++i) {
		cin >> u >> v;
		adj[u].push_back(v);
		++indegree[v];
	}

	vector<int> d(n + 1, 0);
	bool done[n + 1] = {0};
	for(int i = 1; i<=n; ++i) {
		if(indegree[i] == 0 && !done[i]) {
			queue<int> q;
			q.push(i);
			done[i] = true;
			while(!q.empty()) {
				int u = q.front(); q.pop();

				for(int v: adj[u]) {
					if(indegree[v]) {
						d[v] = max(d[v], d[u] + 1);
						--indegree[v];

						if(indegree[v] == 0) {
							done[v] = true;
							q.push(v);
						}
					}
				}
			}
		}
	}

	int mx = 0;
	for(auto e: d) {
		mx = max(mx, e);
	}

	cout << mx << endl;
	return 0;
}

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

int main() {
  int n,w; cin>>n>>w;
  vector<int> weight(n+1), value(n+1);
  for(int i=1; i<=n; i++) cin>>weight[i]>>value[i];
  // 品物が1個のとき,2個のとき...と考える
  vector<vector<ll>> dp(n+1,vector<ll>(w+1,0));
  for(int i=1; i<=n; i++) {
    for(int j=1; j<=w; j++) {
      if(j-weight[i]<0) dp[i][j] = dp[i-1][j];
      else dp[i][j] = max(dp[i-1][j],dp[i-1][j-weight[i]]+value[i]);
    }
  }
  cout << dp[n][w] << endl;
}


Measured memory_bytes: 83004
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=3e5+5,M=2e4+5,inf=0x3f3f3f3f,mod=1e9+7;
#define mst(a,b) memset(a,b,sizeof a)
#define lx x<<1
#define rx x<<1|1
#define reg register
#define PII pair<int,int>
#define fi first
#define se second
#define pb push_back
#define il inline
int a[N],n; 
ll l[N],r[N];
int main(){
	scanf("%d",&n);
	priority_queue<int>qr;
	priority_queue<int,vector<int>,greater<int> >ql;
	ll s=0,t=0;
	for(int i=1;i<=3*n;i++){
		scanf("%d",&a[i]);
		if(i<=n) ql.push(a[i]),s+=a[i];
		else if(i<=2*n){
			s+=a[i];
			ql.push(a[i]);
			s-=ql.top();
			ql.pop();
		}
		else {
			qr.push(a[i]),t+=a[i];
		}
		if(i>=n&&i<=2*n) l[i]=s;
	}
	r[2*n+1]=t;
	for(int i=2*n;i>n;i--){
		 t+=a[i];
		 qr.push(a[i]);
		 t-=qr.top();
		 qr.pop();
		 r[i]=t;
	}
	ll ans=-1e15;
	for(int i=n;i<=2*n;i++){
		if(ans<l[i]-r[i+1]) ans=l[i]-r[i+1]; 
	} 
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 7068
program multiple_of_9
  implicit none
  character(200000) :: s
  integer(8) :: n = 0, m
  integer :: l, i
  read(*,'(a)') s
  l = len_trim(s)
  do i = 1, l, 10
    read(s(i:min(i + 9, l)),*) m
    n = n + m
  end do
  write(*,'(a)') trim(merge('Yes', 'No ', mod(n, 9_8) == 0))
end program multiple_of_9

Measured memory_bytes: 3156
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int D;
  cin>>D;
  int c[26];
  int s[D][26];
  int Tans[D];
  for(int i=0;i<26;i++){
    cin>>c[i];
  }
  for(int i=0;i<D;i++){
    for(int j=0;j<26;j++){
      cin>>s[i][j];
    }
  }
  for(int i=0;i<D;i++){
    Tans[i]=rand()%26+1;
    if(Tans[i]<Tans[i-1]){
      Tans[i-1]=Tans[i];
    }
    cout<<Tans[i]<<endl;
  }
  return 0;
}

Measured memory_bytes: 3664
#include<iostream>
using namespace std;
int main()
{
    long int a,b,c,k;
    cin>>a>>b>>c>>k;
    long int sum=0;
    

    for(long int i =1 ; i<=k ; i++)
    {
       if(i<=a) sum=sum+1;
       else if(i<=b+a && i>a) sum=sum+0 ;
       else sum=sum-1;
    }




    cout<<sum;

}


Measured memory_bytes: 3512
#include"bits/stdc++.h"

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

#define INF 1e10

using namespace std;

signed main(void) {
	int N, K;
	string  T;
	map<char, char> win;
	win['r'] = 'p';
	win['p'] = 's';
	win['s'] = 'r';
	map<char, int> point;

	cin >> N >> K >> point['r'] >> point['s'] >> point['p'] >> T;

	int total = 0;

	rep(i, K) {
		char prev = ' ';
		for (int j = i; j < N; j += K) {
			if (win[T[j]] == prev) {
				prev = ' ';
			}
			else {
				prev = win[T[j]];
				total += point[prev];
			}
		}
	}

	cout << total << endl;

	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)

#define DEBUG

#ifdef DEBUG
#define var_dump(...) fprintf(stdout, __VA_ARGS__)
#define dump(a) cout << a << "\n";
#else
#define var_dump(...) 42
#define dump(a) 42
#endif

// https://beta.atcoder.jp/contests/abc072/tasks/abc072_b

int main() {
    string s; cin >> s;
    REP(i, s.length()) {
        if (i % 2 == 0) cout << s[i];
    }
    cout << "\n";
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>


typedef long long ll;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBAC
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/
//copy(v1.begin(), v1.end(), back_inserter(v2));
using namespace std;

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

ll lcm(ll a, ll b) {
	ll c;
	c = a * b / gcd(a, b);
	return c;
}

int sort_greater(int m,int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(),greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
		return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

int a_z()
{
	for (int i = 0; i <= ('Z' - 'A'); i++) {
		cout << (char)('A' + i);
	}
	return 0;
}

int selecttionsort(int a[], int n) {
	int t,sw = 0, minj;
	for (int i = 0; i < n - 1; i++) {
		minj = i;
		for (int j = 0; j < n - 1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		t = a[i]; a[i] = a[minj]; a[minj] = t;
		if (i != minj) sw += 1;

	}
	return sw;
}

bool is_prime(int x) {
	if (x <= 1) return false;
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0) return false;
	}
	return true;
}

const int mod = 1000000007;
struct mint {
	ll x;
	mint(ll x = 0):x(x%mod){}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		res -= a;
	}
	mint operator*(const mint a)const {
		mint res(*this);
		return res *= a;
	}
};

map<string, int> memo;

using P=pair<int, int>;

struct Clock {
	int hour, minute, second;
	void set(int h, int m, int s) {
		hour = h; minute = m; second = s;
	}
	string to_str() {
		string h, m, s;
		h = to_string(hour);
		m= to_string(minute);
		s= to_string(second);
		if (h.size() < 2) h = "0" + h;
		if (m.size() < 2) m = "0" + m;
		if (s.size() < 2) s = "0" + s;
		return h + ":" + m + ":" + s;
	}
	void shift(int diff_second) {
		int h, m;
		h = diff_second / 3600;
		m = diff_second / 60;
		diff_second %= 60;
		second += diff_second;
		
	}
};


/*void dfs(int v, int p = -1) {
	for (int u : to[v]) {
		if (u == p) continue;
		ans[u] += ans[v];
		dfs(u, v);
	}
}*/
int main() {
	ll n, k,a;
	cin >> n >> k;
	a = n % k;
	if (a <= k - a) cout << a;
	else cout << k - a;
	return 0;
}










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

using namespace std;
using ll =long long;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
const ll INF = 1LL << 60;
const int mod = 1e9+7;
//Write From this Line

int main()
{
	string s;
	cin >> s;
	string S = "" ;
	rep(i,s.size()){
		char c = s[i] ;
		if(s[i] == 'A'){
			S.push_back('A');
		} else if (s[i] == 'B'){
			i ++ ;
			if(s[i] =='C'){
				S.push_back('D');
			} else {
				S.push_back(c);
				S.push_back(s[i]);
			}
		} else S.push_back(c);
	}
	s = S ;
	int n = s.size();
	int a_count = 0 ;
	ll ans = 0 ;
	rep(i,n){
		char c =s[i] ;
		if( c == 'A'){
			a_count ++; 
		} else if( c == 'D'){
			ans += a_count;
		} else a_count = 0 ;
	}
	cout << ans << endl;
}


Measured memory_bytes: 900
n,m=map(int,input().split())
x,y=[0]*m,[0]*m
res=[1]*n
red=[0 for i in range(n)]
red[0]=1
for i in range(m):
    x[i],y[i]=map(int,input().split())
    if red[x[i]-1]==0 and red[y[i]-1]==0:
        res[x[i]-1]-=1
        res[y[i]-1]+=1
    elif red[x[i]-1]>0 and red[y[i]-1]==0:
        res[x[i]-1]-=1
        red[x[i]-1]-=1
        res[y[i]-1]+=1
        red[y[i]-1]=res[y[i]-1]
    elif red[x[i]-1]==0 and red[y[i]-1]>0:
        res[x[i]-1]-=1
        res[y[i]-1]+=1
        red[y[i]-1]=res[y[i]-1]
    elif red[x[i]-1]>0 and red[y[i]-1]>0:
        res[x[i]-1]-=1
        red[x[i]-1]-=1
        res[y[i]-1]+=1
        red[y[i]-1]=res[y[i]-1]
cnt=0
for p in red:
    if p>0:
        cnt+=1
print(cnt)


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<double, P> edge;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3

struct UnionFind{
  vector<int> v;
  UnionFind(int n) : v(n, -1) {}

  int find(int x) { return v[x] < 0 ? x : v[x] = find(v[x]); }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (-v[x] < -v[y]) swap(x, y);
    v[x] += v[y]; v[y] = x;
    return true;
  }
  bool root(int x) { return v[x] < 0; }
  bool same(int x, int y) { return find(x) == find(y); }
  int size(int x) { return -v[find(x)]; }
};

int n;
double x[111],y[111],z[111],r[111];

int main(){
	cin.sync_with_stdio(false);
  while(1){
    cin>>n;
    if(n==0)break;
    rep(i,n)cin>>x[i]>>y[i]>>z[i]>>r[i];
    UnionFind uf(n);
    vector<edge> es;
    rep(i,n)rep(j,i){
      double dist=sqrt(pow(x[i]-x[j],2)+pow(y[i]-y[j],2)+pow(z[i]-z[j],2));
      if(dist<=r[i]+r[j]){
        uf.unite(i,j);
      }else{
        es.push_back(edge(dist-r[i]-r[j],P(i,j)));
      }
    }
    double res=0;
    sort(all(es));
    rep(i,es.size()){
      if(uf.same(es[i].se.fi,es[i].se.se))continue;
      uf.unite(es[i].se.fi,es[i].se.se);
      res+=es[i].fi;
    }
    printf("%.3f\n", res);
  }
	return 0;
}

Measured memory_bytes: 3224
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
using namespace std;
typedef long long ll;
typedef pair<string,int>P;
queue<P>O;
int N,Q,t,st=0;
string n;
int main()
{
	scanf("%d%d",&N,&Q);
	for(int i=0;i<N;i++)
	{
		
		cin>>n>>t;
		O.push(make_pair(n,t));
	}
	for(;!O.empty();)
	{
		P tmp=O.front();O.pop();
		st+=min(tmp.second,Q);
		if(tmp.second<=Q)
			cout<<tmp.first<<" "<<st<<endl;
		else
		{
			tmp.second-=Q;
			O.push(tmp);
		}
	}
}

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

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

  vector<int> vec(N);
  int val;

  for (size_t i = 0; i < N; i++)
  {
    vec[i] = L + i;
  }

  if (vec[0] > 0)
  {
    val = accumulate(vec.begin(), vec.end(), 0) - vec[0];
  }
  else if (vec[N-1] < 0)
  {
    val = accumulate(vec.begin(), vec.end(), 0) - vec[N-1];
  }
  else
  {
    val = accumulate(vec.begin(), vec.end(), 0);
  }
  

  cout << val << endl;
  return 0;
}

Measured memory_bytes: 764
from itertools import product

H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]
D = tuple(product((-1, 0, 1), repeat=2))

for h in range(H):
    for w in range(W):
        if S[h][w] == '#':
            continue
        cnt = 0
        for dh, dw in D:
            if 0 <= h + dh < H and 0 <= w + dw < W and S[h + dh][w + dw] == '#':
                cnt += 1
        S[h][w] = str(cnt)

for s in S:
    print(''.join(s))


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define ll         long long int
#define co         cout
#define ci         cin
#define sf1(n)     scanf("%lld",&n)
#define sf2(n,m)   scanf("%lld %lld",&n,&m);
#define sf3(n,m,p) scanf("%lld %lld %lld",&n,&m,&p)
#define pf1(n)     printf("%lld\n",n);
#define mem(a,b)   memset(a,b,sizeof(a))
#define en         cout<<endl;
#define pb         push_back
#define gcd(n,m)   __gcd(n,m)
#define lcm(n,m)   ((n)/__gcd(n,m))*(m)
#define fi         first
#define se         second
#define coy        cout<< "YES"<<endl;
#define con        cout<< "NO"<<endl;
#define f(a,b)     for(ll i=a;i<b;i++)
#define all(x)     (x).begin(),(x).end()
#define allr(x)    (x).rbegin(),(x).rend()
#define pi         pair<ll,ll>
#define br         break;
#define i64        long long
#define PI         2*acos(0.0)

int main()
{
    ll t,n,g,k,m,mx=1,mn=1e9,c,res,c1,x,y,w,z,c2;
    ci>>n;
    map<string,ll>mp;
    vector<string>a(n);
    f(0,n)
    {
        ci>>a[i];
        mp[a[i]]++;
        mx=max(mx,mp[a[i]]);
    }
    set<string>b;
    map<string,ll>::iterator it;
    for(it=mp.begin();it!=mp.end();it++)
    {
        if(it->se==mx) b.insert(it->fi);
    }
    set<string>:: iterator st;
    for(st=b.begin();st!=b.end();st++)
        co<<*st<<endl;
}



Measured memory_bytes: 40648
#include <bits/stdc++.h>   
                           
using namespace std;       
                           
int main() {               
  int n, q;                
  cin >> n;                
  vector<int> v;           
                           
  for (int i = 0; i < n; i++) { 
    int s; cin >> s;       
    v.push_back(s);        
  }                        
                           
  cin >> q;                
  long long int ans = 0;   
                           
  for (int i = 0; i < q; i++) { 
    int t; cin >> t;       
    if ( *lower_bound(v.begin(), v.end(), t) == t ) {
      ans++;               
    }                      
  }                        
  cout << ans << endl;     
  return 0;                
}                          


Measured memory_bytes: 3452
#include <iostream>
#include <string>
#include <vector> 
using namespace std;
int main(void){
	int n;
	cin>>n;
	int max=0;
	int count =0;
	for(int i=0;i<n;i++){
		int a;
		cin >>a;
		if(a>=max){
			max=a;
			count++;
		}
	}
	cout<<count;
	return 0;
}

Measured memory_bytes: 256
import sys
from collections import Counter
from itertools import accumulate
def input(): return sys.stdin.readline().rstrip()
def main():
    n,k=map(int,input().split())
    H=[int(input())for _ in range(n)]
    H.sort()
    ans=10**9
    for i in range(n-k+1):
        ans=min(ans,H[i+k-1]-H[i])
    print(ans)
if __name__=='__main__':
    main()

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

int main(){
	int n,m;
	cin >> n >> m;
	vector<pair<int,int> > AB(n+m);
	
	for(int i=0;i<n;++i){
		cin >> AB[i].first;
		AB[i].second = 1;
	}
	for(int i=n;i<n+m;++i){
		cin >> AB[i].second >> AB[i].first;
	}
	sort(AB.rbegin(),AB.rend());
/*	
	for(int i=0;i<AB.size();++i){
		cout << AB[i].first << " " << AB[i].second <<endl;
	}*/
//	cout << "input finish" <<endl;
	long long unsigned res = 0;
	int cnt = 0;
	int index = 0;
	while(cnt < n){
		//cout << index <<" " << cnt <<" "<< AB[index].first << endl;
		for(int i=0;i<AB[index].second && cnt < n;++i){
//			cout << res << index <<endl;
			res += AB[index].first;
			cnt++;
		}
		index++;
	}
	
	cout << res <<endl;
	
}



Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcountll
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    #define endl '\n'
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    string s;
    cin >> s;
    vector <char> a;
    for (char c : s) {
        if (c == 'T' && a.size() && a.back() == 'S') 
            a.pop_back();
        else
            a.app(c);            
    }   
    cout << a.size() << endl;
}

Measured memory_bytes: 788
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
	int N;
	long long K;
	scanf("%d %lld", &N, &K);
	int A[N], visited[N];
	fill_n(visited, N, 0);
	for (int i = 0; i < N; ++i) scanf("%d", &A[i]);
	int ptr = 0;
	for (long long i = 0; i < K; ++i) {
		if (visited[ptr] != 0) {
			vector<int> cycle;
			cycle.push_back(ptr);
			for (int j = A[ptr] - 1; j != ptr; j = A[j] - 1) cycle.push_back(j);
			printf("%d", cycle[(K - i) % cycle.size()] + 1);
			return 0;
		}
		visited[ptr] = 1;
		ptr = A[ptr] - 1;
	}
	printf("%d", ptr + 1);
	return 0;
}

Measured memory_bytes: 4908
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
int main(){
  int n,l;
  cin>>n>>l;
  int L=l;
  int R=l+n-1;
  int eat;
  if(L>=0){
    eat=L;
  }else if(R<=0){
    eat=R;
  }else{
    eat=0;
  }
  int ans=(L+R)*(R-L+1)/2-eat;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in =new Scanner(System.in);
        int n=0;
        String x=in.next();
        String y=in.next();
        for (int i = 0; i < x.length(); i++) {
            if(x.charAt(i)==y.charAt(i))n++;
        }
        System.out.println(n);
    }
}


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

int main() {
    double w,h,x,y;
    int k=0;
    cin>>w>>h>>x>>y;
    if(x*2==w && y*2==h)
	k++;
	w=(w*h)/2;
	cout<<fixed << setprecision(9) << w<<" "<<k;
	return 0;
}


Measured memory_bytes: 256
use proconio::fastout;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
        n: usize,
        m: usize,
        x: usize,
    }

    let mut c = vec![];
    let mut a = vec![];
    for _ in 0..n {
        input! {
            ci: isize,
            ai: [usize; m],
        }
        c.push(ci);
        a.push(ai);
    }

    let mut ans = isize::max_value();
    for bits in 1..(1 << n) {
        let mut cost = 0;
        let mut skill = vec![0; m];
        for i in 0..n {
            if bits >> i & 1 == 0 {
                continue;
            }
            cost += c[i];
            for (s, ai) in skill.iter_mut().zip(a[i].iter()) {
                *s += ai;
            }
        }
        if skill.into_iter().all(|s| s >= x) {
            ans = ans.min(cost);
        }
    }
    println!("{}", if ans == isize::max_value() { -1 } else { ans });
}


Measured memory_bytes: 2208
def main():
  import sys
  n = int(input())
  a = list(map(int,sys.stdin.readline().split()))
  b = list(map(int,sys.stdin.readline().split()))
  
  count=0
  buffer=0
  
  for c,h in zip(a,b):
    count += min(buffer,c)
    g = max(0,c-buffer)
    count += min(h,g)
    buffer=max(0,h-g)
  else:
    count+=min(buffer,a[-1])
    
    
  print(count)
  
if __name__=="__main__":
  main()

Measured memory_bytes: 19376
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define vi vector<int>
#define vll vector<long long>
#define FOR(n) for(int i=0;i<n;i++)
#define till(n) for(int i=1;i<=n;i++)
#define mod 1000000007
using namespace std;



int main(){
    //ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n, k; cin >> n >> k;
    bool win[k+1];
    int a[k];
    for(int i=0;i<n;i++)cin >> a[i];
    sort(a, a+n);
    win[0] = false;
    for(int i = 1;i<=k;i++){
        win[i] = false;
        for(int j=0;j<n;j++){
            if(a[j] <= i){
                if(win[i-a[j]] == false){
                    win[i] = true;
                    break;
                }
            }
            else break;
        }
    }

    //for(int i=0;i<=k;i++)cout<<win[i] << " ";

    cout << (win[k]?"First":"Second") << endl;

	return 0;
}


Measured memory_bytes: 384
#include<iostream>
using namespace std;
const long mod=1e9+7;
int N,K;
long power(long a,long b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}
long dp[1<<17];
main()
{
	cin>>N>>K;
	long ans=0;
	for(int k=K;k>=1;k--)
	{
		dp[k]=power(K/k,N);
		for(int j=k+k;j<=K;j+=k)dp[k]-=dp[j];
		ans+=k*dp[k]%mod;
	}
	cout<<ans%mod<<endl;
}


Measured memory_bytes: 4352
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;



#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)
#define MP(a,b) make_pair(a,b)

ll debugFlag = false;
template<typename T> void debug(T&);
template<typename T> void debug(T&, bool);
template<typename T> void debug(vector<T>&);
template<typename T> void debug(vector<T>&, bool);
template<typename T, typename U> void debug(pair<T, U>&);
template<typename T, typename U> void debug(pair<T, U>&, bool);

template<typename T>
void debug(T& obj) {
	debug(obj, true);
}

template<typename T>
void debug(T& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << obj;
	if (lnFlag) cout << endl;
}

template<typename T>
void debug(vector<T>& obj) {
	debug(obj, true);
}

template<typename T>
void debug(vector<T>& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << "[";
	rep(i, obj.size()) {
		if (i != 0) cout << ",";
		debug(obj[i], false);
	}
	cout << "]";
	if (lnFlag) cout << endl;
}

template<typename T, typename U>
void debug(pair<T, U>& obj) {
	debug(obj, true);
}

template<typename T, typename U>
void debug(pair<T, U>& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << "(";
	debug(obj.first, false);
	cout << ",";
	debug(obj.second, false);
	cout << ")";
	if (lnFlag) cout << endl;
}

void solve() {

	ll N,M;
	cin >> N >> M;
	if (N==M) {
		cout << "Yes";
	} else {
		cout << "No";
	}

}


int main(int argc, char* argv[]) {
	if (argc == 2 && string(argv[1]) == "debug") debugFlag = true;
	solve();
	return 0;
}

Measured memory_bytes: 3676
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 1e-5
#define LONG_INF 1000000000000000000LL
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL
#define MOD 998244353LL
#define seg_size 262144*4
#define REP(a,b) for(long long a = 0;a < b;++a)
int main() {
	long long n, k;
	cin >> n >> k;
	vector<long long> inputs;
	REP(i, n) {
		long long a;
		cin >> a;
		inputs.push_back(a);
	}
	long long ans = 2e18;
	for (int i = 0; i < (1 << n); ++i) {
		long long tmp = 0;
		long long now = 0;
		long long cnt = 0;
		for (int q = 0; q < inputs.size(); ++q) {
			if (((1 << q) & i)) {
				if (inputs[q] <= now) {
					tmp += (now + 1) - inputs[q];
					now++;
				}
				else {
					now = inputs[q];
				}
				cnt++;
			}
			else {
				now = max(now, inputs[q]);
			}
		}
		if (cnt >= k) {
			ans = min(ans, tmp);
		}
	}
	cout << ans << endl;
}

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

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

    string s;
    s = S.substr(0, 4);
    int y = stoi(s);
    S.erase(0,5);
    s = S.substr(0,2);
    int m = stoi(s);
    S.erase(0,3);
    int d = stoi(S);

    if(m >= 5){
        cout << "TBD" << endl;
    }else{
        cout << "Heisei" << endl;
    }


}

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

int main(){
  long long n,a[500000],ans = 0;
  cin >> n;
  for(int i=0;i<3*n;i++){
    cin >> a[i];
  }
  sort(a,a + 3 * n,greater<int>());
  for(int i = 1;i < 2*n;i+=2){
    ans += a[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3712
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <set>
#include <sstream>
#include <bitset>
#include <string>
#include <cctype>
#include <cstdio>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define all(x) (x).begin(),(x).end()
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)

int main() {
  int N, K; cin >> N >> K;
  string S; cin >> S;
  // cout << S << endl;
  S[K-1] += 0x20;
  cout << S << endl;



}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  int a,b;
  string s;
  cin>>s;
  if(s<="2019/04/30") cout<<"Heisei"<<'\n';
  else cout<<"TBD"<<'\n';
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int n;
    cin>>n;
    long a,sum= 0,max=-1000000,min=1000000;
    for(int i=0;i<n;i++){
        cin>>a;
	    if(a>max)max=a;
	    if(a<min)min=a;
	    sum+=a;
        
    }
	cout<<min<<" "<<max<<" "<<sum<<endl;
	return 0;
    
}


Measured memory_bytes: 3108
package main

import (
	"fmt"
	"math"
)

func main() {
	// Code for B - Tag
	var A, V int
	fmt.Scanf("%d %d", &A, &V)

	var B, W int
	fmt.Scanf("%d %d", &B, &W)

	var T int
	fmt.Scanf("%d", &T)

	C := int(math.Abs(float64(A - B)))

	if C <= T*(V-W) {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 1836
#include<iostream>
using namespace std;
main()
{
	int n,m,a,b,c[55]={0};cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		cin>>a>>b;
		c[a]++;
		c[b]++;
	}
	for(int i=1;i<=n;i++)cout<<c[i]<<endl;
	return 0;
}

Measured memory_bytes: 256
S = input()

arr = []
seq = 1
for i,(a,b) in enumerate(zip(S,S[1:])):
    if a==b:
        seq += 1
    else:
        arr.append(seq)
        seq = 1
arr.append(seq)

assert len(arr)%2==0

ans = [0]*len(S)
i = 0
for r,l in zip(arr[::2],arr[1::2]):
    i += r
    ans[i-1] = ans[i] = (r+l)//2
    if (r+l)%2:
        if r<l:
            if l%2:
                ans[i] += 1
            else:
                ans[i-1] += 1
        else:
            if r%2:
                ans[i-1] += 1
            else:
                ans[i] += 1
    i += l

print(*ans)

Measured memory_bytes: 11424
while True:
    n,x=map(int,input().split())
    cnt=0
    if n==0 and x==0:
        break

    for i in range(1,n+1):
        for j in range(i+1,n+1):
            num=x-i-j
            if j<num<=n:
                cnt+=1

    print(cnt)
    


Measured memory_bytes: 5596
#include<algorithm>//sort(all(変数),greater<型名>())　で降順に
#include<cmath>//切り上げceil(値)
#include<deque>
#include<iomanip>//setprecision(数字)
#include<iostream>
#include<list>
#include<map>
#include<numeric> //xとyの最大公約数は__gcd(x,y),xとyの最小公倍数は(x*y)/__gcd
#include<queue>//priority_queue<型名> 変数：優先度付きキュー　最大値の探索が早い
#include<set>
#include<stack>
#include<string>
#include<vector>

#include<bits/stdc++.h>
#include<cstdio>
#include<cstdlib>
#include<limits>
#include<tuple>
#include<utility>
#define rep0(i,n)  for(ll i=0; i<n; i++)
#define rrep0(i,n) for(ll i=n-1; 0<=i; i--)
#define rep1(i,n)  for(ll i=1; i<=n; i++)
#define rrep1(i,n) for(ll i=n; 1<=i; i--)
#define vll vector<ll>
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define INF 1e18
using ll = long long;
using namespace std;

int main(){
  int a,b;  cin >> a >> b;
  if(b % a == 0) cout << a+b;
  else cout << b-a;
}


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

using namespace std;

int main(void) {
  string s, t;

  getline(cin, s);
  getline(cin, t);

  int r = 0;
  for(int i = 0; i < 3; i++) {
    if(s[i] == t[i]) r++;
  }

  cout << r;

  return 0;
}

Measured memory_bytes: 256
n = int(input())
s = list(input())

S = [0] * n
countW = 0
for i in range(n):
    if s[i] == "W":
        S[i] = 1
        countW += 1

ans = []
countE = n - countW
left = 0
right = 0

for i in range(n):
    if i == 0:
        if S[0] == 0:
            ans.append(countE - 1)
        else:
            ans.append(countE)
    elif 0 < i < n-1:
        left += S[i-1]
        # right = countE - i - 1 + left
        right = n - i - 1 - countW + left + S[i]
        ans.append(left + right)
        # print("------------")
        # print("i: " + str(i))
        # print("left: " + str(left))
        # print("right: " + str(right))
    elif i == n-1:
        ans.append(countW - S[-1])
# print("*********")
# print(countE)
# print(ans)
print(min(ans))

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

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

typedef long long ll;

ll INF = 100000000000000;
ll MOD = 1e9+7;

using Graph = vector<vector<int>>;

Graph G(100010);

int main(){
    int N;string S;
    cin >> N >> S;
    vector<char> A(N);
    string ans = S;
    for(int i = 0;i < N;i++){
        A[i] = S[i];
    }
    bool frag = 1;
    while(frag){
        frag = 0;
        for(int i = 0;i < N-1;i++){
            if(A[i] == '(' && A[i+1] == ')'){
                remove(A,i);
                remove(A,i);
                N -= 2;
                frag = 1;
            }
        }
    }
    //cout << N << endl;
    for(int i = 0;i < N;i++){
        if(A[i] == '('){
            ans = ans + ')';
        }else{
            ans = '(' + ans;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 2560
import java.util.*;
import javax.lang.model.util.ElementScanner6;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        // 入力
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        String out = (a + b + c) >= 22 ? "bust" : "win";

        // 出力
        System.out.println(out);
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define len(X) ((int)(X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = 50;
int N;
int a[MAX_N], b[MAX_N];

bool used[MAX_N+1];
bool dp[MAX_N+1];

bool judge(int s, int t) {
    memset(dp, 0, sizeof(dp));

    dp[s] = true;
    for (int i = 50; i > 0; --i) {
        if (used[i]) {
            for (int j = 0; j <= 50; ++j) {
                if (dp[j]) {
                    dp[j%i] = true;
                }
            }
        }
    }


    return dp[t];
}

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

  cin >> N;
  rep(i, N) cin >> a[i];
  rep(i, N) cin >> b[i];

  for (int i = 1; i <= 50; ++i) used[i] = true;

  for (int i = 0; i < N; ++i) {
      if (!judge(a[i], b[i])) {
          cout << -1 << endl;
          return 0;
      }
  }

  for (int i = 50; i >= 1; --i) {
      used[i] = false;
      bool ok = true;
      for (int j = 0; j < N; ++j) {
          if (!judge(a[j], b[j])) {
              ok = false;
              break;
          }
      }
      if (!ok) used[i] = true;
  }

  ll ans = 0;
  for (int i = 1; i <= 50; ++i) {
      if (used[i]) {
          ans += 1LL << i;  
      }
  }

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


Measured memory_bytes: 504
<?php
fscanf(STDIN, '%d', $n);

$vArr = explode(' ', fgets(STDIN));
$cArr = explode(' ', fgets(STDIN));

$ans = 0;

$counts = [];
$costs = [];
for ($i = 0;$i < $n;$i++) {
    if (((int)$vArr[$i] <=> (int)$cArr[$i]) < 0) {
        continue;
    }
    $ans += (int) $vArr[$i] - (int)$cArr[$i];
}

echo $ans .PHP_EOL;

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

#define pi 3.141592654
#define fix(n) cout << fixed << setprecision(n)

#define rep(i,a,b) for(int i=a;i<b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)

#define ll  long long
#define ull unsigned long long

#define mp make_pair
#define pb push_back
#define fi first
#define se second

#define vi      vector<int>
#define pii     pair<int,int>
#define piii    pair<pair<int,int>,int>
#define all(v)  v.begin(), v.end()

int mod = 1000000007;
const int N = 100005;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin >> s;
    ll k;
    cin >> k;
    int l = s.length();
    int cnt = 0;
    for (int i = 0; i < l; i ++)
    {
        int x = s[i] - '0';
        if ( x != 1)
        {
            cout  << x << endl;
            return 0;
        }
        else
            cnt ++;
        if ( cnt == k)
        {
            cout << x << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (n, c) = run {
        val s = readLine()!!.split(' ')
        s[0].toInt() to s[1].toLong()
    }

    val xs = LongArray(n) { 0 }
    val vs = LongArray(n) { 0 }

    val cum = LongArray(n + 1) { 0 }

    for (i in 0 until n) {
        val (x, v) = readLine()!!.split(' ').map { it.toLong() }
        xs[i] = x
        vs[i] = v
        cum[i + 1] = cum[i] + v
    }

    val r1 = run {
        val g = LongArray(n + 1) { 0 }
        for (i in 0 until n) {
            g[i + 1] = Math.max(g[i], cum[i + 1] - xs[i])
        }
        (0 until n).map {
            g[it] + cum.last() - cum[it] - (c - xs[it]) * 2
        }.max()!!.let {
            Math.max(it, g.last())
        }
    }

    val r2 = run {
        val g = LongArray(n + 1) { 0 }
        for (i in n - 1 downTo 0) {
            g[i] = Math.max(g[i + 1], cum.last() - cum[i] - (c - xs[i]))
        }
        (0 until n).map {
            g[it + 1] + cum[it + 1] - xs[it] * 2
        }.max()!!.let {
            Math.max(it, g.first())
        }
    }

    println(Math.max(r1, r2))
}


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

const int mod = 1e9+7;
const int INF = 2000000;
const double PI = acos(-1.0);

int main() {
    int a, b;
    cin >> a >> b;
    cout << (a-1)*(b-1) << endl;
}

Measured memory_bytes: 3536
#include<iostream>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<map>
#include<utility>
#include<cmath>
#include<tuple>
#include<string>
#include<bitset>
#include<set>
#include<queue>
#include<stack>
#include<cfloat>
#include<cstdio>
using namespace std;
typedef long long ll;

int main(){
    ll a,b,c; cin>>a>>b>>c;
    if(c-a-b>0&&4*a*b-(c-a-b)*(c-a-b)<0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cstring>
#include<cmath>
#include<iterator>
#include<cstdlib>
#define IOS   ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ses   "\n"
#define whp   " "
#define mxi 99999
#define mp make_pair
#define PII pair<int, int>
#define pf printf
#define sf scanf
#define ALL(x) x.begin(),x.end()
#define pb push_back
#define PI acos(-1)
#define sz(a) long long(a.size())
#define ff first
#define ss second
#define forch(it,s) for(auto it:s)
#define each(it,s) for(auto it = s.begin(); it != s.end(); ++it)
#define rep0(i,a,b) for(int i=a; i<b; i++)
#define rep1(i,a,b) for(int i=a; i<=b; i++)
#define rep0in(i,a,b) for(int i=a-1; i>=b; i--)
#define rep1in(i,a,b) for(int i=a; i>b; i--)
#define repv(i,a) for(auto i=a.begin(); i!=a.end();++i)

///priority_queue <int, vector<int>, greater<int>> g
#define MS(a,b) memset(a,b,sizeof(a));

typedef long long ll;
typedef unsigned long long ull;
using namespace std;
ll fx[4]= {1,-1,0,0};
ll fy[4]= {0,0,1,-1};

typedef vector<ll> vll;
typedef vector<string> vss;
typedef vector<pair<ll,ll > > vpr;
typedef vector<pair<string,ll > > vspr;
typedef list<ll> li;
typedef list<string> ls;
typedef list<pair<ll,ll> > lpr;
typedef list<pair<string,ll> > lspr;

bool rs(ll a, ll b){return(a>b);}
ll spd(ll n){ if(n%2==0)return 2; for(ll i=3; i*i<=n; i++){if(n%i==0)return i;}return n;}

int main(){
ll n; cin>>n;
if(n>=30){cout<<"Yes"<<endl;}
else cout<<"No"<<endl;


return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
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 DEBUG_VLL(vec) REP(i, vec.size()) cerr<<vec[i]<<(i==vec.size()-1?'\n':' ');

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

template <class T>
class SegmentTree {
    long long n; // 葉の数
    vector<T> data;  // データを格納する配列
    T def;  // 初期値（単位元）
    function<T(T, T)> operation;  // 区間クエリで使う処理
    function<T(T, T)> update;  // 点更新で使う処理

    T _query(long long a, long long b, long long k, long long l, long long r) {
        if (r <= a || b <= l) return def;
        if (a <= l && r <= b) return data[k];  // a,l,r,bの順で含まれる
        else {
            T c1 = _query(a, b, 2*k+1, l, (l+r)>>1);
            T c2 = _query(a, b, 2*k+2, (l+r)>>1, r);
            return operation(c1, c2);
        }
    }

public:
    SegmentTree(size_t _n, T _def, function<T(T, T)> _operation, function<T(T, T)> _update)
        : def(_def), operation(_operation), update(_update) {
            n = 1;
            while (n < _n) n<<=1;
            data = vector<T>(2*n-1, def);
        }
    
    void change(long long i, T x) {
        i += n-1;
        data[i] = update(data[i], x);
        while (i>0) {
            i = (i-1)>>1;
            data[i] = operation(data[i*2+1], data[i*2+2]);
        }
    }

    T query(long long a, long long b) {
        return _query(a, b, 0, 0, n);
    }

    T operator[](long long i) {
        return data[i+n-1];
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, q; cin >> n >> q;
    SegmentTree<ll> segt((ll)n, (ll)(1LL<<31)-1, 
        [](ll i, ll j){ return min(i, j); },
        [](ll i, ll j){ return j; });
    int com;
    ll x, y;
    for (int i=0; i<q; i++) {
        cin >> com >> x >> y;
        if (com == 0) segt.change(x, y);
        else cout << segt.query(x, y+1) << '\n';
    }
    return 0;
}



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

class Main{
    public static void main(String[] args){
	BufferedReader sc=new BufferedReader(new InputStreamReader(System.in));
	try {
	    while(true){
		String[] st = sc.readLine().split(" ");
		int r = Integer.valueOf(st[0]), c = Integer.valueOf(st[1]);
		if((r|c)==0)
		    break;
		if(r*c%2==0)
		    System.out.println("yes");
		else
		    System.out.println("no");
	    }
	}catch(Exception e){
	    System.out.println("Error");
	}
    }
}

Measured memory_bytes: 19436
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <stack>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdlib>

using namespace std;

#define ALL(c) c.begin(),c.end()
#define RALL(c) c.rbegin(),c.rend()
#define REP(type,i,n) for(type i=0;i<(n);++i)
#define MP(a,b) make_pair((a),(b))

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

const int INF=100000000;
const long long int INF_=1000000000000000000;

lli Gcd(lli a,lli b){
	if(b==0) return a;
	return Gcd(b,a%b);
}

lli Lcm(lli a,lli b){
	return a/Gcd(a,b)*b;
}

class Bar{
	public:
	int p,q,r,b,parent;
	bool exists,is_leaf;
	Bar():parent(-1),exists(false),is_leaf(false){}
	void Init(int a,int b,int c,int d,bool e);
};

void Bar::Init(int a,int bb,int c,int d,bool e){
	p=a; q=bb; r=c; b=d; exists=e;
}

int Find(vector<Bar> &m,int n){
	if(m[n].parent==-1) return n;
	return Find(m,m[n].parent);
}

void Pre(vector<Bar> &m,int n){
	if(m[n].r==-1&&m[n].b==-1){
		m[n].is_leaf=true;
		return;
	}
	if(m[n].r!=-1) Pre(m,m[n].r);
	if(m[n].b!=-1) Pre(m,m[n].b);
}

lli DFS(const vector<Bar> &m,int n){
	if(m[n].is_leaf) return Lcm(m[n].p,m[n].q)/m[n].p+Lcm(m[n].p,m[n].q)/m[n].q;
	lli a,b;
	if(m[n].r==-1) a=Lcm(m[n].p,m[n].q)/m[n].p;
	else a=DFS(m,m[n].r);
	if(m[n].b==-1) b=Lcm(m[n].p,m[n].q)/m[n].q;
	else b=DFS(m,m[n].b);
	return a*Lcm(a*m[n].p,b*m[n].q)/(m[n].p*a)+b*Lcm(a*m[n].p,b*m[n].q)/(m[n].q*b);
}

int main(){
	int N;
	while(cin >> N&&N){
		vector<Bar> mobile(100);
		REP(int,i,N){
			int p,q,r,b;
			cin >> p >> q >> r >> b; //p:q,左の棒の番号、右の棒の番号
			--r;
			--b;
			mobile[i].Init(p,q,r,b,true);
			if(r!=-1) mobile[r].parent=i;
			if(b!=-1) mobile[b].parent=i;
		}
		int parent=-1;
		REP(int,i,100){
			if(mobile[i].exists){
				parent=Find(mobile,i);
				break;
			}
		}
		Pre(mobile,parent);
		lli ans=DFS(mobile,parent);
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1196