akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;

public class Main {

    static int mod = (int) 1e9 + 7;

    public static void main(String[] args) throws Exception {
        Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));

        String s = in.next();
        int d = in.nextInt();
        int length = s.length();

        int[][] dp = new int[2][d]; // 0 - is smaller, 1 is not yet
        dp[1][0] = 1;

        for (int i = 0; i < length; i++) {
            int[][] latestDP = new int[2][d];
            for (int j = 0; j < 10; j++) {
                for (int k = 0; k < d; k++) {
                    int prevSum = Math.floorMod(k - j, d);
                    latestDP[0][k] = add_self(latestDP[0][k], dp[0][prevSum]);
                }
            }
            int digit = Character.getNumericValue(s.charAt(i));
            for (int j = 0; j < digit; j++) {
                for (int k = 0; k < d; k++) {
                    latestDP[0][k] = add_self(latestDP[0][k], dp[1][Math.floorMod(k - j, d)]);
                }
            }
            for (int k = 0; k < d; k++) {
                latestDP[1][k] = add_self(latestDP[1][k], dp[1][Math.floorMod(k - digit, d)]);
            }
            dp = latestDP;
        }

        out.println(sub_self(add_self(dp[0][0], dp[1][0]), 1));
        out.close();
    }

    static int add_self(long a, long b) {
        a += b;
        if (a >= mod) a -= mod;
        return (int) a;
    }

    static int sub_self(long a, long b) {
        a -= b;
        if (a < 0) a += mod;
        return (int) a;
    }
}

Measured memory_bytes: 47596
#include<iostream>
using namespace std;
int main()
{
  int k,a,b;
  cin>>k>>a>>b;
  int flag=0;
  for(int i=a;i<=b;i++)
  {
    if(i%k==0)
    {
      flag=1;
      break;
    }
  }
  if(flag==1)
  {
    cout<<"OK"<<endl;
  }
    else
    {
      cout<<"NG"<<endl;
    }
  return 0;
  }


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

int n;
int a[201];

int main() {
	
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int count = 0;
	while (1) {
		bool odd = false;
		for(int i = 0; i < n; i++) {
			if(a[i] % 2 != 0) {
				odd = true;
			}
		}
		if (odd) break;
		for (int i = 0; i < n; i++) {
			a[i] = a[i] / 2;
			
		}
		count++;
	}
	cout << count << endl;
	return 0;
	
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#define N 753
using namespace std;

int main() {
    char S[20];
    int a, b, c;
    cin >> S;

    int l = strlen(S);
    int d;
    int mind = 1000;
    for (int i = 0; i < l - 2; i++) {
        a = (S[i] - '0') * 100;
        b = (S[i + 1] - '0') * 10;
        c = S[i + 2] - '0';
        d = (a + b + c - N) < 0 ? -(a + b + c - N) : (a + b + c - N);
        if (d < mind) mind = d;
    }

    cout << mind << endl;
    return 0;
}

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

int search(int A[],int n,int key){
    int i = 0;
    A[n]= key;
    while(A[i] !=key) i++;
    return i!=n;
    
}

int main(){
    int n,q;
    int cou =0;
    cin >> n;
    int S[n];
    for(int i =0; i<n; i++){
         cin >> S[i];
    }
    cin >> q;
    int t;
    for (int i =0; i<q; i++){
        cin >> t;
        if (search(S,n,t)) cou++;
        }
    cout << cou << endl;
    return 0;
}


Measured memory_bytes: 3104
from collections import deque
import sys
input = sys.stdin.readline


n, m = map(int, input().split())
edges = [[] for _ in range(n)]

for _ in range(m):
    a, b = map(int, input().split())
    edges[a-1].append(b-1)
    edges[b-1].append(a-1)

todo = deque([[0, 0]])
seen = [-1] * n
seen[0] = 0
while todo:
    node, parent = todo.popleft()

    for to in edges[node]:
        if seen[to] != -1:
            continue

        todo.append([to, node])
        seen[to] = node

print('Yes')
for parent in seen[1:]:
    print(parent+1)


Measured memory_bytes: 39628
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;
 
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;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;

 
#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 oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
  
 

ll sum(ll n) {
ll m=0;
  while(n){
    m+=n%10;
    n/=10;
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
 
#define comuse Comuse()
 
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
 
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}




 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n; 
    ci(n)
  vll A(n);
  vll B(n);
  vll C(n);
  FOR(i,0,n){
    ci(A[i])
  }
  SORT(A);
  FOR(i,0,n){
    ci(B[i])
  }
  SORT(B);
  FOR(i,0,n){
    ci(C[i])
  }
  SORT(C);

  vll D(n);//各成分が何個超えているか
  ll nowl=0;
  ll nowr=0;
  while(true){
    if(A[nowl]<B[nowr]){
      nowl++;
    }
    else{
      D[nowr]=nowl;
      nowr++;
    }

    if(nowl==n){
      FOR(i,nowr,n){
        D[i]=n;
      }
      break;
    }
    if(nowr==n){
      break;
    }
  }

  nowl=0;
  nowr=0;
  vll E(n);
  while(true){
    if(B[nowl]<C[nowr]){
      nowl++;
    }
    else{
      E[nowr]=nowl;
      nowr++;
    }

    if(nowl==n){
      FOR(i,nowr,n){
        E[i]=n;
      }
      break;
    }
    if(nowr==n){
      break;
    }
  }

  ll ans=0;
  /*
  FOR(i,0,n){
    cout<<D[i]<<" "<<E[i]<<endl;
  }
  */
 FOR(i,1,n){
   D[i]+=D[i-1];
 }
  FOR(i,0,n){
    ll a=E[i];
    if(a!=0) ans+=D[a-1];
  }
  co(ans)
}

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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define rep(i, n) for(int i = 0; i < n; i++)

typedef long long ll;
typedef pair<int, int> the;

const int INF = 1 << 29;
const ll LINF = 1LL << 60;

int main()
{
	int n, k;
	cin >> n >> k;
	vector<int> h(n + 1, 0);
	rep(i, n)  cin >> h[i + 1];
	
	vector<ll> dp(n + 1, LINF);  //初期化
	dp[1] = 0;  //初期条件
	//ループ
	for (int i = 2; i <= n; i++) {
		ll t = LINF;
		for (int j = 1; j <= k; j++) {
			if (i - j >= 1) {
				t = min(t, dp[i - j] + abs(h[i] - h[i - j]));
			}
		}
		dp[i] = t;
	}
	cout << dp[n] << endl;
}

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

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

Measured memory_bytes: 3080
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;

int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	int cnt = 0;
	for (int i = 1; i + 1 < n; ++i) {
		if (s[i - 1] == 'A' && s[i] == 'B' && s[i + 1] == 'C') {
			cnt++;
		}
	}
	cout << cnt;
}


















Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using static System.Console;


