akhauriyash/Code-Regression huggingface dataset:
import sys
N, M = [int(v) for v in sys.stdin.readline().split()]
AC = set()
WA = {}
for i in range(M):
    p, s = sys.stdin.readline().split()
    p = int(p)

    if s == 'AC':
        AC.add(p)
    else:
        if p not in AC:
            if p not in WA:
                WA[p] = 1
            else:
                WA[p] += 1
wa = 0
for a, c in WA.items():
    if a in AC:
        wa += c

print(len(AC), wa)


Measured memory_bytes: 11884
from itertools import product,combinations
N,M,Q = map(int,input().split())
B = [list(map(int,input().split())) for _ in range(Q)]
ans = 0
for x in product((0,1),repeat=N-1):
    k = sum(x)
    for y in combinations(range(1,M+1),k+1):
        A = [0 for _ in range(N)]
        cur = 0
        for i in range(N-1):
            if x[i]==0:
                A[i] = y[cur]
            else:
                A[i] = y[cur]
                cur += 1
        A[N-1] = y[cur]
        cnt = 0
        for i in range(Q):
            a,b,c,d = B[i]
            if A[b-1]-A[a-1]==c:
                cnt += d
        ans = max(ans,cnt)
print(ans)

Measured memory_bytes: 68688
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define N 15

int n,e;
int edge[N][N];
int py[N],px[N];

int solve_dp(){
    int (*dp)[N];
    dp = (int(*)[N])malloc(sizeof(int)*(1<<n)*N);
    int m = 1<<n;
    int i,j,k,l,b;
    for(i = 0;i < m;i++) for(j = 0;j < n;j++) dp[i][j] = -1;
    dp[1][0] = 0;
    for(i = 1;i < n;i++){
        for(j = 0;j < m;j++){
            if(i != __builtin_popcount(j)) continue;
            for(k = 0;k < n;k++){
                if(dp[j][k] < 0) continue;
                for(l = 0;l < n;l++){
                    b = 1<<l;
                    if((b&j) || edge[k][l] == -1) continue;
                    b = j|b;
                    if(dp[b][l] < 0 || dp[b][l] > dp[j][k]+edge[k][l]) dp[b][l] = dp[j][k]+edge[k][l];
                }
            }
        }
    }
    int res = -1;
    for(i = 0;i < n;i++){
        if(dp[(1<<n)-1][i] == -1 || edge[i][0] == -1) continue;
        int a = dp[(1<<n)-1][i] + edge[i][0];
        if(res == -1 || res > a) res = a;
    }
    free(dp);
    return res;
}

int solve(){
    int i,j;
    int a,b,d;
    scanf("%d %d",&n,&e);
    for(i = 0;i < n;i++){
        for(j = 0;j < n;j++){
            edge[i][j] = -1;
        }
    }
    for(i = 0;i < e;i++){
        scanf("%d %d %d",&a,&b,&d);
        edge[a][b] = d;
    }
    return solve_dp();
}

int main(){
    printf("%d\n",solve());
}



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

  const ll N = 1000000007;
int main() {
  ll n,k,ans=0;
  cin>>n>>k;
  vector<ll> ruiseki(200001);
  ruiseki[0]=0;
  rep(i,200001){
    ruiseki[i+1]=ruiseki[i]+i+1;
  }
  for(int i=k; i<=n+1; i++){
    ll max_ans,min_ans;
    max_ans=ruiseki[n+1]-ruiseki[n-i+1];
    min_ans=ruiseki[i]-ruiseki[0];
    ans+=max_ans-min_ans+1;
  }
  ans%=N;
  cout<<ans<<endl;
}

Measured memory_bytes: 4808
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
const long long  mod = 1000000007;



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

  
  int ans = 0;
  int d[100001] = {0};
  rep(i,n) {
    int a;
    cin >> a;
    if(a > 100000) {
      ans++;
      continue;
    }
    d[a]++;
  }

  rep(i,100001){
    if(d[i] > i) ans += d[i]-i;
    if(i > d[i]) ans += d[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 3992
#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
	if (a%b == 0) {
		return b;
	}
	return gcd(b%a, a);
}

int gcd3(int a, int b, int c) {
	return gcd(gcd(a, b), c);
}
long long sumGCD(int z) {
	long long res = 0;
	for (int i=1;i<z+1;i++) {
		for (int j=1;j<z+1;j++) {
			for (int k = 1;k<z+1;k++) {
				res+=gcd3(i, j, k);
			}
		}
	}
	return res;
}
main () {
	int n;
	cin>>n;
	cout<<sumGCD(n)<<endl;
}

Measured memory_bytes: 3632
/***************************************** 
****       Solution by SlavicG        ****
*****************************************/
 
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm> 
#include <set>
#include <utility>
#include <queue>
#include <map>
#include <assert.h>
#include <stack>
using namespace std;
#define ll long long
#define forn(i,n) for(int i=0;i<n;++i)
#define MX 10000000001
#define pow2(a) ((a)*(a))
#define pb push_back
#define pf push_front
#define all(v) v.begin(), v.end()
#define endl "\n"
#define FAST std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 int longestIncreasingSubsequenceLenghtDP(int a[],int n){
    int dp[n],ans=0;
    for(int k = 0;k<n;k++){
        dp[k] = 1;
        for(int i = 0;i<k;i++){
            if(a[i] <= a[k]){
                dp[k] = max(dp[k],dp[i] + 1);
                ans = max(dp[k],ans);
            }
        }
    }
    return ans;
 }
