akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,0,v.size()-1)cout << v[i] << " ";cout << endl;
#define arrprint(v,n) rep(i,0,n-1)cout << v[i] << " ";cout << endl;
#define matprint(v,n,m) rep(i,0,n-1){rep(j,0,m-1){cout << v[i][j] << " ";}cout << endl;}
#define SORT(v) sort(v.begin(), v.end())
#define REV(v) reverse(v.begin(), v.end())
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
typedef long long ll;
typedef pair<int,int> P;
template<typename T>
using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>; //小さいものから取り出す

ll f(ll a,ll b, ll x){
    return (a*x)/b - a*(x/b);
}

int main(){
    ll a,b,n;
    cin >> a >> b >> n;

    if(n >= b-1){
        cout << a*(b-1)/b << endl;
        return 0;
    }
    cout << f(a,b,n) << endl;

    // ll l = 0,r = n;
    // int cnt = 1000000;
    // while(cnt--){
    //     ll c1,c2;
    //     c1 = (l*2+r)/3;
    //     c2 = (l+r*2)/3;
    //     if(f(a,b,c1)<f(a,b,c2)){
    //         l = c1;
    //     }else{
    //         r = c2;
    //     }
    // }
    // ll ans = 0;
    // rep(i,l,r)ans = max(ans,f(a,b,i));
    // cout << ans << endl;

    // cout << max(max(f(a,b,l),f(a,b,r)),f(a,b,(r+l)/2)) << endl;
    // cout << f(a,b,l) << " " << f(a,b,r) << endl;
    // cout << l << " " << r << endl;

//  printf("%.10f\n",ans);

    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int i,n,k,a[100000];
int gcd(int x,int y){return y?gcd(y,x%y):x;}
main(){
  int maxa=0,g=0;
  cin>>n>>k;
  for(i=0;i<n;i++){
    cin>>a[i];
    maxa=max(maxa,a[i]);
    g=gcd(g,a[i]);
  }
  if(k%g==0 && maxa>=k) cout<<"POSSIBLE"<<endl;
  else cout<<"IMPOSSIBLE"<<endl;
  return 0;

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,a,b)	for(int i=a;i<=b;i++)
#define rrep(i,a,b)	for(int i=a;i>=b;i--)
using namespace std;
typedef long long ll;
const int N=1e6+5,inf=0x3f3f3f3f;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin>>s;
	s[3]='8';
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int S;

    scanf("%d",&S);

    int h = S / 3600;
    int m = S % 3600 / 60;
    int s = S % 3600 % 60;

    printf("%d:%d:%d\n",h ,m ,s);

        return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
#define PB push_back
#define ZERO (1e-10)
#define INF int(1e9+1)
#define CL(A,I) (memset(A,I,sizeof(A)))
#define DEB printf("DEB!\n");
#define D(X) cout<<"  "<<#X": "<<X<<endl;
#define EQ(A,B) (A+ZERO>B&&A-ZERO<B)
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
#define IN(n) int n;scanf("%d",&n);
#define FOR(i, m, n) for (int i(m); i < n; i++)
#define F(n) FOR(i,0,n)
#define FF(n) FOR(j,0,n)
#define FT(m, n) FOR(k, m, n)
#define aa first
#define bb second
void ga(int N,int *A){F(N)scanf("%d",A+i);}

int main(void){
    IN(a)IN(b)printf("%d\n",a+b/2);
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;


public class Main {
	
	public static class FastReader {
		BufferedReader br;
		StringTokenizer st;
	

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (Exception r) {
					r.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());//converts string to integer
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception r) {
				r.printStackTrace();
			}
			return str;
		}
	}
	
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
    public static long mod = (long) (1e9+7);
    public final static int MAX = (int) 90000000;
  // static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
	   
	 FastReader sc = new FastReader();
	 int n = sc.nextInt(),m = sc.nextInt();
	 char[] s = sc.next().toCharArray();
	 char[] t = sc.next().toCharArray();
     out.print(solve(s,t,n,m));
	 out.close();
		
	}
	private static int gcd(int a, int b) {
		
		// TIME COMPLEXITY: O(Log(max(a,b)))
		if(a<b) return gcd(b,a);
		if(b==0) return a;
		else return gcd(b,a%b);
	}

private static long solve(char[] s, char[] t, int n, int m) {
	if(s[0] != t[0]) return -1;
	 long l = (1L*n*m)/gcd(n,m);
	 Map<Long,Character> map = new HashMap<>(); 
	 for(int i=1;i<=n-1;++i) {
		 long key = i*(l/n)+1;
		  map.put(key,s[i]);
	 }
	 for(int i=1;i<=m-1;++i) {
		 long key = i*(l/m)+1;
		  if(map.containsKey(key) && map.get(key)!=t[i]) {
			 
			  return -1;
		  }
	 }
	 
	return l;
		
		 
		
	
}

}

Measured memory_bytes: 33364
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
ll mod=1000000007;

