akhauriyash/Code-Regression huggingface dataset:
#すぬけ君は新しくできたプログラミングコンテストに会員登録しました。 登録に使ったパスワードを覚えておく自信が無かったすぬけ君は、 手元の紙にパスワードをメモしておくことにしました。 ただし、そのままメモをすると誰かにパスワードを盗まれてしまうかもしれないので、 文字列の偶数番目の文字と奇数番目の文字をそれぞれ別々の紙にメモしておくことにしました。
#パスワードの奇数番目の文字だけを順番を変えずに取り出した文字列 O と、 偶数番目の文字だけを順番を変えずに取り出した文字列 E が与えられます。 すぬけ君のかわりにパスワードを復元してください。
o = input()
e = input()
r = ''
for i in range(len(o)):
  r += o[i]
  if i < len(e):
    r += e[i]
print(r)

Measured memory_bytes: 2940
#include <stdio.h>

int main(void){
	int a,b,c,d;
	char ca[2],cb[2],cc[2],cd[2];
	scanf("%c%c%c%c",&ca,&cb,&cc,&cd);
	a = ca[0]-'0';b = cb[0]-'0';c = cc[0]-'0';d = cd[0]-'0';
	int ans = 7-a;
	//bcdで７-aを作る
	int i,j,k;
	char s[4];
	int checksum(){
		int temp = a;
		if(s[0]=='+')temp+=b;
		else temp -=b;
		if(s[1]=='+')temp+=c;
		else temp -=c;
		if(s[2]=='+')temp+=d;
		else temp -=d;
		if(temp==7)return 1;
		else return 0;
	}
	for(i=0;i<2;i++){
		for(j=0;j<2;j++){
			for(k=0;k<2;k++){
				if(i==0)s[0]='+';
				else s[0]='-';
				if(j==0)s[1]='+';
				else s[1]='-';
				if(k==0)s[2]='+';
				else s[2]='-';
				if(checksum()==1){
					printf("%d%c%d%c%d%c%d=7",a,s[0],b,s[1],c,s[2],d);
					return 0;
				}
			}
		}
	}
	return 0;
}

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

#define int long long
#define pb emplace_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define F first
#define S second
#define fast ios:: sync_with_stdio(false),cin.tie(0);

int32_t main(){
	fast;
	int n;
	cin >> n;
	
	cout << n*(n+1)/2;
}







Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i));
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
constexpr int MAX = 1e4;
constexpr int NIL = -1;
struct Node { int p = NIL, l = NIL, r = NIL; };
vector<Node> T(MAX);
vi D(MAX), H(MAX);
inline void preParse(int u) {
	if(u == NIL) return;
	cout << " " << u;
	preParse(T[u].l);
	preParse(T[u].r);
}
inline void inParse(int u) {
	if(u == NIL) return;
	inParse(T[u].l);
	cout << " " << u;
	inParse(T[u].r);
}
inline void postParse(int u) {
	if(u == NIL) return;
	postParse(T[u].l);
	postParse(T[u].r);
	cout << " " << u;
}
int main() {
	int n; cin >> n;
	int v, l, r;
	rep(i, 0, n) {
		cin >> v >> l >> r;
		T[v].l = l;
		T[v].r = r;
		if(l != NIL) T[l].p = v;
		if(r != NIL) T[r].p = v;
	}
	int root;
	rep(i, 0, n) if(T[i].p == NIL) { root = i; break; }
	P("Preorder");
	preParse(root);
	P("\nInorder");
	inParse(root);
	P("\nPostorder");
	postParse(root);
	P("");
	return 0;
}

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

using namespace std;
const int N = 300;

double dp[1 + N][1 + N][1 + N];
int cnt[5];

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i)  {
        int x;
        cin >> x;
        cnt[x - 1]++;
    }
    dp[0][0][0] = 0;
    for (int c = 0; c <= cnt[2]; c++)
        for (int b = 0; b <= n; b++)
            for (int a = 0; a <= n; a++) {
                if (a + b + c == 0)
                    continue;
                if (a + b + c > n)
                    continue;

                double dd = a + b + c;
                dp[a][b][c] = n / dd;
                if (a > 0)
                    dp[a][b][c] += dp[a - 1][b][c] *  a / dd;
                if (b > 0)
                    dp[a][b][c] += dp[a + 1][b - 1][c] * b / dd;
                if (c > 0)
                    dp[a][b][c] += dp[a][b + 1][c - 1] * c / dd;
            }

    cout << fixed << setprecision (10) << dp[cnt[0]][cnt[1]][cnt[2]] << "\n";
    return 0;
}


Measured memory_bytes: 213248
n,x,m=map(int,input().split())
visited=set()
visited_l=[]
loop=set()
loop_l=[]
visited.add(x)
visited_l.append(x)
xc=x
for i in range(m):
    xc=(xc**2)%m
    if xc in visited and not(xc in loop):
        loop.add(xc)
        loop_l.append(xc)
    elif xc in visited and xc in loop:
        break
    else:
        visited.add(xc)
        visited_l.append(xc)
s=len(visited_l)
t=len(loop_l)



if n<=s:
    

    print(sum(visited_l[:n]))
