akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define sz(x) (int)x.size()
#define int long long
typedef pair<int,int>pii;
typedef vector<int> vi;
typedef vector<vi> vii;
const int mxN=2e5+5,M=1e9+7;
const int LINF = 0x3f3f3f3f3f3f3f3f;
//did u check when n=1?
//is mxN correct?
map<string,int>mp;
int32_t main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        string s;cin>>s;
        mp[s]++;
    }
    int ma=0;
    for(auto it=mp.begin();it!=mp.end();it++){
        ma=max(ma,it->second);
    }
    for(auto it=mp.begin();it!=mp.end();it++){
        if(it->second==ma)cout<<it->first<<"\n";
    }
    
}

Measured memory_bytes: 19224
import java.util.Scanner;

/**
 * Created by wild on 16/08/13.
 */
public class Main{
    public static void main (String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int result = 0;
        for (int i = 0; i < n; i++){
            result += 1 + i;
        }
        System.out.println(result);
    }
}

Measured memory_bytes: 9680
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<string>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include<complex>
#include<unordered_map>
#define deg(x) cout<<#x<<"="<<x<<endl;
#define fd(x) for(int i=0;i<x;i++)
#define fdd(a,x) for(int i=a;i<x;i++)
#define fx(x,n) for(int i=n-1;i>=x;i--)
#define mst(x) memset(x,0,sizeof(x));
#define fi first
#define se second
#define TB ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define ok "ok"
#define HH puts("");
#define ls rt<<1
#define rs rt<<1|1
#define pb(a,b) a.push_back(b);
#define FIN  freopen("1.in","r",stdin);
#define FOUT freopen("1.out","w",stdout);
using namespace std;
typedef long long ll;typedef long long LL;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<string,int> pss;
typedef unsigned long long ull;
const ll mod=1e9+7;
const ll inf=1e9+7;
const long double eps=1e-8;
ll qpow(ll a,ll b,ll m){ ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
const double pi=acos(-1);

ll a[203040];

int main()
{
    TB
    int n;
    cin>>n;
    fd(n) cin>>a[i];
    sort(a,a+n);
    ll sum=a[n-1],flag=n-2,flog=1;
    for(int i=n-3;i>=0;i--){
        sum+=a[flag];
        //deg(sum)
        flog++;
        if(flog%2) flag--;
    }
    cout<<sum<<'\n';
    return 0;
}


Measured memory_bytes: 5216
#include<iostream>
#include<vector>
#include<climits>
#include<string>

const int HMAX = 10;
const int WMAX = 1000;


/*
横のラインの引き方 2^(H-1)通り. Hが小さいのでこれはbit全探索.
あと縦にどう引くかであるが, これは
- 最後に縦をおラインを引いた地点からKを超えないギリギリのところでラインを引く
とすれば最小になる. これで計算量はO(2^H * HW)
*/


int main(){
    int H, W, K;
    std::cin >> H >> W >> K;
    std::vector<std::string> Choco(H);
    for(int i = 0; i < H; i++){
        std::cin >> Choco[i];
    }

    int res = INT_MAX;
    for(int bit = 0; bit < (1 << (H - 1)); bit++){
        int N = 0; // 横線の数
        std::vector<int> ord(H, 0); // 同じブロックごとに数字付け
        for(int i = 0; i < H - 1; i++){
            // bitが立っている
            if(bit & (1 << i)){
                ord[i + 1] = ord[i] + 1;
                N++;
            }else{
                // 立っていない
                ord[i + 1] = ord[i];
            }
        }


        int add = 0;
        bool gok = true;
        std::vector<int> nums(N + 1, 0);
        for(int w = 0; w < W; w++){
            std::vector<int> one(N + 1, 0);
            bool ok = true;
            for(int h = 0; h < H; h++){
                one[ord[h]] += Choco[h][w] - '0';
                nums[ord[h]] += Choco[h][w] - '0';
                if(one[ord[h]] > K) gok = false;
                if(nums[ord[h]] > K) ok = false;
            }
            if(!ok){
                add++;
                nums = one;
            }
        }
        if(gok){
            res = std::min(res, N + add);
        }
    }

    std::cout << res << std::endl;

    return 0;
}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
	int n;
	while(cin >> n){
		cout << "3C" << ((n-1)%39+1<10?"0":"") << (n-1)%39+1 << endl;
	}
}

Measured memory_bytes: 0
#include<map>
#include<set>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<ctime>
#include<vector>
#include<bitset>
#include<string>
#include<cstdio>
#include<numeric>
#include<utility>
#include<sstream>
#include<cstdlib>
#include<iomanip>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<functional>
#include<unordered_map>
#define _USE_MATH_DEFINES
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
#define pb(n) push_back(n)
#define ue(N) N.erase(unique(N.begin(),N.end()),N.end());
#define nou(S) cout << S
#define hou(S) cout << setprecision(30) << S << endl
#define vec(K,L,N,S) vector<L> K(N,S)
#define dv(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define tv(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define maxx 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define endl "\n"
typedef long long int lli;
typedef unsigned long long int uli;
const uli mod = 1e9 + 7;
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
  
  int a,b;
  cin>>a>>b;
  for(int i=0;i<a+b+1;++i){
    char n;
    cin>>n;
    if(i==a&&n!='-'){
      cout<<"No"<<endl;
      return 0;
    }
    if(i!=a&&n=='-'){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
}

Measured memory_bytes: 3656
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

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

def solve(la):
    ans = 0
    s = la[0]
    for i in range(1, len(la)):
        a = la[i]
        ns = s+a
        # print(i, s, a, ns)
        if s*ns < 0:
            s = ns
            continue
        ans += abs(ns)+1
        if ns < 0:
            ns += abs(ns)+1
        else:
            ns -= abs(ns)+1
        s = ns
    return ans

def main():
    n = ri()
    la = rli()
    first = la[0]

    ans1 = 0
    if first <= 0:
        ans1 += abs(first)+1
        la[0] = 1
    ans1 += solve(la)

    ans2 = 0
    la[0] = first
    if first >= 0:
        ans2 += abs(first)+1
        la[0] = -1
    ans2 += solve(la)
    print(min(ans1, ans2))


if __name__ == '__main__':
    main()


Measured memory_bytes: 14468
import java.util.Scanner;

public class Main {

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

		int x = scan.nextInt();
		int y = scan.nextInt();

		long a = 0;	//答え．何通りか

		if(x > 2*y || y > 2*x) {
			a = 0;
		}else if ((x + y)%3 != 0) {
			a = 0;
		}else {
			int n = (x+y)/3;
			int dif = Math.abs(x-y);
			int r = (n - dif)/2;

			int m = (int) (Math.pow(10, 9) + 7);

			a = 1;
			for(int i = 0; i < r; i++) {
				a = a * (n - i)%m * powMod(i+1, m-2, m) % m;
			}
		}

		System.out.println(a);

	}


	/**
	 *
	 * @param a 底
	 * @param b 指数
	 * @param m 法
	 * @return
	 */
	public static long powMod(long a, long b, long m) {
		long pow = 1;

		while (b > 0) {
			if((b & 1) == 1) {
				pow *= a%m;
				pow %= m;
			}
			a *= a%m;
			a %= m;
			b >>= 1;
		}

		return pow;
	}

}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<string,ll>;
using vl = vector<ll>;
using Map = map<ll,vl>;
using vvl = vector<vector<ll>>;
ll INF=1LL<<60;
ll MOD=998244353;



