akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.NoSuchElementException;
import java.util.Queue;
import java.util.Scanner;
import java.util.logging.Level;
import java.util.logging.Logger;

public class Main {
   
    static class aa{
	int r=1;	boolean t=false;
    }
    
    public static void main(String[] args) {
	
	Scanner sc = new Scanner(System.in);
	
	int N=sc.nextInt();
	int M=sc.nextInt();	
	
	aa[] a=new aa[N];
	for (int i = 0; i < N; i++) {
	    a[i]=new aa();
	}
	a[0].t=true;
	int aaaa=1;
	for (int i = 0; i < M; i++) {
	    int x=sc.nextInt();	    int y=sc.nextInt();

	    
	    if(a[x-1].t){
		if(!a[y-1].t){
		a[y-1].t=true;
		aaaa++;}
	    }
	    a[x-1].r--;
	    a[y-1].r++;
	    
	    if( a[x-1].r==0){
		if(a[x-1].t)
		    aaaa--;
		a[x-1].t=false;
		
	    }
	    
	    
		
	
	}
	
	System.out.println(aaaa);
    }
}

Measured memory_bytes: 85284
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int n;cin>>n;
  long long int count5=0,count2=0;
  long long int i=10;
  if(n%2!=0)
  {
    cout<<0<<endl;
    return 0;
  }
  while(i<=n)
  {
    count5+=n/i;
    i*=5;
  }
  i=2;
  while(i<=n)
  {
    count2+=n/i;
    i*=2;
  }
  if(count2<count5)
  	cout<<count2<<endl;
  else
    cout<<count5<<endl;
  return 0;
}

Measured memory_bytes: 256
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const Ld pi = M_PI;
const Int MOD = 1000000007;
const Int INF = 1LL << 61;

Int Floor(Int a, Int b) {
    return (a - (a % b)) / b;
}

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

    int n;
    cin >> n;

    for (int i = 0; i < 11; i++) {
        if (n <= i * 1000) {
            cout << i * 1000 - n << endl;
            return 0;
        }
    }

    return 0;
}

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

