akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<queue>
#include<tuple>
#define mid ((l+r)>>1)
using namespace std;
namespace fio{
	streambuf*in=cin.rdbuf();
	char bb[1000000], *s=bb, *t=bb;
	#define gc() (s==t&&(t=(s=bb)+in->sgetn(bb,1000000),s==t)?EOF:*s++)
	inline int read(){
		int x=0;
		char ch=gc();
		while(ch<48)ch=gc();
		while(ch>=48)x=x*10+ch-48,ch=gc();
		return x;
	}
}using fio::read;
using mp=pair<int,int>;
using mt=tuple<int,int,int>;
int n, m;
vector<mt>road[100005];
int sz[3000005], ls[3000005], rs[3000005], cnt; long long sum[3000005];
int root[100005], dep[100005];
inline void add(int&root, int x, int l, int r, int p, int v){
	sz[root=++cnt]=sz[x]+1, sum[root]=sum[x]+v;
	if(l!=r)if(p<=mid)add(ls[root], ls[x], l, mid, p, v), rs[root] = rs[x];else add(rs[root], rs[x], mid + 1, r, p, v), ls[root] = ls[x];else;
}
inline long long sub(int x, int l, int r, int p, int v){
	if(!x)return 0;
	if(l==r)return 1ll * v * sz[x] - sum[x];
	return p<=mid?sub(ls[x], l, mid, p, v) : sub(rs[x], mid + 1, r, p, v);
}
int anc[100005][20];
long long ps[100005];
void dfs(int x, int p){
	anc[x][0]=p, dep[x]=dep[p]+1;for(int i=1;i<20;i++)anc[x][i]=anc[anc[x][i-1]][i-1];
	for(mt it:road[x])if(get<0>(it)!=p)ps[get<0>(it)]=ps[x]+get<2>(it), add(root[get<0>(it)], root[x], 1, n, get<1>(it), get<2>(it)), dfs(get<0>(it), x);
}
int lca(int x, int y){
	if(dep[x]<dep[y])swap(x, y);
	for(int i=19;~i;i--)if(dep[anc[x][i]]>=dep[y])x=anc[x][i];
	if(x==y)return x;
	for(int i=19;~i;i--)if(anc[x][i]!=anc[y][i])x=anc[x][i], y=anc[y][i];
	return anc[x][0];
}
int main(){
	n=read(), m=read();
	for(int i=1, x, y, c, v;i<n;i++)x=read(), y=read(), c=read(), v=read(), road[x].emplace_back(y, c, v), road[y].emplace_back(x, c, v);
	dfs(1, 0);
	for(int i=1;i<=m;i++){
		int c=read(), v=read(),x=read(), y=read(), __lca=lca(x, y);
		printf("%lld\n", ps[x] + ps[y] - (ps[__lca]<<1)
			+ sub(root[x], 1, n, c, v) + sub(root[y], 1, n, c, v) - (sub(root[__lca], 1, n, c, v)<<1));
	}
}

Measured memory_bytes: 75392
#include <iostream>
#include <vector>
using namespace std;
typedef vector<int> comb;

inline int first(int n){
	return ((1 << n) - 1);
}

int nextSet(int x){
	int small, ripple, newSmall,ones;
	
	small = x & -x;
	ripple = x + small;
	newSmall = ripple & -ripple;
	ones = (( newSmall / small ) >> 1) - 1;
	
	return (ripple | ones);
}

comb setComb(int s, int n){
	comb c;
	for(int i=1 ; i<=n ; i++){
		if( s & 1 ) c.push_back(i-1);
		s >>= 1;
	}
	return c;
}

