akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
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; }

const int MOD = 1000000007;
const int INF = 1e9;

const int mod = 1000000007;
const int inf = 1e9;
#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    string s, t, u;
    cin >> s >> t >> u;
    cout << s[0] << t[1] << u[2] << endl;
}

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

using namespace std;

template<typename T>
long long modpow(const T n,const T p,const T mod);
template<typename T>
long long modinv(const T n,const T mod);
template<typename T>
bool chmax(T &a,const T &b);
template<typename T>
bool chmin(T &a,const T &b);

long long inf=1000000007;

int main(){
	long long n;
	cin>>n;
	long long ans=0;

	for(long long i=1;i<=n;i++){
		long long l=0,r=n;
		long long up=-1;
		while(r-l>1){
			long long mid=(l+r)/2;
			if(n-i*mid>=1){
				l=mid;
				up=l;
			}else{
				r=mid;
			}
		}//cout<<i<<" "<<up<<endl;

		if(up==-1) continue;
		ans+=up;
	}

	cout<<ans<<endl;

	return 0;
}

template<typename T>
long long modpow(const T n,const T p,const T mod){
	if(p==0) return 1;
	if(p%2==0){
		long long a=modpow(n,p/2,mod);
		return a*a%mod;
	}
	if(p%2==1) return (modpow(n,p-1,mod)*n)%mod;
	cerr<<"ERROR"<<endl;
	return 1;
}

template<typename T>
long long modinv(const T n,const T mod){
	return modpow(n,mod-2,mod);
}

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

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


Measured memory_bytes: 3628
def comb(n, k):
    ans = 1
    for i in range(k):
        ans *= (n-i)
    for i in range(k):
        ans //= (k-i)
    return ans

def count(n, k):
    if len(n) < k:
        return 0
    if k == 0:
        return 1
    if int(n) == 0:
        return 0
    if n[0] == "0":
        return count(n[1:], k)
    return count(n[1:], k-1) + comb(len(n)-1, k)*9**(k) + (int(n[0])-1)*comb(len(n)-1, k-1)*9**(k-1)

n = input()
k = int(input())
print(count(n, k))

Measured memory_bytes: 38256
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        a: [usize; n]
    };

    let a: Vec<usize> = a;
    let max = a.iter().max().unwrap();
    let max_count = a.iter().filter(|&x| x == max).count();

    for i in 0..n {
        if a[i] == *max && max_count == 1 {
            let mut x = a.clone();
            x[i] = 0;
            println!("{}", x.iter().max().unwrap());
        } else {
            println!("{}", max);
        };
    }
}


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

using namespace std;

long long n, a[1000005];
vector <long long> v;

int main () {
	cin >> n;
	for(int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for(int i = 0; i < n; i++) {
		if(a[i] % 2 == 0) {
			if(a[i] % 5 == 0 || a[i] % 3 == 0) {
			}
			else {
				cout << "DENIED";
				return 0;
			}
		}
	}
	cout << "APPROVED";
	return 0;
}

Measured memory_bytes: 256
N,M,X=map(int,input().split())
lst=[[0 for e in range(M+1)] for f in range(N)]
for i in range(N):
 lst[i]=list(map(int,input().split()))
F=10**7
for i in range(2**N):
 E=0
 Sui=[0]*N
 for j in range(N):
  if ((i >> j) & 1):
   Sui[j]+=1
 skl=[0]*M
 cost=0
 for k in range(N):
  if Sui[k]==1:
   for t in range(M):
    skl[t]+=lst[k][t+1]
   cost+=lst[k][0]
 E=0
 for t in range(M):
  if skl[t]>=X:
   E+=1
 if E==M:
  F=min(cost,F)
if F==10**7:
 print(-1)
else:
 print(F)


Measured memory_bytes: 9240
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <map>
#include <set>
#include <vector>
#include <list>
#include <queue>
#include <sstream>
#include <cmath>
#include <functional>
#include <climits>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define reps(s,i,n) for(int i=s;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define skip(i,n,p) for(int i=0;i<n;i+=p)
#define all(a)  (a).begin(),(a).end()
#define int64 long long
#define debug cerr << __FILE__ << ":" << __LINE__ << endl;
#define INF 2147483647

struct Init {
    Init() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout.precision(20);
        cout << fixed;
        // setw(6) << setfill('0')
    }
} init;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {
    for(int i = 0; i < (int) v.size(); i++) {
        ostr << v[i] << (i + 1 != v.size() ? " " : "");
    }
    return ostr;
}

template <typename _K, typename _V>
ostream& operator << (ostream& ostr, const map<_K, _V>& v) {
    ostr << "{";
    for (auto iter = v.begin(); iter != v.end(); ++iter) {
        ostr << (*iter).first << ": " << (*iter).second << ", ";
    }
    ostr << "}";
    return ostr;
}

template <typename _K>
ostream& operator << (ostream& ostr, const set<_K>& v) {
    for (auto iter = v.begin(); iter != v.end(); ++iter) {
        ostr << *iter << (iter != v.end() ? " " : "");
    }
    return ostr;
}

template <typename _K, typename _V>
ostream& operator << (ostream& ostr, const pair<_K, _V>& v) {
    ostr << "(" << v.first << ", " << v.second << ")";
    return ostr;
}

vector<string> split(const string &s, char delim) {
    vector<string> result;
    stringstream ss(s);
    string item;
    while (getline(ss, item, delim)) {
    if (!item.empty()) {
            result.push_back(item);
        }
    }
    return result;
}

int64 powmod(int64 n, int64 count, int64 mod) {
    if (count == 0) return 1;
    if (count % 2 == 0) {
        int64 t = powmod(n, count / 2, mod);
        return t * t % mod;
    }
    return n * powmod(n, count - 1, mod) % mod;
}

int64 ncr(int64 n, int64 r, int64 mod) {
    int64 a;
    if (n < r) a = min(n, r - n);
    else a = min(n - r, r);

    int64 res = 1;
    rep(i, a) {
        res = res * (n - i) % mod;
        res = res * powmod(i + 1, mod - 2, mod) % mod;
    }

    return res;
}

