akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
using namespace std;

#define ll long long
#define pb push_back

int main(){

	ll N, x;
	vector<ll> A;
	cin >> N >> x;
	for(ll i = 0; i < N; i ++){
		ll a;
		cin >> a;
		A.pb(a);
	}
	sort(A.begin(), A.end());
	ll ans = 0;
	for(ll i = 0; i < N && x >= 0; i ++){
		if(x >= A[i]){
			x -= A[i];
			ans ++;
			if(i == N - 1 && x > 0)ans --;
		}
		else break;
	}
	if(ans < 0)ans = 0;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
def main():
    s = input()
    n = len(s)
    l, r, ans = 0, n-1, 0
    while l < r:
        if s[l] == s[r]:
            l += 1
            r -= 1
        elif s[l] == "x":
            ans += 1
            l += 1
        elif s[r] == "x":
            r -= 1
            ans += 1
        else:
            print(-1)
            exit()
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9072
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch Test | diff Test.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address Test.cpp && ./a.out

/*

 5/25/2020

 16:11-

 */

const int MAX_N=1e6+1;
LL A[MAX_N];
int N,M;

void solve() {
  LL res=0;
  map<int,int> cnt;
  cnt[0]=1;
  LL cur=0;
  REP(i,N) {
    cur+=A[i];
    res+=cnt[cur%M];
    cnt[cur%M]++;
  }
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;

  cin>>N>>M;
  REP(i,N) cin>>A[i];
  solve();

  return 0;
}


Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K,S;
  cin >> N >> K >> S;
  
  for (int i = 0; i < K; i++) {
    cout << S << ' ';
  }
  for (int i = 0; i < N-K; i++) {
    if (S != 1000000000){
      cout << S+1 << ' ';
    }
    else {
      cout << S-1 << ' ';
    }
  }
  cout << endl;
}

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

typedef long long ll;

int main() {
	string S;
	cin >> S;

	ll N = S.size();
	ll sum=0;
	for (int i = 0; i < 1 << N; i++) {
		ll tmp = 0;

		for (int j = 0; j < N; j++) {

			if (i & 1 << j) {
				sum += tmp;
				tmp = 0;
			}
			else {
				tmp = tmp * 10 + S[j] - '0';
			}
		}
		sum += tmp;
	}

	cout << sum << endl;

}

Measured memory_bytes: 256
#include<stdio.h>
 
void visit(int);
int map[101][101];
int f[101],d[101],color[101],time,n;
int main()
{
  int i,j,v,vv,m;
 
  scanf("%d",&n);
  for(i=0;i<n;i++){
    color[i]=0;
    for(j=0;j<n;j++){
      map[i][j]=0;
    }
  }
  time=0;
  for(i=0;i<n;i++){
    scanf("%d%d",&v,&m);
    for(j=0;j<m;j++){
      scanf("%d",&vv);
      map[v-1][vv-1]=1;
    }
  }
  for(i=0;i<n;i++){
    if(color[i]==0)visit(i);
  }
  for(i=0;i<n;i++){
    printf("%d %d %d\n",i+1,d[i],f[i]);
  }
  return 0;
}
 
void visit(int u)
{
  int i;
  color[u]=1;
  d[u]=++time;
  for(i=0;i<n;i++){
    if(map[u][i]==1){
      if(color[i]==0)visit(i);
   
    }
  }
  color[u]=2;
  f[u]=++time;
}


