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

int solve(int n, int m, int l) {
    vector<vector<int>> dp(n, vector<int>(l + 1, 1e9));
    dp[0][l] = 0;
    vector<vector<tuple<int, int, int>>> adj(n);
    for (int i = 0; i < m; i++) {
        int a, b, d, e;
        cin >> a >> b >> d >> e;
        a--, b--;
        adj[a].emplace_back(b, d, e);
        adj[b].emplace_back(a, d, e);
    }

    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<>> que;
    que.emplace(0, l);
    while (!que.empty()) {
        auto top = que.top();
        que.pop();
        int v = top.first, k = top.second;
        for (auto &t : adj[v]) {
            int u = get<0>(t), d = get<1>(t), e = get<2>(t);
            // 何も守らない
            if (dp[v][k] + e < dp[u][k]) {
                dp[u][k] = dp[v][k] + e;
                que.emplace(u, k);
            }
            if (d <= k && dp[v][k] < dp[u][k - d]) {
                dp[u][k - d] = dp[v][k];
                que.emplace(u, k - d);
            }
        }
    }
    int ret = 1e9;
    for (int i = 0; i <= l; i++) {
        ret = min(ret, dp.back()[i]);
    }
    return ret;
}

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

    while (1) {
        int n, m, l;
        cin >> n >> m >> l;
        if (n == 0) break;
        cout << solve(n, m, l) << '\n';
    }
}


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

using namespace std;

#define ll long long

int const N = 111, W = 1e5 + 11;

ll n, w;

ll arr[N][2], dp[N][W], vis[N][W];

ll pound(ll index, ll weight)

{

		if (index > n)				return 0;

				

		if (weight > w)

				return -1e9;

				

		if (vis[index][weight])

				return dp[index][weight];

				

		vis[index][weight] = 1;

		

		return dp[index][weight] = max(arr[index][1] + pound(index + 1, weight + arr[index][0]), pound(index + 1, weight));

}

int main()

{

    cin >> n >> w;

    

    for (int i = 0; i < n; ++i)

        cin >> arr[i][0] >> arr[i][1];

        

    cout << pound(0, 0);

    

    return 0;

}

Measured memory_bytes: 157952
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
int main(){
    int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin>>k;
    cout<<a[k-1]<<endl;
}

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

using namespace std;

const int md = 1000000007;

inline void add(int &a, int b) {
  a += b;
  if (a >= md) {
    a -= md;
  }
}

inline int mul(int a, int b) {
  return (long long) a * b % md;
}

const int N = 1234567;

int who[N];
int mask[N];
int kb[N];
int g[N];
int deg[N];
int ans;

void dfs(int v, int ways) {
  if (v == 1) {
    int rm0 = deg[0];
    int rm1 = deg[1];
    int z = 0;
    while (true) {
      int cur0 = kb[mask[0] & who[z]];
      int cur1 = kb[mask[1] & who[z]];
      add(ans, mul(ways, 1 << (rm0 - cur0 + rm1 - cur1)));
      if (cur0 == 0 || cur1 == 0) {
        break;
      }
      rm0 -= cur0;
      rm1 -= cur1;
      ways = mul(ways, (1 << cur0) - 1);
      ways = mul(ways, (1 << cur1) - 1);
      z++;
    }
    return;
  }
  g[v] = 0;
  int rm = deg[v];
  while (true) {
    int cur = kb[mask[v] & who[g[v]]];
    who[g[v]] ^= (1 << v);
    dfs(v - 1, mul(ways, 1 << (rm - cur)));
    who[g[v]] ^= (1 << v);
    if (cur == 0) {
      break;
    }
    rm -= cur;
    ways = mul(ways, (1 << cur) - 1);
    g[v]++;
  }
}

int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    x--; y--;
    mask[x] |= (1 << y);
  }
  if (mask[0] & 2) {
    mask[0] ^= 2;
  }
  kb[0] = 0;
  for (int i = 1; i < (1 << n); i++) {
    kb[i] = kb[i & (i - 1)] + 1;
  }
  for (int i = 0; i < n; i++) {
    deg[i] = kb[mask[i]];
  }
  for (int z = 0; z <= n; z++) {
    who[z] = 0;
  }
  ans = 0;
  dfs(n - 1, 1);
  int total = 1;
  for (int i = 0; i < m; i++) {
    add(total, total);
  }
  int res = total;
  add(res, md - ans);
  printf("%d\n", res);
  return 0;
}


Measured memory_bytes: 8448
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define reverse(x) reverse(x.begin(), x.end())
#define pb push_back
#define pii pair<int, int>
#define pll pair<long long,long long>
typedef long long ll;
const int mod = 1e9+7;
using namespace std;
int n, m;

int main(){
	int i, j;
	string s;
	cin >> s;
	n = s.length();
	int ans=0, r=s.length()-2;
	for(i=n-2; i; i-=2){
		bool ok = 1;
		for(j=0;j<i/2;j++){
			if(s[j]!=s[j+i/2])ok=0;
		}if(ok){
			cout << i;
			return 0;
		}
	}return 0;
}


Measured memory_bytes: 3596
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp64 {
    class Program {
        static void Main(string[] args) {
            int N = int.Parse(Console.ReadLine());
            string[] s = new string[N];
            for (int i = 0; i < N; i++) {
                s[i] = Console.ReadLine();
            }

            int M = int.Parse(Console.ReadLine());
            string[] t = new string[M];
            for (int i = 0; i < M; i++) {
                t[i] = Console.ReadLine();
            }

            int ans = 0;

            var cand = s.Distinct().ToList();

            foreach(var element in cand) {
                ans = Math.Max(ans, s.Where(x => x == element).Count() - t.Where(x => x == element).Count());
            }



            if (ans < 0) {
                Console.WriteLine(0);
            } else {
                Console.WriteLine(ans);
            }
        }
    }
}