namespace atcorder2
{
    class Program
    {
        public static long Read()
        {

            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {

            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }

       
        public static long C(long n,long k)
        {
            long bunsi = 1;
            
            for (long i = 1; i <= k; i++)
            {
                bunsi *= n--;
                bunsi /= i;
            }
            
            return bunsi ;
        }

        



        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);


            var np = Reads();
            var n = np[0];
            var p = np[1];
            var a = Reads();
            var odd = 0;
            var even = 0;
            for (int i = 0; i < n; i++)
            {
                if (a[i] % 2 == 0) even++;
                else odd++;
            }
            long oddo = 0;
            long odde = 0;
            
            for (long i = 0; i <=odd; i++)
            {
                if (i % 2 == 0) odde += C(odd, i);
                else oddo += C(odd, i);
            
            }
            WriteLine(p == 1 ? (long)Math.Pow(2, even) * oddo : (long)Math.Pow(2, even) * odde);



            Console.Out.Flush();
        }
    }
}




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

using ll = long long ;

using namespace std;

struct EDC{
    ll A, B;
};

int main() {
    ll N, M;
    EDC drink[100000];
    cin >> N >> M;
    for(int i = 0; i < N; ++i) {
        cin >> drink[i].A >> drink[i].B;
    }
    sort(drink, drink+N, [&](const EDC &a, const EDC &b){ return (a.A < b.A);});
    int index = 0;
    ll money = 0;
    while(M){
        money += drink[index].A * min(M, drink[index].B);
        M -= min(M, drink[index].B);
        index++;
    }
    cout << money << endl;
    return 0;
}	


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 20000;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    ll n = s.length(),stock = 0,i = 0,c = 0;
    s += 'D';
    while(i < n){
        if (s[i] == 'A'){
            stock++;
            i++;
        }
        else if (s[i] == 'B' && s[i+1] == 'C'){
            c += stock;
            i += 2;
        }
        else{
            stock = 0;
            i++;
        }
    }
    PRINT(c);
}

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

int main() {
  int r, g, b;
  cin >> r >> g >> b;
  int n = 100 * r + 10 * g + b;

  if(n % 2 == 0) {
    n /= 2;
    if(n % 2 == 0) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  } else {
    cout << "NO" << endl;
  }
}


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

#define pb push_back
using namespace std;
 
int main()
{
 
 	#ifndef ONLINE_JUDGE
    freopen("Input.txt", "r" , stdin);
    freopen("Output.txt", "w" , stdout);
    #endif

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

 	
 	long n;
    cin>>n;
    string s;
    cin>>s;

    long r=0,g=0,b=0;

    for(long i=0;i<n;i++)
    {
        if(s[i]=='R')
            r++;
        else if(s[i]=='G')
            g++;
        else
            b++;
    }

    long long totalnumber=r*g*b;
   // cout<<totalnumber<<endl;

    for(long i=1;i<=n/2;i++)
    {
        for(int j=0;j+2*i<n;j++)
        {
            if(s[j]!=s[j+i] and s[j+i]!=s[j+2*i] and s[j]!=s[j+2*i]){
                totalnumber--;
                //cout<<j<<endl;
            }
        }
    }

    cout<<totalnumber;

	return 0;
}

Measured memory_bytes: 3660
S = int(input())

kMod = 10**9+7

memo = {}

def count(n):
    if n < 3:
        return 0
    if n in memo:
        return memo[n]
    ans = 1
    for i in range(3, n+1):
        ans += count(n-i)
        ans %= kMod
    memo[n] = ans
    return ans

print(count(S))

Measured memory_bytes: 72312
def main():
    n, m = map(int, input().split())
    p = 2**n
    inf = 10**20
    dp = [inf]*p
    dp[0] = 0
    for _ in range(m):
        a, _ = map(int, input().split())
        c = sum([2**(int(i)-1) for i in input().split()])
        for s in range(p):
                t = s|c
                if dp[t] > dp[s] + a:
                    dp[t] = dp[s] + a
    ans = dp[-1]
    if ans == inf:
        ans = -1
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3188
#include <cstdio>