int result[1000] = {0};
int factDP(int n) 
{
   if (n >= 0) {
      result[0] = 1;
      for (int i = 1; i <= n; ++i) {
         result[i] = i * result[i - 1];
      }
      return result[n];
   }
}
bool checkPrime(int n)
{
    if(n<2) return false;
    for(int x = 2;x*x <=n;x++)
    {
        if(n%x == 0)return false;
    }
    return true;
}
vector<int> primeFactors(int n){
    vector<int> f;
    for(int x = 2;x*x<=n;x++){
        while(n%x==0){
            f.push_back(x);
            n/=x;
        }
    }
    if(n>1)f.push_back(n);
    return f;
}
int binary_Search_Classic(int n, int arr[],int target){
	int l,r,mid;
	l=0;
	r=n-1;
	while(l<=r){
		mid= l+(r-l)/2;
		if(arr[mid] == target){
			return mid;
		}
		if(arr[mid] < target){
			l=mid+1;
		}else
		{
			r=mid-1;
		}
	}
	return -1;
}
int binary_Search_First_Greater(int n, int arr[],int target){
	int l,r,ans,mid;
	l = 0;
	r = n-1;
	ans=-1;
	while(l<=r){
		mid = l + (r-l)/2;
		if(arr[mid] > target){
			ans=mid;
			r=mid-1;
		}else{
			l = mid+1;
		}
	}
	return ans;
}
int countDistinctCharsString(string s) {
    unordered_map<char, int> m; 
    for (int i = 0; i < s.length(); i++) { 
        m[s[i]]++; 
    }
    return m.size(); 
} 
int main()
{
	int n,m;
	cin >> m >> n;
	int a[n];
	forn(i,n)cin >> a[i];
	sort(a,a+n);
	int ans1=0,ans2=0;
	bool flag;
	for(int i = m;i<=1000;i++)
	{
		flag=0;
		for(int j = 0;j<n;j++)
		{
			if(i == a[j])
			{
				flag=1;
				break;
			}
		}
		if(flag==0){
			ans1=i;
			break;
		}
	}
	for(int i = m;i>=-1000;i--)
	{
		flag=0;
		for(int j = 0;j<n;j++)
		{
			if(i == a[j])
			{
				flag=1;
				break;
			}
		}
		if(!flag)
			{
				ans2=i;
				break;
			}
	}
	if(abs(ans1-m) < abs(ans2-m))
	{
		cout << ans1 << endl;
	}else{
		cout << ans2 << endl;
	}
	return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	int n;
	string a,b,c;
	cin>>n>>a>>b>>c;
	int sum=0;
	for(int i=0;i<n;i++)
	{
		if(a[i]==b[i]&&a[i]==c[i])
			continue;
		else if(a[i]==b[i]||a[i]==c[i]||b[i]==c[i])
			sum++;
		else
			sum+=2;
	}
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 256
# ABC077C - Snuke Festival (ARC084C)
import sys
input = sys.stdin.readline

from bisect import bisect_left, bisect_right

def main():
    n = int(input())
    A, B, C = [sorted(map(int, input().rstrip().split())) for _ in range(3)]
    l, ans = len(C), 0
    for i in B:
        ans += bisect_left(A, i) * (l - bisect_right(C, i))
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 22720
n = int(input())
lst_a = [int(i) for i in input().split()]
lst_b = [int(i) for i in input().split()]
j = 0
flag = True
for i in range(n):
  if i > 0:
    if lst_a[i] != lst_a[i - 1]:
      j = 0
  if lst_a[i] != lst_b[i]:
    continue
  else:
    flag = False
    while j != n:
      if lst_a[i] != lst_b[j] and lst_a[j] != lst_b[i]:
        lst_b[i], lst_b[j] = lst_b[j], lst_b[i]
        flag = True
        break
      j += 1
    if not flag:
      break
if not flag:
  print('No')
else:
  print('Yes')
  lst_b = [str(i) for i in lst_b]
  print(' '.join(lst_b))

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

int main(){
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  int min, max;
  if (A > C) {
    min = A;
  } else {
    min = C;
  }
  if (B > D) {
    max = D;
  } else { 
    max = B;
  }
  
  if (max < min) {
    cout << 0 << endl;
  } else {
    cout << max - min << endl;
  }

}

Measured memory_bytes: 256
//https://beta.atcoder.jp/contests/abc112/tasks/abc112_a
#include <iostream>

int main() {
  int N;
  std::cin >> N;

  if (N == 1) {
    std::cout << "Hello World" << std::endl;
  } else {
    int A,B;
    std::cin >> A >> B;
    std::cout << A + B << std::endl;
  }

  return 0;
}


Measured memory_bytes: 256
import math
a,b,x = map(int,input().split())
x/=a

#theta = arctan(b/a)
half_area=a*b/2
if x==half_area:
    print(45)
if x<half_area:
    c = 2*x/b/b
    print(90-math.degrees(math.atan(c)))
if x>half_area:
    c = 2*(a*b-x)/a/a
    print(math.degrees(math.atan(c)))

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

#define mod 1000000007
int n,k,ans,f[2005][2005],sum[2005];

int main(){
    scanf("%d%d",&n,&k);
	f[0][n+1]=1;
    for(int i=1;i<=k;i++)
		for(int j=n+1;j>=1;j--){
			sum[j]=(sum[j+1]+f[i-1][j])%mod;
			f[i][j]=(j<=n-i+1?sum[j]:0);
		}
    ans=(f[k][1]-f[k-1][1]+mod)%mod;
    for(int i=1;i<=n-k-1;i++)ans=(ans+ans)%mod;
    printf("%d",ans);
}

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

int main() {
  int N,i;
  string s;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> s;
    if( s == "Y" ){
    cout << "Four" << endl;
    
    return 0;
  }
  }
  
  cout << "Three" << endl;
  
}


Measured memory_bytes: 256
import pprint
H,W,D=map(int,input().split())
table=[list(map(int,input().split())) for _ in range(H)]
Q=int(input())
query=[list(map(int,input().split())) for _ in range(Q)]
num=[]
distfrom1D=[]
cumldist=[0]*(H*W+1)
for i in range(H):
    for j in range(W):
        num.append([table[i][j],i,j])
num.sort(key=lambda x:x[0])
#print(num)
#for i in range()
cnt=0
"""
for i in range(D):
    buf=[0]
    for j in range(i,H*W-D,D):
        #print(i+j,i+j+D)
        buf.append(buf[len(buf)-1]+abs(num[j][1]-num[j+D][1])+abs(num[j][2]-num[j+D][2]))
    #print(buf)
    distfrom1D.append(buf)
#[1,1+D,]
#[2,2+D,]
#...
#[D,D+D,]
#pprint.pprint(distfrom1D)
for i in range(Q):
    l=query[i][0]
    r=query[i][1]
    row=((l%D)-1)%D
    col1 = (l // D)
    col2 = (r // D)
    if l%D==0:
        col1=col1-1
        col2=col2-1
    print(distfrom1D[row][col2]-distfrom1D[row][col1])
"""
#""l-r%D==0より""、各点考えられる固定の始点(1..D)から1,2,...,1+D,2+D,...,1+2D,2+2D,...の累積和をdpっぽく作れる
for i in range(1,H*W+1):
    if i//D>0:
        cumldist[i]=cumldist[i-D]+abs(num[i-D-1][1]-num[i-1][1])+abs(num[i-D-1][2]-num[i-1][2])