elif n<=s+t:
    print(sum(visited_l)+sum(loop_l[:n-s-t]))

else:
    ans=sum(visited)
    n=n-s
    ans+=(sum(loop_l)*(n//t))
    ans+=sum(loop_l[:n%t])
    print(ans)
    

Measured memory_bytes: 17324
#import<cstdio>
#import<map>
#define I(M,A)for(i=0;i<M;i++)scanf("%d",&x),A[i+1]=A[i]+x;
main(){for(int n[1501],m[1501],o,a,b,i,j,x;scanf("%d%d",&a,&b),a;printf("%d\n",o)){std::map<int,int>z;*n=*m=o=0;I(a,n)I(b,m)for(i=0;i<=a;i++)for(j=0;j<=b;j++)z[n[i]+m[j]]++;for(std::map<int,int>::iterator p=z.begin();p!=z.end();p++)o+=(p->second)*((p->second)-1)/2;}}

Measured memory_bytes: 18000
from scipy import optimize

X = int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

divisors = make_divisors(X)
divisors = divisors + [-x for x in divisors]
for p in divisors:
    def f(x):
        return (x+p)**5 - x**5 - X 
    sol = optimize.fsolve(f, X**(1./5.))
    #print(sol[0])
    B = int(round(sol[0]))
    A = B + p
    #print(p, A, B)
    if A**5 - B**5 == X:
        print(A, B)
        break

Measured memory_bytes: 49752
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5+5;
const int mod = 1e9+7;
ll qpow(ll a,ll b){ll res=1;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

int main()
{
    set<string>s;
    int n;
    scanf("%d",&n);
    for(int i = 1;i <= n;++i){
        string a;
        cin>>a;
        s.insert(a);
    }
    cout<<(int)s.size()<<endl;
    return 0;
}


Measured memory_bytes: 19228
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
	return os << "(" << x.first << "," << x.second << ")";
}
typedef long long ll;
typedef long double ld;
map<vector<int>, ll> dp;
vector<ll> A;
ll solve(int l, int r, int cl, int cr) {
	auto t = {l, r, cl, cr};
	if (dp.count(t)) return dp[t];
	if (r - l == 1) return 0;
	ll ret = LLONG_MAX;
	for (int m = l + 1; m < r; ++m) {
		ret = min(ret, solve(l, m, cl, cl + cr) + solve(m, r, cl + cr, cr) + A[m] * (cl + cr));
	}
	return dp[t] = ret;
}
int main() {
	int n;
	scanf("%d", &n);
	A.resize(n);
	for (int i = 0; i < n; ++i) scanf("%lld", &A[i]);
	ll ans = solve(0, n - 1, 1, 1) + A[0] + A[n - 1];
	printf("%lld\n", ans);
}


Measured memory_bytes: 32280
import numpy as np

N, M, C = map(int, input().split())
B= np.array(list(map(int, input().split())))
truthCnt = 0
for i in range(0, N):
    A = np.array(list(map(int, input().split())))
    sum = C
    for j in range(0, M):
        sum += A[j]*B[j]

    if sum > 0 :
        truthCnt += 1

print(truthCnt)

Measured memory_bytes: 12424
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>

typedef struct{
    long long a;
    long long b;
    long long rest;
} task_t;
task_t task[200010];

int strsort(const void *A, const void *B){
    long long R=((task_t*)A)->rest-((task_t*)B)->rest;
    long long Q=((task_t*)A)->a-((task_t*)B)->a;
    long long P=((task_t*)A)->b-((task_t*)B)->b;
    if (P!=0){
        return P;
    } else if (Q!=0){
        return Q;
    } else {
        return R;
    }
}

int main(void){
    long long n,t=0,margin=0;
    scanf("%lld",&n);
    for (int i=0; i<n; i++){
        scanf("%lld%lld",&task[i].a,&task[i].b);
        task[i].rest=task[i].b-task[i].a;
    }
    qsort (task,n,sizeof(task_t),strsort);
    for (int i=0; i<n; i++){
        t+=task[i].a;
        if (t<=task[i].b){
            margin=task[i].b-t;
        } else {
            margin-=(task[i].a);
        }
        if (margin<0){
            printf("No\n");
            return 0;
        }
    }

    printf("Yes\n");
    return 0;
}


Measured memory_bytes: 9596
#include<stdio.h>
#include<stdlib.h>
#define TYPE long long
int cmp(const void *a, const void *b) { return *(TYPE *)a - *(TYPE *)b; }
int main() {
	long long N,l,r,ans;
	scanf("%lld", &N);
	long long *X = (long long *)malloc(sizeof(long long)*N);
	long long *f = (long long *)malloc(sizeof(long long)*N);
	for (int i = 0; i < N; i++)
	{
		scanf("%lld", &X[i]);
		f[i] = X[i];
	}

	qsort(f, N, sizeof(long long), cmp);
	l = f[N / 2 - 1];
	r = f[N / 2];
	for (int i = 0; i < N; i++)
	{
		if (X[i]<r)
		{
			ans = r;
		}
		else
		{
			ans = l;
		}
		printf("%lld\n", ans);
	}

	return 0;
}

Measured memory_bytes: 5216
def resolve():
    N, Y = map(int, input().split())

    resx, resy, resz = (-1, -1, -1)
    for x in range(N+1):
        for y in range(N+1-x):
            z = N - x - y
            total = 10000*x + 5000*y + 1000*z

            if total == Y:
                resx, resy, resz = (x, y, z)
                break
    
    print(resx, resy, resz)
    
resolve()

Measured memory_bytes: 3064
import numpy as np
s = input()

k = 753
for n in range(len(s)-2):
	i = 0
	i += int(s[n])*100
	i += int(s[n+1])*10
	i += int(s[n+2])
	if np.abs(753-i) < k:
		k = np.abs(753-i)

print(k)


Measured memory_bytes: 21796
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string.h>
#include<cmath>
using namespace std;
int main(){
  string s;
  int k;
  scanf("%d\n",&k);
  getline(cin,s);
  //printf("%d",s.size());
  if(k<s.size()){
   for(int i=0;i<k;i++){
       cout<<s[i];
   }
  cout<<"...";
  }
  else{
      cout<<s;
  }
}
     


 

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

int main(){
  int64_t N,P;
  cin>>N>>P;
  for(int64_t i=0;i<N;i++){
    int64_t A;
    cin>>A;
    if(A%2==1){
      cout<<(int64_t)pow(2,N-1)<<endl;
      return 0;
    }
  }
  cout<<(int64_t)pow(2,N)*(1-P)<<endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    int K = sc.nextInt();
    String s = sc.next();

    sc.close();

    String[] S = s.split("");

    int score = 0;

    for (int i = 0; i < S.length - 1; i++) {
      if (S[i].equals(S[i + 1])){
        score++;
      }
    }

    int ans = Math.min(score + 2 * K, N - 1);

    System.out.println(ans);

  }

}

Measured memory_bytes: 33060
#include <cstdio>
#include <random>
#include <cassert>
#include <algorithm>    
#include <iostream>
#include <chrono>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <bitset>
#define pb push_back
#define mk make_pair
#define eb emplace_back
#define eps 1e-8
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()

// #define int long long


using namespace std;
typedef long double ld;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef tuple<int, int, int> tiii;
typedef vector<int> vii;
typedef vector<long double> vd;
const int inf = 1e9;
const long long INF = 1e18;
const int M = 1e9 + 7;


int dp[5555][5555];
char s[5555];

signed main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	int n;
	cin >> n >> (s + 1);
	int res = 0;
	for(int i = 1; i <= n; ++i) {
		for(int j = i + 1; j <= n; ++j) {
			if(s[i] == s[j]) dp[i][j] = min(j - i, dp[i - 1][j - 1] + 1);
			res = max(res, dp[i][j]);
		}
	}
	cout << res << endl;





    
	return 0;
}