int main() {
    string s; cin >> s;
    rep(i, s.size()) {
        if (s[i] == '?') {
            cout << "D";
        } else {
            cout << s[i];
        }
    }
    cout << endl;
}


Measured memory_bytes: 3752
#include<stdio.h>

int array[20];
int n;

int check(int,int);

int main(){
  int q,i,judge;
  int marray[200];

  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&array[i]);

  scanf("%d",&q);
  for(i=0;i<q;i++) scanf("%d",&marray[i]);

  for(i=0;i<q;i++){
    judge=check(0,marray[i]);
    if(judge) printf("yes\n");
    else printf("no\n");
  }
  return 0;
}

int check(int i,int m){
  int judge;
  if(m == 0) return 1;
  if(i == n) return 0;
  judge = check(i+1,m) || check(i+1,m-array[i]);

  return judge;
} 

Measured memory_bytes: 580
#[allow(unused_imports)]
use itertools::Itertools;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

fn main() {
    input! {
        k: usize,
        s: Chars,
    }
    if s.len() <= k {
        for s in s {
            print!("{}", s);
        }
    } else {
        for i in 0..k {
            print!("{}", s[i]);
        }
        print!("...");
    }
    // println!("Yes");
    // println!("No");
    // println!("{}", );
}


Measured memory_bytes: 2184
#include <iostream>
#include <vector>
#include <chrono>
#include <random>
#include <cassert>
#include <algorithm>

std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());

const int ms = 1 << 18;

struct PT {
	typedef int T;
	T x, y;
	PT(T _x = 0, T _y = 0) : x(_x), y(_y){}
	PT operator +(const PT &p) const { return PT(x+p.x,y+p.y); }
	PT operator -(const PT &p) const { return PT(x-p.x,y-p.y); }
	bool operator < (const PT &p) const { return x != p.x ? x < p.x : y < p.y; }
	bool operator == (const PT &p)const { return x == p.x && y == p.y; }

	friend std::ostream& operator << (std::ostream &os, PT &p) {
		return os << "(" << p.x << ", " << p.y << ")";
	}
	friend std::istream& operator >> (std::istream &is, PT &p) {
		return is >> p.x >> p.y;
	}
};

int n;
PT a[ms], tmp[ms];
int sz[23];
PT b[23][1 << 9];
int ans[ms];
std::vector<std::pair<int, int>> qries[ms];

void go(int on, int h) {
	for(int i = 0; i < sz[h-2]; i++) {
		tmp[i] = b[h-2][i] + a[on];
	}
	std::merge(tmp, tmp+sz[h-2], b[h-2], b[h-2]+sz[h-2], b[h]);
	sz[h] = 1;
	for(int i = 1; i < sz[h-2] + sz[h-2]; i++) {
		PT cur = b[h][i];
		cur.y = std::max(cur.y, b[h][sz[h]-1].y);
		if(cur.x == b[h][sz[h]-1].x) {
			b[h][sz[h]-1] = cur;
		} else {
			b[h][sz[h]++] = cur;
		}
	}
	for(auto qry : qries[on]) {
		for(int i = 0, j = sz[h]-1; i < sz[h-1]; i++) {
			while(j >= 0 && b[h][j].x + b[h-1][i].x > qry.first) j--;
			if(j == -1) break;
			ans[qry.second] = std::max(ans[qry.second], b[h][j].y + b[h-1][i].y);
		}
	}
	if(on+on <= n) go(on+on, h+1);
	if(on+on+1 <= n) go(on+on+1, h+1);
}


int main() {
	std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
	std::cin >> n;
	for(int i = 1; i <= n; i++) {
		std::cin >> a[i];
		std::swap(a[i].x, a[i].y);
	}
	int q;
	std::cin >> q;
	for(int i = 0; i < q; i++) {
		int x, y;
		std::cin >> x >> y;
		qries[x].emplace_back(y, i);
	}
	sz[0] = sz[1] = 1;
	b[0][0] = b[0][1] = PT(0, 0);
	go(1, 2);
	for(int i = 0; i < q; i++) {
		std::cout << ans[i] << '\n';
	}
}

Measured memory_bytes: 17448
#include <bits/stdc++.h>
#include <stdlib.h>
#include <string>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793
int nx[4]={0,-1,0,1};
int ny[4]={-1,0,1,0};

ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    ll r=a%b;
    while(r!=0){
        a=b;
        b=r;
        r=a%b;
    }
    return b;
}