#print(cumldist)
for i in range(Q):
    l=query[i][0]
    r=query[i][1]
    print(cumldist[r]-cumldist[l])






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

int main()
{
    int n;
    cin >> n;
    int a[3*n];

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

    sort(a, a+(3*n));

    long long ans = 0;

    for(int i=(3*n-2); i>=n; i-=2){
        ans += a[i];
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4768
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

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

    int n, x, y, z;
    cin >> n >> x >> y >> z;
    int sum = x + y + z - 1;
    int mask = (1 << sum) - 1;

    vector<vector<int>> dp(n + 1, vector<int>(1 << sum));
    dp[0][0] = 1;
    rep(i, n){
        rep(s, 1 << sum){
            for(int j = 1; j <= 10; j++){
                int t = ((s << j) | (1 << (j - 1)));
                if((t >> (z - 1)) % 2 && (t >> (y + z - 1)) % 2 && (t >> sum) % 2){
                    continue;
                }
                dp[i+1][t&mask] += dp[i][s];
                dp[i+1][t&mask] %= MOD;
            }
        }
    }

    int all = 1;
    rep(i, n){
        all *= 10;
        all %= MOD;
    }
    int ans = 0;
    rep(s, 1 << sum){
        ans += dp[n][s];
        ans %= MOD;
    }

    cout << ((all + MOD) - ans) % MOD << endl;

    return 0;
}


Measured memory_bytes: 21888
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 3e5 + 10;
int d[N];
int main() {
    int h, n;
    cin >> h >> n;
    for(int i = 0; i < n; i++) {
        cin >> d[i];
        h -= d[i];
    }
    cout << (h > 0 ? "No":"Yes");
    return 0;
}

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

using namespace std;
#define ll long long
const int N = 2e5 + 5;
int a[N], fr[N];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    ll ans = 0;
    for (int i = 0; i < n; i++) cin >> a[i], ans += fr[a[i]]++;
    for (int i = 0; i < n; i++) {
        cout << ans - fr[a[i]] + 1 << "\n";
    }
    return 0;

}

Measured memory_bytes: 3712
// Package main provides
//
// File:  a.go
// Author: ymiyamoto
//
// Created on Sun Dec 30 18:01:19 2018
//
package main

import "fmt"

func main() {
	arr := make([]string, 3)
	for i := range arr {
		fmt.Scan(&arr[i])
	}

	for i := range arr {
		fmt.Print(string(arr[i][i]))
	}

	fmt.Println()
}


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

const int N = 19;
int f[N][(1<<17)+5], g[(1<<17)+5], n, m, e[N][N], p[(1<<17)+5];
inline int lowbit (int x) {return x&(-x);}

int main () {
	int tot = 0, ans = 0, u, v, c;
	
	scanf ("%d%d", &n, &m);
	for (int i = 1; i <= m; ++ i) {
		scanf ("%d%d%d", &u, &v, &c);
		e[u][v] = e[v][u] = c; tot += c;
	}
	
	for (int i = 0; i <= n; ++ i)
		for (int s = 0; s < (1<<n); ++ s) f[i][s] = -1e9;
	f[1][1] = 0;
	//cout << tot << endl;
	for (int i = 0; i <= n; ++ i) p[1<<(i)] = i+1;
	for (int s = 1; s < (1<<n); ++ s) {
		g[s] = g[s-lowbit (s)];
		for (int i = p[lowbit (s)]+1; i <= n; ++ i)
			if (s&(1<<(i-1))) g[s] += e[p[lowbit (s)]][i];
	}
	//for (int s = 0; s < (1<<n); ++ s) cout << g[s] << " "; cout << endl;
	
	for (int s = 1; s < (1<<n); ++ s)
		for (int i = 1; i <= n; ++ i) {
			for (int t = s; t; t = s&(t-1)) if ((1<<(i-1))&t)
				f[i][s] = max (f[i][s], f[i][(1<<(i-1)|(s-t))]+g[t]);
			for (int j = 1; j <= n; ++ j) if (e[i][j] && ((1<<(j-1))&s)==0)
				f[j][(1<<(j-1))|s] = max (f[j][(1<<(j-1))|s], f[i][s]+e[i][j]);
		}
	
	for (int s = 1; s < (1<<n); ++ s) if ((1<<(n-1))&s) ans = max (ans, f[n][s]);
	//for (int s = 0; s < (1<<n); ++ s) cout << f[n][s] << " "; cout << endl;
	printf ("%d\n", tot-ans);
	
	return 0;
}


Measured memory_bytes: 8832
#include <bits/stdc++.h> 
using namespace std; 
int main() {
  int tableau[3]; 
  cin >> tableau[0] >> tableau[1] >> tableau[2]; 
  sort(tableau, tableau + 3); 
  int a = tableau[0], b = tableau[1], c = tableau[2]; 
  if ((a == 5)&& (b == 5) && (c == 7))
    	cout << "YES"; 
  else
    cout << "NO"; 
  return 0; 
  
  
  
  
  
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO ?????????????????????????????????????????????
		int input[] = new int[100];
		int numOfInput;

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		numOfInput = Integer.parseInt(br.readLine());

		String tmpArray[] = br.readLine().split(" ");

		for(int i = 0; i < tmpArray.length ; i++){
			input[i] = Integer.parseInt(tmpArray[i]);
		}

		insertionSort(input, numOfInput);



	}

	public static void insertionSort(int[] array, int n){

		printArray(array, n);
		for(int i = 1; i <= n - 1; i++){
			int v = array[i];
			int j = i - 1;
			while (j >= 0 && array[j] > v){
				array[j+1] = array[j];
				j--;
			}
			array[j+1] = v;

			printArray(array, n);
		}
	}

	public static void printArray(int[] array, int n){
		for(int i = 0; i < n ; i++){
			System.out.print(array[i]);
			if(i < n - 1){
				System.out.print(" ");
			}
			else{
				System.out.println();
			}
		}
	}

}

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