int main(){
    ll N;
    cin >> N;
    string S;
    cin >> S;
    ll ans=0;
    for(ll i=1;i<N;i++){
        string s=S.substr(0,N-i);
        string t=S.substr(i);
        ll count=0;
        ll Max=0;
        for(ll j=0;j<N-i;j++){
            if(s[j]==t[j])count++;
            else count=0;
            Max=max(count,Max)
        ;}
        Max=min(Max,i);
        ans=max(ans,Max)
    ;}
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
if n%2==0:
  dp=[[0 for i in range(2)] for j in range(n)]
  dp[0][0]=a[0]
  dp[1][1]=a[1]
  for i in range(2,n):
    if i==2:
      dp[i][0]=dp[i-2][0]+a[i]
      dp[i][1]=dp[i-2][1]+a[i]
    else:
      dp[i][0]=dp[i-2][0]+a[i]
      dp[i][1]=max(dp[i-2][1],dp[i-3][0])+a[i]
  print(max(dp[n-1][1],dp[n-2][0]))

else:
  dp=[[0 for i in range(3)] for j in range(n)]
  dp[0][0]=a[0]
  dp[1][1]=a[1]
  dp[2][2]=a[2]
  for i in range(2,n):
    if i==2:
      dp[i][0]=dp[i-2][0]+a[i]
      dp[i][1]=dp[i-2][1]+a[i]
    else:
      dp[i][0]=dp[i-2][0]+a[i]
      dp[i][1]=max(dp[i-2][1],dp[i-3][0])+a[i]
      dp[i][2]=max(dp[i-2][2],dp[i-3][1],dp[i-4][0])+a[i]
  print(max(dp[n-1][2],dp[n-2][1],dp[n-3][0]))

Measured memory_bytes: 116948
import scala.io.StdIn.readLine
 
object Main extends App {
  def calc(op:String,x:Int,y:Int) = {
    op match {
      case "+" => x+y
      case "-" => x-y
      case "*" => x*y
    }
  }
 
  val l = readLine.split(" ")
 
  def revP(n:Int,stack:List[Int]):Int =  {
    if(n==l.length) stack(0)
    else {
      val s = l(n)
      val stack2 =
        if(s.forall(_.isDigit)) s.toInt::stack
        else {
          val x::y::tail = stack
          calc(s,y,x)::tail
        }
      revP(n+1,stack2)
    }
  }
 
  println(revP(0,Nil))
 
}

Measured memory_bytes: 43788
#include<iostream>
using namespace std;
int main(){
    int a,b;
    cin >> a >> b;
    
    if (a < b){
        cout << "a < b" << endl;
    } else if(a > b){
        cout << "a > b" << endl;
    }else{
        cout << "a == b" << endl;
    }
    
    
    return 0;
}


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

int W, H;
string m[50];
int t[50][50];
int v[10000];

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

int dfs(int xx, int yy, int n)
{
  int res = 1;
  t[yy][xx] = n;
  queue<int> q;
  q.push(xx);
  q.push(yy);

  while(q.size())
  {
    int x = q.front(); q.pop();
    int y = q.front(); q.pop();

    if(m[y][x] != '.')
    {
      if(v[n] == 0)
      {
        if(m[y][x] == 'W')
          v[n] = 1;
        else
          v[n] = 2;
      }
      if(v[n] == 1 && m[y][x] == 'B' || v[n] == 2 && m[y][x] == 'W')
        v[n] = 3;
      continue;
    }

    for(int i = 0; i < 4; i++)
    {
      int tx = x + dx[i], ty = y + dy[i];
      if(0 <= tx && tx < W && 0 <= ty && ty < H && t[ty][tx] <= 0)
      {
        q.push(tx);
        q.push(ty);
        if(!t[ty][tx])
        {
          res++;
          t[ty][tx] = n;
        }
      }
    }
  }
  return res;
}

int main()
{
  while(true)
  {
    cin >> W >> H;
    if(!W)
      break;
    fill((int*)t, (int*)t + 2500, 0);
    fill(v, v + 10000, 0);
    for(int i = 0; i < H; i++)
    {
      cin >> m[i];
      for(int j = 0; j < W; j++)
        if(m[i][j] != '.')
          t[i][j] = -1;
    }

    int a = 11, w = 0, b = 0;
    for(int y = 0; y < H; y++)
    {
      for(int x = 0; x < W; x++)
      {
        if(t[y][x] == 0)
        {
          int r = dfs(x, y, a);
          if(v[a] == 1)
            w += r;
          if(v[a] == 2)
            b += r;
          a++;
        }
      }
    }
    cout << b << " " << w << endl;
  }
}

Measured memory_bytes: 1280
#include<stdio.h>
#include<stdbool.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#define rep(i,n) for(int i=0; i <(n); i++)

int compint(const void *a,const void *b){
  return *(int *)a-*(int *)b;
}

void pop(char *str){
  const int len = strlen(str);
  if(len==0){
  }else{
    char c = str[len-1];
    str[len-1]='\0';
  }
}

int check(char *str){
  int len = strlen(str);
  rep(i,len/2){
    if(str[i]!=str[i+len/2]){
      return -1;
    }
  }
  return 1;
}

void doing(char *str){
  pop(str);
  int len = strlen(str);
  if(len%2==0){
    if(check(str)==1){
      printf("%d\n",len);
    }else{
      doing(str);
    }
  }else{
    doing(str);
  }
}

int main(){
  char s[201];
  scanf("%s",s);
  doing(s);
}

Measured memory_bytes: 1732
c1 = list(map(int, input().split()))
c2 = list(map(int, input().split()))
c3 = list(map(int, input().split()))
c = [c1, c2, c3]
Takahashi = True
for i in range(3):
    for j in range(3):
        for k in range(3):
            for l in range(3):
                if c[i][k] - c[j][k] != c[i][l] - c[j][l]:
                    Takahashi = False
                    break
for i in range(3):
    for j in range(3):
        for k in range(3):
            for l in range(3):
                if c[i][k] - c[i][l] != c[j][k] - c[j][l]:
                    Takahashi = False
                    break
if Takahashi == True:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define re register
#define SIZE 1005
#define MOD 1000000007
using namespace std;
int n,m;
char a[SIZE][SIZE];
int dp[SIZE][SIZE];
int main()
{
	cin>>n>>m;
	for(re int i=1;i<=n;++i)
		for(re int j=1;j<=m;++j)
			cin>>a[i][j];
	dp[1][1]=1;
	for(re int i=1;i<=n;++i)
		for(re int j=1;j<=m;++j)
			if(a[i][j]=='.' && !(i==1 && j==1))
				dp[i][j]=(dp[i-1][j]+dp[i][j-1])%MOD;
	cout<<dp[n][m]<<endl;
	return 0;
} 

Measured memory_bytes: 5120
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;

ll MOD = (ll)(1000 * 1000 * 1000 + 7);
const int MAXCNT = 50;
ll comb[100000+MAXCNT][MAXCNT];

inline ll c(int a, int b) {
  return comb[a-b][b];
}

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> num;
  int rem = M;
  for(int i = 2; i <= rem; i++) {
    if(rem % i == 0) {
      int cnt = 0;
      while(rem % i == 0) {
	rem /= i;
        cnt++;
      }
      num.push_back(cnt);
    }
  }


  REP(i,MAXCNT) comb[0][i] = 1LL;
  REP(i,N+MAXCNT) comb[i][0] = 1LL;
  for(int i = 1; i < N+MAXCNT; i++) {
    for(int j = 1; j < MAXCNT; j++) {
      comb[i][j] = comb[i-1][j];
      comb[i][j] += comb[i][j-1];
      comb[i][j] %= MOD;
    }
  }

  ll ans = 1LL;
  for(int i = 0; i < num.size(); i++) {
    int n = num[i];
    ans = (ans * c(n+N-1, n)) % MOD;
  }
  //  cout << "Answer=";                                     
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 39296
N,M,X=map(int,input().split())
A=list(map(int,input().split()))
x=0#0~X
y=0#X~N
for i in range(0,X):
    if i in A:
        x+=1
for i in range(X,N):
    if i in A:
        y+=1
print(min(x,y))

Measured memory_bytes: 3064
/*
For the brave souls who are here: You are the chosen ones, the valiant
knights of coding who toil away, without rest, fixing my most awful
code. To you, true saviors, kings of men, I say this:
never gonna give you up, never gonna let you down,
never gonna run around and desert you. Never gonna make you cry,
never gonna say goodbye. Never gonna tell a lie and hurt you.
*/

#include <algorithm>
#include <bitset>
#include <complex>
#include <cstring>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <unordered_map>
#include <vector>
//#include <boost/math/common_factor.hpp>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, N) FOR(i, 0, N)
#define RREP(i, N) RFOR(i, N, 0)
#define FILL(A,value) memset(A,value,sizeof(A))
#define endl '\n'

#define ALL(V) V.begin(), V.end()
#define SZ(V) (int)V.size()
#define pb push_back
#define mp make_pair
#define Pi 3.14159265358979
#define A first
#define B second

typedef long long ll;
typedef vector <int> vi;
typedef vector<ll> vl;
typedef pair <int, int> pi;
typedef pair <ll, int> pl;
typedef pair <ll, ll> pll;
typedef pair <double, double> pd;

//change these according to prob constraints
const int INF = 1000000000;
const int MAX = 100005;
const int MAX1 = 1005;
const int MAX2 = 105;
const int LEN = 105;
const int BASE = 1000000000;
const double EPS = 1e-7;
const int MOD = 1000000007;
//g++ -std=c++11 your_file.cpp -o your_program

int wt[105], val[105];
ll dp[MAX];

int main(void){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ifstream in("");
	ofstream out("");
	clock_t begin = clock();
	int n, w;
    cin >> n >> w;
    REP(i, n){
        cin >> wt[i] >> val[i];
    }
    REP(i, n) {
        RREP(j, w + 1) {
            if (j < wt[i]) break;
            dp[j] = max(dp[j], val[i] + dp[j - wt[i]]);
        }
    }
    cout << dp[w] << endl;
	clock_t end = clock();
    double esecs = double(end - begin) / CLOCKS_PER_SEC;
    //cout << esecs << " seconds" << endl;
	return 0;
}


Measured memory_bytes: 1024
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		String s = sc.next();
		
		// 計算
		String result = "";
		
		String first = s.substring(0, 2);
		String last = s.substring(2, 4);
		int f = Integer.parseInt(first);
		int l = Integer.parseInt(last);
		
		if(1 <= f && f <= 12){
		    if(1 <= l && l <= 12){
		        result = "AMBIGUOUS";
		    }else{
		        result = "MMYY";
		    }
		}else{
		    if(1 <= l && l <= 12){
		        result = "YYMM";
		    }else{
		        result = "NA";
		    }
		}
		
		// 出力
		System.out.println(result);
	}
}