int main(){
  string a, b, c;
  cin >> a >> b >> c;
  char A,B,C;
  A = a.front();
  B = b.front();
  C = c.front();
  string ans[3];
  A -= 32;
  B -= 32;
  C -= 32;
  cout << A << B << C << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <complex>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define E 1e-6
#define INF 0x3f3f3f3f
#pragma comment(linker, "/STACK:1024000000,1024000000")
void open(){freopen("data.txt","r",stdin);}
void out(){freopen("out.txt","w",stdout);}
const int maxn = 101010;
const int MOD = 1e9 + 7;

int main()
{
    char str[100005];
    int num[26];
    int len,minn;
    scanf("%s",str);
    len=strlen(str);

    for(int i=0;i<len;i++)
    {
        num[str[i]-'a']=1;
    }

    char c;
    for(int i=0;i<26;i++)
    {
        if(num[i]==0)
        {
            c='a'+i;
            cout<<c<<endl;
            return 0;
        }
    }
    puts("None");
    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii;
typedef pair<ld,ld> id;
typedef tuple<ll,ll,ll> tl;
typedef tuple<ll,ll,ll,ll> ql;

#define FOR(i, a, b) for(ll i=(a); i<=(b); i++)
#define ROF(i, a, b) for(ll i=(a); i>=(b); i--)
#define MEM(x, v) memset(x, v, sizeof(x))
#define FILL(x, n, v) fill(x, x+n, v);
#define ALL(x) x.begin(), x.end()
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define f first
#define s second
#define ins insert
#define e emplace
#define eb emplace_back
#define ef emplace_front
#define p push
#define pf push_front
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define ft front
#define bk back
#define pp pop
#define ppb pop_back
#define ppf pop_front

#define db cout<<"YEET\n";
#define ct(x) cout<<x<<'\n';

const ll MOD = 1e9+7; //998244353
const ll MAXN = 2e5+5;
const ll INF = 1e18;
const ld PI = acos((ld)-1);

int main(){
    FAST
    ll n, ans[MAXN];
    MEM(ans, 0);
    cin >> n;
    FOR(i,1,n-1){
        ll x;
        cin >> x;
        ans[x]++;
    }
    FOR(i,1,n){
        cout << ans[i] << '\n';
    }
}

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

int main() {
  int n, k; cin >> n >> k;
  vector<int> c(n);
  rep(i,k) {
    int d; cin >> d;
    rep(j,d) {
      int a; cin >> a;
      a--;
      c[a]++;
    }
  }
  
  int count = 0;
  rep(i,n) {
    if (c[i] == 0) count++;
  }
  
  cout << count << endl;
  
  return 0;
      
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

ll n, m, color[100000], ans;
vector<int>g[100000];

bool vipartiteGraph(int node, int c) {
	color[node] = c;
	bool res = true;
	for (int i = 0; i < g[node].size(); i++) {
		if (color[g[node][i]] == INT32_MAX) {
			res = res && vipartiteGraph(g[node][i], (c+1)%2);
		}
		else if (color[g[node][i]] == c) {
			res = false;
		}
	}

	return res;
}

int main() {
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		g[a - 1].push_back(b - 1);
		g[b - 1].push_back(a - 1);
	}

	for (int i = 0; i < n; i++)color[i] = INT32_MAX;

	if (vipartiteGraph(0, 0)) {//二部グラフであったら
		//cout << "二部グラフである" << endl;

		ll brack = 0, white = 0;
		for (int i = 0; i < n; i++) {
			if (color[i] == 0)brack++;
			else white++;
		}
		ans = brack*white-m;
		//cout << "brack:" << brack << " white:" << white << endl;
	}
	else {//二部グラフでなかったら
		//cout << "二部グラフでない" << endl;
		ans = n*(n - 1) / 2 - m;
	}

	cout << ans << endl;
}

Measured memory_bytes: 6912
N = int(input())
words = []
for i in range(N):
  s = str(input())
  s_sort = ''.join(sorted([ch for ch in s]))
  words.append(s_sort)

words_sort = sorted(words)

counter = 0
target_word = ''
counts = []
for word in words_sort:
  if word == target_word:
    counter += 1
  else:
    counts.append(counter)
    counter = 1
    target_word = word

counts.append(counter)

from math import factorial

ans = 0
for cnt in counts:
  if cnt > 1:
    ans += factorial(cnt) // factorial(cnt-2) // 2

print(ans)

Measured memory_bytes: 12224
#include<bits/stdc++.h> 
using namespace std;
long long a, b, c, k;
int main(){
	scanf("%lld%lld%lld%lld", &a, &b, &c, &k);
	if(a>=k){
		printf("%lld", k);
	}
	else if(k>a&&k<=a+b){
		printf("%lld", a);
	}
	else if(k>a+b){
		printf("%lld", a+a+b-k);
	}
	return 0;
}

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

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#include<map>
#include<stack>
#include<queue>
#include<math.h>


using namespace std;


int main() {

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	long long int n;
	cin >> n;
	int arr[n][3];
	for (long long int i = 0; i < n; i++)
	{
		for (long long int j = 0; j < 3; j++)
			cin >> arr[i][j];
	}


	long long int dp[3];
	dp[0] = 0;
	dp[1] = 0;
	dp[2] = 0;
	long long int ans[3];
	ans[0] = 0;
	ans[1] = 0;
	ans[2] = 0;
	for (long long int i = 0; i < n; i++)
	{
		dp[0] = arr[i][0] + max(ans[1], ans[2]);

		dp[1] = arr[i][1] + max(ans[0], ans[2]);

		dp[2] = arr[i][2] + max(ans[0], ans[1]);
		ans[0] = dp[0];
		ans[1] = dp[1];
		ans[2] = dp[2];

	}

	cout << max(ans[0], max(ans[1], ans[2])) << endl;













	return 0;


}

Measured memory_bytes: 4824
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if(a+b==3)
        cout<<"3"<<endl;
    else if(a+b==4)
        cout<<"2"<<endl;
    else
        cout<<"1"<<endl;

    return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(' ').map { it.toInt() }
    val ans = IntArray(n) {0}
    a.forEach {
        ans[it - 1]++
    }
    println(ans.joinToString("\n"))
}

Measured memory_bytes: 73400
# C - pushpush

from collections import deque

n = int(input())
a = list(map(int, input().split()))

b = deque()

for i in range(n):
    if i % 2 == 0:
        b.append(a[i])
    else:
        b.appendleft(a[i])

if len(a) % 2 == 1:
    b = list(b)
    b = b[::-1]
    
print(*b)

Measured memory_bytes: 25412
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef string str;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9+7;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define pb(x) pop_back(x)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define sum(x) accumulate(all(x),0)
#define pc(x) __builtin_popcount(x)
#define gll greater<ll>()

ll n;

void solve(){
 cin >> n;
 vll v; 
 if(n<=5){
  cout << 2 << " " << 5 << " " << 63; 
  if(n>3) cout << " " << 20;
  if(n>4) cout << " " << 30;
   cout << endl;
   return;
 }
  
  set<ll> ans;
 
 rep(i,1,n/4+10){
   v.eb(6*i-4);
   v.eb(6*i-3);
   v.eb(6*i-2);
   v.eb(6*i);
 }
  
  sort(all(v));
  
 ll s=0;
  rep(i,0,n) {
    s+=v[i];
    ans.insert(v[i]);
  }
  
  if(s%6==2){
   rep(i,n,n+6) if(v[i]%6==0) {
    ans.erase(ans.find(8)); 
    ans.insert(v[i]);  
     break;
   }
  }else if(s%6==3){
   rep(i,n,n+6) if(v[i]%6==0) {
     ans.erase(ans.find(9)); 
    ans.insert(v[i]);  
     break;
   }
   }else if(s%6==5){
   rep(i,n,n+6) if(v[i]%6==4) {
     ans.erase(ans.find(9)); 
    ans.insert(v[i]);  
     break;
   }
  }
  

  auto y=*ans.rbegin();
  
  for(auto x:ans) {
    cout << x;
  if(y!=x) cout << " ";
  else cout << endl;
  }
  
}  
int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  solve();
}

Measured memory_bytes: 4576
#include <iostream>
#include <string>
#include <list>
#include <vector>

using namespace std;

int main(int argc, char* argv[]) {
    int n, key;
    string cmd;
    cin >> n;

    list<int> lst;
    for (int i = 0; i < n; i++){
        cin >> cmd;
        if (cmd == "insert"){
            cin >> key;
            lst.push_front(key);
        }else if (cmd == "delete"){
            cin >> key;
            for (auto itr = lst.begin(); itr != lst.end(); itr++){
                if (*itr == key){
                    lst.erase(itr);
                    break;
                }
            }
        }else if (cmd == "deleteFirst") lst.pop_front();
        else if (cmd == "deleteLast") lst.pop_back();
    }

    for (auto itr = lst.begin(); itr != --(lst.end()); itr++) cout << *itr << " ";
    cout << *(--lst.end()) << "\n";
    return 0;
}