Measured memory_bytes: 13404
n, d = map(int, input().split())
coords = []
for i in range(n):
    x = list(map(int, input().split()))
    coords.append(x)

from math import sqrt

res = 0
for i in range(n):
    for j in range(i + 1, n):
        ci = coords[i]
        cj = coords[j]
        s = 0
        for k in range(d):
            s += (ci[k] - cj[k]) ** 2
        sq = sqrt(s)
        if sq.is_integer():
            res += 1
print(int(res))

Measured memory_bytes: 38256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n = INT()
p = LIST()

ans = 0
for i in range(n):
	if i != 0 and i != n-1 and p[i-1] < p[i] < p[i+1]:
		ans += 1
	elif i != 0 and i != n-1 and p[i-1] > p[i] > p[i+1]:
		ans += 1
print(ans)


Measured memory_bytes: 5968
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const ll MAX=16;
ll k,p10[MAX]={1,};
ll sum(ll x){
    if(x==0) return 0ll;
    return sum(x/10ll)+x%10ll;
}
int main(){
    ll now=0;
    scanf("%lld",&k);
    for(ll i=1;i<16;i++) p10[i]=p10[i-1]*10ll;
    for(ll i=0;i<k;i++){
        ll pt=0;
        now++;
        while(now>sum(now)*p10[pt]){
            now+=(9ll-now/p10[pt]%10ll)*p10[pt];
            pt++;
        }
        printf("%lld\n",now);
    }
}


Measured memory_bytes: 256
def div2(r):
    c = 0
    while r % 2 == 0:
        r //= 2
        c += 1
    return c


n = int(input())
a = list(map(int, input().split()))
ans = 1000000
for e in a:
    ans = min(ans, div2(e))
print(ans)


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

inline bool check(ll a, ll b, ll c){ return a<b+c; }

int main(){
  ll n, a[100100];
  scanf("%lld",&n);
  for(int i=0;i<n;i++)scanf("%lld",a+i);
  sort(a,a+n,greater<ll>());

  ll ans = 0;
  for(int i=0;i<n-2;i++){
    if(check(a[i],a[i+1],a[i+2])){
      for(int j=i+3;j<n-2;j++){
	if(check(a[j],a[j+1],a[j+2])){
	  ll sum = 0;
	  for(int k=0;k<3;k++)sum += a[i+k] + a[j+k];
	  ans = max(ans,sum);
	  goto END1;
	}
      }
    }
  }
 END1:;

  for(int i=0;i<n-5;i++){
    int comb = (1<<3)-1;
    while(comb < (1<<5)){
      vector<ll> A,B;
      for(int j=0;j<6;j++){
	if( (comb>>j)&1 )A.push_back(a[i+j]);
	else B.push_back(a[i+j]);
      }

      if(check(A[0],A[1],A[2]) && check(B[0],B[1],B[2])){
	ll sum = 0;
	for(int k=0;k<6;k++)sum += a[i+k];
	ans = max(ans,sum);
	goto END2;
      }

      int x = comb & -comb, y = comb + x;
      comb = ( ( (comb & ~y) /x ) >> 1) | y;
    }
  }

 END2: cout << ans << endl;
}

Measured memory_bytes: 2016
//K-OS WITH THE OCDE

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <deque>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <climits>

using namespace std;

typedef long long int ll;
typedef long double db;


#define TEST ll t; cin>>t; while(t--)
#define vell vector<ll>
#define pl pair<ll,ll>
#define all(v) v.begin(),v.end()
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define dbg(x)  cerr << #x << ": "<< x <<endl
#define dbg2(x,y) cerr<< #x <<": "<< x <<" || "<< #y << ": " << y << endl

#define endl "\n"
#define MAX 1e18
#define MIN INT_MIN
#define mod 1000000007



void solve()
{
     ll l,r,d;
     cin >> l >> r >> d;
     ll f = 0;

     for(ll i=1 ; i<= 102 ; ++i) {

        if(d*i >=l && d*i <=r)
            f++;
     }

     cout << f;
}

int main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);cin.tie(0);   
    //TEST
     solve();
}



Measured memory_bytes: 3580
//....SARANSH GUPTA....\\

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fo(p,n) for(int i=p;i<n;i++)
#define FIO ios_base::sync_with_stdio(false);   cin.tie(NULL);   cout.tie(NULL);
#define endl "\n"
#define mp make_pair
#define pb push_back
#define mod 1000000007

int main()
{
    FIO
    ll a,b,c;
    cin>>a>>b>>c;
    a=llabs(a);
    
    ll x=a/c;
    if(b<x)
    {
        
        ll ans=a-b*c;
        cout<<ans<<endl;
    }
    else
    {
        ll best=a%c;
        b-=x;
        if(b%2==0)
        cout<<best<<endl;
        else
        {
            cout<<(llabs(best-c))<<endl;
        }
    }
}

Measured memory_bytes: 3640
#include <cstdio>
#include <queue>
#include <vector>
#include <algorithm>
using namespace std;

// city, speed, prev -> time
int N, M, start, goal;
double dist[40][40][40];

struct Edge {
    int to, length, limit;
};

struct Elem {
    int city, speed, prev;
    bool operator<(const Elem &x) const {
        return dist[city][speed][prev] > dist[x.city][x.speed][x.prev];
    }
};

typedef vector< vector< Edge > > Graph;
const double INF = 1e20;