typedef long long ll;

ll A, B, C, D;

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

int main() {
	int T; scanf("%d", &T);
	while(T --) {
		scanf("%lld%lld%lld%lld", &A, &B, &C, &D);
		if(D < B) puts("No");
		else {
			if(A < B) puts("No");
			else {
				if(A % B > C) puts("No");
				else {
					if(C + 1 >= B) puts("Yes");
					else {
						ll d = D % B, st = A % B;
						d = gcd(d, B); 
						st += (C - st) / d * d;
						if(st + d < B) puts("No");	
						else puts("Yes");
					}
				}
			}
		}
	}
	return 0;
}



Measured memory_bytes: 128
N=int(input())

maxn=55555

prime=[1]*(maxn+1)
prime[0]=0
prime[1]=0
plst=[]
for i in range(2,maxn+1):
    if prime[i]==1:
        if i%5==1:
            plst.append(str(i))
        for j in range(2,maxn//i+1):
            prime[i*j]=0

print(' '.join(plst[:N]))

Measured memory_bytes: 40304
#include <stdio.h>

int main(int argc, const char * argv[]) {

        int w,h,x,y,r;
        
        scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);
        if ((0 <= x - r ) && (x+r <= w) && (0 <= y - r) && (y+r <= h)) {
            printf("Yes\n");
        } else printf("No\n");
        
    
    
    return 0;
}

Measured memory_bytes: 584
package main
import (
    "bufio"
    "fmt"
    "os"
    "strconv"
)

var i int = 0       // current index
var tail int = 0    // ahead index

func main() {
    sc := bufio.NewScanner(os.Stdin)
    sc.Split(bufio.ScanWords)

    // number of data
    var n int
    if sc.Scan() { n, _ = strconv.Atoi(sc.Text()) }

    // prepare the array
    var array []int = make([]int, n, n)

    // run
    var c string    // command
    var x int       // number
    for ; sc.Scan();  {
        c = sc.Text()

        switch c {
          // 各演算子を受け取ったらスタックの値を用いて演算を実行
        case "insert":
            if sc.Scan() { x, _ = strconv.Atoi(sc.Text()) }
            array = insert(array, x)
        case "delete":
            if sc.Scan() { x, _ = strconv.Atoi(sc.Text()) }
            array = delete(array, x)
        case "deleteFirst":
            deleteFirst(array)
        case "deleteLast":
            deleteLast(array)
        }
    }
    for a := i-1; a >= tail+1; a-- {
        if array[a] != -1 {
            fmt.Printf("%d ", array[a])
        }
    }
    fmt.Printf("%d\n", array[tail])
}

func insert(array []int, x int) []int{
    array[i] = x
    i++
    return array
}

func delete(array []int, x int) []int{
    for k := i-1; k >= tail; k--{
        if array[k] == x {
            array[k] = -1
            if k == tail { tail++ }
            break
        }
    }
    return array
}

func deleteFirst(array []int) {
    i--
    if array[i] == -1 { deleteFirst(array) }
}

func deleteLast(array []int) {
    tail++
    if array[tail] == -1 { deleteLast(array) }
}




Measured memory_bytes: 27380
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
namespace Capp
{
    class Program
    {
        public enum En
        {
            a
            ,b
            ,c
            ,d
            ,e
            ,f
        }

        
        static void Main(string[] args)
        {
            var c = new Solve();
            c.S();

        }
    }

    public class Solve
    {
        List<int>[] es = new List<int>[10];
        int n;
        int m;
        int res = 0;
        int t = 0;
        void rec(int x)
        {
            if (t == (1 << n) - 1)
            {
                res++;
                return;
            }
            foreach(var v in es[x])
            {
                if ((t & (1 << v)) > 0)
                    continue;
                t |= (1 << v);

                rec(v);
                t ^= (1 << v);
            }
        }
        public void S()
        {
            var nm = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            n = nm[0];
            m = nm[1];
            for (int i = 0; i < 10; i++)
            {
                es[i] = new List<int>();
            }
            for (int i = 0; i < m; i++)
            {
                var s = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
                var a = s[0] - 1;
                var b = s[1] - 1;
                es[a].Add(b);
                es[b].Add(a);
            }
            t = 1;
            rec(0);
            Console.WriteLine(res);
        }
    }

    public class Test<T> : ITest<T>
    {
        public string S { get; set; }
    }

    public interface ITest<out T>
    {
        string S { get; set; }
    }

    struct c
    {
        public string s { get; set; }
        private dynamic _d;
        public dynamic d { get { return _d; }}
        public void Setd(dynamic d)
        {
            _d = d;
        }
    }
    class AsTest
    {
        internal async Task<int> AsyncMethod(int x)
        {
            var t1 = Task.Run(() =>
            {
                Thread.Sleep(10000);
                return 10 * x;
            });
            var res = await t1;
            Console.WriteLine($"asyncmethod {res}");


            return res;
        }

    }
}