Measured memory_bytes: 108800
N = int(input())
A = sorted(list(map(int, input().split())), reverse=True)

res = 0
if N % 2 == 0:
    r = N // 2
    for i in range(r):
        res += A[i] * 2
    print(res - A[0])
else:
    r = N // 2 + 1
    for i in range(r):
        res += A[i] * 2
    print(res - A[0] - A[r - 1])


Measured memory_bytes: 31444
url = "https://atcoder.jp//contests/abc098/tasks/arc098_a"

def main():
    input()
    s = input()
    w_count = s.count('W')
    right_we = {"W": w_count, "E": len(s) - w_count}
    left_we = {"W": 0, "E": 0}
    ans = 10000000
    for v in s:
        right_we[v] -= 1
        ans = min(ans, right_we["E"] + left_we["W"])
        left_we[v] += 1
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 74052
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		Array.Sort(A);
		int cnt = 0;
		int a = (A[2] - A[0]) / 2;
		cnt += a;
		A[0] += 2 * a;
		int b = (A[2] - A[1]) / 2;
		A[1] += 2 * b;
		cnt += b;
		
		int min = A.Min();
		for(int i=0;i<3;i++) A[i] -= min;
		
		int sum = A.Sum();
		if(sum == 1){
			cnt += 1;
		} else if(sum == 2){
			cnt += 2;
		}
		Console.WriteLine(cnt);
		
	}
	int[] A;
	public Sol(){
		A = ria();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 13268
use itertools::iproduct;
use proconio::input;

#[derive(Debug, Clone, Copy)]
enum Label {
    X,
    Y,
    Integer(usize),
}

fn err() -> ! {
    println!("Impossible");
    std::process::exit(0);
}

fn main() {
    input!(a: usize, b: usize, d: [[usize; b]; a]);
    let mut coeff = vec![vec![None; b]; a];
    for (i, j) in iproduct!(0..a, 0..b) {
        'coeff: for (k, l) in iproduct!(0..=100, 0..=100) {
            let base = |x, y| (x + 1) * k + (y + 1) * l;
            if d[i][j] < base(i, j) {
                continue;
            }
            let r = d[i][j] - base(i, j);
            for (i1, j1) in iproduct!(0..a, 0..b) {
                if base(i1, j1) + r < d[i1][j1] {
                    continue 'coeff;
                }
            }
            coeff[i][j] = Some((k, l, r));
            break;
        }
    }
    let coeff: Vec<Vec<(usize, usize, usize)>> = coeff
        .iter()
        .map(|v| v.iter().map(|x| x.unwrap_or_else(|| err())).collect())
        .collect();

    let cliff_size = coeff
        .iter()
        .map(|v| v.iter().map(|x| x.0.max(x.1) + 1))
        .flatten()
        .max()
        .unwrap();
    let vertex_count = cliff_size * 2;

    let mut edges = vec![];
    for i in 0..cliff_size - 1 {
        edges.push((i, i + 1, Label::X));
        edges.push((cliff_size + i, cliff_size + i + 1, Label::Y));
    }
    let mut ckd = vec![vec![false; cliff_size]; cliff_size];
    for (i, j) in iproduct!(0..a, 0..b) {
        let (k, l, r) = coeff[i][j];
        if ckd[k][l] {
            continue;
        }
        ckd[k][l] = true;
        edges.push((k, 2 * cliff_size - 1 - l, Label::Integer(r)));
    }
    let edge_count = edges.len();

    assert!(vertex_count <= 300);
    if 300 < vertex_count {
        err();
    }

    println!("Possible");
    println!("{} {}", vertex_count, edge_count);
    for (u, v, w) in edges {
        println!(
            "{} {} {}",
            u + 1,
            v + 1,
            match w {
                Label::X => 'X'.to_string(),
                Label::Y => 'Y'.to_string(),
                Label::Integer(x) => x.to_string(),
            }
        );
    }
    println!("{} {}", 1, vertex_count);
}


