akhauriyash/Code-Regression huggingface dataset:
#include<string.h>
#include<stdio.h>

//出力、比較のためソート用の配列は外部変数
char bub[36][3];
char sel[36][3];
//入力数確認
int val;

void bubble(void){
  int s,i;
  char tmp[3];

  for(i = 0;i < val;i++){
    for(s = val-1;s > i;s--){
      if(bub[s][1]<bub[s-1][1]){
	strcpy(tmp,bub[s-1]);
	strcpy(bub[s-1],bub[s]);
	strcpy(bub[s],tmp);
      }
    }
  }
}

void select(void){
  int s,i,cmp;
  char tmp[3];
  
  for(i = 0;i < val;i++){
    cmp = i;
    for(s=i+1;s<val;s++){
      if(sel[s][1]<sel[cmp][1])
	cmp = s;
    }
    strcpy(tmp,sel[i]);
    strcpy(sel[i],sel[cmp]);
    strcpy(sel[cmp],tmp);
  }
}

int main(){
  
  //比較のフラグ
  int flg = 0;
  int j; 
  char scn[36][3];
  char kind[4];  

  scanf("%d",&val);
  
  for(j = 0;j < val;j++){
    scanf("%s",scn[j]);
    strcpy(bub[j],scn[j]);
    strcpy(sel[j],scn[j]);
  }

  //バブルソート
  bubble(); 
  for(j = 0;j < val - 1;j++)
    printf("%s ",bub[j]);
  printf("%s\n",bub[j]);
  //バブルソートは後ろから順番に並び替えられてゆき、同じ数字の時に順番が入れ替わらないので絶対に安定
  printf("Stable\n");
    
  //選択ソート
  select(); 
  for(j = 0;j < val - 1;j++)
    printf("%s ",sel[j]);
  printf("%s\n",sel[j]);

  //絶対安定のバブルソートと比較すれば良い
  for(j = 0;j < val;j++){
    if(strcmp(sel[j],bub[j]) != 0){
      flg = 1;
      break;
    }
  }
   
  if(flg == 0)printf("Stable\n");
  else printf("Not stable\n");
  
  return 0;
}

Measured memory_bytes: 620
#include<bits/stdc++.h>
#define eps 1e-9
#define MOD 1000000007;
#define INV_10 299473306;
using namespace std;
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int a, b, c;
	cin >> a >> b >> c;
	cout << c << ' ' << a << ' ' << b << '\n';
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
const long long mod = 1000000007;
int main() {
	int H, W;
	scanf("%d %d", &H, &W);
	char S[H][W];
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) scanf(" %c", &S[i][j]);
	}
	int apsp[H * W][H * W];
	for (int i = 0; i < H * W; ++i) {
		for (int j = 0; j < H * W; ++j) apsp[i][j] = mod;
	}
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			for (int k = 0; k < H; ++k) {
				for (int l = 0; l < W; ++l) {
					if (i == k && j == l) apsp[i * W + j][k * W + l] = 0;
					else if (((i == k && j == l + 1) || (i == k && j == l - 1) || (i == k + 1 && j == l) || (i == k - 1 && j == l)) && (S[i][j] == '.' && S[k][l] == '.')) apsp[i * W + j][k * W + l] = 1;
				}
			}
		}
	}
	for (int k = 0; k < H * W; ++k) {
		for (int i = 0; i < H * W; ++i) {
			for (int j = 0; j < H * W; ++j) apsp[i][j] = min(apsp[i][j], apsp[i][k] + apsp[k][j]);
		}
	}
	int ans = 0;
	for (int i = 0; i < H * W; ++i) {
		for (int j = 0; j < H * W; ++j) {
			if (apsp[i][j] != mod) ans = max(ans, apsp[i][j]);
		}
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 768
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <stack>
#include <string>
#include <cstring>
#include <numeric>
#include <iomanip>
#include <fstream>
using namespace std;
long long mod=998244353;
//
int main(){
	int n;
	cin>>n;
	int m=n%10;
	if(m==3){
		cout<<"bon"<<endl;
	}else if(m==0||m==1||m==6||m==8){
		cout<<"pon"<<endl;
	}else{
		cout<<"hon"<<endl;
	}
	return 0;
}

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

int main(){
    int N;
    cin >> N;
    int a[N];
    int ans = 0;
    map<int,int> mp;
    for(int i = 0;i < N;i++){
        cin >> a[i];
        mp[a[i]]++;
    }

    for(auto p : mp){
        int x = p.first;
        int n = p.second;
        if(n < x){
            ans += n;
        }else{
            ans += n - x;
        }
    }
    cout << ans << endl;
    return 0;
}

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

vector<int> tree[200005], values;

void dfs(int index, int parent = -1) {
	int result = 0;
	for (int pos : tree[index]) {
		if (pos == parent) continue;
		values[pos] += values[index];
		dfs(pos, index);
	}
}

int main() {
	int N = 2, Q = 1;
	cin >> N >> Q;

	repeat(i, N - 1) {
		int a = 0, b = 0;
		cin >> a >> b;
		a -= 1;
		b -= 1;
		tree[a].push_back(b);
		tree[b].push_back(a);
	}

	values.resize(N);

	repeat(i, Q) {
		int p = 0, x = 0;
		cin >> p >> x;
		p -= 1;
		values[p] += x;
	}

	dfs(0);

	repeat(i, N) {
		cout << values[i] << endl;
	}

	cout << endl;
	return 0;
}


Measured memory_bytes: 23552
#include <iostream>
#include <cstdio>
#include <bitset>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>

using namespace std;

#define ll long long
#define vec vector
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)

int main()
{
	ll n;
	string s,s1,s2;
	bool flag = false;

	cin >> n;
	cin >> s;

	if (n % 2 == 0)
	{
		forll(i, 0, n / 2)
		{
			s1.push_back(s[i]);
			s2.push_back(s[i + n / 2]);
		}
		if (s1 == s2)
			flag = true;
	}

	if (flag)
		cout << "Yes";
	else
		cout << "No";

}

Measured memory_bytes: 256
n, y = map(int, input().split())
y //= 1000

cnt = 0

if not(y // 10 <= n <= y):
    print(-1, -1, -1)
else:
    for i in range(y+2):
        for j in range(y//5+2):
            if (y-i-5*j)==(n-i-j)*10 and n-i-j>=0:
                print(n-i-j, j, i)
                break
        else:
            continue
        break
    else:
        print(-1, -1, -1)

Measured memory_bytes: 40684
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define dbug(x) cout<<#x<<"="<<x<<endl
#define m0(x) memset(x,0,sizeof(x))
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pl;

template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) is >> x;
  return is;
}