Measured memory_bytes: 13396
#include<stdio.h>
#include<math.h>
int main()
{
    double i,n,p=0.0;
    while(~scanf("%lf",&n))
    {
        for(i=0; i<8; i++)
        {
            p=pow(2.0,i);
            if(p>n)
            {
                printf("%.lf\n",p/2);
                break;
            }
            else if(p==n)
            {
                printf("%.lf\n",p);
                break;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
int main(void){
	int n,i,j,c;
	long long int a[10000],b=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%lld",&a[i]);
		b+=a[i];
	}
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			if(a[i]<a[j]){
				c=a[i];
				a[i]=a[j];
				a[j]=c;
			}
		}
	}
	printf("%lld %lld %lld\n",a[0],a[n-1],b);
	return 0;
}

Measured memory_bytes: 676
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main() {
  int a;
  cin >> a;
  if(a >= 30){
    cout << "Yes";
  }
  else{
    cout << "No";
  }
  
  return 0;
}

Measured memory_bytes: 3636
// failed to generate code

#include <bits/stdc++.h>
using namespace std;

#ifdef ENABLE_DEBUG
#define DEBUG(a) cerr<<#a<<"="<<endl
#define DEBUG_ARRAY(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define DEBUG(a) 
#define DEBUG_ARRAY(a,n) 
#endif
#define P(a,b) make_pair(a,b)
#define FOR(i, a, b) for(int i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(int i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define INF (1L<<55)

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;

long N;
long A[5000];
vector<long> m[5000];
long dp1[5000],nd[5000],dp2[5000][5000],curdp[5000];

void dfs(long cur=0,long prev=-1){
    nd[cur]=1;
    dp2[cur][0]=A[cur];
    for(size_t i = 0; i < m[cur].size(); i++)
    {
        long to=m[cur][i];
        if(to!=prev){
            dfs(to,cur);
            if(A[cur]>0){
                long pl=INF;
                if(A[to]>0){
                    pl=min(pl,dp1[to]);
                }
                for(long j = 0; j < nd[to]; j++)
                {
                    if(dp2[to][j]<0){
                        pl=min(pl,j+1);
                    }
                }
                dp1[cur]+=pl;
            }
            for(long j = 0; j < nd[cur]+nd[to]; j++)
            {
                curdp[j]=INF;
            }
            for(long j = 0; j < nd[cur]; j++)
            {
                for(long k = 0; k < nd[to]; k++)
                {
                    curdp[j+k]=min(curdp[j+k],dp2[cur][j]+dp2[to][k]);
                    if(dp2[to][k]<0)curdp[j+k+1]=min(curdp[j+k+1],dp2[cur][j]);
                }
                if(A[to]>0){
                    curdp[j+dp1[to]+1]=min(curdp[j+dp1[to]+1],dp2[cur][j]);
                }
            }
            nd[cur]+=nd[to];
            for(long j=0;j<nd[cur];j++){
                dp2[cur][j]=curdp[j];
            }
        }
    }
}

int main(){	
    ios::sync_with_stdio(false);
    cin>>N;
    REP(N){
        cin>>A[i];
    }
    REP(N-1){
        long tmp1,tmp2;
        cin>>tmp1>>tmp2;
        tmp1--;tmp2--;
        m[tmp1].push_back(tmp2);
        m[tmp2].push_back(tmp1);
    }
    dfs();
    long ret=5005;
    if(A[0]>0){
        ret=dp1[0];
    }
    for(long i = 0; i < 5000; i++)
    {
        if(dp2[0][i]<0){
            ret=min(ret,i);
        }
    }
    cout<<ret<<endl;
    return 0;
}


Measured memory_bytes: 195328
a=[1,3,5,7,8,10,12]
b=[4,6,9,11]
c=[2]

d=[int(i) for i in input().split()]

def judge(d):
    if (d[0] in a) and (d[1] in a):
        print("Yes")
    elif (d[0] in b) and (d[1] in b):
        print("Yes")
    elif (d[0] in b) and (d[1] in b):
        print("Yes")
    else:
        print("No")

judge(d)

Measured memory_bytes: 3064
#include<stdio.h>
int main(void){
    int a,b,c,i,x;
        scanf("%d%d%d",&a,&b,&c);
        for( x = a;x <= b;x++){
        if(c%x == 0)
            i++;
        }
        printf("%d\n",i);

return 0;
}

Measured memory_bytes: 596
#include<stdio.h>
int main()
{
    int a, b, s;
    scanf("%d %d",&a,&b);
    if(a>0&&a<10 && b>0&&b<10){
        s = a*b;
    }
    else{
        s = -1;
    }
    printf("%d",s);
    return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<long long> a(n);
    long long y = 0;
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
        y += a.at(i);
    }
    
    long long ans = LONG_LONG_MAX;
    long long x = 0;
    for (int i = 0; i < n - 1; i++) {
        x += a.at(i);
        y -= a.at(i);
        ans = min(ans, abs(x - y));
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <set>
#include <utility>
#include <cstdio>
#include <cstring>
#include <numeric>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)

int main()
{
	int N;
	cin >> N;
	map<ll, int> M;
	for (int i = 0; i < N; i++)
	{
		ll A;
		cin >> A;
		M[A]++;
	}
	vector<ll> A;
	for (auto m : M)
	{
		if (m.second >= 4)
		{
			A.push_back(m.first);
			A.push_back(m.first);
		}
		else if (m.second >= 2)
		{
			A.push_back(m.first);
		}
	}
	sort(A.begin(), A.end(), greater<ll>());
	if (A.size() < 2)
	{
		cout << 0 << endl;
	}
	else
	{
		cout << A[0] * A[1] << endl;
	}
	return 0;
}

Measured memory_bytes: 6528
#include <cstdio> 
#include <ctime> 
#include <cmath>   
#include <cstring>
#include <cstdlib>               //a = clock(); b = clock(); time = a - b;
#include <iostream>                                      
#include <map>                   //map<Type, Type>::iterator it;
#include <queue>                 //priority_queue< Type >Name
#include <stack>                 
#include <vector>                //.push_back()
#include <string>  
#include <algorithm>  
#define e 2.718281828459045      //底数
#define pi 3.141592653589793239  //high precision Π
#define swap(a, b) {int temp = a; a = b; b =temp;}
using namespace std;
typedef long long ll;            //>10^18
typedef long double ld;          //3.3621e-4932 ~ 1.18937e4932
typedef unsigned long long ull;  //>10^20
const int MOD = 1e9 + 7;
const int MAXN = 1e5 + 5;
const int INF = 0x3f3f3f3f;      
int main(int argc, char *argv[]){
	//ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);//使用后无法用scanf, printf
	char s1[MAXN], s2[MAXN]; 
	scanf("%s\n",s1);
	scanf("%s",s2);
	int cnt = 0, mn = 1005;
	for(int i = 0; i <= strlen(s1) - strlen(s2); i++){
		cnt = 0;
		for(int k = i; k < strlen(s2) + i; k++)
			if(s1[k] != s2[k - i]) cnt++;				
		mn = min(cnt, mn);
	}
	cout << mn;
	return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007

using ll = long long int;
using P = pair<int,int>;

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

const ll INF=(ll)1e19;
//const int INF=(1<<30);

int f(int n){
  if(n%2==0){
    return n/2;
  }else{
    return 3*n+1;
  }
}

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

  vector<int> a;
  a.emplace_back(0);
  a.emplace_back(s);

  set<int> st;

  st.insert(s);

  for(int i=2; ;i++){
    int tmp = f(a[i-1]);
    if(st.find(tmp) != st.end()){
      cout << i << endl;
      return 0;
    }
    a.emplace_back(tmp);
    st.insert(tmp);
  }

}



Measured memory_bytes: 256
import sys
import itertools

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, M = map(int, readline().split())
AB = [tuple(map(int, readline().split())) for _ in range(N)]

AB.sort()

ans = 0
for yen, cnt in AB:
    if M == 0:
        break
    ans += yen * min(cnt, M)
    M -= min(cnt, M)
print(ans)


Measured memory_bytes: 17068
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <climits>

constexpr int SINT_MAX = std::numeric_limits<int>::max();
constexpr int SINT_MIN = std::numeric_limits<int>::min();

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

template<class T>
T choose(bool b, T t, T f)
{
    if (b) return t;
    else return f;    
}

const char *YesNo(bool b)
{
    return choose(b, "Yes", "No");
}

const char *YESNO(bool b)
{
    return choose(b, "YES", "NO");
}

template<class NumT>
NumT diffabs(NumT l, NumT r)
{
    if (l < r) return r-l;
    else return l-r;    
}

struct myinout_t {} io;

template<class T>
myinout_t &operator >>(myinout_t &my, T &i)
{
    cin >> i;
    return my;
}

myinout_t &operator >>(myinout_t &my, int &i)
{
    int r = scanf("%d", &i);
    if (r != 1) exit(EXIT_FAILURE);
    return my;
}

myinout_t &operator >>(myinout_t &my, ll &i)
{
    int r = scanf("%lld", &i);
    if (r != 1) exit(EXIT_FAILURE);
    return my;
}

template<class T>
myinout_t &operator <<(myinout_t &my, const T &i)
{
    cout << i;
    return my;
}

myinout_t &operator <<(myinout_t &my, int i)
{
    printf("%d", i);
    return my;
}

myinout_t &operator <<(myinout_t &my, ll i)
{
    printf("%lld", i);
    return my;
}

myinout_t &operator <<(myinout_t &my, double i)
{
    printf("%.20f", i);
    return my;
}

constexpr char BR = '\n';


///////////////////////////////////////////////////

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

    int sum = 0;
    for (char c : S)
        sum += c - '0';
    
    bool ans = (sum % 9 == 0);
    io << YesNo(ans) << BR;
}

Measured memory_bytes: 3748
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define name(x) #x
using namespace std;


const int INF = INT_MAX;
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}