Measured memory_bytes: 34388
#include <stdio.h>
#include <queue>
using namespace std;
queue<int>q;
int n, f, ans;
char ins[200][201];
int s[200][200];
int v[200];
void dfs(int a, int b) {
	for (int i = 0; i < n; i++) {
		if (s[a][i] && v[i] == 2 && i != b) {
			v[i] = 1 - v[a];
			dfs(i, a);
		}
	}
}
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf(" %s", ins[i]);
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			s[i][j] = ins[i][j] - '0';
		}
	}
	for (int i = 1; i < n; i++)v[i] = 2;
	dfs(0, -1);
	f = 1;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (s[i][j] && v[i] == v[j])f = 0;
		}
	}
	if (f == 0) {
		printf("-1\n");
		return 0;
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++)v[j] = 0;
		v[i] = 1;
		q.push(i);
		while (!q.empty()) {
			f = q.front();
			q.pop();
			for (int j = 0; j < n; j++) {
				if (s[f][j] && v[j] == 0) {
					v[j] = v[f] + 1;
					q.push(j);
				}
			}
		}
		for (int j = 0; j < n; j++) {
			if (v[j] > ans)ans = v[j];
		}
	}
	printf("%d\n", ans);
}

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

#define int long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)
 
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
 
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
 
#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/
 
// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}
#ifdef _DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
#endif