int main() {
  int N, K; cin >> N >> K;
  vector<int> vec(N + 2); rep(i, N) cin >> vec[i + 1];
  vec[0] = 0; vec[N + 1] = 0;

  const long long INF = 1e18 + 10;
  vector<vector<long long>> dp(400, vector<long long>(400, INF));
  dp[0][0] = 0;

  rep(k, N + 2) rep(i, k) rep(j, N + 2) {
    if (dp[i][j] == INF) continue;
    long long d = vec[k] - vec[i];
    if (d < 0) d = 0;
    dp[k][j + k - i - 1] = min(dp[k][j + k - i - 1], dp[i][j] + d);
  }

  cout << dp[N + 1][K] << endl;
}

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

using namespace std;
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
typedef long long ll;

int N, K, C;
string S;
int book[200005];
int main()
{
    fio;
    cin >> N >> K >> C;
    cin >> S;
    vector<int> ans;
    int cnt = 0, idx = 0;

    idx = N - 1;
    cnt = 0;
    while (idx >= 0) {
        if (S[idx] == 'o') {
            ++book[idx];
            ++cnt;
            idx -= (C + 1);
        } else {
            --idx;
        }
    }
    if (cnt != K) {
        return 0;
    }
    idx = 0;
    cnt = 0;
    while (idx < N) {
        if (S[idx] == 'o') {
            if (book[idx]) {
                ans.push_back(idx + 1);
            }
            idx += (C + 1);
            ++cnt;
        } else {
            ++idx;
        }
    }

    for (int val : ans) {
        cout << val << endl;
    }
    cerr << "Time : " << (double) clock() / (double) CLOCKS_PER_SEC << "s\n";
    return 0;
}

Measured memory_bytes: 3468
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll mod = 1000000007;

ll r(ll x, ll y) {
  if (y == 0) return 1;
  else if (y % 2 == 0) return r(x, y/2) * r(x, y/2) % mod;
  else return x * r(x, (y-1)/2) % mod * r(x, (y-1)/2) % mod;
}


int main() {
  ll a, b, c,d;
  cin >>a>>b>>c>>d;
  if (c%b==0) c/=b;
  else c = c/b + 1;
  if (a%d==0) a/=d;
  else a = a/d + 1;
  
  if (c<=a) cout << "Yes" <<endl;
  else cout << "No" <<endl;
}

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

#define INF 1000000007
#define LINF 1000000000000000007

using namespace std;

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

string s, t = "zzzzz";
int k;

int main(){
	cin >> s >> k;
	set<string> se;
	set<string>::iterator ite;;
	for(int i = 0; i < s.size(); i++){
		for(int j = 1; j <= k; j++){
			if(i+j > s.size()) break;
			se.insert(s.substr(i, j));
		}
	}
	
	int i = 1;
	for(ite = se.begin(); ite != se.end(); ++ite, i++){
		if(i == k) cout << *ite << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1664
#include<iostream>
using namespace std;
int main()
{
	int N;
	cin>>N;
	string num;
	string a[4]={"AC","WA","TLE","RE"};
	int m[4]={0};
	for(int i=0;i<N;i++)
	{
		cin>>num;
		for(int j=0;j<4;j++)
		if(num==a[j])
		m[j]++;
	}
	for(int i=0;i<4;i++)
	{
		cout<<a[i]<<" x "<<m[i]<<endl;
	}

 } 

Measured memory_bytes: 3624
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

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

ull s(ull arg) {
  ull ret = 0;
  while (arg > 0) {
    ret += arg % 10;
    arg /= 10;
  }

  return ret;
}

int main() {
  ull k;
  cin >> k;

  ull base = 1;
  ull diff = 1;
  while (k > 0) {
    if (((double)base / s(base)) <= ((double)(base + diff) / s(base + diff))) {
      cout << base << endl;
      base += diff;
      k--;
    } else {
      base -= diff;
      diff *= 10;
      base += diff;
    }
  }

  return 0;
}

Measured memory_bytes: 256
A, B = map(int, input().split())
S = input()
if len(S) == A + B + 1 and S[A] == '-':
    for i in range(len(S)):
        if i != A and not S[i].isdecimal():
            print('No')
            exit()
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let mut a: i32 = read();
    let mut b: i32 = read();
    let mut c: i32 = read();


    if a == 1 && b == 1 && c == 1 {
        println!("0");
        return;
    }

    if a == b && b == c {
        println!("-1");
        return;
    }

    let mut ans = 0;
    while a % 2 != 1 && b % 2 != 1 && c % 2 != 1 {
        let half_a = a / 2;
        let half_b = b / 2;
        let half_c = c / 2;
        a = half_b + half_c;
        b = half_a + half_c;
        c = half_a + half_b;
        ans += 1;
    }

    println!("{}", ans);
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
N = int(input())
l = [input() for _ in range(N)]

ans = []
l.sort()
num = 1
max_num = 0

for i in range(1,N):
    if l[i] == l[i-1]:
        num += 1
    else:
        if num > max_num:
            max_num = num
            ans = [l[i-1]]
        elif num == max_num:
            ans.append(l[i-1])
        num = 1
if num > max_num:
        max_num = num
        ans = [l[i]]
elif num == max_num:
    ans.append(l[i])

for i in ans:
    print(i)

Measured memory_bytes: 83416
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];
		for(int i = 0; i < n; i++) {
			arr[i] = sc.nextInt();
		}
		Arrays.sort(arr);
		int res = 0;
		for(int i = 0; i < n-2; i++) {
			for(int j = i+1; j < n-1; j++) {
				int min = Integer.max(arr[i]-arr[j], arr[j]-arr[i]), max = arr[i]+arr[j];
				int st;
				if(arr[j+1] > min) {
					st = j+1;
				}
				else if(arr[n-1] <= min) {
					continue;
				}
				else {
					int a = j+1, b = n-1;
					while(b-a > 1) {
						int c = (a+b)/2;
						if(arr[c] > min) b = c;
						else a = c;
					}
					st = b;
				}
				int end;
				if(arr[n-1] < max) {
					end = n;
				}
				else if(arr[j+1] >= max) {
					continue;
				}
				else {
					int a = j+1, b = n-1;
					while(b-a > 1) {
						int c = (a+b)/2;
						if(arr[c] < max) a = c;
						else b = c; 
					}
					end = b;
				}
				res += end - st;
			}
		}
		System.out.println(res);
	}

}