const int MAX_SIZE = 405;
ll memo[MAX_SIZE][MAX_SIZE];
ll cumSum[MAX_SIZE];
bool visited[MAX_SIZE][MAX_SIZE];
int N;
vector<ll> a;

ll rec(int l, int r){
    
    //基底
    if (l >= r) return 0;
    
    
    //メモ化処理
    if(visited[l][r]){
        return memo[l][r];
    }
    visited[l][r] = true;
    
    ll& ret = memo[l][r];
    ret = 1LL<<50;
    
    for(auto k = l; k<r ;k++){
        ret = min(ret, rec(l,k) + rec(k+1,r) + cumSum[r]-cumSum[l-1]);
        
    }
    
    
    return ret;
}


int main() {

    cin >> N;
    a.resize(N+1);
    for(auto i = 1; i<=N; i++){
        cin >> a[i];
        cumSum[i] = cumSum[i-1] + a[i];
    }
    
    cout << rec(1,N) << endl;
    
    return 0;
}




Measured memory_bytes: 1664
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>
#include <cstdint>
#include <tuple>
#include <numeric>
#define M_PI       3.14159265358979323846

using namespace std;

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FILL(a, x) memset(a, x, sizeof(a))

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)

int h[100005];
int dp[100005];

int main() {
	int n;
	scanf("%d", &n); 
	memset(dp, 0x7f, sizeof(dp));
	dp[0] = 0;
	REP(i, n)scanf("%d", &h[i]);
	REP(i, n) {
		FOR(j, i + 1, min(n, i + 3)) {
			dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
		}
	}
	printf("%d\n", dp[n - 1]);
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sca = new Scanner(System.in);
		int n = sca.nextInt();
		int[] ai = new int[n];
		int[] ans = new int[n];
		for(int i = 1; i < n; i++) {
			ai[i] = sca.nextInt();
			ans[ai[i]-1]++;
		}

		for(int i = 0; i < n; i++) {
			System.out.println(ans[i]);
		}

		// 後始末
		sca.close();
	}
}