Measured memory_bytes: 2184
import unittest


class TestC(unittest.TestCase):
    def test_1(self):
        self.assertEqual(think(2, [[1, 2], [2]], [0, 1]), 1)

    def test_2(self):
        self.assertEqual(think(2, [[1, 2], [1], [2]], [0, 0, 1]), 0)

    def test_3(self):
        self.assertEqual(think(5, [[1, 2, 5], [2, 3]], [1, 0]), 8)


def solve():
    n, s, p = read()
    result = think(n, s, p)
    write(result)


def read():
    n, m = read_int(2)
    s = []
    for _ in range(m):
        buf = read_line().split()
        k = int(buf[0])
        s.append(list(map(int, buf[1:k + 1])))
    p = read_int(m)
    return n, s, p


def read_int(n):
    return read_type(int, n)


def read_float(n):
    return read_type(float, n)


def read_type(t, n):
    return list(map(lambda x: t(x), read_line().split(' ')))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(n, s, p):
    count = 0
    m = len(s)
    for bit in range(2 ** n):
        satisfy = True
        for i in range(m):
            if satisfies_condition(bit, s[i], p[i]):
                continue
            satisfy = False
            break
        if satisfy:
            count += 1
    return count


def write(result):
    print(result)


def satisfies_condition(bit, s, p):
    result = 0
    for ss in s:
        result ^= mask(bit, ss)
    return result == p


def mask(bit, k):
    return (bit >> (k - 1)) & 1


if __name__ == '__main__':
    # unittest.main()
    solve()

Measured memory_bytes: 5704
import sys
input = sys.stdin.readline


def read():
    N = int(input().strip())
    A = list(map(int, input().strip().split()))
    return N, A


def solve(N, A):
    B = [0 for a in A]
    mid = N // 2
    for i in range(0, N, 2):
        B[mid+i//2] = A[i]
    for i in range(1, N, 2):
        B[mid-(i+1)//2] = A[i]
    if N % 2 == 1:
        print(*B[::-1])
    else:
        print(*B)


if __name__ == '__main__':
    inputs = read()
    solve(*inputs)


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

struct board_data {
  int H;
  int W;
};

int main () {

  int H,W;
  std::vector <board_data> v;

  do {
    std::cin >> H >> W;
    v.push_back({H,W});
  } while (H != 0 && W != 0);

  for(int i = 0; i < v.size(); i++){

    for(int h_num = 0; h_num < v[i].H; h_num++){

      for(int w_num = 0; w_num < v[i].W; w_num++){

        if((h_num + w_num) % 2) // odd
          std::cout << '.';
        else  // even
          std::cout << '#';
    }
      std::cout << std::endl;
    }

    if(i != v.size() - 1)
      std::cout << std::endl;
  }

  return 0;
}



Measured memory_bytes: 3140
n, m, c = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)
as = []
n.times do
  as.push gets.split.map(&:to_i)
end
count = 0
as.each do |a|
  sum = c
  0.upto(m - 1) do |i|
    sum += a[i] * b[i]
  end
  count += 1 if sum > 0
end
puts count


Measured memory_bytes: 1788
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jaynil
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DKnight solver = new DKnight();
        solver.solve(1, in, out);
        out.close();
    }

    static class DKnight {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long x = in.nextLong();
            long y = in.nextLong();
            if ((2 * x - y) % 3 != 0 || (2 * y - x) % 3 != 0 || 2 * x - y < 0 || 2 * y - x < 0) {
                out.println(0);
                return;
            }
            long p = (2 * x - y) / 3;
            long q = (2 * y - x) / 3;
            long ans = 1;
            long anp = 1;
            long anq = 1;
            long mod = 1000000007;
            for (int i = 1; i <= p + q; i++) {
                ans *= i % mod;
                if (i <= p) anp *= i % mod;
                if (i <= q) anq *= i % mod;
                ans %= mod;
                anp %= mod;
                anq %= mod;
            }
            out.println((ans * ((Maths.power(anp, mod - 2, mod) * Maths.power(anq, mod - 2, mod)) % mod)) % mod);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }

    static class Maths {
        static long power(long x, long y, long p) {
            long res = 1;
            x = x % p;
            while (y > 0) {
                if ((y & 1) == 1)
                    res = (res * x) % p;
                y = y >> 1;
                x = (x * x) % p;
            }
            return res;
        }

    }
}