signed main() {
    
    int x;
    cin >> x;
    if(x<1200) cout << "ABC" << endl;
    else cout << "ARC" << endl;
    
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <iterator>
#include <algorithm>
#include <string>
#include <map>
#include <list>
using namespace std;

int main() {
  int h,w;
  cin >> h >> w;
  char s[h+1][w+1];
  for(int i=0; i<h; ++i){
    for(int j=0; j<w; ++j){
      cin >> s[i][j];
    }
  }

  int num=0;
  for(int i=0; i<h; ++i){
    for(int j=0; j<w; ++j){
      if(s[i][j]=='#')++num;
    }
  }

  if(num==h+w-1){
    cout << "Possible" << endl;
  }else{
    cout << "Impossible" << endl;
  }
}



Measured memory_bytes: 3516
n=int(input())
a=list(map(int,input().split()))
t=int(input())
b=list(map(int,input().split()))
a=sorted(a)

import bisect
cnt=0
for i in b:
    x=bisect.bisect_left(a,i)
    if x!=n and i==a[x]:
        cnt+=1
print(cnt)


Measured memory_bytes: 16708
python -cH,W,A,B=`tr \  ,`';M=10**9+7;C=1
for I in range(1,H):Z=C=C*(W+H-B+~I)*pow(I,M-2,M)%M
for I in range(1,H-A):C=C*(B-1+I)*(H-I)*pow(I*(W+H-B+~I),M-2,M)%M;Z+=C
print Z%M'

Measured memory_bytes: 6724
#include <iostream>
#include <string>
#include <vector>
#include<algorithm>
#include <stdio.h>
#include <bitset>
using namespace std;
typedef long long ll;

int main() {
	string s;
	int ans=0;
	int i = 1;
	cin >> s;
	string before,now;
	before += s[0];
	while (i < s.length()) {
		now += s[i];
		if (before != now) {
			ans++;
			before = now;
			now = "";
		}
		
		
		i++;
	}
	ans++;
	cout << ans << endl;
	
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

// 参考 http://drken1215.hatenablog.com/entry/2019/05/13/112000

map<int, int> mp;
void prime_factorize(int n) { // n <= 10^12も考慮 今回の問題には関係ない
    int tmp = n;
    for (int i = 2; i * i <= n; ++i) {
        int cnt = 0;
        while (tmp % i == 0) {
            tmp /= i;
            cnt++;
        }
        if (cnt) mp[i] += cnt;
    }
    if (tmp != 1) mp[tmp]++;
    
}

// 素因数列を前から走査
int dfs(map<int, int>::iterator p, int mul) { // 引数にこれまでの積, 返り値に個数
    if (p == mp.end()) { // 最下層 なかったら終わらない
        if (mul == 1) return 1; // ちょうど75で割り切れた
        return 0;
    }
    
    int res = 0;
    rep(i, p->S + 1) {
        if (mul % (i + 1) != 0) continue; // 75を割っていくが, 割り切れないのはとばす
        res += dfs(++p, mul / (i + 1));
        --p; // 戻さないと今のi + 1でp増えちゃってる
    }
    
    return res;
}

int main() {
    int n;
    cin >> n;
    
    rep3(i, 1, n + 1) prime_factorize(i);
    // for (auto e : mp) cout << e.F << " " << e.S << endl;
    
    // 約数の個数75に限らずdfsできる
    cout << dfs(mp.begin(), 75) << endl;
}


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

int main(){
  int n, x;
  cin >> n >> x;
  int l[n];
  rep(i,n){
    cin >> l[i];
    if(i!=0)
      l[i]+=l[i-1];
  }
  int ans =0;
  rep(i,n)
    if(l[i]<=x)
      ans++;
  cout << ans+1 << endl;
  
}

Measured memory_bytes: 3608
x, n = gets.split.map(&:to_i)
ps = gets.split.map(&:to_i)

sorted_ps = ps.sort

answer = nil

(0..100).each do |num|
  break if answer

  if sorted_ps.bsearch { |y| y >= (x - num) } != x - num
    answer =  x - num
  elsif sorted_ps.bsearch { |y| y >= (x + num) } != x + num
    answer =  x + num
  end
end

puts answer


Measured memory_bytes: 14380
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
struct Words{
    string s;
    int a[26];
}w[55];
int main()
{
    int n;
    string s;
    cin>>n;
    for(int i = 0; i < n; i++){
        cin>>s;
        int len = s.size();
        for(int j = 0; j < len; j++){
            if(s[j] == 'a')w[i].a[0]++;
            if(s[j] == 'b')w[i].a[1]++;
            if(s[j] == 'c')w[i].a[2]++;
            if(s[j] == 'd')w[i].a[3]++;
            if(s[j] == 'e')w[i].a[4]++;
            if(s[j] == 'f')w[i].a[5]++;
            if(s[j] == 'g')w[i].a[6]++;
            if(s[j] == 'h')w[i].a[7]++;
            if(s[j] == 'i')w[i].a[8]++;
            if(s[j] == 'j')w[i].a[9]++;
            if(s[j] == 'k')w[i].a[10]++;
            if(s[j] == 'l')w[i].a[11]++;
            if(s[j] == 'm')w[i].a[12]++;
            if(s[j] == 'n')w[i].a[13]++;
            if(s[j] == 'o')w[i].a[14]++;
            if(s[j] == 'p')w[i].a[15]++;
            if(s[j] == 'q')w[i].a[16]++;
            if(s[j] == 'r')w[i].a[17]++;
            if(s[j] == 's')w[i].a[18]++;
            if(s[j] == 't')w[i].a[19]++;
            if(s[j] == 'u')w[i].a[20]++;
            if(s[j] == 'v')w[i].a[21]++;
            if(s[j] == 'w')w[i].a[22]++;
            if(s[j] == 'x')w[i].a[23]++;
            if(s[j] == 'y')w[i].a[24]++;
            if(s[j] == 'z')w[i].a[25]++;
        }
    }
    for(int i = 0; i < 26; i++){
        int count = 999;
        for(int j = 0; j < n; j++){
            count = min(w[j].a[i], count);
        }
        for(int j = 0; j < count; j++)printf("%c", 'a'+i);
    }


    return 0;
}


Measured memory_bytes: 256
# abc150_b.py
# https://atcoder.jp/contests/abc150/tasks/abc150_b

# B - Count ABC /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 200点

# 問題文
# 英大文字のみからなる長さ Nの文字列 Sがあります。
# Sの連続する部分列 (入出力例をご覧ください) として ABC がいくつ含まれるかを求めてください。

# 制約
#     3≤N≤50
#     Sは英大文字のみからなる。

# 入力
# 入力は以下の形式で標準入力から与えられる。
# N
# S

# 出力
# Sが連続する部分列として含む ABC の個数を出力せよ。

# 入力例 1
# 10
# ZABCDBABCQ

# 出力例 1
# 2

# Sの 2 文字目から 4 文字目、および 7 文字目から 9 文字目の 2箇所の連続する部分列が ABC に一致しています。

# 入力例 2
# 19
# THREEONEFOURONEFIVE

# 出力例 2
# 0

# Sは ABC に一致する連続する部分列を含みません。

# 入力例 3
# 33
# ABCCABCBABCCABACBCBBABCBCBCBCABCB

# 出力例 3
# 5


global FLAG_LOG
FLAG_LOG = False


def log(value):
    # FLAG_LOG = True
    # FLAG_LOG = False
    if FLAG_LOG:
        print(str(value))


def calculation(lines):
    S = lines[1]
    N = int(lines[0])
    # N, M = list(map(int, lines[0].split()))
    # values = list(map(int, lines[1].split()))
    # values = list(map(int, lines[2].split()))
    # values = list()
    # for i in range(N):
    #     values.append(int(lines[i]))
    # valueses = list()
    # for i in range(N):
    #     valueses.append(list(map(int, lines[i+1].split())))

    result = 0
    for n in range(N-2):
        if S[n:n+3] == 'ABC':
            result += 1

    return [result]


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['10', 'ZABCDBABCQ']
        lines_export = [2]
    if pattern == 2:
        lines_input = ['19', 'THREEONEFOURONEFIVE']
        lines_export = [0]
    if pattern == 3:
        lines_input = ['33', 'ABCCABCBABCCABACBCBBABCBCBCBCABCB']
        lines_export = [5]
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    global FLAG_LOG
    if len(args) == 1:
        mode = 0
        FLAG_LOG = False
    else:
        mode = int(args[1])
        FLAG_LOG = True
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(2)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理
if __name__ == '__main__':
    main()


Measured memory_bytes: 9192
use std::cmp::Reverse;
use std::collections::{BinaryHeap, HashMap};

use proconio::input;

fn solve(target: i64, a: u128, b: u128, c: u128, d: u128) {
    let mut heap = BinaryHeap::new();
    let mut best = HashMap::new();
    heap.push((Reverse(0), target));
    best.insert(target, 0);

    fn push(
        heap: &mut BinaryHeap<(Reverse<u128>, i64)>,
        best: &mut HashMap<i64, u128>,
        m: i64,
        cost: u128,
    ) {
        let now_best = best.entry(m).or_insert(std::u128::MAX);
        if cost < *now_best {
            *now_best = cost;
            heap.push((Reverse(cost), m));
        }
    }

    while let Some((Reverse(cost), n)) = heap.pop() {
        if n == 0 {
            println!("{}", cost);
            return;
        }
        if n < 0 {
            continue;
        }
        if n % 2 == 0 {
            let m = n / 2;
            let cost = cost + a.min(m as u128 * d);
            push(&mut heap, &mut best, m, cost);
        } else {
            push(&mut heap, &mut best, n - 1, cost + d);
            push(&mut heap, &mut best, n + 1, cost + d);
        }
        if n % 3 == 0 {
            let m = n / 3;
            let cost = cost + b.min((m * 2) as u128 * d);
            push(&mut heap, &mut best, m, cost);
        } else if n % 3 == 1 {
            push(&mut heap, &mut best, n - 1, cost + d);
            push(&mut heap, &mut best, n + 2, cost + d * 2);
        } else {
            push(&mut heap, &mut best, n - 2, cost + d * 2);
            push(&mut heap, &mut best, n + 1, cost + d);
        }
        if n % 5 == 0 {
            let m = n / 5;
            let cost = cost + c.min((m * 4) as u128 * d);
            push(&mut heap, &mut best, m, cost);
        } else if n % 5 == 1 {
            push(&mut heap, &mut best, n - 1, cost + d);
            push(&mut heap, &mut best, n + 4, cost + d * 4);
        } else if n % 5 == 2 {
            push(&mut heap, &mut best, n - 2, cost + d * 2);
            push(&mut heap, &mut best, n + 3, cost + d * 3);
        } else if n % 5 == 3 {
            push(&mut heap, &mut best, n - 3, cost + d * 3);
            push(&mut heap, &mut best, n + 2, cost + d * 2);
        } else {
            push(&mut heap, &mut best, n - 4, cost + d * 4);
            push(&mut heap, &mut best, n + 1, cost + d);
        }
    }
}

fn main() {
    input! {
        t: u64,
        cases: [(i64, u128, u128, u128, u128); t],
    };

    for case in cases {
        solve(case.0, case.1, case.2, case.3, case.4);
    }
}


Measured memory_bytes: 8292
#define CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include<string>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
#include<math.h>
#include<vector>
#include<utility>
#include<functional>
#include<iostream>
#define sqr(x) x*x
bool flg=false;
using namespace std;

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b;
	double x;
	string s;
	cin >> a>>b;
	s = to_string(a) + to_string(b);
	a = stoi(s);
	x = sqrt((double)a);
	if (x-(int)x>0) {
		cout << "No\n";
	}
	else
	{
		cout << "Yes\n";
	}
	
	return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())

if N == 0 or M == 0 or N == 2 or M == 2:
    print("0")
elif N == 1 and M == 1 :
    print("1")
elif N == 1 :
    print(M - 2)
elif M == 1 :
    print(N - 2)
elif N <= 2 or M <= 2:
    print((N - 2) * 2 + (M - 2) * 2)
else :
    print((N - 2) * (M - 2))
    


Measured memory_bytes: 3060
#include <bits/stdc++.h>
 
using namespace std;
 
#define N 20
 
int v[N + 1];
int c[N + 1];
 
int main(){
	int ans, n, i;
 
	scanf("%d", &n);
 
	for (i = 1; i <= n; i++){
		scanf("%d", v + i);
	}
 
	for (i = 1; i <= n; i++){
		scanf("%d", c + i);
	}
 
	ans = 0;
 
	for (i = 1; i <= n; i++){
		if (v[i] > c[i]){
			ans += v[i] - c[i];
		}
	}
 
	printf("%d\n", ans);
 
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int *compute_table(const string &t) {
	int m = t.size();
	int *table = new int[m + 1];
	table[0] = -1;
	int j = -1;
	for (int i = 0; i < m; i++) {
		while (j >= 0 && t[i] != t[j]) j = table[j];
		j++;
		table[i + 1] = j;
	}
	return table;
}
vector<int> string_match(const string &s, const string &t) {
	int n = s.size();
	int m = t.size();
	int *table = compute_table(t);
	vector<int> ans;
	int i = 0, j = 0;
	while (i < n) {
		if (s[i] == t[j]) {
			i++; j++;
			if (j == m) {
				ans.push_back(i - m);
				j = table[j];
			}
		}
		else if (j > 0) j = table[j];
		else i++;
	}
	delete[] table;
	return ans;
}
int main() {
	string S, T;
	cin >> S >> T;
	vector<int> ans = string_match(S, T);
	for (int i = 0; i < ans.size(); i++) {
		cout << ans[i] << endl;
	}
}

Measured memory_bytes: 8312
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF = 2e9
#define LINF = 1e18
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
#define dump(x) cout << #x << "=" << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO")
#define Yes(n) cout << ((n) ? "Yes" : "No")

int main(){
    
    while(1){
        int n, x;
        cin >> n >> x;
        if(n == 0 && x == 0)return 0;
        int cnt = 0;
        for(int i = 1; i <= n; ++i){
            for(int j = i+1; j <= n; ++j){
                for(int k = j+1; k <= n; ++k){
                    if(i+j+k == x){
                        cnt++;
                    }
                }
            }
        }
        cout << cnt << endl;
    }

}


Measured memory_bytes: 3092
# https://www.slideshare.net/hcpc_hokudai/advanced-dp-2016 動的計画法の問題の解説がされている 神

# これが比較的わかりやすいかも https://algo-logic.info/bit-dp/

'''
定式化(本は"集める"DPで定義してるが、わかりやすさのため"配る"DPで定式化)

ノーテーション
S ... 頂点集合
| ... 和集合演算子
dp[S][v] ... 重みの総和の最小。頂点0から頂点集合Sを経由してvに到達する。

更新則
dp[S|{v}] = min{dp[S][u]+d(u,v) | u∈S} ただしv∉S

初期条件
dp[∅][0] = 0 #Vはあらゆる集合
dp[V][u] = INF #ほかはINFで初期化しておく

答え
dp[すべての要素][0] ... 0からスタートしてすべての要素を使って最後に0に戻るための最小コスト
'''

# verify https://onlinejudge.u-aizu.ac.jp/courses/library/7/DPL/all/DPL_2_A
INF = 2 ** 31
from itertools import product


def solve(n, graph):
    '''nは頂点数、graphは隣接行列形式'''
    max_S = 1 << n  # n個のbitを用意するため
    dp = [[INF] * n for _ in range(max_S)]
    dp[0][0] = 0
    for S in range(max_S):
        for u, v in product(range(n), repeat=2):
            if (S >> v) & 1 == 1:  # vが訪問済みの場合は飛ばす
                continue
            dp[S | (1 << v)][v] = min(dp[S | (1 << v)][v],
                                      dp[S][u] + graph[u][v])
    print(dp[-1][0] if dp[-1][0] != INF else -1)


# # 入力例
# n = 5
# graph = [[INF, 3, INF, 4, INF],
#          [INF, INF, 5, INF, INF],
#          [4, INF, INF, 5, INF],
#          [INF, INF, INF, 0, 3],
#          [7, 6, INF, INF, INF]]
# solve(n, graph)


# verify用
n, e = map(int, input().split())
graph = [[INF] * n for _ in range(n)]
for _ in range(e):
    s, t, d = map(int, input().split())
    graph[s][t] = d
solve(n, graph)



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

int main()
{
   int x;
   cin >> x ;
   if(x < 600) cout << "8" << endl;
   else if(x < 800) cout << "7" << endl;
   else if(x < 1000) cout << "6" << endl;
   else if(x < 1200) cout << "5" << endl;
   else if(x < 1400) cout << "4" << endl;
   else if(x < 1600) cout << "3" << endl;
   else if(x < 1800) cout << "2" << endl;
   else if(x < 2000) cout << "1" << endl;
   return 0;
}

Measured memory_bytes: 3588
#include<stdio.h>

#define MAX 100
#define INF 1000000000

int n,p[MAX+1],m[MAX+1][MAX+1];

int min(int m,int q){
  if(m <= q)return m;
  else return q;
}

void matrixChainOrder(){
  int i,j,k,l,q,length;

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

  for(l = 2; l <= n; l++){
    for(i = 1; i <= n - l + 1; i++){
      j = i + l - 1;
      m[i][j] = INF;
      for(k = i; k <= j - 1; k++){
        q = m[i][k] + m[k+1][j] + p[i-1] * p[k] * p[j];
        m[i][j] = min(m[i][j],q);
      }
      
    }
    
  }
  /*for(i = 1; i <=n; i++){
    for(j = 1; j <= n; j++ ){
      printf("%d",m[i][j]);
    }
    printf("\n");
    }*/
}

int main(){
  int i,j;

  scanf("%d",&n);

  for(i = 1; i < n+1; i++)scanf("%d %d",&p[i-1],&p[i]);
  
  matrixChainOrder();
  
  printf("%d\n",m[1][n]);
  
  return 0;
}


Measured memory_bytes: 2108
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>
using namespace std;

int main(){
    int h, w, n;
    cin >> h >> w >> n;
    int board[h][w];
    vector<int> A(n+1);
    for (int i = 1; i <= n; i++) {
        cin >> A[i];
    }
    int index = 1;
    for (int i = 0; i < h; i++) {
        if(i%2==0){
            for (int j = 0; j < w; j++) {
                board[i][j] = index;
                A[index]--;
                if(A[index]==0) index++;
            }
        }
        else{
            for (int j = w-1; j >= 0; j--) {
                board[i][j] = index;
                A[index]--;
                if(A[index]==0) index++;
            }
        }
    }
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if(j) cout << " ";
            cout << board[i][j] ;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}
#define _cTime (chrono::system_clock::now())
#define progress (chrono::duration_cast<chrono::milliseconds>(_cTime-_sTime).count())
#define reset _sTime=_cTime
auto reset;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,a,b,c,ans=INF;
	cin>>n>>a>>b>>c;
	vl v(n);
	rep(i,n)cin>>v[i];
	rep(i,1<<(2*n)){
		int tmp=0;
		vl aa,bb,cc;
		rep(j,n){
			if((i&(1<<(2*j)))&&(i&(1<<(2*j+1))))aa.push_back(v[j]);
			else if(i&(1<<(2*j)))bb.push_back(v[j]);
			else if(i&(1<<(2*j+1)))cc.push_back(v[j]);
		}
		if(aa.size()==0||bb.size()==0||cc.size()==0)continue;
		ll asum=0,bsum=0,csum=0;
		rep(j,aa.size())asum+=aa[j];
		tmp+=abs(asum-a)+(aa.size()-1)*10;
		rep(j,bb.size())bsum+=bb[j];
		tmp+=abs(bsum-b)+(bb.size()-1)*10;
		rep(j,cc.size())csum+=cc[j];
		tmp+=abs(csum-c)+(cc.size()-1)*10;
		chmin(ans,tmp);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>
#include <cstring>

using namespace std;

typedef pair<int, int> P;
#define mp make_pair
#define FOR(i, a, b) for(int (i)=a;(i)<(b);++(i))
#define rep(i, n)  FOR(i,0,n)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort((v).begin(), (v).end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define all(c) (c).begin(),(c).end()
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define Print(p) cout<<(p)<<endl
#define F first
#define S second
#define pb push_back
#define mod 1000000007LL
#define INF 105000000000

const int maxn = 1e5 + 10;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int a, b, c; cin >> a >> b >> c;
	if ((10 * b + c) % 4 == 0) YES;
	else NO;

	return 0;
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, n) for(ll i = 1; i <= ll(n); i++)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); i++)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); i++)
#define all(v) v.begin(), v.end()
//bool chmin(ll & a, ll  b) { if (b < a) { a = b; return 1; } return 0; }
//bool chmax(ll & a, ll b) { if (b > a) { a = b; return 1; } return 0; }
const ll INF = 999999999999999;
const ll MOD = 1000000007;
const ll MAX_N=500010;
ll N, ans=0;
int main() {
  cin >> N;
  vl vec(N);
  rep(i, N) cin >> vec[i];

  set<ll> S;
  rep(i, N) S.insert(vec[i]);
  
  cout << S.size() << endl;
  return 0;
}

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

