akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
#CODEFESTIVAL 2016 Final B

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
ans = []
tmp = 0
for i in range(1,n+1):
    if tmp + i <= n:
        ans.append(i)
        tmp += i
    else:
        tmp += i
        ans.append(i)
        ans.remove(tmp - n)
        break
for i in ans:
    print(i)


Measured memory_bytes: 42096
#include<stdio.h>
#define MAX 100
#define INFTY 2097152
#define WHITE 0
#define GRAY 1
#define BLACK 2
int prim();
int n,M[MAX][MAX];

int main(){
  int e;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      
      scanf("%d",&e);
      if(e==-1)
	M[i][j]=INFTY;
      else
	M[i][j]=e;}}
  printf("%d\n",prim());
  return 0;
}

int prim(){
  int u,minv;
  int d[MAX],p[MAX],color[MAX];
  int sum=0;
  for(int i=0;i<n;i++){
    d[i]=INFTY;
    p[i]=-1;
    color[i]=WHITE;
  }

  d[0]=0;

  while(1){
    minv=INFTY;
    u=-1;
    for(int i=0;i<n;i++){
      if(minv>d[i]&&color[i]!=BLACK){
	u=i;
	minv=d[i];
      }
    }
    if(u==-1)break;
    color[u]=BLACK;
    for(int v=0;v<n;v++){
      if(color[v]!=BLACK&&M[u][v]!=INFTY){
	if(d[v]>M[u][v]){
	  d[v]=M[u][v];
	  p[v]=u;
	  color[v]=GRAY;
	}
      }}}

  for(int i=0;i<n;i++){
    if(p[i]!=-1)
      sum+=M[i][p[i]];
  }
  return sum;
}



Measured memory_bytes: 2720
main = do
  [a,b,c,d] <- map read . words <$> getLine
  print (switchs a b c d)

switchs a b c d
  | b<=c = 0
  | a>=d = 0
  | a>=c && b<=d = b - a
  | a<=c && b>=d = d - c
  | b>c && a<c = b - c
  | otherwise = d - a


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

#define pout(n)  printf ("%d\n", n)

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
#define BIT(bit,a,n) for (int bit = a;bit < (1<<n);bit++) // {0, 1, ..., n-1} の部分集合の全探索 // n番目のフラグが立っている状態は (1<<n)

const int d4x[4] = {1, 0, -1, 0};
const int d4y[4] = {0, 1, 0, -1};
const int d8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const int d8y[8] = { 0,1,1,1,0,-1,-1,-1 };

#define MAX_N (int)2e5+20

typedef long long ll;
using namespace std;

int a,b,c;
int main() {
    scanf("%d%d%d",&a,&b,&c);
    if(a+b >= c) puts("Yes");
    else puts("No");
    return 0;
}

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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  string s,t;
  cin >> s >> t;
  vector<vl> pos(26,vl(0));
  REP(i,s.size()){
    pos[s[i]-'a'].push_back(i);
  }
  ll time = 0,count = -1;
  REP(i,t.size()){
    ll c = t[i]-'a';
    if(pos[c].size()==0){
      cout << -1 << endl;
      return 0;
    }
    auto itr = lower_bound(pos[c].begin(),pos[c].end(),count+1);
    if(itr==pos[c].end()){
      time++;
      count = pos[c][0];
    }else{
      count = *itr;
    }
    //DEBUG(time);
    //DEBUG(count);
  }


  ll ans = time*(ll)s.size()+count+1;
  cout << ans<< endl;
  return 0;
}


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

bool isPrime(int x);

int main()
{
  int x;
  cin >> x;
  
  while(1)
  {
    if (isPrime(x)) break;
    x ++;
  }
  
  cout << x << endl;
  return 0;
}

bool isPrime(int x)
{
  if (x == 2) return true;
  if (x % 2 == 0) return false;

  for (int i = 2; i < x / 2; i ++)
    if (x % i == 0) return false;

  return true;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

ll nCk(int n, int k) {
  ll x = 1, y = 1;
  for (int i = 0; i < k; i++) {
    x *= n - i;
    y *= i + 1;
  }
  return x / y;
}

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

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

  vector<ll> dp(n + 100, 0);
  map<ll, ll> m;
  for (int i = 0; i < n; i++) {
    m[a[i]]++;
  }

  for (auto p : m) {
    ll i = p.first;
    ll v = p.second;

    dp[i] = nCk(v, 2);
  }

  ll total = 0;
  for (int i = 0; i <= n; i++) {
    total += dp[i];
  }

  for (int i = 0; i < n; i++) {
    m[a[i]]--;
    cout << nCk(m[a[i]], 2) + total - dp[a[i]] << ln;
    m[a[i]]++;
  }

  return 0;
}

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

public class MainClass
{
	public const long Giri = 1000000007;

	public static void Main(string[] args)
	{
		var n = Console.ReadLine().ToInt();
		var a = Input().ToInt();
		var dic = new Dictionary<int, int>(n);
		
		for(int i = 0; i < n; i++)
		{
			if(!dic.ContainsKey(a[i]))
				dic.Add(a[i],0);
			dic[a[i]]++;
		}
		var sorted = dic.OrderBy(pair => pair.Key);
		
		int cnt = 0;
		foreach(var pair in sorted)
		{
			int r = pair.Value;
			if(dic.ContainsKey(pair.Key+1))
				r += dic[pair.Key+1];
			if(dic.ContainsKey(pair.Key-1))
				r += dic[pair.Key-1];
			cnt = Math.Max(cnt, r);
		}
		Console.WriteLine(cnt);
		
	}
	

	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(' '); }
	public static int Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
}



Measured memory_bytes: 21728
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		while (true) {

			int n = sc.nextInt();

			if (n == 0) {
				break;
			}

			int[] s = new int[n];
			for (int i = 0; i < n; i++) {
				s[i] = sc.nextInt();
			}

			Arrays.sort(s);

			int sum = 0;
			for (int i = 1; i < n - 1; i++) {
				sum += s[i];
			}

			int avg = sum / (n - 2);

			System.out.println(avg);

		}

		sc.close();

	}

}