Measured memory_bytes: 63208
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <map>

#define rep(i, c) for(int i = 0; i < (int)c; i++)

using namespace std;

int N, A[3][3], b[10];
bool appear[3][3];

typedef long long ll;

int main() {
	for(int i = 0; i < 3; i++) {
		for(int j = 0; j < 3; j++) cin >> A[i][j];
	}
	cin >> N;
	for(int i = 0; i < N; i++) cin >> b[i];
	for(int i = 0; i < N; i++) {
		for(int j = 0; j < N; j++) {
			appear[i][j] = false;
			for(int k = 0; k < N; k++) {
				if(A[i][j] == b[k]) appear[i][j] = true;
			}	
		}
	}
	string ANS = "No";
	for(int i = 0; i < 3; i++) {
		if(appear[i][0] and appear[i][1] and appear[i][2]) ANS = "Yes";
	}
	for(int i = 0; i < 3; i++) {
		if(appear[0][i] and appear[1][i] and appear[2][i]) ANS = "Yes";
	}
	if(appear[0][0] and appear[1][1] and appear[2][2]) ANS = "Yes";
	if(appear[0][2] and appear[1][1] and appear[2][0]) ANS = "Yes";
	cout << ANS << endl;
	return 0;
}

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

#define sz(x) int(x.size())
#define Task "abc"
#define For(i, a, b) for(int i = (a), _b = (b); i <= b; ++i)
#define All(x) (x).begin(), (x).end()
#define mp make_pair

typedef unsigned long long ull;
typedef long long ll;

const int maxn = 1e5 + 10;
const int inf = 0x3f3f3f3f;
const ll mod = 1e9 + 7;

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
//  freopen(Task".inp", "r", stdin); freopen(Task".out", "w", stdout);
  string s; cin >> s;
  cout << (s == "ABC" ? "ARC" : "ABC");
}



Measured memory_bytes: 3644
#include<iostream>
using namespace std;
int main()
{
    int n,p,i,cnt=0,m;
    cin >> n;
    for(i=0;i<n;i++){
        cin >> p;
        if(i==0 || m>p){
            cnt++;
            m=p;
        }
    }
    cout << cnt;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int n, b, f, r, v,a[4][3][10],i,j,k,h;
  for(i=0;i<4;i++){
    for(j=0;j<3;j++){
      for(k=0;k<10;k++){
        a[i][j][k]=0;
      }
    }
  }
  scanf("%d", &n);
  for(h=0;h<n;h++){
  scanf("%d %d %d %d",&b,&f,&r,&v);
  for(i=0;i<4;i++){
    for(j=0;j<3;j++){
      for(k=0;k<10;k++){
        if(i==(b-1)&&j==(f-1)&&k==(r-1)){
          a[i][j][k] += v;
        }
      }
    }
  }
}
for(i=0;i<4;i++){
  for(j=0;j<3;j++){
    for(k=0;k<10;k++){
      printf(" %d", a[i][j][k]);
      if(k==9){
        printf("\n");
      }
      if(k==9&&j==2&&i<3){
        printf("####################\n");
      }
    }
  }
}
return 0;
}



Measured memory_bytes: 2056
#include <bits/stdc++.h>
using namespace std;
using Point = pair<int,int>;

int main()
{
    int N;
    cin >> N;
    
    vector<Point> a(N);
    vector<int> ref(N);
    for(int i=0;i<N;i++)
    {
        cin >> a[i].first;
        cin >> a[i].second;
        ref[i] = i;
    }
    
    double ans=0;
    int count = 0;
    do{
        count ++;
        double temp=0;
        for(int i=0;i<N-1;i++)
        {
            temp += sqrt((a[ref[i]].first - a[ref[i+1]].first)*(a[ref[i]].first - a[ref[i+1]].first)
            +(a[ref[i]].second - a[ref[i+1]].second)*(a[ref[i]].second - a[ref[i+1]].second));
        }
        
        ans += temp;
    }while(next_permutation(ref.begin(),ref.end()));
    
    ans = ans / (double)count;
    
    
    cout << setprecision(20)<<ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
q = int(input())
li = [input().split() for i in range(q)]
for i in li:
    a, b, c, d = map(int, i)
    ans = 0
    for j in range(a, c+1):
        for k in range(b, d+1):
            ans += 0 if j%2 == 1 and k%2 == 0 else 1
    print(ans)



Measured memory_bytes: 22888
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#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() {
  ll a,b,c,k;
  cin >> a >> b >> c >> k;
  ll ans = min(a,k);
  k -= a;
  if(k>0) k-=b;
  if(k>0) ans -= min(k,c);
  cout << ans << endl;
}