int main() {
 string S;
  cin >> S;
  if (S.at(0) == S.at(1) && S.at(1) == S.at(2)){
   cout << "No" << endl; 
  }
  else{
   cout << "Yes" << endl; 
  }
  
}


Measured memory_bytes: 256
# coding: utf-8

import sys
def input(): return sys.stdin.readline().strip()

# N = int(input())
N, X = map(int, input().split())
L = [int(x) for x in input().split()]
# S = input()

ans = [0]
for i, l in enumerate(L):
    ans.append(ans[i] + l)

aa = 0
for a in ans:
    if a <= X:
        aa += 1

print(aa)


Measured memory_bytes: 38384
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
#include <sstream>
#include <string>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <limits>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <fstream>
#include <iterator>
#include <random>
#include <chrono>


#define forr(i,start,count) for (int i = (start); i < (start)+(count); ++i)
#define set_map_includes(set, elt) (set.find((elt)) != set.end())
#define readint(i) int i; cin >> i
#define readll(i) ll i; cin >> i
#define readdouble(i) double i; cin >> i
#define readstring(s) string s; cin >> s

typedef long long ll;

using namespace std;

ll modd = 1000 * 1000 * 1000 + 7;


int main()   {

      ios_base::sync_with_stdio(false);

      cout.precision(17);
      mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
      uniform_int_distribution<int> rand_gen(0, modd);   // rand_gen(rng) gets the rand no


//    readint(test_cases);
    int test_cases = 1;
    forr(t, 1, test_cases) {
        readint(n);
        vector<bool> a;
        forr(i,0,n) {
            readint(b); readint(bb);
            a.push_back(b==bb);
        }
        bool three = false;
        forr(i,0,n-2) {
            three = a[i] && a[i+1] && a[i+2];
            if (three) {break;}
        }
        cout << (three ? "Yes" : "No") << endl;

    }
    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

class UnionFind {
public:
    vl parent;  // 親ノード
    vl Siz;  // 集合の大きさ
    
    // コンストラクタ
    UnionFind(ll n): parent(n), Siz(n, 1) {
        rep(i, n) {
            parent[i] = i;
        }
    }

    // n要素で初期化
    void init(ll n) {
        parent.resize(n);
        Siz.assign(n, 1);
        rep(i, n) {
            parent[i] = i;
        }
    }

    // xの属する集合の根を求める
    ll root(ll x) {
        if(parent[x] == x) {
            return x;
        }
        else {
            return parent[x] = root(parent[x]);
        }
    }

    // xとyの属する集合を併合
    void unite(ll x, ll y) {
        x = root(x);
        y = root(y);
        if(x == y) {
            return;
        }
        if(Siz[x] < Siz[y]) {
            swap(x, y);
        }
        Siz[x] += Siz[y];
        parent[y] = x;
    }
    
    // xとyが同じ集合に属するかどうか
    bool same(ll x, ll y) {
        return root(x) == root(y);
    }

    // xの属する集合の要素数を求める
    ll size(ll x) {
        return Siz[root(x)];
    }
};

int main() {
    ll n, m;
    cin >> n >> m;

    UnionFind Uni(n);
    Uni.init(n);
    vl a(m), b(m), c(m);
    rep(i, m) {
        cin >> a[i] >> b[i] >> c[i];
        a[i]--;  b[i]--;
        c[i] *= -1;
        Uni.unite(a[i], b[i]);
    }

    // ベルマンフォード法。計算量はO(V*E)
    vl dist(n, INF);  // dist[v] : 頂点svから頂点vへの最短距離
    const ll sv = 0;  // 始点となる頂点。デフォルトでは0
    dist[sv] = 0;
    rep(loop, n-1) {
        rep(i, m) {
            if(dist[a[i]] == INF) {
                continue;
            }
            if(dist[b[i]] > dist[a[i]] + c[i]) {
                dist[b[i]] = dist[a[i]] + c[i];
            }
        }
    }

    vl negativeCycle(n);  // negativeCycle[v] : 頂点vを含む負閉路があるとき1
    rep(loop, n) {
        rep(i, m) {
            if(dist[a[i]] == INF) {
                continue;
            }
            if(dist[b[i]] > dist[a[i]] + c[i]) {
                dist[b[i]] = dist[a[i]] + c[i];
                negativeCycle[b[i]] = 1;
            }
            if(negativeCycle[a[i]]) {
                negativeCycle[b[i]] = 1;
            }
        }
    }

    if(negativeCycle[n-1]) {
        out("inf");
    }
    else {
        out(-dist[n-1]);   
    }
    
    re0;
}

Measured memory_bytes: 384
use std::io::*;
use std::str::*;

pub fn read_from<T: FromStr, R: Read>(s: &mut R) -> T {
    let s = s.bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    if !s.is_empty() {
        if let Ok(s) = s.parse::<T>() {
            s
        } else {
            panic!("faild to parse {}", s);
        }
    } else {
        if cfg!(local) {
            // eprintln!("reached to EOF");
        }
        std::process::exit(0)
    }
}

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let mut stdin = stdin.lock();
    read_from(&mut stdin)
}