Measured memory_bytes: 27236
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int32_t, int32_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

bool IsSquaredValue(int32_t n) {
  const int32_t a = static_cast<int32_t>(sqrt(n));
  return (a * a == n);
}

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

  int32_t A, B, K;
  cin >> A >> B >> K;
  for (int32_t i = A; i <= B; ++i) {
    if ((i >= A && i < A + K) || (i >= B - K + 1 && i <= B)) {
      cout << i << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
from sys import stdin
import sys
import math

[N, C, K] = list(map(int, stdin.readline().rstrip().split()))
T = sorted([int(input()) for i in range(N)])

bus = 1
passenger = 0
first_passengers_time = -1
for i in T:
    if passenger == C or (passenger > 0 and first_passengers_time + K < i):
        bus += 1
        passenger = 0
        first_passengers_time = 0

    if passenger == 0:
        passenger += 1
        first_passengers_time = i
    elif passenger < C and first_passengers_time + K >= i:
        passenger += 1

print(bus)


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


int main()
{
	int N = 0;
	cin >> N;
	if (3 > N) {
		cout << "0" << endl;
	}else
		if (N % 3 == 0) {
		cout << N / 3 << endl;
	}else
		if (N % 3 == 1) {
			cout << ((N - 4) / 3) + 1 << endl;
	}else
		if (N % 3 == 2) {
			cout << (N - 2) / 3 << endl;
	}


    return 0;
}

Measured memory_bytes: 256
'use strict'
const main = arg => {
  const n = parseInt(arg.split(' ')[0], 10)
  const k = parseInt(arg.split(' ')[1], 10)
  let i = 1
  while (n >= Math.pow(k, i)) i++
  console.log(i)
}
main(require('fs').readFileSync('/dev/stdin', 'utf-8'))


Measured memory_bytes: 7372
x,y,a,b,c=map(int,input().split())
p,q,r=[list(reversed(sorted(list(map(int,input().split()))))) for i in range(3)]
p=p[0:x]
q=q[0:y]
p.append(0)
q.append(0)
r.append(0)

s=0
i,j,k=0,0,0

for _ in range(x+y):
  if p[i]>=q[j] and p[i]>=r[k]:
    s+=p[i]
    i+=1
  elif q[j]>=r[k]:
    s+=q[j]
    j+=1
  else:
    s+=r[k]
    k+=1
    
print(s)


Measured memory_bytes: 22720
#include<iostream>//一坨头文件
#include<fstream>
#include<algorithm>
using namespace std;
int n,h,d=-100;//n存字符长度，h存当前高度，d存最大高度
char a[110];//a数组存字符串
int main()
{
     cin>>n;//读入字符串的长度
     for(int i=1;i<=n;i++)
     {
     	cin>>a[i];//读入字符串
     	if(a[i]=='I')h++;//如果字符是I，高度++
     	if(h>d)d=h;//每次选取最大值
     	if(a[i]=='D')h--;//如果字符是D，高度--
     	if(h>d)d=h;//每次选取最大值
     }
     cout<<d<<endl;//输出最大值,记得换行
    return 0;//完美结束
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cstdint>
using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	string sa(b, '0' + a), sb(a, '0' + b);
	cout << (sa < sb ? sa : sb) << endl;
	return 0;
}


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

int x;

int main() {
    cin >> x;

    // x * y % 360 = 0

    int cur = 0;

    for (int i = 0; ; i++) {
        cur += x;
        cur %= 360;

        if (cur == 0) {
            printf("%d\n", i + 1);
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 3692
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<math.h>
#include<queue>
#include<deque>
#include<map>
#include<bitset>

#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)

using namespace std;
using ll = long long;

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

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


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

ll dp[10010][2][110];
const ll mod = 1000000007;

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

    int len = s.size();

    memset(dp, 0, sizeof(dp));
    dp[0][0][0] = 1;

    for (int i = 0; i < len; i++)
    {
        int p = s[i] - '0';
        for (int j = 0; j < 2; j++)
        {
            for (int k = 0; k < d; k++)
            {
                for (int l = 0; l <= (j ? 9 : p); l++)
                {
                    int nextk = (k+l)%d;
                    dp[i+1][j || (l<p)][nextk] += dp[i][j][k];
                    dp[i+1][j || (l<p)][nextk] %= mod;
                }
            }
        }
    }
    
    // 0が入るから1引く
    ll ans = (dp[len][1][0]+dp[len][0][0])%mod - 1;
    if (ans < 0) {
        ans += mod;
    }
    cout << ans << endl;

    return 0;
}

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

void fnInput(vector<int>& rvnNum)
{
  int nNumSiz;
  cin >> nNumSiz;
  rvnNum.resize(nNumSiz);

  for (int& rnNum : rvnNum)
    cin >> rnNum;
}

int fnGcdGet(int nNumA, int nNumB)
{
  int nDividend = max(nNumA, nNumB);
  int nDivisor  = min(nNumA, nNumB);

  while (nDividend % nDivisor != 0)
  {
    int nRemain = nDividend % nDivisor;
    nDividend = nDivisor;
    nDivisor  = nRemain;
  }
  return nDivisor;
}

int fnMaxGcd(const vector<int>& cnrvnNum)
{
  vector<int> vnLeftGcd(cnrvnNum.size());
  vector<int> vnRigtGcd(cnrvnNum.size());
  int nMaxGcd = 0;

  vnLeftGcd[0] = cnrvnNum[0];
  
  for (int i = 1; i < cnrvnNum.size(); i++)
    vnLeftGcd[i] = fnGcdGet(vnLeftGcd[i - 1], cnrvnNum[i]);
  
  vnRigtGcd[cnrvnNum.size() - 1] = cnrvnNum[cnrvnNum.size() - 1];

  for (int i = cnrvnNum.size() - 2; i >= 0; i--)
    vnRigtGcd[i] = fnGcdGet(vnRigtGcd[i + 1], cnrvnNum[i]);

  for (int i = 0; i < cnrvnNum.size(); i++)
    if (i == 0)
      nMaxGcd = max(nMaxGcd, vnRigtGcd[i + 1] );
    else if (i == cnrvnNum.size() - 1)
      nMaxGcd = max(nMaxGcd, vnLeftGcd[i - 1] );
    else
      nMaxGcd = max(nMaxGcd, fnGcdGet(vnLeftGcd[i - 1], vnRigtGcd[i + 1] ));
  
  return nMaxGcd;
}
 
int main()
{
  vector<int> vnNum;

  fnInput(vnNum);
  cout << fnMaxGcd(vnNum) << endl;

  return 0;
}

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

ll gcd(ll a, ll b){return b ? gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}

int f(int &a){
  int cnt=0;
  while(a%2 == 0){
    a /= 2;
    ++cnt;
  }
  return cnt;
}

int main(){
  int n, m;
  cin >> n >> m;
  vector<int> vec(n);
  for(int i=0; i<n; ++i){
    cin >> vec.at(i);
    if(vec.at(i)%2 != 0){
      cout << 0 << endl;
      return 0;
    }
    vec.at(i) /=2;
  }
  int t=f(vec.at(0));
  for(int i=1; i<n; ++i){
    if(t != f(vec.at(i))){
      cout << 0 << endl;
      return 0;
    }
  }
  for(int i=0; i<t; ++i){
    m /= 2;
  }
  ll l=1;
  for(int i=0; i<n; ++i){
    l = lcm(l, vec.at(i));
    if(l > m){
      cout << 0 << endl;
      return 0;
    }
  }
  m /= l;
  int ans= (m+1)/2;
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

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

using namespace std;

string adj(string a, string b, unsigned long int m) {
  if(a.find(b) != string::npos) return a;
  int mmch = 0;
  REP(i,min(m,min(a.size(),b.size()))){
    if (a.substr(a.size() - i) == b.substr(0,i)) mmch = i;
  }
  a += b.substr(mmch);
  return a;
}


int main() {
  while(1){
    int n;
    cin >> n;
    if(!n) break;
    vector<string> a(n);
    REP(i,n) cin >> a[i];
    string ms = "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz";
    vector<vector<string>> bdp(1<<n,vector<string>(n,ms));
    std::fill(begin(bdp[0]),end(bdp[0]),"");
    REP(i,1<<n){
      REP(l,n){
        bitset<10> bs(i);
        REP(j,n){
          if(!bs[j]){
            bitset<10> cbs(bs);
            cbs[j]=true;
            int k = cbs.to_ulong();
            string as = adj(bdp[i][l],a[j],a[j].size());
            if(as.size() < bdp[k][j].size() || (as.size() == bdp[k][j].size() && as < bdp[k][j]))
              bdp[k][j] = as;
          }
        }
      }
    }
    REP(i,n){
      if(ms.size() > bdp.back()[i].size() || (ms.size() == bdp.back()[i].size() && ms > bdp.back()[i]))
        ms = bdp.back()[i];
    }
    cout << ms << endl;
  }
  return 0;
}

Measured memory_bytes: 1760
#include <iostream>
#include <algorithm>
#include <array>
#include <bitset>
#include <cstring>
#include <deque>
#include <math.h>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <queue>
#include <vector>

#define FOR(i, a, b) for(int (i) = (a); (i) < (b); ++(i))
#define rFOR(i, a, b) for(int (i) = (b); (i) >= (a); --(i))
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) rFOR(i, 0, (n-1))
#define SORT(A) std::sort((A).begin(), (A).end())
#define ALL(A) (A).begin(), (A).end()
// 座標圧縮 (for vector) : ソートしてから使うのが一般的 ; SORT(A) => COORDINATE_COMPRESSION(A)
#define COORDINATE_COMPRESSION(A) (A).erase(unique((A).begin(),(A).end()),(A).end())

using lli = long long int;
using pii = std::pair<int, int>;

template <typename T>
bool chmin(T& a, T b){
    if(b < a){ a = b; return true;}
    return false;
}

template <typename T>
bool chmax(T& a, T b){
    if(a < b){ a = b; return true;}
    return false;
}


// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~




int main(void){
    lli n; scanf("%lld", &n);
    if(n % 2 != 0) puts("0");
    else{
        n /= 2;
        lli cnt = 0;
        while(n > 0){
            n /= 5;
            cnt += n;
        }
        printf("%lld\n", cnt);
    }

    


    return 0;
}


Measured memory_bytes: 888
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e5 + 10;
int a[N];
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	if (n <= 999) cout << "ABC" << endl;
	else cout << "ABD" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define M1 1000000007
#define M2 998244353

#define fl(i,a,b)  for(ll i=a;i<b;i++)
#define ifl(i,a,b) for(ll i=b-1;i>=a;i--)
#define f(i,n)     for(int i=0;i<n;i++)
#define bf(i,n)    for(int i=n-1;i>=0;i++)


#define p0(a) cout << a << " "
#define P1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl

#define bn "\n"

//------------------------------------------------------------------------ 
// #define V(a) vector<a>
// #define vt() vector< tuple < int ,int ,int > > ;
// #define vector< int ,int > pv;
// vector< pair <int,int> > vect;


//------------------------------------------------------------------------

ll modI(ll a,ll m);
ll gcd(ll a,ll b);
ll powM(ll x,ll y,ll m);
ll swap(ll a,ll b);

void swap(ll& a,ll& b)
{
    ll tp=a;
    a=b;
    b=tp;
}

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

ll powM(ll x,ll y,ll m)
{
    ll ans=1,r=1;
    x%=m;
    while(r>0&&r<=y)
    {
        if(r&y)
        {
            ans*=x;
            ans%=m;
        }
        r<<=1;
        x*=x;
        x%=m;
    }
    return ans;
}
 
ll modI(ll a, ll m)
{
    ll m0=m,y=0,x=1;
    if(m==1) return 0;
    while(a>1)
    {
        ll q=a/m;
        ll t=m;
        m=a%m;
        a=t;
        t=y;
        y=x-q*y;
        x=t;
    }
    if(x<0) x+=m0;
    return x;
}

//---------------------------------------------------------------------------

// variable = Expression1 ? Expression2 : Expression3
// max = (n1 > n2) ? n1 : n2; 
// (n>m) ? cout<<"True"<<endl:cout<<"false"<<endl ;

// ---------------------------------------------------------------------------	

// int n;cin>>n;int a[n];for(int i=0;i<n;i++)cin>>a[i];    
// for(int i=0;i<n;i++)cout<<a[i];
// int a,b;cin>>a>>b;   

//----------------------------------------------------------------------------

// vector< tuple < int ,int ,int > > tv;
// vector< int ,int > pv;


//----------------------------------------------------------------------------


int main() {
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
	int tt=1;
   // cin>>tt;
	while(tt--)
	{
	    
	    
	    int n; cin>>n;
	int arr[n+1];

	map <int,int> mapp,m2;
	fl( i,1,n+1)
	{
	    ll h;
	    cin>>h; 
	    arr[i] = h;
	    //v1.pb(i-h); v2.pb(i+h);
	   // mapp[i-h]++;
	    m2[i+h]++; mapp[i-h]++;
	}
	int sum=2000;
	sum++;
	sum=sum+102;
	ll fin = 0;
	
	 fl(i,1,n+1)
    {
        fin =fin+ m2[i-arr[i]];
        fin =fin+ mapp[i+arr[i]];
    }
    sum=sum-18;
	P1(fin/2);
	    
	}
	
	return 0;
}


Measured memory_bytes: 38408
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S, T;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<int, int> P;

ll calc(){
    while(A%K != 0 && A > K){
        ll t = A / K;
        A = t * K + ((A - t * K) % (t + 1));
        if(A%K == 0) break;
        A -= t + 1;
    }
    //cout<<A<<endl;
    return A / K;
}

int main() {
    cin>>N;
    ll ans = 0;
    rep(i,N){
        cin>>A>>K;
        ll temp = calc();
        ans = ans ^ temp;
        //cout<<temp<<endl;
    }
    cout<<(ans > 0 ? "Takahashi" : "Aoki")<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int c = scanner.nextInt();
		int count = 0;
		for (int i = a;i <= b; i++) {
			if (c % i == 0)
				count++;
		}
		System.out.println(count);
		scanner.close();
	}
}

Measured memory_bytes: 17356
#include <stdio.h>
#include <stdlib.h>
int main(){
    int A,B;
    int K;
    scanf("%d%d",&A,&B);
    
        K = (A+B)/2;
    if(2*K !=A+B){
    printf("IMPOSSIBLE\n");
    }else
    printf("%d\n",K);
    return 0;
}

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

 using namespace std;
main () 
{
  
int n;
cin >> n;
int c1=0,c2=0,c3=0,c4=0;
for (int i = 0; i < n; i++)
{
    string s;
    cin >>s;
    if (s=="AC")
    c1++;
    else if (s=="WA")
    c2++;
    else if (s=="RE")
    c3++;
    else if (s=="TLE")
    c4++;
}
  cout << "AC x " << c1 << "\n"<<"WA x " << c2 << "\n"<< "TLE x " << c4 << "\n"<<"RE x " << c3 << "\n";

return 0;
    
}

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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)


int main() {
	cin.sync_with_stdio(false);
	string s;
	cin >> s;
	int c[26] = {};
	string so;
	rep(i, s.size()) {
		c[s[i] - 'a']++;
		so.push_back(s[i]);
	}
	int ans, minans=100;
	char mc;
	rep(i, 26) {
		if (c[i] == 0)continue;
		rep(j, s.size()) {
			s[j] = so[j];
		}
		mc = 'a' + i;
		bool flag = false;
		ans = 0;
		rep(j, s.size()) {
			if (s[j] != mc) {
				flag = true;
				break;
			}
		}
		while (flag) {
			flag = false;
			ans++;
			rep(j, s.size()) {
				if (j != 0 && s[j] == mc) {
					s[j - 1] = mc;
				}
			}
			rep(j, s.size() - ans) {
				if (s[j] != mc) {
					flag = true;
					break;
				}
			}
			
		}
		
		minans = min(minans, ans);
	}
	
	cout << minans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int i,j,aa,ba;
  int a[100][100]={0};
  int b[100]={0};
  int c[100]={0};
  scanf("%d %d",&aa,&ba);
  
  for(i=0;i<aa;i++){
  	for(j=0;j<ba;j++){
    	scanf("%d ",&a[i][j]);
    }
  }
  
  for(i=0;i<ba;i++){
  	scanf("%d",&b[i]);
  }
  
    for(i=0;i<aa;i++){
  	for(j=0;j<ba;j++){
    	c[i] += a[i][j]*b[j];
    }
      printf("%d\n",c[i]);
  }
  
  return 0;
  
}


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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
typedef long long ll;

int main(){
  int n,a;
  cin >> n;
  vector<int> d(n);
  int count = 0;
  rep(i,n){
    cin >> a;
    if(a%2==0){
      d[i]=a;
      count++;
      if(d[i]%3==0 || d[i]%5==0)count--;
    }
  }
  if(count==0)cout << "APPROVED" << endl;
  else cout << "DENIED" << endl;
}


Measured memory_bytes: 256
import itertools
import bisect
            

N = int(input())
L = list(map(int,input().split()))

# Lを小さい順にソート
L = sorted(L)

# a <= b <= cを仮定してもおｋ
# a,bを全探索し，条件を満たすcの数をO(N)未満の方法で求めればよい
ans = 0
for i in range(N-2):
    a = L[i]
    for j in range(i+1,N-1):
        b = L[j]

        # Lの中で条件b-a<cを満たす最小のc
        ind_cmin = j+1

        # Lの中で条件L[k]<a+bを満たす最大のk = Lの中で昇順ソートを崩さずa+bを挿入できる最小のインデックス-1
        # 2分法で探す
        ind_cmax = bisect.bisect_left(L,a+b) - 1

        ans += ind_cmax - ind_cmin + 1

print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    double n,m,sum=0,k=2;
    cin>>n>>m;
    sum+=1900*m;
    sum+=(n-m)*100;
    for(int i=0;i<m;i++){
        k=k*2;
if(i==0)
k=2;
    }
    cout<<sum*k<<'\n';
    return(0);
}

Measured memory_bytes: 256
s = gets
d = ('a'..'z').to_a
fff = "None"
0.upto(25) do |j|
  frag = false
  s.length.times do |i|
    if d[j] == s[i]
      frag = true
      break
    end
  end
  if frag == false
    fff = d[j]
    break
  end
end
puts fff


Measured memory_bytes: 1916
use std::io;
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::f64::consts::PI;

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}

