akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int A,B;
int a[5555],b[5555];
int main(void){
  cin >> A >> B;
  for(int i = 0; i < A; i++) cin >> a[i];
  for(int i = 0; i < B; i++) cin >> b[i];

  int res = 0;
  for(int i = 0; i < B; i++){
    int p = i;
    for(int j = 0; j < A && p < B; j++){
      if(a[j] == b[p]) p++;
    }
    res = max(res,p-i);
  }
  cout << res << endl;
}

Measured memory_bytes: 1208
{-# LANGUAGE BangPatterns #-}

module Main
  ( main
  )
where
 
import           Control.Applicative
import           Control.Monad
import           Data.Bits
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import           Data.List
import           Data.Maybe
import qualified Data.Vector                   as V
 
parse = fst . fromJust
parseInt = parse . BS.readInt
parseInteger = parse . BS.readInteger
readInt = parseInt <$> BS.getLine
readInteger = parseInteger <$> BS.getLine
readIntList = map parseInt . BS.words <$> BS.getLine
readIntegerList = map parseInteger . BS.words <$> BS.getLine

res = 1000000000 + 7

main = do
  [a, b] <- map (\val -> if val == 1 then 14 else val) <$> readIntList
  putStrLn $ if a > b then "Alice" else if a < b then "Bob" else "Draw"


Measured memory_bytes: 380
#include "bits/stdc++.h"
using namespace std;
const int maxn = 200200;
int main(){
  int n, m, c;
  cin >> n >> m >> c;
  vector<int> b(m);
  for(int & u : b) cin >> u;
  int cc = 0;
  for(int i = 0; i < n; i++){
    vector<int> a(m);
    for(int & u : a) cin >> u;
    int sum = 0;
    for(int j = 0; j < m; j++) sum += b[j] * a[j];
    sum += c;
    if(sum > 0) cc++;
  }
  cout << cc << endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;

#include <math.h>
#define PI 3.14159265358979323846264338327950L

long long gcd(long long a, long long b)
{
    for (;;)
    {
        if (a == 0) return b;
        b %= a;
        if (b == 0) return a;
        a %= b;
    }
}

long long lcm(long long a, long long b)
{
    long long temp = gcd(a, b);

    return temp ? (a / temp * b) : 0;
}




int main() {
    int a, a1, a2;
    cin >> a >> a1 >> a2;
    if (a + a1 + a2 >= 22) {
        cout << "bust";
    }
    else {
        cout << "win";
    }

    return 0;
}

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

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " = " << x << endl
using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;

const ld PI = 3.14159265359;

ll MOD = (ll) 10399;
const ll MAXN = (ll) 1e3 + 10;
const ll INF = (ll) LONG_LONG_MAX / 100;
const ld EPS = (ld) 1e-8;
const ll P = 104107;

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

ll pw(ll b, ll p){
	if(p == 0) return 1;
	if(p & 1) return mul(b, pw(b, p - 1));
	return pw(mul(b, b), p / 2);
}
ll inv(ll x){
	return pw(x, MOD - 2);
}

int main(){
	/*
	ll n, k;
	cin >> n>> k;
	cout << n -k+1;*/
	ll r,g,b,n;
	cin >> r >> g >> b >> n;
	ll rem, ans = 0;
	for(int i = 0; i <= n; i+= r)
		for(int j = 0; j<=n;j+= b){
			rem = n - i - j;
			if((rem >= 0) && (rem % g == 0)) ans ++;
		}
	cout << ans;
	return 0;
}


/*
fuck hashal
*/



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

int main(){
	int a1, a2, a3, a4, b1, b2, b3, b4;
	cin >> a1 >> a2 >> a3 >> a4 >> b1 >> b2 >> b3 >> b4;
	cout << max(a1+a2+a3+a4, b1+b2+b3+b4) << endl;	
	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<algorithm>
#include<list>
#include<cmath>
#include<iomanip>
#include<queue>
#include<functional>
#include<climits>
#include<iterator>
using namespace std;

const double pi=4*atan(1.0);
using cWeightEdges=std::vector<std::vector<std::pair<int,int>>>;
struct cVertex{
	int dist;
	int prev;
};
constexpr int parent_null=-1;
inline void initialize_vertices(vector<cVertex>& Vertices,int start){
	for(auto& vertex:Vertices){
		vertex.dist=INT_MAX;
		vertex.prev=parent_null;
	}
	if(0<=start && start<Vertices.size()){
		Vertices[start].dist=0;
	}
}
inline void relax(int from,int to,int weight_from_to,vector<cVertex>& Vertices){
	if(from<0 || Vertices.size()-1<from || to<0 || Vertices.size()-1<to)return;

	//????????§???????????§??????????????????????????????
	if(Vertices[from].dist==INT_MAX && Vertices[from].prev==parent_null)return;

	if(Vertices[to].dist>Vertices[from].dist+weight_from_to){
		Vertices[to].dist=Vertices[from].dist+weight_from_to;
		Vertices[to].prev=from;
	}
}

pair<vector<cVertex>,bool> solve_by_BellmanFord(const cWeightEdges& Edges,int start){
	if(Edges.empty())return pair<vector<cVertex>,bool>();

	vector<cVertex> Vertices(Edges.size());
	initialize_vertices(Vertices,start);

	int EdgeNum=0;
	for(const auto edge:Edges){
		EdgeNum+=edge.size();
	}

	//relaxation process
	for(int i=0;i<EdgeNum-1;++i){
		for(int j=0;j<Edges.size();++j){
			for(const auto& val:Edges[j]){
				relax(j,val.first,val.second,Vertices);
			}
		}
	}

	//check the validity of the algorithm (if there exists some negative weight cycles, we cannot define shortest path)
	for(int i=0;i<Edges.size();++i){
		for(const auto& val:Edges[i]){
			if(Vertices[i].dist<INT_MAX && Vertices[val.first].dist>Vertices[i].dist+val.second){
				return make_pair(vector<cVertex>(),true);
			}
		}
	}

	return make_pair(Vertices,false);
}

int main() {
	int N,M,root;
	cin>>N>>M>>root;

	cWeightEdges Edges(N);
	for(int i=0;i<M;++i){
		int s,t,w;
		cin>>s>>t>>w;
		Edges[s].push_back(make_pair(t,w));
	}

	auto ans=solve_by_BellmanFord(Edges,root);

	if(ans.second){
		cout<<"NEGATIVE CYCLE"<<endl;
	}
	else{
		for(const auto & val:ans.first){
			if(val.dist==INT_MAX){
				cout<<"INF"<<endl;
			}
			else{
				cout<<val.dist<<endl;
			}
		}
	}

	//system("pause");
	return 0;
}

Measured memory_bytes: 3228
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, m, c = map(int, readline().split())
    b = list(map(int, readline().split()))

    ans = 0

    for i in range(n):
        a = list(map(int, readline().split()))
        cur = c
        for j in range(m):
            cur += a[j] * b[j]
        if cur > 0:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 61852
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <sstream>
#include <fstream>

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)

using namespace std;

int main() {
  int N, K;
  cin >> N >> K;
  int Ds[10] = {};
  rep (i, K) {
    int D;
    cin >> D;
    Ds[D] = 1;
  }
  for (int i = N; i <= 10 * N; i++) {
    string temp = to_string(i);
    bool is_valid = true;
    rep (y, temp.size()) {
      if (Ds[temp[y] - '0']) {
        is_valid = false;
        break;
      }
    }
    if (is_valid) {
      cout << i << endl;
      break;
    }
  }
  return 0;
}

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

int main(){
    while(1){
        int n;
        cin >> n;
        
        if(n == 0)  break;
        
        int A[n];
        for(int i = 0; i < n; i++)  cin >> A[i];

        int rest = 32;
        bool ichiro = true;
        int pos = 0;

        while(rest != 0){
            if(ichiro){
                rest -= (rest-1)%5;
            }else{
                rest -= A[pos];
                pos = (pos+1)%n;
            }

            ichiro = !ichiro;
            if(rest < 0)    rest = 0;
            cout << rest << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 2992
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a;i < b;i++)
#define rrep(i,a,b) for(int i = a;i >= b;i--)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << #x << ": " << x << endl;
typedef long long ll;
using namespace std;

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

   string s;
   cin >> s;
   char next = '0';
   int a = 0, b = 0;

   //cout << "a" << endl;
   rep(i,0,s.size()){
      if(s[i] != next) a++;
      if(next == '0') next = '1';
      else next = '0';
      //cout << a << endl;
   }

   //cout << "b" << endl;
   
   next = '1';
   rep(i,0,s.size()){
      if(s[i] != next) b++;
      if(next == '0') next = '1';
      else next = '0';
      //cout << b << endl;
   }

   cout << min(a,b) << endl;

   return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
int main(){
    while(1){
        ll N, M, P;
        cin >> N >> M >> P;
        if(!N && !M && !P) break;
        M--;
        ll po[N];
        for(ll i = 0; i < N; i++) cin >> po[i];
        ll yo = 0;
        for(ll i = 0; i < N; i++) yo += po[i];
        yo *= 100;
        cout << (po[M] ? yo * (100 - P) / (100 * po[M]) : 0) << endl;
    }
    return 0;
}


Measured memory_bytes: 3008
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>
#include <cstring>

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

typedef unsigned int uint;
typedef long long llong;
typedef unsigned long long ullong;
typedef long double ldouble;

typedef vector<llong> vecllong;
typedef vector<vecllong> vvecllong;

const llong MOD = 1e9 + 7;
const llong INF = 1e17;

#define FOR(i, n) for (llong i = 0; i < n; i++)
#define FORS(i, a, b) for (llong i = a; i < b; i++)
#define FORR(i, n) for (llong i = n; i > 0; i++)

double memo[310][310][310];  // dp[one][two][three]
double N;

double search(llong one, llong two, llong three) {
    if(memo[one][two][three] >= 0) {
        return memo[one][two][three];
    }
    if(one == 0 and two == 0 and three == 0) {
        return 0.0;
    }

    double ret = 0.0;
    if(one > 0) ret += search(one - 1, two, three) * one;
    if(two > 0) ret += search(one + 1, two - 1, three) * two;
    if(three > 0) ret += search(one, two + 1, three - 1) * three;
    ret += N;
    ret *= 1.0 / (one + two + three);

    memo[one][two][three] = ret;
    return ret;
};

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

    cin >> N;

    llong one = 0;
    llong two = 0;
    llong three = 0;

    FOR(i, N) {
        llong a;
        cin >> a;
        if(a == 1) {
            one++;
        } else if (a == 2) {
            two++;
        } else if (a == 3) {
            three++;
        }
    }

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

    double ans = search(one, two, three);

    printf("%.16f\n", ans);

    return 0;
}

Measured memory_bytes: 233088
import java.util.*;
public class Main{

	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int a = Integer.parseInt(scan.next());
		int b = Integer.parseInt(scan.next());
		int h = Integer.parseInt(scan.next());
		int m = Integer.parseInt(scan.next());

		double theta_short = h*30 + m*0.5;
		double theta_long = m*6;

		double theta = Math.min(Math.abs(theta_long - theta_short), 360 - Math.abs(theta_long - theta_short));

		System.out.print(Math.pow(a*a + b*b -2*a*b*Math.cos(Math.toRadians(theta)),0.5));

	}
}



Measured memory_bytes: 35932
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <iomanip>
#include <algorithm>
#include <cmath>

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

int main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;

	while (true) {
		C -= B;
		if (C <= 0) {
			cout << "Yes" << endl;
			return 0;
		}
		A -= D;
		if (A <= 0) {
			cout << "No" << endl;
			return 0;
		}
	}

	return 0;
}


Measured memory_bytes: 3568
#include <iostream>
#include <string>
#include <algorithm>
#define REP(i, n) for(int i = 0; i < n; i++)
using namespace std;
const int MAX_N = 20;
const int MAX_M = 200;
int A[MAX_N + 1];
int B[MAX_M + 1];
int n, m, i;
bool exhaustive(int i, int m)
{
    if(m == 0) return 1;
    else if(m < 0 || i >= n) return 0;
    else return exhaustive(i + 1, m - A[i]) || exhaustive(i + 1, m);
}
int main()
{
    cin >> n;
    REP(i, n) cin >> A[i];
    cin >> m;
    REP(i, m) cin >> B[i];
    REP(i, m)
    {
        string ans = exhaustive(0, B[i]) ? "yes" : "no";
        cout << ans << endl;
    }
}

Measured memory_bytes: 3204
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines



def main():
    #距離が3の倍数である経路のうち最短である経路が存在するかどうかを調べる
    #存在するときその経路の距離を3で割った商が答え
    #存在しないとき-1を出力する

    #経路の距離を3で割った余りで頂点の状態を分類する

    #与えられたグラグをGとする
    #Gの辺の張っている隣接頂点u,vを考える
    #Gは有効グラフであるからu->vの様に辺が張っているとする
    #次のようにグラフGの頂点拡張する
    #(u, r) := uへたどり着く最短経路を3で割ったときr余る状態（状態を頂点とした新たなグラフG'を考えることになる）
    #辺の重みは1であるので(u, 0)->(v, 1), (u, 1)->(v, 2), (u, 2) -> (v, 0)の状態遷移が考えられる
    #（例：余り0から1移動すれば経路は1伸びるから全経路を3で割った余りは1となる）

    #(S, 0) -> ... ->(T, 0)となる最短経路が「距離が3の倍数である経路のうち最短である経路」である

    N, M = map(int, readline().split())
    to = [[] for _ in range(N)]
    for _ in range(M):
        u, v = map(int, readline().split())
        u-=1
        v-=1
        to[u].append(v)
    S, T = map(int, readline().split())
    S-=1
    T-=1

    INF = int(1e9)
    #距離を3で割った余りで分類して状態の遷移を考える
    dist = [[INF for _ in range(3)] for _ in range(N)]     

    #BFS
    from collections import deque
    dq = deque()
    dq.append((S, 0))
    dist[S][0] = 0
    while len(dq)>0:
        v, r = dq.popleft() 
        for nxv in to[v]:
            nxr = (r+1)%3
            if dist[nxv][nxr] != INF:
                continue
            dist[nxv][nxr] = dist[v][r] + 1
            dq.append((nxv, nxr))

    if dist[T][0] == INF:
        print(-1)
    else:
        print(dist[T][0]//3)
if __name__ == '__main__':
    main()


Measured memory_bytes: 67504
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <numeric>
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
typedef unordered_map<ll, ll> ump;
typedef pair<ll, ll> P;

ump mp;

ll comb2(ll n) {
    return n * (n - 1) / 2;
}

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
        mp = ump();
#pragma clang diagnostic pop
#endif
        ll n;
        cin >> n;
        vector<ll> a(n);
        ll dp[n + 1];
        rep(i, n) cin >> a[i];
        dp[0] = 0;
        rep(i, n) {
            dp[i + 1] = dp[i] + a[i];
        }

        rep(i, n + 1) mp[dp[i]]++;
        ll ans = 0;
        each(m, mp) {
            ans += comb2(m.second);
        }
        cout << ans << endl;


#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 11592
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include<stack>
#include<sstream>
#include<iomanip>
#include<map>
typedef long long ll;

#define pi 3.14159265358979323846
#define VI vector<int>
#define VLL vector<long long>
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
const ll MOD = 1e9 + 7;
using namespace std;
template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}

template<typename T>
T finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}
ll frac(ll n)
{
	if (n == 0) {
		return 1;
	}
	return (n * frac(n - 1)) % MOD;
}