int main(){
    int n;
    int time=0;
    bool flag=true;
    pair<int,int>now=make_pair(0,0);
    cin >> n;
    rep(i,n){
        int t,x,y;
        cin >> t >> x >>y;
        int t_sub=t-time;
        time=t;
        int dis=abs(x-now.first)+abs(y-now.second);
        now=make_pair(x,y);
        if(dis==t_sub) continue;
        else if(dis>t_sub) flag=false;
        else{
            int a=t_sub-dis;
            if(a%2==0) continue;
            else flag=false;
        }
    }
    if(flag) cout <<"Yes" <<endl;
    else cout << "No" <<endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iomanip>
#include<vector>
#include<queue>
#include<deque>
#include<string>
#include<utility>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<set>
#include<map>
#include<bitset>
#include<stack>
#include<ctime>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<pli> vpli;
typedef vector<vi> mat;
 
inline ll read(){
	ll Hashimoto=0,Kanna=1;
	char I_Love=getchar();
	while(I_Love<'0'||I_Love>'9'){
		if(I_Love=='-')Kanna=-1;
		I_Love=getchar();
	}
	while(I_Love>='0'&&I_Love<='9'){
		Hashimoto=Hashimoto*10+I_Love-'0';
		I_Love=getchar();
	}
	return Hashimoto*Kanna;
}
 
#define I_Love_Hashimoto_Kanna main
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define filein(s) freopen(s,"r",stdin);
#define fileout(s) freopen(s,"w",stdout);
#define file freopen("I_Love_Hashimoto_Kanna.out","w",stdout);
#define RE cout<<"I_Love_Hashimoto_Kanna"<<endl;
#define Tone(Kanna) cout<<Kanna<<endl;
#define Tall(Hashimoto,Kanna) for(int I_Love=0;I_Love<Kanna;I_Love++)cout<<Hashimoto[I_Love]<<(I_Love==Kanna-1?"\n":" ");
#define FOR(I_Love,Hashimoto,Kanna) for(int I_Love=Hashimoto;I_Love<Kanna;I_Love++)
#define MP(Hashimoto,Kanna) make_pair(Hashimoto,Kanna)
#define REV(Kanna) reverse(Kanna.begin(),Kanna.end());
#define SORT(Kanna) sort(Kanna.begin(),Kanna.end());
#define inf (int)1e9
#define linf (ll)1e15
#define mod (inf+7)
 
int n,m;
vpli g[111111];
ll s[111111][2];
bool v[111111][2];
 
void bfs(){
	queue<pii>q;
	q.push({0,1});
	v[0][1]=1;
	s[0][1]=0;
	while(!q.empty()){
		int u=q.front().first;
		int sym=q.front().second;
		q.pop();
		FOR(i,0,g[u].size()){
			ll val=g[u][i].first-s[u][sym];
			int to=g[u][i].second;
			if(v[to][1-sym]){
				if(s[to][1-sym]!=val){
					Tone(0);
					exit(0);
				}
			}
			else{
				s[to][1-sym]=val;
				v[to][1-sym]=1;
				q.push({to,1-sym});
			}
			if(v[to][sym]){
				ll check=s[to][0]-s[to][1];
				if(check<=0){
					Tone(0);
					exit(0);
				}
				if(check%2!=0){
					Tone(0);
					exit(0);
				}
			}
		}
	}
ll mn=linf,mx=1;
	ll val=linf;
	FOR(i,0,n){
		if(v[i][0]&&v[i][1]){
			if(val==linf){
				val=s[i][0]-s[i][1];
				val/=2;
			}
			else {
				if(val!=(s[i][0]-s[i][1])/2){
					Tone(0);
					exit(0);
				}
			}
		}
		if(v[i][0]){
			if(s[i][0]<2){
				Tone(0);
				exit(0);
			}
			mn=min(mn,s[i][0]-1);
		}
		if(v[i][1]){
			if(s[i][1]<=0)mx=max(mx,1-s[i][1]);
		}
	}
	if(val!=linf){
		FOR(i,0,n){
			if(v[i][1])if(val+s[i][1]<1){
				Tone(0);
				return ;
			}
			if(v[i][0])if(s[i][0]-val<1){
				Tone(0);
				return ;
			}
		}
		Tone(1);
	}
	else if(mx>mn)Tone(0)
	else Tone(mn-mx+1)
}
 
int I_Love_Hashimoto_Kanna() {
  fastio;
  n=read();m=read();
  FOR(i,0,m){
  	int a,b;
		ll s;
  	a=read()-1;
  	b=read()-1;
  	s=read();
  	g[a].push_back({s,b});
  	g[b].push_back({s,a});
	}
	bfs();
  
  return 0;
}

Measured memory_bytes: 10368
import sys
import math
import fractions
import itertools
from collections import deque
import copy
import bisect

MOD = 10 ** 9 + 7
INF = 10 ** 18 + 7
input = lambda: sys.stdin.readline().strip()

n = int(input())
ans = ["{0}".format(n) + ":"]
for i in range(2, int(math.sqrt(n) // 1) + 3):
    if n == 1:
        break
    elif n % i == 0:
        while n % i == 0:
            ans.append("{0}".format(i))
            n //= i
if n != 1:
    ans.append("{0}".format(n))
print(" ".join(ans))



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

public class Main {

	public static void main(String[] args) {

		//?????£?????????
		String strAnser = null;

		int[] intNumList = new int[5];

		int intW =0;
		int intH =0;
		int intx =0;
		int inty =0;
		int intr =0;

		boolean NumOk = false;

		try {
			//??\????????????
			BufferedReader strLine = new BufferedReader(new InputStreamReader(System.in));
			String strInput = strLine.readLine();

			String[] strNumList = strInput.split(" ", 0);

			//int????????????
			intW = Integer.parseInt(strNumList[0]);
			intH = Integer.parseInt(strNumList[1]);
			intx = Integer.parseInt(strNumList[2]);
			inty = Integer.parseInt(strNumList[3]);
			intr = Integer.parseInt(strNumList[4]);

			//??\?????°???????????§??????
			if (0 < intH && intH <= 100) {
				if (0 < intW && intW <= 100) {
					if (-100 < intx && intx <= 100) {
						if (0 < intr && intr <= 100) {
							NumOk = true;
						}
					}
				}
			}

			if (NumOk) {
				if (0 <= intx - intr && intx + intr <= intW) {
					if (0 <= inty - intr && inty + intr <= intH) {
						strAnser = "Yes";
					}
				}
			}
			if (strAnser == null) {
				strAnser = "No";
			}
			System.out.println(strAnser);

		}catch (IOException e1) {
			System.out.println(e1);
		}catch (NumberFormatException e2) {
			System.out.println(e2);
		}
	}
}

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

using namespace std;

int main(int argc, const char *argv[]) {
  using ll = long long;
  ll a, b, c, k;
  cin >> a >> b >> c >> k;

  ll ans = min(k, a);
  k = max(0ll, k - (a + b));
  ans -= k;
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3624
package main

import "fmt"
var N, K int
var u, w, v int
var dp, arr []int
var DP, mat [][]int
var vis, dist []int

const (
	MaxInt = 1<<31 - 1
	MinInt = -MaxInt - 1
	MOD = int(1e9) + 7
)
func addSelf(a *int, b int) {
	*a += b
}

func subSelf(a *int, b int) {
	*a -= b
}

func addSelfMOD(a *int, b int) {
	addSelf(a, b)
	if *a >= MOD {
		*a -= MOD
	}
}

func subSelfMOD(a *int, b int) {
	subSelf(a, b)
	if *a < 0 {
		*a += MOD
	}
}
func max(a, b int) int {
	if a > b { return a }
	return b
}

func min(a, b int) int {
	if a < b { return a }
	return b
}

func abs(a int) int {
	if a < 0 { return -a }
	return a
}

func main() {
	_,e := fmt.Scanf("%d%d", &N, &K)
	if e != nil { return }
	dp = make([]int, K+1)
	dp[0] = 1
	for i:=0; i<N; i++ {
		_,e = fmt.Scanf("%d", &u)
		if e != nil { return }
		fake := make([]int, K+1)
		for used:=K; used>=0; used-- {
			tmp, L,R := dp[used], used+1, used + min(u, K-used)
			if L<=R {
				addSelfMOD(&fake[L], tmp)
				if R+1 <= K {
					subSelfMOD(&fake[R+1], tmp)
				}
			}
		}
		prefix := 0
		for i := range fake {
			addSelfMOD(&prefix, fake[i])
			addSelfMOD(&dp[i], prefix)
		}
	}
	fmt.Println(dp[K])
}


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

typedef long long ll;

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

using namespace std;
int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
//  --------------------------------------

	string S; cin >> S;
	bool good = true;

	for (int i = 0; i < S.size(); i++)
	{
		if (i%2 == 1 && S[i] =='R')
		{
			good = false;
			break;
		}
		else if(i%2 == 0 && S[i] =='L')
		{
			good = false;
			break;
		}
		
		
	}
	
	if (good)
	{
		cout << "Yes" << "\n";
	}
	else
	{
		cout << "No" << "\n";		
	}
	
	

}

Measured memory_bytes: 256
import collections
N = int(input())
s = [input() for i in range(N)]
M = int(input())
t = [input() for i in range(M)]

d = collections.defaultdict(int)
for x in s:
    d[x] += 1
for x in t:
    d[x] -= 1

ans = 0
for x in d:
    ans = max(ans, d[x])
print(ans)


Measured memory_bytes: 3316
mo = 10 ** 9 + 7
n, a, b = map(int, input().split())
u = (pow(2, n, mo) - 1 + mo) % mo
def rev(u):
    return pow(u, mo - 2, mo)
def C(p, q):
    ans = 1
    for i in range(q):
        ans = ans * (p - i) % mo
    for i in range(q):
        ans = ans * rev(i + 1) % mo
    return (ans + mo) % mo
u = (u - C(n, a) - C(n, b) + mo * 2) % mo
print(u)

Measured memory_bytes: 38896
import sys


class Baseball:
    def __init__(self):
        self.runner = 0
        self.out_count = 0
        self.score = 0

    def hit(self):
        if self.runner == 3:
            self.score += 1
        else:
            self.runner += 1

    def homerun(self):
        self.score = self.score + self.runner + 1
        self.runner = 0

    def out(self):
        self.out_count += 1
        if self.out_count == 3:
            print self.score
            self._clear()

    def _clear(self):
        self.runner = 0
        self.out_count = 0
        self.score = 0



baseball = Baseball()
sys.stdin.readline()
for line in sys.stdin:
    line = line.rstrip('\n')
    if line == 'HIT':
        baseball.hit()
    elif line == 'HOMERUN':
        baseball.homerun()
    elif line == 'OUT':
        baseball.out()

Measured memory_bytes: 4256
loop do
  m, n = gets.split.map(&:to_i)
  break if m == 0
  arr = m.times.map{ gets.split.map(&:to_i) }.sort_by{ |a| a[1] }
  n = arr.transpose[0].reduce(:+) - n
  res = 0
  arr.each do |a, b|
    break if n <= 0
    res += (n - a > 0 ? a : n) * b
    n -= a
  end
  p res
end

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

int main(){
	int i,j,k,n,m,l,f,x,y,z;
	string s[105], t[105];
	cin >> n;
	rep(i, n) cin >> s[i];
	cin >> m;
	rep(i, m) cin >> t[i];

	map<string, int> ma;
	f = 0;
	rep(i, n){
		ma[s[i]]++;
	}
	rep(i, m){
		ma[t[i]]--;
	}

	
	for(auto it=ma.begin();it!=ma.end();it++) {
		f=max(f,it->second);
	}

	cout << f;
}


Measured memory_bytes: 256
n, m = map(int, input().split())


list1 = [[0]*m for i in range(n)]
list2 = [0]*m

for i in range(n):
    list = input().split()
    for j in range(m):
        list1[i][j]=int(list[j])
for j in range(m):
    list2[j] = int(input())

sum = [0]*n
for i in range(n):
    for j in range(m):
        sum[i] += list1[i][j] * list2[j]
for i in range(n):
    print(sum[i])


Measured memory_bytes: 6020
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
using edge = struct { int to; int cost; };
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; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  IOS;
  int h,w; cin >> h >> w;
  int a[h][w];
  REP(i,h) REP(j,w) cin >> a[i][j];

  vector<tuple<int,int,int,int>> ans;
  REP(i,h-1) REP(j,w) {
    if(a[i][j]%2==0) continue;
    a[i][j]--; a[i+1][j]++;
    ans.push_back( make_tuple(i,j,i+1,j) );
  }
  REP(j,w-1) {
    if (a[h-1][j]%2==0) continue;
    a[h-1][j]--; a[h-1][j+1]++;
    ans.push_back( make_tuple(h-1,j,h-1,j+1) );
  }

  COUT(ans.size());
  for(auto x: ans) {
    cout
      << get<0>(x)+1 << " "
      << get<1>(x)+1 << " "
      << get<2>(x)+1 << " "
      << get<3>(x)+1 << endl;
  }

  return 0;
}

Measured memory_bytes: 6284
/*
    Washief Hossain Mugdho
    21 September 2020
    Educational DP Subtree
*/

#ifndef DEBUG
#pragma GCC optimize("-O2")
#endif

#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define fastio ios_base::sync_with_stdio(0)
#define untie cin.tie(0)
#define ms(a, b) memset(a, b, sizeof a)
using namespace std;
int n, mod, x, y;
const int mx = 1e5 + 5;
ll down[mx], up[mx];
list<int> adj[mx];

void downPaths(int a, int parent)
{
    for (auto i : adj[a])
        if (i != parent)
        {
            downPaths(i, a);
            down[a] = (down[a] * (down[i] + 1)) % mod;
        }
}

void upPaths(int a, int parent)
{
    vector<int> children;
    for (int i : adj[a])
        if (i != parent)
            children.pb(i);

    ll suffix[children.size() + 2], prefix[children.size() + 2];
    prefix[0] = suffix[children.size() + 1] = 1;

    for (int i = 0; i < children.size(); i++)
    {
        prefix[i + 1] = (prefix[i] * (down[children[i]] + 1)) % mod;
        suffix[children.size() - i] = (suffix[children.size() - i + 1] * (down[children[children.size() - i - 1]] + 1)) % mod;
    }

    for (int i = 0; i < children.size(); i++)
    {
        ll res = (prefix[i] * suffix[i + 2]) % mod;
        res = (res * up[a] + 1) % mod;
        up[children[i]] = res;
        upPaths(children[i], a);
    }
}

int main()
{
#ifdef LOCAL_OUTPUT
    freopen(LOCAL_OUTPUT, "w", stdout);
#endif
#ifdef LOCAL_INPUT
    freopen(LOCAL_INPUT, "r", stdin);
#endif
    cin >> n >> mod;
    for (int i = 0; i < n - 1; i++)
    {
        cin >> x >> y;
        adj[x].pb(y);
        adj[y].pb(x);
    }
    for (int i = 1; i <= n; i++)
        down[i] = up[i] = 1;
    downPaths(1, 0);
    upPaths(1, 0);
    for (int i = 1; i <= n; i++)
        cout << (down[i] * up[i]) % mod << endl;
}


Measured memory_bytes: 29500
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", ans);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int c[10][10];
int a[205][205];



int main(void) {
	int h, w;
	cin >> h >> w;
	
	rep (i, 10) rep (j, 10) cin >> c[i][j];
	rep (i, h) rep (j, w) cin >> a[i][j];

	rep (k, 10) rep (i, 10) rep (j, 10) chmin(c[i][j], c[i][k] + c[k][j]);

	ll ans = 0;
	rep (i, h) rep (j, w) {
		if (a[i][j] == -1 || a[i][j] == 1) continue;
		ans += c[a[i][j]][1];
	}

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

Measured memory_bytes: 384
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

#include <bits/stdc++.h>

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;

const int MXN = 2e5, IINF = 1e9 + 10, INF = 1e18 + IINF + 10, MOD = 1000000007;
const ld PI = 4.0 * atanl(1.0), PREC = .000001;
const char nl = '\n';

#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i, a, b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto& a : x)
#define uid(a, b) uniform_int_distribution<int>(a, b)(rng)

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define rall(x) x.end(), x.begin()
#define lb lower_bound
#define ub upper_bound
#define sz(x) (int)(x).size()
#define ins insert

int n, m, t, a[MXN];

void fast() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); }

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }

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