int main(){

  int N;
  cin >> N;

  ll T,A;
  ll t,a,tem;

  cin>>T>>A;
  reps(i,1,N){
    cin>>t>>a;
    tem=max((T+(t-1))/t,(A+(a-1))/a);
    T=tem*t;
    A=tem*a;
  }

  cout << T+A <<endl;
  return 0;
}


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

int main(int argc, char **argv)
{
	string S, T; cin >> S >> T;
	int N = (int)S.size();
	map<char, char> arrow1, arrow2;

	bool ok{true};
	for (int i = 0; i < N; ++i)
	{
		char &s = S[i], &t = T[i];
		if (arrow1.count(s)) if (arrow1[s] != t) ok = false;
		if (arrow2.count(t)) if (arrow2[t] != s) ok = false;
		arrow1[s] = t, arrow2[t] = s;
	}
	std::cout << (ok ? "Yes" : "No")<< std::endl;
}

Measured memory_bytes: 776
h,w=map(int,input().split())
for j in range(h):
    a=list(map(str,input().split()))
    for i in range(w):
        if a[i]=='snuke':
            c='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
            print(c[i]+str(j+1))
            break
    else:
        continue
    break

Measured memory_bytes: 3060
#include <iostream>
#include <string.h>

using namespace std;

int main(){

  string s,p,temp;

  cin >> s >> p;
  temp = s+s+s;

  if( temp.find(p) != string::npos){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

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

signed main() {
  int a,b;
  cin >> a >> b;
  if(a>=13) cout << b << endl;
  else if(a>=6) cout << b/2 << endl;
  else cout << 0 << endl;
}


Measured memory_bytes: 256
while True:
    a,b,c = map(int,input().split())
    if a+b+c == -3:
        break
    if (a == -1) or (b == -1):
        print('F')
    elif a+b >= 80:
        print('A')
    elif a+b >= 65:
        print('B')
    elif a+b >= 50:
        print('C')
    elif (30 <= a+b) and (a+b < 50):
        if c >= 50:
            print('C')
        else:
            print('D')
    else:
        print('F')


Measured memory_bytes: 5596
#define y1 askjdkasldjlkasd
#include <bits/stdc++.h>
#undef y1

using namespace std;

#define pb push_back
#define mp make_pair
#define fi(a, b) for(int i=a; i<=b; i++)
#define fj(a, b) for(int j=a; j<=b; j++)
#define fo(a, b) for(int o=a; o<=b; o++)
#define fdi(a, b) for(int i=a; i>=b; i--)
#define fdj(a, b) for(int j=a; j>=b; j--)
#define fdo(a, b) for(int o=a; o>=b; o--)
#define sz(x) (int)x.size()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<ll> vll;

#ifdef LOCAL
#define err(...) fprintf(stderr, __VA_ARGS__)
#else
#define err(...) while (0)
#endif

double START_TIME;

void exit() {
#ifdef LOCAL	
	cerr << "TIME: " << setprecision(5) << fixed << (clock() - START_TIME) / CLOCKS_PER_SEC << endl;
#endif	
	exit(0);
}

template<typename A, typename B>
ostream& operator<<(ostream& os, pair<A, B> p) {
	os << "(" << p.first << ", " << p.second << ")";
	return os;
}

template<typename T>
ostream& operator<<(ostream& os, vector<T> v) {
	fi(0, sz(v) - 1) {
		os << v[i] << " ";
	}
	return os;
}

template<typename T>
ostream& operator<<(ostream& os, set<T> t) {
	for (auto z : t) {
		os << z << " ";
	}
	return os;
}

template<typename T1, typename T2>
ostream& operator<<(ostream& os, map<T1, T2> t) {
	cerr << endl;
	for (auto z : t) {
		os << "\t" << z.first << " -> " << z.second << endl;
	}
	return os;
}

#ifdef LOCAL
#define dbg(x) {cerr << __LINE__ << "\t" << #x << ": " << x << endl;}
#define dbg0(x, n) {cerr << __LINE__ << "\t" << #x << ": "; for (int ABC = 0; ABC < n; ABC++) cerr << x[ABC] << ' '; cerr << endl;}
#else
#define dbg(x) while(0){}
#define dbg0(x, n) while(0){}
#endif

#ifdef LOCAL
#define ass(x) if (!(x)) { cerr << __LINE__ << "\tassertion failed: " << #x << endl, abort(); }
#else
#define ass(x) assert(x)
#endif

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

const int MAX = 2e5 + 41;
const int MOD = 1e9 + 7;

int mul(int a, int b) {
	return (ll) a * b % MOD;
}

int n;
char s[MAX];
int ans;

void solve () {
	int ans = 1;
	int cnt = 0;
	fi(1, n) ans = mul(ans, i);
	fi(0, n * 2 - 1) {
		if (cnt % 2 == 0) {
		  if (s[i] == 'W') {
		    if (cnt == 0) {
		    	ans = 0;
		    	break;
		    }
		    ans = mul(ans, cnt);
		    cnt--;
		  } else {
		  	cnt++;
		  }
		} else {
			if (s[i] == 'B') {
		    if (cnt == 0) {
		    	ans = 0;
		    	break;
		    }
		    ans = mul(ans, cnt);
		    cnt--;
		  } else {
		  	cnt++;
		  }
		}
	}

	if (cnt != 0) ans = 0;

	printf("%d\n", ans);
}

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	START_TIME = (double)clock();
#endif
	
	scanf("%d", &n);
	scanf("%s", s);
	solve();

	exit();
	return 0;
}





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

int main() {
int a, b = 5;
while(1) {
cin >> a >> b;
if (a == 0 && b == 0) {
break;
}
for (int i = 0; i < a; i++) {
for (int j = 0; j < b; j++) {
if (i % 2 == 1) {
if (j % 2 == 1) {
cout << "#";
}else {
cout << ".";
}} else {
if (j % 2 == 1) {
cout << ".";
}else {
cout << "#";
}
}
}cout << endl;
} cout << endl; }
return 0;
}


Measured memory_bytes: 3092
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <limits.h>
#include <cinttypes>
#include <bits/stdc++.h>

#define max(a,b) (((a) > (b)) ? (a) : (b))
#define min(a,b) (((a) < (b)) ? (a) : (b))
#define abs(a) (((a) < 0) ? -(a) : (a))

#define FOR(var, to)          for (register int var = 0; var < to; var++)
#define FROMTO(var, from, to) for (register int var = from; var <= to; var++)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

static inline int ri() {
	int a;
	scanf("%d", &a);
	return a;
}

static inline s64 rs64() {
	s64 a;
	scanf("%" SCNd64, &a);
	return a;
}

static inline void wi(int a) {
	printf("%d", a);
}

static inline void wu64(u64 a) {
	printf("%" PRIu64, a);
}

bool judge(s64 a,s64 b,s64 c,s64 d) {
	if (a<b) return false;
	if (b > d) return false;
	if (b == d) return ((a%b) <= c);
	if (b <= c) return true;
	// if (a == b) return true; // WA
	// a >= b
	// b < d
	// b > c
	s64 first = c-(b-(a-c-1)%b-1);
	// printf("  first : %" PRId64 "\n", first);
	if (first < 0) return false;
	s64 gc;
	{
		s64 b_ = b;
		s64 d_ = d;
		while(b_&&d_){
			if (b_>d_) b_%=d_;
			else d_%=b_;
		}
		gc = max(b_,d_);
	}
	// printf("  gc : %" PRId64 "\n", gc);
	if (b-c-1 >= gc) return false;
	if (b-c <= 1) return true;
	s64 bb = (b-1)%gc;
	s64 cc = (c+1)%gc;
	if (bb == cc)
		return !(first%gc == bb);
	else if (bb < cc)
		return !(first%gc >= bb || first%gc <= cc);
	else
		return !(first%gc >= bb && first%gc <= cc);
	
}

int main() {
	int t = ri();
	s64 a[t];
	s64 b[t];
	s64 c[t];
	s64 d[t];
	FOR(i,t) {
		a[i] = rs64();
		b[i] = rs64();
		c[i] = rs64();
		d[i] = rs64();
	}
	
	FOR(i,t)
		printf("%s\n", judge(a[i],b[i],c[i],d[i]) ? "Yes" : "No");
	
	
	
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <ctype.h>
#include <string.h>

int main(void)
{
    char W[11], T[1001];
    char eot[] = "END_OF_TEXT";
    int i, j;
    int count = 0;
    scanf(" %s", W);
    j = 0;
    while(1){
        j = 0;
        scanf("%s", T); //kalau guna fgets dapat sikit taktau kenapa
        if(strcmp(T, eot) == 0) break;
        
        for(i = 0; i < strlen(T); i++){
            if(isalpha(T[i]) && isupper(T[i])){
                T[i] = tolower(T[i]);
            }
        }
        if(strcmp(W, T) == 0) count++;

        //printf("count in this line  : %d\n", strlen(W));
    }
    printf("%d\n", count);
    return (0);
}



Measured memory_bytes: 2108
while True:
    H, W = map(int, input().split())

    if H == W == 0:
        break

    for h in range(H):
        for w in range(W):
            if (h + w) % 2 == 0:
                print("#", end="")
            else:
                print(".", end="")
        print()
    
    print()



Measured memory_bytes: 7000
#include <iostream>
using namespace std;
int main(){
  int a, b, c;
  cin >> a >> b >> c;
  for(int i = 1; i <= b; i++){
    if((a*i)%b == c){
      cout << "YES" << endl;
      return 0;
    }
  }
    cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define P pair<int, int>
#define F first
#define S second
#define mod 1000000007
#define MOD 998244353
#define INF 10000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 1};
template <class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
void allcout(auto V) {
    for(auto x : V) cout << x << ' ';
    cout << endl;
}
vector<int> Ans;
void dfs(int n, int s) {
    int m = n % 10;
    Ans.push_back(n);
    if(s < 10) {
        dfs(n * 10 + m, s + 1);
        if(m > 0) dfs(n * 10 + m - 1, s + 1);
        if(m < 9) dfs(n * 10 + m + 1, s + 1);
    }
}
signed main() {
    int K;
    cin >> K;
    rep(i, 9) dfs(i + 1, 1);

    sort(all(Ans));
    Ans.erase(unique(all(Ans)), Ans.end());
    cout << Ans[K - 1] << endl;
}


Measured memory_bytes: 3444
#include<cstdio>
#include<cctype>
#include<algorithm>
#include<iostream>
#include<cstring>

#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define debug(...) fprintf(stderr,__VA_ARGS__)

using namespace std;

inline char nc(){ return getchar();static char buf[100000] , *p1,*p2; return p1 == p2 && (p2 = (p1 = buf) + fread(buf,1,100000,stdin),p1 == p2) ? EOF : *p1++;}
template<class T>inline void rd(T & x){ x = 0;char ch = nc();for(;!isdigit(ch);ch = nc()); for(;isdigit(ch);ch = nc()) x = x * 10 - 48 + ch;}

typedef long long ll;

const int maxn = 600 + 10;
const int mod = 1e9 + 7;

int f[maxn][maxn] , g[maxn][maxn] , h[maxn] , a[maxn] , b[maxn];

template<class T>inline T add(T a,T b){ a += b; if(a > mod) a -= mod; return a;}
template<class T>inline T sub(T a,T b){ a -= b; if(a < 0) a += mod; return a;}
template<class T>inline T mul(T a,T b){ return (ll)a * b % mod;}


int main(){
	int n,m;
	rd(n); rd(m);
	for(int i = 1;i <= m;i++){
		rd(a[i]);
		rd(b[i]);
	}	
	h[0] = 1;
	for(int i = 1;i <= n;i++) h[i] = mul(h[i - 1],(i << 1) - 1);
	int ans = 0;
	for(int l = n * 2;l;l--){
		for(int r = l + 1;r <= n * 2;r += 2){
			bool flag = 1;
			int in = 0;
			for(int i = 1;i <= m;i++){
				int t = (a[i] >= l && a[i] <= r) + (b[i] >= l && b[i] <= r);
				if(t == 1){
					flag = 0;
					break;
				}
				if(t) in++;
			}
			if(flag){
				in = (r - l + 1 >> 1) - in;
				int out = n - m - in;
				f[l][r] = g[l][r] = h[in];
				for(int i = l + 1;i < r;i += 2){
					f[l][r] = sub(f[l][r],mul(f[l][i],g[i + 1][r]));
				}
				ans = add(ans,mul(f[l][r],h[out]));
			}
		}
	}
	printf("%d\n",ans);
}
 

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

class disjointset {
public:
	vector<int> rank, p;
	disjointset(){}
	disjointset(int size) {
		rank.resize(size, 0);
		p.resize(size, 0);
		for (int i = 0; i < size; i++) makeset(i);
	}

	void makeset(int x) {
		p[x] = x;
		rank[x] = 0;
	}
	bool same(int x, int y) {
		return findset(x) == findset(y);
	}

	void unite(int x, int y) {
		link(findset(x), findset(y));
	}

	void link(int x, int y) {
		if (rank[x] > rank[y]) {
			p[y] = x;
		}
		else {
			p[x] = y;
			if (rank[x] == rank[y]) {
				rank[y]++;
			}
		}
	}

	int findset(int x) {
		if (x != p[x]) {
			p[x] = findset(p[x]);
		}
		return p[x];
	}
};

int main() {
	int n, a, b, q;
	int t;

	cin >> n >> q;
	disjointset ds = disjointset(n);

	for (int i = 0; i < q; i++) {
		cin >> t >> a >> b;
		if (t == 0) ds.unite(a, b);
		else if (t == 1) {
			if (ds.same(a, b)) cout << "1" << endl;
			else cout << "0" << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 3200
########関数部分##############
def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)
############################
 
 
#####関数をつかってみる．#####
######今回は二進数に変換######
n, k = map(int, input().split())
x10 = n
x2 = Base_10_to_n(x10, k)
ans = str(x2)
print(len(ans))

Measured memory_bytes: 8960
//#pragma GCC target("avx2")
//#pragma GCC optimization("O3")
//#pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define ub upper_bound
#define lb lower_bound
#define bit __builtin_popcount
#define memset(x) memset(x,0,sizeof(x))

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<vector<int>> matrix;

inline void boost(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

const ll maxn=2e5+123;
const ll inf=1e9+123;
const ll linf=1e18+123;
const ll mod=1e9+7;
const double eps=1e-9;
const double pi=acos(-1);
int dx[8]={0,1,-1,0,1,-1,1,-1};
int dy[8]={1,0,0,-1,1,1,-1,-1};
string t="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
    boost();
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int n;
    cin>>n;
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++){
        int q=s[i]-'A';
        cout<<t[(q+n)%26];
    }
    exit(0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
int a, b, c, d;
int f[4000][4000][2];

void upd(int &a, int b) {
	a += b; if (a >= mod) a -= mod;
}

int main() {
	cin >> a >> b >> c >> d;
	f[a][b][0] = 1;
	for (int i = a; i <= c; ++i)
		for (int j = b; j <= d; ++j) {
			upd(f[i + 1][j][0], 1ll * f[i][j][0] * j % mod);
			upd(f[i][j + 1][1], 1ll * f[i][j][0] * i % mod);
			upd(f[i + 1][j][0], f[i][j][1]);
			upd(f[i][j + 1][1], 1ll * f[i][j][1] * i % mod);
		}
	printf("%d", (f[c][d][0] + f[c][d][1]) % mod);
}


Measured memory_bytes: 86124
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B;
  cin >> A >> B;
  if(B>=0){
    if(A+B>=A*B){
    cout << A+B << endl;
    }
    else{
    cout << A*B << endl;
    }
  }
  else if (B<0){
    if(A-B>=A*B){
    cout << A-B << endl;
    }
    else{
    cout << A*B << endl;
    }
  }
}


Measured memory_bytes: 3516
main()
{
    int A, B, C[3]={0}, i, ans=0;
    scanf("%d%d", &A, &B);
    C[0]=A+A-1;
    C[1]=B+B-1;
    C[2]=A+B;
    for(i=0;i<3;i++)
        if(ans < C[i]) ans=C[i];
    printf("%d",ans);
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<vector>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int *a,*b,*c;
    b=new int [n];
    a=new int [n];
    c=new int [n];
    for(int i=0; i<n; i++)
    {
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
          bool flag=0;
          if(a[0])c[0]=1;
          else c[0]=0;
          for(int j=1;j<n;j++){
              if(a[j])
                c[j]=c[j-1]+1;
              else c[j]=c[j-1];
              //cout<<c[j]<<' ';
          }
          //cout<<endl;
          for(int j=n-1;j>=0;j--){
             //cout<<c[j]<<' '<<a[j]<<endl;
             if(c[j]==a[j]&&a[j]){
                b[i]=a[j];
                a[j]=0;
                flag=1;
                break;
             }
          }
          if(!flag){
            cout<<-1;
            return 0;
          }
    }
    for(int i=n-1;i>=0;i--)
        cout<<b[i]<<endl;
}


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

# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define p(s) std::cout << s << endl;

int main()
{
    int n;cin >> n ;
    int a[26];
    for(int i=0;i<n;i++){
        char tmp;cin >> tmp;
        if(tmp=='Y'){
            p("Four")
            return 0;
        }
    }
    p("Three")
}

Measured memory_bytes: 256
#include <stdio.h>

struct dice {
	int area[6];
};

void diceroll(const char order, struct dice *dice)
{
	int temp;

	if (order == 'N') {
		temp = dice->area[0];
		dice->area[0] = dice->area[1];
		dice->area[1] = dice->area[5];
		dice->area[5] = dice->area[4];
		dice->area[4] = temp;
	}
	else if (order == 'W') {
		temp = dice->area[0];
		dice->area[0] = dice->area[2];
		dice->area[2] = dice->area[5];
		dice->area[5] = dice->area[3];
		dice->area[3] = temp;
	}
	else if (order == 'E') {
		temp = dice->area[0];
		dice->area[0] = dice->area[3];
		dice->area[3] = dice->area[5];
		dice->area[5] = dice->area[2];
		dice->area[2] = temp;
	}
	else if (order == 'S') {
		temp = dice->area[0];
		dice->area[0] = dice->area[4];
		dice->area[4] = dice->area[5];
		dice->area[5] = dice->area[1];
		dice->area[1] = temp;
	}
}

int main() {
	struct dice dice[100];
	char order;
	int n;
	int i, j, k, l, m;

	scanf("%d", &n);

	for (i = 0; i < n; i++) {
		scanf("%d %d %d %d %d %d", &dice[i].area[0], &dice[i].area[1], &dice[i].area[2], &dice[i].area[3], &dice[i].area[4], &dice[i].area[5]);
	}

	for (i = 1; i < n; i++) {
		for (k = 0; k < 2; k++) {
			for (l = 0; l < 4; l++) {
				for (j = 0; j < 4; j++) {
					diceroll(order, &dice[i]);
					for (m = 0; m < i; m++) {
						if (dice[i].area[0] == dice[i - m - 1].area[0] && dice[i].area[1] == dice[i - m - 1].area[1] && dice[i].area[2] == dice[i - m - 1].area[2] && dice[i].area[3] == dice[i - m - 1].area[3] && dice[i].area[4] == dice[i - m - 1].area[4] && dice[i].area[5] == dice[i - m - 1].area[5]) {
							printf("No\n");

							return 0;
						}
					}
					order = 'W';
				}
				order = 'N';
			}
			for (l = 0; l < 4; l++) {
				for (j = 0; j < 4; j++) {
					diceroll(order, &dice[i]);
					for (m = 0; m < i; m++) {
						if (dice[i].area[0] == dice[i - m - 1].area[0] && dice[i].area[1] == dice[i - m - 1].area[1] && dice[i].area[2] == dice[i - m - 1].area[2] && dice[i].area[3] == dice[i - m - 1].area[3] && dice[i].area[4] == dice[i - m - 1].area[4] && dice[i].area[5] == dice[i - m - 1].area[5]) {
							printf("No\n");
							return 0;
						}
					}
					order = 'W';
				}
				order = 'S';
			}
		}
	}

	printf("Yes\n");
	return 0;
}



Measured memory_bytes: 2108
#include<stdio.h>
#define MAX 100005

typedef struct{
    char name[100];
    int t;
}P;

int head , tail, n;
P queue[MAX];
void enqueue(P x)
{
    queue[tail] = x;
    tail = ( tail + 1 ) % MAX;
}

P dequeue()
{
    P x = queue[head];
    head = ( head + 1 ) % MAX;
    return x;
}


int main()
{
    int q, i, tmp, time = 0;
    P u;
    scanf("%d %d", &n, &q);
    for( i = 0; i < n; i++ ){
        scanf("%s%d", queue[i].name, &queue[i].t);
    }
    head = 0; tail = n;
    while( head != tail ){
        u = dequeue();
        if( u.t > q ){
            time += q;
            u.t -= q;
            enqueue(u);
        }else{
            time += u.t;
            printf("%s %d\n", u.name, time);
        }
    }
    return 0;
}

Measured memory_bytes: 11808
#include<stdio.h>
int main (void)
{
   int a,b,c,d;

   scanf("%d%d%d%d",&a,&b,&c,&d);

   if((a+b)==(c+d)) printf("Balanced\n");

   else if ((a+b)>(c+d)) printf("Left\n");

   else printf("Right\n");

   return 0;
}


Measured memory_bytes: 128
using System;
using System.Linq;
using System.Collections.Generic;

class Cmondai
{
    static void Main()
    {
        var N = Int32.Parse(Console.ReadLine());
        var list = new List<long[]>();
        for (int i=0;i<N;++i)
        {
            var xyh = Console.ReadLine().Split(' ').Select(num => Int64.Parse(num)).ToArray();
            var x = xyh[0];
            var y = xyh[1];
            var h = xyh[2];
            list.Add(new long[3] { x, y, h });
        }
        var kizyun = list.Where(x=>x[2]!=0).First();
        for (int i=0;i<=100;++i)
        {
            for (int j=0;j<=100;++j)
            {
                var height = kizyun[2]+ Math.Abs(kizyun[0] - i) + Math.Abs(kizyun[1] - j);
                var isCorrect = true;
                for (int k = 0; k < N; ++k)
                {
                    if (Math.Max(0,height- Math.Abs(list[k][0] - i) - Math.Abs(list[k][1] - j)) != list[k][2])
                    {
                        isCorrect = false;
                        break;
                    }
                }
                if (isCorrect)
                {
                    Console.WriteLine($"{i} {j} {height}");
                    return;
                }
            }
        }
    }
}

Measured memory_bytes: 13524
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=200005;
int n;
ll c[155][155];
inline ll gcd(ll a,ll b) { return !b?a:gcd(b,a%b); }
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		ll a=0,b=1; bool fl=0; char ch=getchar();
		for(;!isdigit(ch);ch=getchar());
		for(;isdigit(ch) || ch=='.';ch=getchar())
		{
			if(isdigit(ch))
			{
				a=a*10+ch-'0';
				if(fl) b*=10;
			}
			else fl=1;
		}
		ll v=gcd(a,b);
		a/=v,b/=v;
//		cout<<a<<' '<<b<<endl;
		int s=75,t=75;
		while(a%2==0) a/=2,s++;
		while(a%5==0) a/=5,t++;
		while(b%2==0) b/=2,s--;
		while(b%5==0) b/=5,t--;
		c[s][t]++;
//		cout<<s<<' '<<t<<endl;
	}
	ll ans=0;
	for(int i=1;i<=150;i++)
		for(int j=1;j<=150;j++)
			for(int k=1;k<=150;k++)
				for(int l=1;l<=150;l++)
					if(i+k>=150 && j+l>=150 && c[i][j] && c[k][l])
					{
						if(i!=k || j!=l) ans+=c[i][j]*c[k][l];
						else ans+=c[i][j]*(c[k][l]-1);
//						cout<<i<<' '<<j<<' '<<k<<' '<<l<<endl;
					}
	printf("%lld\n",ans/2);
	return 0;
}

Measured memory_bytes: 3852
def gcd(a, b):
    if a == 0:
        return b
    return gcd(b % a, a)


n, x0 = map(int, input().split())
x = [x0] + list(map(int, input().split()))
x.sort()
d = [x2 - x1 for x1, x2 in zip(x, x[1:])]

ans = d[0]
for d1, d2 in zip(d, d[1:]):
    ans = min(ans, gcd(d1, d2))

print(ans)

Measured memory_bytes: 14252
import qualified Data.ByteString.Char8 as B
import Data.Char
import Data.List

readInts :: IO [Int]
readInts = unfoldr (B.readInt . B.dropWhile isSpace) <$> B.getLine

main :: IO ()
main = do
  getLine
  bs <- readInts
  print $ solve bs

solve :: [Int] -> Int
solve (b:bs) = sum $ zipWith min (b:b:bs) ((b:bs) ++ [10^5])


Measured memory_bytes: 508
import sys
sys.setrecursionlimit(10**7)

readline = sys.stdin.buffer.readline
def readstr():return readline().rstrip().decode()
def readstrs():return list(readline().decode().split())
def readint():return int(readline())
def readints():return list(map(int,readline().split()))
def printrows(x):print('\n'.join(map(str,x)))
def printline(x):print(' '.join(map(str,x)))


class AVL_like_BIT:  # 1-indexed
    def __init__(self,n):  # 1~nを要素として持ちうる。
        self.n = n
        self.tree = [0]*(self.n+1)
        self.depth = n.bit_length()

    def add(self,k):  # kを木に加える
        while k<=self.n:
            self.tree[k]+=1
            k += k&-k
    
    def delete(self,k): # kを木から削除する
        while k<=self.n:
            self.tree[k]-=1
            k += k&-k

    def sum(self,k):  # 1~kの和
        ans = 0
        while k>0:
            ans += self.tree[k]
            k -= k&-k
        return ans
    
    def lower_bound(self,k):  # k以上の最小要素
        x = self.sum(k-1)
        if x == self.sum(self.n):  # k以上の要素がないときは-1を返す
            return -1
        p = 0
        v = 1<<self.depth
        for i in range(self.depth + 1):  # sum(p) = sum(k-1)なるpの右端 + 1が答え
            q = p+v
            if q <= self.n and self.tree[q] <= x:
                x -= self.tree[q]
                p += v
            v>>=1
        return p+1

    def upper_bound(self,k):  # k以下の最大要素
        x = self.sum(k)
        if x == 0:  # k以下の要素がないときは-1を返す
            return -1
        p = 0
        v = 1<<self.depth
        for i in range(self.depth + 1):  # sum(p) = sum(k)なるpの左端が答え
            q = p+v
            if q <= self.n and self.tree[q] < x:
                x -= self.tree[q]
                p += v
            v>>=1
        return p+1

    def query(self,k):  # k番目の要素出力
        if k > self.sum(self.n):  # k個以上の要素がないときは-1を返す
            return -1
        p = 0
        v = 1<<self.depth
        for i in range(self.depth + 1):  # sum(p) = kなるpの左端が答え
            q = p+v
            if q <= self.n and self.tree[q] < k:
                k -= self.tree[q]
                p += v
            v>>=1
        return p+1

def compress(a):
    b = sorted(set(a))
    d = {x:i+1 for i,x in enumerate(b)}
    return b,d


import heapq

n,q = readints()

X = []

block = []
free = []
for i in range(n):
    s,t,x = readints()
    X.append(x)
    block.append([s-x,x])
    free.append([t-x,x])

b,d = compress(X)
block = [(x[0],d[x[1]]) for x in block]
free = [(x[0],d[x[1]]) for x in free]
heapq.heapify(block)
heapq.heapify(free)

ans = []
avl = AVL_like_BIT(len(d))
for i in range(q):
    D = readint()
    while block:
        if block[0][0]<=D:
            a = heapq.heappop(block)
            avl.add(a[1])
        else:
            break
    while free:
        if free[0][0]<=D:
            a = heapq.heappop(free)
            avl.delete(a[1])
        else:
            break        
    ans.append(avl.lower_bound(0))

ans = [b[x-1] if x >=0 else -1 for x in ans]
printrows(ans)


Measured memory_bytes: 156180
#include<bits/stdc++.h>
using namespace std;
#define LL long long
const int N=1e5+5;

LL n,m,v,p;
LL a[N],h[N];
bool ok(int x)
{
	if(x>n) return 1;
	for(int i=1;i<=n;i++)
		h[i]=a[i];
	LL all=m*v;
	for(int i=1;i<=x;i++)
		h[i]+=m;
	all-=m*x;
	for(int i=n-p+2;i<=n;i++)
		h[i]+=m;
	all-=m*(p-1);
	if(h[n-p+1]>h[x]) return 0;
	for(int i=x+1;i<=n-p+1;i++)
		all+=h[i]-h[x];
	if(all>0) return 0;
	return 1;
}

int main()
{
	
	cin>>n>>m>>v>>p;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	sort(a+1,a+n+1);
	//cout<<ok(4)<<'\n';
	int can=1<<20;
	for(int i=19;i>=0;i--)
	{
		if(ok(can-(1<<i))) can-=(1<<i);
		//cout<<can<<'\n';
	}
	cout<<n-can+1<<'\n';
	
	return 0;
}

Measured memory_bytes: 1792
if __name__ == '__main__':
    n = int(input())
    graph = [[0 for i in range(n)] for _ in range(n)]
    frist = [0 for _ in range(n)]
    end = [0 for _ in range(n)]
    visit = [False for _ in range(n)]
    # get the group
    for i in range(n):
        datas = [int(num) for num in input().split(' ')]
        if datas[1] > 0:
            for j in datas[2:]:
                graph[datas[0] - 1][j - 1] = 1

    queue = [0]
    visit = [False for _ in range(n)]
    visit[0] = True
    depths = [0 for _ in range(n)]
    while len(queue) != 0:
        point = queue.pop(0)
        for i in range(n):
            if graph[point][i] == 1 and visit[i] is False:
                queue.append(i)
                visit[i] = True
                depths[i] = depths[point] + 1
        if len(queue) == 0:
            for i in range(n):
                if visit[i] is False:
                    queue.append(i)
                    depths[i] = -1
                    visit[i] = True

    for i in range(n):
        print('%d %d' % (i + 1, depths[i]))


Measured memory_bytes: 5704
n,m,X,Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
z = list(range(X+1,Y+1))

x.sort()
y.sort()

flag = 1

for i in z:
    if X<i<=Y and x[-1]<i and y[0]>=i:
        flag = 0
        
if flag == 0:
    print("No War")
else:
    print("War")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  // ここにプログラムを追記
  int s;
  int count = 0;
  cin >> s;
  for(int i = 0; i < 3; i++){
	int j = s%10;
    if(j == 1){
		count += j;
    }
    
    s /= 10;
  }
  cout << count << endl;
	

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define sz(x) (int)(x).size()
using namespace std;

const int maxn=1e6+7,mod=1e9+7;
ll dp[4][maxn];

ll add(ll a, ll b)
{
    a+=b;
    if (a>=mod)
        a-=mod;
    return a;
}

ll mult(ll a, ll b)
{
    return ((a%mod)*(b%mod))%mod;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    cin>>n;
    dp[0][0]=1;
    for (int j=1;j<=n;++j)
    {
        dp[0][j]=mult(dp[0][j-1],8);
        dp[1][j]=add(dp[0][j-1],mult(dp[1][j-1],9));
        dp[2][j]=add(dp[0][j-1],mult(dp[2][j-1],9));
        dp[3][j]=add(mult(dp[3][j-1],10),add(dp[1][j-1],dp[2][j-1]));
    }
    cout<<dp[3][n];
    return 0;
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    int n;
    ll ans=0;
    cin>>n;
    vector<ll> a(n);
    
    for(int i = 0; i < n; i++)
    {
        cin>>a[i];
        a[i]-=i+1;
    }
    sort(all(a));
    ll mid =a[n/2];
        
    
    for(int i = 0; i < n; i++)
    {
        ans+=abs(a[i]-mid);
    }
    
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>

using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ll> pdl;
typedef pair<ld, ld> pdd;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
//typedef boost::multiprecision::cpp_int bigint;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	ll N;
	cin >> N;
	VLL A;
	A.reserve(N);
	for (ll n = 0; n < N; n++) {
		ll a;
		cin >> a;
		A.push_back(a);
	}
	sort(A.begin(), A.end(), [](ll a, ll b) {
		return a < b;
	});
	vector<ll> AA;
	AA.reserve(N);
	AA.push_back(1);
	for (ll n = 1; n < N; n++) {
		if (A[n] == A[n - 1])AA.back()++;
		else AA.push_back(1);
	}
	//種類数を数える
	ll type = AA.size();
	//重複分
	ll db = N - AA.size();
	if (db & 1)cout << type - 1 << "\n";
	else cout << type << "\n";
	return 0;
}

Measured memory_bytes: 1792
local mod = 1000000007
local n = io.read("*n")
local t = {}
for i = 1, n do
  t[i] = io.read("*n")
end
local currank = 1
local currank_left = 1
local tgt = -1
local rank = {}
for i = 1, n do rank[i] = 0 end
for i = 1, n do
  if t[i] < tgt + 2 then
    local currank_right = i
    rank[currank] = currank_right - currank_left + 1
    currank = currank + 1
    currank_left = i + 1
  else
    tgt = tgt + 2
  end
end
if currank_left <= n then
  rank[currank] = n + 1 - currank_left
end
for i = 2, #rank do
  rank[i] = rank[i] + rank[i - 1]
end
local ret = 1
for i = 1, n do
  ret = (ret * (rank[i] + 1 - i)) % mod
end
print(ret)


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

main() {
    ll N; cin >> N;
    ll A[5]; rep(i,5) cin >> A[i];
    sort(A,A+5);
    cout << (N+A[0]-1)/A[0]+4 << endl; 
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#define N 100

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

int main(void)
{
	int i,p[N],n,S;
	
	while(1)
	{
		scanf("%d",&n);
		if(n==0) break;
		S=0;
		for(i=0;i<=n-1;i++)
		{
			scanf("%d",&p[i]);
			S+=p[i];
		}
		qsort(p,n,sizeof(int),compar);
		S=S-p[0]-p[n-1];
		S=S/(n-2);
		printf("%d\n",S);
	}
	return 0;
}

Measured memory_bytes: 604
S=input()
lens = len(S)
s = [S[i] for i in range(lens)]
a = ['A' for i in range(lens) if S[i]=='A']
b = ['B' for i in range(lens) if S[i]=='B']
if len(a)>0 and len(b)>0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
S = input()

ans = 0
for i in range(N):
	ans = max(ans, len(set(S[:i])&set(S[i:])))

print(ans)


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

int main() {
  int n,m,cnt=0;
  string s;
  map<string,int> cards;
  cin >> n;
  for(int i=0 ;i<n ;i++){
    cin >> s;
    cards[s] += 1;
  }
  cin >> m;
  for(int i=0 ;i<m ;i++){
    cin >> s;
    cards[s] -= 1;
  }
  for(pair<string,int>p:cards){
    cnt = max(cnt,p.second);
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
import numpy as np

N, Q = map(int, input().split())
S = np.array(list('_' + input()), dtype='U2')

A = (S == 'A')
C = (S == 'C')
AC = (A[:-1] & C[1:])
AC_cum = AC.cumsum()

for _ in range(Q):
    l, r = map(int, input().split())
    print(AC_cum[r-1] - AC_cum[l-1])

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

int main() {
	long long a, b, res = 1;
	cin >> a >> b;
	for (long long i = 2; i * i <= a; i++) {
		if (a % i == 0) {
			while (a % i == 0)
				a /= i;
			if (b % i == 0)
				res++;
		}
	}
	if (a > 1 && b % a == 0)
		res++;
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i = (a) ;i < (b) ;i++)
#define repr(i, a, b) for (int i = (b) - 1 ;i >= a ;i--) 
int main(){
	int K, T, a[100] ;
	cin>>K>>T ;
	for (int i = 0 ;i < T ;i++)
		cin>>a[i] ;
	sort(a, a + T) ;
	int sum = 0 ;
	for (int i = 0 ;i < T - 1 ;i++)
		sum += a[i] ;
	if (sum >= a[T - 1]){
		cout<<0<<endl ;
	}else
	cout<<a[T - 1] - sum - 1<<endl ;


	return 0 ;
}


Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Main main = new Main();
        main.solve();
    }
    public void solve() throws Exception {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int max_color = 0;
        int current = 1;
        while (current < N) {
            current *= 2;
            max_color += 1;
        }
        int[] nodes = new int[N];
        for (int i = 0; i < N; i++) {
            nodes[i] = i;
        }
        for (int i = 0; i < N-1; i++) {
            int x = nodes[i];
            StringBuilder sb = new StringBuilder();
            for (int j = i + 1; j < N; j++) {
                int y = nodes[j];
                sb.append(level(x, y));
                sb.append(" ");
            }
            System.out.println(sb.substring(0, sb.length()-1));
        }
    }
    private int level(int x, int y) {
        int z = x ^ y;
        int level = 1;
        while ((z & 1) == 0) {
            z = z >> 1;
            level += 1;
        }
        return level;
    }
}


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

int main() {
  string s; cin >>s;
  string ans = "Good";
  for (int i=0; i<3; i++){
    if (s.at(i)==s.at(i+1)){
      ans = "Bad";
    }
  }
  cout <<ans;
  cout <<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, e) for (int i = s; i < e; ++i)
#define sort_(a) stable_sort(a.begin(), a.end())
#define rsort(a) stable_sort(a.rbegin(), a.rend())
#define sum(a) accumulate(a.begin(), a.end(), 0LL)
#define join(a, d) accumulate(a.begin() + 1, a.end(), a[0], [](string s, string t) {return s + d + t;})
#define all(a) a.begin(), a.end()
// #define __lcm(a, b) std::__detail::__lcm(a, b)
typedef long long ll;
const long mod = 1e9 + 7;

int main(void) {
#ifdef DEBUG
  freopen("input.txt", "r", stdin);
#endif

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

  array<int, 3> A;
  cin >> A[0] >> A[1] >> A[2];
  sort_(A);
  int n = A[2] - A[1];
  int ans = n;
  A[0] += n;
  A[1] += n;
  ans += ((A[2] - A[0]) + 1) / 2;
  if ((A[2] - A[0]) % 2) ++ans;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

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

#ifdef DEBUG
    #define IFD if(true)
#else
    #define IFD if(false)
#endif

#include <vector>
template<typename T_mc_data>

class ModComb
{
private:
    int max_n;
    T_mc_data mod; // M
    vector<vector<T_mc_data>> table;

public:

    // 引数: n の最大値、M は mod の値
    ModComb(int n, T_mc_data M = 0) : table(n + 1, vector<T_mc_data>(n + 1))
    {
        max_n = n;
        mod = M;
        for(int i = 0; i <= n; i++) {
            table[i][0] = 1;
            table[i][i] = 1;
            for(int j = 1; j < i; j++) {
                table[i][j] = (table[i - 1][j - 1] + table[i - 1][j]);
                if(mod != 0) {
                    table[i][j] %= mod;
                }
            }
            /*
            // デバッグ出力
            for(int j = 0; j <= i; j++) {
                cout << table[i][j] << " ";
            }
            cout << endl;
            */
        }
    }

    // aCb を求める
    T_mc_data calc(T_mc_data a, T_mc_data b)
    {
        if(a > max_n || a < b || a < 0) return 0; // error
        if(a == 0 && b == 0) return 1;
        return table[a][b];
    }
};

/////


int main()
{
    int N, K;
    cin >> N >> K;
    ll mod = 1000000007;
    ModComb<ll> mc(N, mod);

    rep(i, K) {
        ll ans = 0;
        // (N-K+1)C(i+1) 赤い石の間に青い石を入れる総数
        IFD cout << "i: " << i << endl << N - K + 1 << " " << i + 1 << " " << K - 1 << endl;
        ans = mc.calc(N - K + 1, i + 1);
        if(i != 0) {
            // (K-1)C(i) 青い石の塊ごとに何個ずつにするかの総数
            ans = ans * mc.calc(K - 1, i) % mod;
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 31616
#include <bits/stdc++.h>
using namespace std;
#define ll int
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
#define pll pair<pair<int,int>,pair<int,int> > 
const int M=2e5+5;
ll even[M],odd[M],pos[M],sp1[M][20],sp2[M][20],ind[M];
vector<pair<int,int> > v;
ll query1(ll st,ll en)
{
	ll len=(en-st+1);
	len=ind[len];
	ll b=1<<len;
	ll val=min(sp1[st][len],sp1[en-b+1][len]);
	return val;
}
ll query2(ll st,ll en)
{
	ll len=(en-st+1);
	len=ind[len];
	ll b=1<<len;
	ll val=min(sp2[st][len],sp2[en-b+1][len]);
	return val;
}
pair<int,int> solve(int l,int r)
{
	if(l>r)
		return {-1,-1};
	int x,y;
	if(l%2)
	{
		x = query1(l,r);
		y = query2(pos[x]+1,r);
	}
	else
	{
		x = query2(l,r);
		y = query1(pos[x]+1,r);
	}
	v.pb({x,y});
	return {x,y};
	// solve(l,pos[x]-1);
	// solve(pos[y]+1,r);
	// solve(pos[x]+1,pos[y]-1);
}
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		if(i%2)
		{
			cin>>odd[i];
			even[i]=n+1;
			pos[odd[i]]=i;
		}
		else
		{
			cin>>even[i];
			odd[i]=n+1;
			pos[even[i]]=i;
		}
	}
	ll curr=0;
	for(ll i=1;i<M;i++)
	{
		ll b=1<<(1+curr);
		if(b>=i)
			ind[i]=curr;
		if(b==i)
			curr++;
	}
	//assing values to sp[i][0] here
	for(int i=1;i<=n;i++)
	{
		sp1[i][0]=odd[i];
		sp2[i][0]=even[i];
	}
	for(ll p=1;p<20;p++)
	{
		for(ll i=1;i<=n;i++)
		{
			ll b=1<<(p-1);
			if(i+b<=n)
			{
				sp1[i][p]=min(sp1[i][p-1],sp1[i+b][p-1]);
				sp2[i][p]=min(sp2[i][p-1],sp2[i+b][p-1]);
			}
		}
	}
	auto u = solve(1,n);
	priority_queue<pll,vector<pll>,greater<pll>> pq;
	pq.push({u,{1,n}});
	while(!pq.empty())
	{
		auto u=pq.top();
		pq.pop();
		auto p = u.ff;
		auto rg = u.ss;
		cout<<p.ff<<" "<<p.ss<<" ";
		auto r = solve(rg.ff,pos[p.ff]-1);
		if(r.ff!=-1)
			pq.push({r,{rg.ff,pos[p.ff]-1}});
		r = solve(pos[p.ff]+1,pos[p.ss]-1);
		if(r.ff!=-1)
			pq.push({r,{pos[p.ff]+1,pos[p.ss]-1}});
		r = solve(pos[p.ss]+1,rg.ss);
		if(r.ff!=-1)
			pq.push({r,{pos[p.ss]+1,rg.ss}});
	}
	cout<<"\n";
	return 0;
}

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

int kitasatoshibasaburou;
int u[20][20];
int o[20][20]={};
int tate;
int yoko;
int ushi;
int a[101];
int b[101];
int c[101];
int d[101];
int main(){
  cin>>kitasatoshibasaburou;
    for(int i=0;i<kitasatoshibasaburou;i++){
      cin>>tate>>yoko>>ushi;
      for(int j=0;j<ushi;j++){
	cin>>a[j]>>b[j]>>c[j]>>d[j];
      }
      u[0][0]=1;
      for(int k=0;k<tate+1;k++){
	for(int l=0;l<yoko+1;l++){
	  for(int m=0;m<ushi;m++){
	    if(k==a[m]&&k==c[m]&&(b[m]==l||d[m]==l)&&(b[m]==l+1||d[m]==l+1)){
	      o[k][l]=o[k][l]+1;
	    }if(l==b[m]&&l==d[m]&&(a[m]==k||c[m]==k)&&(a[m]==k+1||c[m]==k+1)){
		o[k][l]=o[k][l]+100;
	      }
	      }
	  //cout<<k<<l<<"o"<<o[k][l]<<endl;
	      if(o[k][l]==0){u[k+1][l]=u[k+1][l]+u[k][l];
		u[k][l+1]=u[k][l+1]+u[k][l];
	      }else if(o[k][l]==1){u[k+1][l]=u[k+1][l]+u[k][l];
	      }else if(o[k][l]==100){u[k][l+1]=u[k][l+1]+u[k][l];
	      }
	      //cout<<k<<l<<"u"<<u[k][l]<<endl;
	  }
	}
      if(u[tate][yoko]==0){cout<<"Miserable Hokusai!"<<endl;
      }else{cout<<u[tate][yoko]<<endl;}
      for(int uma=0;uma<20;uma++){
	for(int yagi=0;yagi<20;yagi++){
      u[uma][yagi]=0;
      o[uma][yagi]=0;
	}
      }
      int tate=0;
      int yoko=0;
      int ushi=0;
      for(int neko=0;neko<101;neko++){
      a[neko]=0;
      b[neko]=0;
      c[neko]=0;
      d[neko]=0;
      }
      //cout<<tate<<yoko<<ushi<<endl;
    }
}

Measured memory_bytes: 1168