const MOD: i64 = 1_000_000_007;

fn extgcd(a: i64, b: i64, x: &mut i64, y: &mut i64) -> i64 {
    let mut d = a;
    if b != 0 {
        d = extgcd(b, a % b, y, x);
        *y -= (a / b) * (*x);
    } else {
        *x = 1; *y = 0;
    }
    d
}

fn mod_inverse(a: i64, m: i64) -> i64 {
    let mut x = 0;
    let mut y = 0;
    extgcd(a, m, &mut x, &mut y);
    (m + x % m) % m
}

fn mod_fact(n: i64, p: i64, e: &mut i64, fact: &Vec<i64>) -> i64 {
    *e = 0;
    if n == 0 {
        return 1;
    }

    let res = mod_fact(n/p, p, e, fact);
    *e += n/p;
    if (n/p %2 != 0) {
        return res * (p - fact[(n%p) as usize]) % p;
    }
    res * fact[(n%p) as usize] % p
}

fn mod_comb(n: i64, k: i64, memo: &Vec<i64>) -> i64 {
    if n < 0 || k < 0 || n < k {
        return 0;
    }
    let mut e1 = 0;
    let mut e2 = 0;
    let mut e3 = 0;
    let a1 = memo[n as usize];
    let a2 = memo[k as usize];
    let a3 = memo[(n-k) as usize];
    if e1 > e2 + e3 {
        return 0;
    }
    a1 * mod_inverse(a2 * a3 % MOD, MOD) % MOD
}


