akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<unordered_map>
#include<cmath>
#include <bits/stdc++.h>
using namespace std;

int main(){
	
	int N,K;
	cin>>N>>K;
	map<int,int> S;
	int d[N];
	
	int b = 0;
	for(int i = 0; i < K; i++){
		cin>>b;
		int a= 0;
		for(int j = 0; j < b; j++){
			cin>>a;
			S[a-1]++;
		}
	}
	
	
	int ans = 0;
	for(int i = 0; i < N; i++){
		
		if(S[i]==0){
			ans++;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3636
#include <iostream>
using namespace std;
int main()  {
    
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    while(1) {
        int as = c-b;
        int ts = a-d;
        //cout<<as<<" "<<ts<<endl;
        if(as<=0)   {
            cout<<"Yes"<<endl;
            break;
        } 
        if(ts<=0)   {
            cout<<"No"<<endl;
            break;
        }
        c = as;
        a = ts;
    }
    return 0;
}

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

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, __VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

// 500, 61min

#define MOD 1000000007
#define INF 1000000000
#define MAX_N 100010

//#define CONFIRM

ll X, Y;
#ifdef CONFIRM
int dp[100][100][2] = {}; // 0: Alice ターン、かち 1: Brown のターン、かち

// x, y でプレイヤーが 0 Alice, 1 Brown のときの勝者を返す
// 0 なら勝者 Alice, 1 なら勝者 Brown
int dfs(int x, int y, int cur) {
    if(dp[x][y][cur] != -1) { return dp[x][y][cur]; }
    if(x <= 2 && y <= 2) { return dp[x][y][cur]; }
    int next = (cur == 0) ? 1 : 0;
    // x を削る
    for(int i = 1; i * 2 <= x; ++i) {
        int ret = dfs(x - i * 2, y + i, next);
        if(ret == cur) {
            dp[x][y][cur] = ret;
            return ret;
        }
    }
    // y を削る
    for(int i = 1; i * 2 <= y; ++i) {
        int ret = dfs(x + i, y - i * 2, next);
        if(ret == cur) {
            dp[x][y][cur] = ret;
            return ret;
        }
    }
    dp[x][y][cur] = next;
    return next;
}
#endif

int main()
{
    cin >> X >> Y;
#ifdef CONFIRM
    MINUS(dp);
    dp[0][0][0] = 1;
    dp[0][0][1] = 0;
    dp[0][1][0] = 1;
    dp[0][1][1] = 0;
    dp[0][2][0] = 0;
    dp[0][2][1] = 1;
    dp[1][0][0] = 1;
    dp[1][0][1] = 0;
    dp[1][1][0] = 1;
    dp[1][1][1] = 0;
    dp[1][2][0] = 1;
    dp[1][2][1] = 0;
    dp[2][0][0] = 0;
    dp[2][0][1] = 1;
    dp[2][1][0] = 1;
    dp[2][1][1] = 0;
    dp[2][2][0] = 1;
    dp[2][2][1] = 0;
    for(int i = 0; i < 100; ++i) {
        for(int j = 0; j < 100; ++j) {
            //printf("X: %d Y: %d Winner: %s\n", i, j, (dfs(i, j, 0) == 0) ? "Alice" : "Brown");
            if(dfs(i, j, 0) == 1 && abs(i-j) >= 2) {
                printf("predict is not correct %d %d\n", i, j);
                return 0;
            }
        }
    }
#endif
    if(abs(X-Y) < 2) { printf("Brown\n"); }
    else{ printf("Alice\n"); }
    return 0;
}


Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007
#1_A
"""
import math

n = int(input())
m = n
ans = []
i = 2
k = math.sqrt(n)
while i <= k:
    if n%i == 0:
        n = n//i
        ans.append(i)
        i -= 1
        if n == 1:
            break
    i += 1
if len(ans) == 0 or n != 1:
    ans.append(n)
print(m,end = ": ")
for i in range(len(ans)-1):
    print(ans[i], end = " ")
print(ans[-1])
"""

#1_B
"""
m,n = map(int, input().split())
b = bin(n)[2:]
num = [m]
for i in range(len(b)-1):
    num.append(num[-1]**2%1000000007)
ans = 1
for i in range(len(b)):
    ans *= num[i] if b[len(b)-1-i] == "1" else 1
    ans %= 1000000007
print(ans)
"""

#1_C
"""
import math

l = int(input())
a = list(map(int, input().split()))
dict = {}
for n in a:
    ans = []
    i = 2
    k = math.sqrt(n)
    dic = {}
    while i <= k:
        if n%i == 0:
            n = n//i
            ans.append(i)
            i -= 1
            if n == 1:
                break
        i += 1
    if len(ans) == 0 or n != 1:
        ans.append(n)
    for i in ans:
        if i in dic:
            dic[i] += 1
        else:
            dic[i] = 1
    for i in dic.keys():
        if i in dict:
            dict[i] = max(dict[i], dic[i])
        else:
            dict[i] = dic[i]
sum = 1
for x,y in dict.items():
    sum *= x**y
print(sum)
"""

#1_D
"""
import math

n = int(input())
m = n
ans = []
i = 2
k = math.sqrt(n)
dic = {}
while i <= k:
    if n%i == 0:
        n = n//i
        ans.append(i)
        i -= 1
        if n == 1:
            break
    i += 1
if len(ans) == 0 or n != 1:
    ans.append(n)
ans = list(set(ans))
sum = m
for i in ans:
    sum *= (1-1/i)
print(int(sum))
"""

#1_E
"""
def gcd(a,b):
    if a==0:
        return b
    return gcd(b%a,a)
a,b = LI()
g = gcd(a,b)
a//=g
b//=g
if b == 1:
    print(0,1)
    quit()
if b < 4:
    f = b-1
else:
    p = []
    x = 2
    m = b
    while x**2 <= b:
        if not m%x:
            p.append(x)
            while not m%x:
                m//=x
        x += 1
    if m != 1:p.append(m)
    f = b
    for i in p:
        f *= (1-1/i)
    f = int(f)
x_ = pow(a,f-1,b)
y_ = (1-a*x_)//b
ans = [x_,y_,abs(x_)+abs(y_)]
for i in range(-10000,10000):
    s = -b*i+x_
    t = a*i+y_
    m = abs(s)+abs(t)
    if m < ans[2]:
        ans = [s,t,m]
    elif m == ans[2] and s <= t:
        ans = [s,t,m]
print(ans[0],ans[1])
"""

#2
#2_A
"""
a,b = LI()
print(a+b)
"""

#2_B
"""
a,b = LI()
print(a-b)
"""

#2_C
"""
a,b = LI()
print(a*b)
"""

#2_D
a,b = LI()
if a*b < 0:
    print(-(-a//b))
else:
    print(a//b)



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

S = input().rstrip("\r\n")
N = len(S)
ans = "Yes"
for i in range(N):
    if S[i] != S[N-1-i]:
        ans = "No"
        break
for i in range((N-1)//2):
    if S[i] != S[(N-1)//2-1-i]:
        ans = "No"
        break
for i in range((N+3)//2-1, N):
    if S[i] != S[N-1-i]:
        ans = "No"
        break
print(ans)

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    int n,k;
    cin>>n;
    cin>>s;
    cin>>k;
    for(int i=0;i<n;i++)
    
    {
        if(s[i]!=s[k-1]) s[i]='*';
    }
    for(int i=0;i<n;i++)
    cout<<s[i];
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		const long MOD = 1000000007;
		static void Main(string[] args)
		{
			Combination.Initialize(2000, MOD);
			var nk = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
			long n = nk[0];
			long k = nk[1];

			long hole = k + 1;
			StringBuilder sb = new StringBuilder();
			for (int i = 1; i <= k; i++) {
				long red = Combination.Calculate(n - k + 1, i, MOD);
				long blue = Combination.Calculate(k - 1, i - 1, MOD);
				sb.AppendLine((red * blue % MOD).ToString());
			}

			Console.WriteLine(sb.ToString());
		}
	}

	public static class Combination
	{
		private static long[] factor;
		private static long[] inverseFactor;
		private static long[] inverse;

		// テーブルを作る前処理
		public static void Initialize(long max, long mod)
		{
			factor = new long[max + 1];
			inverseFactor = new long[max + 1];
			inverse = new long[max + 1];

			factor[0] = factor[1] = 1;
			inverseFactor[0] = inverseFactor[1] = 1;
			inverse[1] = 1;
			for (int i = 2; i <= max; i++) {
				factor[i] = factor[i - 1] * i % mod;
				inverse[i] = mod - inverse[mod % i] * (mod / i) % mod;
				inverseFactor[i] = inverseFactor[i - 1] * inverse[i] % mod;
			}
		}

		public static long Calculate(long n, long k, long mod)
		{
			if (n < k) return 0;
			if (n < 0 || k < 0) return 0;
			return factor[n] * (inverseFactor[k] * inverseFactor[n - k] % mod) % mod;
		}
	}
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define VPII vector<pair<int,int> >
#define F first
#define S second
#define RF(x) freopen(x,"r",stdin)
#define WF(x) freopen(x,"w",stdout)
typedef long long LL;
using namespace std;
typedef pair<LL,LL> PLL;
typedef pair<int,int> PII;
const LL MOD = 1e9+7;
const int SIZE = 1e6+5;
const LL INF = 1LL<<58;
const double eps = 1e-13;

int v[100009];
bool o[100009];
LL l[100009];
LL r[100009];

int main(){
	DRI(n);
	RI(v[0]);
	REPP(i,1,n){
		char c;scanf(" %c",&c);
		o[i]=(c=='+');
		RI(v[i]);
	}
	LL sum=0;
	REP(i,n){
		sum+=v[i];
	}
	REPP(i,1,n){
		if(!o[i]){
			l[i]=l[i-1]+v[i]*2;
		}
		else l[i]=l[i-1];
	}
	REPP(i,1,n){
		if(!o[i]){
			r[i]=2*v[i];
			for(int j=i+1;j<n;j++){
				if(!o[j])break;
				r[i]+=2*v[j];
			}
		}
	}
	//REP(i,n)printf("%lld ",l[i]);puts("");
	//REP(i,n)printf("%lld ",r[i]);puts("");
	LL cmax=-INF;
	REPP(i,1,n){
		if(!o[i]){
			cmax=max(cmax,sum-l[i-1]-r[i]);
		}
	}
	if(cmax==-INF){
		cmax=sum;
	}
	printf("%lld",cmax);
}


Measured memory_bytes: 2432
#include <stdio.h>
#include <math.h>
int main(void) {
	int n, d, count = 0;
	int x[10][10];
	double sq_dis, dis;
	scanf("%d%d", &n, &d);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < d; j++)
			scanf("%d", &x[i][j]);
	}

	for (int i = 0; i < n - 1; i++) {
		for (int j = i + 1; j < n; j++) {
			sq_dis = 0;
			for (int k = 0; k < d; k++)
				sq_dis += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
			dis = sqrt(sq_dis);
			if (ceil(dis) == floor(dis))
				count++;
		}
	}

	printf("%d\n", count);
	return 0;
}

Measured memory_bytes: 384
N=int(input())
A1=list(map(int,input().split()))
A2=list(map(int,input().split()))
B1=[0*i for i in range(N)]
B2=[0*i for i in range(N)]

B1[0]=A1[0]
B2[0]=A2[0]
for i in range(0,N-1):
    B1[i+1]=B1[i]+A1[i+1]
    B2[i+1]=B2[i]+A2[i+1]
maximum=B1[0]+B2[N-1]
for i in range(1,N):
    point=B1[i]+(B2[N-1]-B2[i-1])
    maximum=max(maximum,point)
print(maximum)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define ld long double
#define vi vector<vector<ll> >
using namespace std;
const int MOD=1000000007;
const int MOD2=15000007;
const ll MAX=9187201950435737471;
const int N=100005;
const ll INF=1e17;
const long double PI=acos(-1);


void solve(int T){
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    while(b<=a && k>0){
        b*=2;
        k--;
    }
    while(c<=b && k>0){
        c*=2;
        k--;
    }
    if(a<b && b<c){
        cout<<"Yes\n";
    }
    else cout<<"No\n";
}

int main() {
    fastio
    int T=1;
    //cin>>T;
    for(int i=1;i<=T;i++){
        solve(i);
        //if(i<T)cout<<"\n";
    }
    return 0;
}




Measured memory_bytes: 3660
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int N, M, X;
    cin >> N >> M >> X;
    vector<int> A(M);
    for (auto& a : A) {
        cin >> a;
    }
    int ansL = 0;
    int ansR = 0;
    for (auto a : A) {
        if (a < X) {
            ++ansL;
        }
        if (X < a) {
            ++ansR;
        }
    }
    cout << min(ansL, ansR) << endl;
}


Measured memory_bytes: 256
while True:
    table=input().split()
    
    a=int(table[0])
    b=table[1]
    c=int(table[2])
    
    if b=='?':
        break
    elif b=='+':    
        print("%d"%(a+c))
    elif b=='-':
        print("%d"%(a-c))
    elif b=='*':
        print("%d"%(a*c))
    elif b=='/':
        print("%d"%(a/c))
        


Measured memory_bytes: 5592
N, X, Y = map(int, input().split())
D = [None] + [0] * (N - 1) #最低距離が1からNまでの個数を表示するリストを作る(YZT さんのコメント)

#各最低距離の個数カウント
for i in range(1, N):                           # i 出発
    for j in range(i + 1, N + 1):               # j 到着
        d = min(abs(j - i),                     # 近道をしない
                abs(X - i) + 1 + abs(j - Y),    # 「+1」は近道の距離、X < Y　
                abs(Y - i) + 1 + abs(j - X))    # 「+1」は近道の距離、Y < X　
        D[d] += 1                               # 距離ｄごとにカウント
        # print(abs(j-i),abs(X-i)+1 , abs(j-Y) , abs(Y - i) + 1,abs(j - X)," ",d,D," ",i,j)
    
for d in D[1:]: #最低距離は１だから距離０は使わないが、添え字＝距離とすることでわかりやすい
    print(d)

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

int main(){
  int N;
  cin>>N;
  
  vector<int>A(N);
  
  for(int i=0;i<N;i++){
    cin>>A.at(i);
    }

    sort(A.begin(),A.end());
    
    cout<<A.at(N-1)-A.at(0)<<endl;
    }
    
       

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

namespace mondai0008
{
	class Program
	{
		static void Main(string[] args)
		{
			while( true ) {
				var	s	= Console.ReadLine();
				if( s == null ) {
					break;
				}
				var	n	= int.Parse( s );
				
				int	cnt	= 0;
				for( int a = 0; a <= 9; a++ ) {
					for( int b = 0; b <= 9; b++ ) {
						for( int c = 0; c <= 9; c++ ) {
							for( int d = 0; d <= 9; d++ ) {
								if( a + b + c + d == n ) {
									cnt++;
								}
							}
						}
					}
				}
				Console.WriteLine( cnt );
			}
		}
	}
}

Measured memory_bytes: 5608
a,b,c = map(int,input().split())
k = int(input())

while k > 0:
    if b <= a:
        b *= 2
        k -= 1
    else:
        break
while k > 0:
    if c <= b:
        c *= 2
        k -= 1
    else:
        break
if a < b < c:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9168
#include <iostream>
#define nmax 405
using namespace std;
int n, a[nmax];
long long s[nmax][nmax];
long long dp[nmax][nmax];

int main()
{
  	int i, j, k, l;
	cin >> n;
  	for (i = 1; i <= n; i++)
      cin >> a[i];
  	for (i = 1; i <= n; i++)
      for (j = i; j <= n; j++)
       	s[i][j] = s[i][j-1] + a[j];

  	for (i = 1; i <= n; i++)
      for (j = 1; j <= n; j++)
        dp[i][j] = 1LL<<60;

  	for (i = 1; i <= n; i++)
      dp[i][i] = 0;

    for (l= 2; l <= n; l++)
        for (i = 1; i + l - 1 <= n; i++) {
      	    j = i + l - 1;
            for (k = i; k < j; k++) {
                long long val = dp[i][k] + s[i][k] + dp[k + 1][j] + s[k + 1][j];
                if (dp[i][j] > val)
                    dp[i][j] = val;
            }
        }
  	cout << dp[1][n] << '\n';

	return 0;
}


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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back

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

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

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

int main(){
	int n;
	cin>>n;
	vi t(n);
	string s[50];
	for (int i = 0; i < n; i++){
		cin>>s[i]>>t[i];
	}
	string x;
	cin>>x;
	
	int time=0;
	for (int i = 1; i < n; i++){
		if(s[i-1]==x){
			for (int j = i; j < n ; j++){
				time+=t[j];
			}
			break;
		}
	}

	cout<<time<<endl;

	return 0;
}


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

#define min3(a,b,c)   min(a,min(b,c))
#define max3(a,b,c)   max(a,max(b,c))
#define min4(a,b,c,d) min(min(a,b),min(c,d))
#define max4(a,b,c,d) max(max(a,b),max(c,d))

#define count_one(a) __builtin_popcount(a)  // Returns the number of set bits(1) in a number(a). In long long use __builtin_popcountll(a)
#define parity(i)    __builtin_parity(i)  //even parity 0 and odd parity 1
#define blz(a)       __builtin_clz(a) //Returns the number of leading zeroes in a number(a)
#define btz(a)       __builtin_ctz(a) //Returns the number of trailing zeroes in a number(a)
#define gcd(a,b)     __gcd(a,b)
#define lcm(a,b)     (a*(b/gcd(a,b)))

#define pb   push_back
#define PI   M_PI
#define endl "\n"
#define sc   scanf
#define pf   printf

#define ll  long long
#define ull unsigned long long

#define W(t)            while(t--)
#define rep1(i,n)       for(int i = 0; i < n; i++)
#define rep2(a,b)       for(int i = a; i <= b; i++)
#define repit(it,type)  for(it = type.begin(); it != type.end(); it++)
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
using namespace std;
using namespace __gnu_cxx;

int main()
{
    IOS
    ll a,b,c,d,k,ans=0;
    cin>>a>>b>>c>>d>>k;
    a = 60*abs(c-a) - b+d;
    ans = a-k;
    cout<<ans<<endl;

    return 0;
}



Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <string>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
using namespace std;

#define REP(i,p,n) for(ll i=p;i<ll(n);++i)
#define rep(i,n) REP(i,0,n)

using ll = long long int;
using pll = pair<ll, ll>;

const ll T = 26;

ll D;
vector<ll> C;
vector< vector<ll> > S;

int main()
{
    cin >> D;

    C.assign(D, 0);
    rep (t, T) { cin >> C[t]; }

    S.assign(D, vector<ll>(T, 0));
    rep (d, D) { rep (t, T) { cin >> S[d][t]; } }

    vector<ll> L(T, 0);

    rep (d, D)
    {
        ll value = 0, index = 0;

        rep (t, T)
        {
            const ll x = S[d][t] + (d - L[t] + 1) * C[t];
            if (value <= x) { value = x; index = t; }
        }

        cout << index + 1 << endl;

        L[index] = d;
    }

    return 0;
}


Measured memory_bytes: 3732
#include <iostream>
using namespace std;
int main(void){
	unsigned long long a[87]={};
	int n;
	a[0]=2;
	a[1]=1;
	cin >> n;
	int i;

	for(i=2; i<=n; i++){
		a[i]=a[i-1]+a[i-2];
	}
	cout << a[i-1] << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <iomanip>
#include <ios>
#include <vector>
#include <string>
#include <algorithm>
#include <string>
#include<limits>
#include<cstdlib>
#include<functional>
#include<cassert>
#include <cstdio>
#include <stack>
#include <queue>
#include <map>
#define fi(p) for(int i=0;i<(p);i++)
#define ce(d) cout<<d<<endl;
#define ll long long
#define sorts(c) sort((c).begin(),(c).end());

using namespace std;

void solve() {
	string s;
	cin >> s;
	int half;
	if (s.size() % 2 == 0) {
		half = s.size() / 2;
	}
	else {
		half = s.size() / 2 + 1;
	}

	int res = 0;

	fi(s.size()/2) {
		if (s[i] == s[s.size()-1-i]) {
			continue;
		}
		else {
			res++;
		}
	}
	ce(res)
}



int main()
{

	solve();

	int a;//止める用
	cin >> a;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
#define M 1000000007
int n,m,w[205];
ll dp[2][205][10005],ans;
int main(void){
    cin>>n>>m;
    for(int i=0;i<n;i++)cin>>w[i];
    sort(w,w+n);
    w[n]=m;
    dp[1][n][0]=1;
    for(int i=0;i<n;i++){
        int u=(i+1)%2;
        for(int j=0;j<=m;j++){
            for(int k=0;k<n;k++){
                if(j>=w[i])dp[i%2][k][j]=(dp[u][k][j-w[i]]+dp[u][k][j])%M;
                else dp[i%2][k][j]=dp[u][k][j];
                if(k==i)dp[i%2][k][j]=(dp[i%2][k][j]+dp[u][n][j])%M;
            }
            if(j>=w[i])dp[i%2][n][j]=dp[u][n][j-w[i]];
            else dp[i%2][n][j]=0;
        }
    }
    for(int j=0;j<=n;j++)for(int k=m-w[j]+1;k<=m;k++)ans=(ans+dp[(n-1)%2][j][k])%M;
    cout<<ans<<endl;
}


Measured memory_bytes: 34432
a,b,c,x,y = list(map(int, input().split()))

price1 = a*x + b*y


if(x>y):
    price2 = y*2*c + (x-y)*a
    price3 = x*2*c
else:
    price2 = x*2*c + (y-x)*b
    price3 = y*2*c

print(min(price1,price2,price3))

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int n, m, a[200], b[200], d[200]; vector<int>v1, v2, w1, w2, dp1, dp2;
vector<int>knapsack(int W, vector<int>v, vector<int>w) {
	vector<int>dp(W + 1000, 999999999);
	for (int i = 0; i < dp.size(); i++) { dp[i] = 999999999; }
	dp[0] = 0;
	for (int i = 0; i < (int)min(v.size(), w.size()); i++) {
		for (int j = v[i]; j <= W; j++)dp[j] = min(dp[j], dp[j - v[i]] + w[i]);
	}
	for (int i = W - 1; i >= 0; i--) {
		dp[i] = min(dp[i], dp[i + 1]);
	}
	return dp;
}
int main() {
	while (true) {
		v1.clear(); v2.clear(); w1.clear(); w2.clear(); dp1.clear(); dp2.clear();
		cin >> n; if (n == 0)break;
		for (int i = 0; i < n; i++)cin >> a[i]; cin >> m;
		for (int i = 0; i < m; i++) {
			string S, T; cin >> S >> b[i] >> T >> d[i]; if (d[i] >= 200000)d[i] = 200000;
			if (d[i] == 0)continue;
			if (T == "Single") { v1.push_back(d[i]); w1.push_back(b[i]); }
			if (T == "All") { v2.push_back(d[i]); w2.push_back(b[i]); }
		}
		dp1 = knapsack(400000, v1, w1);
		dp2 = knapsack(400000, v2, w2);
		if (v1.size() == 0) {
			int maxn = 0; for (int i = 0; i < n; i++)maxn = max(maxn, a[i]);
			cout << dp2[maxn] << endl;
		}
		else {
			int maxn = 999999999;
			for (int i = 0; i <= 300000; i++) {
				int sum = dp2[i];
				for (int j = 0; j < n; j++) {
					if (a[j] > i && dp1[a[j] - i] <= 1e8) {
						sum += dp1[a[j] - i];
					}
				}
				maxn = min(maxn, sum);
			}
			cout << maxn << endl;
		}
	}
	return 0;
}

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


def main():
    s = input().strip()
    q = int(input())
    queries = [input().split() for _ in range(q)]
    pre = []
    post = []
    flg = True
    for query in queries:
        if query[0] == "1":
            flg = not flg
            continue
        if query[1] == "1":
            if flg:
                pre.append(query[2])
            else:
                post.append(query[2])
        else:
            if flg:
                post.append(query[2])
            else:
                pre.append(query[2])
    pre.reverse()
    pre.append(s)
    pre.extend(post)
    s = "".join(pre)
    if not flg:
        s = s[::-1]
    print(s)


if __name__ == "__main__":
    main()


Measured memory_bytes: 102576
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp34 {
    class Program {
        static void Main(string[] args) {
            var s = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            int A = s[0];
            int B = s[1];

            int sum = A + B;
            int sub = A - B;
            int pro = A * B;

            Console.WriteLine(Math.Max(sum, Math.Max(sub, pro)));

        }

    }
}


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

int c[5];
int main()
{
	int i, t1, t2;
	for (i = 0; i < 3; i++) {
		scanf("%d %d", &t1, &t2);
		c[t1]++, c[t2]++;
	}
	for (i = 1; i <= 4; i++) if (c[i] == 3 || c[i] == 0) {cout << "NO"; return 0;}
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, a, b) for (int i = (a); i < ((int)b); ++i)
#define rrep(i, a, b) for (int i = (int)(b) - 1; i >= ((int)a); --i)
#define sz(c) ((int)c.size())
#define all(c) c.begin(),c.end()

using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;

void dump_impl(string str) {}
template <class H, class... T>
void dump_impl(string s, const H &head, const T&... tail) {
    int par = 0;
    rep(i, 0, sz(s)) {
        char ch = s[i];
        if (ch == ',' && par == 0) {
            cerr << " = " << head << ", ";
            dump_impl(s.substr(i + 1), tail...);
            return;
        } else {
            cerr << ch;
            if (ch == '(') par++;
            if (ch == ')') par--;
        }
    }
}
#define dump(...) do { cerr << "\x1b[33;1m"; dump_impl(#__VA_ARGS__ ",", __VA_ARGS__); cerr << "\x1b[0m" << endl; } while (0)

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

signed main() {
    vector<bool> mon_sat(300005);
    rep(i, 0, 300005) {
        if (i % 7 == 1 || i % 7 == 6) {
            mon_sat[i] = true;
        } 
    }
    vector<bool> mon_sat_prime(300005, true);
    mon_sat_prime[0] = mon_sat_prime[1] = false;
    rep(i, 2, 300005) {
        if (mon_sat_prime[i]) {
            if (!mon_sat[i]) {
                mon_sat_prime[i] = false;
                continue;
            }

            rep(k, 2, 300005) {
                if (k * i > 300000) break;
                mon_sat_prime[i * k] = false;
            }
        }
    }

    while (1) {
        int N;
        cin >> N;
        if (N == 1) break;

        vi ans;
        rep(i, 1, 600) {
            if (N % i != 0) continue;
            if (mon_sat_prime[i]) {
                ans.push_back(i);
            }
            if (mon_sat_prime[N / i]) {
                ans.push_back(N / i);
            }
        }
        sort(all(ans));
        ans.erase(unique(all(ans)), ans.end());

        cout << N << ": ";
        rep(i, 0, sz(ans)) {
            cout << ans[i];
            if (i != sz(ans) - 1) {
                cout << " ";
            }
        }
        cout << endl;
    }
}



Measured memory_bytes: 3164
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

typedef long long ll;

const int INF = 2e9 + 5;
const int alength=100100;

int main() {
	int k;
	cin>>k;
	int a,b;
	a=k/2+(k%2==1);
	b=k/2;
	cout<<a*b;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

ll ck(vector<ll> a,ll x,ll y) {
  ll n=a.size();
  ll dp[n];
  fill(dp,dp+n,MAX);
  rep(i,n) *lower_bound(dp,dp+n,a[i])=a[i];
  ll xx=lower_bound(dp,dp+n,MAX)-dp;
  rep(i,n) a[i]*=-1;
  fill(dp,dp+n,MAX);
  rep(i,n) *lower_bound(dp,dp+n,a[i])=a[i];
  ll yy=lower_bound(dp,dp+n,MAX)-dp;
  rep(i,n) a[i]*=-1;
  if(x==xx&&y==yy) return 1;
  return 0;
}

void Main() {
  
  ll n,x,y;
  cin >> n >> x >> y;
  if(x>=y) {
    vector<vector<ll> > v;
    vector<ll> a;
    rep(i,n) {
      a.pb(i+1);
      if(a.size()==x||i==n-1) {
        v.pb(a);
        a.clear();
      }
    }
    reverse(all(v));
    ll z=y-v.size();
    rep(i,v.size()-1) {
      if(!z) break;
      if(v[i].size()==1) continue;
      ll c=min(z+1,(ll)v[i].size());
      reverse(v[i].end()-c,v[i].end());
      z-=c-1;
    }
    vector<ll> b;
    rep(i,v.size()) {
      rep(j,v[i].size()) b.pb(v[i][j]);
    }
    if(!ck(b,x,y)) pr(-1);
    else PR(b,n);
  } else {
    vector<vector<ll> > v;
    vector<ll> a;
    rrep(i,n) {
      a.pb(i+1);
      if(a.size()==y||!i) {
        v.pb(a);
        a.clear();
      }
    }
    reverse(all(v));
    ll z=x-v.size();
    rep(i,v.size()-1) {
      if(!z) break;
      if(v[i].size()==1) continue;
      ll c=min(z+1,(ll)v[i].size());
      reverse(v[i].end()-c,v[i].end());
      z-=c-1;
    }
    vector<ll> b;
    rep(i,v.size()) {
      rep(j,v[i].size()) b.pb(v[i][j]);
    }
    if(!ck(b,x,y)) pr(-1);
    else PR(b,n);
  }
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 15684
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <set>
using namespace std;

int m[5][4][11];

int main(){
    int n;cin>>n;
    for(int i=0;i<n;i++){
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        m[a][b][c]+=d;
    }
    for(int i=1;i<=4;i++){
        for(int j=1;j<=3;j++){
            for(int k=1;k<=10;k++){
                cout<<" "<<m[i][j][k];
            }
            cout<<endl;
        }
        if(i<=3)cout<<"####################"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3092
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <cmath>
#include <map>
using namespace std;
#define MOD 1000000007
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

i64 N, X;

i64 solve(i64 A, i64 B)
{
	if (A == 0 || B == 0) return 0;
	if (A == B) return 2 * A;
	if (A < B) {
		return solve(A, B % A) + 2 * A * (B / A);
	} else {
		i64 rem = A % B;
		return A + 2 * B * (A / B) + rem + solve(rem, B - rem) - (rem == 0 ? B : 0);
	}
}

int main()
{
	scanf("%lld%lld", &N, &X);
	printf("%lld\n", X + solve(N - X, X));
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

string solve(int a, int b, int c, int d){
	string ans;
	if(a==b){
		for(int i=c; i<=d; i++){
			if(i&1) ans+='A';
			else ans+='B';
		}
		return ans;
	}
	int t;
	if(a>b) t=(a+b)/(b+1);
	else t=(a+b)/(a+1);
	int x1=0, x2=a;
	while(x1!=x2){
		int x=(x1+x2+1)/2;
		int x3;
		if(x%t==0) x3=x/t*(t+1)-1;
		else x3=x/t*(t+1)+(x%t);
		int b0=b-x3/(t+1), a0=a-(x3-x3/(t+1));
		if(a0<0 || b0<0 || (ll)b0>(ll)t*(ll)(a0+1)) x2=x-1;
		else x1=x;
	}
	if(x1%t==0) x1=x1/t*(t+1)-1;
	else x1=x1/t*(t+1)+(x1%t);
	int b0=b-x1/(t+1), a0=a-(x1-x1/(t+1));
	for(int i=c; i<=d; i++){
		if(i<=x1){
			if(i%(t+1)==0) ans+='B';
			else ans+='A';
		}else if(i<=x1+(b0-a0*t)){
			ans+='B';
		}else{
			if((i-(x1+(b0-a0*t))-1)%(t+1)==0) ans+='A';
			else ans+='B';
		}
	}
	return ans;
}
int main()
{
	int q; cin>>q;
	for(int i=0; i<q; i++){
		int a, b, c, d;
		cin>>a>>b>>c>>d;
		cout<<solve(a, b, c, d)<<endl;
	}
	return 0;
}

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

#define ll long long
#define sc(n) int n; scanf("%d",&n);
#define mod 10000007
#define N 100001
#define MX 1000000001
#define log(n) (int)log2(n)
#define logg(a)(b) log(b)/log(a)
#define pb(x) push_back(x);
#define T int t, q=0; scanf("%d", &t); while(q++<t)
#define pi acos(-1)
#define flag bool fl=true;
#define fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0);

int main()
{

        ll h1, m1, h2, m2, k,tot=0;
        cin>>h1>>m1>>h2>>m2>>k;
        h1=h1*60;
        h2=h2*60;

        tot=abs(-h1+h2-m1+m2);
        cout<<tot-k<<endl;


}



Measured memory_bytes: 3560
N,K = list(map(int,input().split()))

ans = 0
for i in range(K,N+2):
  min_j = (i-1)*i//2
  max_j = min_j + (N+1-i)*i
  ans += max_j - min_j +1
  ans = ans % (10**9+7)
print(ans)

Measured memory_bytes: 9148
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

int g=1,n,m,k,p;
vector<int> members(1,0);

void dfs(int x,vector<vector<int>> &friends,vector<vector<int>> &block,vector<int> &group){
    int cnt=1;
    stack<int> s;
    group[x]=g;
    s.push(x);
    while(!s.empty()){
        p=s.top();s.pop();
        for(int t:friends[p]){
            if(group[t]!=0)continue;
            group[t]=g;
            s.push(t);
            cnt++;
        }
    }
    members.pb(cnt);
    g++;
}

//AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC
int main(){
    int x,y;
    cin>>n>>m>>k;
    vector<vector<int>> friends(n,vector<int>(0));
    vector<vector<int>> block(n,vector<int>(0));
    vector<int> visited(n,0);
    vector<int> group(n,0);
    for(int i=0;i<m;i++){
        cin>>x>>y;
        friends[x-1].pb(y-1);
        friends[y-1].pb(x-1);
    }
    for(int i=0;i<k;i++){
        cin>>x>>y;
        block[x-1].pb(y-1);
        block[y-1].pb(x-1);
    }
    for(int i=0;i<n;i++){
        if(group[i]==0)dfs(i,friends,block,group);
        int tmp=members[group[i]]-friends[i].size()-1;
        for(int x:block[i]){
            if(group[x]==group[i])tmp--;
        }
        if(i==n-1)cout<<tmp<<endl;
        else cout<<tmp<<" ";
    }
    
}


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

void sortDecrease(vector<int> &array);

int main() {
  string s;
  cin >> s;
  
  int count0 = count(s.begin(), s.end(), '0');
  int count1 = s.size() - count0;
  cout << min(count0, count1) *2 << endl;
	

  return 0;
}

Measured memory_bytes: 512
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1ll << 60;
const double PI = 2 * asin(1);

int N, Start[105], Goal[105];
vector <int> Graph[105];

int Time = 0;
int DFS(int node){
  for (int i = 0; i < Graph[node].size(); i++){
    int next = Graph[node][i];
    if (Start[next] == 0){
      Time++;
      Start[next] = Time;
      DFS(next);
    }
  }
  Time++;
  Goal[node] = Time;
  return 0;
}

int main(){
  cin >> N;
  for (int i = 0; i < N; i++){
    int M, K; cin >> M >> K;
    for (int j = 0; j < K; j++){
      int Node; cin >> Node;
      Graph[M].push_back(Node);
    }
  }

  for (int i = 1; i <= N; i++){
    if (Graph[i].size() > 0) sort(Graph[i].begin(), Graph[i].end());
  }
  
  for (int i = 1; i <= N; i++){
    if (Start[i] == 0){
      Time++; Start[i] = Time; DFS(i);
    }
  }
  

  for (int i = 1; i <= N; i++){
    printf("%d %d %d\n", i, Start[i], Goal[i]);
  }
  
  return 0;
}



Measured memory_bytes: 3272
#ALDS1_1_D
n = int(input())
r_was = int(input())
lowest = r_was
r_is = int(input())
ans = r_is - lowest
r_was = r_is
for ni in range(n-2):
  r_is = int(input())
  if r_was < lowest:
    lowest = r_was
  if r_is - lowest > ans:
    ans = r_is - lowest
  r_was = r_is
print(ans)


Measured memory_bytes: 5608
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
#define FOR(i, n) for (int i = 0; i < (int)(n); i++)
#define MAX_N 15
#define MAX_M 15
using ll = long long;

int main() {
  ll N, M, X;
  ll ans = (1L << 60);
  vector<int> C(MAX_N);
  vector<vector<int>> A(MAX_N, vector<int>(MAX_M));
  // 理解度
  vector<int> U(MAX_M);

  bool flag = false;
  cin >> N >> M >> X;

  FOR(i, N) {
    cin >> C[i];
    FOR(j, M) { cin >> A[i][j]; }
  }

  FOR(bits, 1 << N) {
    ll sum = 0;

    FOR(i, M) { U[i] = 0; }

    FOR(i, N) {
      if (bits & (1 << i)) {
        FOR(j, M) U[j] += A[i][j];
        sum += C[i];
      }
    }

    ll cnt = 0;
    FOR(i, M) {
      if (U[i] >= X) cnt++;
    }

    if (cnt == M) {
      flag = true;
      ans = min(ans, sum);
    }
  }

  if (flag)
    cout << ans << endl;
  else
    cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using ld = long double;
const ll ATCODER_AMARI = 1000000007; //10^9 + 7
const ll INF = 10000000000000;


int main() {
  ll n; cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];

  vector<ll> check(n,0);
  bool even_or_not = false;
  if(n%2 == 0) even_or_not = true;
  rep(i,n) {
    ll tmp = a[i];
    if(even_or_not && tmp % 2 == 0) {
      cout << 0 << endl;
      return 0;
    }
    else if(!even_or_not && tmp % 2 == 1) {
      cout << 0 << endl;
      return 0;
    }

    check[tmp]++;
    if(check[tmp] > 2) {
      cout << 0 << endl;
      return 0;
    }
    if(check[0] > 1) {
      cout << 0 << endl;
      return 0;
    }
  }

  ll ans = 1;
  ll cycle = n/2;
  rep(i,cycle){
    ans = (ans * 2) % ATCODER_AMARI;
  }

  cout << ans << endl;
  
}


Measured memory_bytes: 4764
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_135
{
    class D
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            string s = Read();
            int[] mods = new int[s.Length];
            mods[0] = 1;
            for(int i = 1; i < s.Length; i++)
            {
                mods[i] = (mods[i - 1] * 10) % 13;
            }
            Array.Reverse(mods);
            long mask = 1000000000 + 7;
            long defaultMod = 0;
            for(int i = 0; i < s.Length; i++)
            {
                if (s[i] == '?') continue;

                defaultMod += mods[i] * (s[i] - '0');
                defaultMod %= 13;
            }
            long[] cnts = new long[13];
            cnts[defaultMod] = 1;
            for(int i = 0; i < s.Length; i++)
            {
                if (s[i] != '?') continue;

                long[] next = new long[13];
                for(int j = 0; j < 10; j++)
                {
                    int delta = mods[i] * j;
                    for(int k = 0; k < 13; k++)
                    {
                        next[(k + delta) % 13] += cnts[k];
                        next[(k + delta) % 13] %= mask;
                    }
                }
                cnts = next;
            }

            WriteLine(cnts[5]);
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 15836
#include <stdio.h>
int main(void){
    int n,m,i;
    scanf("%d",&n);
    int a[n];
    for(i=0;i<n;i++){
        a[i]=0;
    }
    for(i=1;i<n;i++){
        scanf("%d",&m);
        a[m-1]=a[m-1]+1;
    }
    for(i=0;i<n;i++){
        printf("%d\n",a[i]);
    }
    return 0;
}
    

Measured memory_bytes: 2476
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,q,x,y;
    cin>>n;
    int a[n+1];
    int b[100001]={0};
    long long int sum=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        b[a[i]]++;
        sum+=a[i];
    }
    cin>>q;
    for(int i=1;i<=q;i++)
    {
        cin>>x>>y;
        sum+=((b[x]*y)-(b[x]*x));
        b[y]+=b[x];
        b[x]=0;
        cout<<sum<<endl;
    }
    return 0;
}

Measured memory_bytes: 4380
//use itertools::Itertools;
use std::cmp;
use std::collections::BTreeMap;
use std::collections::BTreeSet;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use std::io::Read;
use std::usize::MAX;

macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, [ $t:tt ]) => {{let len = read_value!($next, usize);(0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()}};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

fn solve() {
    input! {
        a: char
    }

    let little = match a {
        'a' => true,
        'b' => true,
        'c' => true,
        'd' => true,
        'e' => true,
        'f' => true,
        'g' => true,
        'h' => true,
        'i' => true,
        'j' => true,
        'k' => true,
        'l' => true,
        'm' => true,
        'm' => true,
        'o' => true,
        'p' => true,
        'q' => true,
        'r' => true,
        's' => true,
        't' => true,
        'u' => true,
        'v' => true,
        'w' => true,
        'x' => true,
        'y' => true,
        'z' => true,
        _ => false,
    };

    println!("{}", if little { "a" } else { "A" });
}

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();

    /*
    // 入力を一括で読み込む場合
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut input = buf.split_whitespace();

    // inputに対しnext()で読み込んでいく
    let q: usize = input.next().unwrap().parse().unwrap();
    */
}

const LARGE_PRIME: u64 = 1_000_000_007;

// @〜でsnippet


Measured memory_bytes: 2236
#include<cstdio>
#include<algorithm>
using namespace std;
 
int n,m;
int a,b,x;
short dp[5000][5000];
 
int main(){
  scanf("%d%d",&n,&m);
  for(int i=0;i<n;i++)
    for(int j=0;j<=i;j++)dp[i][j] = -1;
 
  for(int i=0;i<m;i++){
    scanf("%d%d%d",&a,&b,&x);
    a--; b--;
    dp[a][b] = max(dp[a][b],(short)x);
  }
 
  for(int i=0;i<n;i++){
    for(int j=0;j<=i;j++){
      if(i){
    dp[i][j] = max(dp[i][j],(short)(dp[i-1][j]-1));
    if(j)dp[i][j] = max(dp[i][j],(short)(dp[i-1][j-1]-1));
      }
    }
  }
 
  int ans = 0;
  for(int i=0;i<n;i++)
    for(int j=0;j<=i;j++)
      if(0<=dp[i][j])ans++;
  printf("%d\n",ans);
}

Measured memory_bytes: 40000
N = int(input())
Cs = list(map(int, input().split()))
adj = [[] for _ in range(N)]
for _ in range(N - 1):
    a, b = map(int, input().split())
    adj[a - 1].append(b - 1)
    adj[b - 1].append(a - 1)

degs = [0] * N
clusters = [[] for _ in range(N)]


def go(curr, fro):
    col = Cs[curr] - 1
    deg = 1
    clust = {}
    for n in adj[curr]:
        if n == fro:
            continue
        ch_deg, ch_clust = yield n, curr
        clusters[col].append(ch_deg - ch_clust.get(col, 0))
        if len(ch_clust) > len(clust):
            clust, ch_clust = ch_clust, clust
        for k, v in ch_clust.items():
            clust[k] = clust.get(k, 0) + v
        deg += ch_deg
    clust[col] = deg
    return deg, clust


def tramp(gen_fn, *args):
    stack = [gen_fn(*args)]
    val = None
    while stack:
        gen = stack[-1]
        try:
            params = gen.send(val)
        except StopIteration as e:
            stack.pop()
            val = e.value
        else:
            stack.append(go(*params))
            val = None
    return val


_, root_clust = tramp(go, 0, -1)
for i in range(N):
    clusters[i].append(N - root_clust.get(i, 0))


for clust in clusters:
    tot = (N * N + N) // 2
    for cnt in clust:
        tot -= (cnt * cnt + cnt) // 2
    print(tot)


Measured memory_bytes: 236752
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long input_min = sc.nextLong();
		long max = sc.nextLong();
		sc.close();
		int binMax = 0;
		while (max > Math.pow(2, binMax)) {
			binMax++;
		}
		int[] array = new int[binMax + 1];
		long min_xor = 0;
		long min = input_min -1;
		if (min % 2 == 1) {
			long count = (min + 1) / 2;
			if (count % 2 == 1) {
				min_xor = 1;
			}
		} else {
			long count = min / 2;
			if (count % 2 == 1) {
				min_xor = 1;
			}
			long nowi = min;
			int bin = 0;
			while (min >= Math.pow(2, bin)) {
				bin++;
			}
			for (int j = 0; j < bin; j++) {
				if (nowi >= Math.pow(2, bin - j - 1)) {
					array[bin - j - 1]++;
					nowi -= Math.pow(2, bin - j - 1);
				}
			}
		}
		array[0] += min_xor;

		long max_xor = 0;
		if (max % 2 == 1) {
			long count = (max + 1) / 2;
			if (count % 2 == 1) {
				max_xor = 1;
			}
		} else {
			long count = max / 2;
			if (count % 2 == 1) {
				max_xor = 1;
			}
			long nowi = max;
			int bin = 0;
			while (max >= Math.pow(2, bin)) {
				bin++;
			}
			for (int j = 0; j < bin; j++) {
				if (nowi >= Math.pow(2, bin - j - 1)) {
					array[bin - j - 1]++;
					nowi -= Math.pow(2, bin - j - 1);
				}
			}
		}
		array[0] += max_xor;


		long ans = 0;
		for (int k = 0; k < binMax + 1; k++) {
			if (array[k] % 2 == 1) {
				ans += Math.pow(2, k);
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 22740
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#define rep(i, s, g) for (i = s; i <= g; i++)
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;

int main(void)
{
    string s, t, ans;
    static int dp[3010][3010];
    int i, j;

    cin >> s >> t;

    s.insert(s.begin(), 0);
    t.insert(t.begin(), 0);

    rep(i, 0, s.size() - 2)
    {
        rep(j, 0, t.size() - 2)
        {
            if (s[i + 1] == t[j + 1])
            {
                dp[i + 1][j + 1] = dp[i][j] + 1;
            }
            else
            {
                dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j]);
            }
        }
    }

    i = s.size() - 1;
    j = t.size() - 1;

    while (1)
    {
        if (dp[i - 1][j - 1] == dp[i][j] - 1 && dp[i - 1][j] == dp[i][j] - 1 && dp[i][j - 1] == dp[i][j] - 1)
        {
            ans.insert(ans.begin(), s[i]);
            i--;
            j--;
        }
        else if (dp[i - 1][j - 1] != dp[i][j] && dp[i][j - 1] == dp[i][j])
        {
            j--;
        }
        else
        {
            i--;
        }

        if (i == 0 || j == 0)
        {
            break;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 35584