int main(){
	int n=10, k, x, s, sum, ans;
	comb c;
	
	while( cin >> k >> s , k || s ){
		ans = 0;
		x = first(k);
		while( !(x & ~first(n) ) ){
			c = setComb( x , n );
			sum = 0;
			for(int i=0 ; i<c.size() ; i++){
				sum += c.at(i);
			}
			if( sum == s ) ans++;
			x = nextSet( x );
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 0
#include <iostream>

using namespace std;

int n, q, p[100005], s[100005];

int main()
{
	cin >> n >> q;
	char pre;
	for (int i = 1; i <= n; i++)
	{
		char c;
		cin >> c;
		if (c == 'C' && pre == 'A') p[i - 1] = 1;
		pre = c;
	}
	for (int i = 1; i < n; i++)
	{
		s[i] = s[i - 1] + p[i];
	}
	for (int i = 1; i <= q; i++)
	{
		int l ,r ;
		cin >> l >> r;
		cout << s[r - 1] - s[l - 1] << endl;
	}
	return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
#define PN() {cout << "No" << endl; return 0;}
#define PY() {cout << "Yes" << endl; return 0;}

int main(){
  int n; cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++) cin >> a[i];
  sort(a.begin(), a.end());
  int am = a[n-1];
  bool is_alleq = true;
  for(int i=0;i<n;i++){
    if(a[i] <= am-2) PN()
  	if(a[i]!=am) is_alleq = false;
  }
  if(is_alleq && am <= n / 2) PY()
  else if(is_alleq && am+1 == n) PY()
  else if(is_alleq) PN();
  int pos = 0;
  while(a[pos]==am-1) pos++;
  if(pos <= am-1 && 2 * (am-pos) <= n-pos) PY()
  else PN()
  return 0;
}

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

int main() {
	int N;
	cin >> N;
	long ans=0;
	vector<string> A(N);
	for (size_t i = 0; i < N; i++)
	{
		cin >> A.at(i);
		sort(A.at(i).begin(), A.at(i).end());
	}
	
	unordered_map<string,int> P;
	for (size_t i = 0; i < N; i++)
	{
		P[A.at(i)] = 0;
	}
	for (size_t i = 0; i < N; i++)
	{
		ans += P[A.at(i)];
		P[A.at(i)]+=1;
	}
	cout << ans;
}

Measured memory_bytes: 17700
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end());
  puts(s<t?"Yes":"No");
  return 0;
}
// cLay varsion 20170910-1

// --- original code ---
// {
//   string s, t;
//   cin >> s >> t;
//   sort(s.begin(), s.end());
//   sort(t.begin(), t.end());
//   reverse(t.begin(), t.end());
//   puts(s<t?"Yes":"No");
// }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
int main(void){
    int n;cin>>n;
    rep1(i, 9)rep1(j, 9){if(i*j==n){co("Yes");return 0;}}
    co("No");
}



Measured memory_bytes: 256
#include <assert.h>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <bitset>
typedef long long ll;
typedef unsigned long long ull;

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define DEBUG(vec) for (auto v : vec) { cout << v << " "; } cout << endl;

using namespace std;

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

  int N;
  cin >> N;

  double t[110] = {};
  double v[110] = {};

  REP(i, N) {
    cin >> t[i + 1];
  }
  REP(i, N) {
    cin >> v[i + 1];
  }
  for (int i = N + 1; i > 0; i--) {
    if (v[i] < v[i - 1] - t[i - 1]) {
      v[i - 1] = v[i] + t[i - 1];
    }
    // cout << v[i] << endl;
  }

  double run[20010] = {};
  int tim = 1;
  double current = 0;
  double area = 0;
  for (int i = 1; i <= N; i++) {
    // double current = run[i - 1];
    double current_lim = v[i];
    double next_lim = v[i + 1];

    REP(j, t[i]) {
      if (current - (t[i] - j) + 1 > next_lim) {
        run[tim] = current - 1;
      } else if (current + 1 <= current_lim &&
                 current + 1 - (t[i] - j) + 1 > next_lim) {
        run[tim] = current;
        // cout << "x: " << area << endl;
        area += 0.5;
      } else {
        run[tim] = min(current_lim, current + 1);
      }
      current = run[tim];
      // cout << current << " " << area << endl;
      area += run[tim] * 2;
      tim++;
    }
  }
  printf("%.10f\n", area / 2);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d;
int main()
{
	cin>>a>>b>>c>>d;
	if(a+b>c+d)
	{
		cout<<"Left"<<endl;
	}
	if(a+b==c+d)
	{
		cout<<"Balanced"<<endl;
	}
	if(a+b<c+d)
	{
		cout<<"Right"<<endl;
	}
}

Measured memory_bytes: 256
import math
            
def koch(n, x1, y1, x2, y2):
  if n == 0:
    return
   
  theta60 = math.radians(60)
           
  sx = ( 2 * x1 + x2 ) /3
  sy = ( 2 * y1 + y2 ) /3
  tx = ( 2 * x2 + x1 ) /3
  ty = ( 2 * y2 + y1 ) /3
  ux = ( tx - sx ) * math.cos( theta60 ) - ( ty - sy ) * math.sin( theta60 ) + sx
  uy = ( tx - sx ) * math.sin( theta60 ) + ( ty - sy ) * math.cos( theta60 ) + sy
            
  koch(n-1, x1, y1, sx, sy)
  print sx, sy
  koch(n-1, sx, sy, ux, uy)
  print ux, uy
  koch(n-1, ux, uy, tx, ty)
  print tx, ty
  koch(n-1, tx, ty, x2, y2)
     
n = input()
            
p1x = float(0.)
p1y = float(0.)
p2x = float(100.)
p2y = float(0.)
            
print p1x, p1y
koch(n, p1x, p1y, p2x, p2y)
print p2x, p2y

Measured memory_bytes: 6656
/*
    Author : Simanta Deb Turja
*/
#include <bits/stdc++.h>
using namespace std;

#define Professor

using ll = long long;
using i64 = unsigned long long;

template <typename T> inline T Min (T a, T b, T c) { return min(a, min(b, c)); }
template <typename T> inline T Min (T a, T b, T c, T d) { return min(a, min(b, min(c, d))); }
template <typename T> inline T Max (T a, T b, T c) { return max(a, max(b, c)); }
template <typename T> inline T Max (T a, T b, T c, T d) { return max(a, max(b, max(c, d))); }

template <typename T> inline T Ceil(T a, T b) { return ((a % b == 0) ? (a / b) : (a / b + 1)); } 
template <typename T> inline T Floor(T a, T b) { return a / b; }

template <typename T> inline T Power (T a, T p) { T res = 1, x = a; while ( p ) { if ( p & 1 ) res = ( res * x ); x = ( x * x ); p >>= 1;}return res; }
template <typename T> inline T BigMod (T a,T p,T M) { a %= M;T ret = 1; while (p) { if (p & 1) ret = (ret * a) % M; a = (a * a) % M; p = p >> 1; } return ret; }
template <typename T> inline T InverseMod (T a,T M) { return BigMod (a, M - 2, M); }

template <typename T> inline T gcd ( T a, T b ) { a = abs(a); b = abs(b); while ( b ) { a = a % b; swap ( a, b ); } return a; }
template <typename T> inline T lcm(T x,T y) { return (((x)/gcd((x),(y)))*(y)); }


#define endl '\n'
#define eb emplace_back

const int N = (int)4e5 + 10;
const double EPS = 1e-7;
const double PI = acos(-1.0);
const ll LLINF = (ll)1e18+1;
const int INF = (int)1e9+1;
const ll MOD = (ll)1e9 + 7;

template <typename T> bool cmp (const pair <T, T> &a, const pair <T, T> &b) { return a.first < b.first; }


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    auto Solve = [&]() {
        #ifdef __APPLE__
            cout << "Running\n";
        #endif
        int n, W;
        cin >> n >> W;
        vector <ll> w(n), v(n);
        for (int i = 0; i < n; ++i) {
            cin >> w[i] >> v[i];
        }
        vector <vector <ll> > dp(n, vector <ll> (W + 1));
        vector <vector <bool> > vis(n, vector <bool> (W + 1, false));
        function <ll(int, int)> memo = [&](int pos, int cap) {
            if (pos == n) {
                return 0LL;
            }
            if (vis[pos][cap] != 0) {
                return dp[pos][cap];
            }
            vis[pos][cap] = 1;
            ll ret = -LLINF;
            if (cap - w[pos] >= 0) {
                ret = max(ret, memo(pos + 1, cap - w[pos]) + v[pos]);
            }
            ret = max(ret, memo(pos + 1, cap));
            return dp[pos][cap] = ret;
        };
        cout << memo(0, W) << endl;
    };
    Solve();
    
    return 0;
}