fn main() {
    let line: Vec<usize> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let n = line[0];
    let k = line[1];
    let mut memo = vec![0i64; 400_010];
    memo[0] = 1;
    memo[1] = 1;
    for i in 2..memo.len() {
        memo[i] = (memo[i-1] * (i as i64)) % MOD;
    }

    let mut ans = 0;
    if k >= n-1 {
        ans = mod_comb((2 * n -1) as i64, (n-1) as i64, &memo);
    } else {
        for i in 0..k+1 {
            ans += mod_comb(n as i64, i as i64, &memo) * mod_comb((n - 1) as i64, i as i64, &memo) % MOD;
            ans %= MOD;
        }
    }
    println!("{}", ans);
}


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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

constexpr int INF = 1001001001;
std::string S, T;
std::vector<int> v;
int dp[500100];
int len_S, len_T, start;

std::vector<int> Z_Algorithm(std::string seq){
    auto s = seq.size();
    std::vector<int> res(s);
    res[0] = s;
 
    int i = 1, j = 0; // satisfying seq[0..j) = seq[i..i+j)
    while(i < s){
        while(i + j < s && seq[j] == seq[i+j]){
            j += 1;
        }
        res[i] = j;
        if(j == 0){
            i += 1;
            continue;
        }
        int k = 1;
        while(i + k < s && k + res[k] < j){
            res[i+k] = res[k];
            k += 1;
        }
        i += k;
        j -= k;
    }
 
    return res;
}