Measured memory_bytes: 3640
def check(price, disabled_digits):
    price = int(price)
    disabled_digits = set(disabled_digits)
    while not set(str(price)).isdisjoint(disabled_digits):
        price += 1
    return price


def main():
    price, k = input().split()
    disabled_digits = input().split()
    print(check(price, disabled_digits))


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int INF = 1e9;
const long double EPS = 1e-10;

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

  rep(i, n) {
    int ans = 1, res = INF;
    rep(j, m) {
      int dist = abs(a[i] - c[j]) + abs(b[i] - d[j]);
      if (dist < res) {
        ans = j + 1;
        res = dist;
      }
    }
    cout << ans << endl;
  }

  
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;class Program
{
	static void Main(string[] args)
	{
        //var exStdIn = new System.IO.StreamReader( "stdin.txt" );System.Console.SetIn( exStdIn );
		int n = int.Parse(Console.ReadLine());
		string s = Console.ReadLine();
		int l = 0, r = n-1;
		int ans = 0;
		while(true){
			while(l<n&&s[l]=='R')l++;
			while(0<r&&s[r]=='W')r--;
			if(r<=l)break;
			ans++;
			l++;r--;
		}
		Console.WriteLine(ans);
	}
	
}


Measured memory_bytes: 28236
#![allow(non_snake_case)]
#![allow(unused_imports)]
use proconio::input;
use std::collections::HashMap;
use std::collections::VecDeque;
use std::cmp::max;
use std::cmp::min;


fn main() {
    input! {
        A: i64,
        B: i64,
        C: i64,
    }

    // sqrt(A) + sqrt(B) < sqrt(C)
    // <=> A + B + 2sqrt(A)sqrt(B) < C
    // <=> 2sqrt(A)sqrt(B) < C - A - B
    // <=> 4AB < (C - A - B) ** 2 and C - A - B >= 0

    let ans = if C > A + B {
        if (C - A - B) * (C - A - B) > 4 * A * B {
            "Yes"
        } else {
            "No"
        }
    } else {
        "No"
    };

    println!("{}", ans);
}


Measured memory_bytes: 2124
n,m = map(int,input().split())
path = [input().split() for x in range(m)]

table = [[] for x in range(n)]
for x in path:
    table[int(x[0])-1].append(int(x[1])-1)
    table[int(x[1])-1].append(int(x[0])-1)
    
import itertools
count = 0
for z in itertools.permutations(range(0,n)):
    if z[0] == 0:
        for y in range(len(z)-1):
            if z[y+1] in table[z[y]]:
                continue
            else:
                count -= 1
                break
        count += 1
print(count)

Measured memory_bytes: 3064
import fractions
N = int(input())
for h in range(1,3501):
    for n in range(1, 3501):
        q = 4*n*h-N*(n+h)
        p = n*h*N
        if q <= 0:
            continue
        if p%q==0:
            ans = [h,n,p//q]
print(*ans)

Measured memory_bytes: 67288
from collections import Counter
while True:
    M,NMIN,NMAX = map(int,input().split())
    if M == 0: break
    src = [int(input()) for i in range(M)]
    ctr = Counter(src)
    ctr = list(ctr.items())
    ctr.sort(reverse=True)
    
    n = passed = maxgap = 0
    for (s1,n1),(s2,n2) in zip(ctr, ctr[1:]):
        n += n1
        if n < NMIN: continue
        if n > NMAX: break
        gap = s1-s2
        if gap >= maxgap:
            maxgap = gap
            passed = n
    print(passed)

Measured memory_bytes: 6028
#include <stdio.h>

int main(){
  int change, charge, count;

  while(scanf("%d", &charge)){
    if(charge == 0) break;
    change = 1000 - charge;
    count = 0;

    count += change / 500;
    change %= 500;

    count += change / 100;
    change %= 100;

    count += change / 50;
    change %= 50;

    count += change /10;
    change %= 10;

 count += change / 5;
    change %= 5;

    count += change /1;

    printf("%d\n", count);
  }
  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#include<chrono>
using namespace std;
using ll = long long;

int main() {
  int N, M;
  cin >> N;
  map<string, int> S;
  map<string, int> T;
  for (int i = 0; i < N; i++) {
    string s;
    cin >> s;
    if (S.count(s)) {
      S[s]++;
    }
    else {
      S[s] = 1;
    }
  }
  
  cin >> M;
  for (int i = 0; i < M; i++) {
    string t;
    cin >> t;
    if (T.count(t)) {
      T[t]++;
    }
    else {
      T[t] = 1;
    }
  }
  int ans = 0;
  for (auto p : S) {
    if (T.count(p.first)) {
      p.second -= T[p.first];
    }
    if (p.second > ans) {
      ans = p.second;
    }
  }
  cout << ans << endl;
}

  
      
  
  

Measured memory_bytes: 256
#include <iostream>
#include <string>
std::string S, T;

void fastio() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
}

int main() {
  fastio();
  std::cin >> S >> T;
  std::cout << T << S << '\n';
  return 0;
}

Measured memory_bytes: 504
def mi():
	return map(int, input().split())

maxn = 100000
s = [1]
n = int(input())
for i in range(20):
	if 6**i<=maxn:
		s.append(6**i)
	if 9**i<=maxn:
		s.append(9**i)
dp = [10**10]*(maxn+4)
dp[0] = 0
m = len(s)
for i in range(1,maxn+1):
	for j in range(m):
		if s[j]<=i:
			subres = dp[i-s[j]]
		if subres!=10**10 and subres+1<dp[i]:
			dp[i] = subres+1
print (dp[n])

Measured memory_bytes: 41836
# Aさんは a[m]地点、Bさんは b[m]地点、Cさんは c[m]地点
# 2人の人間は、距離が d[m] 以内の時直接会話可能
# A・Cが直接的に会話できる or A・Bが直接会話でき、かつ B・Cが直接会話できる
# 会話できるなら Yes ,できないなら No を出力

a,b,c,d = map(int , input().split())
# print(a)
# print(b)
# print(c)
# print(d)


# a と c の差の絶対値が d 以下
if abs(c-a) <= d:
    print('Yes')
# a と b の差の絶対値が d 以下かつ b と c 野さの絶対値が d 以下
elif abs(b-a) <= d and abs(c-b) <= d:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9172
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d,e,t,s=0;
  cin >> a >> b >> c >> d >> e;
  if(a<0){
	t = a*(-1);
	s = t * c;
        s += d;
	s = s+(b*e);
  }
  if (a==0) {
      s += d;
      s = s * (b * e);
  }
  if (a > 0) {
	s = ((b-a) * e);
  }
  cout << s << endl;
 return 0;
}