int main() {
  fast();
  cin >> n;
  vector<int> b(n - 1);
  for (auto& x : b) cin >> x;
  vector<int> a(n);
  FOR(i, 0, n - 1) { a[i] = b[i]; }
  int s = 0;
  a[n - 1] = INF;
  FOR(i, 0, n - 1) a[i + 1] = min(a[i + 1], b[i]);
  trav(x, a) s += x;
  cout << s;
  return 0;
}



Measured memory_bytes: 3640
import bisect as bc

N,M,K = map(int,input().split())
A = [0]*(N+1)
B = [0]*(M+1)
A[1:] = list(map(int,input().split()))
B[1:] = list(map(int,input().split()))
A.append(10**9+10)
B.append(10**9+10)

A_S = [0]*(N+2)
B_S = [0]*(M+2)

for i in range(1,N+2):
    A_S[i] = A_S[i-1]+A[i]
for i in range(1,M+2):
    B_S[i] = B_S[i-1]+B[i]

ans = 0
for i in range(N+2):
    tmp_K = K-A_S[i]
    if tmp_K > 0:
        j = bc.bisect_right(B_S,tmp_K) - 1
        ans = max(i+j,ans)
    if tmp_K == 0:
        ans = max(ans,i)
    
print(ans)






    




Measured memory_bytes: 113824
#include<bits/stdc++.h>
#define ll long long int
#define F first
#define S second
#define M 1000000007
#define SI(x) scanf("%d", &x)
#define PI(x) printf("%d\n", x)
#define SL(x) scanf("%I64d", &x)
#define PL(x) printf("%I64d\n", x)
#define PB push_back
#define MP make_pair