/*char r[4];
int yaju[4];
char op[3];
int sum = 0;
scanf("%s", r);
for (int i = 0;i < 4;i++) {
	yaju[i] = r[i] - '0';
}
*/
int main() {
	ll A,B,C,X,Y; cin >> A>>B>>C>>X>>Y;
	ll ans = 0;
	if ((A + B) >= C * 2) {
		if (X > Y) {
			ans += C * 2 * Y;
			if (A >= C * 2) ans += 2 * C * (X - Y);
			else ans += A * (X - Y);
		}
		else {
			ans += C * 2 * X;
			if (B >= C * 2)ans += 2 * C * (Y - X);
			else ans += B * (Y - X);
		}
	}
	else {
			ans += A * X;
			ans += B * Y;
		}
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    boolean flag = false;

    for(int i = 1; i <= b; i++){
      if(a * i % b == c){
        flag = true;
        break;
      }
    }

    if(flag == true){
      System.out.println("YES");
    }else{
      System.out.println("NO");
    }

  }
}

/*
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
String blank = sc.nextLine();
String s = sc.nextLine();
System.out.println();
System.exit(0)
*/


Measured memory_bytes: 22868
#include<bits/stdc++.h>
using namespace std;
int sum(int i){
  int sum=0;
   while(i>0){
      sum+=i%10;
      i/=10;
    }
  return sum;
}
int main(){
  int n;
  int min=1<<30;
  cin >>n;
  for(int i=1;i<n;i++){
    int j=n-i;
    int k=sum(i)+sum(j);
    if(min>k)min=k;
  }
  cout << min << endl;
}

      


