akhauriyash/Code-Regression huggingface dataset:
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define PB push_back
#define MP make_pair

int L, N;
LL X[200000];
LL sum[2][200000];
int main(){
	cin >> L >> N;
	for(int i=0; i<N; i++) cin >> X[i];
	for(int i=0; i<N; i++) sum[0][i] = (i == 0 ? 0 : sum[0][i-1]) + 2*X[i];
	for(int i=N-1; i>=0; i--) sum[1][i] = (i == N-1 ? 0 : sum[1][i+1]) + 2*(L-X[i]);
	//時計回りで一気に
	LL ans = 0;
	for(int i=N-1; i>=0; i--){
		if(i == 0){
			ans = max(ans, L-X[0]);
			break;
		}
		LL tmp = (L - X[i]) * 2;
		if(i%2 == 0){
			tmp += sum[0][i/2-1];
			tmp += sum[1][i/2];
			tmp -= sum[1][i];
			tmp -= L-X[i/2];
		}
		else{
			tmp += sum[0][i/2];
			tmp -= X[i/2];
			tmp += sum[1][i/2+1];
			tmp -= sum[1][i];
		}
		ans = max(ans, tmp);
	}
	//反時計回りで一気に
	for(int i=0; i<N; i++){
		if(i == N-1){
			ans = max(ans, X[N-1]);
			break;
		}
		LL tmp = X[i] * 2;
		if((i+N)%2 == 0){
			tmp += sum[0][(N+i)/2-1];
			tmp -= sum[0][i];
			tmp += sum[1][(N+i)/2];
			tmp -= L-X[(N+i)/2];
		}
		else{
			tmp += sum[0][(N+i)/2];
			tmp -= sum[0][i];
			tmp -= X[(N+i)/2];
			tmp += sum[1][(N+i)/2+1];
		}
		ans = max(ans, tmp);
	}
	cout << ans << endl;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
int32_t main(){
    IOS;
    string t;
    cin >> t;
    if(t[2] == t[3] && t[4] == t[5]){
    	cout << "Yes\n";
    } else {
    	cout << "No\n";
    }
    return 0;
}



Measured memory_bytes: 3596
//B Tap Dance
#include "bits/stdc++.h"
using namespace std;

int main()
{
  int n;
  string s;
  cin>>s;
  n=s.size();
  for(int i=0;i<n;i++)
  {
    if(i%2==0)
    {
      if(s.at(i)=='L')
      {
        cout<<"No"<<endl;
        break;
      }
    }
    if(i%2==1)
    {
      if(s.at(i)=='R')
      {
        cout<<"No"<<endl;
        break;
      }
    }
    if(i==n-1)
    {
      cout<<"Yes"<<endl;
    }
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
     
     
    int main(){
    	int n,a;
    	long long sum=0;
    	bool ok=false;
    	cin >> n;
    	for(int i=0;i<n;i++){
    		cin >> a;
    		if(ok&&a>0){
    			a--;
    			sum++;
    		}
    		sum+=a/2;
    		ok=a%2?true:false;
    	}
    	cout << sum << endl;
    	return 0;
    }

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


int main() {
  int n;
  cin >> n;
  
  vector<string> s(n);
  vector<int> t(n);
  
  for(int i=0;i<n;i++){
    cin>>s.at(i);
    cin>>t.at(i);
  }
  string x;
  cin >>x;
  
  int a=0;
  for(int i=0;i<n;i++){
    if(x==s.at(i)){
      a=i+1;
      break;
    }
  }
  
  int c=a;
  
  int sum=0;
  for(int c=a;c<n;c++){
    sum+=t.at(c);
  }
  
  cout << sum <<endl;
}
    
    

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <limits>
#include <sstream>

using namespace std;

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

	cout << n * m << endl;
}


Measured memory_bytes: 3108
#include <iostream>
#include <vector>

int main() {
  unsigned N;
  std::cin >> N;
  std::vector<unsigned long long> A(N), B(N);
  for (unsigned i = 0; i < N; ++i) {
    std::cin >> A[i] >> B[i];
  }
  unsigned long long push = 0u;
  for (unsigned i = N ; i-- > 0u; ) {
    auto tmp = (A[i] + push) % B[i];
    if (tmp) {
      push += B[i] - tmp;
    }
  }
  std::cout << push << std::endl;
  return 0;
}


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

int main() {
  int n;
  cin>>n;
  if (n==1) {
    cout<<1<<endl;
    return 0;
  }
  int x[55];
  int y[55];
  for (int i=0; i<n; i++) {
    cin>>x[i]>>y[i];
  }
  vector<pair<int,int>> v;
  for (int i=0; i<n-1; i++) {
    for (int j=i+1; j<n; j++) {
      v.push_back({x[i]-x[j],y[i]-y[j]});
      v.push_back({-(x[i]-x[j]),-(y[i]-y[j])});
    }
  }
  sort(v.begin(),v.end());
  int a=v[0].first,b=v[0].second;
  int cnt=0,ans=0;
  for (int i=0; i<n*(n-1)/2; i++) {
    if (a==v[i].first&&b==v[i].second)
      cnt++;
    else {
      ans=max(ans,cnt);
      a=v[i].first;
      b=v[i].second;
      cnt=1;
    }
  }
  ans=max(ans,cnt);
  cout<<n-ans<<endl;
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define kk 1000000007
int l,n,m,k,a,b,c,tmp,cc[300005],u,v,gp1[300005],gp2[300005],an1[300005],an2[300005],an3[300005];
vector<int > ee;
map<pair<int ,int > ,int > mm;
int find1(int x){
	return gp1[x] == x? x : gp1[x] = find1(gp1[x]); 
}
int find2(int x){
	return gp2[x] == x? x : gp2[x] = find2(gp2[x]); 
}
char g;
int main(){
	scanf("%d%d%d",&n,&k,&l);
	for (int i=1;i<=n;i++) gp1[i] = i;
	for (int i=1;i<=n;i++) gp2[i] = i;	
	
	for (int i=0;i<k;i++){
		scanf("%d%d",&u,&v);
		gp1[find1(gp1[u])] = find1(gp1[v]);
	}
	
	for (int i=0;i<l;i++){
		scanf("%d%d",&u,&v);
		gp2[find2(gp2[u])] = find2(gp2[v]);
	}
	for (int i=1;i<=n;i++){
		if (!an1[find1(gp1[i])]) an1[find1(gp1[i])] = ++tmp;
		if (!an2[find2(gp2[i])]) an2[find2(gp2[i])] = ++tmp;		
	}
	for (int i=1;i<=n;i++){
		u = find1(gp1[i]);
		v = find2(gp2[i]);
		mm[mp(an1[u],an2[v])] ++;
	}
	for (int i=1;i<=n;i++){
		u = find1(gp1[i]);
		v = find2(gp2[i]);	
		an3[i] = mm[mp(an1[u],an2[v])];	
	}	
	for (int i=1;i<=n;i++) printf(i==n?"%d\n":"%d ",an3[i]);
}

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

int main()
{
	int a, b, k, x;
	int count = 0;
	cin >> a >> b >> k;
	if (a < b) {
		x = b;
		b = a;
		a = x;
	}
	for (int i = a; i > 0; i--) {
		if (a%i == 0 && b % i == 0) {
			count++;
		}
		if (count == k) {
			cout << i << endl;
			return 0;
		}
	}
}

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

bool IsPrime(int num){
   if (num == 2) return true;
    else if (num % 2 == 0) return false; 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2){
        if (num % i == 0)
            return false;
    }
    return true;
}

int main() {
  int x;
  cin >> x;
  int i=x;
  while(!IsPrime(i))i++;
  cout << i << endl;
}


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

const unsigned long long int MOD = 1000000007;

/* 繰り返し二乗法 */
unsigned long long int mod_repeat_squaring(int n, int p, int mod)
{
    if (p == 0)
    {
        return 1;
    }
    if (p & 1)
    {
        return (n % mod) * mod_repeat_squaring(n, p - 1, mod) % mod;
    }
    else
    {
        return (mod_repeat_squaring(n, p / 2, mod) % mod) * mod_repeat_squaring(n, p / 2, mod) % mod;
    }
}

unsigned long long int mod_comb(int n, int r, int mod)
{
    std::vector<unsigned long long int> fact(n + 1), fact_inv(n + 1);
    
    // 階乗の計算
    fact[0] = 1; //初期値fact[0]からfact[n]まで求めていく
    for (int i = 0; i < n; i++)
    {
        fact[i + 1] = fact[i] * (i + 1) % mod;
    }
    
    // 逆元の計算
    fact_inv[n] = mod_repeat_squaring(fact[n], mod - 2, mod) % mod; //初期値fact_inv[n]からfact_inv[0]まで求めていく
    for (int i = n - 1; i >= 0; i--)
    {
        fact_inv[i] = (fact_inv[i + 1] % mod) * (i + 1) % mod;
    }
    
    return ((fact[n] % mod) * fact_inv[r] % mod) * fact_inv[n - r] % mod;
}

int main() {
    int x, y;
    std::cin >> x >> y;

    if ((x + y) % 3 != 0)
    {
        std::cout << 0 << std::endl;
        return 0;
    }

    int n = (- x + 2 * y) / 3;
    int m = (2 * x - y) / 3;

    if (n < 0 || m < 0)
    {
        std::cout << 0 << std::endl;
        return 0;
    }
    
    if (n + m == 0 || n == 0)
    {
        std::cout << 1 << std::endl;
        return 0;
    }
    
    std::cout << mod_comb(n + m, n, MOD) << std::endl;

    return 0;
}

Measured memory_bytes: 13816
from collections import deque
N=int(input())
G=[[] for i in range(N)]
for i in range(N-1):
    a,b=map(int,input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)
stack1=deque(G[0])
stack2=deque(G[N-1])
X=[-1]*N
X[0]=1
X[N-1]=0
while(stack1 or stack2):
    Stack1=deque()
    for i in stack1:
        if X[i]==-1:
            X[i]=1
            for j in G[i]:
                if X[j]==-1:
                    Stack1.append(j)
    stack1=Stack1
    Stack2=deque()
    for i in stack2:
        if X[i]==-1:
            X[i]=0
            for j in G[i]:
                if X[j]==-1:
                    Stack2.append(j)
    stack2=Stack2
f,s=0,0
for i in range(N):
    if X[i]==1:
        f+=1
    else:
        s+=1
if f>s:
    print("Fennec")
else:
    print("Snuke")


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

typedef struct P{
    int num;
    int left;
    int right;
}Node;

void pre(Node node[],int n){
    if(n==-1){return;}
    printf(" %d",node[n].num);
    pre(node,node[n].left);
    pre(node,node[n].right);
}

void ino(Node node[],int n){
    if(n==-1){return;}
    ino(node,node[n].left);
    printf(" %d",node[n].num);
    ino(node,node[n].right);
}

int insert(Node node[],int n,int x,int num){
    int ii=0;
    if(n==-1||node[n].num==-1){
        node[x].num = num;
        return x;
    }else if(node[n].num>num){
        ii = insert(node,node[n].left,x,num);
        if(ii!=0){
            node[n].left = ii;
        }
    }else{
        ii = insert(node,node[n].right,x,num);
        if(ii!=0){
            node[n].right = ii;
        }
    }
    return 0;
}

int find(Node node[],int n,int num){
    if(n==-1){return 0;}
    else if(node[n].num>num){return find(node,node[n].left,num);}
    else if(node[n].num<num){return find(node,node[n].right,num);}
    else{return 1;}
}

int main(void){
    int n,i,j,x,y;
    char str[7];
    Node *node;
    scanf("%d",&n);
    node = (Node*)malloc(sizeof(Node)*n);
    for(i=0;i<n;i++){
        node[i].num = -1;
        node[i].left = -1;
        node[i].right = -1;
    }
    x = 0;
    for(i=0;i<n;i++){
        scanf("%s",str);
        if(str[0]=='i'){
            scanf("%d",&y);
            insert(node,0,x,y);
            x++;
        }else if(str[0]=='f'){
            scanf("%d",&y);
            y = find(node,0,y);
            if(y==1){printf("yes\n");}
            else{printf("no\n");}
        }else{
            ino(node,0);
            printf("\n");
            pre(node,0);
            printf("\n");
        }
    }
    return 0;
}


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

using namespace std;

int main(){
    int n;
    cin>>n;
    vector<int> p(n);
    for(int i=0; i<n; ++i){
        cin>>p[i];
    }

    int cnt=0;
    for(int i=1; i<n-1; ++i){
        if((p[i]<p[i-1] && p[i]>=p[i+1]) || (p[i]<p[i+1] && p[i]>=p[i-1])){
            cnt++;
        }
    }
    cout<<cnt<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
 
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	char a,b;
	cin>> a>> b;
	if(a==b)
	{
		cout<<"H";
	}
	else

	{
		cout<<"D";
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;cin>>N;
  string S;cin>>S;
  vector<int>A(N+1);
  vector<int>B(N+1);
  for(int i=0;i<N;i++){
    if(i!=0)A[i+1]+=A[i];
    if(S.at(i)=='#')A[i+1]++;
  }
  for(int i=N-1;i>=0;i--){
    if(i!=N-1)B[i]+=B[i+1];
    if(S.at(i)=='.')B[i]++;
  }
  int ans=10000000;
  for(int i=0;i<=N;i++){
    ans=min(ans,A[i]+B[i]);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 5248
#include <stdio.h>

int main(void)
{
    int x1, y1, x2, y2;
    scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
    int x = x2 - x1;
    int y = y2 - y1;
    printf("%d %d %d %d\n", x2 - y, y2 + x, x1 - y, y1 + x);

    return 0;
}

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

#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define min4(a,b,c,d) min(min(a,b),min(c,d))
#define max4(a,b,c,d) max(max(a,b),max(c,d))
#define count_one(a) __builtin_popcount(a)  // Returns the number of set bits(1) in a number(a). In long long use __builtin_popcountll(a)
#define parity(i)   __builtin_parity(i)  //even parity 0 and odd parity 1
#define blz(a)   __builtin_clz(a) //Returns the number of leading zeroes in a number(a)
#define btz(a)   __builtin_ctz(a) //Returns the number of trailing zeroes in a number(a)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define ll long long
#define pb push_back
#define PI M_PI
#define endl "\n"
#define sc scanf
#define pf printf
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
int main()
{
     IOS
     int k,a,b;

     cin>>k>>a>>b;
     for(int i = a; i <= b; i++)
     {
          if(i%k==0)
          {
               cout<<"OK\n";
               return 0;
          }
     }
     cout<<"NG\n";
     return 0;
}



Measured memory_bytes: 3652
import sys
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
enum = enumerate
inf = 1001001002002002002

import random

def linput(ty=int, cvt=list):
	return cvt(map(ty,input().rstrip().split()))

def vinput(rep=1, ty=int, cvt=list):
	return cvt(ty(input().rstrip()) for _ in "*"*rep)

def gcd(a: int, b: int):
	while b: a, b = b, a%b
	return a

def lcm(a: int, b: int):
	return a * b // gcd(a, b)

def bye(res):
	sT = "No Yes".split()
	print(sT[res])
	#exit(0)

def sol(N,A,B,C,D):
	res = inf
	at,bt,ct,dt = [0,]*4
	an,bn,cn,dn = [0,]*4
	cn = N
	for c in range(32):
		bn = cn
		for b in range(42):
			an = bn
			for a in range(63):
				dt = at+bt+ct+ an
				r = a*A+b*B+c*C+dt*D
				if res>r: print(a,b,c,dt,r)###
				res = min(res, r)
				if not an: break
				at += an%2
				an = an//2
			at = 0
			bt += 0<bn%3
			bn = bn//3 + (bn%3==2)
		bt = 0
		cMod5 = cn%5
		ct += min(5-cMod5, cMod5)
		cn = cn//5 + (cMod5>2)
	
	print(res)

def sol2(N,A,B,C,D):
	dM = dict({0: 0, 1: D})
	
	def dfs(n):
		if n in dM.keys():
			return dM[n]

		res = min(
				D*n,
				D*(n%2) + A + dfs(n//2),
				D*(n%3) + B + dfs(n//3),
				D*(n%5) + C + dfs(n//5),
				D*(n%2) + A + dfs((n+1)//2),
				D*((3 - n%3)%3) + B + dfs((n+2)//3),
				D*((5 - n%5)%5) + C + dfs((n+4)//5)
			)

		dM[n] = res
		return res
	
	dfs(N)
	#print(dM)###
	print(dM[N])


def main():
	T, = linput()
	for _ in "*"*T:
		sol2(*linput())

def ran():
	vRan = [random.randint(1,10) for _ in "*"*5]
	print(vRan)
	sol2(*vRan)

if __name__ == "__main__":
	main()
	#ran()


Measured memory_bytes: 20460
n=int(input())
a=list(map(int,input().split()))

for i in range(n):
    a[i]-=(i+1)
a.sort()

a_sum=[a[0]]
a_minus_sum=[-a[0]]

for i in range(1,n):
    a_sum.append(a[i]+a_sum[-1])
    a_minus_sum.append(-a[i]+a_minus_sum[-1])

ans=min(a_sum[-1]-a[0]*n,a_minus_sum[-1]+a[-1]*n)

for g in range(1,n-1):
    ans=min(a[g]*(-n+2*g+1)+a_sum[-1]-a_sum[g]+a_minus_sum[g-1],ans)

print(ans)

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

void solve(){
    int n;
    cin>>n;
    vector<double> dp(n+1);
    dp[0]=1;
    
    for(int i=0;i<n;i++){
        double p;
        cin>>p;
        for(int j=i+1;j>=0;j--){
            dp[j]=(j>0?dp[j-1]*p:0)+dp[j]*(1-p);
        }
    }
    double ans=0;
    for(int i=(n+1)/2;i<=n;i++) ans+=dp[i];
    cout<<setprecision(10)<<ans;
}

int main() {
	// your code goes here
	//freopen("inptmp0.txt","r",stdin);
	int T;
	
	//cin>>T;
	T=1;
	while(T--){
	    solve();
	}
	return 0;
}


Measured memory_bytes: 3832
import copy
N = int(input())
p = list(map(int,input().split()))
ph = copy.copy(p)
sp = copy.copy(p)
sp.sort()
for i in range(N-1):
  for j in range(i,N):
    tmp = ph[i]
    ph[i] = ph[j]
    ph[j] = tmp
    if sp == ph:
      print('YES')
      exit()
    ph = copy.copy(p)
print('NO')


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

typedef long long int int64;

#define MIN(a,b) ((a)<(b)?(a):(b))

#define POS(i,j)  ((i)*(400+1)+(j))

int a[100];

int64 calc(int x,int y,int64 *dp){
  if(y-x<=1) return 0;
  if(dp[POS(x,y)]>0) return dp[POS(x,y)];
  int64 local=1000000000000000000LL;
  int i;
  for(i=x+1;i<y;i++){
    int64 t=calc(x,i,dp)+calc(i,y,dp);
    local=MIN(local,t);
  }
  int64 sum=0;
  for(i=x;i<y;i++) sum+=a[i];
  dp[POS(x,y)]=local+sum;
  return dp[POS(x,y)];
}

void run(void){
  int n;
  scanf("%d",&n);
  int i;
  for(i=0;i<n;i++) scanf("%d",a+i);
  int64 *dp=(int64 *)calloc((400+1)*(400+1),sizeof(int64));
  int64 ans=calc(0,n,dp);
  printf("%lld\n",ans);
}

int main(void){
  run();
  return 0;
}


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


int main(){
    int n;
    vector<int> v;
    cin>>n;

    int hoge;
    for(int i=0;i<n;i++){
        cin>>hoge;
        v.push_back(hoge);
    }

    sort(v.begin(), v.end(), greater<int>());

    int ans=0;

    for(int i=0;i<n;i++){
        if(i%2==0)ans+=v[i];
        else ans-=v[i];
    }
    cout<<ans<<endl;

}



Measured memory_bytes: 256
import math
def main():
    a, b, C = map(int, input().split())
    C /= 180
    C *= math.pi
    
    S = 1 / 2 * a * b * math.sin(C)
    L = math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(C)) + a + b
    h = 2 * S / a
    print(S)
    print(L)
    print(h)


if __name__ == "__main__":
    main()

Measured memory_bytes: 7980
#include<bits/stdc++.h>
using namespace std;
#define INF INT_MAX
int main(void){
	int v, e;
	cin >> v >> e;
	long leng[v][v];
	fill(leng[0], leng[v], INF);
	for(int i = 0; i < v; i++) leng[i][i] = 0;
	for(int i = 0; i < e; i++){
		int a, b, c;
		cin >> a >> b >> c;
		leng[a][b] = (long)c;
	}
	for(int k = 0; k < v; k++){
		for(int i = 0; i < v; i++){
			for(int j = 0; j < v; j++){
				if(leng[i][k] != INF && leng[k][j] != INF)
					leng[i][j] = min(leng[i][j], leng[i][k] + leng[k][j]);
			}
		}
	}
	int flg = 1;
	for(int i = 0; i < v; i++){
		if(leng[i][i] < 0){
			flg = 0;
			break;
		}
	}
	if(!flg) cout << "NEGATIVE CYCLE" << endl;
	else {
		for(int i = 0; i < v; i++){
			for(int j = 0; j < v - 1; j++){
				if(leng[i][j] != INF) cout << leng[i][j] << ' ';
				else cout << "INF" << ' ';
			}
			if(leng[i][v - 1] != INF) cout << leng[i][v - 1] << endl;
			else cout << "INF" << endl;
		}
	}
	return 0;
}


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

#define int long long

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

    priority_queue<int> que;

    for(int i = 0;i < n;i++){
        int a;
        cin >> a;
        que.push(a);
    }

    for(int i = 0;i < m;i++){
        int tmp = que.top();
        que.pop();
        tmp /= 2;
        que.push(tmp);
    }

    int ans = 0;
    for(int i = 0;i < n;i++){
        ans += que.top();
        que.pop();
    }

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

Measured memory_bytes: 1400
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int c = Integer.parseInt(sc.next());
        int x = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        int result = 0;
        for (int i = 0; i <= a; i++) {
            for (int j = 0; j <= b; j++) {
                for (int j2 = 0; j2 <= c; j2++) {
                    int value = 500 * i + 100 * j + 50 * j2;
                    if (value == x) {
                        result++;
                    }
                }
            }
        }

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


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

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

    vec<ll> Y(N + 1);
    for (int i = 1; i <= N; ++i) {
        for(int j =i;j<=N;j+=i){
            Y[j]+=1;
        }
    }
    ll ans = 0;
    for (ll i = 1; i <= N; ++i) {
        ans+=(i*Y[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 81300
#include <iostream>
#include <string>
#include <algorithm>

#define EOS "END_OF_TEXT"

using namespace std;

int main() {
	int cnt = 0;
	string target;
	string s;
	
	cin >> target;
	cin >> s;

	transform(target.begin(), target.end(), target.begin(), ::tolower);

	while(s != EOS) {
		transform(s.begin(), s.end(), s.begin(), ::tolower);
		
		if(s == target) 
			cnt++;

		cin >> s;
	}

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 3184
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void) {
  int n, a[100001], ans = 0, soe = 1, flag = 0;

  if(scanf("%d", &n) == 1);

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

  for(int i = 0; i < n; i++) {
    ans++;
    if((soe = a[soe - 1]) == 2) {
      printf("%d", ans);
      flag = 1;
      break;
    }
  }

  if(!flag) {
    printf("-1");
  }

  return 0;
}


Measured memory_bytes: 512
n, m = map(int, input().split())
VW = [tuple(map(int, input().split())) for i in range(n)]
V = [v for v, w in VW]
W = [w for v, w in VW]
# n, m = 4, 5
# V = [4, 5, 2, 8]
# W = [2, 2, 1, 3]
# DP[i][j]=i個の品物で重さj以内で最大価値
DP = [[0 for j in range(m+1)] for i in range(n+1)]
for i in range(n):
    for j in range(m+1):
        if j < W[i]:
            DP[i+1][j] = DP[i][j]
        else:
            DP[i+1][j] = max(DP[i][j], DP[i][j-W[i]]+V[i])
print(DP[n][m])



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

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

    char a_char = '0' + a;
    char b_char = '0' + b;

    string a_str(b, a_char);
    string b_str(a, b_char);

    if (a_str < b_str) {
        cout << a_str << endl;
    } else {
        cout << b_str << endl;
    }
}

Measured memory_bytes: 256
open Printf
open Scanf

let input_string () =
  scanf "%s\n" (fun s -> s)

let input_int () =
  scanf "%d\n" (fun k -> k)

let input_int2 () =
  scanf "%d %d\n" (fun x y -> (x, y))

let input () =
  let n = input_int () in
  let rec loop acc i =
    if i = n then
      (n, List.rev acc)
    else
      let (a, b) = input_int2 () in
      loop ((a, b)::acc) (i+1)
  in
  loop [] 0

let f () =
  let (n, ps) = input () in
  let rec loop ps =
    match ps with
     | (a1, b1)::(a2, b2)::(a3, b3)::ps' ->
        if a1=b1 && a2=b2 && a3=b3 then
          true
        else
          loop ((a2, b2)::(a3, b3)::ps')
     | _ -> false
  in
  if loop ps then
    printf "Yes\n"
  else
    printf "No\n"

let () = f ()


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

int main() {
	int A;
	cin >> A;
	if (A == 3 || A == 5 || A == 7)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int A,B,S1,S2,S3,max;
  scanf("%d %d",&A,&B);
  S1=A+(A-1);
  S2=A+B;
  S3=B+(B-1);
  max=S1;
  if(max<=S2){
    max=S2;
    if(max<=S3){
      max=S3;
      printf("%d\n",S3);
    }else{
      printf("%d\n",S2);
    }
  }else if(max<=S3){
    max=S3;
    if(max<=S2){
      max=S2;
      printf("%d\n",S2);
    }else{
      printf("%d\n",S3);
    }
  }else{
    printf("%d\n",S1);
  }
  return 0;
}



Measured memory_bytes: 128
X,N = map(int, input().split())
if N==0:
  print(X)
  exit()
p = list(map(int, input().split()))

if not(X in p):
  print(X)
  exit()

for i in range(1,51,1):
  if not ((X-i) in p):
    print (X-i)
    exit()
  elif not ((X+i) in p):
    print(X+i)
    exit()

Measured memory_bytes: 9204
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var scanner = bufio.NewScanner(os.Stdin)

const MaxUint = ^uint(0)
const MaxInt = int(MaxUint >> 1)

func nextStr() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextStr())
	return i
}

func absInt(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

func minInt(numbers ...int) int {
	result := MaxInt
	for _, number := range numbers {
		result = minTwoInt(result, number)
	}
	return result
}

func minTwoInt(x, y int) int {
	if x < y {
		return x
	} else {
		return y
	}
}

func main() {
	scanner.Split(bufio.ScanWords)
	x := nextInt()
	k := nextInt()
	d := nextInt()

	var ans int

	abs_x := absInt(x)

	counts := abs_x / d
	if counts > k {
		ans = abs_x - k*d
	} else {
		if (k-counts)%2 == 0 {
			// 残り回数が偶数
			ans = abs_x % d
		} else {
			// 残り回数が奇数
			ans = minInt(absInt(abs_x%d+d), absInt(abs_x%d-d))
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1776
/**Bismillahir Rahmanir Rahim.**/

/**
 *    author:  nasimnoob
**/

#include<bits/stdc++.h>
#include<stdlib.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<cstring>
#include<cstdio>

using namespace std;

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

typedef long long int                        ll;
typedef unsigned long long int              ull;
typedef long double                          ld;

//-----------------------------------------------------------//
#define      test                       int t; cin>>t;  while(t--)

#define      cube(x)                    (x*x*x)
#define      sqr(x)                     (x*x)

#define      sc1(x)                     scanf("%lld",&x);
#define      sc2(x,y)                   scanf("%lld %lld", &x, &y)
#define      scf1(x)                    scanf("%lf",&x)
#define      scf2(x,y)                  scanf("%lf %lf", &x, &y)

#define      srev                       reverse(s.begin(),s.end())
#define      sortstr                    sort(s.begin(), s.end());
#define      gtl(x)                     getline(cin, (x))

#define      PI                         acos(-1) // 3.1415926535897932
#define      MIN                        9999999

#define      Faster                     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

//scanf("%[^\n]%*c", str);
//sort(s,s+n,greater<int>());
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);


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

int main()
{
    Faster;

    int n;

    cin >> n ;

    if(n >= 0 &&  n <= 1000)
        cout << 1000-n << endl;

    else if(n > 1000 &&  n <= 2000)
        cout << 2000-n << endl;

    else if(n > 2000 &&  n <= 3000)
        cout << 3000-n << endl;

    else if(n > 3000 &&  n <= 4000)
        cout << 4000-n << endl;

    else if(n > 4000 &&  n <= 5000)
        cout << 5000-n << endl;

    else if(n > 5000 &&  n <= 6000)
        cout << 6000-n << endl;

    else if(n > 6000 &&  n <= 7000)
        cout << 7000-n << endl;

    else if(n > 7000 &&  n <= 8000)
        cout << 8000-n << endl;

    else if(n > 8000 &&  n <= 9000)
        cout << 9000-n << endl;

    else
        cout << 10000-n << endl;
    return 0;
}






Measured memory_bytes: 3604
w,h = map(int,input().split())
l = []
for _ in range(w):
  l.append((int(input()),0))
for _ in range(h):
  l.append((int(input()),1))
l.sort()
a = w+1
b = h+1
ans = 0
for p,t in l:
  if t:
    ans += p*a
    b -= 1
  else:
    ans += p*b
    a -= 1
print(ans)
    
  

Measured memory_bytes: 24544
#include <stdio.h>

typedef struct{
	int name;
	int p;
	int q;
	int r;
	int cal;
}sweet;

int main(void){
	while(1){
		int n, i, a, b, c;
		int s, t, u, v;
		sweet sw[1000];	
			
		scanf(" %d", &n);
		if(n==0) break;
	
		for(i=0; i<n; i++){
			scanf(" %d %d %d %d", &sw[i].name, &sw[i].p, &sw[i].q, &sw[i].r);		
			sw[i].cal = 4*sw[i].p + 9*sw[i].q + 4*sw[i].r;
		}
		
		scanf(" %d %d %d %d", &s, &t, &u, &v);
		
		int flag=0;
		for(i=0; i<n; i++){
			if(sw[i].p<=s && sw[i].q<=t && sw[i].r<=u && sw[i].cal<=v){
				flag=1;
				printf("%d\n", sw[i].name);
			}
		}
		
		if(flag==0) printf("NA\n");

	}

	return 0;
}

Measured memory_bytes: 632
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin>>N;
    float sum=0;
    for(int i=0;i<N;i++){
        string gaku;
        string type;
        cin>>gaku;
        cin>>type;
        if(type=="BTC"){
            sum+=atof(gaku.c_str())*(float)380000;
        }else{
            sum+=atof(gaku.c_str());
        }
    }
    cout<<sum<<endl;
    return 0;
}

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

using namespace std;
int f[3005][3005];
string s,t;
stack<char> st;
main()
{
    cin>>s>>t;
    for(int i=1;i<=s.length();i++)
    {
    	for(int j=1;j<=t.length();j++)
    	{
    		if(s[i-1]==t[j-1]) f[i][j]=max(f[i-1][j-1]+1,max(f[i-1][j],f[i][j-1]));
    		else f[i][j]=max(f[i-1][j],f[i][j-1]);
		}
	}
	int i=s.length();
	int j=t.length();
//	for(int i=1;i<=s.length();i++)
//    {
//    	for(int j=1;j<=t.length();j++)
//    	{
//    		cout<<f[i][j]<<" ";
//		}
//		cout<<'\n';
//	}
	while(i>=1&&j>=1)
	{
		if(s[i-1]==t[j-1])
		{
			if(f[i][j]==f[i-1][j-1]+1)
			{
				st.push(s[i-1]);
				i-=1;
				j-=1;
			}
			else if(f[i][j]==f[i-1][j])
			{
				i-=1;
			}
			else j-=1;
		}
		else
		{
			if(f[i][j]==f[i-1][j])
			{
				i-=1;
			}
			else j-=1;	
		}
	}
	while(st.size())
	{
		cout<<st.top();
		st.pop();
	}
}


Measured memory_bytes: 35456
#include<bits/stdc++.h>
using namespace std;
 
/// ----------------------------- (Debug) ------------------------------
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i));}
sim, class b dor(pair < b, c > d) {ris << "(" << d.first << ", " << d.second << ")";}
sim dor(rge<c> d) {*this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]";}
#else
sim dor(const c&) { ris; }
#endif
};
vector<char*> tokenizer(const char* args) {
  char *token = new char[111]; strcpy(token, args); token = strtok(token, ", ");
  vector<char*> v({token});
  while(token = strtok(NULL,", ")) v.push_back(token);
  return reverse(v.begin(), v.end()), v;
}
void debugg(vector<char*> args) { cerr << "\b\b "; }
template <typename Head, typename... Tail>
void debugg(vector<char*> args, Head H, Tail... T) {
  debug() << " [" << args.back() << ": " << H << "] ";
  args.pop_back(); debugg(args, T...);
}
#define harg(...) #__VA_ARGS__
#ifndef ONLINE_JUDGE
#define dbg(...) { debugg(tokenizer(harg(__VA_ARGS__, \b\t-->Line)), __VA_ARGS__, __LINE__); cerr << endl;}
#else
#define dbg(...) { }
#endif
/// -----------------------------------------------------------------------

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi; 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)    
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define REP(i,a,b) for(i=a;i<=b;i++)
#define RAP(i,a,b) for(i=a;i>=b;i--)
#define spa <<" "<<
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
ll mod=998244353;
const int MX=0x3f3f3f3f;

int main() {
    IOS;
	int n,i,k,j;
	cin>>n>>k;
	int l[k],r[k];
	REP(i,0,k-1) cin>>l[i]>>r[i];
	ll dp[n+1],pre[n+1];
	pre[0]=0;
	pre[1]=1;
	REP(i,2,n){
		dp[i]=0;
		pre[i]=0;
		REP(j,0,k-1){
			if(i>=l[j]){
				dp[i]+=pre[i-l[j]]-pre[max(0,i-r[j]-1)];
				dp[i]%=mod;
				if(dp[i]<0) dp[i]+=mod;
			}
		}
		pre[i]=dp[i]+pre[i-1];
		pre[i]%=mod;
	}
	cout<<dp[n];
    return 0;   
} 

Measured memory_bytes: 6700
import java.util.*;
import java.math.*;
 import static java.util.stream.Collectors.toList;

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

		int n = sc.nextInt();
		int x = sc.nextInt();
		
		List<Integer> listL = new ArrayList<>();
		int totalLength =0;
		int resultCount=1;

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

			int ln =sc.nextInt();
			totalLength+=ln;
			if(totalLength>x){
				break;				
			}
			resultCount++;

		}

		
		System.out.println(resultCount);
 
	}

}




Measured memory_bytes: 22228
#include<stdio.h>

int main(void) {
	double  v, h;
	int N;

	while((scanf("%lf", &v))!=EOF){
	h = v*v / 19.6;
	for (N = 1; (double)(5 * N - 5) < h;N++);
	
	printf("%d\n", N);}

	return 0;
}

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

int main(){
    using namespace std;
    unsigned long N;
    cin >> N;
    unsigned long ans{~0UL};
    for(unsigned long i{0}, pa{~0UL}, a; i < N; ++i){
        cin >> a;
        if(pa + 1 < a)return 0 & puts("-1");
        if(pa + 1 == a)++ans;
        else ans += a;
        pa = a;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/detail/standard_policies.hpp>
// using namespace __gnu_pbds;
using namespace std;
// template <typename T>
// using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,
//     tree_order_statistics_node_update>;
 
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
typedef long long int ll;
typedef long double ld;
const ll N = 1e5+9;
// const ll m = 1e9 + 7;
// const ll inf= 1e14;
const ll mod =998244353;
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#define pld pair<ld,ld>
ll powm(ll a, ll b) { a = a%mod;ll res = 1; while (b) { if (b & 1) res = (res * a) % mod; a = (a * a) % mod; b >>= 1; } return res; }
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout); 
    #endif  
    int t = 1;
    // cin>>t;
    while(t--){
        string s;cin>>s;
        ll n = s.size();
        ll ct[26];
        memset(ct,0,sizeof(ct));
        for(int i = 0;i<n;i++){
            ct[s[i]-'a']++;
        }
        ll ans = (n*(n-1))/2;
        for(int i = 0;i<26;i++){
            ans-=((ct[i]*(ct[i]-1))/2);
        }
        cout<<ans+1<<'\n';
    }
}

Measured memory_bytes: 3784
n,m = map(int,input().split())
tall = [int(e) for e in input().split()]

is_best = [True]*n

for i in range(m):
    c = [int(f)-1 for f in input().split()]
    a,b = c[0],c[1]
    if tall[a] < tall[b]:
        is_best[a] = False

    elif tall[b] < tall[a]:
        is_best[b] = False

    else:
        is_best[a],is_best[b] = False,False

print(is_best.count(True))

Measured memory_bytes: 20088
def merge(s, left, mid, right):
    global count
    n1 = mid - left
    n2 = right - mid
    L = s[left:mid] + [1000000001]
    R = s[mid:right] + [1000000001]

    i = 0
    j = 0
    for k in range(left,right):
        if L[i] <= R[j]:
            s[k] = L[i]
            i += 1
        else:
            s[k] = R[j]
            j += 1
            count += (n1 -i)

def mergesort(s, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        mergesort(s, left, mid)
        mergesort(s, mid, right)
        merge(s, left, mid, right)

n = int(input())
count = 0
s = list(map(int, input().split()))
mergesort(s, 0, n)
print(count)



Measured memory_bytes: 27472
#include <bits/stdc++.h>
#define ll long long
#define INF 0x3f3f3f3f
using namespace std;
const int maxn = 1e3;
string w[3] = {"Sunny", "Cloudy", "Rainy"};
string s;

void read()
{
    cin >> s;
}

void solve()
{
    for(int i = 0; i < 3; ++i)
        if(w[i] == s)
        {
            cout << w[(i+1)%3] << endl;
            break;
        }
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define mod 1000000007
#define vll vector<ll>
#define pll vector<pair<ll,ll>>



int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t;
	//cin>>t;
	t=1;
	start:
	while(t--){

      string s;
      cin>>s;
      ll sum=0;

      for(ll i=0;i<s.size();i++){
        sum+=s[i]-'0';
      }
      if(sum%9==0){
        cout<<"Yes"<<endl;
      }
      else cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3772
n = int(input())
a = list(map(int, input().split()))
colors = [0]*9
for i in a:
    colors[min(i//400, 8)] += 1

mi = 0
for i in range(8):
    if colors[i]>0:
        mi += 1
if mi==0:
    mi = 1
    ma = colors[-1]
else:
    ma = mi+colors[-1]
print(mi, ma)

Measured memory_bytes: 3064
#include<cstdio>
#include<algorithm>
using namespace std;
#define ll long long
const int maxn=1e5+5;
const ll INF=0x3f3f3f3f3f3f3f3f;
int a[maxn];
struct node
{
    int l,r;
    ll diff,lz;
}tree[4*maxn];
void build(int l,int r,int cur)
{
    tree[cur].l=l;
    tree[cur].r=r;
    if(l==r)
        return;
    int mid=(l+r)>>1;
    build(l,mid,cur<<1);
    build(mid+1,r,cur<<1|1);
    return;
}
void push_up(int cur)
{
    tree[cur].diff=tree[cur<<1].diff+tree[cur<<1|1].diff;
    return;
}
void push_down(int cur)
{
    if(tree[cur].lz!=0)
    {
        tree[cur<<1].diff+=(tree[cur<<1].r-tree[cur<<1].l+1)*tree[cur].lz;
        tree[cur<<1].lz+=tree[cur].lz;
        tree[cur<<1|1].diff+=(tree[cur<<1|1].r-tree[cur<<1|1].l+1)*tree[cur].lz;
        tree[cur<<1|1].lz+=tree[cur].lz;
        tree[cur].lz=0;
    }
    return;
}
void add(int l,int r,ll val,int cur)
{
    if(l>r) return;
    if(tree[cur].l>=l&&tree[cur].r<=r)
    {
        tree[cur].diff+=(tree[cur].r-tree[cur].l+1)*val;
        tree[cur].lz+=val;
        return;
    }
    if(tree[cur].l>r||tree[cur].r<l)
        return;
    push_down(cur);
    add(l,r,val,cur<<1);
    add(l,r,val,cur<<1|1);
    push_up(cur);
    return;
}
ll diff0[maxn];
void together(int cur)
{
    if(tree[cur].l==tree[cur].r)
    {
        diff0[tree[cur].l]=tree[cur].diff;
        return;
    }
    push_down(cur);
    together(cur<<1);
    together(cur<<1|1);
    push_up(cur);
    return;
}
ll minn[maxn];
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    build(0,m-1,1);
    ll base=0;
    for(int i=1;i<n;i++)
    {
        if(a[i]<a[i+1])
        {
            base+=(ll)(a[i+1]-a[i]);
            add(a[i]+1,a[i+1]-1,-1,1);
            add(a[i+1],a[i+1],a[i+1]-a[i]-1,1);
        }
        else
        {
            base+=(ll)(m-a[i]+a[i+1]);
            add(0,0,-(m-a[i]),1);
            add(1,a[i+1]-1,-1,1);
            add(a[i+1],a[i+1],m-a[i]+a[i+1]-1,1);
            add(a[i]+1,m-1,-1,1);
        }
    }
    together(1);
    minn[0]=base;
    for(int i=1;i<=m;i++)
        minn[i]=minn[i-1]+diff0[i-1];
    ll ans=INF;
    for(int i=1;i<=m;i++)
        ans=min(ans,minn[i]);
    printf("%lld\n",ans);
    return 0;
}
/*
 4 6
 1 5 1 4
 8 9 7 5 6 9
 
 9 9 8 7 6 5 4 3 2
 */


Measured memory_bytes: 9748
S = list(map(int, input().rstrip()))

plan_0 = [i % 2 for i in range(len(S))]
plan_1 = [i % 2 for i in range(1, len(S)+1)]

x = len(S) - sum([(plan_0[i] - S[i])==0 for i in range(len(S))])
y = len(S) - sum([(plan_1[i] - S[i])==0 for i in range(len(S))])

print(min(x, y))

Measured memory_bytes: 6304
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <map>
#include <fstream>
using namespace std;

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

	vector<pair<int,int>> query(M);

	for(int i=0; i<M; i++)
	{
		int _0,_1;
		cin>>_0>>_1;
		query[i] = make_pair(_0,_1);
	}

	sort(query.begin(),query.end());

	queue<pair<int,int>> e;

	int min = -1;
	int max = 1000000007;
	e.push(make_pair(min,max));
	for(int i=0; i<M; i++)
	{
		//幅を狭める
		if(min < query[i].first && query[i].second < max)
		{
			min = query[i].first;
			max = query[i].second;
			e.pop();
			e.push(make_pair(min,max));
		}
		if(max <= query[i].first) // && max < query[i].second
		{
			min = query[i].first;
			max = query[i].second;
			e.push(make_pair(min,max));
		}
	}
	int e_size = e.size();
	while(!e.empty())
	{
		//cout<<e.front().first<<","<<e.front().second<<endl;
		e.pop();
	}
	cout<<e_size<<endl;
	return 0;
}

Measured memory_bytes: 1024
N = int(input())
ans = 0
count = 0
for i in range(N+1):
	count  = 0
	if i%2 == 1:
		for j in range(i):
			if i % (j+1) == 0:
				count += 1
	if count == 8:
		ans += 1
print(ans)

Measured memory_bytes: 3060
N,M=list(map(int,input().split()))
A=sorted(list(map(int,input().split())))
bc=[list(map(int,input().split())) for _ in range(M)]
bc.sort(key=lambda x: x[1],reverse=True)

D=[0]*N
i=0
for b,c in bc:
    cnt=0
    while i<N and cnt<b:
        D[i]=c
        i+=1
        cnt+=1
    if i==N:
        break

E=[max(A[i],D[i]) for i in range(N)]
print(sum(E))

Measured memory_bytes: 89112
a, b, k = $stdin.gets.chomp.split().map(&:to_i)

# puts a,b,k

# default = (a..b).to_a

# puts default

x=[]
y=[]


lim_a = [b, a+k].min
lim_b = [a, b-k+1].max

for i in a...lim_a do
  if a <= i && i <= b
    x << i
  end
end


# puts ""

for i in lim_b..b do 
  if a <= i && i <= b
    y << i
  end
end

# p x| y
ans = ((x | y).uniq) 

puts ans.sort


Measured memory_bytes: 1788
#include<iostream>  
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std; 
int  s[10001]; 
int ans=0,n;
int main()  
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&s[i]);
	}
	sort(s+1,s+1+n);
	printf("%d\n",s[n]-s[1]);
	return 0;
}
 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    ll n;
    cin>>n;
    ll t=0;
    vector<pair<ll,ll>>p(n);
    rep(0,i,n){
        cin>>p[i].second>>p[i].first;
    }
    sort(p.begin(),p.end());
    rep(0,i,n){
        ll b=p[i].first,a=p[i].second;
        t+=a;
        if(t>b){
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
}

Measured memory_bytes: 3328
#include <ctype.h>
#include <cstdio>

using namespace std;

int main() {
  int m[26] = {0};
  for (;;) {
    const int c = getchar();
    if (c == EOF)
      break;

    if (isupper(c)) {
      m[c - 'A']++;
    } else if (islower(c)) {
      m[c - 'a']++;
    }
  }
  for (int i = 0; i < 26; ++i)
    printf("%c : %d\n", i + 'a', m[i]);

  return 0;
}

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

int main()
{
    long long n,i,j,k;
    cin>>n;
    long long a[n],x=0;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        x=a[i]^x;
    }
    for(i=0;i<n;i++)
    {
        cout<<(a[i]^x)<<" ";
    }
    cout<<endl;
}


Measured memory_bytes: 5008
<?php
  
$kx = explode(' ', trim(fgets(STDIN)));
$k = $kx[0];
$x = $kx[1];

$l = $x-$k+1;
$r = $x+$k-1;

for($i=$l; $i<=$r; $i++){
  if ($i !== $l) echo " ";
  echo $i;
}
  
?>

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

public class Hello
{
    public static void Main()
    {
        hoge();
        //System.Console.ReadLine();
    }

     public static void hoge()
    {
        var n = long.Parse(System.Console.ReadLine());
        var a = System.Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        var vlst = new Dictionary<long, long>();
        foreach(var v in a)
        {
            if (vlst.ContainsKey(v))
            {
                vlst[v]++;
            }
            else
            {
                vlst.Add(v, 1);
            }
        }
        var q = long.Parse(System.Console.ReadLine());

        var sum = a.Sum();
        var query = a.AsEnumerable();
        Dictionary<long, long> dic = new Dictionary<long, long>();

        for(long i = 0; i < q; i++)
        {
            var var = System.Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
            var b = var[0];
            var c = var[1];
            if (!vlst.ContainsKey(b))
            {
                vlst.Add(b, 0);
            }
            var sa = c - b;
            sa *= vlst[b];
            sum += sa;
            Console.WriteLine(sum);
            if (!vlst.ContainsKey(c))
            {
                vlst.Add(c, 0);
            }
            vlst[c] += vlst[b];
            vlst[b] = 0;
        }

    }
}

Measured memory_bytes: 49892
//auto 関数名 = [(&:ラムダ外の引数をとる時))](引数の型1 引数名1, 引数の型2, 引数名2, ...) { 関数の処理 }; //inside main() define function. take care of };
// for (int tmp = 0; tmp < (1 << ビット数); tmp++) {
//   bitset<ビット数> s(tmp);
//   // (ビット列sに対する処理)
// }
// sort(配列変数.begin(), 配列変数.end());
// do {
//   // 順列に対する処理
// } while (next_permutation(配列変数.begin(), 配列変数.end()));
//const double PI = acos(-1); M_PI
// cout << fixed << setprecision(10);
#include <bits/stdc++.h>
#include <regex>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define _GLIBCXX_DEBUG 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end() //sort(all(vec)); ,reverse(all(vec));etc
int main(){
 int n;
 cin>>n;
 int cnt;
 int min=10000;
 for(int i=1;i<n/2+1;i++){
     int j=n-i;
     cnt=0;
     cnt+=i/100000+(i%100000)/10000+(i%10000)/1000+(i%1000)/100+(i%100)/10+i%10;
     cnt+=j/100000+(j%100000)/10000+(j%10000)/1000+(j%1000)/100+(j%100)/10+j%10;
     if(cnt<min){
       min=cnt;
     } 
   }
 cout<<min<<endl;
}



Measured memory_bytes: 3644
#include<bits/stdc++.h>
 
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define repn(i,a,b)   for(int i=a;i>=b;i--)
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define mp  make_pair
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
#define inf 1e18

 
using namespace std;
 
int max(int a, int b)
{
    if(a>b) return a;
    else return b;
}
 
int min(int a,int b)
{
    if(a<b) return a;
    else return b;
}
bool isPrime(int n) 
{ 
    // Corner cases 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
  
    // This is checked so that we can skip 
    // middle five numbers in below loop 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (int i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
  
    return true; 
} 
signed main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output1.txt", "w", stdout);
    #endif
    
    IOS;
    int n,k,i;
    cin>>n>>k;
    vi v(n);
    for(i=0;i<n;i++)cin>>v[i];
    sort(v.begin(),v.end());
    int ans=0;
    for(i=0;i<min(n,k);i++)
    {
        ans+=v[i];
    }    
    cout<<ans;
}

Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n); for(ll i = 0; i < (ll)n; i++)
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; }

int main() {
  vector<char> v = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
  ll k;
  cin >> k;
  string s;
  cin >> s;
  
  ll n = s.size();
  string ans;
  
  rep(i, n){
    rep(j, 26){
      if(s.at(i) == v.at(j))
        ans.push_back(v.at((j+k)%26));
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3612
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <boost/xpressive/xpressive.hpp>

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;
using namespace boost;

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

  S.pop_back();
  xpressive::smatch m;
  const xpressive::sregex re = xpressive::sregex::compile(R"(^([a-z]+)\1)");
  xpressive::regex_search(S, m, re);
  cout << m.str().length() << endl;
  return 0;
}


Measured memory_bytes: 3888
# frozen_string_literal: true

n = gets.to_i
l = gets.split.map(&:to_i).sort
count = 0
0.upto(n - 3) do |i|
  a = l[i]
  (i + 1).upto(n - 2) do |j|
    b = l[j]
    c_lower = j + 1
    add = 0
    c_upper = l.bsearch_index { |e| a + b <= e }
    if c_upper.nil?
      c_upper = n - 1
      add = 1
    end
    next if c_upper < c_lower

    diff = c_upper - c_lower
    diff = 0 if diff.negative?

    count += diff + add
  end
end

puts count


Measured memory_bytes: 3836