using namespace std;

int main()
{

    string s1, s2;
    cin >> s1 >> s2;

    if(s1.length() > s2.length())
        return cout << "GREATER", 0;

    if(s1.length() < s2.length())
        return cout << "LESS", 0;

    for(int i = 0; i<s1.length(); i--)
    {
        if(s1[i]>s2[i])
            return cout << "GREATER", 0;

        if(s2[i]>s1[i])
            return cout << "LESS", 0;
    }

    cout << "EQUAL";
}


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;
typedef pair<int, int> pi;
const int INF = 0x3f2f1f0f;

const int MAX_N = 1e5 + 10;
int N; ll Sum[MAX_N]; int Cnt[MAX_N];
vector<int> Ed[MAX_N];
bool Chk[MAX_N];
int main() {
	cin >> N;
	for(int i=1, x, y; i<N; i++) {
		scanf("%d%d", &x, &y);
		Ed[x].push_back(y); Sum[x] += y; Cnt[x]++;
		Ed[y].push_back(x); Sum[y] += x; Cnt[y]++;
	}
	queue<int> Q;
	for(int i=1; i<=N; i++) if(Cnt[i] == 1) Q.push(i);

	bool whiteWin = false;
	while(!Q.empty()) {
		int v = Q.front(); Q.pop();
		if(Chk[v]) continue;
		if(Cnt[v] == 0) {whiteWin = true; break;}
		int p = Sum[v];
		Cnt[p]--; Cnt[v]--; Sum[v] -= p; Sum[p] -= v;
		Chk[p] = Chk[v] = true;
		for(int w : Ed[p]) {
			if(Chk[w]) continue;
			Sum[w] -= p;
			Cnt[w]--;
			if(Cnt[w] == 1) Q.push(w);
		}
	}
	puts(whiteWin ? "First" : "Second");
	return 0;
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0, sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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; }