Measured memory_bytes: 29312
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

int main(){
  int H,R;
  cin >> R >> H;
  if(H + R > 0){
    cout << 1 << endl;
  }
  else if(H + R == 0){
    cout << 0 << endl;
  }
  else{
    cout << -1 << endl;
  }
}



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

int main(void)
{
    string S;
    cin >> S;
    int f = (S[0] - '0')*10 + S[1] - '0';
    int b = (S[2] - '0')*10 + S[3] - '0';

    if(1<=f && f <= 12) {
        if(1<=b && b<=12) {
            puts("AMBIGUOUS");
        }
        else {
            puts("MMYY");
        }
    }
    else {
        if(1<=b && b<=12) {
            puts("YYMM");
        }
        else {
            puts("NA");
        }
    }
    
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
//#include<fstream>
#include<vector>
#include<stack>

using namespace std;

int main() {
	//ifstream fin("in.txt");

	int n = 0;

	while (cin >> n) {

		if (n == 0)break;

		//???????????\???
		vector<vector<int> > member;

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

			int num = 0;
			cin >> num;

			vector<int> piece;

			for (int i = 0; i < num; i++) {
				int tmp = 0;
				cin >> tmp;
				piece.push_back(tmp);
			}
			member.push_back(piece);
		}

		int k = 0; 
		cin >> k;

		vector<int> ans;

		for (int i = 0; i < k; i++) {
			int tmp;
			cin >> tmp;
			ans.push_back(tmp);
		}

		//???????????\????????????

		int ansNum = 0;
		bool same = false;

		for (int i = 0; i < member.size(); i++) {
			if (ans.size() <= member[i].size()) {
				for (int j = 0; j < ans.size(); j++) {
					same = false;
					for (int k = 0; k < member[i].size(); k++)
						if (ans[j] == member[i][k])same = true;
					if (same)continue;
					else break;
				}
				if (same) {
					if(ansNum == 0)ansNum = i + 1;
					else ansNum = -1;
				}
			}
		}
		if (ansNum == 0)ansNum = -1;

		cout << ansNum << endl;

	}


	return 0;
}

Measured memory_bytes: 1272
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int l;cin>>l;
	int keta = log2(l) + 1;
	vector<P> g;
	vector<int> dist;
	// cout << keta << endl;
	// cout << fixed << setprecision(10) << pow(2.0,20.0) << endl;
	for(int i = 1; i < keta; i++) {
		g.pb(mp(i,i + 1));
		g.pb(mp(i,i + 1));
		dist.pb(pow(2,i - 1));
		dist.pb(0);
	}
	for(int i = keta - 1; i > 0; i--) {
		if (l - pow(2,i - 1) >= pow(2,keta - 1)){
			g.pb(mp(i, keta));
			dist.pb(l - pow(2,i - 1));
			l -= pow(2,i -1);
			// cout << l << endl;
		}
	}
	cout << keta << " " << g.size() << endl;
	for(int i = 0; i < g.size(); i++) {
		cout << g[i].fs << " " << g[i].sc << " " << dist[i] << endl; 
	}
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  
  long long A_i;
  long long ans = 0;
  long long tallest = 0;
  
  for(int i=0; i < N; ++i){
 	cin >> A_i;
    tallest = max(tallest, A_i);
    ans += tallest - A_i;
  }
    
  cout << ans << endl;
}

Measured memory_bytes: 3596
/*==============================================*\
Codeforces ID:    mdshihab
                                                  |
Name:     Md. Shihabul Minhaz                     |
Study:      CSE, JKKNIU                           |
Address:  Trishal, Mymensingh, Bangladesh         |
                                                  |
 mail:   mdshihabul20171@gmail.com                |
 FB  :   fb.com/mdshihabul.minhaz.7               |
 github: Shihabulminhaz                           |
stopstalk :  mdshihab                             |
                                                  |
@uthor   Md. Shihabul Minhaz (shihab)             |
\*===============================================*/


#include<bits/stdc++.h>
using namespace std;
#define fi(a) scanf("%d",&a);
#define fli(a) scanf("%ld",&a);
#define fll(a) scanf("%lld",&a);
#define pi(a) printf("%d\n",a);
#define ppi(i,a) printf("Case %d: %d\n",i,a);
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
void FI()
{
#ifndef ONLINE_JUDGE
    freopen("C:\\Users\\SHIHAB\\Desktop\\input.in","r",stdin);
#endif // ONLINE_JUDGE
}

int arr[100005];
int main()
{
    fast
    //FI(); /// skip this line for compile
    int check;
    for(int i=1;i<=250;i++){
        for(int j=1;j<=250;j++){
            for(int k=1;k<=250;k++){
                check = (i+j+k)*(i+j+k)-i*j-j*k-k*i;
                if(check<10007){
                    arr[check]++;
                }
            }
        }
    }

    int n;
    cin >> n;
    for(int i=1;i<=n;i++){
        cout << arr[i] << endl;
    }
    return 0;
}



Measured memory_bytes: 3632
MOD = 10**9 + 7
n, m = [int(item) for item in input().split()]
a = set([-1]) 
dp = [0] * (n+10)
dp[0] = 1
for i in range(m):
    val = int(input())
    a.add(val)
for i in range(n):
    if i+1 in a and i+2 in a:
        print("0")
        exit()
    elif i+1 in a:
        dp[i+2] += dp[i]
    elif i+2 in a:
        dp[i+1] += dp[i]
    else:
        dp[i+1] += dp[i]
        dp[i+2] += dp[i]
    dp[i+1] %= MOD
    dp[i+2] %= MOD
print(dp[n] % MOD)