int main() {
    while(1) {
        scanf("%d%d", &N, &M);
        if(N == 0 && M == 0) break;

        Graph G(N);
        scanf("%d%d", &start, &goal);
        start--; goal--;
        for(int i=0; i<M; i++) {
            int u, v, d, c; scanf("%d%d%d%d", &u, &v, &d, &c);
            u--; v--;
            G[u].push_back(Edge{v, d, c});
            G[v].push_back(Edge{u, d, c});
        }

        for(int i=0; i<N; i++) {
            for(int j=0; j<=30; j++) {
                for(int k=0; k<N; k++) {
                    dist[i][j][k] = INF;
                }
            }
        }
        dist[start][1][N] = 0;

        priority_queue<Elem> que;
        que.push(Elem{start, 1, N});

        double ans = INF;
        while(que.size()) {
            Elem cur = que.top(); que.pop();
            int sp = cur.speed, ct = cur.city, pr = cur.prev;
            if(sp <= 0) continue;
            // printf("sp = %d, ct = %d, pr = %d\n", sp, ct, pr);

            for(size_t i=0; i<G[ct].size(); i++) {
                Edge e = G[ct][i];
                if(e.to == pr || sp > e.limit) continue;
                double cost = 1.0 * e.length / sp;
                for(int k=-1; k<=1; k++) {
                    int next_sp = sp + k;
                    if(e.to == goal && sp == 1) {
                        ans = min(ans, dist[ct][sp][pr] + cost);
                    }
                    if(dist[e.to][next_sp][ct] > dist[ct][sp][pr] + cost) {
                        dist[e.to][next_sp][ct] = dist[ct][sp][pr] + cost;
                        que.push(Elem{e.to, next_sp, ct});
                    }
                }
            }
        }

        if(ans == INF) printf("unreachable\n");
        else printf("%.12f\n", ans);
    }
    return 0;
}


