akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
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; }
ll mod= 1e9 + 7;


int main(){
  int n;
  cin >> n;
  ll a[n];
  rep(i,n)cin >> a[i];
  ll ans=0;
  rep(i,60){
    ll x=0;
    rep(g,n)if(a[g]>>i&1)++x;
    ll ans2=x*(n-x)%mod;//i桁目の1と0を数えて、(1,0)の組み合わせ数を出す(1,0の出る数は背反である)
    rep(g,i)ans2=ans2*2%mod;//オーバーフローを防ぐ為、repで2^iを計算している
    ans+=ans2;
    ans%=mod;
  }
  cout << ans << endl;
}

Measured memory_bytes: 5936
package main

import (
	"fmt"
)

func main() {
	var n, m int
	fmt.Scan(&n, &m)

	listH := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&listH[i])
	}

	listA := make([]int, m)
	listB := make([]int, m)
	for i := 0; i < m; i++ {
		fmt.Scan(&listA[i], &listB[i])
	}

	count := 0
	list := make([]bool, n)
	for i := 0; i < n; i++ {
		list[i] = true
	}

	for i := 0; i < m; i++ {
		if listH[listA[i]-1] > listH[listB[i]-1] {
			list[listB[i]-1] = false
		} else if listH[listA[i]-1] < listH[listB[i]-1] {
			list[listA[i]-1] = false
		} else {
			list[listA[i]-1] = false
			list[listB[i]-1] = false
		}

	}
	for i := 0; i < n; i++ {
		if list[i] == true {
			count++
		}
	}

	fmt.Println(count)

}


Measured memory_bytes: 7312
#include<bits/stdc++.h>
using namespace std;
map<string ,int> data;
vector<string> word;
int main(){
    int N;
    string kata,tes;
    cin>>N;
    int temp=0,c=0;

    for(int i = 0 ; i < N ;i++){
        cin>>kata;
        word.push_back(kata);
        data[kata]++;
        if(data[kata] > 1){c=1;temp=0;}//cout<<temp;

        if(i > 0 ){
        string cek1 ;
        cek1 = word[i-1];
        string cek2;
        cek2 = word[i];
            if(cek1[cek1.length() - 1 ] ==  cek2[0]){
                temp++;
            }
        }
    }
     if(temp == N-1){
        cout<<"Yes"<<endl;
    }else if (temp != N-1 || c==1){
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i=(a); i<(b); i++)
#define FORD(i, a, b) for (int i=(a); i>(b); i--)
#define PPC(x) __builtin_popcount(x)
#define MSB(x) (31 - __builtin_clz(x))
#define SZ(x) ((int)(x).size())
#define BACK(x) prev((x).end())
#define HASK(x, y) ((x).find(y) != (x).end())
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define ithBit(m, i) ((m) >> (i) & 1)
#define ft first
#define sd second
#define kw(a) ((a) * (a))
#ifdef DEBUG
#include "debug.h"
#else
#define dbg(...) 0
#endif
using namespace std;
 
const int maxN = 1 << 17;

int cost[maxN], dp[maxN][120];

int solve(string& T)
{
	for (char c : "rsp")
		dp[0][c] = 0;	
	int n = SZ(T);
	
	FOR(i, 1, n+1)
	{
		dp[i]['r'] = (T[i] == 's') * cost['r'] + max(dp[i-1]['s'], dp[i-1]['p']);
		dp[i]['s'] = (T[i] == 'p') * cost['s'] + max(dp[i-1]['r'], dp[i-1]['p']);
		dp[i]['p'] = (T[i] == 'r') * cost['p'] + max(dp[i-1]['s'], dp[i-1]['r']);
	}
	
	return max({dp[n]['r'], dp[n]['s'], dp[n]['p']});
}

char T[maxN];

void solve()
{
	int n, k;
	scanf ("%d%d%d%d%d", &n, &k, &cost['r'], &cost['s'], &cost['p']);
	
	dbg(cost['s']);
	
	scanf ("%s", T);
	int res = 0;
	FOR(s, 0, k)
	{
		string x = "#";
		for (int i=s; i<n; i+=k)
			x += T[i];
		res += solve(x);
		dbg(res);
	}
	printf("%d\n", res);
}			
 
int main()
{
	int t = 1;
	//scanf ("%d", &t);
	FOR(tid, 1, t+1)
	{
		//printf("Case #%d: ", tid);
		solve();
	}
	return 0;
}
 




Measured memory_bytes: 50272
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int k2 = k * 2;
		int[][] count = new int[4 * k + 1][4 * k + 1];
 
		for (int i = 0; i < n; i++) {
			int x = sc.nextInt();
			int y = sc.nextInt();
			if (sc.next().equals("W")) {
				y += k;//全てblackに
			}
			x %= k2;
			y %= k2;
			//二次元imos 重みの加算
			count[x][y]++;
			count[x][y + k]--;
			count[x + k][y]--;
			count[x + k][y + k]++;
			count[x + k][y + k]++;
			count[x + k][y + k + k]--;
			count[x + k + k][y + k]--;
			count[x + k + k][y + k + k]++;
		}
		//横方向への累積和
		final int H = count.length;
		final int W = count[0].length;
		for (int y = 0; y < H; y++) {
			for (int x = 1; x < W; x++) {
				count[y][x] += count[y][x - 1];
			}
		}
		//縦方向への累積和
		for (int y = 1; y < H; y++) {
			for (int x = 0; x < W; x++) {
				count[y][x] += count[y - 1][x];
			}
		}
		for(int y = 0; y < H; y++) {
			for(int x = 0; x < W; x++) {
				if(y < k2 && x < k2) continue;
				count[y % k2][x % k2] += count[y][x];
			}
		}
		long ans = 0L;
		for (int y = 0; y < k2; y++) {
			for (int x = 0; x < k2; x++) {
				ans = Math.max(ans, count[y][x]);
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 139324
using System;
using System.Collections.Generic;
using System.Linq;
using static AtCoder.Io;

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            var ab = ReadIntArray();
            var a = ab[0];
            var b = ab[1];
            a = a == 1 ? 14 : a;
            b = b == 1 ? 14 : b;
            Console.WriteLine(a == b ? "Draw" : a > b ? "Alice" : "Bob");
        }
    }

    public static class Io
    {
        public static string ReadString() => Console.ReadLine();
        public static string[] ReadStringArray() => ReadString().Split(' ');
        public static int ReadInt() => int.Parse(ReadString());
        public static long ReadLong() => long.Parse(ReadString());
        public static int[] ReadIntArray() => ReadStringArray().ParseInt().ToArray();
        public static long[] ReadLongArray() => ReadStringArray().ParseLong().ToArray();
        public static IEnumerable<int> ParseInt(this IEnumerable<string> source) => source.Select(int.Parse);
        public static IEnumerable<long> ParseLong(this IEnumerable<string> source) => source.Select(long.Parse);
    }
}


