akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
struct Fast {Fast(){std::cin.tie(0);std::ios::sync_with_stdio(false);}} fast;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define repR(i, n) for(ll i = n; i >= 0; i--)
#define For(i, m, n) for(ll i = m; i < n; i++)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) v.begin(), v.end()

using namespace std;

ll mod = 1e9+7;
inline ll gcd(ll a, ll b){
    ll r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

inline ll lcm(ll x, ll y)
{
    if(x == 0 || y == 0) {
        return -1;
    }
    
    return (x * y / gcd(x, y));
}

inline ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

inline ll nCr(ll n, ll r) {
    if ( r * 2 > n ) r = n - r;
    ll dividend = 1;
    ll divisor  = 1;
    for ( ll i = 1; i <= r; ++i ) {
        dividend *= (n-i+1);
        divisor  *= i;
    }
    return (dividend / divisor);
}

// 因数分解
inline vector<pair<ll, int>>factorize(ll n){
    vector<pair<ll, int>> res;
    for(ll i = 2; i * i <= n; ++i){
        if(n % i) continue;
        res.emplace_back(i, 0);
        while(n % i == 0){
            n /= i;
            res.back().second++;
        }
    }
    if(n != 1) res.emplace_back(n, 1);
    return res;
}

inline bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

//階乗
inline ll factorialMethod(ll k){
    ll sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

inline ll vector_finder(std::vector<ll> vec, ll number) {
    auto itr = std::find(vec.begin(), vec.end(), number);
    size_t index = std::distance( vec.begin(), itr );
    if (index != vec.size()) { // 発見できたとき
        return 1;
        
        
    }
    else { // 発見できなかったとき
        return 0;
    }
}

void recursive_comb(ll *indexes, ll s, ll rest, std::function<void(ll *)> f) {
    if (rest == 0) {
        f(indexes);
    } else {
        if (s < 0) return;
        recursive_comb(indexes, s - 1, rest, f);
        indexes[rest - 1] = s;
        recursive_comb(indexes, s - 1, rest - 1, f);
    }
}

void foreach_permutation(int n, std::function<void(int *)> f) {
    int indexes[n];
    for (int i = 0; i < n; i++) indexes[i] = i;
    do {
        f(indexes);
    } while (std::next_permutation(indexes, indexes + n));
}

int main(){
    ll n;
    cin >> n;
    vector<ll> p(n);
    rep(i, n){
        cin >> p[i];
    }
    std::sort(p.begin(), p.end());
    ll temp = p.size();
    p.erase(std::unique(p.begin(), p.end()), p.end());
    if(temp != p.size()){
        cout << "NO" << endl;
    }else {
        cout << "YES" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include<bits/extc++.h>
using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;
using ll = long long;
#define AC ios::sync_with_stdio(0),cin.tie(0);

int main()
{
    AC
    int n,r=0;
    cin>>n;
    vector<int> v(n+1);
    for(int i=1;i<n;i++) cin>>v[i];
    r+=v[1];
    for(int i=2;i<=n;i++) r+=min(v[i-1],v[i]);
    r+=v[n-1];
    cout<<r<<'\n';
}


Measured memory_bytes: 256
#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;
    cin >> n;
    int ans = 0;
    int a;
    rep(i, n) {
        cin >> a;
        while (a % 2 == 0) {
            a /= 2;
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = int_fast64_t;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

void answer() {
  ll n, k;
  cin >> n >> k;
  vector<ll> p(n);
  rep(i, n) cin >> p[i];
  sort(ALL(p));
  ll ans = 0;
  rep(i, k) ans += p[i];
  cout << ans << "\n";
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 3652
/*
AtCoderBeginnerContest042
Problem D - いろはちゃんとマス目 / Iroha and a Grid
Time limit : 2sec / Memory limit : 256MB
Score : 400 points
*/

#include <iostream>
#include <vector>

int MODULUS = 1000000007;

std::vector<long> fact;
std::vector<long> inv;
std::vector<long> invFact;

long plus(long x, long y)
{
    long res = x+y;
    res %= MODULUS;
    return res;
}

long mult(long x, long y)
{
    long res = x*y;
    res %= MODULUS;
    return res;
}

long Num(int dr, int dc)
{
    int N = dr + dc;
    long res = fact[N];
    res = mult(res, invFact[dr]);
    res = mult(res, invFact[dc]);

    return res;
}

long solve(int H, int W, int A, int B)
{
    long res = 0;

    int r = A, c = B;
    while (r < H && c < W)
    {
        //upper left:   r=H-1, c=0
        //lower right:  r=0, c=W-1
        long term = mult(Num(H-1-r, c), Num(r, W-1-c));
        res = plus(res, term);
        r++;
        c++;
    }

    return res;
}

void nextFact(int i)
{
    fact.push_back(mult(i, fact[i-1]));
}

void nextInv(int i)
{
    int rem = MODULUS%i;
    long y = inv[rem];
    long z = MODULUS - MODULUS/i;
    inv.push_back(mult(y,z));
}

void nextInvFact(int i)
{
    invFact.push_back(mult(inv[i], invFact[i-1]));
}

int main()
{
    int H, W, A, B;
    std::cin >> H >> W >> A >> B;

    fact.push_back(1);
    inv.push_back(-1);
    invFact.push_back(1);

    fact.push_back(1);
    inv.push_back(1);
    invFact.push_back(1);

    for (int i=2; i<=H+W; i++)
    {
        nextFact(i);
        nextInv(i);
        nextInvFact(i);
    }

    std::cout << solve(H, W, A, B) << "\n";
}


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

int N, M, A[1 << 18], B[1 << 18];
pair<int, int> dist[1 << 18];
vector<int> X[1 << 18], Y;

int main() {
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		cin >> A[i] >> B[i];
		X[A[i]].push_back(B[i]);
	}
	for (int i = 0; i < 10000; i++) Y.push_back(i);
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= N; j++) dist[j] = make_pair(1 << 30, -1);

		queue<int> Q;
		for (int j : X[i]) {
			dist[j] = make_pair(1, i);
			Q.push(j);
		}
		while (!Q.empty()) {
			int pos = Q.front(); Q.pop();
			for (int j : X[pos]) {
				if (dist[j].first > dist[pos].first + 1) {
					dist[j].first = dist[pos].first + 1;
					dist[j].second = pos;
					Q.push(j);
				}
			}
		}

		if (dist[i].first != (1 << 30)) {
			vector<int> R; int cx = i;
			while (true) {
				cx = dist[cx].second;
				R.push_back(cx);
				if (cx == i) break;
			}
			reverse(R.begin(), R.end());
			if (Y.size() > R.size()) Y = R;
		}
	}
	if (Y.size() == 10000) cout << "-1" << endl;
	else {
		cout << Y.size() << endl;
		for (int i = 0; i < Y.size(); i++) cout << Y[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 10752
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AX solver = new AX();
        solver.solve(1, in, out);
        out.close();
    }

    static class AX {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int a = in.nextInt(), b = in.nextInt();

            int answer = Math.max(Math.max(a + b, a - b), a * b);

            out.println(answer);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 22740
#!/bin/bash
''':'
docker run --rm -it -v $(cd $(dirname $0) && pwd):/vo:ro pypy:3-2.4.0 \
   /bin/bash -c "pypy3 /vo/$(basename $0) < /vo/g.inp"
exit $?
'''
import sys

def _ia(): return [ int(x) for x in sys.stdin.readline().strip().split() ]

class Bigint:
    def __init__(self,n,mod=10**9+7):
        self.n = n % mod
        self.mod = mod
        return


    def __str__(self):
        return str(self.n)


    def __add__(self,other):
        ot = type(other)
        if ot==Bigint:
            return Bigint(self.n+other.n,self.mod)
        elif ot==int:
            return Bigint(self.n+other,self.mod)
        else:
            raise ValueError("Invalid type")


    def __iadd__(self,other):
        return self.__add__(other)


    def __sub__(self,other):
        ot = type(other)
        if ot==Bigint:
            o = other.n
        elif ot==int:
            o = other
        else:
            raise ValueError("Invalid type")
        #
        return Bigint(self.n - o, self.mod)


    def __isub__(self,other):
        return self.__sub__(other)


    def __mul__(self,other):
        ot = type(other)
        if ot==Bigint:
            return Bigint(self.n*other.n,self.mod)
        elif ot==int:
            return Bigint(self.n*other,self.mod)
        else:
            raise ValueError("Invalid type")


    def __imul__(self,other):
        return self.__mul__(other)


    def __pow__(self,other):
        assert type(other)==int, "power should be integer"
        #
        if other<0: return self ** ( other % ( self.mod-1 ) )
        ret = Bigint(1,self.mod)
        now = Bigint(self.n,self.mod)
        while other>0:
            if other%2==0: pass
            else: ret *= now
            other//=2
            now*=now
        return ret


    def __truediv__(self,other):
        ot = type(other)
        if ot==Bigint:
            o = other
        elif ot==int:
            o = Bigint(other)
        else:
            raise ValueError("Invalid type")

        self *= ( o ** (o.mod-2) )
        return self


    def __itruediv__(self,other):
        return self.__truediv__(other)

def combination(n,k):
   kp = min(k,n-k)

   ne = Bigint(1)
   for i in range(n-kp+1, n+1): ne *= i
   de = Bigint(1)
   for i in range(1, kp+1): de *= i
   return ne / de

n, a, b = _ia()
ans = Bigint(2) ** n - 1
ans -= combination(n,a)
ans -= combination(n,b)
print(ans)

Measured memory_bytes: 42480
import java.io.*;
import java.util.*;

public class Main {
	int M = 1_000_000_007;
	
	void run() {
		int n = in.nextInt();
		int[] x = new int[n];
		for (int i = 0; i < n; i++) {
			x[i] = in.nextInt();
		}
		long ans = 1;
		int m = 0;
		for (int i = 0; i < n; i++) {
			if (m > 0 && x[i] == 2 * m) {
				ans *= m + 1;
				ans %= M;
			} else {
				m++;
			}
		}
		while (m > 0) {
			ans *= m;
			ans %= M;
			m--;
		}
		out.println(ans);
	}

	static MyScanner in;
	static PrintWriter out;

	public static void main(String[] args) throws IOException {
		boolean stdStreams = true;
		String fileName = Main.class.getSimpleName().replaceFirst("_.*", "").toLowerCase();
		String inputFileName = fileName + ".in";
		String outputFileName = fileName + ".out";
		
		Locale.setDefault(Locale.US);
		BufferedReader br;
		if (stdStreams) {
			br = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
		} else {
			br = new BufferedReader(new FileReader(inputFileName));
			out = new PrintWriter(outputFileName);
		}
		in = new MyScanner(br);
		int tests = 1;//in.nextInt();
		for (int test = 0; test < tests; test++) {
			new Main().run();
		}
		br.close();
		out.close();
	}
	
	static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		MyScanner(BufferedReader br) {
			this.br = br;
		}
		
		void findToken() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
		}
		
		String next() {
			findToken();
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		
		long nextLong() {
			return Long.parseLong(next());
		}
		
		double nextDouble() {
			return Double.parseDouble(next());
		}
	}
}


Measured memory_bytes: 36184
import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 1000000007
sys.setrecursionlimit(1000000)

N = ri()
A = rl()

sumA = sum(A)

even = [0]
s = 0
for i in range(N-1, -(2*N+4), -2):
	s += A[i%N]
	even.append(s)
odd = [0]
s = 0
for i in range(N-2, -(2*N+4), -2):
	s += A[i%N]
	odd.append(s)

B = [0] * N
for i in range(N):
	r = 0
	if i%2==0:
		r = even[N//2-i//2+N//2+1]-even[N//2-i//2]
	else:
		r = odd[N//2-1-(i-1)//2+N//2+1]-odd[N//2-1-(i-1)//2]
	B[i] = r - (sumA-r)
print(*([B[-1]]+B[:-1]))

Measured memory_bytes: 113600
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
const long double pi = acos(-1);
const long double eps = 1e-10;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }

void yes() { cout << "Yay!\n"; }
void no() { cout << ":(\n"; }

int main() {
    init();

    int n; cin >> n;
    VI a(n); cin >> a;

    VL cnt(n + 1);
    cnt[0] = 3;
    ll ans = 1;
    FOR(i, 0, n) {
        (ans *= cnt[a[i]]) %= mod;
        --cnt[a[i]];
        ++cnt[a[i] + 1];
    }

    cout << ans << "\n";
}


Measured memory_bytes: 1408
using System;
using System.Linq;
using System.Collections.Generic;

namespace Atcoder
{
    class Program
    {
        public static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int N = int.Parse(input[0]);
            int M = int.Parse(input[1]);
            int X = int.Parse(input[2]);
            int Y = int.Parse(input[3]);
            string[] citiesX = Console.ReadLine().Split(' ');
            string[] citiesY = Console.ReadLine().Split(' ');
            int Xmax=-1000;
            int Ymin=1000;
            for (int i = 0; i < N;i++){
                int tmp = int.Parse(citiesX[i]);
                if(tmp>Xmax){
                    Xmax = tmp;
                }
            }
            for (int i = 0; i < M;i++){
                int tmp = int.Parse(citiesY[i]);
                if(tmp<Ymin){
                    Ymin = tmp;
                }
            }
            if(Xmax<Ymin&&X<Ymin&&Y>Xmax){
                Console.WriteLine("No War");
            }else{
                Console.WriteLine("War");
            }
                
        }

    }
}


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

int main()
{
  int n,x;
  cin>>n>>x;
  int l[n],i,j=n+1,sum=0;
  for(i=0;i<n;i++){
    cin>>l[i];
  }
  for(i=0;i<n;i++){
    sum+=l[i];
    if(sum>x){
      j=i+1;
      break;
    }
  }
  cout<<j<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int x,y;

  while (1) {
    scanf("%d %d", &x, &y);
    if (x == 0 && y == 0) break;
    if (x < y) {
      printf("%d %d\n", x, y);
    }
    else {
      printf("%d %d\n", y, x);
    }
  }

  return (0);
}



Measured memory_bytes: 2116
#include <stdio.h>
#define INF 10000000

int main(void){
	int n,m;
	
	while(scanf("%d %d",&m,&n),n,m){
		int i,j;
		int a,b,cost,time,c;
		int DPc[256][256];
		int DPt[256][256];
		int k,ans[256];
		
		for(i=0;i<256;i++){
			for(j=0;j<256;j++){
				if(i==j){
					DPc[i][j]=0;
					DPt[i][j]=0;
				}
				else{
					DPc[i][j]=INF;
					DPt[i][j]=INF;
				}
			}
		}
		
		for(i=0;i<m;i++){
			scanf("%d %d %d %d", &a, &b, &cost, &time);
			DPc[a][b]=cost;
			DPc[b][a]=cost;
			DPt[a][b]=time;
			DPt[b][a]=time;
		}
		
		for(k=0;k<=n;k++){
			for(i=0;i<=n;i++){
				for(j=0;j<=n;j++){
					if(DPt[i][k]+DPt[k][j]<DPt[i][j]){
						DPt[i][j]=DPt[i][k]+DPt[k][j];
					}
					if(DPc[i][k]+DPc[k][j]<DPc[i][j]){
						DPc[i][j]=DPc[i][k]+DPc[k][j];
					}
				}
			}
		}
		
		scanf("%d", &m);
		for(i=0;i<m;i++){
			scanf("%d %d %d", &a, &b, &c);
			if(c==1){
				ans[i]=DPt[a][b];
			}
			else {
				ans[i]=DPc[a][b];
			}
		}
		for(i=0;i<m;i++){
			printf("%d\n",ans[i]);
		}
	}
	return 0;
}

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

typedef int64_t i64;
typedef uint64_t ui64;

class graph{
public:
    struct adj{
        int index;
        int start;
        int to;
        i64 cost;
    };
    int nd;
    int eg;
    vector<adj> *node;
    vector<adj> edge;
    graph(int n,int m){
        nd=n;
        eg=m;
        node=new vector<adj>[nd]{};
        edge={};
    }
    void add_dir(int i,int s,int t,i64 c){
        node[s].push_back({i,s,t,c});
        edge.push_back({i,s,t,c});
    }
    void add_undir(int i,int s,int t,i64 c){
        node[s].push_back({i,s,t,c});
        node[t].push_back({i,t,s,c});
        edge.push_back({i,s,t,c});
    }
    void refr(void){
        for(int i=0;i<nd;i++) vector<adj>().swap(node[i]);
        delete[] node;
        vector<adj>().swap(edge);
    }
    bool IsLink(void);
    void DFS(int r,i64 *&p,bool *&vst);
    bool IsPlus(void);
    void BellmanFord(int s,i64 *&d);
    void Dijkstra(int s,i64 *&d);
    void BFS(int s,i64 *&d);
    void WarshallFloyd_dir(i64 **&d);
    void WarshallFloyd_undir(i64 **&d);
    i64 WMST_dir(int r);
    i64 WMST_undir(void);
    void Edmonds(int r,vector<adj> &p);
    void Kruscal(vector<adj> &p);
    void Prim(vector<adj> &p);
    void Artic(vector<int> &p);
    void Artic_sub(int r,int &k,int par,vector<int> &p,int *&ord,int *&low,bool *&vst);
    void Bridge(vector<adj> &p);
    void Bridge_sub(int r,int &k,int par,vector<adj> &p,int *&ord,int *&low,bool *&vst);
    void SCC(int *&c);
    void SCC_sub1(int r,vector<int> &vs,bool *&vst);
    void SCC_sub2(int r,int k,int *&c,bool *&vst,graph &rg);
    bool IsDAG(void);
    bool IsDAG_sub(int r,int &k,int *&l,int *&vst);
    void TopolSort(int *&l);
    void TopolSort_sub(int r,int &k,int *&l,bool *&vst);
    i64 Diameter(void);
    void Cumul(int s,i64 *&d);
};

i64 graph::Diameter(void){
    i64 *d=new i64[nd]{};
    for(int i=0;i<nd;i++) d[i]=INT64_MAX/2;
    queue<int> que;
    int u=0;
    d[0]=0;
    i64 ma=d[0];
    que.push(0);
    while(!que.empty()){
        int i=que.front();
        que.pop();
        for(const auto &j:node[i]){
            if(d[j.to]!=INT64_MAX/2) continue;
            d[j.to]=d[i]+j.cost;
            if(d[j.to]>ma){
                ma=d[j.to];
                u=j.to;
            }
            que.push(j.to);
        }
    }
    for(int i=0;i<nd;i++) d[i]=INT64_MAX/2;
    d[u]=0;
    ma=d[u];
    que.push(u);
    while(!que.empty()){
        int i=que.front();
        que.pop();
        for(const auto &j:node[i]){
            if(d[j.to]!=INT64_MAX/2) continue;
            d[j.to]=d[i]+j.cost;
            if(d[j.to]>ma){
                ma=d[j.to];
            }
            que.push(j.to);
        }
    }
    return ma;
}

int main(void){
    int n;
    scanf("%i",&n);
    graph g(n,n-1);
    int s,t;
    i64 w;
    for(int i=0;i<n-1;i++){
        scanf("%i%i%lli",&s,&t,&w);
        g.add_undir(i,s,t,w);
    }
    printf("%lli\n",g.Diameter());
    return 0;
}



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

// for loop
#define rep(i,a,n) for(int i=(a);i<(n);++i)
#define repe(i,a,n) for(int i=(a);i<=(n);++i)
#define rrep(i,n,a) for(int i=(n);n>(a);--i)
#define rrepe(i,n,a) for(int i=(n);n>=(a);--i)

// abbreviati
#define PB(v) push_back(v)
#define MP make_pair
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define ENDL << "\n"

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

// constant
const int INF = 1<<30;
const ll INFLL = 1LL << 60;
const ll MOD = 1000000007;
const long double PI =(acos(-1));

/***Snippet***************************************************
ifelse, isprime, torad, todeg, lcm, bfs,chmin,chmax
**************************************************************/

// adjacency list
vector<int> to[100005];

// Graph
using Graph = vector<vector<int>>;

// Grid
int H,W;
vector<vector<int>> field;

// 4方向への移動ベクトル
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int r;cin >> r;
    cout << 3*r*r ENDL;
    
    return 0;
}

Measured memory_bytes: 5996
// import chie template :) {{{
import std.stdio, std.algorithm, std.array, std.string, std.math, std.conv,
  std.range, std.container, std.bigint, std.ascii, std.typecons;

// }}}
// nep.scanner {{{
class Scanner {
  import std.stdio : File, stdin;
  import std.conv : to;
  import std.array : split;
  import std.string;
  import std.traits : isSomeString;

  private File file;
  private char[][] str;
  private size_t idx;

  this(File file = stdin) {
    this.file = file;
    this.idx = 0;
  }

  this(StrType)(StrType s, File file = stdin) if (isSomeString!(StrType)) {
    this.file = file;
    this.idx = 0;
    fromString(s);
  }

  private char[] next() {
    if (idx < str.length) {
      return str[idx++];
    }

    char[] s;
    while (s.length == 0) {
      s = file.readln.strip.to!(char[]);
    }

    str = s.split;
    idx = 0;

    return str[idx++];
  }

  T next(T)() {
    return next.to!(T);
  }

  T[] nextArray(T)(size_t len) {
    T[] ret = new T[len];

    foreach (ref c; ret) {
      c = next!(T);
    }

    return ret;
  }

  void scan()() {
  }

  void scan(T, S...)(ref T x, ref S args) {
    x = next!(T);
    scan(args);
  }

  void fromString(StrType)(StrType s) if (isSomeString!(StrType)) {
    str ~= s.to!(char[]).strip.split;
  }
}
// }}}

void main() {
  auto cin = new Scanner;
  int n, h, w;
  cin.scan(n, h, w);
  int res;
  foreach (i; 0 .. n) {
    int y, x;
    cin.scan(y, x);
    res += min(y / h, x / w);
  }
  writeln(res);
}


Measured memory_bytes: 380
#include <iostream>
#include <stdio.h>
#include <queue>
#include <cmath>

#define int64 long long int

using namespace std;

int GCD(int, int);
int LCM(int, int);

int main ()
{
    int a, b;
    while(cin >> a >> b){
        cout << GCD(a, b) << ' ' << LCM(a, b) << endl;
    }
    return 0;
}

int GCD(int a, int b){
    int buf;
    while(a % b != 0){
        buf = a % b;
        a = b;
        b = buf;
    }
    return b;
}

int LCM(int a, int b){
    int64 ab = (int64)a*b;
    return ab / GCD(a, b);
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
#define INF 1000000007
using namespace std;
const int MAXN = 222222;
struct sakura
{
    long long x;
    long long y;
}ball[MAXN];

long long x[MAXN];
long long y[MAXN];
long long maxn[MAXN];
long long minl[MAXN];
long long n,ans,ans1,ans2,bmax,bmin,rmax,rmin;
inline bool cmp(sakura xx,sakura yy){ return xx.x<yy.x; }
int main()
{
    scanf("%lld",&n);
    bmax=rmax=-1;bmin=rmin=INF;
    for(register int i=1;i<=n;++i)
    {
        scanf("%lld%lld",&x[i],&y[i]);
        if(x[i]>y[i]) swap(x[i],y[i]);
        ball[i].x=x[i];ball[i].y=y[i];
        bmax=max(bmax,y[i]);
        bmin=min(bmin,y[i]);
        rmax=max(rmax,x[i]);
        rmin=min(rmin,x[i]);
    }
    ans1=(bmax-bmin)*(rmax-rmin);
    bmin=rmin;sort(ball+1,ball+n+1,cmp);
    ans2=INF;maxn[1]=minl[1]=ball[1].y;
    for(register int i=2;i<=n;++i)
    {
        maxn[i]=max(maxn[i-1],ball[i].y);
        minl[i]=min(minl[i-1],ball[i].y);
        if(i!=n) ans2=min(ans2,max(maxn[i],ball[n].x)-min(minl[i],ball[i+1].x));
    }
    ans2*=(bmax-bmin);ans=min(ans1,ans2);
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 10240
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

int main(void){
    int n,m;
    cin>>n>>m;
    int a;
    vector<bool> ok;
    vector<ll> dp;
    rep(i,n+10){
        ok.push_back(true);
        dp.push_back(0);
    }
    rep(i,m){
        cin>>a;
        ok[a] = false;
    }
    dp[0] = 1;
    rep(i,n+1){
        if(!ok[i]) continue;
        dp[i] %= MOD;
        dp[i+1] += dp[i];
        dp[i+2] += dp[i];
    }
    cout<<dp[n]%MOD<<endl;
    return 0;
}


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

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) ll(x.size()) //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB emplace_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define Umap unordered_map
#define Uset unordered_set

int main(){
    ll n;
    cin >> n;
    vector<ll> h(n);
    REP(i, n) cin >> h[i];
    ll cnt = 0, max_ = 0;
    REP(i, n){
        if(max_ <= h[i]){
            max_ = h[i];
            cnt++;
        }
    }
    cout << cnt;
    return 0;
}



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

int main(int argc, char const *argv[]) {
  int N,c,s,f; cin>>N;
  vector<ll> C(N - 1);
  vector<ll> S(N - 1);
  vector<ll> F(N - 1);
  vector<it> table;
  for(int i = 0; i < N - 1; i++){
    cin>>c>>s>>f;
    C[i] = c;
    S[i] = s;
    F[i] = f;
  }

  //Not Smart
  for(int i = 0; i < N; i++){
      int t = 0;
      for(int j = i; j < N - 1; j++){
          if(t < S[j]) {
            t = S[j];
          } else if(t % F[j] == 0){

          } else {
            t = t + F[j] - t % F[j];
          }
          t+=C[j];
      }
      cout << t << "\n";
  }

  /*
  vector<ll> result(N, 0);
  for(int i = N - 1; i >= 0; i--){
    if(i == N - 1){
      result[i] = 0;
      continue;
    }
    if(i == N - 2){
      result[i] = S[i] + C[i];
      continue;
    }

    if(S[i] + C[i] <= result[i + 1] - C[i + 1]){
      result[i] = result[i + 1];
    } else {
      ll rem = (F[i + 1] - (S[i] + C[i]) % F[i + 1]) % F[i + 1];
      result[i] = result[i + 1] - S[i + 1] + S[i] + rem + C[i];
    }
  }
  //Output Result
  for(int i = 0; i < N; i++) cout << result[i] << "\n";
  */
  return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <complex>
#include <cmath>
using namespace std;
typedef complex<double> P;
typedef pair<P, double> C;
#define X real()
#define Y imag()

const double pi = acos(-1), EPS = (1e-7);

double dot(P a, P b){
  return a.X*b.X + a.Y*b.Y;
}

vector<P> cpcc(C a, C b){
  //円と円の交点
  double d = abs(a.first-b.first), ra = a.second, rb = b.second;
  double t = (ra*ra-rb*rb+d*d)/2/d, h = sqrt(ra*ra-t*t);
  P m = t/abs(b.first-a.first)*(b.first-a.first)+a.first;
  vector<P> cp(2,m);
  P n = (a.first-b.first)*P(0,1);
  n /= abs(n);
  cp[0] -= h*n;
  cp[1] += h*n;
  return cp;
}

vector<P> tangent_to_C(P p, C c){
  //点pから円cに伸ばした接線の接点を求める
  C c2 = C((p+c.first)/2.0,abs(p-c.first)/2.0);
  return cpcc(c,c2);
}

bool in_sector(P c, double r, double theta, double a, double b){
  if(abs(c) < r + EPS) return false;
  if(abs(c) + r > a + EPS) return false;
  vector<P> cps = tangent_to_C(P(0,0), C(c, r));
  if(cps.empty()) return false;
  P d = P(cos(b), sin(b));
  for(int i = 0; i < (int)cps.size(); ++i){
    P cp = cps[i];
    if(dot(cp, d)/abs(cp) < cos(theta/2) - EPS) return false;
  }
  return true;
}

void dfs(vector< vector<int> > &G, int v, vector<int> &P, vector<int> &R, int t){
  for(int i = 0; i < (int)G[v].size(); ++i){
    int v_ = G[v][i];
    int d = min(P[v_], R[v_]+t) - R[v_];
    R[v_] += d;
    if(d > 0) dfs(G, v_, P, R, d);
  }
}

int solve(vector< vector<int> > &G, vector<int> P){
  int n = G.size();
  vector<int> R(n, 0);
  R[0] = P[0];
  dfs(G, 0, P, R, R[0]);
  return R.back();
}

int main(){
  int N;
  cin >> N;
  double theta, a;
  vector<int> Power(N+2, 0);
  Power.back() = (int)1e9;
  cin >> theta >> a >> Power[0];
  theta *= pi/180.0;
  vector<P> L(N+1);
  vector<double> R(N+1), A(N), T(N), B(N);
  for(int i = 0; i < N; ++i){
    double x, y;
    cin >> x >> y >> R[i] >> T[i] >> A[i] >> B[i] >> Power[i+1];
    L[i] = P(x, y);
    T[i] *= pi/180.0;
    B[i] *= pi/180.0;
  }
  double x, y;
  cin >> x >> y >> R[N];
  L[N] = P(x, y);
  vector< vector<int> > G(N+2);
  for(int i = 0; i < N; ++i){
    for(int j = 0; j <= N; ++j){
      if(i == j) continue;
      if(in_sector(L[j]-L[i], R[j], T[i], A[i], B[i])){
        G[i+1].push_back(j+1);
      }
    }
  }

  int ans = 0;
  for(int i = 0; i <= N; ++i){
    if(abs(L[i]) + R[i] > a) continue;
    if(abs(L[i]) - R[i] < EPS) continue;
    vector<P> cps = tangent_to_C(P(0,0), C(L[i], R[i]));
    if(cps.empty()) continue;
    P cp = cps[0];
    if(arg(cps[0]) > arg(cps[1])) swap(cps[0], cps[1]);
    double b = arg(cp*P(cos(theta/2), sin(theta/2)));
    G[0] = vector<int>();
    for(int j = 0; j <= N; ++j){
      if(in_sector(L[j], R[j], theta, a, b)){
        G[0].push_back(j+1);
      }
    }
    ans = max(ans, solve(G, Power));
  }
  cout << ans << endl;
  return 0;
}



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

typedef long long ll;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

bool compPair(const pair<int, int>& arg1, const pair<int, int>& arg2) {
    return arg1.first > arg2.first;
}

int main(void) {
    string a;
    cin >> a;

    vector<ll> abc(26);
    ll n = a.size();
    for(ll i=0;i<n;i++) {
        abc.at(a.at(i)-'a')++;
    }

    ll ans;
    ans = n * (n-1) / 2;
    for(ll i=0;i<26;i++) {
        ans -= abc.at(i) * (abc.at(i)-1) / 2;
    }
    ans++;

    // for(ll i=0;i<26;i++) {
    //     cout << abc.at(i) << "/";
    // }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int dp[110][110];

int main(){
    int h,w;
    cin>>h>>w;
    char fi[h][w];
    rep(i,h) rep(j,w) cin>>fi[i][j];
    rep(i,h) rep(j,w) dp[i][j]=INF;
    if(fi[0][0]=='#') dp[0][0]=1;
    else dp[0][0]=0;

    rep(i,h){
        rep(j,w){
            if(fi[i][j]=='.' && fi[i+1][j]=='#') dp[i+1][j]=min(dp[i+1][j],dp[i][j]+1);
            else dp[i+1][j]=min(dp[i+1][j],dp[i][j]);

            if(fi[i][j]=='.' && fi[i][j+1]=='#') dp[i][j+1]=min(dp[i][j+1],dp[i][j]+1);
            else dp[i][j+1]=min(dp[i][j+1],dp[i][j]);
        }
    }

    /*
    rep(i,h){
        rep(j,w){
            cout<<dp[i][j]<<" ";
        }
        cout<<endl;
    }*/

    cout<<dp[h-1][w-1]<<endl;
} 


Measured memory_bytes: 3660
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include <string.h>
#include <math.h>

using namespace std;

vector<int> n;
string ans;

void df(int c, int sum, string s) {
	if (c == n.size()) {
		if(sum == 7)ans = s;
		return;
	}
	df(c + 1, sum + n[c], s + "+" + std::to_string(n[c]));
	df(c + 1, sum - n[c], s + "-" + std::to_string(n[c]));
	return;
}

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

	for (int i = 0; i < 4; i++) n.push_back(s[i] - '0');

	df(1, n[0], std::to_string(n[0]));

	cout << ans << "=7" << endl;

	return 0;
}

Measured memory_bytes: 256
/*
Author: Sagar Gupta
E mail: sagar.june97p@gmail.com
*/

#pragma comment(linker, "/STACK:268435456")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define endl ("\n")
#define deb(n) cerr << #n << " = " << (n) << '\n'
#define FOR(i, n) for (int(i) = 0; (i) < n; (i)++)
#define PI (3.141592653589)
#define ordered_set tree<int, null_type, std::less<int>, rb_tree_tag, tree_order_statistics_node_update>

#define MOD 1000000007

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed;
    cout.precision(10);
    // Those who cannot acknowledge themselves, will invariably fail

    int a, b, t;
    cin >> a >> b >> t;
    int dib = a;
    int sol = 0;
    for(int i = a;i<=100;i+=dib)
    {
        if(i <= t)
        {
            sol += b;
        }
    }
    cout << sol;


    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,ans=0,maxn=0;
	string a;
	cin>>n;
	cin>>a;
	for (int i=0;i<n;i++)
	{
		if (a[i]=='I') ans++;
		else ans--;
		maxn=max(ans,maxn);
	}
	cout<<maxn<<endl; 
}

Measured memory_bytes: 256
#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(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	int N;
	cin >> N;
	
	vector<int> A(N);
	REP(i, N) cin >> A[i];
	
	int sum = 0;
	REP(i, N) sum ^= A[i];
	
	vector<int> ans(N);
	REP(i, N) ans[i] = sum ^ A[i];
	
	// ans[0] = 1;
	// FOR(i, 1, N) {
	// 	ans[i] = A[i - 1] ^ A[i] ^ ans[i - 1];
	// }
	
	REP(i, N) printf("%d%c", ans[i], i + 1 == N ? '\n' : ' ');
	
	
	// bool ok = true;
	// REP(i, N) {
	// 	int cur = 0;
	// 	REP(j, N) {
	// 		if (i == j) continue;
	// 		cur ^= ans[j];
	// 	}
	// 	ok &= cur == A[i];
	// }
	// if (ok) puts("OK");
	
	return 0;
}


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

int main()
{
    int n;cin>>n;
    int max;
    vector<int> dig(9,0);
    int i,j,k,ii;
    int mdig;
    bool c3,c5,c7;
    int ans=0;
    for(mdig=3;mdig<=9;mdig++)
    {
        max=1;
        for(i=0;i<mdig;i++)max*=3;
        for(i=0;i<max;i++)
        {
            ii=i;
            for(j=0;j<mdig;j++)
            {
                dig.at(j)=ii%3;
                ii/=3;
            }
            k=0;
            c3=false;
            c5=false;
            c7=false;
            for(j=mdig-1;j>=0;j--)
            {
                k*=10;
                if(dig.at(j)==0){k+=3;c3=true;}
                if(dig.at(j)==1){k+=5;c5=true;}
                if(dig.at(j)==2){k+=7;c7=true;}
            }
            if(k<=n&&c3&&c5&&c7)ans++;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
n = int(input())
score = []
for i in range(n):
    a,b = map(int,input().split())
    score.append([a,b,a+b])
score.sort(key = lambda x: x[2])
score.reverse()

takahashi = 0
aoki = 0
for i in range(n):
    if i%2 == 0:
        takahashi += score[i][0]
    else:
        aoki += score[i][1]
print(takahashi-aoki)

Measured memory_bytes: 24484
import sys
import socket

hostname = socket.gethostname()

if hostname == 'F451C':
    sys.stdin = open('a1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def main():
    a, b = read_int_list()
    if a > b:
      res = str(b) * a
    else:
      res = str(a) * b
    print(res)


main()


Measured memory_bytes: 3568
n = int(input())
t = 0
h = 0
for i in range(n):
  tarou_cards,hanako_cards = input().split()
  if tarou_cards > hanako_cards:
    t=t+3
  elif tarou_cards < hanako_cards:
    h=h+3
  else:
    t+=1
    h+=1
print(t,h)


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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int N;
ll A[100100], B[100100];

ll f(){
    if(N == 0){
        if(A[0] == 1){
            return 1;
        }

        return -1;
    }

    if(A[0] != 0){
        return -1;
    }

    ll res = 1, cur = 1;

    for(int i=1;i<=N;++i){
        if(A[i] > cur * 2){
            return -1;
        }

        ll ncur = std::min<ll>(cur * 2 - A[i], B[i+1]);
        res += ncur + A[i];
        cur = ncur;
    }

    return res;
}

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

    std::cin >> N;

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

    for(int i=N;i>=0;--i){
        B[i] = A[i] + B[i+1];
    }

    ll res = f();
    std::cout << res << std::endl;
}


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

int main(){
  int N,M;
  cin >> N;
  vector<string> s(N);
  std::map<string,int> m;
  
  for(int i=0;i<N;i++){
    cin>>s.at(i);
    if(m.find(s.at(i))!=m.end()){
      m.at(s.at(i))++;
    }else{
      m.insert(std::make_pair(s.at(i),1));
    }
  }
  
  cin>>M;
  for(int i=0;i<M;i++){
    string t;
    cin>>t;
    if(m.find(t)!=m.end()){
      m.at(t)--;
    }
  }
  int ans=0;
  for(int i=0;i<N;i++){
    ans = max(ans,m.at(s.at(i)));
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
ll MOD = 1e9 + 7;
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    ll N, W;
    cin >> N >> W;
    vector<ll> w(N), v(N);
    rep(i, N) cin >> w[i] >> v[i];

    vector<vector<ll>> dp(N + 10, vector<ll>(N * 1000 + 10, 1e15));

    dp[0][0] = 0;
    dp[0][v[0]] = w[0];

    rep(i, N) rep(j, N * 1000 + 10){
        if(j >= v[i + 1]) dp[i + 1][j] = min(dp[i][j], dp[i][j - v[i + 1]] + w[i + 1]);
        else dp[i + 1][j] = dp[i][j];
    }

    ll ans = 0;
    rep(j, N * 1000 + 10) if(dp[N - 1][j] <= W) ans = j;

    print(ans);

    return 0;
}

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

using namespace std;

using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main() {
    ll n, m, i, j, k;
    cin >> n;
    string s;
    cin >> s;
    string t;
    if(n%2!=0){
        cout << "No" << endl;
    }else{
        for(i=0;i<n/2;i++){
            if(s[i]!=s[i+n/2]){
                cout << "No" << endl;
                return 0;
            }
        }
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

long long ipow(int n, int m) {
    if (m == 0) return 1;
    if (m == 1) return n;
    return n * ipow(n, m - 1);
}


long long comb(int n, int r){
    vector<vector<long long> > v(n + 1, vector<long long>(r + 1, 0));
    for(int i = 0; i < n + 1; i++) {
        v[i][0] = 1;
        if (i < r + 1) {
            v[i][i] = 1;
        }
    }
    for(int i = 1; i < n + 1; i++) {
        for(int j = 1; j < min(i, r+1); j++) {
            v[i][j] = v[i - 1][j - 1] + v[i - 1][j];
        }
    }
    return v[n][r];
}


int count(string s, int k) {
    int msd = s[0] - '0';
    while (msd == 0) {
        s = s.substr(1);
        msd = s[0] - '0';
    }
    if (s.length() < k) {
        return 0;
    }
    if (k == 0) {
        return 1;
    }
    if (s.length() == k && k == 1) {
        return msd;
    }
    int sum = 0;
    if (s.length() > k) {
        sum += comb(s.length() - 1, k) * ipow(9, k);
    }
    for (int i = 1; i < msd; i++) {
        sum += comb(s.length() - 1, k - 1) * ipow(9, k - 1);
    }
    sum += count(s.substr(1), k - 1);

    return sum;
}

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

    cout << count(s, k) << '\n';
    return 0;
}


Measured memory_bytes: 888
/*input

*/


//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define pb          push_back
#define pii         pair<ll int,ll int>
#define vpii        vector< pii >
#define vi          vector<ll int>
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			(ll)1e18
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define repr(i,a,b) for(ll int i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int solve()
{
	ll k;cin>>k;
	ll sum=0;
	rep(i,1,k+1)
		rep(j,1,k+1)
			rep(m,1,k+1) sum+=__gcd(__gcd(i,j),m);
	cout<<sum<<"\n";
	return 0;
}

int main()
{
	auto start = chrono::high_resolution_clock::now();

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

	ll test_cases=1;
	//cin>>test_cases;
	while(test_cases--)
		solve();

	auto stop = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(stop-start);
	// cout<<"\nduration: "<<(double)duration.count()<<" milliseconds";
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=1;i<n;i++)
#define lpin(a,i,n) for(int i=0;i<n;i++){cin>>a[i];}

int main(){
  while(1){
    char x;
    int a=0,b=0,de[150],ch=0,f=0,it=0;
    if(f=0){
      f=1;
    }
    else  scanf("%c",&x);
    scanf("%c",&x);
    if(x=='.') break;
    while(1){
      if(x=='(') {
	a++;
	
	it++;
	de[it]=1;
      }
      if(x==')') {
	if(de[it]==1){
	  a--;
	  it--;
	}
	else{ch=1;}
      }
      if(x=='['){
	b++;
	it++;
	de[it]=2;
      }
      if(x==']'){
	if(de[it]==2){
	  b--;
	  it--;
	}
	else{ch=1;}
      }
      if(a<0 || b<0){
	ch=1;
      }
      scanf("%c",&x);
      if(x=='.') break;
    }
    if(ch==0 &&a==0 && b==0) cout<<"yes"<<endl;
    else cout<<"no"<<endl;
  }
  return 0;
}



Measured memory_bytes: 3164
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>

#include <stdio.h>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, k, n) for (int i = (k); i < (n); i++)
#define rrep(i, k, n) for (int i = (k); i >= (n); i++)
#define pb push_back
#define eb emplace_back
#define vec vector

typedef uint8_t   i8;
typedef uint16_t  i16;
typedef int       i32;
typedef long long i64;

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

const i64 inf = 1LL << 60;
const i32 mod = 1e9 + 7;

using namespace std;

/* Input variables. */
i32 n;
vec<i64> h;
vec<i64> dp;

/* Solve! */
void solve() {
  dp = vec<i64>(n, inf);
  dp[0] = 0;
  irep(i, 1, n) {
    chmin(dp[i], dp[i - 1] + abs(h[i - 1] - h[i]));
    if (i >= 2) chmin(dp[i], dp[i - 2] + abs(h[i - 2] - h[i]));
  }
  cout << dp[n - 1] << endl;
}

int main() {
  /* Input handling. */
  cin >> n;
  h = vec<i64>(n);
  rep(i, n) cin >> h[i];

  solve();
  return 0;
}

Measured memory_bytes: 1792