Measured memory_bytes: 3608
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 100000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
struct edge { int to, cost; };

//sは初めの点、vは頂点size、dは最短距離を求める(初期化はINF),Gは有向グラフ
void dijkdtra(int s, int v, vector<int>& d, whei(edge)& G) {
	priority_queue<Pint, vector<Pint>, greater<Pint>> que;//firstが距離、secondが頂点
	d[s] = 0;//スタートの距離はもちろんzero
	que.push(Pint(0, s));
	while (!que.empty()) {
		Pint p = que.top();
		que.pop();
		int V = p.second;
		if (d[V] < p.first)continue;
		for (int i = 0; i < G[V].size(); i++) {
			edge e = G[V][i];
			if (d[e.to] > d[V] + e.cost) {
				d[e.to] = d[V] + e.cost;
				que.push(Pint(d[e.to], e.to));
			}
		}
	}
}


int main() {
	double n, k;
	double ans = 0;
	cin >> n >> k;
	rep(i, 1, n + 1) {
		double x = 1 / n;
		int a = i;
		for (;;) {
			if (a >= k)break;
			a *= 2;
			x /= 2;
		}
		ans += x;
	}
	cout << keta(10) << ans << endl;
	return 0;
}

Measured memory_bytes: 256
//I am so vegetable
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define FIO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define PB push_back
#define IN insert
#define ER erase
#define CT count
#define EP empty
#define _for(i,a,b) for(int i = (a);i<(b);++i)
#define _rfor(i,a,b) for(int i = (a);i>(b);--i)
#define _sfor(p,st) for(auto &p:st)
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;
const double eps = 1e-6;
const double pi = 3.141593;
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
ll qpow(ll x, ll y) { ll ans = 1; for (; y > 0; y >>= 1) { if (y & 1)ans *= x; x *= x; }return ans; }
ll qpow(ll x, ll y, int MOD) { ll ans = 1; for (; y > 0; y >>= 1) { if (y & 1)ans = ans*x%MOD; x = x*x%MOD; }return ans; }
void exgcd(ll a,ll b,ll &x,ll &y){
    if(!b){x=1;y=0;return;}
    exgcd(b,a%b,x,y);
    ll X=x;
    x=y; y=X-a/b*y;
}
ll inv(ll x, int mod = MOD) { return qpow(x, mod - 2) % mod; }
ll m_m(ll a){ return (a%MOD+MOD)%MOD; }