Measured memory_bytes: 21844
#include <stdio.h>
int uni(int point[20],int rank[2]){
        int i,j,pvs;
        for(i=0; i<10; i++){
                for(j=0; j<9; j++){
                        if(point[j]<point[j+1]){
                                pvs = point[j];
                                point[j] = point[j+1];
                                point[j+1] = pvs;
                        }
                }
                for(j=10; j<19; j++){
                        if(point[j]<point[j+1]){
                                pvs = point[j];
                                point[j] = point[j+1];
                                point[j+1] = pvs;
                        }
                }
        }
for(i=0; i<3; i++){
                rank[0]+=point[i];
                rank[1]+=point[i+10];
        }
}

int main(void){
        int k;
        int point[20],rank[2] = {0,0};
        for(k=0; k<20; k++){
                scanf("%d",&point[k]);
        }
        uni(point,rank);
        printf("%d %d\n",rank[0],rank[1]);
        return 0;
}


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

int main(){
  vector<pair<int,int>> xy(4);
  cin>>xy.at(0).first>>xy.at(0).second>>xy.at(1).first>>xy.at(1).second;

  int x=xy.at(1).first-xy.at(0).first;
  int y=xy.at(1).second-xy.at(0).second;

  cout<<xy.at(1).first-y<<" ";
  cout<<xy.at(1).second+x<<" ";
  cout<<xy.at(0).first-y<<" ";
  cout<<xy.at(0).second+x<<endl;
}


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