pub fn readn<T: FromStr>(n: usize) -> Vec<T> {
    let stdin = stdin();
    let mut stdin = stdin.lock();
    (0..n).map(|_| read_from(&mut stdin)).collect()
}

fn calc(c: char) -> usize {
    if c == '1' {
        1
    } else {
        2e18 as usize
    }
}

fn main() {
    let s: Vec<char> = read::<String>().chars().collect();
    let n = s.len();
    let k: usize = read();
    let k = k - 1;
    let mut len = 0;
    let mut ans = '?';
    for i in 0..n {
        let next = len + calc(s[i]);
        if len <= k && k < next {
            ans = s[i];
            break;
        }
        len = next;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define mod 1000000007
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
void yes() { cout << "Yay!" << endl; }
void no() { cout << ":(" << endl; }
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y)* mod_pow(kai(y, y), mod - 2, mod) % mod;
}
struct edge { int to, cost; };
int n, k, r, s, p;
string t;
char ans[114514];
signed main() {
	cin >> n >> k >> r >> s >> p;
	cin >> t;
	int ta = 0;
	rep(i, n) {
		if (t[i] == 'r')ans[i] = 'p';
		else if (t[i] == 's')ans[i] = 'r';
		else ans[i] = 's';
	}
	for (int i = k; i < n; i++) {
		if (ans[i] == ans[i - k])ans[i] = 'a';
	}
	rep(i, n) {
		if (ans[i] == 'p')ta += p;
		else if (ans[i] == 's')ta += s;
		else if (ans[i] == 'r')ta += r;
	}
	cout << ta << endl;
	ggr
}