int rec(int i){
    if(dp[i] != -1){
        return dp[i];
    }

    dp[i] = INF;

    if(v[start+i] >= len_T){
        int j = (i + len_T) % len_S;

        return dp[i] = std::min(rec(j) + 1, INF);
    }

    return dp[i] = 0;
}

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

    std::cin >> S >> T;

    len_S = S.size();
    len_T = T.size();
    start = len_T + 1;

    T += '$';
    
    {
        int t = (len_T + len_S - 1) / len_S;

        for(int i=0;i<t;++i){
            T += S;
            T += S;
        }
    }

    v = std::move(Z_Algorithm(T));

    memset(dp, -1, sizeof(dp));

    int res = 0;

    for(int i=0;i<len_S;++i){
        if(dp[i] == -1){
            res = std::max(res, rec(i));
        }
    }

    if(res == INF){
        res = -1;
    }

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


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

int main(void)
{
    int N;
    cin >> N;

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

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

    vector<int> diff(N, 0);
    for (int i = 0; i < N; i++)
    {
        diff.at(i) = value.at(i) - cost.at(i);
        // cout << diff.at(i) << endl;
    }

    // 降順でソート with greater<int>()
    sort(diff.begin(), diff.end(), greater<int>());
    // for (int i = 0; i < N; i++)
    // {
    //     cout << diff.at(i) << endl;
    // }

    int max_diff = (diff.at(0) < 0 ? 0 : diff.at(0));
    int cmp_diff = 0;
    for (int i = 0; i < N; i++)
    {
        cmp_diff += diff.at(i);
        if (cmp_diff >= max_diff)
        {
            max_diff = cmp_diff;
        }
        else
            break;
    }

    cout << max_diff << endl;
    return (0);
}

Measured memory_bytes: 256
n,u,v=map(int,input().split())
ab=[list(map(int,input().split())) for i in range(n-1)]
data=[[] for i in range(n+1)]
for a,b in ab:
    data[a].append(b)
    data[b].append(a)
flag=[-1]*(n+1)
que=[u]
flag[u]=0
cnt=1
while que:
    h=[]
    for x in que:
        for y in data[x]:
            if flag[y]==-1:
                flag[y]=cnt
                h.append(y)
    cnt+=1
    que=h
flag_2=[-1]*(n+1)
que=[v]
flag_2[v]=0
cnt=1
start=0
ans=0
if flag[v]<=2:
    start=v
else:
    while que:
        h=[]
        for x in que:
            for y in data[x]:
                if flag_2[y]==-1:
                    flag_2[y]=cnt
                    h.append(y)
                    if flag[y]-flag_2[y]<=2:
                        ans=flag_2[y]
                        start=y
                        break
            else:
                continue
            break
        else:
            cnt+=1
            que=h
            continue
        break
que=[start]
if flag[v]%2==0:
    ans+=1
    h=[]
    for x in que:
        for y in data[x]:
            if flag_2[y]==-1 and flag[y]==ans:
                flag_2[y]=ans
                h.append(y)
    que=h
while que:
    ans+=1
    h=[]
    for x in que:
        for y in data[x]:
            if flag_2[y]==-1 and ans>flag[y]:
                flag_2[y]=ans
                h.append(y)
    que=h
print(ans-2)

Measured memory_bytes: 80472
#include <iostream>
using namespace std;
int main()
{
    char a,b,c,d,e,x;
    cin>>x;
    a='i',
    b='o';
    c='e';
    d='u';
    e='a';
    if (x==a or x==b or x==c or x==d or x==e)
    {
        cout<<"vowel";
    }
    else
    {
        cout<<"consonant";
    }

    return 0;
}

Measured memory_bytes: 256