int main() {
  int n;cin >>n;
  int sum=0;
  while(n>0){
    sum += n%10;
    n /=10;
  }
  if(sum==1) sum*=10;
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N, K;
  cin>>N>>K;
  int ans = 1;
  for(int i=0;i<N;++i) {
    if(ans*2<ans+K) ans *= 2;
    else ans += K;
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 3628
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int getLCS(char*, char*);
int C[1001][1001];

main(){
	char x[1001], y[1001];
	int q, i;

	scanf("%d", &q);
	for (i = 0; i < q; i++){
		scanf("%s%s", x, y);
		printf("%d\n", getLCS(x, y));
	}
	return 0;
}

int getLCS(char *x, char *y){
	int i, j, lenX, lenY, **C, *tmp, max;

	lenX = strlen(x);
	lenY = strlen(y);

	tmp = calloc((lenX + 1) * (lenY + 1), sizeof(int));
	C = malloc(sizeof(int *) * (lenX + 1));
	for (i = 0; i <= lenX; i++){
		C[i] = tmp + (lenY + 1)*i;
	}

	for (i = 0; i < lenX; i++){
		for (j = 0; j < lenY; j++){
			if (x[i] == y[j]) C[i + 1][j + 1] = C[i][j] + 1;
			else C[i + 1][j + 1] = ((C[i][j+1] > C[i+1][j])?  C[i][j+1] : C[i+1][j]);
		}
	}
	max = C[lenX][lenY];

	free(C);
	free(tmp);

	return max;
}

Measured memory_bytes: 4540
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
#include <cstring>
using namespace std;

using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

constexpr int M = 1000003;
int fact[M + 5], ifact[M + 5];
int mod_pow(int x, int n){
    int res = 1;
    while(n){
        if(n & 1)   res = (int)((ll)res * x % M);
        x = (int)((ll)x * x % M);
        n >>= 1;
    }
    return res;
}

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

    fact[0] = ifact[0] = 1;
    for(int i = 1; i < M; ++i)  fact[i] = (int)((ll)fact[i - 1] * i % M);
    ifact[M - 1] = mod_pow(M - 1, M - 2);
    for(int i = M - 1; i > 0; --i)  ifact[i - 1] = (int)((ll)ifact[i] * i % M);
    int Q;
    cin >> Q;
    for(int i = 0; i < Q; ++i){
        int x, d, n;
        cin >> x >> d >> n;
        if(d == 0){
            cout << mod_pow(x, n) << '\n';
            continue;
        }
        x = (int)((ll)x * mod_pow(d, M - 2) % M);
        if(x + n - 1 >= M){
            cout << 0 << '\n';
            continue;
        }
        int ans = (int)((ll)fact[x + n - 1] * ifact[x - 1] % M);
        ans = (int)((ll)ans * mod_pow(d, n) % M);
        cout << ans << '\n';
    }
}

Measured memory_bytes: 11456
use proconio::input;
use proconio::marker::Chars;
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused)]
const ALPHA_SMALL: [char; 26] = [
    'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
    't', 'u', 'v', 'w', 'x', 'y', 'z',
];
#[allow(unused)]
const ALPHA: [char; 26] = [
    'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
    'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
];
macro_rules! maxs {
    ($x:expr, $($y:expr), *) => {{
        let mut ret = $x;
        $(
            ret = max(ret, $y);
        )*
        ret
    }};
}
fn main() {
    input!(N: usize);
    let mut Ds = vec![vec![0; 7]; 7];
    let mut check = false;
    let mut tot = 0;
    let mut ans = "No";
    for _ in 0..N {
        input!((a, b): (usize, usize));
        if a == b {
            check = true;
            tot += 1;
        } else {
            check = false;
            tot = 0;
        }
        if tot >= 3 {
            ans = "Yes";
        }
    }

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


Measured memory_bytes: 2140
from sys import stdout
printn = lambda x: stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True # and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n = inn()
a = inl()
b = [ [0]*n for i in range(60) ]
acc = [ [0]*n for i in range(60) ]
sums = [0]*60
for bit in range(60):
    for i in range(n):
        b[bit][i] = (a[i]>>bit)&1
    acc[bit][n-1] = b[bit][n-1]
    for i in range(n-2,-1,-1):
        acc[bit][i] = acc[bit][i+1] + b[bit][i]
    for i in range(n-1):
        sums[bit] += acc[bit][i+1] if b[bit][i]==0 else \
                     (n-1-i-acc[bit][i+1])

x = 0
for bit in range(60):
    x = (x + sums[bit]*(2**bit)) % R
print(x)


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

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

int main() {
  ll n, k, ans = 0;
  cin >> n >> k;
  for (ll i = k; i <= n + 1; ++i) {
    ans += n * i - i * i + i + 1;
    ans = ans % MOD;
  }

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


Measured memory_bytes: 3628
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

import static java.lang.Integer.parseInt;

/**
 * Thread Tree
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;

		Main main = new Main();

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			int n = parseInt(line);
			Post[] posts = new Post[n + 1];
			posts[0] = main.new Post(0, "", -1);

			for (int i = 1; i <= n; i++) {
				int k = parseInt(br.readLine());
				String msg = br.readLine();
				posts[i] = main.new Post(i, msg, posts[k].depth + 1);
				posts[k].children.add(posts[i]);
			}

			System.out.print(posts[1].toString());

		} //end while
	} //end main

	class Post {
		Post parent;
		int id;
		String msg;
		int depth;
		List<Post> children;

		Post(int id, String msg, int depth) {
			this.id = id;
			this.msg = msg;
			this.depth = depth;
			children = new ArrayList<>();
		}

		public String toString() {
			StringBuilder ret = new StringBuilder();
			for (int i = 0; i < depth; i++) {
				ret.append('.');
			}
			ret.append(msg).append('\n');
			for (Post c : children) {
				ret.append(c.toString());
			}
			return ret.toString();
		}
	}
}

Measured memory_bytes: 588208
import java.io.PrintWriter
import java.util.*

val pw = PrintWriter(System.out)
val sc = Scanner(System.`in`)

fun main(args: Array<String>) {
    val H = sc.nextLong()
    val W = sc.nextLong()
    println(pp2020(H, W))
}

fun pp2020(H: Long, W: Long): Long {
    var ans = 0L
    if(H == 1L){
        ans = 1L
    }else if(W == 1L){
        ans = 1L
    }else if(H*W%2 == 0L){
        ans = H*W/2
    }else {
        ans = H*W/2 + 1
    }
    return ans
}


fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextListOfString() = next().split(" ")
fun nextListOfInt() = nextListOfString().map { it.toInt() }
fun nextListOfLong() = nextListOfString().map { it.toLong() }
fun nextListOfDouble() = nextListOfString().map { it.toDouble() }



Measured memory_bytes: 31260
from collections import Counter

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

def prime_factorization(n):
    factor = []
    f = 2
    while f ** 2 <= n:
        if n % f == 0:
            factor.append(f)
            n //= f
        else:
            f += 1
    if n > 1:
        factor.append(n)
    return factor

p = prime_factorization(P)
c = Counter(p)

l = []
j = []
for k, v in c.items():
    if N <= v:
        l.append(k)
        j.append(v//N)
ans = 1

for i,v in zip(l,j):
    ans *= i**v

print(ans)

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

using namespace std;

#define all(x) x.begin(), x.end()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;

const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;

int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }

int r[205][205], n, s, t;
vi g[205], P;

void process(int u, int v, int w){
	g[u].push_back(v), g[v].push_back(u);
	r[u][v] += w;
}

bool AP(){
	queue <int> q;
	q.push(s);
	P.assign(2 * n + 5, -1);
	while(!q.empty()){
		int k = q.front();
		q.pop();
		if(k == t) return true;
		for(int x : g[k]){
			if(P[x] == -1 && r[k][x] > 0){
				P[x] = k;
				q.push(x);
			}
		}
	}
	return false;
}

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

	cin >> n;
	ii red[101], blue[101];
	s = 0, t = 2 * n + 1;
	for(int i = 0; i < n; i++){
		cin >> red[i].first >> red[i].second;
	}
	for(int i = 0; i < n; i++){
		cin >> blue[i].first >> blue[i].second;
	}
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			if(red[i].first < blue[j].first && red[i].second < blue[j].second){
				process(i + 1, n + j + 1, mod);
			}
		}
	}
	for(int i = 0; i < n; i++){
		process(s, i + 1, 1);
		process(n + i + 1, t, 1);
	}
	int mf = 0;
	while(AP()){
		int aug = mod;
		for(int x = t; x != s; x = P[x]){
			aug = min(aug, r[P[x]][x]);
		}
		for(int x = t; x != s; x = P[x]){
			r[P[x]][x] -= aug;
			r[x][P[x]] += aug;
		}
		mf += aug;
	}
	cout << mf;
}

Measured memory_bytes: 512
use v5.18; # strict say state
use warnings;
use List::Util qw(reduce first max min sum0);

my ($n, $a, $b) = split / /, <STDIN>;

my $c = $a + $b - 1;
if ($c%2==1) {
  say abs($b-$a) / 2;
} elsif ($c < 2*$n-$c) {
  say $c/2;
} else {
  say ((2*$n-$c)/2);
}

Measured memory_bytes: 768
N = int(input())
A = list(map(int, input().split()))

dp = [{} for _ in range(N + 2)]
dp[0][0] = 0
dp[-1][0] = 0

for i in range(1, N + 1):
    f = (i - 1) // 2
    t = (i + 1) // 2
    for j in range(f, t + 1):
        var1 = dp[i - 2][j - 1] + A[i - 1] if j - 1 in dp[i - 2] else -float('inf')
        var2 = dp[i - 1][j] if j in dp[i - 1] else -float('inf')
        dp[i][j] = max(var1, var2)

print(dp[N][N // 2])


Measured memory_bytes: 140468
n = gets.to_i
vv = gets.split.map(&:to_i).sort

made_arr = []

target = vv.shift
target2 = vv.shift
while(true) do
  made_arr << 1.000000 * (target + target2)/ 2

  break if made_arr.size + vv.size == 1
  made_arr.sort!

  if made_arr.size==0
    target = vv.shift
    target2 = vv.shift
    next
  elsif vv.size==0
    target = made_arr.shift
    target2 = made_arr.shift
    next
  end

  if made_arr.first < vv.first
    target = made_arr.shift
    if made_arr.size==0
      target2 = vv.shift
    elsif vv.size==0
      target2 = made_arr.shift
    elsif made_arr.first < vv.first
      target2 = made_arr.shift
    else
      target2 = vv.shift
    end
  else
    target = vv.shift
    if made_arr.size==0
      target2 = vv.shift
    elsif vv.size==0
      target2 = made_arr.shift
    elsif made_arr.first < vv.first
      target2 = made_arr.shift
    else
      target2 = vv.shift
    end
  end
end

puts made_arr.first


Measured memory_bytes: 1788
# -*- coding: utf-8 -*-

import sys
from itertools import accumulate

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N = INT()
A = LIST()
B = LIST()

S1 = []
S2 = []
for i in range(3):
    if A[i] < B[i]:
        S1.append(i)
    else:
        S2.append(i)
        A[i], B[i] = B[i], A[i]

def calc(cnt, i):
    d, m = divmod(cnt, A[i])
    return d * B[i] + m

def count(S, N):
    if len(S) == 0:
        return N
    elif len(S) == 1:
        return calc(N, S[0])
    elif len(S) == 2:
        res = 0
        for x in range(N+1):
            y = N - x
            if y < 0:
                break
            cnt = calc(x, S[0]) + calc(y, S[1])
            res = max(res, cnt)
        return res
    else:
        res = 0
        for x in range(N+1):
            for y in range(N+1):
                z = N - x - y
                if z < 0:
                    break
                cnt = calc(x, S[0]) + calc(y, S[1]) + calc(z, S[2])
                res = max(res, cnt)
        return res

N2 = count(S1, N)
ans = count(S2, N2)
print(ans)


Measured memory_bytes: 41948
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

int main(void) {
    int N, p;
    cin >> N;
    string ANS = "YES"; 
    int count = 0;
    for(int i=1; i<=N; i++) {
        cin >> p;
        if (p != i) {
            count++;
        }
        if (count > 2) {
            ANS = "NO";
            break;
        }
    }
    cout << ANS;
}


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

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;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  ll n, m;
  cin >> n >> m;
  vector <pair <ll, ll>> v(m, pair <ll, ll> ());
  map <ll, ll> score;
  map <pair <ll, ll>, ll> tmp;
  vector <pair <ll, ll>> u(m, pair <ll, ll> ());
  rep(i, m) {
    ll a, b;
    cin >> a >> b;
    pair <ll, ll> p = make_pair(a, b);
    v.at(i) = p;
    u.at(i) = p;
  }
  sort(u.begin(), u.end());
  rep(i, m) {
    if (score.count(u.at(i).first)) {
      score.at(u.at(i).first)++;
      tmp[u.at(i)] = score.at(u.at(i).first);
    } else {
      score[u.at(i).first] = 1;
      tmp[u.at(i)] = 1;
    }
  }
  rep(i, m) {
    ll p = v.at(i).first, x = tmp.at(v.at(i));
    string s = to_string(p), t = to_string(x);
    rep(j, 6-s.size()) cout << 0;
    cout << p;
    rep(j, 6-t.size()) cout << 0;
    cout << x << endl;
  }
}

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

int main()
{
	int s;
	string strs[4] = {"maerd","remaerd","esare","resare"};
	string str;
	cin >> str;
	reverse(str.begin(), str.end());

	int beforelen = str.length();
	bool isfirst = true;
	int count = 0;
	while (count++ < 100000)
	{
		if (str.length() == beforelen && !isfirst)
			break;
		isfirst = false;
		if (str.length() < 5)
			break;
		string ss = str.substr(0,5);
		if (ss == strs[0] || ss == strs[2]) {
			str.erase(0,5);
			continue;
		}
		if (str.length() < 6)
			break;
	    ss = str.substr(0, 6);
		if (ss == strs[3]) {
			str.erase(0, 6);
			continue;
		}
		if (str.length() < 7)
			break;
		ss = str.substr(0,7);
		if (ss == strs[1])
		{
			str.erase(0,7);
			continue;
		}
		
	}
	if (str.length() == 0)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 512
H, W, D = map(int, input().split())
A_where = [0] * (H*W+1)
A_where[0] = (-1, -1)
for p in range(H):
    A = list(map(int, input().split()))
    for q in range(W):
        A_where[A[q]] = (p, q)

Q = int(input())

DP = [0] * (H*W+1)

for i in range(D+1, H*W+1):
    y1, x1 = A_where[i]
    y2, x2 = A_where[i-D]

    DP[i] = DP[i-D] + abs(y1-y2) + abs(x1-x2)

for i in range(Q):
    l, r = map(int, input().split())
    print(DP[r] - DP[l])


Measured memory_bytes: 58908
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  string s;
  cin >> s;
  deque<char> q;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == 'B') {
      if (!q.empty()) q.pop_back();
    } else {
      q.push_back(s[i]);
    }
  }
  while (!q.empty()) {
    cout << q.front();
    q.pop_front();
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;

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

	string s;
	cin >> s;
	if(s[0] == s[2]){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}


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

const int mod = 1e9 + 7;
const int MN = 222;

int N, M;
char G[MN][MN];
int chk[MN][MN];
vector<int> R, C;

int main() {
    scanf("%d %d", &N, &M);

    for(int i = 0; i < N; i++) {
        scanf("\n");
        for(int j = 0; j < M; j++) {
            scanf("%c", &G[i][j]);
        }
    }

    int ans = 1;
    if(N % 2) {
        int found = 0;
        for(int i = 0; i < M / 2; i++) if(G[N / 2][i] != G[N / 2][M - 1 - i]) {
            found = 1;
            break;
        }
        if(found) ans = 1LL * ans * 2 % mod;
    }
    if(M % 2) {
        int found = 0;
        for(int i = 0; i < N / 2; i++) if(G[i][M / 2] != G[N - 1 - i][M / 2]) {
            found = 1;
            break;
        }
        if(found) ans = 1LL * ans * 2 % mod;
    }

    for(int i = 0; i < N / 2; i++) {
        for(int j = 0; j < M / 2; j++) {
            vector<char> X;
            unordered_map<char, int> dx;
            X.push_back(G[i][j]);
            X.push_back(G[N - 1 - i][j]);
            X.push_back(G[i][M - 1 - j]);
            X.push_back(G[N - 1 - i][M - 1 - j]);
            sort(X.begin(), X.end());
            X.resize(unique(X.begin(), X.end()) - X.begin());
            for(int i = 0; i < X.size(); i++) dx[X[i]] = i;

            vector<int> cnt(4, 0);
            for(int a = 0; a < 2; a++) for(int b = 0; b < 2; b++) cnt[ dx[ G[ a? i : N - 1 - i ][ b? j : M - 1 - j ] ] ]++;

            if(X.size() == 4) {
                R.push_back(i);
                C.push_back(j);
                ans = 1LL * ans * 12 % mod;
            }
            else {
                int tmp = 24;
                for(int a = 0; a < 4; a++) for(int b = 1; b <= cnt[a]; b++) tmp /= b;
                ans = 1LL * ans * tmp % mod;
            }
        }
    }

    sort(R.begin(), R.end());
    sort(C.begin(), C.end());
    R.resize(unique(R.begin(), R.end()) - R.begin());
    C.resize(unique(C.begin(), C.end()) - C.begin());

    for(int i = 0; i < (int)R.size() + (int)C.size() - 1; i++) ans = 1LL * ans * 2 % mod;
    cout << ans;
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<iomanip>

using namespace std;
using ll = long long;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  double L; cin >> L;
  cout << fixed << setprecision(16) << L/3.0 * L/3.0 * L/3.0 << endl;

  // end-----------------------------------------------
  // cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}


Measured memory_bytes: 256
import sys

ni = lambda: int(sys.stdin.readline().rstrip())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())
ns = lambda: sys.stdin.readline().rstrip()

o = list(ns())
e = list(ns())
ans = ''
for i in range(len(e)):
    ans += o[i] + e[i]
if len(o) > len(e):
    ans += o[-1]
print(ans)


Measured memory_bytes: 3064
#include<stdio.h>
#include<math.h>

int main()
{
    float c;
    int a, b, d, e, i;
    scanf("%d %d",&a,&b);
    d = 0;
    for(i=b;i!=0;i/=10)
        d++;
    e = sqrt(a * pow(10,d)+b);
    c = sqrt(a * pow(10,d)+b);
    if(c==e)
        printf("Yes");
    else
        printf("No");
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;

public class Main
{

  static class CharComparatorA implements Comparator<Character>
  {
    @Override
    public int compare(Character o1, Character o2)
    {
      return o1.compareTo(o2);
    }
  }

  static class CharComparatorD implements Comparator<Character>
  {
    @Override
    public int compare(Character o1, Character o2)
    {
      return o2.compareTo(o1);
    }
  }

  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    String s = r.readLine();
    String t = r.readLine();
    ArrayList<Character> sa = new ArrayList<Character>();
    ArrayList<Character> ta = new ArrayList<Character>();

    for(int i = 0; i < s.length(); i++)
    {
      sa.add(s.charAt(i));
    }

    for(int i = 0; i < t.length(); i++)
    {
      ta.add(t.charAt(i));
    }

    Collections.sort(sa, new CharComparatorA());
    Collections.sort(ta, new CharComparatorD());

    s = "";
    t = "";
    
    for(Character c : sa)
    {
      s += c;
    }
    
    for(Character c : ta)
    {
      t += c;
    }
    
    System.out.println(s.compareTo(t) < 0 ? "Yes" : "No");

  }

}


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

signed main() {

    int h, w, x, y;
    cin >> w >> h >> x >> y;
    bool flg = (x*2 == w) && (y*2 == h);
    printf("%lf %d\n", (double)h*(double)w/2.0, flg);

    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def Yes(): print("Yes"); return
def No(): print("No"); return

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def Base_10_to_n(X, n):
  if X//n:
    return Base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def Base_n_to_10(X, n):
  return sum(int(str(X)[-i])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############

A,B = inputIL()
S = inputS()

num = ["0","1","2","3","4","5","6","7","8","9",]

if len(S) != A+B+1:
  No()
  exit()
for i in range(A):
  if S[i] not in num:
    No()
    exit()
if S[A] != "-":
    No()
    exit()
for i in range(A+1,A+B+1):
  if S[i] not in num:
    No()
    exit()  
Yes()

Measured memory_bytes: 38384
from collections import deque


def upd(a, b, v):
    global N
    dp[a][b] = max(dp[a][b], v)
    dp[b][a] = max(dp[b][a], v)
    dp[N][a] = max(dp[N][a], v)
    dp[N][b] = max(dp[N][b], v)
    dp[a][N] = max(dp[a][N], v)
    dp[b][N] = max(dp[b][N], v)
    dp[N][N] = max(dp[N][N], v)


N = int(input())
A = list(map(lambda x: int(x) - 1, input().split()))

INF = 1 << 32
dp = [[-INF] * (N + 1) for _ in range(N + 1)]
upd(A[0], A[1], 0)
base = 0

for i in range(2, 3 * N - 1, 3):
    x, y, z = A[i], A[i + 1], A[i + 2]
    if x == y == z:  # x, y, z 3文字すべて等しいとき
        base += 1
    else:
        q = deque()
        for _ in range(3):
            # a, b, x, y, z のうち, b, y, z を消すとき
            for k in range(N):
                v = dp[k][N]
                if y == z:
                    v = max(v, dp[k][y] + 1)
                q.append((k, x, v))
            # a, b, x, y, z のうち, a, b, z を消すとき
            v = max(dp[z][z] + 1, dp[N][N])
            q.append((x, y, v))
            # x, y, z をローテート
            x, y, z = z, x, y
        while q:
            a, b, v = q.popleft()
            upd(a, b, v)

l = A[-1]
ans = max(dp[N][N], dp[l][l] + 1)
print(ans + base)


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

int main(){
	string s;cin >> s;
  	map<char,int> a;
  	for(int i=0;i<4;i++)a[s[i]]++;
  	if(a.size()==2){
    	if(a.begin()->second && next(a.begin(),1)->second){
        	cout <<"Yes";
          	return 0;
        }
    }
  	cout << "No";
  
  	return 0;
}

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

#define endl "\n"
#define int long long
#define vec(x) vector<x>
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pair<int,int>>
#define matrix(x) vector<vector<x>>
#define all(v) v.begin(),v.end()
#define mem(a,b) memset(a, b, sizeof a)
#define setBits(n) __builtin_popcountll(n)
#define prec(n) fixed<<setprecision(n)
#define ff first
#define ss second
#define print(x) for(auto it:x) cout<<it<<" ";
#define dbg(x) cerr<<#x<<" :: "<<x<<endl;
#define dbg2(x,y) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
const int INF = 1e9;
const int MOD = 1e9 + 7; 
const double pi = acos(-1);
int power(int a,int b,int m=MOD)
{int ans=1;while(b>0){if(b&1)ans=(ans*a)%m;a=(a*a)%m;b>>=1;}
return ans;}
int dir[]={-1, 0, 1, 0, -1};
int dx[]={1,1,0,-1,-1,-1, 0, 1};
int dy[]={0,1,1, 1, 0,-1,-1,-1};

const int N = 1e5+1;

void lcs(string s1,string s2)
{
    int i,j,m=s1.size(),n=s2.size();
    int dp[m+1][n+1];
    for(i=0;i<=m;i++)
    for(j=0;j<=n;j++)
    {
        if(i==0 or j==0)
        dp[i][j]=0;
        else if(s1[i-1]==s2[j-1])
        dp[i][j]=1+dp[i-1][j-1];
        else
        dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
    }
	int ind=dp[m][n];
	char s[ind+1];
	s[ind]='\0';
	i=m,j=n;
	while(i>0 and j>0)
	{
		if(s1[i-1]==s2[j-1])
		{
			s[ind-1]=s1[i-1];
			ind--;i--;j--;
		}
		else if(dp[i-1][j]>dp[i][j-1])
		i--;
		else
		j--;
	}
	cout<<s<<endl;
}

void solve()
{
	string s1,s2;
	cin>>s1>>s2;
    lcs(s1,s2);
}

int32_t main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	int t;
	t=1;
	//cin>>t;
	while(t--)
		solve();
}

Measured memory_bytes: 70656
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
Int grundy(Int a,Int k){
  if(a<k) return 0;
  if(k==1) return a;
  if(a%k==0) return a/k;
  Int d=a-(a*(k-1)/k);
  Int l=0,r=a/d+1;
  while(l+1<r){
    Int m=(l+r)>>1;
    Int b=a-d*m;
    Int c=b-(b*(k-1)/k);
    if(d==c) l=m;
    else r=m;
  }
  return grundy(a-d*r,k);
};

signed main(){
  Int n;
  cin>>n;
  Int ans=0;
  for(Int i=0;i<n;i++){
    Int a,k;
    cin>>a>>k;
    ans^=grundy(a,k);
  }
  cout<<(ans?"Takahashi":"Aoki")<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdio>
using namespace std ;
int main(){
    int a,b,c,i,n;
    int d;
    int arr[500];
    cin>>a>>b>>n;
    int e = 0;
    for(i=a;i<=b;i++){
        if(e<n){
            arr[e] = i;
            e++;
        }
        else{
            break;
        }
    }
    int j=0;
    for(i = b;i >= a;i--){
        if(j<n){
            arr[e] = i;
            j++;
            e++;
        }
        else{
            break;
        }
    }
    sort(arr,arr+e);
    cout<<arr[0]<<endl;
    for(i = 1;i < e;i++){
        if(arr[i]!=arr[i-1]){
            cout<<arr[i]<<endl;
        }
    }
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
  int N, tmp, p[10], max = 0, sum = 0;

  cin >> N;
  for(int i = 0; i < N; i++)
    cin >> p[i];

  for(int i = 0; i < N; i++){
    if(p[i] > max){
      max = p[i];
      tmp = i;
    }
  }

  for(int i = 0; i < N; i++){
    if(i != tmp)
      sum += p[i];
    else
      sum += p[i] / 2;
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 256
n = int(input())
dish = list(map(lambda x: int(x), input().split()))
utility = list(map(lambda x: int(x), input().split()))
bonus = list(map(lambda x: int(x), input().split()))

pre_dish = -1
ans = 0
for i in range(n):
    ans += utility[dish[i] - 1]
    if pre_dish == dish[i] - 1:
        ans += bonus[pre_dish - 1]
    pre_dish = dish[i]
    
print(ans)

Measured memory_bytes: 38384
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N, M;
  cin>>N>>M;
  vector<vector<int> > edge(N);
  int u, v;
  for(int i=0;i<M;++i) {
    cin>>u>>v;
    u--;
    v--;
    edge[u].push_back(v);
  }
  int S, T;
  cin>>S>>T;
  S--;
  T--;
  queue<pair<int, int> > que;
  que.push(mp(S, 0));
  pair<int, int> state;
  map<pair<int, int>, int> amap;
  for(int i=0;i<N;++i) {
    for(int j=0;j<3;++j) {
      amap[mp(i, j)] = -1;
    }
  }
  while(!que.empty()) {
    state = que.front();que.pop();
    if(amap[mp(state.fi, state.se%3)]>-1) continue;
    amap[mp(state.fi, state.se%3)] = state.se;
    for(int i=0;i<edge[state.fi].size();++i) {
      if(amap[mp(edge[state.fi][i], (state.se+1)%3)]>-1) continue;
      que.push(mp(edge[state.fi][i], (state.se+1)));
    }
  }
  if(amap[mp(T, 0)]==-1) cout<<-1<<endl;
  else cout<<amap[mp(T, 0)]/3<<endl;
}



Measured memory_bytes: 27556
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

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

    ll ans = 0;
    vector<bool> exi(26, false);
    rep(i, n - 1) {
        ll cnt = 0;
        for (ll j = 0; j <= i; j++) {
            exi[(ll)(s[j] - 'a')] = true;
        }
        for (ll j = i + 1; j < n; j++) {
            if (exi[(ll)(s[j] - 'a')] == true) {
                cnt++;
                exi[(ll)(s[j] - 'a')] = false;
            }
        }
        chmax(ans, cnt);
    }

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

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;int main() {
  int N, a = 0;
  cin >> N;
  vector<int> vec(N);
  for(int i = 0; i < N; i++){
    cin >> vec.at(i);
  }
  for(int i = 0; i < N; i++){
    if(vec.at(i) == a+1){
      a++;
    }
  }
  if(a == 0){
    cout << -1;
  }
  else{
    cout << vec.size() - a;
  }
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
using namespace std;
 
#define PB(x)	push_back(x)
#define ALL(x)	(x).begin(), (x).end()
#define ALLR(x)	(x).rbegin(), (x).rend()
#define MP(x)	make_pair(x)
 
#define debug(_x)		cerr << #_x << '=' << _x << endl;
#define debug2(_x, _y)	cerr << #_x << '=' << _x << ' ' << #_y << '=' << _y << endl;
#define debugn(_a)		cerr << #_a << ": "; for (const auto _x: _a) cerr << _x << ' '; cerr << endl;
 
#define FAST_IO ios::sync_with_stdio(false); cin.tie(0)
 
#define int long long int
 
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef unsigned long long ull;
 
const int INF = LONG_LONG_MAX>>1;
const int NINF = LONG_LONG_MIN;

int32_t main() {
	FAST_IO;
	
	int N, W;
	cin >> N >> W;
	int w[N]; 
	int v[N];
	for (int i = 0; i < N; i++) cin >> w[i] >> v[i];
	int V = 0;
	for (int i = 0; i < N; i++) V += v[i];
	int dp[N+1][V+1];
	//debug(V);
	for (int i = 0; i <= N; i++)
		for (int j = 0; j <= V; j++) dp[i][j] = INF;
		
	for (int i = 1; i <= N; i++)
		for (int j = 0; j <= V; j++) {
			if (v[i-1] >= j) {
				dp[i][j] = min(dp[i-1][j], w[i-1]);
			} else {
				dp[i][j] = min(dp[i-1][j], dp[i-1][j-v[i-1]] + w[i-1]);
			}
		}
	
	int ans;
	for (int i = V; i >= 0; i--) {
		if (dp[N][i] <= W) {
			ans = i;
			break;
		}
	}
	cout << ans << endl;
}
// g++ -Wall -Wextra -Wshadow -fsanitize=undefined


Measured memory_bytes: 79232
#!venv/bin/python
 
import math
import numpy as np
import random
import copy
import statistics 
import bisect
import heapq
from collections import defaultdict 
import time
import sys

WARU = 1000000007

N, M = [ int(x) for x in input().split() ]
A = {}
for i in range(M):
    A[int(input())] = 1

ans = [None for i in range(N + 1)]
ans[0] = 1
ans[1] = 1
for a in A:
    ans[a] = 0

for i in range(N):
    n = i + 1
    if ans[n] is not None:
        continue
    ans[n] = (ans[n-2] + ans[n-1]) % WARU


print(ans[N])


Measured memory_bytes: 26116
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<ll> V;
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)

int main(){

    ll K, T;
    cin >> K >> T;
    V v(T);
    rep(i, T)cin >> v[i];
    ll ans = *max_element(v.begin(), v.end()) * 2 - accumulate(v.begin(), v.end(), 0) - 1;
    cout << max(ans, 0LL) << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>


int permutation(int *a, int n) {
    bool *b = new bool[n];
    for (int i=0;i<n;++i){
        b[i] = false;
    }
    int sign = 1;
    for (int i=0;i<n;++i) {
        int j = i;
        while (!b[j]) {
            b[j] = true;
            j = a[j];
            if (b[j]) {
                break;
            }
            sign *= -1;
        }
    }
    delete [] b;
    return sign;
}

void flip(int *a, int i) {
    int tmp = a[i-1];
    a[i-1] = -a[i+1];
    a[i] = -a[i];
    a[i+1] = -tmp;
}

void try_sort(int * a, int n) {

}

int main() {
    int n;
    {
        std::string buf;
        std::getline(std::cin, buf);
        std::istringstream iss(buf);
        iss >> n;
    }
    int* a1 = new int[n];
    {
        std::string buf;
        std::getline(std::cin, buf);
        std::istringstream iss(buf);
        for (int i=0;i<n;++i) {
            int xx;
            iss >> xx;
            a1[i] = xx;
        }
    }
    int* a2 = new int[n];
    {
        std::string buf;
        std::getline(std::cin, buf);
        std::istringstream iss(buf);
        for (int i=0;i<n;++i) {
            int xx;
            iss >> xx;
            a2[i] = xx;
        }
    }
    int* a3 = new int[n];
    {
        std::string buf;
        std::getline(std::cin, buf);
        std::istringstream iss(buf);
        for (int i=0;i<n;++i) {
            int xx;
            iss >> xx;
            a3[i] = xx;
        }
    }
    int *a = new int [n];
    for (int i=0;i<n;++i) {
        if (a1[i] < a3[i]) {
            if (a3[i] != a1[i]+2 || a2[i] != a1[i]+1) {
                std::cout << "No" << std::endl;
                return 0;
            }
            a[i] = a1[i] / 3 + 1;
        } else {
            if (a1[i] != a3[i]+2 || a2[i] != a3[i]+1) {
                std::cout << "No" << std::endl;
                return 0;
            }
            a[i] = - (a3[i] / 3 + 1);
        }
    }
    int *evens = new int[n/2];
    int *odds = new int[n/2 + n%2];
    int even_sign = 1;
    int odd_sign = 1;
    for (int i = 0; i < n; ++i) {
        if (i%2 == 0) {
            if (a[i]%2 == 0) {
                std::cout << "No" << std::endl;
                return 0;
            }
            if (a[i] > 0) {
                odds[i/2] = a[i]/2;
            } else {
                odds[i/2] = -a[i]/2;
                odd_sign *= -1;
            }
        } else {
            if (a[i]%2 == 1) {
                std::cout << "No" << std::endl;
                return 0;
            }
            if (a[i] > 0) {
                evens[i/2] = a[i]/2 - 1;
            } else {
                evens[i/2] = -a[i]/2 - 1;
                even_sign *= -1;
            }
        }
    }

    if (permutation(odds, n/2 +n%2) == even_sign && permutation(evens, n/2) == odd_sign) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }
    return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;

int main(){
	ll n; cin >>n;
	bool a=true;
	ll cnt=n;
	ll num=0;
	while(cnt>9){
		if(cnt%10!=9){
			a=false;
		}
		cnt/=10;
		num++;
	}
	cout << cnt+num*9+(a?0:-1)<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<string>
#include<vector>
using namespace std;

int main(void){
	int x, a, b;
	cin >> x >> a >> b;
	x -= a;
	while (x - b >= 0) {
		x -= b;
	}
	cout << x;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<algorithm>
using namespace std;

int main(void)
{
	int N;
	cin >> N;

	vector<int> n;
	for(int i=1; i<10; i++)
		n.push_back(i * 111);

	cout << *lower_bound(n.begin(), n.end(), N) << endl;

	return 0;
}


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

const int N = 8;
const int FREE = -1;
const int NOT_FREE = 1;

int row[N], col[N], dpos[2*N-1], dneg[2*N-1];
int G[N][N];

void printBoard()
{
    for(int i=0; i<N; i++)
    {
        for(int j=0; j<N; j++)
        {
            if(G[i][j] && row[i]!=j)
                return;
        }
    }
    for(int i=0; i<N; i++)
    {
        for(int j=0; j<N; j++)
        {
            if(row[i]==j)
                cout << "Q";
            else
                cout << ".";
        }
        cout << endl;
    }
}
void recursive(int i)
{
    if(i==N)
    {
        printBoard();

        return;
    }

    for(int j=0; j<N; j++)
    {
        if(col[j]==NOT_FREE || dpos[i+j]==NOT_FREE || dneg[i-j+N-1]==NOT_FREE)
            continue;
        row[i] = j;

        col[j] = dpos[i+j] = dneg[i-j+N-1] = NOT_FREE;
        recursive(i+1);

        row[i] = col[j] = dpos[i+j] = dneg[i-j+N-1] = FREE;
    }
}

int main()
{
    int k, sr, sc;
    cin >> k;
    memset(row, FREE, sizeof(row));
    memset(col, FREE, sizeof(col));
    memset(dpos, FREE, sizeof(dpos));
    memset(dneg, FREE, sizeof(dneg));
    memset(G, 0, sizeof(G));
    for(int i=0; i<k; i++)
    {
        cin >> sr >> sc;
        G[sr][sc] = 1;
    }
    recursive(0);
    return 0;
}



Measured memory_bytes: 3104
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

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

ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}

//-----------------------ここから-----------

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

    vector<pair<int,int>> a(n);
    for(int i = 1; i <= n; i++){
        int tmp;
        cin >> tmp;

        a[i - 1] = make_pair(tmp, i);
    }

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

    for(int i = 0; i < n; i++){
        cout << a[i].second << " ";
    }

    cout << endl;

    
}


Measured memory_bytes: 1536
N = int(input())
ac_counter = 0
wa_counter = 0
tle_counter = 0
re_counter = 0
for i in range(N):
    current = input()
    if current == 'AC':
        ac_counter += 1
    if current == 'WA':
        wa_counter += 1
    if current == 'TLE':
        tle_counter += 1
    if current == "RE":
        re_counter += 1
print("AC x " + str(ac_counter))
print("WA x " + str(wa_counter))
print("TLE x " + str(tle_counter))
print("RE x " + str(re_counter))



Measured memory_bytes: 9144