Measured memory_bytes: 512
# include <stdio.h>
int main()
{
	int a[10000];
	int q;
	int n;
	scanf("%d",&n);
	for(int i = 0;i < n; i++)
		scanf("%d",&a[i]);
	scanf("%d",&q);
	int num = 0;
	for(int i = 0; i < q; i++)
	{
		int ccc;
		scanf("%d", &ccc);
		a[n] = ccc;
		int j = 0;
		while(a[j] != ccc)
			j++;
		if(j != n)	num++;
	}
	printf("%d\n",num);
 } 


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

int main(){
    // input
    int N; cin >> N;
    vector<int> V(N);
    for(int i=0; i<N; ++i){
        cin >> V[i];
    }
    vector<int> C(N);
    for(int i=0; i<N; ++i){
        cin >> C[i];
    }

    // compute
    int ans = 0;
    for(int i=0; i<N; ++i){
        if(V[i] > C[i]){
            ans += V[i] - C[i];
        }
    }

    // output
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define double long double
//↓TLE,MLE魔!!!
#define int long long
//↑TLE,MLE魔!!!
#define inf 1000000007 //10^9+7
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
signed main() {
	int x;
	cin>>x;
	if(x<1200)puts("ABC");
	else puts("ARC");
}


Measured memory_bytes: 256
import collections
n = int(input())
d = list(map(int,input().split()))
dc = collections.Counter(d)

m = int(input())
t = list(map(int,input().split()))
dt = collections.Counter(t)

for k,v in dt.items():
    if dc[k] < v:
        print("NO")
        exit()

print("YES")

Measured memory_bytes: 57056
#include <iostream>

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

        auto ans = 0;
        for (auto i = 1; i <= n; i += 2) {
                auto yn = 0;
                for (auto j = 2; j < n / 2 + 1; ++j) {
                        if (i % j == 0) {
                                ++yn;
                        }
                        if (yn > 6) {
                                break;
                        }
                }
                if (yn == 6) {
                        ++ans;
                }
        }
        std::cout << ans << std::endl;
        return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);

int main()
{
  
      #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
 fast;
string s;
cin>>s;
int n=s.length(),  cnt=0, maxi=0;
for(int i=0; i<n; i++)
{
	if(s[i]=='R')
		cnt++;
	else
	{
		maxi=max(maxi,cnt);
		cnt=0;
	}
}
maxi=max(maxi,cnt);
cout<<maxi<<"\n";
}

Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>
 
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n; i > 0; i--)
 
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;
 
int main(){
	int h,w;
	cin>>h>>w;
	vector<string> a;
	rep(i,h){
		string s;
		cin>>s;
		bool flg=false;
		rep(j,w){
			if(s[j]!=*"."){
				flg=true;
			}
		}
		if(flg){
			a.push_back(s);
		}
	}
	vector<string> b(a.size());
	rep(i,w){
		bool flg=false;
		rep(j,a.size()){
			if(a[j][i]!=*"."){
				flg=true;
			}
		}
		if(flg){
			rep(j,a.size()){
				b[j]+=a[j][i];
			}
		}
	}
	rep(i,b.size()){
		cout<<b[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 256