Measured memory_bytes: 79856
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,A,C0=100,C1=0;
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> A;
    for(;;){
      if(A%2 == 0){
        C1++;
        A /= 2;
      }
      else break;
    }
    if(C0>C1) C0 = C1;
    C1 = 0;
  }
  cout << C0 << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <cmath>
#include <map>
#include <vector>
#include <cctype>
#include <set>
#include "iostream"
using namespace std;
const int INF = 2147483640;
typedef unsigned long long ll;
const int MAXN = 600500;
const int MOD = 998244353;
long long gcd(long long a,long long b)
{
	if(b>a)
	{
		long long t=a;
		a=b;
		b=t;
	}
	long long aa=a,bb=b,c;
	do
	{
	    c=a%b;
		a=b;
		b=c;
	}while(c);
	return aa/a*bb;
}
long long arr[110];
int main()
{

	int n;
	cin>>n;
	long long temp,ans=1;
	for (int i = 0; i < n; ++i)
	{
		cin>>temp;
		ans=gcd(ans,temp);
	}
	cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
int A,B,C;
C=0;
scanf("%d %d",&A,&B);
if(A>=B){C+=A;A--;}else{C+=B;B--;}
if(A>=B){C+=A;A--;}else{C+=B;B--;}
printf("%d\n",C);

return 0;
}


Measured memory_bytes: 128
s=str(input())
s=list(s)
for i in range(0,len(s)):
  if s[i]=="A":
    temp1=i
    break    
for j in range(0,len(s)-temp1):
  if s[len(s)-j-1]=="Z":
    temp2=len(s)-j-1
    break 
print(temp2-temp1+1)

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