Measured memory_bytes: 13396
# -*- coding: utf-8 -*-

def input_one_number():
    return int(input())

def input_multiple_number():
    return map(int, input().split())

def input_multiple_number_as_list():
    return list(map(int, input().split()))


N,M,X =  input_multiple_number()

listC = [0]*N
tableA = [[0]*M for i in range(N)]

for i in range(N):
	iii = input_multiple_number_as_list()
	listC[i] = iii[0]
	for j in range(M):
		tableA[i][j] = iii[j+1]
INF = 10000000000
ans = INF

import itertools as it
for i in it.product(range(2), repeat=N):
	isOK = True
	price = 0
	listM = [0]*M
	for j in range(N):
		if i[j] == 1:
			for qqq in range(M):
				listM[qqq] += tableA[j][qqq]
			price += listC[j]
	for skils in range(M):
		isOK = (listM[skils] >= X) and isOK

	if isOK:
		ans = min(price,ans)

if ans == INF:
	print(-1)
else:
	print(ans)






Measured memory_bytes: 9252
from fractions import gcd
n = int(input())
A = list(map(int,input().split()))
X = [0 for i in range(n)]
Y = [0 for i in range(n)]
for i in range(1,n):
    X[i] = gcd(X[i-1],A[i-1])
for i in range(n-1)[::-1]:
    Y[i] = gcd(Y[i+1],A[i+1])
#print(X)
#print(Y)
Z = [gcd(X[i],Y[i]) for i in range(n)]
print(max(Z))


Measured memory_bytes: 16616
#include<iostream>
#include<cstring>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
const int N=2e5+5;
int main()
{
	int n;
	int x[8];
	for(int i=0;i<8;i++) x[i]=i+1;
	cin>>n;
	int t=0;
	int A=0,B=0;
	int a[N],b[N];
	for(int i=0;i<n;i++) cin>>a[i];
	for(int i=0;i<n;i++) cin>>b[i];
	while(next_permutation(x,x+n))
	{
		t++;
		int ant=0,bnt=0;
		for(int i=0;i<n;i++)
		{
			if(x[i]==a[i]) ant++;
			if(x[i]==b[i]) bnt++;
		}
		if(ant==n) A=t;
		if(bnt==n) B=t;
	}
	int sum;
	sum=abs(A-B);
	cout<<sum<<endl;
	return 0;
}

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

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

        int n = Integer.parseInt(in.next());
        PrintWriter out = new PrintWriter(System.out);

        for(int i = 1; i <= n; i++){
            if(i % 3 == 0) out.printf(" %d", i);
            else{
                int x = i;
                do{
                    if(x % 10 == 3){
                        out.printf(" %d", i);
                        break;
                    }
                }while((x /= 10) > 0);
            }
        }
        out.println();
        out.flush();
    }
}


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

int main(){
  int hi,bu,a[4],b[4];
    while(cin>>a[0]>>a[1]>>a[2]>>a[3]>>b[0]>>b[1]>>b[2]>>b[3]){
      hi=0;
      bu=0;
      for(int i=0;i<=3;i++){
	for(int j=0;j<=3;j++){
	  if(a[i]==b[j]){
	    if(i==j)hi++;
	    else bu++;
	  }
	}
      }
      cout<<hi<<" "<<bu<<endl;
    }
  return 0;
}

Measured memory_bytes: 1160
import sys
input = sys.stdin.readline
X=int(input().rstrip())
maxX=10**6

def resolve():
    check,table=sieve(maxX)

    for a in table:
        if a>=X:
            print(a)
            return

def sieve(n):#n以下の素数を返す, is_prime[i]:iが素数ならtrue、table[i]:小さい順に素数入る
    is_prime = [True for _ in range(n+1)]
    is_prime[0] = False

    for i in range(2, n+1):
        if is_prime[i-1]:
            j = 2 * i
            while j <= n:
                is_prime[j-1] = False
                j += i
    table = [ i for i in range(1, n+1) if is_prime[i-1]]
    is_prime=[False]+is_prime ##[False]は勝手につけた、累積和をするときはこの影響で[0]+いらない
    return is_prime, table