Measured memory_bytes: 3416
#include<bits/stdc++.h>
using namespace std;
int n,k,a[100005],ans=2e9;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> n >> k;
	for(int i = 0; i < n; i++) cin >> a[i];
	sort(a,a+n);
	for(int i = 0; i <= n - k; i++){
		ans = min(ans,a[i + k - 1] - a[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
def solve(N, M, SC):
    for i in range(0, 10**(N+1)):
        n = str(i)
        if len(n) == N and all([n[s-1] == str(c) for s, c in SC]):
            return i
    return -1

if __name__ == "__main__":
    N, M = map(int, input().split(" "))
    SC = []
    for _ in range(M):
        SC.append(list(map(int, input().split(" "))))
    print(solve(N, M, SC))


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

#define ll long long
#define rep(i,n) for(ll i=(ll)(0); i<(ll)(n); ++i)
#define irep(i,m,n) for(ll i=(ll)(m); i<(ll)(n); ++i)
#define vi vector<int>

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

const long long MOD = 1e9 + 7;

signed main()
{
  int n;
  cin>>n;
  vi c(n-1),s(n-1),f(n-1);
  rep(i,n-1){
    cin>>c[i]>>s[i]>>f[i];
  }
  rep(i,n){
    int t=0;
    irep(j,i,n-1){
      if(t<s[j]){
        t+=(s[j]-t)+c[j];
      }else{
        if(t%f[j]) t+=(f[j]-(t%f[j]))+c[j];
        else t+=c[j];
      }
    }
    cout<<t<<endl;
  }
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        mut a: i64,
        mut b: i64
    }
    let mut ans = 0;
    if a > b {
        ans += a;
        a -= 1;
    } else {
        ans += b;
        b -= 1;
    }
    ans += std::cmp::max(a, b);
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<iostream>

using namespace std;
int main(){
	int N,K,a,b;
	cin >> N >> K;
	for(int i=0;i<K;i++){
		cin >> a >> b;
		cout<< (min(min(a,b),min(N-a+1,N-b+1))-1)%3+1 << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;cin >> S;
    int cnt[26] = {};
    rep(i, S.length()) {
        cnt[S[i] - 'a']++;
        if (cnt[S[i] - 'a'] > 1) {
            cout << "no" << endl;
            return 0;
        }
    }
    cout << "yes" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mmax(a,b,c) max(a,max(b,c))
#define mmin(a,b,c) min(a,min(b,c))
#define M 1000000007
#define V vector
#define F(a,b,c) for (a=b;a<=c;++a)
#define I cin
#define O cout
#define pb push_back
#define all(x) x.begin(),x.end()
#define ff first
#define ss second

int main() {
    I.sync_with_stdio(false);
    I.tie(0);
    ll t,n,q,i,j;
    I>>n;
    V<ll> h(n),dp(n+1,0);
    F(i,0,n-1)
        I>>h[i];
    dp[2]=abs(h[1]-h[0]);
    if (n>2)
    {
        dp[3]=min(dp[2]+abs(h[2]-h[1]),abs(h[2]-h[0]));
        for (i=4;i<=n;++i)
            dp[i]=min(dp[i-1]+abs(h[i-1]-h[i-2]),dp[i-2]+abs(h[i-1]-h[i-3]));
    }
    cout<<dp[n]<<'\n';
    return 0;
}

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

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

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

const ll INF = 1LL << 60;

int main(){
  string ans = "Yes";
  int n; cin >> n;
  vector<string> w(n);
  rep(i, n) cin >> w[i];

  for (int i = 1; i < n; i++) {
    if(w[i][0] != w[i-1][w[i-1].size()-1]) ans = "No";
    for (int j = 0; j < i; j++) {
      if (w[i] == w[j]) ans = "No";
    }
  }

  std::cout << ans << '\n';
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    int main()
    {
      int n,k,x,y,total;
      cin>>n>>k>>x>>y;
      if(n<k)
      {
        total=n*x;
        cout<<total<<endl;
      }
      else
      {
        total=(k*x)+((n-k)*y);
        cout<<total<<endl;
      }
      return 0;
    }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=200005;
int Left[N],Right[N],num,x,val[N],n,l,sl[N],sr[N];
ll ans;
void dec(){
	int now;
	for (now=num-1;now>0;now--)
		if (val[now]!=val[now-1])break;
	int d=num-now,v=val[now];
	ll s=0;
	for (int i=now;i<num;i++){
		ans+=(ll)Left[i]*Right[i];
		if (i-l+1>=now)s+=Left[i-l+1];
		ans+=s*Right[i];
	}
	if (d<l){
		num=now;
		while (num)dec();
		return;
	}
	int dd=d/l;
	for (int i=0;i<=dd;i++)sl[i]=sr[i]=0;
	for (int i=now;i<num;i++){
		sl[(i-now+1)/l]+=Right[i];
		sr[(num-i)/l]+=Left[i];
	}
	num=now+dd;
	for (int i=1;i<=dd;i++){
		Right[now+i-1]=sl[i];
		Left[num-i]=sr[i];
	}
	s=0;
	for (int i=now;i<num;i++){
		val[i]=v+1;
		ans-=(ll)Left[i]*Right[i];
		if (i-l+1>=now)s+=Left[i-l+1];
		ans-=s*Right[i];
	}
}
int main(){
	scanf("%d%d",&n,&l);
	while (n--){
		scanf("%d",&x);
		while (num>0){
			if (val[num-1]>=x)break;
			dec();
		}
		Left[num]=Right[num]=1;
		val[num]=x;
		num++;
	}
	while (num)dec();
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 2560
M, N, X, Y = map(int, input().split())
X_city = list(map(int, input().split()))
Y_city = list(map(int, input().split()))

X_city.append(X)
Y_city.append(Y)

if max(X_city) < min(Y_city) or min(X_city) > max(Y_city) :
  print("No War")
else :
  print("War")

Measured memory_bytes: 3060
### SNIPPET
  # array = [*1..q].map { |_| gets.split.map(&:to_i) }
  # n = gets.split.map(&:to_i)
  # [].all?(&:even?)
  # a = [*1..m].repeated_combination(n).to_a
  # 切り捨て: .floor(2).to_f ,切り上げ： .ceil(2).to_f,四捨五入: round(2)
  # 3.upto(6) do |i|, 6.downto(3) do |i|
  # 公約数125.gcd(100)、公倍数125.lcm(100)
  # PI = Math::PI
  # 高さh = a * Math.sin(w / 180.0 * Math::PI)
  # 底辺 = a * Math.cos(w / 180.0 * Math::PI)
def chmax(a, b) a > b ? a : b end
  # def chmin(a, b) a < b ? a : b end

# 3 5
# 1 20
# 2 30
# 3 40
n,w = gets.split.map(&:to_i)
wv = [*1..n].map { |_| gets.split.map(&:to_i) }
dp = [0] * (w+1)

# dp[i] :- 重さの合計がiの時の価値の最大値


0.upto(n-1) do |k|
  lw,lv = wv[k]
  w.downto(lw) do |i|
    dp[i] = chmax(dp[i], dp[i-lw] + lv)
  end
end

puts dp.max


# 2**n
# a b c
# 0 0 0
# 0 0 1
# 0 1 0
# 0 1 1

# dp[i] dp[i+1] + toru
#       dp[i+1] + toranai

#       iのこすう(n) * 

# O(wn) = 10**5 * 100

Measured memory_bytes: 2556
#include <iostream>
#include <algorithm>

using namespace std;

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

    sort(a, a + n, greater<int>());

    int midIndex = a[1];
    for(int i = 2; i < n; i++)
    {
        if(abs(a[i] - a[0]/2) < abs(midIndex - a[0]/2))
        {
            midIndex = a[i];
        }
    }

    cout << a[0] << ' ' << midIndex;

    return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main
{
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		
		for(; ;)
		{
			int n = scanner.nextInt();
			if(n == 0)
			{
				break;
			}
			
			class Data
			{
				int e;
				long sum;
				boolean is_view;
			}
			Data[] data = new Data[n];		
			
			for(int i=0; i<n; i++)
			{
				data[i] = new Data();
				data[i].e = scanner.nextInt();
				long p = scanner.nextLong();
				long q = scanner.nextLong();
				data[i].sum = p * q;
				data[i].is_view = true;
			}
			
			for(int i=0; i<n; i++)
			{
				if(data[i].is_view)
				{
					for(int j=i+1; j<n; j++)
					{
						if(data[i].e == data[j].e)
						{
							data[i].sum += data[j].sum;
							data[j].is_view = false;
						}
					}
				}
			}
			
			int count = 0;
			for(int i=0; i<n; i++)
			{
				if(data[i].is_view && data[i].sum>=1000000)
				{
					System.out.println(data[i].e);
					count ++;
				}
			}
			
			if(count == 0)
			{
				System.out.println("NA");
			}
		}
	}
}

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

int main()
{
  string s;
  cin>>s;
  int l=s.length(),p,c,flag=1;
  p=l/2;
  c=(l+3)/2;
  for(int i=0;i<l/2;i++)
  {
    if(s[i]!=s[l-i-1])
    {
		flag=0;
      	break;
    }
  }
  if(flag){
  for(int i=0;i<p/2;i++)
  {
    if(s[i]!=s[p-i-1])
    {
		flag=0;
      	break;
    }
  }}
  if(flag){
    int j=0;
  for(int i=c-1;i<l/2;i++)
  {
    if(s[i]!=s[l-j-1])
    {
		flag=0;
      	break;
    }j++;
  }}
  if(flag)cout<<"Yes";
  else cout<<"No";
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#define MINI -1
using namespace std;
int main() {
	int n,content;
	cin>>n>>content;
	vector<int>v(n),w(n),dp(content+1,0);
	dp[0]=0;
	for(int i=0;i<n;++i){
		cin>>v[i]>>w[i];
	}
	for(int i=0;i<n;++i){
		for(int j=content;j-w[i]>=0;--j){
			dp[j]=max(dp[j-w[i]]+v[i],dp[j]);
		}
	}
	cout<<dp[content]<<endl;
	return 0;
}


Measured memory_bytes: 3152
#include <bits/stdc++.h>
	#define hell                         1000000007 
	#define M                            1000000007
	#define Maxi                      10000000000000000
	#define lcm(a,b)                     (a*b)/__gcd(a,b)
	#define ll                           long long

	#define vll                          vector<ll>
	#define vi                           vector<long long>
	#define pll                          vector< pair<ll,ll> >
	#define pb                           push_back
	//#define mp                           make_pair
	#define all(v)                       v.begin(),v.end()
	#define lbnd                         lower_bound
	#define ubnd                         upper_bound
	#define bs                           binary_search
	#define F                            first
	#define S                            second
	#define rep(i,a,b)                   for(i=a;i<b;i++)
	#define parr(a,n)                    for(i=0;i<n;i++) cout<<a[i]<<" ";cout<<endl;
	#define pcont(a)                     for(auto i:a) cout<<i<<" ";cout<<endl;
	#define ret(x)                       return cout<<x,0;
	#define dbg(x)                       cout << #x << " is " << x << endl;
	//#define endl                           '\n'


	// Debug //

	#define trace(x)                 cerr << #x << ": " << x << endl;
	#define trace1(x)                cerr << #x << ": " << x << endl;
	#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
	#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
	#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
	#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
	#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;


	using namespace std;
	

	
	int main()
	{

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

		
		
		float a,b;
		cin>>a>>b;

		cout<<ceil((b-1.0)/(a-1.0))<<endl;

		return 0;
		}
	











Measured memory_bytes: 256
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();
    int point;
    boolean con1 = true;
    boolean con2 = true;
    
    for(int i = 0; i < s.length() && con1;i++) {
      con2 = true;
      for(int j = i; j < (s.length()+i) && con2;j++) {
      	if(j >= s.length()) point = j - s.length();
        else point = j;
        
        if(s.charAt(j - i) != t.charAt(point)) con2 = false;
      }
      if(con2) con1 = false;
    }
        
    if(!con1) System.out.println("Yes");
    else System.out.println("No");
  }
}


Measured memory_bytes: 35616
#include <iostream>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
using namespace std;

#define INF 1e18
#define int long long

signed main() {
    int n, k; cin >> n >> k;
    vector<pair<int, int>> v;
    for(int i = 0; i < n; i++) {
        pair<int, int> p; cin >> p.first >> p.second;
        v.push_back(p);
    }

    sort(v.begin(), v.end());

    int ans = 0;
    int cnt = 0;
    for(int i = 0; i < n && cnt < k; i++) {
        ans = v[i].first;
        cnt += v[i].second;
    }

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


Measured memory_bytes: 2420
import heapq
Heappop=heapq.heappop
Heappush=heapq.heappush
N,M=map(int,input().split())
L=[]
for _ in range(N):
    a,b=map(int,input().split())
    L.append([a,-b])
L.sort()
q=[0]*10**5
ans=0
d=1
memo=0
while d<=M:
    while memo<=N-1:
        a,b=L[memo]
        if d<a:
            break
        else:
            Heappush(q,b)
            memo+=1
    ans-=Heappop(q)
    d+=1
print(ans)

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

int main(int argc, char *argv[]){
  int l, m, n;
  while(std::cin >> l, l){
    int sum = 0, ans = 1e9;
    for (int i = 0; i < 12; i++) {
      std::cin >> m >> n;
      sum += m - n;
      if(sum >= l && ans == 1e9)ans = i + 1;
    }
    if(ans == 1e9) std::cout << "NA" << std::endl;
    else std::cout << ans << std::endl;
  }
  return 0;
}

Measured memory_bytes: 1160
import java.util.Scanner;

public class Main {
    private static int W, H, N;
    private static int x1 = 0, y1 = 0, x2, y2;
    private static int[] x, y, a;
    private static Scanner scanner = new Scanner(System.in);


    public static void main(String[] args){
        input();
        solve();
    }

    private static void solve() {
        for (int i = 0; i < N; i++) {
                update_xy(x[i], y[i], a[i]);
        }

        if (x2 > x1 && y2 > y1)
            System.out.println((x2-x1)*(y2-y1));
        else
            System.out.println(0);
    }

    private static void update_xy(int xi, int yi, int ai) {
        switch(ai){
            case 1:
                x1 = Math.max(x1, xi);
                break;
            case 2:
                x2 = Math.min(x2, xi);
                break;
            case 3:
                y1 = Math.max(y1, yi);
                break;
            case 4:
                y2 = Math.min(y2, yi);
                break;
        }
    }

    private static void input() {
        W = scanner.nextInt();
        H = scanner.nextInt();
        N = scanner.nextInt();

        x2 = W;
        y2 = H;

        x = new int[N];
        y = new int[N];
        a = new int[N];

        for (int i = 0; i < N; i++) {
            x[i] = scanner.nextInt();
            y[i] = scanner.nextInt();
            a[i] = scanner.nextInt();
        }
    }

    private static void test_input() {
        W = 5;
        H = 4;
        N = 2;

        x2 = W;
        y2 = H;

        x = new int[]{2, 3};
        y = new int[]{1, 3};
        a = new int[]{1, 4};

    }
}


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

using namespace std;

typedef long long ll;

const int INF = 1e9;

int main()
{
  int num = 1, val = -1;
  while (true) {
    fscanf(stdin, "%d", &val);
    if (val == 0) { break; }
    fprintf(stdout, "Case %d: %d\n", num, val);
    ++num;
  }
  return 0;
}

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


int s[130];
int dp[4000][4000];
bool v[4000][4000];
int how[4000];
int n,m;
int dfs(int x,int y)
{
    if(v[x][y])return dp[x][y];
    v[x][y]=1;
    int ty=0,u=-1;
    for(int i=0;i<m;i++)
        if((s[i]&x)==y)
        {
            int z=s[i]^y;
            how[z]++;
            if(z!=u)ty++,u=z;
        }
    for(int i=0;i<m;i++)
        if((s[i]&x)==y)
            how[s[i]^y]=0;
    if(ty==1)
        return dp[x][y]=0;
    else
    {
        int sum=1000000;
        for(int i=0;i<n;i++)
            if(((1<<i)&x)==0)
                sum=min(sum,1+max(dfs((1<<i)|x,y),dfs((1<<i)|x,(1<<i)|y)));
        return dp[x][y]=sum;
    }

}
int main()
{
    while(scanf("%d%d",&n,&m)&&n)
    {
        char f[130];
        for(int i=0;i<m;i++)
        {
            int z=0;
            scanf("%s",f);
            for(int j=0;j<n;j++)
                z|=f[j]-'0'<<j;
            s[i]=z;
        }
        int lim=1<<n;
        for(int i=0;i<lim;i++)
            for(int j=0;j<lim;j++)
                v[i][j]=0;
        printf("%d\n",dfs(0,0));
    }
    return 0;
}

Measured memory_bytes: 44188
#include <bits/stdc++.h>
#define DBG(x) cerr << #x << " = " << x << endl

typedef long long LL;
using namespace std;

const int N = 1000;
bool vis[N][N];
int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};

bool in(int x, int y, int n, int m) {
    return x >= 0 && x < n && y >= 0 && y < m;
}

int fuck(int n, int m) {
    memset(vis, false, sizeof(vis));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            vis[i][j] = !vis[i][j];
            for (int dir = 0; dir < 8; ++dir) {
                int x = i + dx[dir];
                int y = j + dy[dir];
                if (in(x, y, n, m))
                    vis[x][y] = !vis[x][y];
            }
        }
    }
    int ret = 0;
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < m; ++j)
            if (vis[i][j]) ++ret;
    return ret;
}

LL F(LL x, LL y) {
    if (x > y) swap(x, y);
    if (x == 2 || y == 2) return 0;
    if (x == 1 && y == 1) return 1;
    if (x == 1) return y - 2;
    return 1LL * (x - 2) * (y - 2);

}

int main(int argc, char **argv) {
    LL n, m;
    while(cin >> n >> m) {
        cout << F(n, m) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[6],cnt[5];
int main() {
	for(int i=0;i<6;i++){
		cin>>a[i];
		cnt[a[i]]++;
	}
	ll mi=3,ma=0;
	for(int i=1;i<=4;i++){
		ma=max(ma,cnt[i]);
		mi=min(mi,cnt[i]);
	}
	cout<<((ma==3||mi==0)?"NO":"YES")<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long mod = pow(10, 9) + 7;
const long long INF = 1LL << 60;
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;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, long long B) {return (A + (B - 1)) / B;}

int char2int(char c)
{
  if (c == '0') return 0; if (c == '1') return 1; if (c == '2') return 2;
  if (c == '3') return 3; if (c == '4') return 4; if (c == '5') return 5;
  if (c == '6') return 6; if (c == '7') return 7; if (c == '8') return 8;
  if (c == '9') return 9;
}

int main()
{
  string s;
  cin >> s;
  int N = s.size();
  vector<int> S(N);
  for (int i = 0; i < N; i++) S.at(i) = char2int(s.at(i));
  
  long long ans = 0;
  
  for (int i = 0; i < pow(2, N - 1); i++)
  {
    vector<int> V(N, 0);
    
    for (int j = 1, p = 1; j < N; j++)
    {
      V.at(j) = (i / p) % 2;
      p *= 2;
    }
    
    for (long long k = N - 1, q = 1; k >= 0; k--)
    {
      ans += S.at(k) * q;
      if (V.at(k) == 0) q *= 10;
      else q = 1;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast",3,"inline")
#include<bits/stdc++.h>
using namespace std;
#define fir first
#define sec second
#define m_p make_pair
#define y1 ygftgfgcdtfgxffgx
#define y2 yfdsesgvtyghftfvv
#define x1 xvyr6cf6fgcfgf676
#define x2 xcr6rfc5r66y6r6fr
#define up_bound upper_bound
#define low_bound lower_bound
#define next_per next_permutation
#define pb push_back
#define i_to_s to_string
typedef priority_queue<int> p_queue;
typedef priority_queue<int, vector<int>, greater<int> > min_p_queue;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int mon[20]={31,28,31,30,31,30,31,31,30,31,30,31};
ll gcd(ll x,ll y){return ((y==0)?x:gcd(y,x%y));}
string s,t;
ll ans;
void check(string _s){
	ll n=_s.size()/2,m=_s.size();
	string s1=_s.substr(0,n);
	string s2=_s.substr(n,n);
	if(s1==s2) ans=max(ans,m);
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>s;int n=(s.size()-1);
	for(int i=0;i<n;i++){
		t+=s[i];if(i&1)check(t);
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <math.h>
#include <sstream>

using namespace std;

int main()
{
  int A, B, C;
  cin >> A >> B >> C;
  if (min(A,B) <= C and C <= max(A,B)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  return 0;
}


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

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

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

  for (int i = 0; i < n; ++i) cout << s[i] << t[i];
  cout << endl;

  return 0;
}


Measured memory_bytes: 384
n,m = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(n)]
A.sort()
ans = 0
cnt = 0
for a in A:
    tmp = min(m-cnt,a[1])
    ans += tmp*a[0]
    cnt+=tmp
    if cnt >= m:
        break
print(ans)

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

int main(){
    int h,w;
    cin >> h >> w;
    vector<vector<char>> s(h, vector<char>(w));
    for(int i=0;i<h;i++)for(int j=0;j<w;j++) cin >> s[i][j];

    vector<vector<pair<int, int>>> vec(h, vector<pair<int, int>>(w, {0,0}));

    for(int i=0;i<h;i++){
        int count = 0;
        bool flag = false;
        for(int j=0;j<w;j++){
            if(s[i][j] == '.'){
                if(flag) count++;
                else{
                    flag = true;
                    count++;
                }
                if(j==w-1){
                    for(int k=j-count+1;k<=j;k++) vec[i][k].first = count;
                    flag = false;
                    count = 0;
                }
            }else{
                if(flag){
                    for(int k=j-count;k<j;k++) vec[i][k].first = count;
                    flag = false;
                }
                count = 0;
            }
        }
    }

    for(int j=0;j<w;j++){
        int count = 0;
        bool flag = false;
        for(int i=0;i<h;i++){
            if(s[i][j] == '.'){
                if(flag) count++;
                else{
                    flag = true;
                    count++;
                }
                if(i==h-1){
                    for(int k=i-count+1;k<=i;k++) vec[k][j].second = count;
                    flag = false;
                    count = 0;
                }
            }else{
                if(flag){
                    for(int k=i-count;k<i;k++) vec[k][j].second = count;
                    flag = false;
                }
                count = 0;
            }
            
        }
    }

    int ans = 0;
    for(int i=0;i<h;i++)for(int j=0;j<w;j++) ans = max(ans, vec[i][j].first + vec[i][j].second - 1);


    cout << ans << endl;
}

Measured memory_bytes: 35584
# -*- coding: utf-8 -*-
from scipy.misc import comb
import collections

N = int(input())
numbers = map(int, input().split())


def countSubZeroRange(numbers):
    Sums = [0]
    for number in numbers:
        Sums.append(Sums[-1] + number)
    zeroSumCounts = 0
    for key, value in collections.Counter(Sums).items():
        zeroSumCounts += comb(value, 2, 1)
    return zeroSumCounts


print(countSubZeroRange(numbers))


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

int main() {
  int H, W;
  cin >> H >> W;
  //1行目
  for (int i = 0; i < W + 2; i++) {
    cout << '#';
  }
  cout << endl;
  //2~H+1行目
  for (int i = 0; i < H; i++) {
    string a;
    cin >> a;
    cout << '#' << a << '#' << endl;
  }
  //H+2行目
  for (int i = 0; i < W + 2; i++) {
    cout << '#';
  }
  cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
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;}

int main(){
    int n;cin>>n;
    vector<int> a(n+1);
    rep(i,n){
        cin>>a[i+1];
    }
    deque<int> dq;
    bool isr = false;
    rep(i,n){
        int j = i+1;
        if(j%2==1){
            dq.push_back(a[j]);
        }else{
            dq.push_front(a[j]);
        }
    }
    if(n%2==1) reverse(dq.begin(), dq.end());
    rep(i,n){
        int t = dq.front(); dq.pop_front();
        cout<<t<<' ';
    }

}

Measured memory_bytes: 3840
#include<stdio.h>
#include<stdlib.h>
#define MAX 2000001
#define VMAX 10000
int main()
{
    unsigned short *A,*B;
    int C[VMAX+1];
    int n,i,j;
    scanf("%d",&n);
    A=malloc(sizeof(short)*n+1);
    B=malloc(sizeof(short)*n+1);
    for(i=0;i<=VMAX;i++)
        C[i]=0;
    for(i=0;i<n;i++)
    {
        scanf("%hu",&A[i+1]);
        C[A[i+1]]++;
    }
    for(i=1;i<=VMAX;i++)
        C[i]=C[i]+C[i-1];
    for(j=1;j<=n;j++)
    {
        B[C[A[j]]]=A[j];
        C[A[j]]--;
    }
    for(i=1;i<=n;i++)
    {
        if(i>1) printf(" ");
        printf("%d",B[i]);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 9604
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1<<30
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define RREP(i,a,b) for(ll i=(a); i>=(b); i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> pl;
typedef vector<pair<ll, ll>> vpl;



int main(){
    ll a; cin >> a;
    cout << (3 * a * a) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
const int INF = 2147483647;//int max
const int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;


int main() {
    int n;
    cin >> n;
    vector<string> s(n);
    rep(i,n)cin >> s[i];
    int m;
    cin >> m;
    vector<string> t(m);
    rep(i,m)cin >> t[i];
    int ans = 0;
    rep(i,n){
        int score = 0;
        for(string str :s)if(s[i] == str)score++;
        for(string str :t)if(s[i] == str)score--;
        ans = max(ans,score);
    }
    cout << ans;
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int[] a = new int[n];


        for(int i = 0; i < n; i++){
            a[i] = sc.nextInt();
            //a[i] = i;
        }

        if(n % 2 == 0){
            for(int i = n - 1; i >= 0; i -= 2){
                System.out.println(a[i]);
            }
            for(int i = 0; i < n; i += 2){
                System.out.println(a[i]);
            }
        }else{
            for(int i = n - 1; i >= 0; i -= 2){
                System.out.println(a[i]);
            }
            for(int i = 1; i < n; i += 2){
                System.out.println(a[i]);
            }
        }


    }
}


Measured memory_bytes: 92124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define si(x) int(x.size())
const int mod1=1000000007,mod2=1000000009,MAX=300005,INF=1<<30;

struct Rollinghash{
    string S;
    int n;
    int base1;
    int base2;
    vector<ll> h1,h2,ru1,ru2;
    
    void make(string &T,int ba1,int ba2){
        S=T;
        n=S.size();
        h1.assign(n+1,0);
        h2.assign(n+1,0);
        ru1.assign(n+1,0);
        ru2.assign(n+1,0);
        base1=ba1;
        base2=ba2;
        
        ru1[0]=1;
        ru2[0]=1;
        
        for(int i=1;i<=n;i++){
            h1[i]=h1[i-1]*base1+ll(S[i-1]-'A');
            h1[i]%=mod1;
            
            h2[i]=h2[i-1]*base2+ll(S[i-1]-'A');
            h2[i]%=mod2;
            
            ru1[i]=ru1[i-1]*base1%mod1;
            ru2[i]=ru2[i-1]*base2%mod2;
        }
    }
    
    pair<ll,ll> ha(int l,int r){
        pair<ll,ll> res;
        res.fi=(h1[r]-h1[l]*ru1[r-l]%mod1+mod1)%mod1;
        res.se=(h2[r]-h2[l]*ru2[r-l]%mod2+mod2)%mod2;
        
        return res;
    }//開区間
};

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    mt19937_64 rng(58);
    
    string S,T;cin>>S>>T;
    Rollinghash A,B;
    ll base1=rng(),base2=rng();
    A.make(S,base1,base2);
    B.make(T,base1,base2);
    
    for(int i=0;i+si(T)<=si(S);i++){
        pair<ll,ll> ha1=A.ha(i,i+si(T)),ha2=B.ha(0,si(T));
        if(ha1==ha2) cout<<i<<endl;
    }
}




Measured memory_bytes: 36316
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define P pair<int,int>
#define PI 3.141592653589793
const int INF = 1001001001;
const ll MX = 1e18;
const int mod = 1000000007;

vector<int> ki[200005];
vector<int> ans;

void dfs(int v, int p) {//vは今見ているnode,pはvの親
	for (int u : ki[v]) {
		if (u == p) continue;
		ans[u] += ans[v];
		dfs(u, v);
	}
}
int main() {
	int n;
	cin >> n;
	int q;
	cin >> q;
	rep(ni, n - 1) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		ki[a].push_back(b);
		ki[b].push_back(a);
	}
	ans.resize(n);
	rep(i, q) {
		int p, x;
		cin >> p >> x;
		p--;
		ans[p] += x;
	}
	dfs(0, -1);
	rep(i, n) cout << ans[i] << " ";
}


Measured memory_bytes: 24240
#include <stdio.h>
int main(void){
    int n,x,g=0,c=1,l[100];
    
    scanf("%d%d",&n,&x);
    for(int i=0;i<n;i++)scanf("%d",&l[i]);
    for(int i=0;i<n;i++){
        g+=l[i];
        if(g>x)break;
        c++;
    }
    printf("%d",c);
    
  return 0;
}


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

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  vector<int> x(n);
  rep(i, n) cin >> x[i];

  ll ans = 0;
  for (int i = 1; i < n; ++i) {
    ans += min((ll)a*(x[i]-x[i-1]), (ll)b);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3716
#include<bits/stdc++.h>
using namespace std;
int main()
{
      int a,b,c,d=0;
      int train,bus=0;
      cin>>a>>b>>c>>d;
      if(a<b)
      {
      	 train=a;
	  }
	  else
	  {
	  	train=b;
	  }
	  if(c<d)
	  {
	  	bus=c;
	  }
	  else
	  {
	  	bus=d;
	  }
	  cout<<train+bus;
	  return 0; 
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
static const long double pi = acos(-1.0);
using namespace std;

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

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
#define ld long double
#define pii pair<int,int>
#define fi first
#define se second
#define mex 100005
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
//vector<int> adj[mex];
//a+b=a^b+2*(a&b)
ll dp[mex][103];
int n,k;
int a[103];

   
int main(){
	fast
	
	cin>>n>>k;
	
	for(int i=0;i<n;i++)
	 cin>>a[i];
	 
	
	for(int i=0;i<n;i++){
		 for(int j=0;j<=k;j++){
			 if(i==0){
				 if(j<=a[i])
			      dp[j][i]=1;
			     else
			      dp[j][i]=0;
			     
			     //if(j!=0) 
			      //dp[j][i]=(dp[j][i]+dp[j-1][i])%mod;
			 } 
			 else{
				 if(j<=a[i]){
				  dp[j][i]=dp[j][i-1]%mod;
				  if(j!=0)
				   dp[j][i]=(dp[j][i]+dp[j-1][i])%mod;
			     }
			     else{
					 dp[j][i]=(dp[j][i-1]-dp[j-a[i]-1][i-1]+mod)%mod;
					 if(j!=0)
						dp[j][i]=(dp[j][i]+dp[j-1][i])%mod;
				}
			 }
		 }
	}
	
	cout<<dp[k][n-1]%mod;			 
	//cout<<recur(k,0);
	 
	
}


Measured memory_bytes: 80768
x=list(map(int, input().split()))
y=list(map(int, input().split()))
z=list(map(int, input().split()))
if x[1]-x[0] != y[1]-y[0] or y[1]-y[0] != z[1]-z[0] or x[2]-x[0] != y[2]-y[0] or y[0]-x[0] !=y[1]-x[1] or z[1]-x[1] !=z[2]-x[2] or z[0]-x[0] !=z[1]-x[1] or z[1]-x[1] !=z[2]-x[2] :
    print('No')
else:
    print('Yes')

Measured memory_bytes: 9224