struct UnionFind{
    vector<int> par; // par[i]:iの親の番号
    vector<int> s; // s[i]:iの属する木のノード数
    int n_group; // 木の数
    
    UnionFind(int N) : par(N) {
        for(int i=0; i<N; i++) par[i] = i;
        s.assign(N, 1);
        n_group = N;
    }
    
    int root(int x){ // xが属する木の根
        if(par[x] == x) return x;
        return par[x] = root(par[x]);
    }
    
    void unite(int x, int y){ // xとyの木を併合
        int rx = root(x);
        int ry = root(y);
        if(rx == ry) return;
        par[rx] = ry;
        s[ry] += s[rx];
        s[rx] = 0;
        n_group--;
    }
    
    bool same(int x, int y){ // xとyが同じ木に属するかどうか
        return root(x) == root(y);
    }

    int size(int x){ // xが属する木のノード数
        return s[root(x)];
    }
};

int main(void){
    int N,M; cin >> N >> M;
    VI p(N),n2id(N);
    REP(i,N){
        cin >> p[i]; p[i]--;
        n2id[p[i]] = i;
    }
    UnionFind uf(N);
    REP(i,M){
        int x,y; cin >> x >> y;
        x--; y--;
        uf.unite(x,y);
    }
    int ans = 0;
    REP(i,N){
        if(uf.same(i,n2id[i])) ans++;
    }
    cout << ans << en;
    return 0;
}

Measured memory_bytes: 1920
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {

    int N;
    cin >> N;

    vector<int> V(N);
    vector<int> C(N);

    for (int i = 0; i < N; ++i) {
        cin >> V[i];
    }

    for (int i = 0; i < N; ++i) {
        cin >> C[i];
    }

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

    cout << num << endl;
}



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

int main() {
  
  int D=0;
  
  cin >> D;
  
  if(D==25) {
    
    cout << "Christmas" << endl;
    
    return 0;
    
  } else if(D==24) {
    
    cout << "Christmas Eve" << endl;
    
    return 0;
    
  } else if(D==23) {
    
    cout << "Christmas Eve Eve" << endl;
    
    return 0;
    
  } else if(D==22) {
    
    cout << "Christmas Eve Eve Eve" << endl;
    
    return 0;
    
  }
  
}

Measured memory_bytes: 256
#include<vector>
#include<list>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i;
  int a[201],b,n;
  int sm,su,um;
  while(cin>>n&&n){
    memset(a,0,sizeof(a));
    for(i=0;i<n;i++){
      cin>>b;
      a[b]=1;
    }
    for(i=1;i<n*2+1;i++){
      if(a[i]==0)
	a[i]=2;
    }
    sm=su=n;
    b=0;
    for(;;){
      for(i=b+1;i<n*2+1;i++){
	if(a[i]==1){
	  a[i]=0;
	  sm--;
	  b=i;
	  break;
	}
      }
      if(i>=n*2+1)
	b=0;
      if(sm==0)
	break;
      for(i=b+1;i<n*2+1;i++){
	if(a[i]==2&&i>b){
	  a[i]=0;
	  su--;
	  b=i;
	  break;
	}
      }
      if(i>=n*2+1)
	b=0;
      if(su==0)
	break;
    }
    um=0;
    for(i=0;i<n*2+1;i++){
      if(a[i])
	um++;
    }
    cout<<(sm?0:um)<<endl;
    cout<<(su?0:um)<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;

const int N = 1e5;
int a[N];
set<int> s;

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	int n;
	cin >> n;
	for(int i = 0; i < n; ++i) {
		cin >> a[i];
		s.insert(a[i]);
	}
	if(s.size() > 2 || (s.size()==2 && *s.begin() != *s.rbegin()-1)) {
		cout << "No\n";
		return 0;
	}

	if(s.size()==1) {
		int v = *s.begin();
		if(v == n-1 || n/v > 1) {
			cout << "Yes\n";
		} else {
			cout << "No\n";
		}
		return 0;
	}
	int offs=0,b=0;
	for(int i = 0; i < n; ++i) {
		if(a[i] == *s.begin())
			++offs;
		else ++b;
	}
	int v = *s.rbegin()-offs;
	if(v == 0) cout << "No\n";
	else if(b/v > 1) cout << "Yes\n";
	else cout << "No\n";
	return 0;
}

Measured memory_bytes: 5376
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<60;
double pi=3.141592653589793238462643383279L;
double eps=1e-10;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll par[800010];
ll len[800010];
ll you[800010];
void init(ll n){
  for(int i=0;i<n;i++){
    par[i]=i;
    len[i]=0;
    you[i]=1;
  }
}
ll root(ll n){
  if(par[n]==n)return n;
  return par[n]=root(par[n]);
}
void unit(ll a,ll b){
  a=root(a);
  b=root(b);
  if(a==b)return;
  if(len[a]<len[b]){
    par[a]=b;
    you[b]+=you[a];
  }
  else{
    par[b]=a;
    you[a]+=you[b];
    if(len[a]==len[b])len[a]++;
  }
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n,m,k;cin>>n>>m>>k;
    init(n+1);
    vector<int> v[n+1],w[n+1];
    rep(i,0,m){
        int a,b;cin>>a>>b;
        v[a].push_back(b);
        v[b].push_back(a);
        unit(a,b);
    }
    rep(i,0,k){
        int a,b;cin>>a>>b;
        w[a].push_back(b);
        w[b].push_back(a);
    }
    int go[n+1];
    set<int> st[n+1];
    rep(i,1,n+1){
        go[i]=root(i);
        st[go[i]].insert(i);
    }
    rep(i,1,n+1){
        int ans=st[go[i]].size()-1;
        ans-=v[i].size();
        rep(j,0,w[i].size()){
            int ai=w[i][j];
            auto itr=st[go[i]].lower_bound(ai);
            if(itr==st[go[i]].end())continue;
            if(*itr==ai)ans--;
        }
        cout<<ans<<" ";
        
    }
    cout<<endl;
}