import sys
from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """20"""
        output = """23"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """2"""
        output = """2"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """99992"""
        output = """100003"""
        self.assertIO(input, output)

if __name__ == "__main__":
    #unittest.main()
    resolve()

Measured memory_bytes: 24672
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <sstream>
#include <vector>
#include <string>
#include <iomanip>
#include <bitset>
using namespace std;
#define INF	100000000
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define lb lower_bound
#define ub upper_bound
#define SS stringstream
#define rep(i,n) for(int i = 0; i < n; i++)
#define sz(x) ((int)(x).size())
#define SORT(x) sort((x).begin(), (x).end())
#define RSORT(x) sort((x).begin(), (x).end(), greater<int>() )
#define clr(a,b) memset((a),(b),sizeof(a))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<P> Vp;
typedef priority_queue<P, vector<P>, greater<P> > PQ;

string str;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	while(getline(cin,str)){
		rep(i,str.size()){
			if(str[i] != '@'){
				cout << str[i];
				continue;
			}
			rep(j,str[i+1]-'0'){
				cout << str[i+2];
			}
			i += 2;
		}
		cout << endl;
	}
}

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

typedef long long ll;
typedef pair<ll, ll>  pll;

int main(){
    ll H, W;
    cin >> H >> W;
    vector<pll> roads;
    REP(i, H){
        ll p;
        cin >> p;
        roads.push_back({p, 0});
    }
    REP(i, W){
        ll p;
        cin >> p;
        roads.push_back({p, 1});
    }
    sort(roads.begin(), roads.end());
    ll a = H+1;
    ll b = W+1;
    ll res = 0;
    REP(i, roads.size()){
        if(roads[i].second==0){
            res += roads[i].first*b;
            a--;
        }
        if(roads[i].second==1){
            res += roads[i].first*a;
            b--;
        }
    }
    cout << res << endl;
    return 0;
}

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

using namespace std;

int main() {
    int L, A, B, C, D;
    cin >> L >> A >> B >> C >> D;

    int ans = L - max((A + C - 1) / C, (B + D - 1) / D);
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll sum[114514],a[114514];
ll f[114514];
int main(){
	ll n,x,m;
	cin>>n>>x>>m;
	a[1]=x;
	sum[1]=x;
	f[x]=1;
	ll ans=x;
	for(int i=2;i<=min(n,m+1);i++){
		a[i]=a[i-1]*a[i-1]%m;
		sum[i]=a[i]+sum[i-1];
		if(f[a[i]]){
			ans=sum[i-1];
			//cout<<sum[i-1]<<' '<<sum[f[a[i]]-1];
			ll x=n+1-i;
			ans+=(x/(i-f[a[i]]))*(sum[i-1]-sum[f[a[i]]-1])+sum[f[a[i]]+x%(i-f[a[i]])-1]-sum[f[a[i]]-1];
			break;
		}else{
			f[a[i]]=i;
			ans=sum[i];
		}
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 5100
#include<bits/stdc++.h>
using namespace std;
#define ll            long long
#define nl            "\n"
#define PB            push_back
#define fi            first
#define se            second
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define rep(i,n)      for(int i=0;i<n;i++)
#define repn(i,n)     for(int i=1;i<=n;i++)
#define rrep(i,n)     for(int i=n-1;i>=0;i--)
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
/*-----------------------------------------------------------------------------------------------*/
const int N = 1e5+10;
int n,w,h,ans;
int main()
{
    _SAD()
    cin>>h>>w>>n;
    int x=max(h,w);
    if(n%x==0)
    {
        cout<<n/x<<nl;
    }
    else
    {
        cout<<(n/x)+1<<nl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int N;
  cin >> N;
  vector<tuple<string, int, int>> sp(N);
  for (int i = 0; i < N; i++){
    string S;
    int P;
    cin >> S >> P;
    P *= -1;
    sp.at(i) = make_tuple(S, P, i+1);
  }
  sort(sp.begin(), sp.end());
  for (int i = 0; i < N; i++){
    cout << get<2>(sp.at(i)) << endl;
  }
  
  return 0;
}

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

int main()
{
    int n1, n2, s1, s2;
    cin >> n1 >> n2 >> s1 >> s2;
    int sum = 0;
    if(n1 > n2)
    {
        for(int i = 0; i < n2; i++)
            sum += s1;
        for(int j = 0; j < (n1 - n2); j++)
            sum += s2;
    }
    else
    {
        for(int k = 0; k < n1; k++)
            sum += s1;
    }
    cout << sum;
    return 0;
}


Measured memory_bytes: 256
n=int(input())
s=input()*2
for a in['SS','SW','WS','WW']:
    for i in range(1,n+1):
        f=a[i]+s[i]
        if f=='So'or'Wx'==f:
            a+=a[i-1]
        else:
            a+=a[i-1].translate({83:87,87:83})
    if a[:2]==a[n:]:
        print(a[:n])
        break
else:
    print(-1)

Measured memory_bytes: 3628
#include <iostream>
#include <assert.h>
#include <vector>
#include <unordered_map>
#include <queue>
#include <climits>
#include <cmath>
#include <algorithm>
using namespace std;
constexpr int64_t MOD = 1e9 + 7;

// GCD
int32_t GCD(int32_t a, int32_t b) {
  if (b == 0) return a;
  else return GCD(b, a%b);
}

int32_t gcd_key(int32_t a, int32_t b) {
  int32_t big = (a > b)? a : b;
  int32_t small = (a > b)? b : a;
  return small + 1000 * big;
}

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

  int64_t K;
  cin >> K;
  
  unordered_map<int32_t, int32_t> gcd_map;
  for (int a = 1; a <= K; a++) {
    for (int b = 1; b <= K; b++) {
      int32_t key = gcd_key(a,b);
      if (gcd_map.count(key) != 0) {
        continue;
      } else {
        int32_t gcd = GCD(a, b);
        gcd_map[key] = gcd;
      }
    }
  }

  int64_t res = 0;
  for (int a= 1; a <= K; a++) {
    for (int b = 1; b <= K; b++) {
      for (int c = 1; c <= K; c++) {
        int32_t key_ab = gcd_key(a, b);
        int32_t gcd_ab = gcd_map[key_ab];
        int32_t key_abc = gcd_key(gcd_ab, c);
        int32_t gcd_abc = gcd_map[key_abc];
        res += gcd_abc;
      }
    }
  }

  cout << res << endl;
  return 0;
}


Measured memory_bytes: 4272
n = int(input())

d = {}
for _ in range(n):
    s = input()
    if s in d:
        d[s] += 1
    else:
        d[s] = 1

m = max(d.values())

li = []
for i in d:
    if d[i] == m:
       li.append(i)
li.sort()
for j in li:
    print(j)

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


#define fast_IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define pb push_back
#define F first
#define S second
#define int long long int
#define ll long long
#define ld long double

bool isPrime(ll n){if(n<2)return false;for(ll i=2;i*i<=n;++i){if(n%i==0){return false;}}return true;}

ll lcm(ll x,ll y){
    return (x*y)/(__gcd(x,y));
}


signed main(){
    fast_IO;
    int t=1;
    //cin>>t;
    while(t--){
        int n,k,x;
        cin>>n>>k>>x;
        int ans=ceil((float)n/k)*x;
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 3612
solve [] b c acc = acc `mod` b == c
solve (e:es) b c acc = acc `mod` b == c || solve es b c (acc+e)

main = do
  [a,b,c] <- map read . words <$> getLine
  let seq = replicate b a
    in putStrLn (if solve seq b c 0 then "YES" else "NO")


Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int64_t A,B,C; cin>>A>>B>>C;

    int64_t ans=0;
    while(!(A==B && B==C)){
        ans++;
        int64_t minN=min(A,min(B,C));
        int minCnt=0;
        if(A-minN==0) minCnt++;
        if(B-minN==0) minCnt++;
        if(C-minN==0) minCnt++;

        if(minCnt==1){
            if(A-minN==0) A+=2;
            if(B-minN==0) B+=2;
            if(C-minN==0) C+=2;
        }else{
            if(A-minN==0) A+=1;
            if(B-minN==0) B+=1;
            if(C-minN==0) C+=1;
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
double f[3000][3000],a[3000];
int main()
{
	double ans=0;
	int n,i,j;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
		scanf("%lf",&a[i]);
	f[0][0]=1;
	for(i=1;i<=n;i++)
		f[i][0]=f[i-1][0]*(1-a[i]);
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=i;j++)
		{
			if(i==0&&j==0)
				f[i][j]=1;
			else if(i==0&&j==1)
				f[i][j]=0;
			else
				f[i][j]=f[i-1][j]*(1-a[i])+f[i-1][j-1]*a[i];
		}
	}
	for(i=(n+1)/2;i<=n;i++)
		ans+=f[n][i];
	printf("%.9lf",ans);
	return 0;
}

Measured memory_bytes: 68992
#include<bits/stdc++.h>
using namespace std;
int main(){
  int w,h,n;
  cin>>w>>h>>n;
  int x1=0,x2=w,y1=0,y2=h;
  for(int i=0;i<n;i++){
    int x,y,a;
    cin>>x>>y>>a;
    if(a==1)x1=max(x1,x);
    if(a==2)x2=min(x2,x);
    if(a==3)y1=max(y1,y);
    if(a==4)y2=min(y2,y);
  }
  cout<<(x1>x2||y1>y2?0:(x2-x1)*(y2-y1))<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 using namespace std;
 using pii = pair<int, int>;
 using ll = long long;
 #define rep(i, j, n) for(int i = j; i < (int)(n); i++)
 const ll MOD = 1000000007;
 const ll INFL = (1LL << 60);
 const int INFI = (1 << 30);

 int main() {
   double R; cin >> R;
   cout << 3.1415926535 * 2.0 * R << endl;
 }


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

using namespace std;

typedef long long LL;

const int N = 1010;

int a, b, c, x;

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

    int res = 0;
    for(int i = 0; i <= a; i++)
        for(int j = 0; j <= b; j++)
        {
            int t = x - i * 500 - j * 100;
            if(t >= 0 && t % 50 == 0 && t / 50 <= c)
                res++;
        }

    cout << res << endl;
    return 0;
}


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

long long modAdd(long long a, long long b, long long mod) {
	return ((a % mod) + (b % mod)) % mod;
}

long long modSub(long long a, long long b, long long mod) {
	long long c = ((a % mod) - (b % mod)) % mod;
	return ((c < 0) ? c + mod : c);
}
long long modMul(long long a, long long b, long long mod) {
	return ((a % mod) * (b % mod)) % mod;
}

long long modPow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0)
	{
		if (n & 1) {
			res = modMul(res, a, mod);
		}
		a = modMul(a, a, mod);
		n >>= 1;
	}
	return res;
}

long long modDiv(long long a, long long b, long long mod) {
	return modMul(a, modPow(b, mod - 2, mod), mod);
}

long long modCombination(long long n, long long r, long long mod) {
	if (r > n / 2)
		return modCombination(n, n - r, mod);
	long long res = 1;
	for (long long i = 1; i <= r; i++) {
		res = modMul(res, n - i + 1, mod);
		res = modDiv(res, i, mod);
	}
	return res;
}

int main()
{
	int m, n;
	cin >> m >> n;
	cout << modPow(m, n, 1000000007) << endl;
	return 0;
}


Measured memory_bytes: 3120
#include<iostream>
#include<climits>
#include<numeric>
#include<algorithm>
#include <sstream>
#include<cstring>
#include<cmath>
#include<iterator>
#include<utility>
#include<array>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<list>
#include<forward_list>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vlli vector<long long int>
#define vvi vector<vector<int>>
#define vpii vector<pair<int,int>>
#define vs vector<string>
#define lin1(x) ll int x; x = scan();
#define lin2(x,y) ll int x, y; x = scan(), y = scan();
#define lin3(x,y,z) ll int x, y, z; x = scan(), y = scan(), z = scan();
#define pb(x) push_back(x)
#define makep(x,y) make_pair(x,y)
#define mx(a,b) (a)>(b)?(a):(b)
#define mn(a,b) (a)<(b)?(a):(b)
#define fori(s,e) for(i=s;i<=e;i++)
#define forj(s,e) for(j=s;j<=e;j++)
#define fork(s,e) for(k=s;k<=e;k++)
#define rep(i,s,e) for(int i=s;i<=e;i++)
#define brep(i,s,e) for(int i=s;i>=e;i--)
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x));
#define bits1(x) __builtin_popcount(x)
#define pi 3.14159265358979323846264338327950
#define MOD7 1000000007
#define MOD9 1000000009
#define fast std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;

int main()
{
string s;
cin>>s;
int rahul=0;
if(s.length()%2==1){
	rahul=s.length()/2;
	int i=0;
int rohan=s.length()-1;
int count=0;
while(i<rahul&&rohan>rahul){
	if(s[i]!=s[rohan]){
		count+=1;
	}
	i++;
	rohan--;
}
cout<<count<<endl;
}
else{
int count1=0;
rahul=s.length()/2;
int i=0;
int rohan=s.length()-1;
while(i<=rahul&&rohan>=rahul){
	if(s[i]!=s[rohan]){
		count1+=1;
	}
	i++;
	rohan--;
}
cout<<count1<<endl;
}


	//cout<<count1<<endl;

}

Measured memory_bytes: 384
#!/usr/bin/env python3


def parse(n):
    # n -> largest m s.t. m(m+1)/2 <= n
    m = 1
    while m * (m + 1) <= 2 * n:
        m += 1
    return m - 1


def factorint(n):
    fct = []
    b, e = 2, 0
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct


def main():
    N = int(input())
    factors = factorint(N)
    print(sum(parse(v) for _, v in factors))
    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 9216
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223372036854775807
#define INF 2147483647
#define MOD 1000000007
using namespace std;


int main(int argc, char* argv[])
{
    long n,m;
    scanf("%ld%ld", &n, &m);

    vector<long> a(n), b(n), c(m), d(m);
    long i;
    for(i=0; i<n; i++) {
        scanf("%ld%ld", &a[i], &b[i]);
    }
    for(i=0; i<m; i++) {
        scanf("%ld%ld", &c[i], &d[i]);
    }

    long j;
    for(i=0; i<n; i++) {
        long min = INF;
        long minj=-1;
        for(j=0; j<m; j++) {
            long val = abs(a[i]-c[j])+abs(b[i]-d[j]);
            if(min>val) {
                min=val;
                minj=j;
            }
        }
        printf("%ld\n", minj+1);
    }

    return 0;
}



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

int main(){

  int a = 0 ,b = 0 ,menseki = 0 ,shu = 0;


  cin >> a >> b;

  menseki = a * b;

  shu = a * 2 + b * 2;

  cout << menseki <<" "<< shu << "\n";


  return 0;



}

Measured memory_bytes: 1164
n, m = gets.split.map(&:to_i)
ab = n.times.map{ |ab| gets.split.map(&:to_i) }.sort
mny = 0
while m>0 do
   if (fs=ab.shift)[1] <= m
       m -= fs[1]
       mny += fs[0]*fs[1]
   else
       mny += fs[0]*m
       m = 0
   end
end
puts mny

Measured memory_bytes: 11128
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <string>
#include <limits>
#include <algorithm>
#include <map>

using ll = long long;
using ull = unsigned long long;

using namespace std;
int main()
{
  ll n;
  cin >> n;

  auto res = 0;
  for (auto i = 1; i <= n; i += 2) {
    auto count = 0;
    for (auto j = 1; j <= i; j++) {
      if (i % j == 0) count++;
    }
    if (count == 8) res++;
  }

  cout << res << endl;
  return 0;
}


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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

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

	ce(s.substr(0,s.size()-8))

    return 0;
}



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

#define ll long long

#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define fill(ar,val) memset(ar, val, sizeof(ar))
#define fill0(ar) fill((ar), 0)
#define debug(x) cout<<#x<<": "<<x<<endl

#define ld double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

typedef pair<ll, ll> ii;
typedef pair<ii, ll> iii;
typedef vector<ii> vii;
typedef vector<ll> vi;

#define INF 1000000000000000000

ll n,m;
ll l[200010];
ll r[200010];
ll seg[900040];
ll lazy[900040];
bool push[900040];
vector<ll> lef[200010];
vector<pair<ll, ll> > rig[200010];
ll a[200010];
ll dp[200010];

ll combine(ll &a, ll &b) {
   return max(a, b);
}

void propagate(ll t, ll i, ll j) {
   if (push[t]) {
      seg[t] = seg[t] + lazy[t];
      if (i != j) {
         push[t*2] = true;
         push[t*2 + 1] = true;
         lazy[t*2] = lazy[t*2] + lazy[t];
         lazy[t*2 + 1] = lazy[t*2 + 1] + lazy[t];
      }
      push[t] = false;
      lazy[t] = 0;
   }
}

void update(ll t, ll i, ll j, ll l, ll r, ll x) {
   propagate(t, i, j);
   if (i > r || j < l) {
      return ;
   }
   if (l <= i && j <= r) {
      //base case : leaf node information to be stored here
      lazy[t] += x;
      push[t] = true;
      propagate(t, i, j);
      return ;
   }
   ll mid = (i + j) / 2;
   update(t*2, i, mid, l, r, x);
   update(t*2 + 1, mid + 1, j, l, r, x);
   seg[t] = combine(seg[2*t], seg[2*t+1]);
}
 
//Complexity: O(log n)
ll query(ll t, ll i, ll j, ll l, ll r) {
   propagate(t, i, j);
   if (i > r || j < l) {
      //base case: result of out-of-bound query
      return 0;
   }
   if (l <= i && j <= r) {
      return seg[t];
   }
   ll mid = (i + j) / 2;
   if (l <= mid) {
      if (r <= mid) {
         return query(t*2, i, mid, l, r);
      }
      else {
         ll a = query(t*2, i, mid, l, r);
         ll b = query(t*2 + 1,  mid + 1, j, l, r);
         return combine(a, b);
      }
   }
   else {
      return query(t*2 + 1,  mid + 1, j, l, r);
   }
}

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

    cin >> n >> m;

    fr(i,1,m)
    {
        cin >> l[i] >> r[i] >> a[i];
        lef[l[i]].pb(a[i]);
        rig[r[i]].pb(mp(a[i],l[i]));
    }

    fr(i,1,n)
    {
        rep(j,lef[i].size())
        {
            update(1,0,n,0,i-1,lef[i][j]);
            // cout << lef[i][j] << " " << i << endl;
        }

        dp[i] = query(1,0,n,0,i-1);
        update(1,0,n,i,i,dp[i]);

        // cout << dp[i] << endl;
        rep(j,rig[i].size())
        {
            update(1,0,n,0,rig[i][j].ss-1,-rig[i][j].ff);
            // cout << rig[i][j].ss << " " << rig[i][j].ff << " " << dp[i] << " " << i << endl;

        }
    }

    ll ans = 0;

    fr(i,1,n)
    {
        ans = max(ans, dp[i]);
    }

    cout << ans << endl;
}


Measured memory_bytes: 41344
from collections import defaultdict

N, M = map(int, input().split())

D = defaultdict(set)
R = {}
for _ in range(M):
  a, b = map(int, input().split())
  if a in R:
    if b in R:
      aa, bb = R[a], R[b] 
      if aa == bb:
        pass
      else:
        if len(D[aa]) < len(D[bb]):
          aa, bb = bb, aa
        for x in D[bb]:
          R[x] = aa
        D[aa] |= D[bb]
        del D[bb]
    else:
      R[b] = R[a]
      D[R[a]].add(b)
  else:
    if b in R:
      R[a] = R[b]
      D[R[b]].add(a)
    else:
      R[a] = a
      R[b] = a
      D[a].add(a)
      D[a].add(b)

print(max(len(x) for x in D.values()) if D else 1)

Measured memory_bytes: 173008
#include <stdio.h>

int main()
{
    int a, b, op, output;
    
    while(1)
    {
        scanf("%d %c %d\n", &a, &op, &b);

        if(op == '+')
        {
            output = a + b;
        }
        else if(op == '-')
        {
            output = a - b;
        }
        else if(op == '*')
        {
            output = a * b;
        }
        else if(op == '/')
        {
            output = a / b;
        }
        else
        {
            break;
        }
        
        printf("%d\n", output);
    }
    return 0;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:


// Description: グラフの型定義
// Verifyed: Many Diffrent Problem

//Appropriately Changed
using edge = struct {int to;};
using G = vector<vector<edge>>;

//Appropriately Changed
void add_edge(G &graph, int from, int to) {
	graph[from].push_back({to});
	graph[to].push_back({from});
}
 

const int limit = 100010;
int x[limit],y[limit],d[limit];
bool exist[limit];

string color;
int dist[limit];

void dfs(const G &tree,int v,int p,int w){
	w += (color[v] == 'W'),dist[v] = w;
	for(auto &e:tree[v]){
		if(e.to == p) continue;
		dfs(tree,e.to,v,w);
	}
}

int main(void){
	int n;
	cin >> n;
	rep(i,n) exist[i] = true;

	G tree(n);

	rep(i,n-1){
		cin >> x[i] >> y[i];
		x[i]--,y[i]--;
		add_edge(tree,x[i],y[i]);
		d[x[i]]++,d[y[i]]++;
	}

	cin >> color;
	if(n == 1 and color[0] == 'B'){
		cout << 0 << endl;
		return 0;
	}

	queue<int> q;
	rep(v,n){
		if(color[v]=='B' and d[v]==1){
			exist[v] = false,q.push(v);
		}
	}

	while(!q.empty()){
		const int v = q.front(); q.pop();
		d[v] = 0;
		for(auto &e:tree[v]){
			const int v2 = e.to;
			if(d[v2] == 0) continue;
			d[v2]--;
			if(d[v2] == 1 and color[v2] == 'B') exist[v2] = false, q.push(v2);
		}
	}

	rep(v,n) tree[v].clear();

	rep(i,n-1){
		if(exist[x[i]] == false or exist[y[i]] == false) continue;
		add_edge(tree,x[i],y[i]);
	}

	int root = -1, rn = 0;
	rep(v,n){
		if(exist[v] == false) continue;
		rn++;
		root = v;
	}


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


	int base = 2 * (rn - 1);
	rep(v,n){
		if(exist[v] == false) continue;
		const int cur = tree[v].size();
		if(cur & 1) color[v] ^= ('B'^'W');
		if(color[v] == 'W') base++;
	}

	int ans = 1 << 20;
	dfs(tree,root,-1,0);
	rep(v,n) if(exist[v] and dist[root] < dist[v]) root = v;
	dfs(tree,root,-1,0);
	rep(v,n) if(exist[v]) chmin(ans,base - 2 * dist[v]);
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 13824
#include <bits/stdc++.h>
#include <iterator>
using namespace std;
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(v) begin(v), end(v)
#define rreps(i, a, n) for (ll i = (a); i <= (ll)(n); ++i)
#define rrep(i, n) rreps(i, 0, n)
#define reps(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define rep(i, n) reps(i, 0, n)
#define each(i, n) for (auto&& i : n)
#define fill(x, y) memset(x,y,sizeof(x))
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template <typename T> inline void print(const T& x) {cout << x << '\n';}

signed main()
{ 
  int n; cin>>n;
  vi a(n);
  each(v,a) cin>>v;
  if(a[0]!=0) print(-1);
  else 
  {
    rep(i,n-1)
    {
      if(a[i+1]-a[i]>=2)
      {
        print(-1);
        return 0;
      }
    }
    ll ans=0;
    reps(i,1,n)
    {
      if(a[i-1]+1==a[i]) ans++;
      else ans+=a[i];
    }
    print(ans);
  }

  return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <string>
#include <vector>
#include <iostream>

using namespace std;

char get(char o, int i) {
    if (i % 2 == 0) {
        return o;
    }
    if (o == '0') return '1';
    else return '0';
}

int main(void){
    string s;
    cin >> s;
    int count = 0;
    for (int i = 1; i < s.length(); i++){
        char c = get(s[0], i);
        if (c != s[i]) {
            count++;
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 512
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;

int main() {
  int h, w, a[25][25];
  scanf("%d%d", &h, &w);
  for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) scanf("%d", &a[i][j]);
  int ans = 1000000000;
  for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) {
    int sum = 0;
    for (int y = 0; y < h; y++) for (int x = 0; x < w; x++) {
      sum += min(abs(y - i), abs(x - j)) * a[y][x];
    }
    ans = min(ans, sum);
  }
  printf("%d\n", ans);
}



Measured memory_bytes: 2760
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/rope>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
//using namespace __gnu_pbds;
//using namespace __gnu_cxx;


using ll = long long;

//#define int ll

using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;



const int N = 2e5 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 1e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 6e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);


//template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

string s;
main() {
  file("threesum");
  ios;
  cin >> s;
  if (s[1] == 'B') cout << "ARC";
  else cout << "ABC";
  return 0;
}
/**

*/


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

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007
#define INF (1 << 30)
#define REP(i, m, n) for(int i = (int)m; i < (int)n; ++i)
#define rep(i, n) REP(i, 0, n)


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

    string s; cin >> s;
    int N = s.size();
    int ans = 0;
    rep(i, N) if(s[i] == '2') ans++;
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
def main
  n = gets.to_i
  a = gets.split.map(&:to_i)

  if a.include?(0) || a.count { |x| x < 0 } % 2 == 0
    p a.map { |x| x.abs }.inject(:+)
  else
    min = a.min_by { |x| x.abs }
    p a.map { |x| x.abs }.inject(:+) - min.abs*2;
  end
end

main


Measured memory_bytes: 9476
let nk = readLine()!.split(separator: " ").map { Int($0)! }
let n = nk[0], k = nk[1]

var arr: [Int] = []
for _ in 0..<k {
  let _ = readLine()!
  let a = readLine()!.split(separator: " ").map { Int($0)! }
  arr.append(contentsOf: a)
}
print(n - Set(arr).count)

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

using namespace std;

int main() {
  int n;
  cin>>n;
  vector<int> w(n);
  int cnt=0;
  rep(i,n){
    cin>>w[i];
    cnt+=w[i];
  }
  int a=0,ans=1e9;
  for(int i=0;i<n-1;i++){
    a+=w[i];
    ans=min(ans,abs(cnt-a-a));
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3636
#pragma GCC optimize(2)
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <queue>
#include <map>
#include <stack>
#include <vector>
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define debug  freopen("in.txt","r",stdin),freopen("out.txt","w",stdout);
#define pb push_back
#define all(x) x.begin(),x.end()
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
const int maxn = 1e6+10;
const int maxM = 1e6+10;
const int inf = 0x3f3f3f3f;
const ll inf2 = 0x3f3f3f3f3f3f3f3f;
const int mod = 1e9+7;
inline void read(int &x){
    int s=0,w=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
    x = s*w;
}

int N;
int a[maxn];
ll ksm(ll a,ll b){
    ll res = 1;
    while(b){
        if(b&1) res = res*a%mod;
        a = a*a%mod;
        b>>=1;
    }
    return res;
}
void solve(){
    ll ans = 0,sum = 0,sum2 = 0;
    for(int i =1;i<=N;i++) sum = (sum + a[i])%mod;
    for(int i = 1;i<=N;i++) sum2 = (sum2 + (ll)a[i]*a[i])%mod;
    ans = (sum*sum%mod - sum2 + mod) %mod *ksm(2,mod-2)%mod;
    cout<<ans<<'\n';
}
int main(){
//    debug;
    ios;

    cin>>N;
    for(int i =1;i<=N;i++) cin>>a[i];
    solve();


    return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int getRand(int l, int r)
{
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}
  
#define int long long 
#define pb push_back
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define precise(x) fixed << setprecision(x) 

const int MOD = 1e9+7;

int mod_pow(int a,int b,int M = MOD)
{
    int res = 1;
    
    while(b)
    {
        if(b&1) res=(res*a)%M;
        a=(a*a)%M;
        b>>=1;
    }
    
    return res;
}


void solve()
{
   int n,m;
    cin >> n >> m;
    
    int a[n];
    f(i,n) cin >> a[i];
    
    sort(a,a+n);
    
    int tot = 0;
    f(i,n) tot+=a[i];
    
    int cnt = 0;
    
    f(i,n)
    {
        if(a[i]*4*m < tot) ;
        else cnt++;
    }
    
    if(cnt >=m) cout << "Yes";
    else cout <<"No";
}

signed main()
{
    fast;
    
    int t = 1;
    
//    cin >> t;
    
    while(t--)
        
    solve();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define all(v) (v).begin(),(v).end()
 
#define PII pair<int,int>
#define st first
#define nd second
#define pb push_back
#define lint long long int
#define VI vector<int>

using namespace std;

template<class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<"="<<h<<","; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream &os, vector<T> V){
  os<<"[";for(auto vv:V)os<<vv<<",";return os<<"]";
} 

template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}


#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
 
#define make( x) int (x); scanf("%d",&(x));
#define make2( x, y) int (x), (y); scanf("%d%d",&(x),&(y));
#define make3(x, y, z) int (x), (y), (z); scanf("%d%d%d",&(x),&(y),&(z));
#define make4(x, y, z, t) int (x), (y), (z), (t); scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define makev(v,n) VI (v); FOR(i,0,(n)) { make(a); (v).pb(a);} 
#define IOS ios_base::sync_with_stdio(0)
#define HEAP priority_queue
 
#define read( x) scanf("%d",&(x));
#define read2( x, y) scanf("%d%d",&(x),&(y));
#define read3(x, y, z) scanf("%d%d%d",&(x),&(y),&(z));
#define read4(x, y, z, t) scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define readv(v,n) FOR(i,0,(n)) { make(a); (v).pb(a);}
#define jeb fflush(stdout)

const int max_n = 100;

const int mod = 1e9 + 7;
const int PION = 0;
const int POZIOM = 1;
char s[2][max_n];

int main () {
	make(n);
	scanf("%s", s[0]);
	scanf("%s", s[1]);
	int ans = 1;
	int last = PION;
	int poz = 1;
	if (s[0][0]==s[1][0]) ans = 3;
	else {
		ans = 6;
		poz = 2;
		last = POZIOM;
	}
	while (poz != n) {
		if (s[0][poz]==s[1][poz]) {
			if (last == PION) {
				ans = (ans + ans) % mod;
				poz++;
			} else {
				poz++;
				last = PION;
			}
		} else {
			if (last == PION) {
				ans = (ans + ans) % mod;
				poz += 2;
				last = POZIOM;
			} else {
				ans = (ans * 3LL) % mod;
				poz += 2;
				last = POZIOM;
			}
		}
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll N, K;
ll sol(ll x, ll N) {
  if (N == 0) return x;
  return min(sol(x + K, N - 1), sol(x * 2, N - 1));
}
int main () {
  cin >> N >> K;
  cout << sol(1, N) << endl;
}

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

int main() {
  int n,m,tmp;
  int64_t ans=0,r=1000000007;
  cin >> n >> m;
  vector<int>dp(n+1,1);
  for(int i=0;i<m;i++){
  	cin >>tmp;
  	dp.at(tmp)=0;
  }
  for(int i=2;i<=n;i++){
  	if(dp.at(i-1)==0 && dp.at(i-2)==0){
  		dp.at(n)=0;
  		break;
  	}
  	if(dp.at(i)!=0){
  		dp.at(i)=dp.at(i-2)+dp.at(i-1);
  		dp.at(i)%=r;
  	}
  } 	
  cout << dp.at(n) << endl; 
}


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

int main() {
  int a, b, c;
  char c1, c2;
  int ans1 = 0, ans2 = 0;
  while (cin >> a >> c1 >> b >> c2 >> c) {
    if (a * a + b * b == c * c)
      ++ans1;
    else if (a == b)
      ++ans2;
  }
  cout << ans1 << endl << ans2 << endl;
}


Measured memory_bytes: 3112
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cfloat>
#include <algorithm>
#include <numeric>
#include <vector>
#include <iterator>
#include <set>
#include <map>
using namespace std;

const double PI=acos(-1);

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

    if(d == 0){
        if(n == 100) cout << n+1 << endl;
        else cout << n << endl;
    }
    else if(d == 1){
        if(n == 100) cout << n * 101 << endl;
        else cout << n * 100 << endl;
    }
    else{
        if(n == 100) cout << n * 10100 << endl;
        else cout << n * 10000 << endl;
    }
    return 0;
}

Measured memory_bytes: 256