int main() {
	//ofstream cout("E:\\acm dream\\out.txt",ios::out);
	FIO;
	string s,s1;cin>>s>>s1;
    if(s==s1.substr(0,s.size()))cout<<"Yes";
    else cout<<"No";
	return 0;
}

Measured memory_bytes: 3656
#include <iostream>

using namespace std;
int f1(int a,int b,int c)
{
    if(a!=b&&b!=c&&c!=a)
        return 1;
    else
        return 0;
}
int f2(int a,int b,int c)
{
    if(a+c>b&&a+b>c&&b+c>a)
        return 1;
    else
        return 0;
}
int main()
{
   int n;
   cin>>n;
   int s[n+5],i,j,k,z=0;
   for(i=0;i<n;i++)
    cin>>s[i];
   for(i=0;i<n;i++)
   {
       for(j=i+1;j<n;j++)
       {
           for(k=j+1;k<n;k++)
           {
               if(f1(s[i],s[j],s[k])&&f2(s[i],s[j],s[k]))
                z++;
           }
       }
   }
   cout<<z<<endl;
    return 0;
}


Measured memory_bytes: 3632
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr double EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max()/2;
constexpr int MOD = 1e9+7;

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

    int n,a;cin>>n>>a;
    n%=500;
    if(n<=a) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
  int N,M;
  cin >> N >> M;
  int l = 1, r = N;
  for( int i=0;i<M;i++ )
    {
      int L,R;
      cin >> L >> R;
      l = max(l, L);
      r = min(r, R);
    }

  if( r-l < 0)
    cout << 0 << endl;
  else
    cout << r-l+1 << endl;
}


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

