akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

typedef long long ll;
const ll MOD = 1000000007;

using namespace std;

vector<ll> score(1 << 16, 0);

ll ans(int n, vector<ll> &dp) {
    if (n == 0)
        return 0;
    else if (dp[n] != LLONG_MIN)
        return dp[n];
    int mask = 1;
    for (; mask <= n; ++mask) {
        if ((mask | n) != n) continue;
        dp[n] = max(dp[n], score[mask] + ans(n - mask, dp));
    }
    return dp[n];
}

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

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

    // precompute scores for all possible team combinations
    for (int i = 0; i < (1 << n); i++) {
        // cout << "precomputing for i = " << i << endl;
        vector<int> taken;
        for (int j = 0; (1 << j) <= i; j++) {
            // cout << "pushing " << j << endl;
            if ((1 << j) & i) taken.push_back(j);
        }
        for (int j = 0; j < int(taken.size()); j++) {
            for (int k = j + 1; k < (int)taken.size(); k++) {
                score[i] += a[taken[j]][taken[k]];
                // cout << "score added for " << taken[j] << " " << taken[k] << endl;
            }
        }
    }

    // cout << "scores precomputed" << endl;

    vector<ll> dp(1 << n, LLONG_MIN);

    cout << ans((1 << n) - 1, dp);

    return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
using namespace std;


int main ()
{

int n;
cin >> n;

if(n<1000)
{
	cout << "ABC" << endl;
}
else
{
	cout << "ABD" << endl;
}
 	return 0;
}












Measured memory_bytes: 3604
#include<functional>
#include<algorithm>
#include<iostream>
#include<utility>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,x,n) for(int i=x;i<n;i++)
#define pb push_back
#define pf push_front
#define int long long
using namespace std;
const int INF=1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


signed main(){
  int n;
  cin>>n;
  int a[100000];
  rep(i,n)cin>>a[i];
  int temp=0,c=1;
  rep(i,n){
    if(a[temp]==2){
      cout<<c<<endl;
      return 0;
    }
    temp=a[temp]-1;
    c++;
  }
  cout<<-1<<endl;

  return 0;
}




Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using Pair = System.Collections.Generic.KeyValuePair<int, int>;
//using System.Numerics;
//using static System.Math;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 };
    readonly int mod = 1000000007;
    readonly string alfa = "abcdefghijklmnopqrstuvwxyz";
    readonly string ALFA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

    int N;
    void solve()
    {
        var S = cin.next;
        N = S.Length;
        for (int i = 0; i < N - 8; i++)
        {
            Write(S[i]);
        }
        WriteLine();
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}


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