Measured memory_bytes: 3120
<?php

function input($func = null) {
    if ($func === null) {
        return trim(fgets(STDIN));
    } else {
        return $func(trim(fgets(STDIN)));
    }
}
function input_array($func = null) {
    if ($func === null) {
        return explode(' ', input());
    } else {
        return array_map(function($v) use ($func) {
            return $func($v);
        }, explode(' ', input()));
    }
}

list($n, $k) = input_array('intval');

if (($k - 1) * 2 + 1 <= $n) {
    echo "YES\n";
} else {
    echo "NO\n";
}

Measured memory_bytes: 4728
def main():
  n, m = input_list()
  sc = []
  
  d = {}
  mk = 0
  for i in range(m):
    s, c = input_list()
    if s in d and d[s] != c:
      print(-1)
      exit()
    d[s] = c
    mk = max(s, mk)
  for i in range(1000):
    si = str(i)
    if len(si) < n:
      continue
    check = True
    ls = len(si)
    for keta, c in d.items():
      if si[keta-1] != str(c):
        check = False
    if check:
      print(i)
      exit()
  print(-1)
  
def input_list():
  return map(int, input().split())

import math
import fractions
main()

Measured memory_bytes: 66924
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
int main(){
	string s;
	cin>>s;
	int N=s.size();
	long long sum=0;
	rep(i,1<<(N-1)){
		long long now=s[0]-'0';
		rep(j,N-1){
			if((i>>j)&1) now=now*10+s[j+1]-'0';
			else{
				sum+=now;
				now=s[j+1]-'0';
			}
		}
		sum+=now;
	}
	cout<<sum<<endl;
}


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

int N,M,Q;
int L,R,p,q;
int G[501][501] = {{0}};
int main(){
	cin >> N >> M >> Q;
	for(int i=0;i<M;i++){
		scanf("%d%d",&L,&R);
		G[L][R]++;
	}
	for(int i=1;i<=N;i++){
		for(int j=i;j>1;j--){
			G[j-1][i] += G[j][i];
		}
		for(int j=i;j<N;j++){
			G[i][j+1] += G[i][j];
		}
	}
	for(int i=0;i<Q;i++){
		cin >> p >> q;
		printf("%d\n",p<q? G[p][q]:G[q][p]);
	}
}

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

typedef long long int ll;

int main(){
    ll h,w;
    scanf("%lld %lld",&h,&w);
    ll ans = ceil((h*w)/2.0);
    if(h==1 or w==1) ans = 1;
    printf("%lld\n",ans);
    return 0;
}


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

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n)-1; i >= 0; i--)
#define INF (1 << 30)
#define ALEN(ARR) (sizeof(ARR) / sizeof((ARR)[0]))
#define MP make_pair
#define mp make_pair
#define pb push_back
#define PB push_back

#if DEBUG
#define _DEBUG(x) cout << #x << ": " << x << endl
#define _DDEBUG(x, y) cout << #x << ": " << x << ", " << #y << ": " << y << endl
#else
#define _DEBUG(x) ;
#define _DDEBUG(x, y) ;
#endif

#define ll long long
#define ull unsigned long long
#define MOD 1000000007

/** FOR VECTOR DEBUG */
template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  if (!v.empty()) {
    out << '[';
    copy(v.begin(), v.end(), ostream_iterator<T>(out, ", "));
    out << "\b\b]";
  }
  return out;
}

/* template end */
const int limit = 11729;
string dp[limit];
int match[10] = {-INF, 2, 5, 5, 4, 5, 6, 3, 7, 6};

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

  int n, m;
  cin >> n >> m;

  vector<int> al(m);
  REP(i, m) {
    cin >> al[i];
  }
  sort(al.begin(), al.end(), greater<int>());
  REP(i, limit) {
    dp[i] = "";
  }
  REP(i, n) {
    if(i>0 && dp[i].size() ==0) { 
      continue; 
    }
    for (auto j : al) {
      int idx = i + match[j];
      dp[idx] = [&](string s, string t) {
        if (t.size() > s.size() || t > s) {
          return t;
        }
        return s;
      }(dp[idx], dp[i] + to_string(j));
    }
  }

  cout << dp[n] << endl;

  return 0;
}


Measured memory_bytes: 33536