vector<int> blue;
vector<int> red;
vector<int> redpair;
vector<int> v;
vector<vector<int> > c;
int m = 0;
int n = 0;

int gcd(int x,int y){
    if(x % y == 0){
        return y;
    }
    return gcd(y,x%y);
}

bool match(int x){
    if(x == -1){
        return 1;
    }
    for(int i = 0;i < n;i++){
        if(c[x][i] == 1 && v[i] == 0){
            v[i] = 1;
            if(match(redpair[i])){
                redpair[i] = x;
                return 1;
            }
        }
    }
    return 0;
}

int main(){
    while(cin >> m >> n){
        if(m == 0 && n == 0){
            break;
        }
        blue.clear();
        red.clear();
        redpair.clear();
        v.clear();
        c.clear();
        for(int i = 0;i < m;i++){
            int tmp;
            cin >> tmp;
            blue.push_back(tmp);
        }
        for(int i = 0;i < n;i++){
            int tmp;
            cin >> tmp;
            red.push_back(tmp);
            redpair.push_back(-1);
            v.push_back(0);
        }
        for(int i = 0;i < m;i++){
            c.push_back(vector<int>());
            for(int j = 0;j < n;j++){
                c[i].push_back(gcd(blue[i],red[j]) != 1);
            }
        }
        int ans = 0;
        for(int i = 0;i < m;i++){
            for(int j = 0;j < n;j++){
                v[j] = 0;
            }
            if(match(i)){
                ans++;
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 2156
N = int(input())
a = list(map(int,input().split()))
a.sort()
a.reverse()
Alice = []
Bob = []
if N % 2 == 0:
    for i in range(N//2):
        Alice.append(a[i*2])
        Bob.append(a[i*2+1])
    print(sum(Alice) - sum(Bob))
elif N % 2 == 1 and N != 1:
    for i in range((N-1)//2):
        Alice.append(a[i*2])
        Bob.append(a[i*2+1])
    Alice.append(a[-1])
    print(sum(Alice) - sum(Bob))
elif N == 1:
    print(a[0])

Measured memory_bytes: 3064
import java.util.*
import kotlin.math.*

private val readString: ()->String = {readLine()!!}
private val readInt: ()->Int = { readLine()!!.toInt() }
private val readListInt: ()->List<Int> = { readLine()!!.split(' ').map(String::toInt) }


fun main(args: Array<String>) {
    val (N, M) = readListInt()
    val H = readListInt()

    var good = BooleanArray(N){true}
    for(i in 0 until M) {
        var (A,B) = readListInt()
        A--; B--;

        if (H[A] > H[B]) {
            good[B] = false
        } else if (H[A] < H[B]) {
            good[A] = false
        } else {
            assert(H[A] == H[B])
            good[A] = false
            good[B] = false
        }
    }

    val ans = good.count({it})
    println(ans)
}


Measured memory_bytes: 65384
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;
long long MOD = 1000000007LL;

int main() {
	int m, d, m1, d1;
	cin >> m >> d;
	cin >> m1 >> d1;
	if (m != m1) {
		cout << 1 << endl;
	}
	else {
		cout << 0 << endl;
	}

	return 0;
}


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

int main(void) {
	int n = 1;
	cin >> n;
	vector<string> s(n);
	set<string> sset;
	for (int i = 0; i < n; i++) cin >> s[i];
	for (int i = 0; i < n; i++) {
		// しりとりになっているか
		if (i != n-1 && s[i][s[i].length()-1] != s[i + 1][0]) {
			cout << "No" << endl;
			return 0;
		}
		// 同じ言葉を使っていないか
		sset.insert(s[i]);
		if (sset.size() < i + 1) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {
	set<int> mochi;
  	int N;
  	cin >> N;
  	for (int i = 0; i < N; i++) {
    	int temp;
      	cin >> temp;
      	mochi.insert(temp);
    }
  	cout << mochi.size() << endl;
    return 0;
}

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

int main(){
    const int N = int(pow(10,5));
    int a,b = 0,n[N];
    string s;

    cin >> a >> s;

    for(int i = 0; i < a;++i){
        if(s[i] != s[i + 1])
            b++;
    }

    cout << b << endl;
}


Measured memory_bytes: 512
from sys import stdin
def stdinput():
    return stdin.readline().strip()

def main():
    n = int(stdinput())
    a = list(map(int, stdinput().split()))

    for i in range(0, n):
        v = a[i]
        j = i - 1
        while j >= 0 and a[j] > v:
            a[j+1] = a[j]
            j -= 1
        a[j + 1] = v
        print(' '.join(map(str, a)))

if __name__ == '__main__':
    main()


Measured memory_bytes: 5608
#include<stdio.h>
#include<stdlib.h>
int main(){
	int H,W,i,j,end=0;
	int h=0,w=0;
//	char **matrix;
	char matrix[102][102];
	while(1){
		scanf("%d %d%*c",&H,&W);
		if(H==0&&W==0)
			break;
//		matrix  = (char**)malloc(sizeof(char*)*H);
//		for(i=0;i<H;i++){
//			matrix[i] = (char*)malloc(sizeof(char)*W);
//		}
		for(i=0;i<102;i++){
			for(j=0;j<102;j++){
				matrix[i][j]='*';
			}
		}
		for(i=0;i<H;i++){
			scanf("%s%*c",matrix[i]);
		}
		while(end==0){
			switch(matrix[h][w]){
				case '>':matrix[h][w]='*';w++;break;
				case '<':matrix[h][w]='*';w--;break;
				case '^':matrix[h][w]='*';h--;break;
				case 'v':matrix[h][w]='*';h++;break;
				case '.':printf("%d %d\n",w,h);end=1;break;
				default:printf("LOOP\n");end=1;break;
			}
		}
		end=0;
	//	for(i=0;i<H;i++)free(matrix[i]);
	//	free(matrix);
		h=0;w=0;
	}
	return 0;
}

Measured memory_bytes: 0
/**
*    author:  Taichicchi
*    created: 07.09.2020 21:21:50
**/

#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

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

    ll s;

    s = 0;

    for(ll i=0;i<M;++i){
        ll a;
        cin >> a;
        s += a;
    }

    if(N < s){
        cout << -1 << endl;
    }else{
        ll ans;
        ans = N-s;
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 3596
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long int;

const LL MOD = 1000000007;

LL mpow(LL a, LL x) {
	if (x == 0)return 1;
	LL half = mpow(a, x / 2);
	half *= half;
	half %= MOD;
	if (x % 2) {
		half *= a;
		half %= MOD;
	}
	return half;
}


int N;
int par[222222];
vector<int>child[222222];
int vnum[222222];
int cnt[222222];
int dep[222222];

void dfs(int v, int cou) {
	dep[v] = cou;
	for (int ch : child[v]) {
		dfs(ch, cou + 1);
	}
}

struct node {
	LL nil, one;
	LL sum;
};

node operator+(const node&n1, const node&n2) {
	LL nil = (n1.nil * n2.nil) % MOD;
	LL one = (n1.nil * n2.one + n1.one * n2.nil) % MOD;
	return {
		nil,one,n1.sum + n2.sum
	};
}

void merge(vector<node> &prime, vector<node> &brnch) {
	assert(prime.size() >= brnch.size());
	int diff = prime.size() - brnch.size();
	for (int i = 0; i < brnch.size(); ++i) {
		node grow = prime[i + diff] + brnch[i];
		prime[i + diff] = grow;
	}
}

//yes,no
vector<node> dp(int v) {
	if (child[v].empty()) {
		return vector<node>(1, { 1,1,1 });
	}
	/*
	vector<node>res = dp(child[v][0]);

	for (int i = 1; i < child[v].size(); ++i) {
		vector<node>tmp = dp(child[v][i]);
		if (tmp.size() > res.size()) {
			merge(tmp, res);
			//res = move(tmp);
			swap(res, tmp);
		}
		else {
			merge(res, tmp);
		}
	}
	*/
	vector<pair<int, int>>srt;
	vector<vector<node>>tame;
	for (int ch : child[v]) {
		tame.emplace_back(dp(ch));
		srt.push_back({ tame.back().size(),tame.size() - 1 });
	}
	sort(srt.begin(), srt.end());
	//vector<node>&res = tame[srt[0].second];
	for (int i = 1; i < srt.size(); ++i) {
		//vector<node>&tmp = tame[srt[i].second];
		/*
		if (tmp.size() > res.size()) {
			merge(tmp, res);
			res = move(tmp);
			//swap(res, tmp);
		}
		else {
			merge(res, tmp);
		}
		*/
		merge(tame[srt[i].second], tame[srt[i - 1].second]);
	}
	vector<node>&res = tame[srt[srt.size() - 1].second];
	for (int i = res.size()-((srt.size()>=2)?
                             (tame[srt[srt.size() - 2].second].size()):0);
         i < res.size();++i) {
		auto& n = res[i];
		LL zero = mpow(2, n.sum) + MOD;
		zero = (zero - n.one) % MOD;
		n.nil = zero;
	}
	res.push_back({ 1,1,1 });
	return std::move(res);
}

int main(void)
{
	cin >> N;
	for (int i = 0; i < N; ++i) {
		cin >> par[1 + i];
		child[par[1 + i]].push_back(i + 1);
	}
	dfs(0, 0);
	vector<node> ans = dp(0);
	for (int i = 0; i <= N; ++i) {
		cnt[dep[i]]++;
	}
	LL answer = 0;
	for (int i = 0; i < ans.size(); ++i) {
		LL kis = N + 1 - cnt[ans.size() - 1 - i];
		kis = mpow(2, kis);
		kis *= ans[i].one;
		kis %= MOD;
		answer += kis;
		answer %= MOD;
	}
	cout << answer << endl;
	return 0;
}


Measured memory_bytes: 66928
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;

  int n; rd(n);
  auto a=new int[][](2, n);
  a[0]=readln.split.to!(int[]);
  a[1]=readln.split.to!(int[]);

  int mx=0;
  foreach(i; 0..n){
    int sub=0;
    for(auto j=0; j<=i; j++) sub+=a[0][j];
    for(auto j=i; j<n; j++) sub+=a[1][j];
    mx=max(mx, sub);
  }
  
  writeln(mx);
}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}
void wr(T...)(T x){
  import std.stdio;
  foreach(e; x) write(e, " ");
  writeln();
}

Measured memory_bytes: 256
from collections import defaultdict
import itertools
import copy

def readInt():
  return int(input())
def readInts():
  return list(map(int, input().split()))
def readChar():
  return input()
def readChars():
  return input().split()

h,w = readInts()
s = [list(input()) for i in range(h)]

for i in range(1,w-1):
  for j in range(1,h-1):
    if s[j][i]=="#":
      c = 0
      if s[j-1][i]=="#":
        c+=1
      if s[j+1][i]=="#":
        c+=1
      if s[j][i-1]=="#":
        c+=1
      if s[j][i+1]=="#":
        c+=1
      if c==0:
        print("No")
        exit()

print("Yes")

Measured memory_bytes: 9576
data = input().split()

n = int(data[0])
word1 = input()
word2 = input()
word3 = input()

mod = 0

for i in range(n):
    if(word1[i] == word2[i] and word2[i] == word3[i]):
        continue
    elif(word1[i] == word2[i] or word2[i] == word3[i] or word1[i] == word3[i]):
        mod+=1
    else:
        mod+=2


print(mod)




Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=200050;
//ここまでテンプレ
int main(){
	int A,B;
	cin>>A>>B;
	if(A>8 || B>8)
		cout<<":("<<endl;
	else
		cout<<"Yay!"<<endl;
	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (n, w) = readLine()!!.split(' ').map(String::toInt)
    val dp = Array(100001) { Long.MAX_VALUE / 2 }
    dp[0] = 0
    (1..n).forEach {
        val (tw, tv) = readLine()!!.split(' ').map(String::toLong)
        for (sv in 100000 downTo 0) {
            if (sv - tv >= 0) {
                dp[sv] = Math.min(dp[sv], dp[sv - tv.toInt()] + tw)
            }
        }
    }
    println(dp.indices.indexOfLast { dp[it] <= w })
}


Measured memory_bytes: 123304
// D - Moving Piece
#include <bits/stdc++.h>

using namespace std;

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false); cin.tie(0);
	int n, k;
	cin >> n >> k;
	vector<int> p(n), c(n), vi(n);
	for (int i = 0; i < n; i++) cin >> p[i];
	for (int i = 0; i < n; i++) cin >> c[i];

	long long ans = LLONG_MIN;
	for (int i = 0; i < n; i++) {
		vector<int> vi(n);
		vector<long long> a;
		long long t = LLONG_MIN;
		for (int j = 0, x = i; j < min(n, k) && !vi[x]; j++, x = p[x] - 1) {
			vi[x] = 1;
			a.push_back(c[p[x] - 1] + (a.empty() ? 0 : a.back()));
			t = max(t, a.back());
		}
		long long z = k / a.size();
		if (z > 0 && a.back() > 0) {
			t += (z - 1) * a.back();
			t = max(t, z * a.back());
			for (int i = 0; i < k % a.size(); i++)
				t = max(t, z * a.back() + a[i]);
		}
		ans = max(ans, t);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3848
s = input()

def isPalindrome(t):
    if t != t[::-1]:
        return False
    n = len(t)

    l = t[:(n-1)//2]
    r = t[(n+3)//2-1:]
    # print(l, r)
    if l != l[::-1] or r != r[::-1]:
        return False

    return True

if isPalindrome(s):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 38256
def G(x):
  ret = 1 if x%4 in (1, 2) else 0
  for p in range(1,64):
    r = x%(2**(p+1))
    if r >= (2**p) and r % 2 == 0:
      ret += 2**p
  return ret
A, B = map(int,input().split())
print(G(B)^G(A-1))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MAX = 1e6+7;
const int MOD = 1e9+7;
const int INF = 0x3f3f3f3f;

int n, a, b, sum, tem;
int getnum(int x)
{
    int res = 0;
    while(x)
    {
        res += x % 10;
        x /= 10;
    }
    return res;
}
int main()
{
    cin >> n >> a >> b;
    for(int i = 1; i <= n; ++i)
    {
        tem = getnum(i);
        if(tem >= a && tem <= b)
            sum += i;
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int size=1e5;
const int inf=1e9;
int K;
vector<pair<int,int>> g[2][size];
int d[2][size];
void dijkstra(int id,int a){// O(NlogN+M)
	priority_queue<pair<long,int>> pq;
	rep(i,0,K){ d[id][i] = inf; pq.push({-d[id][i],i}); }
	d[id][a] = 0; pq.push({0,a});
	int v; long temp;
	while(!pq.empty()){
		v = pq.top().second;
		pq.pop();
        int u;
		for(pair<int,long> p:g[id][v]){
            u = p.first;
			temp = d[id][v] + p.second;
			if(d[id][u] > temp){
				d[id][u] = temp;
				pq.push({-d[id][u],u});
			}
		}
	}return;
}
int main(){
	cin>>K;
	rep(i,0,K)rep(j,0,10){
		int t = (10*i + j) % K;
		g[0][i].push_back({t,j});
		g[1][t].push_back({i,j});
	}
	dijkstra(0,0);
	dijkstra(1,0);
	int ans = inf;
	rep(i,1,K) ans = min(ans , d[0][i] + d[1][i]);
	cout<<ans<<endl;
}

Measured memory_bytes: 53276
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
  long long int n;
  cin >> n;
  n=n%10;
  if(n==2 || n==4 || n==5 || n==7 || n==9)
  cout << "hon" << endl;
  else if(n==0 || n==1 || n==6 || n==8)
  cout << "pon" << endl;
  else
  cout << "bon" << endl;
  return 0;
} 
	


Measured memory_bytes: 3636
from collections import deque
n=int(input())
graph=[[] for i in range(n)]#0-indexed
edges=[tuple(map(int,input().split())) for i in range(n-1)]#1-indexed
edge_color={(edges[i][0]-1,edges[i][1]-1):0 for i in range(n-1)}#0-indexed
vertex=[0 for i in range(n)]
for i in edges:
  a,b=i[0],i[1]
  a-=1;b-=1
  graph[a].append(b)
  graph[b].append(a)
color=0;most_connected=0
for i in range(n):
  if len(graph[i])>color:
    color=len(graph[i])
    most_connected=i
visited=[False]*n
bfs=deque([most_connected])
if most_connected>graph[most_connected][0]:
  most_connected,graph[most_connected][0]=graph[most_connected][0],most_connected
edge_color[(most_connected,graph[most_connected][0])]=1
while bfs:
  v=bfs.popleft()
  visited[v]=True
  for i in graph[v]:
    if visited[i]:continue
    I,V=i,v
    if i<v:
      I,V=v,i
    
    edge_color[(V,I)]=vertex[v]%color+1
    vertex[V],vertex[I]=edge_color[(V,I)],edge_color[(V,I)] 
    bfs.append(i)
print(color)
for i in edges:
  print(edge_color[(i[0]-1,i[1]-1)])

Measured memory_bytes: 92316
N=int(input())
if N%2==0 and N/2<10:
    print('Yes')
elif N%3==0 and N/3<10:
    print('Yes')
elif N%4==0 and N/4<10:
    print('Yes')
elif N%5==0 and N/5<10:
    print('Yes')
elif N%6==0 and N/6<10:
    print('Yes')
elif N%7==0 and N/7<10:
    print('Yes')
elif N%8==0 and N/8<10:
    print('Yes')
elif N%9==0 and N/9<10:
    print('Yes')
elif N==1:
    print('Yes')
else:
    print('No')

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

using namespace std;

using LL = long long;

template<typename T>
ostream& operator << (ostream& out, const vector<T>& v) {
    out << "[";
    for(auto& x : v) {
        out << x << ", ";
    }
    return out << "]";
}

template<typename S, typename T>
ostream& operator << (ostream& out, const pair<S, T>& p) {
    return out << "{" << p.first << ", " << p.second << "}";
}

bool reachable[310][310][310];

int N;
vector<int> V;
int suff_ones[310];
int suff_zeroes[310];
int shortest_suff[310][310];

void explore(int n, int z, int o) {
    if(z < 0 or o < 0) {
        return;
    }
    if(reachable[n][z][o]) {
        return;
    }
    reachable[n][z][o] = 1;
    shortest_suff[z + suff_zeroes[n]][o + suff_ones[n]] = max(shortest_suff[z + suff_zeroes[n]][o + suff_ones[n]], n);
    if(z + o >= 2) {
        explore(n, z - 1, o); //delete from pool
        explore(n, z, o - 1); //delete from pool
    }
    if(n == N) {
        return;
    }
    if(V[n] == 0) {
        explore(n + 1, z + 1, o - 1); //delete from pool and add from vector
    } else {
        explore(n + 1, z - 1, o + 1); //delete from pool and add from vector
    }
    if(z + o + (N - n) >= 2) {
        explore(n + 1, z, o);
    }
    if(n + 2 <= N) {
        if(V[n] == 0 or V[n + 1] == 0) {
            explore(n + 2, z + 1, o); //delete and add from vector
        }
        if(V[n] == 1 or V[n + 1] == 1) {
            explore(n + 2, z, o + 1); //delete and add from vector
        }
    }
}

const LL MOD = 998244353;
LL dp[310][310][310];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    string S;
    cin >> S;
    for(char c : S) {
        if(c == '0') {
            V.push_back(0);
        } else {
            V.push_back(1);
        }
    }
    N = S.length();
    for(int n = N - 1; n >= 0; --n) {
        suff_ones[n] = suff_ones[n + 1] + V[n];
        suff_zeroes[n] = suff_zeroes[n + 1] + 1 - V[n];
    }
    memset(shortest_suff, -1, sizeof(shortest_suff));
    explore(0, 0, 0);
    
    for(int n = N; n >= 0; --n) {
        for(int z = 0; z <= N; ++z) {
            for(int o = 0; o <= N; ++o) {
                if(n == N) {
                    if(z == 0 or o == 0) {
                        dp[N][z][o] = 1;
                    } else {
                        dp[N][z][o] = (dp[N][z - 1][o] + dp[N][z][o - 1]) % MOD;
                    }
                    continue;
                }
                if(V[n] == 0) {
                    dp[n][z][o] = (((z > 0) ? (dp[n + 1][z - 1][o]) : (0)) + ((o > 0) ? (dp[n][z][o - 1]) : (0))) % MOD;
                } else {
                    dp[n][z][o] = (((z > 0) ? (dp[n][z - 1][o]) : (0)) + ((o > 0) ? (dp[n + 1][z][o - 1]) : (0))) % MOD;
                }
            }
        }
    }
    
    LL ans = 0;
    for(int z = 0; z <= N; ++z) {
        for(int o = 0; o <= N; ++o) {
            if(shortest_suff[z][o] >= 0) {
                ans = (ans + dp[shortest_suff[z][o]][z][o]) % MOD;
            }
        }
    }
    cout << ans << "\n";
    
    
    return 0;
} 


Measured memory_bytes: 232708
typedef long long ll;
typedef long double ld;
#include <bits/stdc++.h>
using namespace std;
// const ll MOD = 1e9+7;

int main() {
    ll q;
    std::cin >> q;
    for (int iii = 0; iii < q; iii++) {
        ll a,b;
        std::cin >> a>>b;
        
        ll r = 1e10;
        ll l = 0;
        
        while(r-l>1){
            ll mid = (r+l)/2;
            ll xm = 0;
            for (ll i = max(1ll,mid/2-10); i <= mid/2+10; i++) {
                ll k = i;
                if(i>=a)k++;
                ll aite = 1+mid-i;
                if(aite>=b)aite++;
                xm = max(xm,k*aite);
            }
            // std::cout << xm << std::endl;
            if(xm>=a*b){
                r = mid;
            }else{
                l = mid;
            }
        }
        std::cout << l << std::endl;
    }
}


Measured memory_bytes: 3608
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
int fact(int n){
  int m;
  if (n == 0)
      return 1;
  m = fact(n - 1);    
  return n * m;       
}
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  vint a(n+1);  
  vector<vector<long long > > dp(n+1,vector<long long>(21));
  REP(i,1,n+1){
      cin>>a[i];
  }
  dp[1][a[1]]=1;
  for(int i=1;i<n;i++){
      for(int j=0;j<=20;j++){
	  if(dp[i][j]>0){
	      if(j+a[i+1]<=20){            //０<=j+t[i],j-j[i]<=２０
		  dp[i+1][j+a[i+1]]+=dp[i][j];
	      }
	      if(j-a[i+1]>=0){
		  dp[i+1][j-a[i+1]]+=dp[i][j];
	      }
	  }
      }
      
  }                              
  cout<<dp[n-1][a[n  ]  ]<<'\n';

  return(0);
}



Measured memory_bytes: 3220
#include<stdio.h>
int main(){
	int a,b,c,d,n1,n2,k1,k2,p,q,x,y;
	scanf("%d%d%d%d%d%d%d%d",&n1,&n2,&k1,&k2,&a,&b,&c,&d);
	p=n1*a+n2*b;
	q=k1*a+k2*b;
	x=n1/10;
	y=n2/20;
	p=p+c*x+d*y;
	x=k1/10;
	y=k2/20;
	q=q+c*x+d*y;
	if(p>q)printf("hiroshi\n");
	else if(q>p)printf("kenjiro\n");
	else printf("even\n");
	return 0;
}


Measured memory_bytes: 2112
#include <iostream>
#define llint long long 
#define mod 1000000007

using namespace std;

int N;

int main(void)
{
	cin >> N;
	
	llint ans = 1;
	for(int i = 1; i <= N; i++){
		ans *= i;
		ans %= mod;
	}
	
	cout << ans << endl;
	return 0;
}

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

vector<pair<int, int>> count(const vector<int>& v, int start, int step) {
	map<int, int> ma;
	for (int i = start; i < (int)v.size(); i += step) {
		if (ma.count(v[i])) ma[v[i]]++;
		else ma[v[i]] = 1;
	}
	int n = (int)v.size() / 2;
	vector<pair<int, int>> ans; ans.push_back(make_pair(n, -1));
	for (auto u : ma) {
		ans.push_back(make_pair(n - u.second, u.first));
	}
	sort(ans.begin(), ans.end());
	return ans;
}

int main(int argc, char const *argv[])
{
	int n; cin >> n;
	vector<int> v(n); rep(i, n) cin >> v[i];
	auto eve = count(v, 0, 2);
	auto odd = count(v, 1, 2);
	if (eve[0].second != odd[0].second) {
		cout << eve[0].first + odd[0].first << endl;
	} else {
		cout << min(eve[0].first + odd[1].first, eve[1].first + odd[0].first) << endl;
	}
	return 0;
}


Measured memory_bytes: 4088
#include <bits/stdc++.h>
 
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
ll mod =  1000000007;
ll maxn = 1000000000;
 
//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------
 
int main(){
   ll n,x,ans=1;
   cin>>n>>x;
   vll l(n+1),d(n+2);
   d.at(1)=0;
   rep(i,n){
       cin>>l.at(i+1);
       d.at(i+2)=d.at(i+1)+l.at(i+1);
       if(d.at(i+2)<=x){
           //cout<<i<<" "<<d.at(i+2)<<endl;
           ans++;
       }
   }
   cout<<ans<<endl;
   
   
}
   



Measured memory_bytes: 256
import java.util.*;

public class Main implements Runnable {

    private static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        // Run with 32MB stack
        Thread thread = new Thread(null, new Main(), "", 32 * 1024 * 1024);
        thread.start();
    }

    @Override
    public void run() {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    static void solve(Scanner scanner) {
        int N = Integer.parseInt(scanner.next());
        int M = Integer.parseInt(scanner.next());
        int L = Integer.parseInt(scanner.next());

        long[][] dist = new long[N][N];
        for (int i = 0; i < N; i++) {
            Arrays.fill(dist[i], Long.MAX_VALUE);
            dist[i][i]  = 0;
        }

        for (int i = 0; i < M; i++) {
            int s = Integer.parseInt(scanner.next()) - 1;
            int t = Integer.parseInt(scanner.next()) - 1;
            int c = Integer.parseInt(scanner.next());
            if (c > L) continue;
            dist[s][t] = c;
            dist[t][s] = c;
        }

        for (int via = 0; via < N; via++) {
            for (int from = 0; from < N; from++) {
                for (int to = 0; to < N; to++) {
                    if (dist[from][via] == Long.MAX_VALUE || dist[via][to] == Long.MAX_VALUE)
                        continue;
                    if (dist[from][to] > dist[from][via] + dist[via][to]) {
                        dist[from][to] = dist[from][via] + dist[via][to];
                    }
                }
            }
        }

        long[][] dist2 = new long[N][N];
        for (int i = 0; i < N; i++) {
            Arrays.fill(dist2[i], Long.MAX_VALUE);
            dist2[i][i]  = 0;
        }

        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                if (dist[i][j] <= L) {
                    dist2[i][j] = 1;
                }
            }
        }

        for (int via = 0; via < N; via++) {
            for (int from = 0; from < N; from++) {
                for (int to = 0; to < N; to++) {
                    if (dist2[from][via] == Long.MAX_VALUE || dist2[via][to] == Long.MAX_VALUE)
                        continue;
                    if (dist2[from][to] > dist2[from][via] + dist2[via][to]) {
                        dist2[from][to] = dist2[from][via] + dist2[via][to];
                    }
                }
            }
        }

        int Q = Integer.parseInt(scanner.next());
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < Q; i++) {
            int s = Integer.parseInt(scanner.next()) - 1;
            int t = Integer.parseInt(scanner.next()) - 1;
            sb.append(dist2[s][t] == Long.MAX_VALUE ? - 1 : dist2[s][t] - 1);
            sb.append('\n');
        }

        System.out.println(sb.toString());
    }
}


Measured memory_bytes: 62084