Measured memory_bytes: 12780
#include <bits/stdc++.h>
#define pr(s) std::cout << s << std::endl
#define prb(s) std::cout << s
using namespace std;


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


  string s;
  cin >> s;

  if (s == "Sunny") pr("Cloudy");
  else if (s == "Cloudy") pr("Rainy");
  else pr("Sunny");

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for (int i = (a); i <= (b); ++i)
#define drep(i,a,b) for (int i = (a); i >= (b); --i)
#define grep(i,u) for (int i = head[u],v = e[i].v; i; v = e[i = e[i].nxt].v)
#define il inline
#define LL long long
#define ULL unsigned LL
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define pll pair<LL,LL>
#define fi first
#define se second
using namespace std;
il LL read() {
	LL res = 0,f = 1; char ch = getchar(); while (!isdigit(ch)) {if (ch == '-') f = -f; ch = getchar();}
	while (isdigit(ch)) {res = res*10+ch-'0'; ch = getchar();} return res*f;
}
namespace qiqi {
	const int N = 2005,INF = 0x3f3f3f3f; int n,ecnt,head[N],f[N],siz[N],sum[N]; char s[N]; struct Edge {int v,nxt;} e[N<<1]; il void add(int u,int v) {e[++ecnt] = (Edge){v,head[u]}; head[u] = ecnt;}
	void dfs(int u,int fa) {int x,y; f[u] = 0; sum[u] = 0; siz[u] = s[u]; grep(i,u) if (v != fa) {dfs(v,u); if (sum[y = v] > sum[x = u]) swap(x,y); f[u] = f[x] >= (sum[x]-sum[y])/2 ? (sum[x]+sum[y])/2 : f[x]+sum[y]; siz[u] += siz[v]; sum[u] += sum[v];} if (fa) sum[u] += siz[u];}
	void main() {
		n = read(); scanf("%s",s+1); rep(i,1,n) s[i] -= '0'; rep(i,2,n) {int u = read(),v = read(); add(u,v); add(v,u);}
		int ans = INF; rep(i,1,n) {dfs(i,0); if (!(sum[i]&1) && f[i]*2 >= sum[i]) ans = min(ans,sum[i]/2);} printf("%d\n",ans != INF ? ans : -1); 
	}
}
int main() {
	qiqi::main(); return 0;
}

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

using namespace std;

int main(){
	int L, R;
	cin >> L >> R;
	
	int res = 2019;
	
	if (R - L >= 2019) {
		res = 0;
	} else {
		int N = R - L + 1;
		vector<int> cands;
		
		for (long long i=L; i<=R; ++i) {
			cands.push_back(i % 2019);
		}
		
		for (int i=0; i<N-1; ++i) {
			for (int j=i+1; j<N; ++j) {
				res = min(res, (cands.at(i) * cands.at(j)) % 2019);
			}
		}
	}
	
	cout << res << endl;
	return 0;
}

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

using namespace std;
using ll = long long;
using P = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  sort(a.begin(), a.end());

  vector<P> s(m);
  rep(i, m) {
    int b, c;
    cin >> b >> c;
    s[i] = {c, b};
  }
  sort(s.rbegin(), s.rend());

  int cur = 0;
  for (auto p : s) {
    int now = cur;
    for (int i = now; i < now + p.second; ++i) {
      if (a[i] < p.first) {
        a[i] = p.first;
        ++cur;
      } else
        break;
    }
  }

  ll sum = 0;
  rep(i, n) sum += a[i];
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 4528
#グローバル変数
count = int()
interval = int()
interval_list = list()

#アルゴリズム：挿入ソート
def insertionSort(list, number, interval):
    for i in range(interval, number):
        v = list[i]
        j = i - interval
        while j >= 0 and list[j] > v:
            list[j + interval] = list[j]
            j = j - interval
            global count
            count += 1
        list[j + interval] = v
    return list

#アルゴリズム：シェルソート
def shellSort(list, number):
    global count, interval, interval_list
    count = 0
    interval = 1
    interval_list.append(1)
    while number >= 3*interval_list[0]+1:
        interval_list.insert(0, 3*interval_list[0]+1)
        interval += 1
    for i in range(interval):
        list = insertionSort(list, number, interval_list[i])
    return list

#初期data
input_number = int(input())
input_list = list()
for i in range(input_number):
    input_list.append(int(input()))

#処理の実行
result_list = list()
result_list = shellSort(input_list, input_number)

#結果の表示
print(interval)
print(" ".join(map(str, interval_list)))
print(count)
[print(i) for i in result_list]



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

int main() {
  int H, W;
  cin >> H >> W;
  vector<bool> dr(H, true), dc(W, true);
  vector<string> L(H);
  for (int i = 0; i < H; i++) {
    cin >> L[i];
    for (int j = 0; j < W; j++) {
      if (L[i][j] == '#') {
        dr[i] = false;
        dc[j] = false;
      }
    }
  }
  for (int i = 0; i < H; i++) {
    if (dr[i]) continue;
    for (int j = 0; j < W; j++) {
      if (dc[j]) continue;
      cout << L[i][j];
    }
    cout << endl;
  }
}

Measured memory_bytes: 384
var IsTest = false;

var Main = function(Input){
  var Arr = Input.split('\n');
  var Max = 0;
  var Total = 0;

  for(var i=1;i<=Number(Arr[0]);++i){
    var CurrentNum = Number(Arr[i]);
    if(Max < CurrentNum){
      Max = CurrentNum;
    }
    Total += CurrentNum;
  }

  Total -= Max / 2;

  console.log(Total);
}

if(IsTest){
  Main(require("fs").readFileSync(__dirname+'/in.txt', "utf8"));  
} else {
  Main(require('fs').readFileSync('/dev/stdin', 'utf8'));
}


Measured memory_bytes: 9420
import java.util.Scanner;

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

        int p[] = new int[n];
        for (int i = 0; i < n; i++) {
            p[i] = in.nextInt();
        }

        long total = 0;
        for (int i = 1; i < n; i++) {
            total += Math.min(p[i] - p[i - 1], t);
        }
        total += t;

        System.out.println(total);
    }
}