Measured memory_bytes: 2120
function main(input) {
  // 入力値の分離
  var tmp = input.split("\n");
  var AC = 0;
  var WA = 0;
  var TLE = 0;
  var RE = 0;

  for(var i = 1; i < tmp.length; i++){
    switch(tmp[i]){
      case "AC":
        AC++;
        break;
      case "WA":
        WA++
        break;
      case "TLE":
        TLE++
        break;
      case "RE":
        RE++
        break;
    }
  }

  var ans = ""
  ans += "AC x " + String(AC) + "\n"
  ans += "WA x " + String(WA) + "\n"
  ans += "TLE x " + String(TLE) + "\n"
  ans += "RE x " + String(RE) + "\n"

  console.log(ans);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));parseInt

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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int N, A, B; cin >> N >> A >> B;
  int ans = 0;
  REP(i,N){
	int t; cin >> t;
	if(t < A || B <= t)
	  ++ans;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
typedef long long ll;

int main(){

  int N; cin >> N;
  vector <int> L(N);
  for (int i = 0; i < N; i++){
    cin >> L[i];
  }
  sort(L.begin(), L.end());

  int ans = 0;
  for (int i = 0; i < N - 2; i++){
    for (int j = i + 1; j < N - 1; j++){
      int A = L[i], B = L[j];
      for (int k = j + 1; k < N; k++){
        if (A + B > L[k]){
          ans++;
        }
      }
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
using ll=long long;
using P=pair<ll,ll>;
using PP=tuple<ll,ll,ll>;
using S=multiset<ll>;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
void decimal(int x){cout<<fixed<<setprecision(x);}
//ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);}
//ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*POW(a,b-1)%mod;ll k=POW(a,b/2);return k*k%mod;}
vi calc(ll x){vi res;while(x>0){res.eb(x%10);x/=10;}reverse(all(res));return res;}

void solve(){
  string s; cin>>s;
  if(s=="RRR") out(3);
  else if(s=="RRS"||s=="SRR") out(2);
  else if(s=="SSS") out(0);
  else out(1);
}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
}


Measured memory_bytes: 3672
// Problem : A - Kyu in AtCoder
// Contest : AtCoder - M-SOLUTIONS Programming Contest 2020
// URL : https://atcoder.jp/contests/m-solutions2020/tasks/m_solutions2020_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define fr(i,a,b) for(int i=a;i<b;i++)
#define frr(i,a,b) for(int i=a;i>=b;i--)
//vector
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define pp pop_back
//pair
#define pi pair<int ,int >
#define mk make_pair
#define ff first
#define ss second
//set
#define si set<int>
#define sit set<int>::iterator 
using namespace std;
int main()
{
fast;
int n;cin>>n;
if(n>=400 && n<=599) cout<<8;
else if(n>=600 && n<=799) cout<<7;
else if(n>=800 && n<=999) cout<<6;
else if(n>=1000 && n<=1199) cout<<5;
else if(n>=1200 && n<=1399) cout<<4;
else if(n>=1400 && n<=1599) cout<<3;
else if(n>=1600 && n<=1799) cout<<2;
else cout<<1;
return 0;
}

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

const int MAX = 200000;

int main() {
    int R[MAX];
    int n;

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

    int maxv = R[1] - R[0];
    int minv = R[0];

    for (int i = 1; i < n; i++) {
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }

    cout << maxv << endl;
}

Measured memory_bytes: 3848
N = gets.chomp.to_i
cnts = {}
max_cnt = 0
N.times do 
  s = gets.chomp
  cnts[s] ||= 0
  cnts[s] += 1
  if max_cnt < cnts[s]
    max_cnt = cnts[s]
  end
end
# S = gets.chomp.chars

a = []
cnts.each do |k, v|
  if v == max_cnt
    a << k
  end
end

a.sort!
a.each do |s|
  print s + "\n"
end

Measured memory_bytes: 33000
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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


	int N = getint(), M = getint();
	int AB[100001] = {};
	rep(i, M) {
		int a = getint(), b = getint();
		AB[b] = max(AB[b], a);
	}

	int kotae = 0;
	int kitta = 1;
	rep1(i, N) {
		if (kitta <= AB[i]) {
			kitta = i;
			kotae++;
		}
	}
	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mkp make_pair
#define mod 1000000007
#define F first
#define S second
#define ld long double
#define f(i,l,f,n) for(i=(l); i<(n) && !(f); i++)
#define endl "\n"

int dp[3001][3001];
string s, t;

int lcs(int n, int m)
{
    if(n==0 || m==0)
    return 0;
    else if(dp[n][m]!=-1)
    return dp[n][m];
    else if(s[n-1]==t[m-1])
    dp[n][m]= lcs(n-1,m-1)+1;
    else
    dp[n][m]=max(lcs(n-1,m), lcs(n,m-1));

    return dp[n][m];
}

void solve()
{
    cin>>s>>t;
    int n = s.length();
    int m = t.length();
    memset(dp, -1, sizeof(dp));
    int l = lcs(n,m);

    char ans[l+1];
    ans[l]='\0';
    int i=n, j=m;
    while(i>0 && j>0)
    {
        if(s[i-1]==t[j-1])
        {
            ans[l-1]=s[i-1];
            l--;
            i--;
            j--;
        }
        else if(dp[i-1][j]>dp[i][j-1])
        i--;
        else
        j--;
    }
    cout<<ans;

}


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

    int t=1, i=0;
    //cin>>t;
    while(t--)
    {
        //cout<<"Case #"<<i++<<": "<<solve()<<endl;
        solve();
    }
}

/*
AGGTAB
GXTXAYB
*/


Measured memory_bytes: 35968
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0583

"""
import sys
from sys import stdin
from itertools import combinations
from functools import reduce
input = stdin.readline



def solve2():
    divs = [1]
    a, b = map(int, input().split())
    if a > b:
        a, b = b, a

    for i in range(2, a+1):
        while a%i == 0 and b%i == 0:
            divs.append(i)
            a //= i
            b //= i

    t = divs[:]
    for i in range(2, len(divs)):
        for c in combinations(divs[1:], i):
            p = reduce(lambda x, y: x*y, c)
            t.append(p)
    st = list(set(t))
    st.sort()
    return st


def solve3():
    divs = [1]
    A = [int(x) for x in input().split()]
    A.sort()
    a, b, c = A[0], A[1], A[2]

    for i in range(2, a+1):
        while a%i == 0 and b%i == 0 and c%i == 0:
            divs.append(i)
            a //= i
            b //= i
            c //= i

    t = divs[:]
    for i in range(2, len(divs)):
        for combi in combinations(divs[1:], i):
            p = reduce(lambda x, y: x*y, combi)
            t.append(p)
    st = list(set(t))
    st.sort()
    return st


def main(args):
    num = int(input())
    if num == 2:
        result = solve2()
    else:
        result = solve3()
    print('\n'.join(map(str, result)))


if __name__ == '__main__':
    main(sys.argv[1:])
    

Measured memory_bytes: 8340
def read_inputs
  n = gets.to_i
  taro = Player.new
  hanako = Player.new
  (1..n).each {
    t, h = gets.chomp.split(" ")
    taro.draw(t)
    hanako.draw(h)
  }
  return taro, hanako
end

class Player
  def initialize
    @hand = []
    @score = 0
  end

  def draw(card)
    @hand << card
  end

  def discard
    @hand.shift
  end

  def add_score(value)
    @score += value
  end

  def hasCard
    @hand.length > 0
  end

  attr_reader :score
end

def battle(p1, p2)
  p1_card = p1.discard
  p2_card = p2.discard
  if p1_card == p2_card
    p1.add_score(1)
    p2.add_score(1)
  elsif p1_card > p2_card
    p1.add_score(3)
  else
    p2.add_score(3)
  end
end

taro, hanako = read_inputs
battle(taro, hanako) while taro.hasCard
puts "#{taro.score} #{hanako.score}"

Measured memory_bytes: 8708
def solve():
    N = int(input())
    A = list(map(int, input().split()))
    chokuzoku = [0]*N
    for i in range(N-1):
        chokuzoku[A[i]-1]  += 1
    for j in range(N):
        print(chokuzoku[j])


if __name__ == '__main__':
    solve()


Measured memory_bytes: 32240
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll a[110];
int main(){
	ll n,k;
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	ll ans=0;
	for(int i=0;i<=min(n,k);i++)for(int j=0;j<=min(n,k)-i;j++){
		vector<ll>v;
		ll sum=0;
		for(int l=1;l<=n;l++){
			if((1<=l&&l<=i)||(n+1-j<=l&&l<=n)){
				sum+=a[l];
				v.push_back(a[l]);
			}
		}
		ll num=k-i-j;
		//cout<<sum<<' '<<v.size()<<endl;
		sort(v.begin(),v.end());
		for(int l=0;l<min(num,(long long)v.size());l++){
			if(v[l]>=0)break;
			sum-=v[l];
		}
		//cout<<num<<' '<<sum<<endl;
		ans=max(ans,sum);
	}
	cout<<ans;
	return 0;
}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;





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

    string s;
    cin>>s;
    int n=s.length();
    if (n%2) out("No");
    for (int i=0; i<n; i+=2) {
	if (s[i]=='h' && s[i+1]=='i') continue;
	out("No");
    }
    out("Yes");
    
    
    return 0;
}


Measured memory_bytes: 3656
// https://atcoder.jp/contests/abc056/tasks/abc056_a
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
const int INF = 1e9;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int w, a, b;
    cin >> w >> a >> b;
    if (a > b)
        swap(a, b);
    cout << max(0LL, b - (a + w)) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
using namespace std;
#define rep2(x,from,to) for(int x = (from); x < (to); ++(x))
#define rep(x,to) rep2(x,0,to)
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};
int b[14][14];
void dfs(int y, int x) {
	if(!b[y][x]) return;
	b[y][x] = 0;
	rep(i,4) {
		dfs(y+dy[i], x+dx[i]);
	}
}
int main() {
	string s;
	while(cin >> s) {
		rep(i,14) {
			b[0][i] = b[i][0] = 0;
			b[13][i] = b[i][13] = 0;
		}
		rep(i,12) {
			b[1][i+1] = s[i] - '0';
		}
		rep2(i,2,13) {
			cin >> s;
			rep(j,12) {
				b[i][j+1] = s[j] - '0';
			}
		}
		int cnt = 0;
		rep(i,14) {
			rep(j,14) {
				if(b[i][j]) {
					dfs(i,j);
					cnt++;
				}
			}
		}
		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 1180
#include<iostream>
using namespace std;
int main(void){
    int A,B,C,D;
    cin>>A>>B>>C>>D;
    if(A+B>C+D)
        cout<<"Left"<<endl;
    else if(A+B<C+D)
        cout<<"Right"<<endl;
    else
        cout<<"Balanced"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

// 便利関数
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

// 入出力
void print() { std::cout << '\n'; }
template <class T>void print(const T &x) {std::cout << x <<'\n';}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}

void solve(long long N, std::vector<std::string> s, long long M, std::vector<std::string> t){
}

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

    long long N;
    cin >> N;

    std::vector<std::string> s(N);
    for(int i = 0 ; i < N ; i++)
        std::cin >> s[i];

    long long M;
    cin >> M;

    std::vector<std::string> t(M);
    for(int i = 0 ; i < M ; i++)
        std::cin >> t[i];

    map<string, ll> ans;
    REP(i, N) ans.insert(make_pair(s[i], 0));
    REP(i, M) ans.insert(make_pair(t[i], 0));
    REP(i, N) ans[s[i]]++;
    REP(i, M) ans[t[i]]--;
    ll maxi = 0;
    for (auto i : ans)
        chmax(maxi, i.second);
    print(maxi);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;

int n, q;
vector<int> ki[200001];
vector<ll> num(200001);
vector<ll> ans(200001);

void dfs(int from, ll coun){
	for (int i = 0; i < ki[from].size(); i++){
		int to = ki[from][i];
		if (ans[to] == -1){
			ans[to] = coun + num[to];
			dfs(to, ans[to]);
		}
	}
	return;
}

int main(){
	cin >> n >> q;
	ki[0].push_back(1);
	for (int i = 0; i < n-1; i++){
		int a, b;
		cin >> a >> b;
		ki[a].push_back(b);
		ki[b].push_back(a);
	}
	for (int i = 0; i < q; i++){
		int p, x;
		cin >> p >> x;
		num[p] += x;
	}
	for (int i = 0; i <= n; i++){
		ans[i] = -1;
	}
	dfs(0, 0);

	for (int i = 1; i <= n; i++){
		cout << ans[i] << " ";
	}
	cout << endl;
 	return 0;
}



Measured memory_bytes: 25856
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<set>
#include<queue>
#include<list>
#include<stdio.h>
#include<stdlib.h>
#include<map>
#include<cstdio>
#include <iomanip>

#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 fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

typedef long long ll;

using namespace std;

int getNumOfDivsor(int N) {
	
	int ans = 0;

	for (int i = 1; i<= N; ++i) {
		if (N%i == 0) {
			++ans;
		}
	}

	return ans;

}

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

	int ans = 0;
	for (int i = 1; i <= n; i+=2) {
		if (getNumOfDivsor(i) == 8) {
			++ans;
		}
	}

	cout << ans << endl;

	return 0;

}


Measured memory_bytes: 256
import sys
from collections import *
import heapq
import math
# from math import gcd
import bisect
import copy
from itertools import permutations,accumulate,combinations,product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n=int(input())
t=list(map(int,input().split()))
v=list(map(int,input().split()))

t.append(0)
v.append(0)
t.insert(0,0)
v.insert(0,0)

tt=sum(t)
lst=[0]*(tt*2+1)

for i in range(tt*2-1):
    tmp=[]
    now=0.5+i/2
    cnt=0
    for j in range(n+2):
        l=cnt
        cnt+=t[j]
        r=cnt
        if j==n+1:
            l=r
        if now<=l:
            tmp.append(l-now+v[j])
        elif r<=now:
            tmp.append(now-r+v[j])
        else:
            tmp.append(v[j])
        # print(l,r)
    lst[i+1]=min(tmp)

# print(lst)
ans=0
for i in range(tt*2):
    ans+=0.25*(lst[i+1]+lst[i])
print(ans)

Measured memory_bytes: 44764
import math
import numpy as np

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors
  
def set_list(es):
  return len(list(set(es))) == 1
  
n = int(input())
n_list = [int(i) for i in input().split()] 

if set_list(n_list):
    print(n_list[0])
else:
  min1 = min(n_list)
  n_list.remove(min1)
  min2 = min(n_list)
  n_list.append(min1)

  div_list = make_divisors(min1) + make_divisors(min2)
  div_set = set(div_list)
  div_list = sorted(list(div_set))

  k = 0
  length = len(div_set)
  while k < length: 
    s = div_list[length - k - 1]
    count = 0
    j = 0
    for x in n_list:
      if n_list[j] % s == 0:
        count += 1
      j += 1
    if count >= n - 1:
      print(s)
      break
      
    k += 1

Measured memory_bytes: 23116
#include<cstdio>
#include<iostream>
using namespace std;
int f[11][11]={{0}};
char m[11][11];
int h,w;
void dfs(int y,int x){
  
  f[y][x]=1;
  for(int i=1;i<=3;i++){
    for(int j=1;j<=3;j++){
      if(y+i>=0 && y+i<h && x>=0 && x<w){
	if(m[y+i][x]=='1' && f[y+i][x]==0)dfs(y+i,x);
	f[y+i][x]=1;
      }
      if(y>=0 && y<h && x+j>=0 && x+j<w){
	if(m[y][x+j]=='1' && f[y][x+j]==0)dfs(y,x+j);
	f[y][x+j]=1;
      }
      if(y-i>=0 && y-i<h && x>=0 && x<w){
	if(m[y-i][x]=='1' && f[y-i][x]==0)dfs(y-i,x);
	f[y-i][x]=1;
      }
      if(y>=0 && y<h && x-j>=0 && x-j<w){
	if(m[y][x-j]=='1' && f[y][x-j]==0)dfs(y,x-j);
	f[y][x-j]=1;
      }
    }
  }
  return ;
}
int main(){
  
  int n,cnt=1;
  scanf("%d",&n);
  while(cnt<=n){
    int x,y;
    h=w=8;
    for(int i=0;i<h;i++){
      scanf("%s",m[i]);
    }
    scanf("%d %d",&x,&y);
    x--;y--;
    
    dfs(y,x);
    
    printf("Data %d:\n",cnt);
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	if(f[i][j])printf("0");
	else printf("%c",m[i][j]);
	f[i][j]=0;
      }
      printf("\n");
    }	
    cnt++;
  }
    
  return 0;
}

Measured memory_bytes: 1196
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define RREP(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N, K; cin >> N >> K;
    if(K > (N-1)*(N-2)/2){
        cout << -1 << endstr; return 0;
    }
    
    ll nn = 0;
    for(ll i = N; i >= 2; i--){
        if(K > (i-1)*(i-2)/2){
            nn = i+1; break;
        }
    }
    
    vpl ans;
    FOR(i, 2, nn+1){
        ans.pb({1, i});
    }
    
    ll rem = (nn-1)*(nn-2)/2 - K;
    
    FOR(i, 2, nn+1){
        FOR(j, i+1, nn+1){
            if(rem > 0){
                ans.pb({i, j});
                rem--;
            }
        }
        if(rem == 0) break;
    }
    
    vvb g(N+1, vb(N+1, false));
    
    FOR(i, nn+1, N+1){
        FOR(j, 1, N+1){
            if(i == j) continue;
            if(g[i][j] || g[j][i]) continue;
            ans.pb({i, j});
            g[i][j] = true; g[j][i] = true;
        }
    }
    
    cout << ans.size() << endstr;
    REP(i, ans.size()) cout << ans[i].ff << " " << ans[i].ss << endstr;
    
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<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()

int main(void){
    int p;
    cin>>p;
    vi d(100002,0);
    d[0]=1;
    rep(lp,p){
        int a,b; cin>>a>>b;
        d[a]++,d[b+1]--;
    }
    int ans=0;
    range(i,1,100002){
        d[i]+=d[i-1];
        if(d[i]>=i) ans=i;
    }
    cout<<ans-1<<endl;
}

Measured memory_bytes: 3100
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()


int main() {
  int n;
  cin >> n;
  vector<ll> a(110000,0);
  rep(i, n) {
    int b;
    cin >> b;
    a[b]++;
  }
  
  int ans;
  for (int x = 1; x <= 100000; x++) {
    int cnt = a[x-1] + a[x] + a[x+1];
    ans = max(ans, cnt);
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 1152
def visit(j, visited, stack, Graph):
    stack[j] = 1
    vflag[j] = 1
    
    for k in Graph[j]:
        if stack[k]:
            return True
        if vflag[k]:
            continue
        if visit(k, vflag, stack, Graph):
            return True
    stack[j] = 0
    return False
 

if __name__=='__main__':
    V,E  = (int(x) for x in  input().split())
    Graph = [[] for i in range(V)]

    for i in range(E):
        s, t = (int(x)for x in input().split())
        Graph[s].append(t)
        
    vflag = [0 for i in range(V)]
    stack = [0 for i in range(V)]
    jdg = 0
    
    for j in range(V):
        if not vflag[j]:
            if visit(j, vflag, stack, Graph):
                jdg = 1
                break
    print(jdg)
 
 




Measured memory_bytes: 5608
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,A,j,x=29;
  cin>>N;
  for(int i=0;i<N;i++){
    cin>>A;
    j=0;
    while(A%2==0)A/=2,j++;
    if(x>j)x=j;
  }
  cout<<x<<endl;
}

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

void tlow(char *c){
	int i=0;
	while(c[i]!='\0')
	{
		if(isupper(c[i]))
			c[i] = tolower(c[i]);
		i++;
	}
}
int main(void){
	char search[11],source[1001];
	int cnt=0;

	scanf("%s",search);
	tlow(search);
	while(1){
		scanf("%s",source);
		if(strcmp(source,"END_OF_TEXT")==0)
			break;
		tlow(source);
		if(strcmp(search,source)==0)
			cnt++;
	}
	printf("%d\n",cnt);
	return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N, L;
    cin >> N >> L;
    vector<string> S(N);
    rep(i, N) cin >> S[i];
    sort(S.begin(), S.end());
    string ans = "";
    rep(i, N) {
        ans += S[i];
    }
    cout << ans << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define loop(i,b,e) for(int i=b;i<=e;i++)
#define loop2(i,e,b) for(int i=e;i>=b;i--)
#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define fi first
#define se second
#define X real()
#define Y imag()
#define cp(a,b)	( (conj(a)*(b)).imag() )
#define length(a) (hypot((a).imag(), (a).real()))
typedef complex<double> point;
typedef long long ll;
typedef unsigned long long ull;
double PI = 3.141592653589793;
const double EPS = 1e-9;
const int N = 1e6 + 5;
const ll mod = 1e9 + 7;
const int oo = 1e9;
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };

string s;

int main() {
	io;
	cin >> s;
	bool a = s[0] == 'A';
	bool b = 00;
	bool c = (s[1] >= 'a' && s[1] <= 'z' ) &&(s[s.size() - 1] >= 'a' && s[s.size() - 1] <= 'z') && (s[s.size() - 1] != 'C');
	for (int i = 2; i < s.size() - 1; i++) {
		if (s[i] == 'C') {
			if (b) {
				b = 0;
				break;
			}
			b = 1;
		}
		else {
			c &= s[1] >= 'a' && s[1] <= 'z';
		}
	}
	if (a && b && c) cout << "AC"; else cout << "WA";
}

Measured memory_bytes: 256
//Shubham Vijayvargiya

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

#define pb push_back
#define mp make_pair
#define eb emplace_back
#define F first
#define S second
#define sz(a) (int)(a.size())
#define set(a,b) memset(a,b,sizeof(a))
#define let(x,a) __typeof(a) x(a)
#define rep(i, begin, end) for (ll i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define all(v) (v).begin(),(v).end()
#define sll(x) { scanf("%lld",&x); }
#define si(x) { scanf("%d",&x); }
#define slf(x) { scanf("%lf",&x); }
#define pll(x) { printf("%lld\n",x); }
#define pi(x) { printf("%d\n",x); }
#define tcases() long long testcases; cin>>testcases ; while(testcases--)

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " = " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " = " << arg1<<" | ";__f(comma+1, args...);
}

#else
#define trace(...)
#endif

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<long long,long long> pll;
typedef vector<long long> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;

const ll mod=1000000007;
//-----------------------------------------------------------------------------------------------------------------------------------------------//

ll ans[1009];

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

	ll n;
	cin>>n;

	rep(i,1,n+1){
		ll j=i;
		ll l=j;
		rep(k,2,l+1){
			while(j%k==0){
				ans[k]++;
				j/=k;
			}
		}
	}
	ll an=1;
	rep(i,1,n+1){
		an=(an*(ans[i]+1))%mod;
	}
	cout<<an<<endl;
	return 0;
}

Measured memory_bytes: 256
#$debug=3
$debug=0

def aux(a,ops)
  return a if ops==[]
  op = ops.shift

  if op=="E"
    return aux(opE(a),ops)
  elsif op=="W"
    return aux(opW(a),ops)
  elsif op=="N"
    return aux(opN(a),ops)
  else
    return aux(opS(a),ops)
  end

end

def opE(a)
	[0, a[4],a[2],a[1],a[6],a[5],a[3]]
end

def opW(a)
	[0, a[3],a[2],a[6],a[1],a[5],a[4]]
end

def opN(a)
	[0, a[2],a[6],a[3],a[4],a[1],a[5]]
end

def opS(a)
	[0, a[5],a[1],a[3],a[4],a[6],a[2]]
end

def main
  if $debug&1==1 
    fh=File.open("ITP_1_11_A.txt")
  else
    fh=STDIN
  end
  a  = fh.gets.chomp.split.unshift("0")
  puts "a: #{a.to_s}" if $debug&2==2
  ops= fh.gets.chomp.split(//)
  puts "ops: #{ops.to_s}" if $debug&2==2
  ans=aux(a,ops)
  puts ans.to_s if $debug&2==2
  puts ans[1]
end

if $0 == __FILE__ then
  main
end


Measured memory_bytes: 6880
import numpy as np
N, L = map(int, input().split())
if L > 0:
    s = np.sum(np.arange(L+1, L+N))
elif L < -N+1:
    s = np.sum(np.arange(L, L+N-1))
else:
    s = np.sum(np.arange(L, L+N))
print(s)

Measured memory_bytes: 21272
#include <bits/stdc++.h>
using namespace std;
int n,sol[205],st,dr,r,x,y;
int ask1(int pos)
{
	cout<<"?"<<" ";
	for(int i=pos;i<=pos+n-1;i++)
		cout<<i<<" ";
	cout<<endl;
	string ans;
	cin>>ans;
	if(ans=="Red")
		return 0;
	else
		return 1;
}
void ask2(int pos,int start)
{
	cout<<"?"<<" ";
	cout<<pos<<" ";
	for(int i=start;i<=start+n-2;i++)
	{
		if(i>2*n)
			cout<<i-2*n<<" ";
		else
			cout<<i<<" ";
	}
	cout<<endl;
	string ans;
	cin>>ans;
	if(ans=="Red")
		sol[pos]=0;
	else
		sol[pos]=1;
}
int main()
{
	cin>>n;
	if(n<=50)
	{
		for(int i=1;i<=n;i++)
		{
			x=ask1(i);
			y=ask1(i+1);
			if(x+y==1)
			{
				st=i+1;
				dr=i+n-1;
				//sol[i]=x;
				//sol[i+n]=y;
				break;
			}
		}
	}
	else
	{
		st=2;
		dr=n+1;
		x=ask1(1);
		while(st!=dr)
		{
			int mid=(st+dr)/2;
			y=ask1(mid);
			if(x!=y)
				dr=mid;
			else
				st=mid+1;
		}
		dr=st+n-2;
		//sol[st-1]=x;
		//sol[dr+1]=y;
	}
	//cout<<st<<" "<<dr<<"\n";
	//return 0;
	for(int i=1;i<=2*n;i++)
	{
		if(st<=i && i<=dr)
				ask2(i,dr+2);
		else
			ask2(i,st);
	}
	cout<<"!"<<" ";
	for(int i=1;i<=2*n;i++)
	{
		if(sol[i])
			cout<<"B";
		else
			cout<<"R";
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 724
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
#define DL double
#define MLL map<LL,LL>::iterator
#define MSL map<string,L>::iterator
#define MLS map<LL,string>::iterator
#define MSS map<string,string>::iterator
#define MCL map<char,LL>::iterator
#define SL set<LL>::iterator
#define SS set<string>::iterator
#define VL V<LL>::iterator
#define G getline
#define SZ size()
#define IN insert
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define MAX 1e18
#define MIN -1e18
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
V<LL>v;
int main()
{
    LL n,m,i,j,k,p,q,o,l,s,t,z=0,r;
    string a;
    cin>>n;
    for(i=0,p=0,q=0;i<n;i++)
    {
        cin>>o;
        v.PSB(o);
    }
    sort(v.B,v.E,greater<LL>());
    for(i=0;i<n;i++)
    {
        if(i%2==0)
        {
            p+=v[i];
        }
        else
        {
            q+=v[i];
        }
    }
    cout<<p-q<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long MOD = 1e9 + 7;
long N,M;
int main(){
    cin >> N >> M;
    long dog = 1,monkey = 1,ans;
    for(int i = 1; i <=N; ++i){
        dog *= i;
        dog %= MOD;
    }
    
    for(int i = 1; i <= M; ++i){
        monkey *= i;
        monkey %= MOD;
    }
    
    if(N >= M + 2 || M >= N + 2){
        ans = 0;
    }else if(abs(N-M) == 1){
        ans = dog*monkey % MOD;
    }else{
        ans = dog*monkey*2 % MOD;
    }
    
    cout << ans << endl;
    
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var h, w, n int
	fmt.Scanf("%d", &h)
	fmt.Scanf("%d", &w)
	fmt.Scanf("%d", &n)
	var max int
	if h > w {
		max = h
	} else {
		max = w
	}
	var c int
	if n%max != 0 {
		c = int(n/max) + 1
	} else {
		c = int(n / max)
	}
	fmt.Println(c)
}


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

const int inf = 2000000000;

int main() {
    int n;
    cin >> n;
    int f[n][10];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 10; j++) {
            cin >> f[i][j];
        }
    }
    int p[n][11];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= 10; j++) {
            cin >> p[i][j];
        }
    }

    int ans = -inf;
    for (int i = 1; i < (1 << 10); i++) {
        int prof = 0;
        for (int j = 0; j < n; j++) {
            int cnt = 0;
            for (int k = 0; k < 10; k++) {
                if (f[j][k] == 1 && (i & (1 << k)) > 0) cnt++;
            }
            prof += p[j][cnt];
        }
        ans = max(ans, prof);
    }

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

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

using namespace std;

int main()
{
  int n, x, in, sum = 0;
  scanf("%d %d", &n, &x);
  int ans = 1;
  while (n--){
    scanf("%d", &in);
    sum += in;
    if (sum <= x)ans++;
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
typedef long long ll;

using namespace std;
const int maxn = 2e6 + 5;

ll isprime[maxn], prime[maxn], numprime, num[maxn], vis[maxn];
ll n, a[maxn];

void makeprime(ll up_bound) {
    isprime[0] = isprime[1] = 1;
    for (ll i = 2; i < up_bound; i++) {
        if (!isprime[i]) prime[numprime++] = i;
        for (ll j = 0; j < numprime && i * prime[j] < up_bound; j++) {
            isprime[i * prime[j]] = 1;
            if (i % prime[j] == 0) break;
        }
    }
}

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

ll primefac(ll x) {
    if (x <= 1) return 0;
    ll cur = 0;
    while (x > 1 && cur < numprime) {
        if (!isprime[x]) {
            vis[x]++;
            if (vis[x] > 1) return 1;
            else return 0;
        }
        if (x % prime[cur] == 0) {
            vis[prime[cur]]++;
            if (vis[prime[cur]] > 1) {
                return 1;
            }

            while (x > 1 && x % prime[cur] == 0)
                x /= prime[cur];
        }
        cur++;
    }
    return 0;
}

int main() {
    makeprime(maxn);
    scanf("%lld", &n);

    ll noflag = 0;
    for (ll i = 1; i <= n; i++) {
        scanf("%lld", a + i);
        num[a[i]]++;

        if (a[i] != 1 && num[a[i]] > 1) 
            noflag = 1;
    }

    // if (noflag) {
    //     printf("not coprime\n");
    //     return 0;
    // }
    
    if ((n - num[1] + 1) > 78499 || noflag) {
        ll g = a[1];
        for (ll i = 2; i <= n; i++)
            g = gcd(g, a[i]);
        
        if (g == 1)
            printf("setwise coprime\n");
        else
            printf("not coprime\n");
        
        return 0;
    }

    noflag = 0;
    ll g = a[1];
    primefac(a[1]);
    for (ll i = 2; i <= n; i++) {
        g = gcd(g, a[i]);
        ll u = primefac(a[i]);
        if (u) noflag = 1;
    }

    if (!noflag) {
        printf("pairwise coprime\n");
    }
    else {
        if (g == 1) printf("setwise coprime\n");
        else printf("not coprime\n");
    }
    return 0;
}

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

 
int main()
{
    
    int s,w;
    cin>>s>>w;
    if(s<=w)
      cout<<"unsafe";
      
    else
      cout<<"safe";
    
    
    
    
     return 0;   
         
  
  
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long    ll;
typedef pair<ll, ll> l_l;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// const ll mod = 1000000007;5
double dp[505][505];
int    n;
double p[505];
double q[505];
double psum[505];
double qsum[505];

double search(int l, int r) {
    if (dp[l][r] != 0) return dp[l][r];
    if (l == r) {
        return dp[l][r] = 0;
    }
    dp[l][r]     = 1e9;
    double total = qsum[r] - qsum[l - 1] + psum[r] - psum[l];
    for (int x = l + 1; x <= r; x++) {
        double left  = qsum[x - 1] - qsum[l - 1] + psum[x - 1] - psum[l];
        double right = total - left - p[x];
        double now   = (search(l, x - 1) + 1) * (left / total) +
                     (search(x, r) + 1) * (right / total);
        dp[l][r] = min(dp[l][r], now);
    }
    return dp[l][r];
}

int main() {
    cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    for (int i = 2; i <= n + 1; i++) cin >> p[i];
    for (int i = 1; i <= n + 1; i++) cin >> q[i];
    for (int i = 1; i <= n + 1; i++) psum[i] = psum[i - 1] + p[i];
    for (int i = i; i <= n + 1; i++) qsum[i] = qsum[i - 1] + q[i];
    cout << 1.0 + search(1, n + 1) << endl;
    return 0;
}


Measured memory_bytes: 5312
#include <bits/stdc++.h>
using namespace std;
#define MAX 2000000
#define INFTY (1<<30)

int H, A[MAX+1];
//H :: ノードの数
//A[] :: 各ノードの値

void maxHeapify(int i) {
  int l, r, largest;
  l = 2 * i;
  r = 2 * i + 1;

  //左の子、自分、右の子のうち値が最大になっているノードを選ぶ
  if (l <= H && A[l] > A[i]) largest = l;
  else largest = i;
  if (r <= H && A[r] > A[largest]) largest = r;

  if (largest != i) {
    swap(A[i], A[largest]);
    maxHeapify(largest);
  }
}

//max-heapの木の中で最大の値はheapの根
int extract() {
  int maxv;
  if (H < 1) return -INFTY;
  maxv = A[1];
  A[1] = A[H];
  H--;
  maxHeapify(1);
  return maxv;
}

//max-heapにキーを追加する
//要素が半分ずつになっていくのでkeyの追加はO(logN)で行える
void increaseKey(int i, int key) {
  if (key < A[i]) return;
  A[i] = key;
  while (i > 1 && A[i/2] < A[i]) {
    swap(A[i], A[i/2]);
    i = i/2;
    //親のほうがキーが大きい場合、入れ替えを行う
  }
}

void insert(int key) {
  H++;
  A[H] = -INFTY;
  increaseKey(H, key);
}

int main() {
  int key;
  string s;
  while (true) {
    cin >> s;
    if (s == "insert") {
      cin >> key;
      insert(key);
    }
    else if (s == "extract") {
      cout << extract() << endl;
    }
    else {
      return 0;
    }
  }
}



Measured memory_bytes: 7008
from functools import lru_cache
import sys
sys.setrecursionlimit(1000000)

N, Z, W = map(int, input().split())
A = [int(a) for a in input().split()]

@lru_cache(maxsize=None)
def X(i, y):
    return max([Y(j+1, A[j]) for j in range(i, N-1)] + [abs(A[N-1] - y)])

@lru_cache(maxsize=None)
def Y(i, x):
    return min([X(j+1, A[j]) for j in range(i, N-1)] + [abs(A[N-1] - x)])

print(X(0, W))

Measured memory_bytes: 76252
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <map>
#include <numeric>
#include <algorithm>
#include <stdio.h>

int main(void){
  long long n,k;
  std::cin >> n >> k;
  (n%k<k-n%k)?std::cout<< n%k:std::cout<< k-n%k;
  return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
typedef pair<long,long> P;
int main(){
  long N,X,Y;cin>>N>>X>>Y;
  vector<vector<long>>A(N);
  
  for(long i=0;i<N-1;i++){
    A[i].push_back(i+1);A[i+1].push_back(i);
  }A[X-1].push_back(Y-1);A[Y-1].push_back(X-1);
  
  vector<vector<long>>D(N,vector<long>(N,LONG_MAX));
  for(long s=0;s<N;s++){
    priority_queue<P,vector<P>,greater<P>> q;q.push(P(0,s));D[s][s]=0;
    while(q.size()){
      P t=q.top();q.pop();
      if(t.first>D[s][t.second])continue;
      for(long e:A[t.second])if(D[s][e]>D[s][t.second]+1){
          D[s][e]=D[s][t.second]+1;q.push(P(D[s][e],e));
      }
    }
  }
  vector<long>ans(N+1,0);
  for(long i=0;i<N;i++)for(long j=0;j<N;j++){
    ans[D[i][j]]++;
  }
  for(long i=1;i<N;i++)cout<<ans[i]/2<<endl;
}


/*
直線的な向こうグラフ+頂点X-Yの変


辺の長さがkであるような個数







*/

Measured memory_bytes: 31744
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

ll fact[200000], invFact[200000], memo[1009];

long long power(long long x, long long c) {
    if(c==0) return 1;
    if(c==1) return x;
    if (c%2==1) return (power( (x*x)%MOD, c/2)*x)%MOD;
    else return power( (x*x)%MOD, c/2)%MOD;
}

void make_combT(ll n){
    fact[0]=1;
    rep1(i,n) fact[i]= fact[i-1]*i%MOD;
    
    invFact[n] = power(fact[n],MOD-2);
    rrep(i,n-1) invFact[i] = invFact[i+1] * (i+1) %MOD;
}

ll comb(ll n, ll m){
    if(n<m||n<0||m<0) return 0;
    return (fact[n] * invFact[m] %MOD) * invFact[n-m] %MOD;
}

ll inv(int k){
    if(memo[k]) return memo[k];
    return memo[k]=power(k,MOD-2);
}

void add(ll &x,ll y){
    x=(x+y)%MOD;
}

ll dp[1009][1009];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    make_combT(1009);
    
    int N,A,B,C,D;
    cin>>N>>A>>B>>C>>D;
    
    dp[A][0]=1;
    FOR(i,A,B+1){
        rep(j,N+1)if(dp[i][j]){
            add(dp[i+1][j],dp[i][j]);
            ll p=1;
            for(int k=1;k<=D&&j+i*k<=N;k++){
                p=p*comb(N-j-i*(k-1),i)%MOD*inv(k)%MOD;
                if(k>=C) add(dp[i+1][j+i*k],dp[i][j]*p%MOD);
            }
        }
    }
    cout1(dp[B+1][N])
}

Measured memory_bytes: 10496