int main(){
  int n, k;
  cin >> n >> k;
  vector<int> v(n+1, 0);
  int a;
  rep(i, n){
    cin >> a;
    ++v[a];
  }
  sort(v.begin(), v.end(), greater<>());
  v.erase(v.begin(), v.begin() + k);
  int ans = 0;
  rep(i, n - k){
    ans += v[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4036
#include <iostream>

using namespace std;

int main()
{
	int a,b,c;
  	cin >> a >> b >> c;
  
  	if(a + b >= c - 1)
    {
     	printf("%d",b+c);
    }
	else
    {
    	printf("%d",b + (a+b+1));
    }
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
const long long INF = 1e9 + 7;
using namespace std;
map<int, int> mp;
int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	const int tmp1 = max(a, c);
	const int tmp2 = min(b, d);
	cout << max(0, tmp2 - tmp1) << endl;
	return 0;
}

Measured memory_bytes: 256
while True:
    n,k = map(int, input().split())
    if n == k == 0:
        break
    s = [int(x) for x in input().split()]
    for _ in range(n):
        b = [int(x) for x in input().split()]
        for i in range(k):
            s[i] -= b[i]
    print("Yes" if min(s) >= 0 else "No")

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

int beki(long long a,long long b,int M = modulo){
	int x = 1;
	while(b!=0){
		if(b&1){
			x=((long long)x*a)%M;
		}
		a=((long long)a*a)%M;
		b>>=1;
	}
	return x;
}

long long findPrimitiveRoot(long long n){
	long long P = n;
	n--;
	vector<long long> p;
	for(long long i=2;i*i<=n;i++){
		if(n%i==0){
			p.push_back(i);
			
			while(n%i==0)n/=i;
		}
	}
	
	if(n!=1)p.push_back(n);
	
	for(long long i=2;true;i++){
		bool f = true;
		for(int j=0;j<p.size();j++){
			if(beki(i,(P-1)/p[j],P)==1){
				f=false;
				break;
			}
		}
		if(f)return i;
	}
	
}

void FFT(vector<complex<double>> &A,int sign){
	int n = A.size();

	double PI = acos(-1.0);
	

	vector<complex<double>> tmp(n);
	int mask = n-1;
	
	for(int i=n>>1;i>=1;i>>=1){
		double dir = 2.0*PI*i*sign/n;

		complex<double> w(cos(dir),sin(dir));
		
		complex<double> now = 1.0;
	
		for(int j=0;j<n;j+=i){
			for(int k=0;k<i;k++){
				tmp[j+k] = A[((j<<1)&mask)|k] + now*A[(((j << 1)|i)&mask)|k];
			}
			now *= w;
		}
		swap(A,tmp);
	}

	int num;
	for(int i=0;true;i++){
		if((n>>i)&1){
			num = i;
			break;
		}
	}

	if(num&1){
		swap(A,tmp);
		for(int i=0;i<n;i++)A[i] = tmp[i];
	}
	
	return;
}

vector<long long> do_FFT(vector<long long> &A,vector<long long> &B){
	
	int n = A.size()+B.size()-1;
	
	if(min(A.size(),B.size())<=150){
		vector<long long> ret(n,0);
		for(int i=0;i<A.size();i++){
			for(int j=0;j<B.size();j++){
				ret[i+j] = mod(ret[i+j] + mod(A[i]*B[j]));
			}
		}
		return ret;
	}
	
	for(int i=0;true;i++){
		if((1<<i)>=n){
			n = (1<<i);
			break;
		}
	}
	
	vector<complex<double>> a(n,complex<double>(0.0,0.0)),b(n,complex<double>(0.0,0.0));
	
	for(int i=0;i<A.size();i++)a[i].real(A[i]);
	for(int i=0;i<B.size();i++)b[i].real(B[i]);
	
	FFT(a,1);
	if(A==B)b=a;
	else FFT(b,1);
	
	vector<complex<double>> c(n);
	for(int i=0;i<n;i++)c[i] = a[i]*b[i];
	
	FFT(c,-1);
	
	vector<long long> C(n);
	for(int i=0;i<n;i++){
		C[i] = round(c[i].real()/n);
	}
	
	return C;
	
}	

int main(){
	
	int g = findPrimitiveRoot(modulo);
	
	vector<long long> arr;
	vector<int> gyaku(modulo,0);
	
	for(int i=0;i<modulo-1;i++){
		arr.push_back(beki(g,i));
		gyaku[arr.back()]=i;
	}
	
	int N;
	cin>>N;
	vector<int> A;
	vector<long long> X(modulo,0LL);
	
	for(int i=0;i<N;i++){
		int a;
		cin>>a;
		
		if(a!=0){
			A.push_back(a);
			X[gyaku[a]]++;
		}
		
	}
	
	vector<long long> Y = X;
	X = do_FFT(X,Y);
	
	for(int i=0;i<A.size();i++){
		X[(gyaku[A[i]]+gyaku[A[i]])%(modulo-1)]--;
	}
	vector<long long> t(modulo-1);
	long long ans = 0LL;
	for(int i=0;i<X.size();i++){
		t[i%(modulo-1)]+=X[i];
	}
	
	for(int i=0;i<t.size();i++){
		t[i]/=2;
		//if(t[i]!=0)cout<<i<<','<<t[i]<<endl;
		ans += t[i]*arr[i];
	}
	
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 43828
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cassert>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> PLL;

constexpr int px[19] = {1,1,2,2,2,3,3, 0,0,0,1,1,2,2,3,3,4,4,4};
constexpr int py[19] = {1,2,1,2,3,2,3, 0,1,2,0,3,0,4,1,4,2,3,4};
constexpr int dx[7] = {-1,-1,0,0,0,1,1};
constexpr int dy[7] = {-1,0,-1,0,1,0,1};

string check(const string c) {
    char field[3][5][5];

    for (int j = 0; j < (1<<19); ++j) {

        for (int k = 0; k < 19; ++k) {
            field[0][px[k]][py[k]] = (j & (1 << k)) != 0 ? 1 : 0;
        }

        for (int k = 0; k < 7; ++k) {
            int x = px[k], y = py[k];
            int pattern = 0;
            for (int l = 0; l < 7; ++l) {
                if (field[0][x+dx[l]][y+dy[l]] > 0) {
                    pattern += (1 << l);
                }
            }
            field[1][x][y] = c[pattern] - '0';
        }

        {
            int pattern = 0;
            for (int l = 0; l < 7; ++l) {
                if (field[1][2+dx[l]][2+dy[l]] > 0) {
                    pattern += (1 << l);
                }
            }
            field[2][2][2] = c[pattern] - '0';
        }

        if (field[1][2][2] != field[2][2][2]) {
            return "no";
        }
    }

    return "yes";
}

bool solve() {
    string c;
    cin >> c;
    if (c == "#") { return false; }
    cout << check(c) << endl;
    return true;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(solve());
    return 0;
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
const int MOD = 1000000007; // 10^9 + 7
const double PI = 3.14159265358979323846;
const int N = 10000000; // 10^7
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int64_t n;
    cin>>n;
    string s;
    do {
        n--;
        s += char(n%26 + 97);
        n/=26;
    } while (n);
    for (int64_t i=s.size()-1; i>=0; --i) cout<<s[i];
    return 0;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

int main(void){
    // Your code here!
    int k,a,b;cin >> k >> a >> b;
    bool res = false;
    FOR(i,a,b){
        if(i%k==0) res = true;
    }
    if(res) cout << "OK";
    else cout << "NG";
}


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

int main(){
    int n;
    std::cin >> n;
    std::vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin>>a.at(i);
    }
    sort(a.begin(),a.end(),greater<int>());
    for (int i = 0; i < n; i++) {
        /* code */
        a.at(i)*=pow((-1),i);
    }
    std::cout << accumulate(a.begin(),a.end(),0) << std::endl;
}

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

using namespace std;

void solve()
{
	int n;
	int sheet;
	while(cin >> n >> sheet)
	{
		if(!n && !sheet)
		{
			break;
		}
		vector<string> Vec(n);
		for(int i = 0; i < n; ++i)
		{
			cin >> Vec[i];
		}
		set<string> Set;
		if(sheet == 2)
		{
			for(int i = 0; i < n; ++i)
			{
				for(int j = 0; j < n; ++j)
				{
					if(i == j)
					{
						continue;
					}
					Set.insert(Vec[i] + Vec[j]);
				}
			}
		}
		if(sheet == 3)
		{
			for(int i = 0; i < n; ++i)
			{
				for(int j = 0; j < n; ++j)
				{
					for(int k = 0; k < n; ++k)
					{
						if(i == j || j == k || i == k)
						{
							continue;
						}
						Set.insert(Vec[i] + Vec[j] + Vec[k]);
					}
				}
			}
		}
		if(sheet == 4)
		{
			for(int i = 0; i < n; ++i)
			{
				for(int j = 0; j < n; ++j)
				{
					for(int k = 0; k < n; ++k)
					{
						for(int l = 0; l < n; ++l)
						{
							if(i == j || i == k || i == l || j == k || j == l || k == l)
							{
								continue;
							}
							Set.insert(Vec[i] + Vec[j] + Vec[k] + Vec[l]);
						}
					}
				}
			}
		}
		cout << Set.size() << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 0
#include <stdio.h>
#include <stdbool.h>

#define N 16

int buffer[N],count=0;
bool used[N+1];

int main(void){
  int k,p[9],q[9],p_num=0,q_num=0,p_the,q_the,count=0;
  scanf("%d",&k);
  for(int i=0;i<k;i++){
    p_num=10*p_num;
    scanf("%d",&p[i]);
    p_num+=p[i];
  }
  for(int i=0;i<k;i++){
    q_num*=10;
    scanf("%d",&q[i]);
    q_num+=q[i];
  }
  
    int print_perm(int x){
  int temp=0;
  for(int i=0;i<x;i++){
    temp*=10;
    temp+=buffer[i];
  }
  return temp;
}
  
  void perm_sub(int l, int f){
  if(l==f){
    count++;
    if(p_num==print_perm(f)) p_the=count;
       if(q_num==print_perm(f)) q_the=count;
  }
  else{
    for(int i=1;i<=l;i++){
      if(used[i]) continue;
      buffer[f]=i;
      used[i]=true;
      perm_sub(l,f+1);
      used[i]=false;
    }
  }
}

  
  perm_sub(k,0);
    if(q_the>p_the){
      printf("%d",q_the-p_the);
      return 0;
    }
  else{
    printf("%d",p_the-q_the);
  }
    
}

Measured memory_bytes: 1676
import sys
from collections import deque
inf=100000000000000000000
fastinput=sys.stdin.readline
N=int(fastinput())
path=[deque() for hoge in range(N)]
for fuga in range(N-1):
    a,b,c=[int(hoge) for hoge in fastinput().split()]
    path[a-1].append([b-1,c])
    path[b-1].append([a-1,c])
Q,K=[int(hoge) for hoge in fastinput().split()]
stack=deque()
stack.append(K-1)
Kcost=[0]*N#あとあと初期化
went=[False]*N
went[K-1]=True
while stack:
    cur=stack.pop()
    curcost=Kcost[cur]
    for next,c in path[cur]:
        if c and not went[next]:
            went[next]=True
            Kcost[next]=curcost+c
            stack.append(next)
for q in range(Q):
    x,y=[int(hoge) for hoge in fastinput().split()]
    print(Kcost[x-1]+Kcost[y-1])
    

Measured memory_bytes: 123996
using System;
class Program
{
	static void Main()
	{
	int n = int.Parse(Console.ReadLine());//int.Parseは文字列を整数に変換。
	int[] a = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
    int[] b = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
    int sum = 0;
    int maxNum = 0;
      for(int i= 0; i < n; i++)
      {
        sum = 0;
        for(int j = 0; j <= i; j++)
        sum += a[j];
        for(int k = i; k < n; k++)
        sum += b[k];
        if(sum > maxNum)maxNum = sum;
      }
	//出力
	Console.WriteLine(maxNum);//WriteLineをWriteとすると、改行なしで出力。
	}
}

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

int main(){
    int a,b;
    cin >> a >> b;
    string s;
    for(int i=0;i<a;i++){
        for(int j=0;j<b;j++){
            cin >> s;
            if(s=="snuke"){
                cout << char('A'+j) << i+1 << endl;
                break;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val scn = Scanner(System.`in`)
    val S = scn.next()
    val T = scn.next()
    var A = scn.nextInt()
    var B = scn.nextInt()
    val U = scn.next()

    if(U==S){
        A--
    }else if(U==T){
        B--
    }

    println("$A $B")
}

Measured memory_bytes: 31252
#include<stdio.h>
#include<math.h>
#include<string.h>


int main() {
	int i, j, k;
	int m, n;
	int f = 0;
	int g = 0;
	int x;
	int a, b, c;
	char s[5];

	scanf("%s", s);

	if (s[1] == 'B') {
		printf("ARC");
	}
	else {
		printf("ABC");
	}


	return 0;
}

Measured memory_bytes: 1736
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define ll long long
const int Mod=1e9+7;
int n;
ll sum;
char s1[60];
char s2[60];
void dfs(int x,int flag,ll ans)
{
    if(x==n)
    {
        sum=(sum+ans)%Mod;
        return ;
    }
    if(x+1<n&&s1[x]==s1[x+1]&&s2[x]==s2[x+1])
    {
        if(!flag)
            dfs(x+2,2,ans*6%Mod);
        else if(flag==1)
            dfs(x+2,2,ans*2%Mod);
        else
            dfs(x+2,2,ans*3%Mod);
    }
    if(s1[x]==s2[x])
    {
        if(!flag)
            dfs(x+1,1,ans*3%Mod);
        else if(flag==1)
            dfs(x+1,1,ans*2%Mod);
        else
            dfs(x+1,1,ans*1%Mod);
    }
}
int main()
{
    scanf("%d",&n);
    scanf("%s%s",s1,s2);
    sum=0;
    dfs(0,0,1);
    printf("%lld\n",sum);
    return 0;
}


Measured memory_bytes: 256
let () =
  let faces = Scanf.sscanf (read_line ()) "%d %d %d %d %d %d" (fun a b c d e f ->  [a;b;c;d;e;f] ) in
  let n = read_int () in
  let rec loop = function
      0 -> ()
    | i -> let index_of_face face =
             let rec loop i = function
                 [] -> raise Not_found
               | hd::tl -> if face = hd then i
                           else loop (i+1) tl
             in
             loop 0 faces
           in
           let i_top, i_front = 
             let top, front = Scanf.sscanf (read_line ()) "%d %d" (fun a b -> a,b ) in
             index_of_face top, index_of_face front
           in
           let i_right = 
             if i_front = (i_top + 2) mod 6 then (i_top + 4) mod 6 
             else if i_front = (i_top + 4) mod 6 then (9 - i_top) mod 6 
             else if i_front = (9 - i_top) mod 6 then (7 - i_top) mod 6 
             else if i_front = (7 - i_top) mod 6 then (i_top + 2) mod 6
             else raise (Invalid_argument "This is not dice")
           in
           Printf.printf "%d\n" @@ List.nth faces i_right;
           loop (i-1)
  in
  loop n
;;


Measured memory_bytes: 2360
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a, b, c; cin >> a >> b >> c;
	int cn = 0;
	while(b <= a){
		b*=2;
		cn++;
	}
	while(c <= b){
		c*=2;
		cn++;
	}
	int k; cin >> k;
	cout << (k>= cn ? "Yes\n" : "No\n");
		
}


Measured memory_bytes: 3592
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int[] x = new int[1000];
		while (true) {
			int m = sc.nextInt();
			int n = sc.nextInt();
			int p = sc.nextInt();
			if (m == 0) {
				break;
			}
			int sum = 0;
			for (int i = 0; i < m; i++) {
				x[i] = sc.nextInt();
				sum += x[i];
			}
			int gold = 100 * sum;
			int haito;
			if (x[n - 1] == 0) {
				System.out.println(0);
			} else {
				haito = gold * (100 - p) / 100 / x[n - 1];
				System.out.println(haito);
			}
		}

	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#define sqr(x) (x)*(x)
using namespace std;
string st;
int n,i,ans;
int main()
{
	cin>>st;
	for (i=1;i<st.length();i++)
	{
		if (st[i]!=st[i-1]) ans++;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 512
import Data.Array.IO
import Data.List
import Data.Maybe
import Control.Monad

main = do
  _ <- getLine
  s <- return . (map read) . lines =<< getContents
  arr <- newArray (0,10000) Nothing :: IO (IOArray Int (Maybe Int))

  writeArray arr 0 (Just 1)
  forM_ s $ \x -> do
    forM_ (reverse [0..10000]) $ \i -> do
      r <- readArray arr i
      when (r /= Nothing) $ do
        writeArray arr (i+x) (Just 1)

  print =<< return . maximum . f =<< getElems arr

  where
    f xs = g $ catMaybes $ zipWith (\a b -> fmap (*b) a) xs [0..]
    g xs = filter (\x -> mod x 10 /= 0 || x == 0) xs


Measured memory_bytes: 2044
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		
		Map<Integer, int[]> id = new TreeMap<>();
		
		for(int i = 0; i < M; i++) {
			int[] a = new int[2];
			a[0] = sc.nextInt();
			a[1] = i;
			int b = sc.nextInt();
			id.put(b, a);
		}
		
		String[] ans = new String[M];
		int[] num = new int[N + 1];
		
		for(int[] c : id.values()) {
			num[c[0]]++;
			ans[c[1]] = String.format("%06d%06d", c[0], num[c[0]]);
			
		}
		for(int i = 0; i < M; i++) {
			System.out.println(ans[i]);
		}
	}
}



Measured memory_bytes: 159208
N = int(input())
W = [input() for _ in range(N)]
words = [''] * N
for i in range(N):
    if i == 0:
        words[i] = W[i]
        continue
    if (W[i] in words) or (W[i - 1][-1] != W[i][0]):
        print('No')
        break
    words[i] = W[i]
else:
    print('Yes')


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

using namespace std;
using namespace std::chrono;

#define rep(i,a,b) for(int i = a;i<(b);++i)
#define trav(a,v) for(auto& a : v)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;

ll big = 1000000007ll;
ll big2 = 1000000009ll;
ll n,m,T,k,q,p,x;


int main()
{
   // freopen("input.txt","r",stdin);
    //freopen("autput.txt","w",stdout);
    ll a,b,c,d,e;

    cin >> a >> b >> c >> d;
    cin >> n;

    ll x = min(4*a, min(2*b,c));
    ll y = min(2*x,d);
    cout << (n/2 * y) + (n%2 * x) << "\n";

    return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define ll long long  int
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
void solve()
{
            ll n,x,t;
            cin>>n>>x>>t;
            ll z=n/x;
            if(n%x!=0)
              z++;
            cout<<z*t;
} 
int main()
{
  
    solve();
  
    return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 300300;
const ll inf = 1ll<<50;
int n;
ll a[N] , sum , sum2 , ans = 1ll<<60;
multiset<ll>pre,suf;

int main(){

scanf("%d",&n);
for(int i=1;i<=n;i++)scanf("%lld",a+i);

//for(int i=1;i<=n;i++)
//    for(int j=i+1;j<=n;j++)
//for(int k=j+1;k<n;k++){
//
//    ll p=0,q=0,r=0,s=0;
//    for(int m=1;m<=i;m++)p+=a[m];
//    for(int m=i+1;m<=j;m++)q+=a[m];
//    for(int m=j+1;m<=k;m++)r+=a[m];
//    for(int m=k+1;m<=n;m++)s+=a[m];
//
//        cout<<p<<" "<<q<<" "<<r<<" "<<s<<" : "<<max( max(p,q),max(r,s) )-min( min(p,q),min(r,s) )<<endl;
//}
//return 0;


for(int i=n;i;i--){
    sum+=a[i];
    suf.insert(sum);
}

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

    suf.erase( suf.find(sum) );
    sum-=a[i];

    sum2+=a[i];
    pre.insert( sum2 );

    if( pre.size()>1 && suf.size()>1 ){

        for(int x=0;x<2;x++){
            for(int y=0;y<2;y++){

        auto it1 = pre.upper_bound( sum2/2ll );
        if( *it1 == sum2 )it1--;
        if(x && it1!=pre.begin())it1--;

        auto it2 = suf.upper_bound( sum/2ll );
        if( *it2 == sum )it2--;
        if(y && it2!=suf.begin())it2--;

        ll p = *it1 , q=sum2-*it1;
        ll r = *it2 , s=sum-*it2;
        ans=min(ans, max( max(p,q),max(r,s) )-min( min(p,q),min(r,s) ) );
            }
        }

    }

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


Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数

//-------------------------------------------------
// 
void yes(){
  cout <<"Yes"<<endl ;
}
void no(){
  cout <<"No"<<endl ;
}


//-------------------------------------------------
// メモ




//-------------------------------------------------


int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n ;
  cin >> n ;
  if(n%2==0){
    cout << n/2 <<endl ;
  }
  else{
    cout << n/2+1 <<endl ;
  }
  
  
  
  return 0 ;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int N, X;

void solve() {
	cin >> N >> X;
	int res = 1;
	int x = 0;
	rep(i, 0, N) {
		int l; cin >> l;
		x += l;
		if(x <= X) res++;
	}
	cout << res << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}


int N, M, V, P;
vector<int> A;

bool check(int m){
	vector<int> B(A);
	int sum = M * V;
	int hoge = N, con = 0;
	
	if(m <= 0) return false;
	if(m > N) return true;
	
	B[m-1] += M;
	sum -= M;
	
	for(int i = 0, j = 0; i < m-1 && j < V-1; i++, j++){
		B[i] += M;
		sum -= M;
	}
	// cout<<"A"<<endl;
	
	for(int i = N-1; i >= m;i--){
		if(A[i] > B[m-1]) {
			B[i] += M;
			sum -= M;
			hoge = i;
			con++;
		}
	}
	// cout<<"B"<<endl;
	if(con >= P) return false;
	if(sum <= 0) return true;
	
	for(int i = m; i < hoge; i++){
		
		B[i] = B[m-1];
		sum -= B[m-1] - A[i];
	}
	// cout<<"C"<<endl;
	if(sum <= 0) return true;
	
	for(int i = hoge-1; i >= m; i--){
		if(A[i] == A[m-1]) break;
		con++;
		sum += B[m-1] - A[i];
		sum -= M;
		
		if(con >= P) return false;
		if(sum <= 0) return true;
	}
	// cout<<"D"<<endl;
	if(con >= P) return false;
	if(sum <= 0) return true;
	// cout<<"E"<<endl;
	return false;
}

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	
	
	cin>>N>>M>>V>>P;
	
	A.resize(N);
	
	for(int i = 0; i < N; i++){
		cin>>A[i];
	}
	
	sort(A.begin(), A.end());
	
	int l = 0, h = N, m;
	
	while(l + 1 < h){
		m = (l + h)>>1;
		
		if(check(m)){
			h = m;
		} else {
			l = m;
		}
	}
	
	// for(int i = 0; i <= N; i++){
		// cout<<"i = "<<i<<" check "<<check(i)<<endl;
	// }
	
	cout<<N - h + 1<<endl;
	
	return 0;
}

/*
6 1 2 1
1000 1 1 3 0 2


*/

Measured memory_bytes: 1792
#include <cstdio>
#include <algorithm>
#include <vector>

#define INF 10000

using namespace std;

struct mn
{
    int n;
    int m;
};

bool mcomp(const mn& left, const mn& right) {
    return left.m < right.m || (left.m == right.m && left.n > right.n);
}

bool ncomp(const mn& left, const mn& right) {
    return left.n > right.n;
}

int main() {
    int N, M, a, i, j;
    int match[] = {0,2,5,5,4,5,6,3,7,6};
    scanf("%d %d",&N,&M);
    vector<mn> A;
    for (i=0; i<M; i++) {
        scanf("%d", &a);
        mn mn1 = {a, match[a]};
        A.push_back(mn1);
    }
    sort(A.begin(), A.end(), mcomp);
    int prev = A[0].m;
    for (i=1; i<M; i++) {
        if (A[i].m == prev) {
            A.erase(A.begin()+i);
            M--; i--;
        }
        else
            prev = A[i].m;
    }
    int dp[N+1];
    dp[0] = 0;
    fill(dp+1, dp+N+1, -INF);
    for (i=0; i<N; i++) {
        if (dp[i] < 0) continue;
        for (j=0; j<M; j++) {
            if (i + A[j].m <= N)
                dp[i + A[j].m] = max(dp[i + A[j].m], dp[i] + 1);
            else 
                break;
        }
    }
    sort(A.begin(), A.end(), ncomp);
    while (N > 0) {
        for (i=0; i<M; i++) {
            if ((dp[N] > 1 && dp [N - A[i].m] == dp[N] - 1) || (dp[N] == 1 && N - A[i].m == 0)) {
                printf("%d", A[i].n);
                N -= A[i].m;
                break;
            }
        }
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace abc131_c
{
    class Program
    {
        static void Main(string[] args)
        {
            var ABCD = Console.ReadLine().Split(' ').Select(x => decimal.Parse(x)).ToList();

            decimal A = ABCD[0];
            decimal B = ABCD[1];
            decimal C = ABCD[2];
            decimal D = ABCD[3];

            var CL = new List<long>();
            var DL = new List<long>();
            var EL = new List<long>();

            var CC = Math.Floor(B / C) - Math.Floor(A / C); //Cの倍数の数
            if (A % C == 0) CC++;
            
            decimal DC = 0;
            decimal LCMC = 0;

            if ( C != D) 
            {
                DC = Math.Floor(B / D) - Math.Floor(A / D); //Dの倍数の数
                if (A % D == 0) DC++;

                var LCM = Lcm(C, D); // C,Dの最小公倍数
                LCMC = Math.Floor(B / LCM) - Math.Floor(A / LCM); //最小公倍数の倍数の数
                if (A % LCM == 0) LCMC++;
            }

            Console.WriteLine(B - A + 1 - (CC + DC - LCMC));
        }

        // 最小公倍数
        public static decimal Lcm(decimal a, decimal b)
        {
            return a * b / Gcd(a, b);
        }

        // ユークリッドの互除法 
        public static decimal Gcd(decimal a, decimal b)
        {
            if (a < b)
                // 引数を入替えて自分を呼び出す
                return Gcd(b, a);
            while (b != 0)
            {
                var remainder = a % b;
                a = b;
                b = remainder;
            }
            return a;
        }

    }
}


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

public class Main {
    static class Reader {
        BufferedReader in;

        Reader() throws IOException {
            in = new BufferedReader(new InputStreamReader(System.in));
        }

        Reader(String name) throws IOException {
            in = new BufferedReader(new FileReader(name));
        }

        StringTokenizer tokin = new StringTokenizer("");

        String next() throws IOException {
            if (!tokin.hasMoreTokens()) {
                tokin = new StringTokenizer(in.readLine());
            }
            return tokin.nextToken();
        }

        int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

    }
    static class Writer {
        PrintWriter cout;

        Writer() throws IOException {
            cout = new PrintWriter(System.out);
        }

        Writer(String name) throws IOException {
            cout = new PrintWriter(new FileWriter(name));
        }

        StringBuilder out = new StringBuilder();

        void print(Object a) {
            out.append(a);
        }

        void println(Object a) {
            out.append(a + "\n");
        }

        void close() {
            cout.print(out.toString());
            cout.close();
        }
    }

    public static void main(String args[]) throws IOException {
        Reader in = new Reader();
        Writer out = new Writer();
        int n = in.nextInt();
        TreeSet<String> t = new TreeSet<>();
        boolean must = true;
        String last = in.next();
        t.add(last);
        for (int i = 1; i < n; i++) {
            String s = in.next();
            if(t.contains(s)) {
                must = false;
            } else {
                t.add(s);
            }
            if(last.charAt(last.length() - 1) != s.charAt(0))
                must = false;
            last = s;
        }
        if(must){
            out.print("Yes");
        } else {
            out.print("No");
        }
        out.close();
    }
}

Measured memory_bytes: 22740
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    
    int min = INT_MAX;
    for(int i=1;i<N;i++){
        string S,T;
        S = to_string(i);
        T = to_string(N-i);
        int sum=0;
        for(int k=0;k<S.size();k++){
            sum += S.at(k) - '0';
        }
        for(int k=0;k<T.size();k++){
            sum += T.at(k) - '0';
        }
        if(sum < min)   min = sum;
    }
    cout << min << endl;
}


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

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

  int t[n];
  int time = 0;
  for (int i=0;i<n;i++) {
    cin >> t[i];
    time += t[i];
  }

  int m;
  cin >> m;
  int p,x;
  int juice[m];
  for (int i=0;i<m;i++) {
    cin >> p >> x;
    juice[i] = time - t[p-1] + x;
  }
  for (int i=0;i<m;i++) {
    cout << juice[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

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

int get_int(void) {
  int num;
  scanf("%d", &num);
  return num;
}

int get_str(char *str, int size)
{
    char format[100];
    if (size == 0)
        return 0;
    snprintf(format, sizeof(format), "%%%ds", size);
    scanf(format, str);
    return 0;
}

#define NUM_MAX 150

int main(void) {
    int num = get_int();
    char str[NUM_MAX];
    get_str(str, num);

    int i, j;
    static int map[NUM_MAX];
    int ans = 0;
    for(i = 0; i < num-1; i++) {
        map[str[i]-'a']++;
        // [0, i] and [i+1, i]
        int res = {0};
        for(j = i+1; j < num; j++) {
            int idx = str[j] - 'a';
            if(map[idx]) res |= (1<<idx);
        }
        ans = max(ans, __builtin_popcount(res));
    }
    printf("%d\n", ans);
}

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

int main() {
	int n, k, d[9];
	cin >> n >> k;
	for (int i = 0; i < k; i++) {
		cin >> d[i];
	}
	while (true) {
		bool f = false;
		string s = to_string(n);
		for (int i = 0; i < s.size(); i++) {
			for (int j = 0; j < k; j++) {
				if (s[i] == '0' + d[j]) {
					f = true;
					break;
				}
			}
			if (f)break;
		}
		if (!f) {
			cout << n << endl;
			break;
		}
		n++;
	}
	return 0;
}



Measured memory_bytes: 256
h,w=map(int,input().split())
ans=10**9
for i in range(1,w):
  ans=min(max(abs(i*h-h//2*(w-i)),abs(i*h-(h+1)//2*(w-i)),((h+1)//2-h//2)*(w-i)),ans)
for i in range(1,h):
  ans=min(max(abs(i*w-w//2*(h-i)),abs(i*w-(w+1)//2*(h-i)),((w+1)//2-w//2)*(h-i)),ans)
if h%3==0 or w%3==0:
  ans=0
else:
  ans=min(ans,h,w)
print(ans)

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

#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define mod 1000000007
#define inf 100000000000010
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
#define all(x) (x).begin(), (x).end()

typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> pi;

bool isprime(ll n)
{
    if(n<=1)return false;
    if(n<=3)return true;
    if(n%2==0||n%3==0)return false;
    for(ll i=5;i*i<=n;i+=6)
    {
        if(n%i==0||n%(i+2)==0)return false;
    }
    return true;
}

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

struct CustomCompare
{
    bool operator()(const int& lhs, const int& rhs)
    {
        return lhs < rhs;
    }
};

bool comp(pair<pi, ll>a,pair<pi,ll>b)
{
    if(a.fi.fi==b.fi.fi)return a.fi.se<b.fi.se;
    return a.fi.fi<b.fi.fi;
}

ll builtin_popcount(ll x)
{
    ll cnt = 0;
    for(ll i=60;i>=0;i--)
    {
        if((1LL<<i)&x)cnt++;
    }
    return cnt;
}

ll addmod(ll a,ll b)
{
    a%=mod;
    b%=mod;
    return (a+b)%mod;
}
ll mulmod(ll a,ll b)
{
    a%=mod;
    b%=mod;
    return (a*b)%mod;
}
/*
const int mxn = 5*(1e6) +10;
vi spf(mxn);
void sieve()
{
    for(ll i =0;i<mxn;i++)spf[i]  = i;
    for(ll i=2;i<mxn;i+=2)spf[i] = 2;
    for(ll i = 3;i*i<mxn;i++)
    {
        if(spf[i]==i)
        {
            for(ll j = i*i;j<mxn;j+=i)
            {
                if(spf[j]==j)spf[j] = i;
            }
        }
    }
}
*/

int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
ll x,k,d; cin>>x>>k>>d;
x = llabs(x);
ll mv = x/d;
//cout<<mv<<endl;
if(mv>=k)
{
    cout<<x-k*d<<endl;
}
else
{
    k-=mv;
    ll pos = x - mv*d;
    if(k%2)cout<<(mv+1)*d-x<<endl;
    else cout<<x-mv*d<<endl;
}
return 0;
}
/*
23 5
10 3 3
2 1 4 11 8 10 5 6 7 9 12 3 14 13 16 18 21 15 17 19 20 23 22
4 6 3 18 23
*/


Measured memory_bytes: 3608
#include<stdio.h>

int search(int);

int  S[100000], q, key, count=0,i,n,mid;
int main(){

 

  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){ 
    scanf("%d", &S[i]);
  }

  scanf("%d", &q);

  for ( i = 0; i < q; i++ ){
   
    scanf("%d", &key);
    if ( search(key)) count++;
  }
  printf("%d\n", count);


  return 0;
}
int search(int key){
  int left =0;
  int right = n;

  while(left < right){
    mid = (left + right)/ 2;
    if( S[mid]== key) return 1;
      
    else if(key < S[mid]){
      right = mid;
    } else {
      left = mid + 1;
    }
  }
  return 0;
}

Measured memory_bytes: 988
N, k = map(int, input().split())
L = [0] * N
K = [0] * N
for i in range(N):
    K[i], *L[i] = list(map(int, input().split()))
    if i == 0:
        ans = set(L[i])
        continue
    ans = ans & set(L[i])
print(len(ans))

Measured memory_bytes: 3060
#include <stdio.h>

int main(void) {
        int a,b;

        scanf("%d %d", &a, &b);
        if(-1000 >= a || -1000 >= b || a <= -1000 || b <= -1000) {
           printf("input error\n");
           return 1;
        }

        if(a < b) {
                printf("a < b\n");
        }else if(a > b) {
                printf("a > b\n");
        }else if(a == b) {
                printf("a == b\n");
        }else {
                printf("others\n");
        }

        return 0;
}



Measured memory_bytes: 2056