Measured memory_bytes: 26488
n,x,m=map(int,input().split())

def f(ai,m):
    return (ai*ai)%m

if x==0:
    print(0)
elif x==1:
    print(n)
elif m==1:
    print(0)
#elif n<=m*2:
#    asum=x
#    ai=x
#    for i in range(1,n):
#        ai=f(ai,m)
#        asum+=ai
#    print(asum)   
else:
    chk=[-1]*m
    asum00=[0]*m
    ai,asum=x,0
    for i in range(m):
        if chk[ai]!=-1:
            icnt0=chk[ai]
            break
        else:
            chk[ai]=i
            asum00[i]=asum
        asum+=ai
        ai=f(ai,m)
    icnt=i
    asum0=asum00[icnt0]
        
    icntk=icnt-icnt0
    n0=n-1-icnt0
    nk=n0//icntk
    nr=n0%icntk
    asumk=asum-asum0

    air,asumr=ai,0
    for i in range(nr):
        asumr+=air
        air=f(air,m)
    asumr+=air
       
    ans=asum0+asumk*nk+asumr    
    print(ans)       


Measured memory_bytes: 67344
#include<bits/stdc++.h>
using namespace std;
#define num 1000000007
//#define num 998244353
#define REP(i,a,n) for(ll i=a;i<n;i++)
#define inarr(i,a,n,A) for(ll i=a;i<n;i++) { cin>>A[i]; }
#define vll vector<long long>
#define pii pair <int,int>
#define pll pair<long long, long long>
#define vpii vector< pair <int,int>>
#define vpll vector< pair<long long, long long>>
#define max(a,b) ((a>b)?a:b)
#define min(a,b) ((a>b)?b:a)
#define max3(a,b,c) ((a>b)?(a>c)?a:c:(b>c)?b:c)
#define min3(a,b,c) ((a<b)?(a<c)?a:c:(b<c)?b:c)
#define avg(a,b) ((a)+(b))/2
#define push push_back
#define pop pop_back
#define mp make_pair
#define sf int flag=0     //Remember semicolon
#define assmin(a,b) if(b<=a) { a=b; }
#define assmax(a,b) if(b>=a) { a=b; }
#define f first
#define s second
#define fix(f,n) std::fixed<<std::setprecision(n)<<f
typedef long long ll;
ll mod(ll a, ll b)
{
	if(a%b<0)
	{
		return a%b + b;
	}
	return a%b;
}
 
 
ll mod_exp(ll a, ll b, ll c)
{
	ll res=1;
	a=a%c;
	while(b>0)
	{
		if(b%2==1)
		{
			res=(res*a)%c;
		}
		b/=2;
		a=(a*a)%c;
	}
	return res;
}
ll mymod(ll a,ll b)
{
    return ((a%b)+b)%b;
}
bool prime[3001];
void SieveOfEratosthenes() 
{ 
    memset(prime, true, sizeof(prime)); 
    prime[1]=false;
    for (int p=2; p*p<=3000; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=3000; i += p) 
                prime[i] = false; 
        } 
    } 
}
ll powe[100005];
void power()
{
    powe[0]=1;
    REP(i,1,100005)
    {
        powe[i]=mymod(2*powe[i-1],num);
    }
}
ll gcdExtended(ll,ll,ll *,ll *);
ll modInverse(ll a, ll m) 
{ 
    ll x, y; 
    ll g = gcdExtended(a, m, &x, &y); 
        ll res = (x%m + m) % m;
        return res;
} 
ll gcdExtended(ll a, ll b, ll *x, ll *y) 
{ 
    if (a == 0) 
    { 
        *x = 0, *y = 1; 
        return b; 
    } 
    ll x1, y1; 
    ll gcd = gcdExtended(b%a, a, &x1, &y1); 
    *x = y1 - (b/a) * x1; 
    *y = x1; 
    return gcd; 
} 
ll fact[100005];
void factorial()
{
    fact[0]=1;
    REP(i,1,100002)
    {
        fact[i]=mymod(i*fact[i-1], num);
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m;
    map<ll,ll> mx;
    set<ll> st;
    ll sum=0;
    cin>>n>>m;
    REP(i,0,m)
    {
        ll p;
        string s;
        cin>>p>>s;
        if(s[0]=='W')
        mx[p]++;
        else if(s[0]=='A' && st.count(p)==0)
        {
        st.insert(p);
        sum+=mx[p];
        }
    }
    cout<<st.size()<<" "<<sum<<"\n";
	return 0;
}

Measured memory_bytes: 11264
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        if (s.equals(t.substring(0,s.length()))){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 26948
// In the name of God
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ldo;
#define pb push_back
#define X first
#define Y second
ll a, b, p, n;
stack<ll> s;
const int MAX = 1e5+100;
string t, res;
bool honest[MAX];
int main()
{
  ios_base :: sync_with_stdio(false);
	cin.tie(0);
	cin >> a >> b;
	n = a+b;
	if (a <= b)
		return cout << "Impossible" << endl, 0;
	s.push(0);
	for (int i = 1; i < n; i++) {
		if (!s.empty()){
			cout << "? " << s.top() << ' ' << i << endl;
			cin >> t;
			if (t=="N")
				s.pop();
			else
				s.push(i);
		}
		else
			s.push(i);
	}
	p = s.top();
	honest[p] = 1;
	for (int i = 0; i < n; i++)
		if (i!=p) {
			cout << "? " << p << ' ' << i << endl;
			cin >> t;
			if (t=="N")
				honest[i] = 0;
			else
				honest[i] = 1;
		}
	t = "";
	for (int i = 0; i < n; i++){
		if (honest[i])
			t += "1";
		else
			t += "0";
	}
	cout << "! "<<  t << endl;
	return 0;
}

Measured memory_bytes: 724
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using psi=pair<string,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
#define MOD ((ll)1e9+7)
void get(){}template<class H,class...T>void get(H&h,T&...t){cin>>h;get(t...);}
template<class T>void geti(T&a){for(auto&_:a)cin>>_;}
template<class T>void getii(T&a){for(auto&_:a)geti(_);}
void put(string d){}template<class H,class...T>void put(string d,H&h,T&...t){cout<<h;if(sizeof...(t))cout<<d;put(d,t...);}
template<class T>void puti(T&a,string d=" "){bool f=1;for(auto&_:a)cout<<(exchange(f,0)?"":d)<<_;cout<<endl;}
template<class T>void putii(T&a,string d=" "){for(auto&_:a)puti(_,d);}
#define dcl(...) ll __VA_ARGS__;get(__VA_ARGS__)
#define dclt(t,...) t __VA_ARGS__;get(__VA_ARGS__)
template<class F,class S>void add(map<F,S>&mp,F f,S s){if(mp.find(f)==mp.end())mp[f]=F();mp[f]+=s;}
 
constexpr int gcd(int a,int b){return b?gcd(b,a%b):a;}
constexpr int lcm(int a,int b){return a*b/gcd(a,b);}


int main(){
    string s;
    cin>>s;
    vi a={(int)count(all(s),'a'),(int)count(all(s),'b'),(int)count(all(s),'c')};
    if( abs(a[0]-a[1])<2 && abs(a[1]-a[2])<2 && abs(a[2]-a[0])<2 ){
        cout<<"YES"<<endl;
    }else cout<<"NO"<<endl;
}


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

int n;
vector<int> a(21);

bool can(int i, int m) {
  if (m == 0)
    return true;
  else if (m < 0 || n < i)
    return false;  // はみ出た or 最後を越した
  else
    return (can(i + 1, m) || can(i + 1, m - a[i]));
}

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

  int q, m;
  cin >> q;
  for (int i = 0; i < q; i++) {
    cin >> m;
    if (can(0, m))
      cout << "yes" << endl;
    else
      cout << "no" << endl;
  }
}



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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)
#define mod 1000000007
typedef long long ll;