int main() {
    int n;
    int p[8];
    int q[8];

    cin >> n;
    for(int i=0; i<n; i++) cin >> p[i];
    for(int i=0; i<n; i++) cin >> q[i];

    int r[8];
    
    for(int i = 0; i < n; i++){
        r[i] = i+1;
    }

    int pn;
    int qn;
    int cnt = 1;

    do{
        int tmp = 0;
        for (int i = 0; i < n; i++){
            if(r[i] == p[i]) tmp++;
        }
        if(tmp == n) pn = cnt;

        tmp = 0;

        for (int i = 0; i < n; i++){
            if(r[i] == q[i]) tmp++;
        }
        if(tmp == n) qn = cnt;

        cnt++;
    }while(next_permutation(r,r+n));

    // cout << pn << " " << qn <<  endl;

    int ans = abs(pn-qn);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
#include <vector>
#include <cstdlib>
#include <utility>
#include <map>

using namespace std;

int main(){
    int x, y;
    cin >> x >> y;
    int a = max(x, y);
    int b = min(x, y);
    if(a - 1 >= b){
        cout << a + a - 1;
    }else{
        cout << a + b;
    }
}

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<ll> h(n);
  for (int i = 0; i < n; i++) cin >> h[i];
  bool ok = true;
  int bef = 0;
  for (int i = 0; i < n; i++) {
    if (h[i] > bef) {
      h[i]--;
    }
    if (bef > h[i]) ok = false;
    bef = h[i];
  }
  if (ok) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


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

    using namespace std;

    int main()
    {
      int N,c=0;

      cin>>N;
      string S;
      cin>>S;
      for(int i=0;i<N;i++)
      {
                if(S[i]=='A'&&S[i+1]=='B'&&S[i+2]=='C')
                    c++;
      }
      cout<<c<<endl;
    }


Measured memory_bytes: 256
#include <stdio.h>


int main()
{
	int t1, t2, t3, t4, sum;
	scanf("%d%d%d%d", &t1, &t2, &t3, &t4);
	sum = t1 + t2 + t3 + t4;
	printf("%d\n%d\n", sum / 60, sum % 60);
	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>
#include <stack>
#include <numeric>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)


int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    n *= 2;
    ll res = 1;
    for(int i=1;i<=n/2;i++){
        res *=i;
        res %= mod;
    }
    if(s[0]=='W'||s[n-1]=='W'){
        cout << 0 << endl;
        return 0;
    }

    ll p = 1;
    for(int i=1;i<n;i++){
        if(s[i]=='B'){
            if(p%2==1){
                res *= p;
                res %= mod;
                p--;
            }else{
                p++;
            }
        }else if(s[i]=='W'){
            if(p%2==1){
                p++;
            }else{
               res *= p;
                res %= mod;
                p--; 
            }
        }
    }
    if(p!=0){
        cout << 0 << endl;
    }else{
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 888
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	class Edge {
		int src;
		int dst;
		int cap;

		public Edge(int src, int dst, int cap) {
			this.src = src;
			this.dst = dst;
			this.cap = cap;
		}
	}

	void solve(int V, int E, int[][] cap, int[][] flow, int s, int t) {
		int tot = 0;
		while (true) {
			int[] pre = new int[V];
			Arrays.fill(pre, -1);
			ArrayDeque<Integer> que = new ArrayDeque<>();
			que.add(s);
			out: while (!que.isEmpty()) {
				int cur = que.poll();
				for (int dst = 0; dst < V; ++dst) {
					if (cap[cur][dst] - flow[cur][dst] <= 0)
						continue;
					if (pre[dst] != -1 && dst != s)
						continue;
					pre[dst] = cur;
					if (dst == t)
						break out;
					que.add(dst);
				}
			}
			if (pre[t] == -1)
				break;
			int inc = Integer.MAX_VALUE / 16;
			for (int i = t; i != s; i = pre[i]) {
				inc = Math.min(inc, cap[pre[i]][i] - flow[pre[i]][i]);
			}
			for (int i = t; i != s; i = pre[i]) {
				flow[pre[i]][i] += inc;
				flow[i][pre[i]] -= inc;
			}
			tot += inc;
		}
		System.out.println(tot);

	}

	void run() {
		Scanner sc = new Scanner(System.in);
		int V = sc.nextInt();
		int E = sc.nextInt();
		int[][] cap = new int[V][V];
		int[][] flow = new int[V][V];
		for (int i = 0; i < E; ++i) {
			int u = sc.nextInt();
			int v = sc.nextInt();
			int c = sc.nextInt();
			cap[u][v] = c;
		}
		int s = 0;
		int t = V - 1;

		solve(V, E, cap, flow, s, t);
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

Measured memory_bytes: 34468
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
int getDigit(int n);            // 数字の桁数を取得する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;

// code
// ------------------------------------------------
int main() {

  ll n,a,b;
  cin >> n >> a >> b;

  cout << ((a + b) % 2 == 0 ? "Alice" : "Borys") << endl;


  return 0;
}
// funcの実体
// ------------------------------------------------
int getDigit(int n)
{
  int i = 1;
  while(1)
  {
    n = n / 10;
    if(n == 1)
      break;
    i++;
  }
  return i;
}
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 256
#ABC168C.rb
a,b,h,m = gets.split.map(&:to_f)

#M
mc = m*6

#H
hc = (h*60+m)*0.5

#CC
cc = (mc - hc).abs

if cc == 180
  #puts "#{cc}"
  puts a+b
  exit
elsif cc > 180
  cc = 360 - cc
end

#puts "mc #{mc}"
#puts "hc #{hc}"
#puts "cc #{cc}"

l = (Math.sqrt((a**2)+(b**2)-2*a*b*(Math.cos(Math::PI/(180/cc)))))

puts l


Measured memory_bytes: 14708
#!/usr/bin/env python3


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    N = int(input())
    A = map(int, input().split())
    B = filter(lambda x: x%2==0, A)
    print('APPROVED' if all(map(lambda x: x%3==0 or x%5==0, B)) else 'DENIED')

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
using System;
using CompLib.Util;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        string s = sc.Next();
        Console.WriteLine(s.Substring(0, 3));
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 25688
<?php

function input() {
    return trim(fgets(STDIN));
}
function input_array() {
    return explode(' ', input());
}

function partition(&$A, $p, $r) {
    $x = $A[$r];
    $i = $p - 1;
    for ($j = $p; $j < $r; $j++) {
        if ($A[$j] <= $x) {
            $i++;
            $t = $A[$i]; $A[$i] = $A[$j]; $A[$j] = $t;
        }
    }
    $t = $A[$i + 1]; $A[$i + 1] = $A[$r]; $A[$r] = $t;
    return $i + 1;
}

$n = (int)input();
$A = array_map(function($numeric_string) {
    return (int)$numeric_string;
}, input_array());
$q = partition($A, 0, $n - 1);

echo implode(' ', array_slice($A, 0, $q)) . ' [' . $A[$q] . '] ' . implode(' ', array_slice($A, $q + 1)) . "\n";


Measured memory_bytes: 40912
package main

import (
	"fmt"
)

func answer(n int) string {
	f := []int{1, 1}
	for i := 2; i <= n; i++ {
		f = append(f, f[i-1]+f[i-2])
	}

	return fmt.Sprintf("%d", f[n])
}

func main() {
	var n int
	fmt.Scan(&n)
	fmt.Println(answer(n))
}



Measured memory_bytes: 1128
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    ll h,w,m;
    cin >> h >> w >> m;
    Vi hor(h,0),ver(w,0);
    map<PLL,int> ma;
    rp(i,m){
        ll h,w;
        cin >> h >> w;
        h--;
        w--;
        hor[h]++;
        ver[w]++;
        ma[mp(h,w)]=1;
    }
    ll hmax=0,vmax=0;
    rp(i,h) chmax(hmax,hor[i]);
    rp(i,w) chmax(vmax,ver[i]);
    Vi hpos,vpos;
    rp(i,h){
        if(hmax==hor[i]) hpos.pb(i);
    }
    rp(i,w){
        if(vmax==ver[i]) vpos.pb(i);
    }
    bool inter=true;
    for(auto hh:hpos){
        for(auto vv:vpos){
            if(!ma.count(mp(hh,vv))){
                inter=false;
                break;
            }
        }
        if(!inter) break;
    }
    if(inter) print(hmax+vmax-1);
    else print(hmax+vmax);
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 35056
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

int main(int argc, char const *argv[]){
    int n;
    typedef pair<int, int> PII;
    auto comp = [](PII lhs, PII rhs) { return lhs.second > rhs.second; };
    priority_queue<PII, vector<PII>, decltype(comp) > que(comp);

    // priority_queue<PII, vector<PII>, 
    //                 decltype([](const PII& lhs, const PII& rhs) -> bool {
    //                     if (lhs.second < rhs.second) return true;
    //                     else return false;
    //                })> que;

    while (cin>>n, n){
        int value, capacity;
        for (int i = 0; i < n; i++){
            cin>>value>>capacity;
            que.push(PII(value, capacity));
        }

        int total = 0;
        bool success = true;
        while (!que.empty()){
            PII p = que.top();
            que.pop();
            total += p.first;
            // cout<<"total="<<total<<endl;
            if (total > p.second ){
                success = false;
            }
        }

        if (success) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }

    return 0;
}

Measured memory_bytes: 3088
#include <iostream>
#include <cmath>
#include <vector>
#include <cstring>
#include <algorithm>
using namespace std;

#define INF 1e10
#define EPS 1e-8

class Point3
{
public:
	double x,y,z;
	Point3()
	{}
	
	Point3(double x, double y, double z)
	:x(x),y(y),z(z)
	{}
	
	Point3 operator-(const Point3& p) const
	{
		return Point3(x-p.x, y-p.y, z-p.z);
	}
	
	Point3 operator+(const Point3& p) const
	{
		return Point3(x+p.x, y+p.y, z+p.z);
	}
	
	Point3 operator*(double s) const
	{
		return Point3(s*x, s*y, s*z);
	}

	Point3 operator/(double s) const
	{
		return Point3(x/s, y/s, z/s);
	}
};



double norm(Point3 a)
{
	return sqrt(a.x*a.x+a.y*a.y+a.z*a.z);
}

double dist3(Point3 a, Point3 b)
{
	return norm(a-b);
}


double dot(Point3 a, Point3 b)
{
	return (a.x*b.x + a.y*b.y + a.z*b.z);
}

Point3 cross(Point3& a, Point3& b)
{
	Point3 r;
	r.x = (a.y*b.z - a.z*b.y);
	r.y = (a.z*b.x - a.x*b.z);
	r.z = (a.x*b.y - a.y*b.x);
	return r;
}

Point3 unit(Point3 p)
{
	return p / norm(p);
}

Point3 projection(Point3 p, Point3 q)
{
	return unit(q)*dot(p,q) / norm(q);
}

Point3 perpendicular(Point3 p, Point3 q)
{
	return p - projection(p, q);
}

double distanceLP(Point3 p, Point3 v, Point3 q)
{
	return norm(perpendicular(q-p, v));

}

double distanceLL(Point3 p, Point3 vp, Point3 q, Point3 vq)
{
	Point3 uvp = unit(vp);
	Point3 uvq = unit(vq);

	double f = 1 - pow(dot(uvp, uvq), 2);
	if( abs(f) < EPS) return distanceLP(p, vp, q);

	double a = dot(p-q, uvq);
	double b = dot(q-p, uvp);
	double c = dot(uvp, uvq);
	double d = 1/f;

	double s = d * (b + c*a);
	double t = d * (c*b + a);

	return norm((p + uvp*s) - (q + uvq*t)); 
}

double dist[105][105];

int main()
{
	int N;
	while(cin >> N, N) {
		Point3 s,t;
		double sx,sy,sz,tx,ty,tz;
		cin >> sx >> sy >> sz >> tx >> ty >> tz;
		s = Point3(sx,sy,sz);
		t = Point3(tx,ty,tz);

		vector<pair<Point3, Point3> > pvs(N);
		for(int i=0; i<N; i++) {
			double x,y,z,a,b,c;
			cin >> x >> y >> z >> a >> b >> c;
			pvs[i].first = Point3(x,y,z);
			pvs[i].second = Point3(x,y,z) - Point3(a,b,c);
		}

		memset(dist, 0, sizeof(dist));

		for(int i=0; i<N; i++) {
			dist[N][i] = dist[i][N] = distanceLP(pvs[i].first, pvs[i].second, s);
			dist[N+1][i] = dist[i][N+1] = distanceLP(pvs[i].first, pvs[i].second, t);
		}

		dist[N][N+1] = dist[N+1][N] = dist3(s, t);

		for(int i=0; i<N; i++)
		for(int j=i+1; j<N; j++) {
			dist[i][j] = dist[j][i] = distanceLL(pvs[i].first, pvs[i].second, pvs[j].first, pvs[j].second);
		}

		for(int k=0; k<N+2; k++)
		for(int i=0; i<N+2; i++)
		for(int j=0; j<N+2; j++) 
			dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);

		cout.setf(ios::fixed);
		cout.precision(5);
		cout << dist[N][N+1] << endl;
	}
}

Measured memory_bytes: 1092
#include <iostream>
#include <string>
#include <cstring>

using namespace std;

int check_format(int a) {
    if(a<=12 && a>0) return 1;
    else return -1;
}

int main() {
    string str;
    cin >> str;
    
    // cout << stoi(str.substr(0, 2)) << endl;
    
    int fir=stoi(str.substr(0, 2)), sec=stoi(str.substr(2, 2));

    if(check_format(fir)==check_format(sec)) {
        if(check_format(fir)==1) {
            cout << "AMBIGUOUS" << endl;
        } else {
            cout << "NA" << endl;
        }
    } else {
        if(check_format(fir)==1) {
            cout << "MMYY" << endl;
        } else {
            cout << "YYMM" << endl;
        }
    }

    return 0;
    
}

Measured memory_bytes: 256
a,b,c,d=map(int,input().split())
MOD=998244353
dp=[[0]*(d+1) for _ in range(c+1)]
for i in range(a,c+1):
  for j in range(b,d+1):
    if i==a and j==b:
      dp[i][j]=1
    else:
      dp[i][j]+=dp[i][j-1]*i
      dp[i][j]+=dp[i-1][j]*j
      dp[i][j]-=dp[i-1][j-1]*(i-1)*(j-1)
      dp[i][j]%=MOD
print(dp[c][d]%MOD)

Measured memory_bytes: 136372
import math

N = int(input())
P = input().split(' ')
sorted_P = sorted(P)
P_num = 0
Q = input().split(' ')
sorted_Q = sorted(Q)
Q_num = 0
for i in range(len(P) - 1):
    P_num += sorted_P.index(P[i]) * math.factorial(N - i - 1)
    sorted_P.pop(sorted_P.index(P[i]))
for j in range(len(Q) - 1):
    Q_num += sorted_Q.index(Q[j]) * math.factorial(N - j - 1)
    sorted_Q.pop(sorted_Q.index(Q[j]))
print(abs(P_num - Q_num))


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

int main(){
  map<string, int> mp;
  int a, b;
  cin >> a;
  rep(i, a){
      string s;
      cin >> s;
      mp[s]++;
  }
  cin >> b;
  rep(i, b){
      string s;
      cin >> s;
      mp[s]--;
  }
  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<map>
#include<string>
#define rep(i,N) for(int i=0;i<N;i++)

long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;

const long long MAX=200010;
long long fac[MAX],finv[MAX],inv[MAX];

//階乗数をあらかじめ求めておく。

//階乗とその逆元
//n_C_k=n!×(k!)^-1×((n-k)!)^-1

//テーブルを作る前処理
void COMinit(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(long long  i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%mod;
        inv[i]=mod-inv[mod%i]*(mod/i)%mod;
        finv[i]=finv[i-1]*inv[i]%mod;
    }
}

//二項係数計算
long long COM(long long  n,long long  k){
    if(n<k)return 0;
    if(n<0 || k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}


int main(){

long long H,W,A,B;
cin>>H>>W>>A>>B;

long long ans=0;

COMinit();



for(long long  i=0;i+B<W;i++){
    ans+=COM(H-1-A+B+i,B+i)*COM(W-1-(B+i)+(A-1),W-1-(i+B));
    if(ans>mod)ans%=mod;
}

cout<<ans<<endl;




 return 0;
}
/*
2 3 1 1

2

10 7 3 4

3570

100000 100000 99999 99999

1

100000 100000 44444 55555

738162020
*/

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)
#define pb push_back
#define deb(x) cout<<#x<<" "<<x<<endl;
#define deb2(x, y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define deb3(x, y, z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define all(x) x.begin(), x.end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
const int mod = 1e9 + 7;
template<class T, class U> inline void add_self(T &a, U b){a += b;if (a >= mod) a -= mod;if (a < 0) a += mod;}
template<class T, class U> inline void min_self(T &x, U y) { if (y < x) x = y; }
template<class T, class U> inline void max_self(T &x, U y) { if (y > x) x = y; }

template <typename T>void print(T v, bool show_index = false){int w = 2;if(show_index){for(int i=0; i<v.size(); i++)cout<<setw(w)<<i<<" ";cout<<endl;}for(auto i= v.begin(); i!=v.end(); i++)cout<<setw(w)<<*i<<" ";cout<<endl;}
template <typename T>void print_vv(T v){if(v.size()==0) {cout<<"Empty"<<endl; return;} int w = 3;cout<<setw(w)<<" ";for(int j=0; j<v[0].size(); j++)cout<<setw(w)<<j<<" ";cout<<endl;for(auto i= 0; i<v.size(); i++){cout<<i<<" {";for(auto j = 0; j!=v[i].size(); j++){cout<<setw(w)<<v[i][j]<<",";}cout<<"},"<<endl;}cout<<endl;}
template <class T, class U> void print_m(map<T,U> m, int w=3){if(m.empty()){cout<<"Empty"<<endl; return;}for(auto x: m)cout<<"("<<x.first<<": "<<x.second<<"),"<<endl;cout<<endl;}

int main(){
    int n; cin>>n;
    while(n){
        int d = n%10;
        if(d==7){
            cout<<"Yes"<<endl;
            return 0;
        };
        n/=10;
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <algorithm>
using namespace std;
using ll = long long;
int main() {
  ll Q, H, S, D, N;
  cin >> Q >> H >> S >> D >> N;
  H = min(H, Q << 1);
  S = min(S, H << 1);
  cout << ((S << 1) <= D ? N * S : (N >> 1) * D + (N & 1) * S) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int min = 9999999;
  for(int i = 1; i < N;i++){
    int num1 = i;
    int num2 = N - i;
    int sum1 = 0;
    while(num1 > 0){
      sum1 += num1 % 10;
      num1 /= 10;
    }
    int sum2 = 0;
    while(num2 > 0){
      sum2 += num2 % 10;
      num2 /= 10;
    }
    if(min > sum1 + sum2) min = sum1 + sum2;
  }
  cout << min << endl;
}

Measured memory_bytes: 3556
#include<iostream>
#include<vector>
#include <algorithm>

using namespace std;
int main(){
	int N, ai;
  	cin >> N;
  	vector<int> A(N - 1);
    fill(A.begin(), A.end(), 0);
    for(int i = 0; i < N - 1; i++){
    	cin >> ai;
        A[ai - 1]++;
    }
    for(int i = 0; i < N - 1; i++) cout << A[i] << endl;
    cout << 0 << endl;
  	return 0;
}

Measured memory_bytes: 4052
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (progn (ql:quickload '(:cl-debug-print :fiveam))
                 (shadow :run)
                 (use-package :fiveam)))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

;; BEGIN_INSERTED_CONTENTS
(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(defmacro println (obj &optional (stream '*standard-output*))
  `(let ((*read-default-float-format* 'double-float))
     (prog1 (princ ,obj ,stream) (terpri ,stream))))

(defconstant +mod+ 1000000007)

;; Hauptteil

(defun main ()
  (let* ((a (read))
         (b (read))
         (k (read))
         (gcd (gcd a b)))
    (loop with c = 1
          for num from gcd downto 1
          do (when (zerop (mod gcd num))
               (when (= k c)
                 (println num)
                 (return-from main))
               (incf c)))))

#-swank(main)


Measured memory_bytes: 16100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false); cin.tie(0); cout.precision(10); cout << fixed
#define endl '\n'

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int n;
vector<int> a, b;

void solve(istream& cin, ostream& cout) {
  cin >> n;
  a.resize(n);
  b.resize(n);
  REP(i, n) cin >> a[i] >> b[i];
  double l, r;
  SORT(a);
  SORT(b);
  if (n % 2 == 0) {
    l = a[n / 2 - 1] + a[n / 2];
    r = b[n / 2 - 1] + b[n / 2];
    cout << int(r - l + 1) << endl;
  } else {
    l = a[(n - 1) / 2];
    r = b[(n - 1) / 2];
    cout << int(r - l + 1) << endl;
  }
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
  return 0;
}
#endif


Measured memory_bytes: 4800