int main(){
int W, a, b;
  cin >> W >> a >> b;
  if(b > a + W) cout << b - a - W << endl;
  else if(b + W < a) cout << a - b - W << endl;
  else cout << 0 << endl;
  
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int top;
int S[1000];
void push(int x)
{
	top++;
	S[top]=x;
}
int pop()
{
	top--;
	return S[top+1];
}
int main()
{
	int a,b;
	top=0;
	char s[100];
	while(scanf("%s",s)!=EOF)
	{
		if(s[0]=='+')
		{
			a=pop();
			b=pop();
			push(a+b);
		}
		else if(s[0]=='-')
		{
			a=pop();
			b=pop();
			push(b-a);
		}
		else if(s[0]=='*')
		{
			a=pop();
			b=pop();
			push(a*b);
		}
		else
		{
			push(atoi(s));
		}
	}
	printf("%d\n",pop());
	return 0;
}

Measured memory_bytes: 2712
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

s=SI()
n=len(s)
count=0
for i in range(n-1):
    if s[i]!=s[i+1]:
        count+=1
print(count)
    
    



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

int n,k,r,s,p;
string t;
int rps(char d)
{
    if(d=='r') return p;
    else if(d=='p') return s;
    else return r; 
}
int main()
{
    ios::sync_with_stdio(false);
	cin.tie(0);
    cin>>n>>k;
    cin>>r>>s>>p;
    cin>>t;
    int dp[100011]={0};
    int res=0;
    for(int i=0;i<k;i++)
    {
        res+=rps(t[i]);
        dp[i]=res;
    }
    for(int i=k;i<t.size();i++)
    {
        if(t[i-k]==t[i])
        {
            dp[i]=max(dp[i-k],dp[i-1]);
            t[i]='0';
        }
        else{
            dp[i]=dp[i-1]+rps(t[i]);
        }
    }
    cout<<dp[n-1];
    return 0;
}

Measured memory_bytes: 848
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ll x, y;
    while (scanf("%lld%lld", &x, &y) != EOF) {
        int cnt = 0;
        while (x <= y) {
            cnt++;
            x *= 2;
        }
        printf("%d\n", cnt);
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<set>
#include<cstring>
#include<algorithm>
#include<cmath>
#define max_n
using namespace std;
typedef long long ll;
int a[100000+20]={0};

int main ()
{
	int i,n;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		int t;
		scanf("%d",&t);
		a[t]++;	
	}	
	int now=a[0]+a[1]+a[2],mx;
	mx=now;
	for(i=3;i<100000+20;i++)
	{
		mx=max(mx,now);
		now=now+a[i]-a[i-3];
	}
	printf("%d\n",mx);
	return 0;
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

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

int main(){
    int h, w;
    cin >> h >> w;
    int ch, cw;
    cin >> ch >> cw;
    int dh, dw;
    cin >> dh >> dw;
    ch--; cw--; dh--; dw--;
    vector<string> maze(h);
    for (int i = 0; i < h; ++i) {
        cin >> maze[i];
    }

    int res[1010][1010];
    for (int i = 0; i < 1010; ++i) {
        for (int j = 0; j < 1010; ++j) {
            res[i][j] = INF;
        }
    }

    deque<pair<pii, int>> que;
    res[ch][cw] = 0;
    que.push_back(make_pair(pii(ch, cw), 0));
    while(!que.empty()){
        pair<pii, int> p = que.front();
        que.pop_front();
        int x = p.first.first;
        int y = p.first.second;
        if (p.second > res[x][y]) continue;

        // 移動A
        for (int i = 0; i < 4; ++i) {
            int nx = x + dx[i];
            int ny = y + dy[i];
            if (nx < 0 || nx >= h || ny < 0 || ny >= w) continue;
            if (maze[nx][ny] == '#') continue;

            if (res[x][y] >= res[nx][ny]) continue;
            res[nx][ny] = res[x][y];
            que.push_front(make_pair(pii(nx, ny), res[nx][ny]));
        }
        // 移動B
        for (int i = -2; i <= 2; ++i) {
            for (int j = -2; j <= 2; ++j) {
                if (i == 0 && j == 0) continue;
                int nx = x + i;
                int ny = y + j;
                if (nx < 0 || nx >= h || ny < 0 || ny >= w) continue;
                if (maze[nx][ny] == '#') continue;

                if (res[x][y] + 1 >= res[nx][ny]) continue;
                res[nx][ny] = res[x][y] + 1;
                que.push_back(make_pair(pii(nx, ny), res[nx][ny]));
            }
        }
    }

    cout << (res[dh][dw] == INF ? -1 : res[dh][dw]) << endl;
}


Measured memory_bytes: 9548
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=mod*mod*3LL;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

struct UnionFind {
    vector<int> par;
    UnionFind(int n) :par(n, -1) { }
    void init(int n) { par.assign(n, -1); }
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    bool connect(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    int size(int x) {
        return -par[root(x)];
    }
};

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    int n = h * w;
    string s[h];
    UnionFind uf(n);
    for(int i=0;i<h;i++){
    	cin >> s[i];
    }
    for(int i=0;i<h;i++){
    	for(int j=1;j<w;j++){
    		if(s[i][j] != s[i][j-1]) uf.connect(i * w + j, i * w + j - 1);
     	}
    }
    for(int i=1;i<h;i++){
    	for(int j=0;j<w;j++){
    		if(s[i][j] != s[i-1][j]) uf.connect(i * w + j, (i-1) * w + j);
    	}
    }
    vector<vector<ll> > cnt(n, vector<ll> (2, 0LL));
    for(int i=0;i<h;i++){
    	for(int j=0;j<w;j++){
    		if(s[i][j] == '#'){
    			cnt[uf.root(i*w+j)][1]++;
    		}else{
    			cnt[uf.root(i*w+j)][0]++;
    		}
    	}
    }
    ll ans = 0;
    for(int i=0;i<n;i++){
    	if(uf.par[i] < 0){
    		ans += cnt[i][0] * cnt[i][1];
    	}
    }
    cout << ans << endl;
    return 0;
}


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

#define VARNAME(x) #x
#define show(x) cerr << #x << " = " << x << endl

using namespace std;
using ll = long long;
using ld = long double;
template <typename T>
vector<T> Vec(int n, T v)
{
    return vector<T>(n, v);
}
template <class... Args>
auto Vec(int n, Args... args)
{
    auto val = Vec(args...);
    return vector<decltype(val)>(n, move(val));
}
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
    os << "sz:" << v.size() << "\n[";
    for (const auto& p : v) {
        os << p << ",";
    }
    os << "]\n";
    return os;
}

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


constexpr ll MOD = (ll)1e9 + 7LL;

template <typename T>
constexpr T INF = numeric_limits<T>::max() / 100;

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

    int N;
    cin >> N;
    vector<int> t(N);
    vector<int> x(N);
    vector<int> y(N);

    for (int i = 0; i < N; i++) {
        cin >> t[i];
        cin >> x[i] >> y[i];
    }
    for (int i = 0; i < N; i++) {
        const int dt = t[i] - (i == 0 ? 0 : t[i - 1]);
        const int d = abs(x[i] - (i == 0 ? 0 : x[i - 1])) + abs(y[i] - (i == 0 ? 0 : y[i - 1]));
        if (d > dt) {
            cout << "No" << endl;
            return 0;
        } else {
            if (d % 2 != dt % 2) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;

    return 0;
}


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

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char ch) {
  if(ch == 'A') {
    return 1;
  }
  else if(ch == 'C') {
    return 2;
  }
  else if(ch == 'G') {
    return 3;
  }
  else if(ch == 'T') {
    return 4;
  }
  else {
    return 0;
  }
}


long long getKey(char str[]) {
  long long sum = 0, p = 1, i;
  for(i = 0; i < strlen(str); i++) {
    sum += p * (getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key) {
  return key % M;
}

int h2(int key) {
  return 1 + (key % (M - 1));
}

int find(char str[]) {
  long long key, i ,h;
  key = getKey(str);
  for(i = 0; ; i++) {
    h = (h1(key) + i * h2(key)) % M;
    if(strcmp(H[h], str) == 0) {
      return 1;
    }
    else if(strlen(H[h]) == 0){
      return 0;
    }
  }
  return 0;
}

int insert(char str[]) {
  long long key, i, h;
  key = getKey(str);
  for(i = 0; ; i++) {
    h = (h1(key) + i * h2(key)) % M;
    if(strcmp(H[h], str) == 0) {
      return 1;
    }
    else if(strlen(H[h]) == 0) {
      strcpy(H[h], str);
      return 0;
    }
  }
  return 0;
}

int main(void) {
  int i, n;
  char str[L], com[9];
  for(i = 0; i < M; i++) {
    H[i][0] = '\0';
  }
  scanf("%d", &n);
  for(i = 0; i < n; i++) {
    scanf("%s %s", com, str);

    if(com[0] == 'i') {
      insert(str);
    }
    else {
      if(find(str)) {
        printf("yes\n");
      }
      else {
        printf("no\n");
      }
    }
  }
  return 0;
}

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

int main() {
	int a, b;
	cin >> a >> b;
	if (a < b) {
		cout << "a < b" << endl;
	}
	else {
		if (a > b) {
			cout << "a > b" << endl;
		}
		else {
			cout << "a == b" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <stack>
#include <functional>
#include <sstream>
#define rep(i,j,n) for(i=j;i<(n);i++)
#define rrep(i,j,n) for(i=j;i>(n);i--)
typedef long long int lli;
#define N 1000000007
#define M 998244353

using namespace std;

int main(){
    lli n,a,b,ans=0;
    lli i,j;
    cin>>n;
    rep(i,1,sqrt(n)+1){
        if(n%i==0){
            a=i;
            b=n/a;
//            cout<<a<<"✖️"<<b<<endl;
        }
    }
    a=max(a,b);
    while(a!=0){
        a/=10;
        ans++;
    }
    cout<<ans<<endl;
}


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

int main(){
    ll n; cin >> n;
    
    int len = 1;
    ll size = 26;
    ll m = n;
    while(m>size){
        m -= size;
        size *= 26;
        len++;
    }
    
    //cout << m << endl;
    m--;
    string a;
    for(int i=0; i<len; i++){
        a.push_back(m%26);
        m /= 26;
    }
    
    for(int i=len-1; i>=0; i--){
        cout << (char)(a[i]+'a');
    }
    cout << endl;
    /*
    
    string a;
    while(n!=0){
        int now = (n-1)%26;
        a = (char)(now+'a') + a;
        n -= now+1;
        n /= 26;
    }
    cout << a << endl;
    return 0;
    */
}

Measured memory_bytes: 3560
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
from sys import stdin

def prime(n):
    L = list(xrange(2, n))
    P = []
    while L[0] ** 2 < n:
        P.append(L[0])
        L = [i for i in L if i % P[-1]]
    return P + L

ps = prime(50030)
for line in stdin:
    n = int(line)
    for p in ps:
        if n < p:
            upper = p
            break
        if p < n:
            under = p
    print(under, upper)

Measured memory_bytes: 5912
def summ(n):
    n_s = str(n)
    tmp = 0
    for i in n_s:
        tmp += int(i)
    return tmp

N,A,B = map(int, input().split())

ans = 0
for i in range(N+1):
    if A <= summ(i) <= B:
        ans += i
print(ans)


Measured memory_bytes: 2940
N=int(input())
li=list(map(int, input().split()))
dp=1
for i in range(N-1):
    if dp:
        if li[i]-1==li[i+1]:
            dp=0
        elif li[i]-1>li[i+1]:
            print('No')
            break
        else:
            dp=1
    else:
        if li[i]==li[i+1]:
            dp=0
        elif li[i]>li[i+1]:
            print('No')
            break
        else:
            dp=1
else:
  print('Yes')

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

int main() {
  int n;
  cin >> n;
  string s;
  if (n % 10 == 3) {
    s = "bon";
  } else if ((n % 10 == 0) || (n % 10 == 1) || (n % 10 == 6) || (n % 10 == 8)) {
    s = "pon";
  } else {
    s = "hon";
  }
  cout << s << endl;
}


Measured memory_bytes: 3628
def main():
    N = int(input())
    v = list(map(int, input().split()))
    v_ki = v[1:N:2].copy()
    val_ki = [i+1 for i in range(10**5)]
    count_ki = [0] * (10**5)
    v_gu = v[0:N:2].copy()
    val_gu = [i+1 for i in range(10**5)]
    count_gu = [0] * (10**5)
    for i in range(N//2):
        count_ki[v_ki[i]-1] += 1
        count_gu[v_gu[i]-1] += 1
    
    ki = list(zip(count_ki, val_ki))
    ki.sort()
    gu = list(zip(count_gu, val_gu))
    gu.sort()
    if ki[-1][1] != gu[-1][1]:
        return N-ki[-1][0]-gu[-1][0]
    else:
        return min(N-ki[-2][0]-gu[-1][0], N-ki[-1][0]-gu[-2][0])

if __name__ == "__main__":
    print(main())


Measured memory_bytes: 32836
N, N, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

ruisekiA = [0]
ruisekiB = [0]
tmpA=0
tmpB=0
for i in range(len(A)):
    tmpA += A[i]
    ruisekiA.append(tmpA)
for i in range(len(B)):
    tmpB += B[i]
    ruisekiB.append(tmpB)
ans = 0
for i in range(len(ruisekiA)):
    #tmp = ruisekiA[i]
    l = 0
    r = len(ruisekiB)
    if ruisekiA[i] > K:
        continue
    while r - l > 1:
        mid = (r + l)//2
        tmp = ruisekiA[i]+ruisekiB[mid]
        if tmp <= K:
            l = mid
        else:
            r = mid

    ans = max(ans, i+l)
print(ans)

Measured memory_bytes: 132424
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,k,i,maior,soma;
    cin>>a>>b>>c;
    maior = max({a, b, c});
    soma = (a+b+c) - maior;
    cin>>k;
    
    if(k!=0){
        for(i=0;i<k;i++){
            maior*=2;
        }
        a = soma + maior;
    }else
        soma = a+b+c;

    cout<<a<<endl;
    return 0;
}

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

int charToInt(char c){
    char zero_num = '0';
    return (int)c - (int)zero_num;
}

signed main(){
    string A; cin>>A;

    //ナイーブに考えれば答えはnC2通り
    // ただし、選択した部分が回文になっていればそれは同じ結果になるのと、
    // 両端の文字が同じならばその両端を除いた部分をひっくり返すのと同じ結果になる
    // したがって
    // 回文の数
    // (各文字に関して同じペアの数 C 2)の和 - そのうち回文の数
    // をnC2から差っ引けばよい
    // と思ったんだけれど、これって回文の数がキャンセルするから、a-zの数を数えればOKなもんだいじゃね?

    char alphabet[26] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

    map<char, int> char_num;
    for(int i=0;i<26;i++){
        char_num[alphabet[i]] = 0;
    }
    int length= A.size();
    rep(i, length){
        char_num[A[i]] +=1;
    }

    int answer = length*(length-1)/2;

    for(int i=0;i<26;i++){
        answer -= char_num[alphabet[i]]*(char_num[alphabet[i]]-1)/2;
    }
    cout<<answer+1<<endl;




    return 0;
}

Measured memory_bytes: 3736
#include <queue>
#include <string>
#include <iostream>
using namespace std;
int bit_in[16][3][7][7], bit_out[16][3][7][7];
int main() {
	int N;
	cin >> N;
	vector<int> X(N), Y(N);
	for (int i = 0; i < N; ++i) cin >> X[i] >> Y[i];
	vector<string> BV(4);
	cin >> BV[0] >> BV[1] >> BV[2] >> BV[3];
	string B = BV[0] + BV[1] + BV[2] + BV[3];
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < 3; ++j) {
			char c = (j == 0 ? 'R' : (j == 1 ? 'G' : 'B'));
			for (int k = 0; k < 4 + X[i]; ++k) {
				for (int l = 0; l < 4 + Y[i]; ++l) {
					for (int p = 0; p < X[i]; ++p) {
						for (int q = 0; q < Y[i]; ++q) {
							int tx = k - p, ty = l - q;
							if (0 <= tx && tx < 4 && 0 <= ty && ty < 4) {
								if (B[tx * 4 + ty] == c) bit_in[i][j][k][l] |= 1 << (tx * 4 + ty);
								else bit_out[i][j][k][l] |= 1 << (tx * 4 + ty);
							}
						}
					}
				}
			}
		}
	}
	queue<int> que; que.push(0);
	vector<int> dist(1 << 16, -1); dist[0] = 0;
	while (!que.empty()) {
		int u = que.front(); que.pop();
		for (int i = 0; i < N; ++i) {
			for (int j = 0; j < 3; ++j) {
				char c = (j == 0 ? 'R' : (j == 1 ? 'G' : 'B'));
				for (int k = 0; k < 4 + X[i]; ++k) {
					for (int l = 0; l < 4 + Y[i]; ++l) {
						int bit = u;
						bit |= bit_in[i][j][k][l];
						bit &= ~bit_out[i][j][k][l];
						if (dist[bit] == -1) {
							dist[bit] = dist[u] + 1;
							que.push(bit);
						}
					}
				}
			}
		}
	}
	cout << dist[(1 << 16) - 1] << endl;
	return 0;
}


Measured memory_bytes: 3444
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>

template <class T, class U>
inline bool chmin(T &lhs, const U &rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

template <class T, class U>
inline bool chmax(T &lhs, const U &rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

// [l, r) from l to r
struct range {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr range(int l_, int r_): l(l_), r(std::max(l_, r_)) { }
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

// [l, r) from r to l
struct revrange {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr revrange(int l_, int r_): l(l_ - 1), r(std::max(l_, r_) - 1) { }
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

constexpr int inf = (1 << 30) - 1;

int main() {
  int H, W;
  std::cin >> H >> W;
  std::vector<std::string> grid(H);
  for (auto &s: grid) {
    std::cin >> s;
  }
  std::vector<std::vector<int>> dp(H, std::vector<int>(W, inf));
  dp[0][0] = (grid[0][0] == '#' ? 1 : 0);
  for (int i: range(0, H)) {
    for (int j: range(0, W)) {
      if (grid[i][j] == '#') {
        if (i > 0) chmin(dp[i][j], dp[i - 1][j] + (grid[i - 1][j] == '.' ? 1 : 0));
        if (j > 0) chmin(dp[i][j], dp[i][j - 1] + (grid[i][j - 1] == '.' ? 1 : 0));
      }
      else {
        if (i > 0) chmin(dp[i][j], dp[i - 1][j]);
        if (j > 0) chmin(dp[i][j], dp[i][j - 1]);
      }
    }
  }
  std::cout << dp[H - 1][W - 1] << '\n';
  return 0;
}


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

int main() {
    ios::sync_with_stdio(0);
    long double r;
    cin >> r;
    cout << M_PI * 2 * r << endl;


    return 0;
}

Measured memory_bytes: 3232
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
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;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
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 > 0) {
		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;
}

int n;
string s, t;

signed main() {
	cin >> n >> s >> t;
	for (int i = 0; i < n; i++) cout << s[i] << t[i];
	cout << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#include <numeric>
#define IINF 1000000000
#define INF 3223372036854775807
#define MOD 1000000007
#define mod 1000000007
#define INT_MAX_ 2147483647
#define EPS (1e-10)
#define REP(i, a, n) fo-r (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
//#define rep(i,n)for (ll i = 0; i < (ll)(n); i++)
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
#define me memset
#define bit(n,k) ((n>>k)&1)
//#define leng length()
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
#define invp(a,p)pom(a,p-2,p)
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp1(pair<Pll,ll> a,pair<Pll,ll> b){
        return a.fi.se>b.fi.se;
}
ll cmp2(pair<Pll,ll> a,pair<Pll,ll> b){
        return a.se<b.se;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_t=clock();
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //------------------------------
    ll x;cin>>x;
    if(x>=1800)cout<<1<<endl;
    else if(x>=1600)cout<<2<<Endl;
    else if(x>=1400)cout<<3<<endl;
    else if(x>=1200)cout<<4<<endl;
    else if(x>=1000)cout<<5<<endl;
    else if(x>=800)cout<<6<<endl;
    else if(x>=600)cout<<7<<endl;
    else cout<<8<<endl;
    //------------------------------
    //fclose(stdin);
    //fclose(stdout);
    //ll end_t=clock();cout<<"time="<<end_t-begin_t<<"ms"<<endl;
    //------------------------------- 
    return 0;
}
//----------------------------------------------------------------------











































Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin >> N;
    int ans = false;
    for(int i = 0; i <= N; i+=4) {
        if((N-i)%7==0) ans = true;
    }
    cout << (ans ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N; cin>>N;
    vint x(N);
    REP(i,N) cin>>x[i];

    vint y=x;
    sort(ALL(y));

    REP(i,N){
        if(x[i]<=y[N/2-1])
            cout<<y[N/2]<<endl;
        else
            cout<<y[N/2-1]<<endl;
    }

}


Measured memory_bytes: 5376
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

int cnt[1000000];
int main(){
  int n;
  cin >> n;
  string t;
  cin >> t;
  rep(i,t.size()) cnt[int(t[i])]++;

  //for (int i=int('a'); i <= int('z');i++) cout << cnt[i];
  //printf("\n");

  rep(i,n-1){
     int tmp[1000000];
     for (int i=int('a');i <= int('z');i++){
        tmp[int(i)] = 0;
     }
     string s;
     cin >> s;
     rep(i,s.size()){
        tmp[s[i]]++;
     }
     for (int i=int('a');i <= int('z');i++){
        cnt[int(i)] = min(cnt[int(i)],tmp[int(i)]);
     }
     //for (int i=int('a'); i <= int('z');i++) cout << cnt[i];
     //printf("\n");
     //for (int i=int('a');i <= int('z');i++){
     //   cnt[int(i)] = 0;
     //}
     
  }
  string res="";
  char x = 'a';
  char y = 'z'; 
  for (int i = int(x);i <= int(y);i++){
     rep(j,cnt[i]) {
        res+=char(i);
     }
  }
  cout << res << endl;
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
int main()
{
    ll n;
    cin>>n;
    string s = to_string(n);
    ll flag=0;
    for(ll i=0;i<s.size();i++)
    {
        if(s[i]=='7')
        {
            flag=1;
            break;
        }
    }
    if(flag==1)
        cout<<"Yes";
    else
        cout<<"No";
}

Measured memory_bytes: 3664
n, k = map(int,input().split())
d = list(map(int,input().split()))

s = 0
while s<k and s == d[s]:
    s += 1

x = 0
y = 0
while x <4:
    if n // (10**x) >0:
        y = x
    x += 1

i = 0
a = [0]
m = 0
while i <= y:
    a.append(((n//(10**(y-i)))%10))
    i +=1

i = 0
t = 0
while i <= y + t:
    j = 0
    while j < k:
        if a[y-i+1] == d[j]:
            a[y-i+1] += 1
            if y-i+1 < y+1:
                a[y-i+2] = s
        if a[y-i+1] == 10:
            a[y-i+1] = 0
            a[y-i] +=1
        j+=1
    i+=1
    if a[0] == 1 and t == 0:
        i = 1
        while i<=y+1:
            a[i] = 0
            i += 1
        i = 0
        t = 1
        continue

i = 0
while i <= y + t:
    m += a[y-i+1]*(10**(i))
    i+=1


print(m)


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

#define REP(i,init, n) for(lli i=init;i<n;i++)
#define REPE(i,init, n) for(lli i=init;i<=n;i++)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

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

lli dp[101][101]; // k 個分用意しなくても上書きしてけば良いので、dp[i][j]のみ用意
bool used[101][101];
lli edges[101][101];
#define INF (LLONG_MAX / 3);

int main() {
    lli n, m;
    cin >> n >> m;
    REP(i, 0, m) {
        lli from, to, cost;
        cin >> from >> to >> cost;
        dp[from][to] = dp[to][from] = cost;
        edges[from][to] = edges[to][from] = cost;
    }

    // 初期化
    REPE(i, 1, n) {
        REPE(j, 1, n) {
            if (dp[i][j])
                continue;
            if (i == j)
                continue;
            dp[i][j] = INF;
        }
    }

    // 最短経路作成
    REPE(k, 1, n) {
        REPE(i, 1, n) {
            REPE(j, 1, n) {
                dp[j][i] = dp[i][j] = min(dp[i][j], dp[i][k]+dp[k][j]);
            }
        }
    }

    REPE(k, 1, n) {
        REPE(i, 1, n) {
            REPE(j, 1, n) {
                if (edges[i][j]) {
                    if (dp[i][j] == edges[i][j]) {
                        used[i][j] = used[j][i] = true;
                    }
                }
                if (edges[i][k]) {
                    if (dp[i][j] == edges[i][k] + dp[k][j]) {
                        used[i][k] = used[k][i] = true;
                    }

                }
                if (edges[k][j]) {
                    if (dp[i][j] == dp[i][k] + edges[k][j]) {
                        used[k][j] = used[j][k] = true;
                    }
                }
            }
        }
    }

    // dump
    lli ans = 0;
    REPE(i, 1, n) {
        REPE(j, i+1, n) {
            //cout << i << "-" << j << ": " << dp[i][j] << endl;
            if (!edges[i][j])
                continue;
            //cout << i << "-" << j << ": " << used[i][j] << endl;
            if (!used[i][j])
                ans++;
        }
    }
    cout << ans << endl;

}

// 4 5 1 2 1 1 3 3 2 3 2 2 4 1 3 4 100
// 5 5 1 2 12 2 3 14 3 4 7 4 5 9 5 1 18


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
#define pb push_back
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)

int main(){
  ll x;
  cin>>x;
  fr(i,1e5){
    if((i*(i+1))/2>=x){cout<<i<<endl;return 0;}
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#define ll long long

using namespace std;


int main() {
	int a, b;
	string s;
	cin >> a >> b;

	if (a == b) s = "==";
	else if (a > b) s = ">";
	else s = "<";
	cout << "a " << s << " b" << endl;
}




Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
template<class T>bool chmax(T &a, const T &b) { 
  if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) {
  if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる




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

  string in;
  vector<int> p(n+1,-1);
  int st=0;
  int go=n;
  int mid;

  cout << 0 << endl;
  cin>>in;
  if(in=="Vacant") return 0;
  if(in=="Male") {
    p[0]=1;
    p[n]=1;
  }
  if(in=="Female") {
    p[0]=0;
    p[n]=0;
  }

  rep(i,100){
    mid=(st+go)/2;
    cout << mid << endl;
    cin>>in;
    if(in=="Vacant") return 0;
    if(in=="Male") p[mid]=1;
    if(in=="Female") p[mid]=0;
    if(((st-mid)%2==0&&p[st]!=p[mid])||
    (abs((st-mid))%2==1&&p[st]==p[mid])) go=mid;
    else st=mid;
  }

}

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

int main(){
 
  long long N, i, b1, b2, count = 0;
  cin >> N;
  vector<long long> A(N + 1), B(N);
  for (i = 0; i < N + 1; i++) cin >> A.at(i);
  for (i = 0; i < N; i++) cin >> B.at(i);
  
  for(i = 0; i < N; i++){
    b1 = B.at(i); //勇者が倒せる人数
    B.at(i) = max(0ll, b1 - A.at(i)); //iの街で討伐作業を行った後の勇者の討伐可能数
    count += min(A.at(i), b1);
    A.at(i) = max(A.at(i) - b1, 0ll); //討伐された後の、iの街のモンスターの数
    
    
    b2 = B.at(i);
    count += min(A.at(i + 1), b2);
    A.at(i + 1) = max(A.at(i + 1) - b2, 0ll);
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int n,m,to[200001],nxt[200001],tot,col[100001],head[100001],sum[3],cnt;
long long ans;
bool vis[100001],flag;
void add(int u,int v){to[++tot]=v,nxt[tot]=head[u],head[u]=tot;}
void dfs(int x,int color){
    ++cnt;
    col[x]=color;
    sum[color]++;
    vis[x]=true;
    for(int i=head[x];i;i=nxt[i]){
        if(!vis[to[i]])dfs(to[i],3-color);
        else if(col[x]==col[to[i]])flag=true;
    }
}
int main(){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++){
        int u,v;
        scanf("%d%d",&u,&v);
        add(u,v);
        add(v,u);
    }
    for(int i=1;i<=n;i++)if(!vis[i]){
        dfs(i,1);
        if(!flag)ans+=1LL*sum[1]*sum[2];
        else ans+=1LL*cnt*(cnt-1)/2;
        sum[1]=sum[2]=flag=cnt=0;
    }
    printf("%lld\n",ans-m);
    return 0;
}

Measured memory_bytes: 3328
class Dice
	def initialize()
		@number = gets.split.map(&:to_i)

		# top bottom N E S W
		@dice_number = [1, 6, 5, 3, 2, 4]
	end

	def rotate(command)
		swap_number = []

		case command
		when 'N'
			swap_number = [2, 1, 4]
			swap(swap_number)
		when 'E'
			swap_number = [3, 1, 5]
			swap(swap_number)
		when 'S'
			swap_number = [4, 1, 2]
			swap(swap_number)
		when 'W'
			swap_number = [5, 1, 3]
			swap(swap_number)
		end
	end

	def rotate_horizontal 
		tmp = @dice_number[2]
		(2..4).each {|i| @dice_number[i] = @dice_number[i+1]}
		@dice_number[5] = tmp
	end

	def swap(number)
		number.map do |n|
			@dice_number[0], @dice_number[n] = @dice_number[n], @dice_number[0]
		end
	end

	def top
		@number[@dice_number[0]-1]
	end

	def front
		@number[@dice_number[4]-1]
	end

	def right
		@number[@dice_number[3]-1]
	end
end

dice = Dice.new

gets.to_i.times do
	top, front = gets.split.map(&:to_i)

	while top != dice.top do
		rotate_command = ['N', 'E', 'S', 'W'].sample
		dice.rotate(rotate_command)
	end

	while front != dice.front do
		dice.rotate_horizontal
	end

	puts dice.right
end

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

ll gcd(int n, int m){
  if(n < m) swap(n,m);

  if(m==0) return 0;
  while(m > 0){
    int res = n%m;
    n = m;
    m = res;
  }
  return n;
}

ll lcm(int n, int m){
  return m*n/gcd(n,m);
}


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

  ll l = lcm(n,m);
  bool ok = true;
  rep(i,gcd(n,m)) ok &= s[l/m*i]==t[l/n*i];
  cout<< (ok ? l : -1) << '\n';
  return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
/// TONI BO$$ was here
/// #MLC

using namespace std;
long long pinex(long long n,long long x,long long y)
{
    long long xx=x,yy=y,r;
    while(yy)
    {
        r=xx%yy;
        xx=yy;
        yy=r;
    }
    return (n/x)+(n/y)-(n/(x*y/xx));
}
int main()
{
    int c,d;
    long long a,b,rez;
    scanf("%lld%lld%d%d",&a,&b,&c,&d);
    printf("%lld",(b-a+1)-pinex(b,c,d)+pinex(a-1,c,d));

    return 0;
}


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

#define pb     push_back
#define mp     make_pair
#define all(v) v.begin() , v.end()
#define allr(v) v.rbegin(), v.rend()
const ll INF =  0x3f3f3f3f;
const int MOD = 1e9+7;
const int MAX = 1e5+5;

ll q, h, s, d, n;

int main(int argc, char const *argv[])
{
  ios_base::sync_with_stdio(false);
  
  // #ifndef ONLINE_JUDGE
  // freopen("in","r",stdin);
  // freopen("out","w",stdout);
  // #endif

  scanf("%lld %lld %lld %lld" , &q, &h, &s, &d);
  scanf("%lld" , &n);

  ll ans;
  ll ol = min(min(4*q, 2*h), s);
  if(n%2 == 0)
  	ans = min(n*ol, (n/2)*d);
  else
  	ans = min(n*ol, (n/2)*d + ol);

  printf("%lld", ans);

  return 0;
} 

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

int main(){
    int n;
    cin >> n;
    map<string, int> mp;
    rep(i,n){
        string s;
        cin >> s;
        auto ite = mp.find(s);
        if(ite!=mp.end()) mp.at(s)++;
        else mp.insert(make_pair(s,1));
    }
    int m;
    cin >> m;
    rep(i,m){
        string s;
        cin >> s;
        auto ite = mp.find(s);
        if(ite!=mp.end()) mp.at(s)--;
        else mp.insert(make_pair(s,-1));
    }
    int ans = 0;
    for(auto x:mp){
        ans=max(ans,x.second);
    }

    cout << ans << endl;

}

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

class Edge
{
public:
	int src,dst,cst;
	Edge(int src, int dst, int cst)
	:src(src),dst(dst),cst(cst)
	{}
};

class State
{
public:
	int p,c,d;
	State(int p, int c, int d)
	:p(p),c(c),d(d)
	{}
	
	bool operator<(const State& s) const {
		if(c != s.c) return c > s.c;

		return d > s.d;
	}
};

typedef vector<vector<Edge> > Graph;

int N,M,C,S,G;
int COST[10001][20];
int P[20], Q[20][51], R[20][51];
int ct[100][100][20];

void dijkstra(int Start, int com, Graph& graph)
{
	priority_queue<State> q;
	q.push(State(Start, 0, 0));

	bool vis[100] = {0};
	while(!q.empty()) {
		State s=q.top(); q.pop();
		if(vis[s.p]) continue;
		vis[s.p] = 1;

		ct[Start][s.p][com] = s.c;

		for(int i=0; i<graph[s.p].size(); i++) {
			Edge& e = graph[s.p][i];

			int td = s.d + e.cst;
			int nc = 0;
			if(td > Q[com][P[com] - 1]) {
				nc = COST[Q[com][P[com] - 1]][com] + abs(td - Q[com][P[com]-1]) * R[com][P[com]-1];
			}
			else nc = COST[td][com];

			if(vis[e.dst]) continue;
			q.push(State(e.dst, nc, td));
		} 
	}
}

int solve(int Start, int Goal, Graph& graph)
{
	priority_queue<State> q;
	q.push(State(Start, 0, 0));

	bool vis[100] = {0};
	while(!q.empty()) {
		State s=q.top(); q.pop();
		if(vis[s.p]) continue;
		vis[s.p] = 1;

		if(s.p == Goal) return s.c;

		for(int i=0; i<graph[s.p].size(); i++) {
			Edge& e = graph[s.p][i];

			if(vis[e.dst]) continue;
			q.push(State(e.dst, s.c + e.cst, 0));
		}
	}

	return -1;
}

int main()
{
	while(cin >> N >> M >> C >> S >> G, (N||M||C||S||G)) {
		S--; G--;

		vector<Graph> graph(C);
		for(int i=0; i<C; i++)
			graph[i].resize(N);

		for(int i=0; i<M; i++) {
			int a,b,c,d;
			cin >> a >> b >> d >> c;
			a--; b--; c--;

			graph[c][a].push_back(Edge(a,b,d));
			graph[c][b].push_back(Edge(b,a,d));
		}

		for(int i=0; i<C; i++)
			cin >> P[i];

		for(int i=0; i<C; i++) {
			Q[i][0] = 0;

			for(int j=1; j<P[i]; j++)
				cin >> Q[i][j];
			
			for(int j=0; j<P[i]; j++)
				cin >> R[i][j];
		}

		for(int i=0; i<C; i++)
			COST[0][i] = 0;

		for(int i=0; i<C; i++)
		for(int j=1; j<P[i]; j++)
		for(int k=Q[i][j-1]+1; k<=Q[i][j]; k++) 
			COST[k][i] = COST[k-1][i] + R[i][j - 1];


		memset(ct, -1, sizeof(ct));
		for(int k=0; k<C; k++)
		for(int i=0; i<N; i++) {
			dijkstra(i, k, graph[k]);
		}


		Graph final(N);
		for(int i=0; i<N; i++)
		for(int j=i+1; j<N; j++) {
			int mmm = (1<<28);
			for(int k=0; k<C; k++) {
				if(ct[i][j][k] == -1) continue;
				mmm = min(mmm, ct[i][j][k]);
			}

			if(mmm == (1<<28)) continue;
			final[i].push_back(Edge(i,j,mmm));
			final[j].push_back(Edge(j,i,mmm));
		}

		cout <<  solve(S, G, final) << endl;
	}
}

Measured memory_bytes: 2892
a = list(map(int, input().split()))
if (a[0]==5 and a[1]==5 and a[2]==7) or (a[0]==5 and a[1]==7 and a[2]==5) or (a[0]==7 and a[1]==5 and a[2]==5):
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3060
#include<stdio.h>

int main(){

  int a,b,c;

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


  if(a<=c && b<=c){
    if (a<=b){
      printf("%d %d %d\n",a,b,c);
    }
    else{
      printf("%d %d %d\n",b,a,c);
    }
  }
  else if(b<=a && c<=a){
    if(b<=c){
      printf("%d %d %d\n",b,c,a);
    }
    else{
      printf("%d %d %d\n",c,b,a);
    }
  }
  else if(a<=b && c<=b){
    if (a<=c){
      printf("%d %d %d\n",a,c,b);
    }
    else {
      printf("%d %d %d\n",c,a,b);
    }
  }
  return 0;
}

Measured memory_bytes: 596
N,M,Q = list(map(int, input().split()))
a = [0] * Q
b = [0] * Q
c = [0] * Q
d = [0] * Q
res = 0

def dfs(array):
  if(len(array) == N+1):
    global res
    p = 0

    for i in range(Q):
      # Abi - Aai = Ci を満たすようなi についてのdiの総和
      if(array[b[i]] - array[a[i]] == c[i]):
        p += d[i]
  
    res = max(p, res);

    return

  array.append(array[-1])
  while(array[-1] <= M):
    dfs(array[::])
    array[-1] += 1

for i in range(Q):
  a[i], b[i], c[i], d[i] = list(map(int, input().split()))

dfs([1])

print(res)




Measured memory_bytes: 9240
n = int(input())
c0 = 0
c1 = 0
c2 = 0
c3 = 0
for i in range(n):
  s = input()
  if s == 'AC':
    c0 += 1
  elif s == 'WA':
    c1 += 1
  elif s == 'TLE':
    c2 += 1
  else:
    c3 += 1
print(f'AC x {c0}')
print(f'WA x {c1}')
print(f'TLE x {c2}')
print(f'RE x {c3}')

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

std::string s;

int main () {
  std::cin >> s;
  for (int i = 1; i < s.size(); ++i) {
    std::vector<char> before, after;
    for (int j = 0; j < s.size()/2-i; ++j){ 
      before.push_back(s[j]);
	  after.push_back(s[j+s.size()/2-i]); 
	}
	if (before == after){
	  std::cout << s.size()-2*i << std::endl;
	  break;
	} 
  }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define mset(x, y) memset(x, y, sizeof x)
#define mcpy(x, y) memcpy(x, y, sizeof x)
using namespace std;

typedef long long LL;
typedef pair <int, int> pii;

inline int Read()
{
	int x = 0, f = 1, c = getchar();
	for (; !isdigit(c); c = getchar())
		if (c == '-')
			f = -1;
	for (;  isdigit(c); c = getchar())
		x = x * 10 + c - '0';
	return x * f;
}

int main()
{
#ifdef wxh010910
	freopen("data.in", "r", stdin);
#endif
	int n = Read(), m = Read(), k = Read();
	for (int i = 0; i <= n; i ++)
		for (int j = 0; j <= m; j ++)
			if (i * m + j * n - 2 * i * j == k)
				return puts("Yes"), 0;
	puts("No");
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;

#define errp(...) fprintf(stderr, __VA_ARGS__)

int main () { 
	int a,b,c,d;
	scanf("%d%d%d%d", &a, &b, &c, &d);
	int area1=a*b,area2=c*d;
	if(area1>=area2)
		printf("%d",area1);
	else
		printf("%d",area2);

}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
	rep(i,3){
		string s; cin>>s;
		char c = s[0];
		c = c-'a'+'A';
		cout<<c;
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 256