int main() {
    int x,a;cin>>x>>a;

    if(x<a){
        cout<<0<<endl;
        return 0;
    }
    cout<<10<<endl;
}


Measured memory_bytes: 256
# include <bits/stdc++.h>
using namespace std;
#define int long long
#define pbdouble(x)	cout<<fixed<<setprecision(14)<<x;
int mod = 1e9 + 7;
double memo[305][305][305];
double top(int x, int y, int z, int n)
{
	if (x < 0 || y < 0 || z < 0)
		return 0;
	if (x == 0 && y == 0 && z == 0)
		return 0;
	double &ans = memo[x][y][z];
	if (ans > -0.9) return ans;
	ans = n + (x * top(x - 1, y, z, n)) + (y * top(x + 1, y - 1, z, n)) + (z * top(x, y + 1, z - 1, n));
	return ans /= (x + y + z);
}
int32_t main ()
{
	ios_base:: sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	int n;
	cin >> n;
	int one = 0, two = 0, three = 0;
	int d;
	memset(memo, -1, sizeof(memo));
	for (int i = 0; i < n; i++)
	{
		cin >> d;
		if (d == 1) one++;
		else if (d == 2) two++;
		else three++;
	}
	pbdouble(top(one, two, three, n));
}
// 10
// 1 3 2 3 3 2 3 2 1 3

// 54.48064457488221

Measured memory_bytes: 221952
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_B main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif


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

    int N, D; cin >> N >> D;
    vvi X(N, vi(D));
    REP(i, N)
        REP(j, D) cin >> X[i][j];

    set<int> st;    
    FOR(i, 1, 201) st.insert(i*i);

    int ans = 0;
    REP(i,N-1){        
        FOR(j,i+1,N) {
            double dist = 0;
            REP(k, D) {
                dist += (X[i][k] - X[j][k])*(X[i][k] - X[j][k]);
            }
            if (st.count(dist) > 0) ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
using namespace std;
int a,b;
int main()
{
	scanf("%d%d",&a,&b);
	if(a>=1&&a<=9&&b>=1&&b<=9)
		printf("%d",a*b);
	else
		printf("-1");
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <algorithm>
#define N 100005

int n;
int c[5];
char s[N][5], ans[N];

int main() {
    int *a = c - 'A';
    scanf("%d%d%d%d", &n, a + 'A', a + 'B', a + 'C');
    for (int i = 1; i <= n; ++i) scanf("%s", s[i]);
    for (int i = 1; i <= n; ++i)
        if (!a[s[i][0]] && !a[s[i][1]]) {
            puts("No");
            return 0;
        } else if (!a[s[i][0]]) ++a[s[i][0]], --a[s[i][1]], ans[i] = s[i][0];
        else if (!a[s[i][1]]) --a[s[i][0]], ++a[s[i][1]], ans[i] = s[i][1];
        else if (a[s[i][0]] < a[s[i][1]] || (a[s[i][0]] == a[s[i][1]] && i < n && (s[i][0] == s[i + 1][0] && s[i][1] != s[i + 1][1] || s[i][0] == s[i + 1][1] && s[i][1] != s[i + 1][0]))) ++a[s[i][0]], --a[s[i][1]], ans[i] = s[i][0];
        else --a[s[i][0]], ++a[s[i][1]], ans[i] = s[i][1];
    puts("Yes");
    for (int i = 1; i <= n; ++i) printf("%c\n", ans[i]);
}


Measured memory_bytes: 2320
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#include <iomanip>
#include <set>
using namespace std;
typedef long long ll;

const ll MOD = 1e9+7;
int p[100000];
ll b[100001];//iはpの中でどこ
multiset<int> st;
int main()
{
	int n;
	ll ans=0;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>p[i];
		b[p[i]]=i;
	}
	st.insert(-1);
	st.insert(-1);
	st.insert(n);
	st.insert(n);
	for(int i=n-1;i>0;i--)
	{
		st.insert(b[i+1]);
		auto r=st.upper_bound(b[i]);
		auto l=st.lower_bound(b[i]);
		l--;
		ll b1=*r;r++;ll b2=*r;
		ll s1=*l;l--;ll s2=*l;
		//cerr<<s2<<" "<<s1<<" "<<b1<<" "<<b2<<endl;
		ans+=i*((b2-b1)*(b[i]-s1)+(b1-b[i])*(s1-s2));
		//cerr<<ans<<endl;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 6144