Measured memory_bytes: 22100
#include <cstdio>
#include <cstdlib>

const int MAXN=100011;

int gcd(int a, int b){
	return (b==0)?a:gcd(b, a%b);
}

void Show(bool i){
	if(i)	puts("POSSIBLE");
	else	puts("IMPOSSIBLE");
}

int N, K;
int A[MAXN], G;

void Test(int a){
	if(a>=0 && a%G==0){
		Show(true);
		exit(0);
	}
}

int main(){
	
	scanf("%d%d", &N, &K);
	for(int i=1;i<=N;++i)	scanf("%d", &A[i]);
	
	G=0;
	for(int i=1;i<=N;++i)	G=gcd(A[i], G);
	
	for(int i=1;i<=N;++i)	Test(A[i]-K);
	
	Show(false);
	
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <set>
using namespace std;
typedef long long lint;

// Graph Templates
using Weight = lint;
using Flow = lint;
struct Edge {
    int src, dst;
    Weight weight;
    Flow cap;
    Edge() : src(0), dst(0), weight(0) {}
    Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;
using Array = vector<Weight>;
using Matrix = vector<Array>;
const Weight inf = numeric_limits<Weight>::max() / 8;

struct ford_fulkerson {
    using Matrix = vector<vector<Flow>>;
    int n, t;
    vector<int> vis;
    vector<vector<Flow>> cap, flow;
    vector<vector<int>> g;
    const Flow INF;
    ford_fulkerson(int n)
        : n(n),
        cap(n, vector<Flow>(n)),
        flow(n, vector<Flow>(n)),
        g(n, vector<int>()),
        INF(numeric_limits<Flow>::max() / 8) {}
    ford_fulkerson(const Graph &graph) : ford_fulkerson(graph.size()) {
        for (int i = 0; i < n; ++i)
            for (auto &e : graph[i]) add_edge(e.src, e.dst, e.cap);
    }
    void add_edge(int u, int v, Flow c) {
        cap[u][v] += c;
        cap[v][u] += c;
        flow[v][u] += c;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    Flow solve(int s, int t) {
        this->t = t;
        Flow res = 0, aug = 1;
        while (aug > 0) {
            vis.assign(n, false);
            res += (aug = augment(s, INF));
        }
        return res;
    }
    Flow augment(const int &v, const Flow &lim) {
        vis[v] = true;
        if (v == t) return lim;
        for (const int &d : g[v]) {
            if (vis[d] || flow[v][d] == cap[v][d]) continue;
            Flow aug = augment(d, std::min(lim, cap[v][d] - flow[v][d]));
            flow[v][d] += aug;
            flow[d][v] -= aug;
            if (aug > 0) return aug;
        }
        return 0;
    }
};

int main(){
    int v, e;
    cin >> v >> e;
    int s, t, c;
    Graph g;
    g.resize(v);
    ford_fulkerson ff(g);
    for (int i=0; i<e; ++i){
        cin >> s >> t >> c;
        ff.add_edge(s, t, c);
    }
    Flow ans = ff.solve(0, v-1);
    cout << ans << endl;
    return 0;
}


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

using namespace std;

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(0)
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define REP(n) FOR(O, 1, (n))
#define pb push_back
#define f first
#define s second
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<piii> viii;

const int MAXN = 1000100, MAXK = 30;
const ll MOD = 1e9+7;
const ll INF = 1e18;
const ld PI = asin(1) * 2;



int main()
{
    FAST_IO;

    ll h; cin >> h;
    ll ans = 0;
    ll cnt = 1;
    ll curBit = 0ll;

    while (h) {
        ans += cnt;
        if (h&(1ll<<curBit)) h^=(1ll<<curBit);
        curBit++;
        cnt *= (ll)2;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }


/*
<url:https://onlinejudge.u-aizu.ac.jp/services/room.html#RitsCamp18Day1/problems/F>
問題文============================================================

 ごちうさが大好きなAORイカちゃんは「ごちうさ数」を定義した。
 ごちうさ数とは、 10 進表記において「 51?3 」を含む自然数のことである。
 ? は 0 〜 9 のどの数字であってもよい。
 
 N 以下の自然数のうち、ごちうさ数の個数を求めよ。
 
=================================================================

解説=============================================================

================================================================
*/

string S;
// dp[i桁目][下3桁][超えうるか][出現済]
ll dp[20][1000][2][2];
ll rec(int idx,int thdigit,bool tight = true,bool ok = false){
    if(idx == S.length()) return ok;
    ll& ret = dp[idx][thdigit][tight][ok];
    if(~ret) return ret;
    ret = 0;
    int x = S[idx] - '0';
    int r = (tight?x:9);
    for(int i = 0; i <= r; i++){
        int next_thdigit = (10*thdigit+i)%1000;
        ret += rec(idx+1,next_thdigit,(tight?!(i<r):tight),ok||((thdigit/10)==51 && i == 3));
    }
    return ret;
}
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    cin >> S;
    fill(***dp,***dp + 20*1000*2*2,-1);
    cout << rec(0,0) << endl;
	return 0;
}



Measured memory_bytes: 3860
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define Decimal fixed << setprecision(20)
#define SHOWP(x) cerr<<"["<<(x).FI<<", "<<(x).SE<<"]";
#define SHOWX(x) cerr<<#x<<": "<<x<<endl;
#define SHOWVEC(v, e) REP(i, e) cerr << (v[i]) << ' '; cerr << endl;
#define SHOW2D(a, h, w) REP(i, h){REP(j, w)cerr<<setw(3)<<(a[i][j])<<' ';cerr<<endl;}
constexpr int INF = 1100000000;
constexpr long long LLINF = 1100000000000000000LL;
constexpr long long MOD = 1000000007;

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


int main()
{
  int r;
  cin >> r;
  cout << 3*r*r << endl;
  return 0;
}


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

#define F first
#define S second
#define int long long
#define ull  unsigned long long
#define pb push_back

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int N = 300;
main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt","w", stdout);
    string s;
    cin >> s;
    int n = s.length();
    int l = (n - 1) / 2;
    int r = n / 2;
    int ans = n / 2;
    char c = s[r];
    while(s[l] == c && s[r] == c){
        ans++;
        l--;
        r++;
        if (l < 0) break;
        if (r >= n) break;
    }
    cout << ans;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000007
const int INF = 1LL<<30;

 
int main(){
    int n,k;
    cin>>n>>k;
    vector<double> p(n);
    rep(i,n){
        cin>>p[i];
        p[i]=(p[i]+1)/2;
    }
    vector<double> s(n+1,0);
    rep(i,n) s[i+1]=s[i]+p[i];

    double ans=0;
    for(int i=k;i<n+1;i++){
        ans=max(ans,s[i]-s[i-k]);
    }

    cout<<fixed<<setprecision(10)<<ans<<endl;
}

Measured memory_bytes: 6464
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define rep(i,x) for(long long i=0;i<(long long)(x);i++)
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define ll long long
int main() {
    int n;
    cin>>n;
    ll ar[n+1];
    ll a[n];
    REP(i,n+1)
    cin>>ar[i];
    REP(i,n)
    cin>>a[i];
    ll p=0,c=0,c1=0;
    REP(i,n)
    {
    p=min(a[i],ar[i]);
    c1=min(ar[i+1],a[i]-p);
    ar[i+1]-=c1;
    c+=p+c1;
    
}
cout<<c<<endl;
}

Measured memory_bytes: 5156
N, M = [int(x) for x in input().strip().split(" ")]

def dfs(v, l):
    for u in d[v]:
        if u in pvs:
            return l + [u]
        if u in vs:
            continue
        pvs.add(u)
        vs.add(u)
        ll = dfs(u, l + [u])
        pvs.remove(u)
        if ll:
            return ll
    return False

d = [set() for _ in range(N)]
for _ in range(M):
    a, b = [int(x) for x in input().strip().split(" ")]
    d[a-1].add(b-1)

vs = set()
for i in range(N):
    if i in vs:
        continue
    vs.add(i)
    pvs = set([i])
    loop = dfs(i, [i])
#    print(i, loop, vs)
    if loop:
        break

import sys
#print(loop)
if not loop:
    print("-1")
    sys.exit()
else:
    ll = []
    lx = loop[-1]
    f = False
    for x in loop:
        if lx == x and not f:
            f = True
            continue
        if not f:
            continue
        ll.append(x)
    loop = ll

v2i = [-1 for _ in range(N)]
for i, v in enumerate(loop):
    v2i[v] = i

i = 0
vs = set()
ss = set()
lnum = len(loop)
ll = []
while True:
    v = loop[i]
    if i in vs:
        f = False
        loop = []
        for x in ll:
            if v == x:
                f = True
            if f:
                loop.append(x)
        break

    m = 0
#    print(v, d[v], v2i, ss, vs)
    for u in d[v]:
        if v2i[u] == -1:
            continue
        if v2i[u] in ss:
            continue
        if v2i[v] > v2i[u]:
            m = max(lnum - v2i[v] + v2i[u], m)
        else:
            m = max(v2i[u] - v2i[v], m)
#        print(u, m, v2i[u])
    for j in range(m-1):
        ss.add((i + j + 1) % lnum)
    vs.add(i)
    ll.append(v)
#    print(i, m, loop)
    i = (i + m) % lnum
#    print(i)

print(len(loop))
for i in loop:
    print(i+1)


Measured memory_bytes: 44396
A = int(input())
B = int(input())
C = int(input())

X = int(input())
res = 0
for i_a in range(0, A+1):
    for i_b in range(0, B+1):
        for i_c in range(0, C+1):
            money = 500 * i_a + 100 * i_b + 50 * i_c
            if money == X:
                res += 1
print(res)

Measured memory_bytes: 3064
import sys
input = lambda: sys.stdin.readline().rstrip()

N = int(input())

ans = 0

def divisor(x):
    res = []
    for i in range(1, int(x**0.5) + 1):
        if x % i == 0:
            if i != x//i:
                res.append(i)
                res.append(x//i)
            else:
                res.append(i)   
    return res[1:]


ans += len(divisor(N-1))

div_N = divisor(N)

for num in div_N:
    tmp = N
    while tmp % num == 0:
        tmp //= num
    if tmp == 1:
        ans += 1
        continue    
    if (tmp-1) % num == 0:
        ans += 1
print(ans)

Measured memory_bytes: 39280
import itertools
n = int(input())
a = list(map(int, input().split()))

n_acc = itertools.accumulate(a)
#r_acc = itertools.accumulate(a[::-1])
# 1, 3, 6, 10, 15 ,21
# 1 vs 20
# 3 vs
#print(n_acc, r_acc)


sigma = sum(a)
ans = 10 ** 16

for i, val in enumerate(n_acc):
    if (i == len(a) - 1):
        break

    rest = sigma - val
    ans = min(abs(val - rest), ans)


print(ans)


Measured memory_bytes: 30604
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<stack>
#include<cstdlib> 
using namespace std;
int main(){
	int x,t;
	cin>>x>>t;
	if(x>=t){
		cout<<x-t<<endl;
	}else{
		cout<<"0"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
using static System.Console;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var sw = ReadLine().Split();
            var s = int.Parse(sw[0]);
            var w = int.Parse(sw[1]);

            if (s <= w)
            {
                WriteLine("unsafe");
            }
            else
                WriteLine("safe");
        }
    }
}


Measured memory_bytes: 27480
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back

template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}

template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

ll gcd(ll a, ll b){
    if(a % b == 0){
        return(b);
    }
    else{
        return(gcd(b, a % b));
    }
}

//scanf("%lld", &);
//cin >> ;
//cout << ans << endl;

ll N, M, K, i, j, k, l, ans, cnt = 0;
ll a, b, c, x, y, z;
string s;
string RGB = {"RGB"};

int main(){
    //cin >> ;
    //cout << ans << endl;
    cin >> x;
    cin >> y;
    cin >> z;



    cout << z << " " << x << " " << y << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int h,w;
    while(1){
        cin >> h >> w;
        if(h == 0 && w == 0) break;
        for(int i = 1; i <= h; i++){
            for(int j = 1; j <= w; j++){
                if((i + j) % 2 == 1){
                    cout << ".";
                } else {
                    cout << "#";
                }
            }
        cout << endl;
        }
    cout << endl;
    }
    return 0;
}


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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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; }

bool comp(pair<ll,ll> a, pair<ll,ll> b){
    return a.second > b.second;
}
int main(void){
    ll N,M; cin >> N >> M;
    vector<ll> A(N); REP(i,N) cin >> A[i];

    vector<pair<ll,ll>> v(M);
    REP(i,M){
        ll b,c; cin >> b >> c;
        v[i].first = b; v[i].second = c;
    }
    SORT(A);
    sort(v.begin(), v.end(), comp);

    ll t = 0;
    vector<ll> newA(N);
    REP(i,M){
        ll b = v[i].first, c = v[i].second;
        for(ll j=t; j<min(t+b, N); j++){
            newA[j] = c;
        }
        t += b;
    }
    vector<ll> AA(N);
    REP(i,N) AA[i] = max(A[i], newA[i]);
    ll ans = 0; REP(i,N) ans += AA[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4224
#include <stdio.h>

int main() {
    int a, b, c, x;
    int ans = 0;
    int i, j, k;

    scanf("%d %d %d %d", &a, &b, &c, &x);

    for (i = 0; i <= a; i++) {
        for (j = 0; j <= b; j++) {
            for (k = 0; k <= c; k++) {
                if ( (500*i + 100*j + 50*k) == x )  {
                    ans++;
                }
            }
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()

template<class T> inline bool chmin(T &a, T b){
	if(a>b){a=b;return true;}
	return false;
}
template<class T> inline bool chmax(T &a, T b){
	if(a<b){a=b;return true;}
	return false;
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;

int ans[200005];
int f(int x){
  	if(x==0)return 0;
	if(ans[x])return ans[x];
	return ans[x]=f(x%__builtin_popcount(x))+1;
}
int div1[200005],div2[200005];
signed main(){
	int N;std::string S;
	std::cin>>N>>S;
	int cnt=0,now1=1,now2=1;
	rep(i,N){
		if(S[i]=='1')cnt++;
	}
	int ans1=0,ans2=0;
	rev(i,N){
		div1[N-1-i]=now1;
		div2[N-1-i]=now2;
		if(S[i]=='1'){
			ans1+=now1;ans2+=now2;
			ans1%=cnt+1;
			if(cnt!=1)ans2%=cnt-1;
		}
		now1*=2;
		now1%=cnt+1;
		if(cnt!=1){
			now2*=2;now2%=cnt-1;
		}
	}
	rep(i,N){
		if(cnt==1&&S[i]=='1')cout<<"0\n";
		else if(S[i]=='1'){
			int j=(ans2-div2[N-i-1]+cnt-1)%(cnt-1);
			cout<<f(j)+1<<"\n";
		}else {
			int j=(ans1+div1[N-i-1])%(cnt+1);
			cout<<f(j)+1<<"\n";
		}
	}
}


Measured memory_bytes: 7652
function Main(input) {
    var INT_MAX = 1000000007;
    input = input.split("\n");
    var line = input[0].split(" ");
    var max = parseInt(line[0]);
    var prime = [2];
    var flag = 0;
    for(var i = 2; i<1000; i++){
        for(var j = 0; j<prime.length; j++){
            if(i%prime[j]===0){
                flag=0;
                break;
            } else {
                flag++;
            }
        }
        if(flag>0){
            prime.push(i);
            flag=0;
        }
    }
    var yakusuu = Array(1000).fill(0);
    for(var i = 2; i<=max; i++){
        var test = i;
        for(var j = 0; j<prime.length; j++){
            while(1){
                if(test%prime[j]===0){
                    yakusuu[prime[j]]++;
                    test = test / prime[j];
                } else {
                    break;
                }
            }
        }
 
    }
    var ans = 1;
    for(var i = 0; i<yakusuu.length; i++){
        if(yakusuu[i] === 0){
            continue;
        } else {
            ans*= (yakusuu[i]+1);
            if(ans>INT_MAX){
                ans = ans % INT_MAX;
            }
        }
    }
    
    console.log(ans)
 
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

int main() {
	LL n;
	cin >> n;
	vector<LL> a(n);
	inc(i, n) { cin >> a[i]; }
	
	vector<LL> s(n + 1);
	inc(i, n) { s[i + 1] = s[i] + a[i]; }
	
	LL ans = 1e18;
	inc(i, n + 1) {
		setmin(ans, abs(s[i] - (s.back() - s[i])));
	}
	
	cout << ans << endl;
	
	return 0;
}


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

int main() {
    int s, w;
    cin >> s >> w;
    if (s > w)
        cout << "safe" << endl;
    else
        cout << "unsafe" << endl;
    return 0;
}

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

int main() {
	int h,w;
	int a[28]={};
	cin>>h>>w;
	char chr;
	for(int i=0;i<h*w;i++){
		cin>>chr;
		int k=chr-97;
		a[k]++;
	}
	int t4=0;
	int t2=0;
	int t1=0;
	for(int i=0;i<28;++i){
		t4+=a[i]/4;
		t2+=a[i]/2;
		t1+=a[i]%2;
	}
	bool flg=true;
	if((h/2)*(w/2)>0&&t4!=(h/2)*(w/2))flg=false;
	if(t2!=((w*h)/2))flg=false;
	if(t1!=(w%2)*(h%2))flg=false;
	if(flg){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}


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

int main() {
    set<string> st;
    int n;
    cin>>n;
    string s;
    while(n--){
        cin>>s;
        st.insert(s);
    }
    cout<<st.size()<<endl;
    return 0;
}


Measured memory_bytes: 19260
#include <algorithm>
#include <array>
#include <climits>
#include <cstddef>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <iterator>
#include <limits>
#include <numeric>
#include <string>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#ifdef ENABLE_ASSERT
#include <cassert>
#else
#undef assert
#define assert static_cast<void>(0)
#endif

using namespace std;
using namespace std::literals;

int main() {
    int n;
    cin >> n;
    auto d = vector<int>(n);
    for (auto &d_i : d)
        cin >> d_i;
    auto sum = 0ULL;
    for (int i = 0; i < n; i++)
        for (int j = i + 1; j < n; j++)
            sum += d[i] * d[j];

    cout << sum;
    return 0;
}


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

#define REP(i, n) for(int64_t i = 0; i < n; i++)
#define REPR(i, n) for(int64_t i = n; i >= 0; i--)
#define FOR(i, m, n) for(int64_t i = m; i < n; i++)
#define FORR(i, m, n) for(int64_t i = m; i >= n; i--)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}
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;}
const ll INF= 1ll << 60;
const ll MOD = 1000000007;
double EPS = 1e-10;
//----------------------------------------------------------

ll x;

int main(){
    cin >> x;
    ll ans=0;
    ll p;
    p = x/500;
    ans+=p*1000;
    x=x-500*p;
    p = x/5;
    ans+=p*5;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>



int p[100],m[100][100];
void MCM(int n){
  int i,l,j,k,b;
  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
      j = i + l - 1;
      m[i][j] = 100000;
      for(k=i;k<j;k++){
        b = m[i][k] + m[k+1][j] + p[i-1] * p[k] * p[j];
        if(m[i][j]>b) m[i][j]=b;
      }
    }
  }
}

int main(){
  int n,i,j;

  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d%d",&p[i-1],&p[i]);
  }

  for(i=1;i<=n;i++){
    m[i][i]=0;
  }
  MCM(n);
  printf("%d\n",m[1][n]);

  return 0;
}

Measured memory_bytes: 636