Measured memory_bytes: 63972
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		char[] s = sc.next().toCharArray();
		char[] t = sc.next().toCharArray();

		int result = Integer.MAX_VALUE;

		for(int i = 0; i <= s.length - t.length; i++){
			int count = 0;
			for(int j = 0; j < t.length; j++){
				if(s[i + j] != t[j]){
					count++;
				}
			}

			result = Math.min(result, count);
		}

		System.out.println(result);
	}
}


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

int main() {
  ll n;
  cin >> n;
  vector<ll> v(n);
  rep(i, n)
    cin >> v.at(i);
  ll ans=0;
  
  rep(i,n){
    for(ll j=i+1; j<n; j++){
      for(ll k=j+1; k<n; k++){
        if(v.at(i)+v.at(j)>v.at(k) && v.at(i)+v.at(k)>v.at(j) && v.at(k)+v.at(j)>v.at(i) && v.at(i)!=v.at(j) && v.at(i)!=v.at(k) && v.at(k)!=v.at(j))
          ans++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3628
#include<iostream>

using namespace std;

int main(){
    string x, y;
    int w = 0;
    cin >> x;
    
    for(int i = 0; i < x.size(); i++){
        x[i] = tolower(x[i]);
    }
    
    while(cin >> y){
        if(y == "END_OF_TEXT") break;
        for(int i = 0; i < y.size(); i++){
            y[i] = tolower(y[i]);
        }
        
        if(x == y) w++;
    }
    cout << w << endl;
    return 0;
    
}


Measured memory_bytes: 3204
#include <bits/stdc++.h>
using namespace std;
int main() {
  int pool[2] = {0, 0};
  int n, a, b; cin >> n >> a >> b;
  string v; cin >> v; 
  for (int i = 0; i < n; ++i) {
    if (v[i] == 'c') {
      	puts("No");
      	continue;
    }
    if (v[i] == 'a' && pool[0] + pool[1] < a + b) puts("Yes"), ++pool[0];
    else if (v[i] == 'b' && pool[0] + pool[1] < a + b && pool[1] < b) puts("Yes"), ++pool[1];
    else puts("No");
  }
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vt = vector<T>;
template<class T> using vvt = vector<vt<T>>;
template<class T> using ttt = tuple<T,T>;
using tii = tuple<int,int>;
using tiii = tuple<int,int,int>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define DIV int(1e9+7)
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
//const double PI = M_PI;  
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}

/*Coding Space*/
int main(){
  int n; cin >> n;
  vi a(n),b(n);
  rep(i,n) cin >> a[i];
  rep(i,n) cin >> b[i];
  
  int ans = 0;
  rep(i,30){
    vi c(n);
    rep(j,n) c[j] = a[j]&((1<<(i+1))-1);
    sort(ALL(c));
    rep(x,n){
      int t = b[x] &((1<<(i+1))-1);
      int cnt = lower_bound(ALL(c),pow(2,i+1,LLINF) - t) - lower_bound(ALL(c),pow(2,i,LLINF) - t);
      cnt += lower_bound(ALL(c), pow(2,i+3,LLINF) - t) - lower_bound(ALL(c),3 * pow(2,i,LLINF) - t);
      if(cnt%2)  ans ^= (1 << i);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=998244353,MAX=1<<18,INF=1<<30;

int main(){
  int L,A,B,C,D;cin>>L>>A>>B>>C>>D;
  cout<<L-max((A+C-1)/C,(B+D-1)/D)<<endl;
}



Measured memory_bytes: 3088
#include <iostream> 
#include <bits/stdc++.h>
#include <vector> 
#include <algorithm> 
#include <string>
#include <cmath>
#include <iomanip> 
#include<climits> 
#include <utility>      
#include <numeric> 
#include <iterator>
#include <map> 
using namespace std; 
#define ll unsigned long long int
int main() {
ll a,b,k;
cin>>a>>b>>k;
if(a>=k)
cout<<a-k<<" "<<b<<endl;
else
{
    if(a+b >= k)
cout<<0<<" "<<a+b-k<<endl;
else
cout<<0<<" "<<0<<endl;
} 
}


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

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

    string T;
    cin >> T;

    if (S.length() + 1 != T.length()) {
        cout << "No";
        return 0;
    }
    if (S.substr(0, S.length()) == T.substr(0, T.length() - 1)) {
        cout << "Yes";
        return 0;
    }
    cout << "No";

}


Measured memory_bytes: 3596
fun main() {
    val n = nextInt()
    val array = nextLongArray(n)
    var all = 0L
    for (i in array) {
        all = all xor i
    }
    printString {
        for (i in array) {
            append(all xor i)
            append(' ')
        } }
}

val sc = java.util.Scanner(System.`in`)
fun next(): String = sc.next()
fun nextInt() = sc.nextInt()
fun next2Int() = Pair(nextInt(), nextInt())
fun next3Int() = Triple(nextInt(),nextInt(), nextInt())
fun nextLongArray(size: Int) = LongArray(size) { nextLong() }
fun nextLong() = sc.nextLong()
fun nextLine(): String = sc.nextLine()
fun nextList() = nextLine().split(" ")
fun printYesNo(isYes: Boolean) = println(if (isYes) "Yes" else "No")
fun printString(action: StringBuilder.()-> Unit) = println(buildString(action))


Measured memory_bytes: 63600
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stdexcept>
#include<cmath>
#include<memory>
#include<algorithm>
#include<cstring>
#include<ctime>
#include<deque>
#include<sstream>
#include<iomanip>
#include<sstream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<climits>
#include<map>
#include<set>
#include<list>
#include<cassert>
#include<deque>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define INF 1<<27
#define all(n) n.begin(),n.end()
#define insert(a,b,c,d) PP(P(a,b),P(c,d))
#define F first
#define S second
#define pb push_back
#define pf push_front
#define MAX 110000
using namespace std;
typedef pair<int,int> P;
typedef pair<P,P> PP;
typedef long long ll;
typedef unsigned long long ull;

bool prime[MAX];
vector<int> vec;

void eratos(){
  rep(i,MAX)prime[i] = false;
  for(int i=3;i<MAX;i+=2)prime[i] = true;
  prime[2] = true;
  for(int i=3;i<=sqrt(MAX);i+=2){
    if(!prime[i])continue;
    for(int j=i+i;j<MAX;j+=i)prime[j] = false;
  }

  vec.pb(2);
  for(int i=3;i<MAX;i+=2){
    if(prime[i])vec.pb(i);
  }

}

int main(){
  eratos();
  
  while(true){
    ll m;
    double a,b;
    P mex = P(-1,-1);
    cin >> m >> a >> b;
    if(m == 0 && a == 0 && b == 0)break;
    for(int i=0;vec[i] <= m/2;i++){
      
      for(int j=i;(long long)vec[j]*vec[i] <= m;j++){
	double A,B;
	A = (double)vec[i]/(double)vec[j];
	B = (double)vec[j]/(double)vec[i];
	if(mex == P(-1,-1) && ( (1 >= A && A >= a/b) || (1 >= B && B >= a/b))){
	    if( (1 >= A && A >= a/b) )mex = P(vec[i],vec[j]);
	    else mex = P(vec[j],vec[i]);
	   
	  }
	  else if(1 >= A && A >= a/b){
	    if(vec[i]*vec[j] >= mex.F*mex.S)
	      mex = P(vec[i],vec[j]);
	  }
	  else if(1 >= B && B >= a/b){
	    if(vec[i]*vec[j] >= mex.F*mex.S)
	      mex = P(vec[j],vec[i]);
	  }
	  
	  
      }
      
    }
    
    assert(mex != P(-1,-1));
    cout << mex.F << " " << mex.S << endl;
  }
  return 0;
}

Measured memory_bytes: 1472
#include <bits/stdc++.h>
using namespace std;
#define freinput "input.txt","r",stdin
#define freoutput "output.txt","w",stdout
#define mp make_pair
#define fi first
#define sc second
#define pb push_back
#define ellapse printf("Time : %0.3lf\n",clock()*1.0/CLOCKS_PER_SEC);
typedef long long ll;
typedef unsigned long int uld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
struct comp {
       bool operator() (int a,int b) {
            return a>b;
       }
};

int main(){
    long a,b;
    cin>>a>>b;
    cout<<(a*b)/__gcd(a,b)<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define pf push_front
#define in insert
#define ff first
#define ss second
#define mp make_pair
//#define int long long
#define uint unsigned long long
#define rep(i,x,m) for(int i=x;i<m;i++)
#define repr(i,x,m) for(int i=x;i>=m;i--)
#define MOD 1000000007
#define endl "\n"
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define vi vector<int>
#define vs vector<string>
#define print(v) for(int i=0;i<v.size();i++) cout<<v[i]<<" ";cout<<endl
using namespace std;
#define noob ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int fac[2000005]={0};
void factorial(){ fac[0]=1; fac[1]=1; for(int i=2;i<200005;i++) fac[i]=((i%MOD)*(fac[i-1]%MOD))%MOD;}
int power(int n,int m)
{int p=1;if(m==0)return 1;p=(power(n,m/2)%MOD);p=(p%MOD*p%MOD)%MOD;
return(m&1?((p%MOD*n%MOD)%MOD):(p%MOD));}
int ncr(int n,int r){return ((fac[n]*power(fac[r],MOD-2))%MOD*power(fac[n-r],MOD-2))%MOD;}
int gcd(int a,int b)
{
	if(b==0)
		return a;
	return gcd(b,a%b);
}
void ram5564()
{
    int k;
    cin>>k;
    int sum=0;
    for(int i=1;i<=k;++i)
    {
    	for(int j=1;j<=k;++j)
    	{
    		for(int l=1;l<=k;++l)
    		{
    			int s=gcd(i,j);
    			int x=gcd(s,l);
    			sum+=x;

    		}
    	}
    }
    cout<<sum;
}

signed main()
{
		noob
		// #ifndef ONLINE_JUDGE
  //    	freopen("input.txt","r",stdin);
  //    	freopen("output.txt","w",stdout);
  //    	#endif   
        
        int t=1;
        //cin>>t;
        while(t--)
        ram5564();
        return 0;
}

Measured memory_bytes: 3652
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
class Main{

    public static void main(String args[])throws IOException
    {
    BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
    String blood;
    int human[]=new int[4];
    while((blood = input.readLine()) != null) {

        String a[]=blood.split(",");

        if(a[1].equals("A")){
        	human[0]++;
        }
        if(a[1].equals("B")){
        	human[1]++;
        }
        if(a[1].equals("AB")){
        	human[2]++;
        }
        if(a[1].equals("O")){
        	human[3]++;
        }

        }
    for(int i=0;i<4;i++)
        {
        System.out.println(human[i]);
        }
    }
}

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

import numpy
import scipy
#import sys


N = int(input())
P = []
for n in range(N):
    P.append(list(map(int, input().split())))

for i, p in enumerate(P):
    if i == 0:
        t_p, x_p, y_p = 0, 0, 0
    else:
        t_p, x_p, y_p = P[i-1][0], P[i-1][1], P[i-1][2]
    t, x, y = p
    dt = t - t_p
    dx = x - x_p
    dy = y - y_p
    dist = abs(dx) + abs(dy)

    if dist > dt:
        print("No")
        exit()

    if dist%2 != dt%2:
        print("No")
        exit()

print("Yes")



Measured memory_bytes: 36440
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		
		int [] a = new int [n];
		int [] b = new int [n];
		int [] c = new int [n];
		
		for (int i=0; i<n; i++) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
			c[i] = sc.nextInt();
		}
		
		int [][] dp = new int [n][3];
		
		dp[0][0] = a[0];
		dp[0][1] = b[0];
		dp[0][2] = c[0];
		
		for (int i=1; i<n; i++) {
			dp[i][0] = Math.max(dp[i-1][1] + a[i], dp[i-1][2] + a[i]);
			dp[i][1] = Math.max(dp[i-1][0] + b[i], dp[i-1][2] + b[i]);
			dp[i][2] = Math.max(dp[i-1][0] + c[i], dp[i-1][1] + c[i]);
		}
		
		int max = 0;
		
		for (int i=0; i<3; i++)
			max = Math.max(max, dp[n-1][i]);
		
		System.out.println(max);
		
	}

}

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

int main() {
  int r,D;
  cin >> r >> D;
  int a[11] = {0};
  cin >> a[0];
  for(int i = 0;i < 11;i++){
    a[i + 1] = ((r * a[i] )- D);
  }
  for(int j = 0;j < 10;j++){
    cout << a[j + 1] << endl; 
  }
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);

/* -----  2019/05/26  Problem: ABC 128 B / Link: http://abc128.contest.atcoder.jp/tasks/abc128_b  ----- */


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

	LL N;
	cin >> N;
	vector<pair<string, PII>>A;
	FOR(i, 0, N) {
		string s; cin >> s;
		int a; cin >> a;
		A.push_back(pair<string, PII>(s, PII(-a, i)));
	}
	SORT(A);
	VI ans(N);
	FOR(i, 0, N) {
		auto it = A[i];
		ans[it.second.second] = i;
		cout << it.second.second + 1 << endl;
	}
	FOR(i, 0, N) {
	//	cout << ans[i] + 1 << endl;
	}

	return 0;
}


Measured memory_bytes: 256
{-# LANGUAGE CPP #-}

import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)

#define MOD 1000000007

modFact :: Int -> Int
modFact 0 = 1
modFact 1 = 1
modFact n = n * modFact (n - 1) `mod` MOD

main :: IO ()
main = do
    [n, m] <- map (fst . fromJust . B.readInt) . B.words <$> B.getLine
    print $ case abs (n - m) of
                0 -> modFact n * modFact m * 2 `mod` MOD
                1 -> modFact n * modFact m `mod` MOD
                _ -> 0


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

using namespace std;
using ll = long long int;
using lc = complex<double>;

int main(void) {
    constexpr ll MOD = 1e9 + 7;
    constexpr double PI = acos(-1);
    cout << fixed << setprecision(32);
    cin.tie(0); ios::sync_with_stdio(false);

    while(1) {
        ll t, d, l;
        cin >> t >> d >> l;
        if(!t) break;
        ll res = 0;
        ll s = 1;
        while(--t) {
            if(s>0) s--;
            ll x;
            cin >> x;
            if(x >= l) s = d;
            if(s) res++;
        }
        cin >> s;
        cout << res << endl;
    }
}



Measured memory_bytes: 3176
from collections import defaultdict
from itertools import permutations
N,M=map(int,input().split())
mat = [[0]*(1+N) for _ in range(1+N)]
for _ in range(M):
    a,b = map(int,input().split())
    mat[a][b] = 1
    mat[b][a] = 1
ans = 0
for tpl in permutations(range(2, 1+N), N-1):
    is_ok = 1
    tpl = [1] + list(tpl)
    for i in range(N-1):
        if mat[tpl[i]][tpl[i+1]] == 0:
            is_ok = 0
            break
    
    if is_ok:
        ans += 1
print(ans)
    

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

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const double eps = 1e-9;

typedef pair<ll, ll> P;

int main()
{
    int n, cnt = 0;
    ll sum = 0;
    cin >> n;
    vector <ll> a(n), b(n), t;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];
    for (int i = 0; i < n; i++) {
        if (a[i] == b[i]) continue;
        if (a[i] < b[i]) {
            sum += b[i] - a[i];
            cnt++;
        }
        else t.push_back(b[i] - a[i]);
    }
    sort(t.begin(), t.end());

    int i;
    for (i = 0; i < int(t.size()); i++) {
        if (sum > 0) sum += t[i];
        else break;
    }
    if (sum > 0) cout << -1 << endl;
    else cout << i + cnt << endl;
    return 0;
}


Measured memory_bytes: 2428
#include <bits/stdc++.h>
    using namespace std;
     
    int main(void)
    {
        string x;
        cin>>x;
        string y;
        for(int i=0;i<x.length();i+=2)
        {
            y+=x[i];
        }
        cout << y<<endl;
        return 0;
    }

Measured memory_bytes: 512
import sys
input=lambda: sys.stdin.readline().rstrip()
n,k=map(int,input().split())
A=[int(i) for i in input().split()]

l,r=0,max(A)
cur=0
while cur<100:
	mid=(l+r)/2
	ct=0
	for a in A:
		if a<=mid:
			continue
		else:
			t=int(a/mid)
			if t*mid==a:
				t-=1
		ct+=t
	if ct<=k:
		r=mid
	else:
		l=mid
	cur+=1

ans=int(r)
if ans==r:
	print(ans)
else:
	print(ans+1)

Measured memory_bytes: 93956
#include <iostream>

using namespace std;

typedef long long ll;

int main(){

    const ll mod = 1000000007;

    ll n;
    cin >> n;

    ll res = 1;


    for (ll i = 1; i <= n; i++){
        res *= i;
        res %= mod;
    }

    // 283051545
    // 457992974

    cout << res;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <string>
#include <algorithm>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(c) c.begin(),c.end()
#define PB push_back

using namespace std;
typedef long long ll;

string S, T;

bool check(int idx)
{
  REP(i, T.size()) {
    if (S[idx + i] != '?' && S[idx + i] != T[i]) return false;
  }
  return true;
}

int main()
{
  cin >> S >> T;
  for (int i = S.size() - T.size(); i >= 0; i--) {
    if (check(i)) {
      REP(j, T.size()) S[i + j] = T[j];
      REP(j, S.size()) if (S[j] == '?') S[j] = 'a';
      cout << S << endl;
      return 0;
    }
  }
  cout << "UNRESTORABLE" << endl;
  return 0;
}

Measured memory_bytes: 256
// May this submission get accepted!

#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define STEP(i, is, ie, step) for (long long i=(is), i##_end=(ie), i##_step = (step); i<=i##_end; i+=i##_step)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
template<class T> bool chmax(T &a, const T &b) { if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(DUMPALL_ITR, (q).size()) { cerr << (q)[DUMPALL_ITR] << (DUMPALL_ITR == DUMPALL_ITR_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(T a, T b) { if (a < b) std::swap(a, b); while (b) std::swap(a %= b, b); return a; }
template<class T> T lcm(const T a, const T b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using  ld = long double;
using namespace std;

// 標準入出力
struct inp {
    size_t sz;
    inp(size_t _sz = 1) : sz(_sz) {}
    template <typename T> operator T () const { T a; cin >> a; return a; }
    template <typename T> operator vector<T> () const { vector<T> a(sz); for (size_t i = 0; i < sz; i++) cin >> a[i]; return a; }
    template <typename T, typename U> operator pair<T, U> () const { T f; U s; cin >> f >> s; return pair<T, U>(f, s); }
};
inp inp1; // input one
template <typename T> void say(T &x, char end = '\n') { cout << x << end; }
template <typename T> void say(vector<T> &x, char sep = ' ', char end = '\n') { for (size_t i = 0, sz = x.size(); i < sz; i++) { cout << x[i] << (i == sz-1 ? end : sep); } }

// モジュール


// 処理内容
int main() {
    
    ios::sync_with_stdio(false); // stdioを使うときはコメントアウトすること
    cin.tie(nullptr);            // インタラクティブ問題ではコメントアウトすること
    
    ll a1 = inp1, a2 = inp1, a3 = inp1;
    cout << (a1+a2+a3>=22?"bust":"win") << endl;
    
}

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

int main() {
    string s[N],ans;
    long long n,l;
    cin>>n>>l;
    for(int i=0;i<n;i++){
        cin>>s[i];
    }
    sort(s,s+n);
    ans=s[0];
    for(int i=1;i<n;i++){
        ans+=s[i];
    }
    cout<<ans<<endl;

    return 0;
    }

Measured memory_bytes: 256
import Foundation
let A = Int(readLine()!)!
let B = Int(readLine()!)!
let C = Int(readLine()!)!
let X = Int(readLine()!)!
var count = 0
//500A + 100B + 50C = X を満たす(A,B,C)

for a in 0 ... A {
    for b in 0 ... B {
        for c in 0 ... C {
            if 500*a + 100*b + 50*c == X {
                count += 1
            }
        }
    }
}
print(count)

Measured memory_bytes: 13024
#include <stdio.h>
#include <string.h>

#define N (1000 + 10)

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

int dp[N][N];
char a[N], b[N];

int LCS(void)
{
  const int a_size = strlen(a) - 1; // last one is '\n'
  const int b_size = strlen(b) - 1;
  int i, j;

  memset(dp, 0, sizeof(dp));

  for (i = 1; i < a_size + 1; ++i) {
    for (j = 1; j < b_size + 1; ++j) {
      int mx = max(dp[i][j - 1], dp[i - 1][j]);
      if (a[i - 1] == b[j - 1]) {
        mx = max(mx, dp[i - 1][j - 1] + 1);
      }
      dp[i][j] = mx;
    }
  }

  return dp[a_size][b_size];
}

int main(void)
{
  int n, i,c=0;
  c=kansu(c);
  if(c == 0){
  scanf("%d\n", &n);
  for ( i = 0; i < n; i++ ){
    fgets(a, N, stdin);
    fgets(b, N, stdin);
    printf("%d\n", LCS());
  }
  return 0;
}}
void kansu(int c){
 int z=0;
 if(z == 0);
   return c;
}



Measured memory_bytes: 5788
//Jai Bhole Ki
#include <bits/stdc++.h>
using namespace std;
#define fast static int fastline = []() { std::ios::sync_with_stdio(false); cin.tie(NULL); return 0; }();
#define ll long long
#define LL unsigned ll
#define pb push_back
#define pi pair<ll,ll>
#define debug(x) cout<<x<<"\n";
#define debug cout<<"debugged\n";
#define minval -2e9
#define maxval 2e9
long double PI =3.14159265358979323846;
 
const ll M=1e9+7;
const ll inf=1e18;
const ll ms=2e5+5;
fast;
ll ans;
vector<vector<int>> vc(ms);
pi dp[ms];
void solve()
{
    ll n,m;cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        ll a,b;cin>>a>>b;
        vc[a].pb(b);vc[b].pb(a);
    }
   // priority_queue<pi,vector<pi>> qe;
   queue<pi>qe;
    qe.push({1,0});
    while(qe.size())
    {
        pi a=qe.front();qe.pop();
        for(auto t:vc[a.first])
        {
            if(t==a.second||dp[t].first!=0)
                continue;
            dp[t]={dp[a.first].first+1,a.first};
            qe.push({t,a.first});
        }
    }
    for(int i=2;i<=n;i++)   
    {
        if(dp[i].first==0)
            {cout<<"No"<<endl;return;}
    }
    cout<<"Yes"<<endl;
    for(int i=2;i<=n;i++)
        cout<<dp[i].second<<endl;
}
int main()
{
 // freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
    //int t;cin>>t;while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 14856
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

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

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

ll score(char c, ll R, ll S, ll P) {
    if (c == 'r') {
        return R;
    } else if (c == 's') {
        return S;
    } else if (c == 'p') {
        return P;
    }
}

int main() {
    INIT;

    ll N, K, R, S, P;
    string T;
    cin >> N >> K >> R >> S >> P;
    cin >> T;

    string str = "";
    rep(i, SZ(T)) {
        if (T[i] == 's') {
            str += "r";
        } else if (T[i] == 'r') {
            str += "p";
        } else if (T[i] == 'p') {
            str += "s";
        }
    }

    // cout << str << endl;

    ll sum = 0;
    rep(i, SZ(str)) { sum += score(str[i], R, S, P); }
    // cout << sum << endl;

    rep(i, K) {
        string s = "";

        for (ll j = i; j < N; j += K) {
            // cout << str[j];
            s += str[j];
        }
        // cout << endl;

        reps(j, 1, SZ(s)) {
            if (s[j - 1] == s[j]) {
                sum -= score(s[j], R, S, P);
                s[j] = 'x';
            }
        }

        // cout << s << endl;
    }
    cout << sum << endl;

    // repv(cands) cout << *it << endl;

    return 0;
}

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

int main() {
  int n,x;
  cin >> n >> x;
  vector<int> g(n);
  int must=0;		//n種類の粉1個分ずつ　ｎ個分
  for(int i=0;i<n;i++){
    cin >> g.at(i);
    must += g.at(i);
  }
  int cnt=0; // ドーナツの個数
  x -= must;
  cnt = n;
  
  sort(g.begin(),g.end());
  while( x > 0 ){
    x -= g.front();
    if( x < 0 ) break;
    cnt++;
  }
  
  cout << cnt << endl;
  
  return 0;
  
}

Measured memory_bytes: 256
x=int(input())
lists=[(i**5,i) for i in range(-1000,1000)]
N=len(lists)
def solve(x):
    for i in range(N):
        for j in range(i):
            if lists[i][0]-lists[j][0]==x:
                print(lists[i][1],lists[j][1])
                return True
solve(x)               

Measured memory_bytes: 9280
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final String[] inputs = scanner.nextLine().split(" ");
        final int a = Integer.parseInt(inputs[0]);
        final int b = Integer.parseInt(inputs[1]);
        final int t = Integer.parseInt(inputs[2]);

        System.out.println(t / a * b);
    }
}


Measured memory_bytes: 23764
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    int X, Y; cin >> X >> Y;
    for (int t = 0; t <= X; ++t)
    {
        int k = X - t;
        if (t * 2 + k * 4 == Y)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 3632
# import math
# import statistics
a=input()
b=input()
#b,c=int(input()),int(input())
c,d=[],[]
for i in a:
    c.append(i)
for i in b:
    d.append(i)
#e1,e2 = map(int,input().split())
# f = list(map(int,input().split()))
#g = [input() for _ in range(a)]
# h = []
# for i in range(e1):
#     h.append(list(map(int,input().split())))
ma=[]
if b in a:
    print(0)
else:
    for i in range(len(c)-len(d)+1):
        count=0
        for k in range(len(d)):
            if c[i:len(d)+i][k]!=d[k]:
                count+=1
        ma.append(count)
    print(min(ma))

Measured memory_bytes: 9120
#include <iostream>
#include <math.h>
#include <string>

using namespace std;

void solve();

int main() {
	solve();
	return 0;
}

//////////////////////////////////////////////////
//////////////////////////////////////////////////

string S;
void solve() {
	cin >> S;
	int nums[4];
	for (int i = 0; i < 4; i++)nums[i] = S[i] - '0';
	int a, b, c;
	for (a = 0; a <= 1; a++) {
		for (b = 0; b <= 1; b++) {
			for (c = 0; c <= 1; c++) {
				int temp = nums[0];
				temp = a == 0 ? temp + nums[1] : temp - nums[1];
				temp = b == 0 ? temp + nums[2] : temp - nums[2];
				temp = c == 0 ? temp + nums[3] : temp - nums[3];
				if (temp == 7) {
					cout << nums[0];
					if (a == 0)cout << "+";
					else cout << "-";
					cout << nums[1];
					if (b == 0)cout << "+";
					else cout << "-";
					cout << nums[2];
					if (c == 0)cout << "+";
					else cout << "-";
					cout << nums[3] << "=7";
					return;
				}
			}
		}
	}
}

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

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

int main() {
	string s;
	cin >> s;
	ll n = s.size();
	vector<int> dict(26, 0);
	rep(i, n) {
		int id = s[i] - 'a';
		dict[id]++;
	}
	ll dup = 0;
	for(int i = 0;i < 26;i++){
		ll len = dict[i];
		if (len) {
			dup += len * (len - 1) / 2;
		}
	}
	ll sum = n * (n - 1) / 2 + 1;
	cout << sum - dup << endl;
	return 0;
}


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

int main(){
  int N;
  int prev[7];
  char temp[10][8] = {"0111111","0000110","1011011","1001111","1100110","1101101","1111101","0100111","1111111","1101111"};
  while(cin >> N,N>=0){
    fill(prev,prev+7,0);
    while(N--){
      int ans[7],n,fig[7];
      cin >> n;
      for(int i=0;i<7;i++){
	if(temp[n][i] -'0' != prev[i]) ans[i] = 1;
	else ans[i] = 0;
      }
      for(int i=0;i<7;i++) fig[i] = temp[n][i]-'0';
      for(int i=0;i<7;i++) cout << ans[i];
      cout << endl;
      copy(fig,fig+7,prev);
    }
  }
}

Measured memory_bytes: 1164
import java.util.*;

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

        int n = sc.nextInt();
        int q = sc.nextInt();
        ArrayList<ArrayDeque<Integer>> queue = new ArrayList<>();
        for(int i = 0;i < n;i++){
            queue.add(new ArrayDeque<>());
        }

        for(int i = 0;i < q;i++){
            int num = sc.nextInt();
            int t = sc.nextInt();

            switch(num){
                case 0: //enqueue
                    int x = sc.nextInt();
                    queue.get(t).add(x);
                    break;
                case 1: //front
                    if(queue.get(t).size() > 0)
                        System.out.println(queue.get(t).getFirst());
                    break;
                case 2: //dequeue
                    if(queue.get(t).size() > 0)
                        queue.get(t).remove();
                    break;
            }
        }
    }
}


Measured memory_bytes: 170064