akhauriyash/Code-Regression huggingface dataset:
use std::io;
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let a: String = iter.next().unwrap().parse().unwrap();
    let b: String = iter.next().unwrap().parse().unwrap();
    let c: String = iter.next().unwrap().parse().unwrap();
    let mut abc: String = "".to_string();
    abc.push( a.chars().nth(0).unwrap() );
    abc.push( b.chars().nth(0).unwrap() );
    abc.push( c.chars().nth(0).unwrap() );
    let ABC = abc.to_uppercase();
    println!("{}", ABC);
}


Measured memory_bytes: 4352
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <numeric>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<((x))<<endl
#define fi first
#define se second

#define INF 147483600

int d[10][10];
bool exist[10];

int main(){
  int n;
  while(cin>>n ,n){
    fill(d[0], d[10], INF);
    fill(exist, exist+10, false);
    rep(i,10) d[i][i]=0;
    rep(i,n){
      int a,b,c;
      scanf("%d %d %d", &a, &b, &c);
      d[a][b]=c;
      d[b][a]=c;
      exist[a]=true;
      exist[b]=true;
    }

    rep(k,10) rep(i,10) rep(j,10) d[i][j] = min(d[i][j], d[i][k]+d[k][j]);

    int res=0;
    int best=INF;
    rep(i,10) if(exist[i]){
      int tmp=0;
      rep(j,10) if(exist[j]) tmp += d[i][j];
      if(tmp < best){
        best = tmp;
        res = i;
      }
    }

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

Measured memory_bytes: 3148
/* Filename: ARC062D.java
 * Author: Mushiyo
 */

import java.util.Scanner;

public class Main{

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

		while (input.hasNext()) {
			String S = input.next();

			int countP = 0, countG = 0;
			int win = 0, lose = 0;
			for (int i = 0; i < S.length(); ++i) {
				if (countP + 1 <= countG) {
					++countP;

					if (S.charAt(i) == 'g') {
						++win;
					}
					
				} else {
					++countG;
					
					if (S.charAt(i) == 'p') {
						++lose;
					}
				}
			}

			System.out.println(win - lose);
		}
	}

}


Measured memory_bytes: 13036
#define _DEBUG
#include "bits/stdc++.h"
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#ifdef _DEBUG
#define debug(...) CHOOSE((__VA_ARGS__,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
#else
#define debug(...)
#endif
#define rep(index,num) for(int index=0;index<(int)num;index++)
#define rep1(index,num) for(int index=1;index<=(int)num;index++)
#define brep(index,num) for(int index=(int)num-1;index>=0;index--)
#define brep1(index,num) for(int index=(int)num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=(ll)1e+18+1;
int INF=1e+9+1;
int main(){
	int a,b;
	scan(a>>b);
	prin(a*b);
	return 0;
}


Measured memory_bytes: 3632
N = int(input())
Plist = []
i=1
print(" ",end="")
while i <= N:
    k=1
    if i%3 == 0:
        Plist.append(i)
    elif i%10 == 3:
        Plist.append(i)
    else:
        while i//k>1 and k>=0:
            if i//k%10 == 3:
                Plist.append(i)
                break
            else:
                k = k*10
    i=i+1
print(' '.join(map(str,Plist)))

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

using namespace std;

const int OO = 1e9;
const double EPS = 1e-9;

#define ndl cout << '\n'
#define sz(v) int(v.size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define present(a, x) (a.find(x) != a.end())
#define db(x) cout << "> " << #x << " = " \
	<< (x) << '\n'
#define db2(x, y) cout << "> " << #x << " = " \
	<< (x) << ", " << #y << " = " << (y) << '\n'
#define db3(x, y, z) cout << "> " << #x << \
	" = " << (x) << ", " << #y << " = " << \
	(y) << ", " << #z << " = " << (z) << '\n'

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<vector<int>> vvi;
typedef map<int, int> mii;
typedef set<int> si;

const int MX = 1005;
int h, w, white;
char grid[MX][MX];
set<pii> currClass;
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};

bool valid(int i, int j) {
	return i >= 0 && i < h && j >= 0 && j < w;
}

int main() {
	ios::sync_with_stdio(false);
	cout.precision(10);
	cin >> h >> w;
	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			cin >> grid[i][j];
		}
	}
	white = h * w;
	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			if (grid[i][j] == '#') {
				--white;
				for (int k = 0; k < 4; ++k) {
					int to_x = i + dx[k], to_y = j + dy[k];
					if (valid(to_x, to_y) && grid[to_x][to_y] == '.')
						currClass.insert({to_x, to_y});
				}
			}
		}
	}
	int ans = 0;
	while (white) {
		++ans;
		set<pii> nxtClass;
		for (auto& pr : currClass) {
			int x = pr.fs, y = pr.sc;
			grid[x][y] = '#';
			--white;
			for (int k = 0; k < 4; ++k) {
				int to_x = x + dx[k], to_y = y + dy[k];
				if (valid(to_x, to_y) && grid[to_x][to_y] == '.' && !present(currClass, mp(to_x, to_y)))
					nxtClass.insert({to_x, to_y});
			}
		}
		currClass = nxtClass;
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 32256
from collections import deque
import sys

if __name__ == '__main__':
    n = int(input())
    d = deque()

    for command in sys.stdin.readlines():

        if command.startswith("insert"):
            d.appendleft(int(command[len("insert"):]))
        elif command.startswith("delete "):
            if int(command[len("delete"):]) in d:
                d.remove(int(command[-2]))
        elif command.startswith("deleteLast"):
            d.pop()
        elif command.startswith("deleteFirst"):
            d.popleft()
        else:
            print(command)

        # print(*d, command, e)
    print(*d)


Measured memory_bytes: 188512
import java.util.Scanner;


public class Main{
	
	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
		while(sc.hasNextInt()) {
			System.out.println(Sx2dx(sc.nextInt(), 600));
		}
		sc.close();
		
	}
	
	static int sq(int x) {
		return x * x;
	}
	
	static int Sx2dx(int d, int width) {
		int result = 0;
		for(int i = 0; i < width / d ; i++) {
			result += sq(d * i) * d;
		}
		return result;
	}
}

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

#define pb push_back
#define int long long
#define debug(n) cerr << #n << " = " << n << '\n';

using namespace std;
const int MAXN = 1e5 + 10;
int a[MAXN] , dp[MAXN];

int32_t main() {
    int n;
    cin >> n;
    for(int i = 0; i < n; i++) 
        cin >> a[i];
    dp[0] = 0;
    dp[1] = abs(a[0] - a[1]);
    for(int i = 2; i < n; i++) {
        dp[i] = min(dp[i - 1] + abs(a[i] - a[i - 1]) , dp[i - 2] + abs(a[i] - a[i - 2]));
    }
    cout << dp[n - 1];
    return 0;   
}


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

//省略形
#define rep(i,n) for(auto i=0; i<n ; ++i)
#define REP(i,a,b) for(auto i=a; i<b; ++i)
#define all(v) (v).begin() , (v).end()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using pii = pair<int , int>;
using pll = pair<long long , long long>;

//よく使う定数
const int INF = 1e9;
const int MOD = 1e9+7;
//逆元
const int INV = 1e9+5;

//UnionFindTree
struct union_find{
  vector<int> data;
  union_find(int size) : data(size , -1) { }

  void merge(int x , int y){
    x = root(x); y = root(y);
    if(x == y) return;
    if(data[y] < data[x]) swap(x , y);
    data[x] += data[y];
    data[y] = x;
    return; 
  }

  bool same(int x , int y){
    x = root(x) , y = root(y);
    return x == y;
  }

  int root(int x){
    return data[x] < 0 ? x : (data[x] = root(data[x]));
  }

  int size(int x){
    return -data[root(x)];
  }
};

//プロトタイプ宣言
void faster(void);
template <class T>
T get_digent(T);
template <class T>
T POW(T , T);
template <class T>
T modpow(T , T , T);

//メモ
//最大公約数:__gcd　|　最小公倍数:__lcm


int main(){
  faster();
  ll n,a,b;
  cin >> n >> a >> b;
  ll tmp = a+b , blk = n/tmp , rem = n%tmp;
  if(rem){
    if(rem >= a) cout << blk*a + a;
    else cout << blk*a + rem;
  }
  else cout << blk*a;
}


























//同期解除
void faster(void){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

//桁数取得
template <class T>
T get_digent(auto x){
  string s;
  s = to_string(x);
  ll digent = s.size();
  return digent;
} 

//繰り返し自乗法
template <class T>
T POW(T x, T y){
  if(y==0) return 1;
  if(y%2 == 1){
    ll temp = POW(x,y-1);
    return (temp*x);
  }
  else{
    ll temp = POW(x,y/2);
    return temp*temp;
  }
} 

//繰り返し自乗法(剰余)
template <class T>
T modpow(T x , T y , T mod){
  if(y == 0) return 1;
  if(y%2 == 1){
    ll temp = modpow(x,y-1,mod);
    return temp*x%mod;
  }
  else{
    ll temp = pow_mod(x,y/2,mod);
    return temp*temp%mod;
  }
}



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

int main(void){
	int n, m;
	cin >> n >> m;
	vector<int> a(50, 0);
	for(int i = 0; i < n; ++i){
		int k;
		cin >> k;
		for(int j = 0 ; j < k; ++j){
			int tmp;
			cin >> tmp;
			a[tmp]++;
		}
	}
	int cnt = 0;
	for(int i = 0; i < 50; ++i){
		if(a[i] == n) cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF= 1LL << 60;
#define REP(i,n) for(ll i=0; i<n; i++)
#define FOR(i,a,n) for(ll i=a; i<n; i++)
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);  
    int n;
    cin >> n;
    int m=5;
    vector<vector<vector<int>>> F(n,vector<vector<int>>(m,vector<int>(2,0)));  
    vector<vector<int>> P(n,vector<int>(11,0));
    int cnt= 0;
    REP(i,n){
        REP(j,m){
            REP(k,2){
                cin >> F[i][j][k];
            }
        }
    }
    REP(i,n){
        REP(j,11){
            cin >> P[i][j];
        }
    }
    int mmax= -(1<<30);
    for(int t=1; t<(1<<10); t++){
        int cc= 0; //point
        REP(i,n){
            int c=0; //かぶった回数
            REP(j,m){
                REP(k,2){
                    if(F[i][j][k] && t>>(j+m*k)&1) c++;
                }
            }
            cc+= P[i][c];
        }
        mmax= max(mmax,cc);
    }
    cout << mmax << endl;
}


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

namespace ABC115A
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            //var n = Console.ReadLine().Split().Select(int.Parse).ToArray();




            if(n==25)Console.WriteLine("Christmas");
            if(n==24)Console.WriteLine("Christmas Eve");
            if(n==23)Console.WriteLine("Christmas Eve Eve");
            if(n==22)Console.WriteLine("Christmas Eve Eve Eve");
            Console.ReadKey();
        }
    }
}


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

int main() {
    int n;
    cin >> n;
    vector<P> p(n);
    rep(i, n) cin >> p[i].second >> p[i].first;

    sort(p.begin(), p.end());
    ll work = 0;
    bool flag = true;
    rep(i,n){
        work += p[i].second;
        if (work > p[i].first) {
            flag = false;
            break;
        }
    }

    cout << (flag ? "Yes" : "No") << endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
  int n;
  while(cin >>n,n){
    int f[1000][1000] = {0};
    string s;
    for(int i=0; i<n; i++){
      cin >>s;
      for(int j=0; j<n; j++){
	if(s[j] == '.') f[j][i] = 0;
	if(s[j] == '*') f[j][i] = 1;
      }
    }
    int dp[1000][1000]={0};
    int m = 0;
    for(int i=0; i<n; i++){
      for(int j=0; j<n; j++){
	if(f[j][i] == 0){
	  if(i == 0) dp[j][i] = 1;
	  else if(j == 0) dp[j][i] = 1;
	  else dp[j][i] = min(dp[j-1][i],min(dp[j-1][i-1],dp[j][i-1]))+1;
	  if(m<dp[j][i]) m = dp[j][i];
	}
      }
    }
    cout <<m<<endl;
  }
  return 0;
}

Measured memory_bytes: 9028
H,W,K=map(int,input().split())
A = []
B = []
for _ in range(H):
    A.append(input())
for i in range(H):
    B.append(list(A[i]))

sum=0
X = 2**H-1
Y = 2**W-1

x=X
while(x):
    y=Y
    while(y):
        S=0
        for i in range(H):
            for j in range(W):
                if B[i][j]=='#' and (1<<i)&x and (1<<j)&y:
                    S+=1
        if S==K:
            sum+=1
        y = (y-1) & 2**W-1
    x = (x-1) & 2**H-1
print(sum)

Measured memory_bytes: 9020
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define FOR1(i, n) FOR(i, 1, n+1)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define int long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));
#define myCeil(dividend, divisor) ceil((double)(dividend) / (double)(divisor))
#define myFloor(dividend, divisor) floor((double)(dividend) / (double)(divisor))
#define calcDigits(num) floor(log10(num))+1

#define dl(line) cerr << "RUN: until " << (line) << "th line." << endl;
#define dv(name, value) cerr << (name) << " is " << (value) << endl;
#define da(v)  cerr << "["; REPI(itr, v){cerr << *itr << (itr != --v.end() ? ", " : "");} cerr << "]" << endl;
#define dpa(v) cerr << "[ " << endl;REPI(itr, v) { cerr << "  [" << (*itr).first << ", " << (*itr).second << ']' << (itr != --v.end() ? "," : "") << endl; } cerr << "]" << endl;


void solve(long long N, std::vector<long long> A, std::vector<long long> B){
  int sum = 0;
  REP(x, N) {
    REP(i, 2) {
      int& monstar = A.at(x+i);
      int& saver = B.at(x);
      if (monstar < saver) {
        sum += monstar;
        saver -= monstar;
        monstar = 0;
      } else
      if (saver <= monstar) {
        sum += saver;
        monstar -= saver;
        saver = 0;
      }
    }
  }

  cout << sum << endl;
}

signed main(){
  long long N;
  scanf("%lld",&N);
  std::vector<long long> A(N+1);
  for(int i = 0 ; i < N+1 ; i++){
    scanf("%lld",&A[i]);
  }
  std::vector<long long> B(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&B[i]);
  }
  solve(N, std::move(A), std::move(B));
}


Measured memory_bytes: 1792
#include <stdio.h>

int main(void){

	int m,f,r;
	int t;
	
	while(1){
		scanf("%d %d %d",&m,&f,&r);
		t=m+f;
		if(m==-1&&f==-1&&r==-1){
			break;
		}

		if(m==-1||f==-1){
			printf("F");
		}
		else if(t>=80){
			printf("A");
		}
		else if(t>=65&&t<80){
			printf("B");
		}
		else if(t>=50&&t<65){
			printf("C");
		}
		else if(t>=30&&t<50){
			if(r>=50){
				printf("C");
			}
			else{
				printf("D");
			}
		}
		else{
			printf("F");
		}
	printf("\n");
	}

	return 0;
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
#define int      long long int
#define MOD      1000000007
#define pb       push_back
#define pf		 push_front
#define vi       vector<int>
#define mi  	 map<int,int>
#define umi		 unordered_map<int,int>
#define pii      pair<int,int>
#define ff 		 first
#define ss 		 second
#define inf		 1e18
#define case	int t;cin>>t;while(t--)
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
int powm(int x, int y, int m = MOD) {
	x = x % m; int res = 1; while (y)
	{if (y & 1)res = res * x; res %= m; y = y >> 1; x = x * x; x %= m;} return res;
}
int modi(int a, int m = MOD) {return powm(a, m - 2, m);}
void pre()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}
int sm[100000] = {0}, dp[100000] = {0};
int fn(int mask)
{	if (mask == 0)
		return 0;
	if (dp[mask] != -1)
		return dp[mask];
	dp[mask] = 0;
	for (int i = mask; i != 0; i = ((i - 1)&mask))
		dp[mask] = max(dp[mask], sm[i] + fn(mask ^ i));
	return dp[mask];
}
int32_t main()
{	pre();
	//case
	{	int n;
		cin >> n;
		int a[n][n];
		memset(dp, -1, sizeof(dp));
		for (int i = 0; i < n; i++)
			for (int j = 0; j < n; j++)
				cin >> a[i][j];
		for (int i = 0; i < (1 << n); i++)
		{	for (int j = 0; j < n - 1; j++)
			{	for (int k = j + 1; k < n; k++)
					if ((i & (1 << j)) && (i & (1 << k)))
						sm[i] += a[j][k];
			}
		}
		//for (int i = 0; i < 8; i++)
		//	cout << sm[i] << endl;
		int as = fn((1 << n) - 1);
		cout << as << endl;

	}
	return 0;
}

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

typedef long long lint;
typedef pair<int, int> P;
#define REP(i, x, n) for(lint i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(lint i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())

const int IINF = 1e9 + 10;
const lint LLINF = (lint)1e18 + 10;
const lint MOD = (lint)1e9 + 7;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

lint power(lint x, lint n){
    lint res = 1;
    while(n > 0){
        if(n & 1){
            res *= x;
            res %= MOD;
        }
        x *= x;
        x %= MOD;
        n >>= 1;
    }
    return res;
}

int main(){
    lint n;
    cin >> n;
    vector<lint> a(n);
    rep(i, n){
        cin >> a[i];
    }
    lint fact = 1;
    REP(i, 1, n+1){
        fact *= i;
        fact %= MOD;
    }
    vector<lint> p(n+1);
    p[0] = 0;
    REP(i, 1, n+1){
        p[i] = power(i, MOD-2);
        p[i] += p[i-1];
        p[i] %= MOD;
    }
    lint ans = 0;
    rep(i, n){
        ans += a[i] * ((p[n-i] + p[i+1] - 1) % MOD);
        ans %= MOD;
    }
    ans *= fact;
    ans %= MOD;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
module Main where
--import Debug.Trace
import Data.List
import Data.Char
import Data.Array
import Data.Maybe
import Data.Ord
import Control.Monad

data Command = Replace Int Int String | Reverse Int Int | Print Int Int deriving (Show)

solve :: String -> [Command] -> [String]
solve _ [] = []
solve s (c:cs) =
    case c of
        Replace a b p -> solve (take a s ++ p ++ drop (b+1) s) cs
        Reverse a b   -> solve (take a s ++ reverse (target a b) ++ drop (b+1) s) cs
        Print   a b   -> target a b: solve s cs
    where target a b = take (b-a+1) (drop a s)

readLine:: IO [Int]
readLine = fmap (map read . words) getLine

readLines :: Int -> IO [Command]
readLines 0 = return []
readLines n = getLine >>=
    (\a -> fmap ((case words a of
        ["replace", a, b, p] -> Replace (read a) (read b) p
        ["reverse", a, b]    -> Reverse (read a) (read b)
        ["print", a, b]      -> Print   (read a) (read b)):) (readLines (pred n)))
            
main :: IO() 
main = do
    s <- getLine
    n <- readLn
    l <- readLines n
    mapM_ putStrLn (solve s l)



Measured memory_bytes: 5748
from sys import stdin
input = stdin.readline

from collections import defaultdict

n, q = map(int, input().split())

dic = defaultdict()









def getRoot(x):
    global n
    for _ in range(n+1):
        if dic[x]["parent"] == x:
            return x
        x = dic[x]["parent"]

def makeSet(x):
    return


def unite(x, y):
    r = getRoot(x)
    l = getRoot(y)
    a = dic[r]["rank"]
    b = dic[l]["rank"]

    if a == b:
        dic[r]["rank"] += 1
        dic[l]["parent"] = r

    elif a > b:
        dic[l]["rank"] = 0
        dic[l]["parent"] = r

    elif a < b:
        dic[r]["rank"] = 0
        dic[r]["parent"] = l

for _ in range(n):
    dic[_] = {"rank":0,"parent":_}

for _ in range(q):
    com , x, y = map(int, input().split())
    if com == 0:
        unite(x, y)

    else:
        s = getRoot(x)
        t = getRoot(y)
        if s == t :
            print('1')
        else:
            print('0')


Measured memory_bytes: 9728
// ref: p302

using System;

public class SingleSourceShortestPath
{
	const int MAX = 100;
	const int INFTY = Int32.MaxValue;
	const int WHITE = 0;
	const int GRAY = 1;
	const int BLACK = 2;

	static int vertexNum; // ????????° = V
	static int[,] M = new int[MAX,MAX]; // ????????????????¨????????????£??\??????

	static void dijkstra() {
		int minv;
		int[] d = new int[MAX]; // ?§????s????????????v?????§??????????????????????¨????
		int[] color = new int[MAX]; // ?¨??????¶???????????§??¨???

		// ?????????
		for (int i = 0; i < vertexNum; i++) {
			d[i] = INFTY;
			color[i] = WHITE; 
		}

		// ????????????????????????
		d[0] = 0;
		color[0] = GRAY;

		while (true) {
			minv = INFTY;
			int u = -1;
			for (int i = 0; i < vertexNum; i++) {
				// ???????¨???????????????????????????´???
				if (minv > d[i] && color[i] != BLACK) {
					u = i;
					minv = d[i]; //????°???????????????´??°
				}
			}
			// ???????????¢?´¢?????????????????????
			if (u == -1)
				break;
			// ?¨????????????????????????´
			color[u] = BLACK;

			for (int v = 0; v < vertexNum; v++) {
				//???????¨?????????????????????????u??¨v?????????????????????
				if (color[v] != BLACK && M[u,v] != INFTY) {
					if (d[v] > d[u] + M[u,v]) {
						d[v] = d[u] + M[u,v];
						color[v] = GRAY;
					}
				}
			}
		}
		// ????????¨?????????????????????
		for (int i = 0; i < vertexNum; i++) {
			Console.WriteLine ("{0} {1}", i, (d[i] == INFTY ? -1 : d[i]));
		}
	}
	public static void Main(String[] args) {
		// ????????°
		vertexNum = int.Parse(Console.ReadLine ());
		// ??????????????????
		for (int i = 0; i < vertexNum; i++) {
			for (int j = 0; j < vertexNum; j++) {
				M[i,j] = INFTY;
			}
		}

		int k, c, u, v;
		for (int i = 0; i < vertexNum; i++) {
			string[] readLine = Console.ReadLine().Split(' ');
			int s = 0;
			u = int.Parse(readLine[s]);	// ????????????
			s++;
			k = int.Parse(readLine[s]); 	// ????¬???°
			for (int j = 0; j < k; j++) {
				s++;
				v = int.Parse(readLine[s]);	// ??£??\?????????????????????
				s++;
				c = int.Parse(readLine[s]); // u??¨v????????????????????????
				M[u, v] = c;
			}
		}
		dijkstra ();
	}
}

Measured memory_bytes: 9188
#include <stdio.h>

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x) {
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename T>
void __print(const T &x) {
    int f = 0;
    cerr << '{';
    for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
    __print(t);
    if (sizeof...(v)) cerr << ", ";
    _print(v...);
}
#ifdef LOCAL
#define debug(x...)               \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define debug(x...)
#endif

#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)

typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a, b, c;
    cin >> a >> b >> c;
    if (c - a - b == 0) {
        cout << "No" << endl;
        return 0;
    }
    if (c < a || c < b) {
        cout << "No" << endl;
        return 0;
    }

    if (c - a - b >= 0) {
        if (4 * a * b < (c - a - b) * (c - a - b)) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    } else {
        if (4 * a * b >= (c - a - b) * (c - a - b)) {
            cout << "No" << endl;
        } else {
            cout << "Yes" << endl;
        }
    }

    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

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

        String s = sc.next();

        int first = Integer.parseInt(s.substring(0,2));
        int second = Integer.parseInt(s.substring(2,4));

        if ((first > 12 && second > 12) || (first == 0 && second > 12)
                || (first > 12 && second == 0) || (first == 0 && second == 0)) {
            System.out.println("NA");
        }else if(first <= 12 && (second > 12 || second == 0)){
            System.out.println("MMYY");
        }else if((first > 12 || first == 0) && second <= 12) {
            System.out.println("YYMM");
        }else if(first <= 12 && second <= 12){
            System.out.println("AMBIGUOUS");
        }

        sc.close();
    }
}


Measured memory_bytes: 23124
#include <iostream>
#include <stdlib.h>
using namespace std;

int main() {
	int w,h,x,y,r;
	cin >> w >> h >> x >> y >> r;
	if (x < 0 || y < 0) cout << "No" << endl;
	else if (w >= x+r && h >= y+r) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

#define F first 
#define S second

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 200010, M = 45;

int n;
int cnt[N][M];
LL a[N];

bool check(int x, int y)
{
	for (int i = 0; i < M; i ++ )
		if (abs(cnt[x][i] - cnt[y][i]) >= 2)
			return false;
	return true;
}

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i ++ )
	{
		scanf("%lld\n", &a[i]);
		for (int j = 0; j < M; j ++ ) cnt[i][j] += (a[i] >> j) & 1;
	}
	
	for (int i = 1; i <= n; i ++ )
		for (int j = 0; j < M; j ++ )
			cnt[i][j] += cnt[i - 1][j];
	
	LL res = 0;
	for (int i = 1; i <= n; i ++ )
	{
		int l = 0, r = i - 1;
		while (l < r)
		{
			int mid = l + r >> 1;
			if (check(i, mid)) r = mid;
			else l = mid + 1;
		}
		res += i - r - 1;
	}
	printf("%lld\n", res + n);
    return 0;
}

Measured memory_bytes: 36992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(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; }
const long long INF = 1LL << 60;

int N;
vector<int> vx;
vector<int> vy;

double dfs(int i, int n, int x, int y, float dist, vector<bool> &visited){
    //cout << "["<<i << " " << n<<"] ";
    if(n==N) {
        //cout <<"dist:" <<dist<< endl;
        return dist;
    }
    visited[i] = true;
    double tot_dist=0.0;
    REP(next_i, N){
        if(visited[next_i]) continue;
        double dist_tmp = dist+sqrt(float((vx[next_i]-x)*(vx[next_i]-x) + (vy[next_i]-y)*(vy[next_i]-y)));
        tot_dist += dfs(next_i, n+1, vx[next_i], vy[next_i], dist_tmp, visited);
    }
    visited[i] = false;
    return tot_dist;
}
int main()
{
    cin>>N;
  	vx.resize(N);
  	vy.resize(N);
    REP(i,N){
        cin>>vx[i]>>vy[i];
    }
    vector<bool> visited(N, false);

    double tot_dist = 0.0;
    REP(next_i, N){
        //float dist = sqrt(float((vx[next_i]-0)*(vx[next_i]-0) + (vy[next_i]-0)*(vy[next_i]-0)));
        tot_dist += dfs(next_i, 1, vx[next_i], vy[next_i], 0, visited);
    }
  
  	int cnt=1;
  	REP(i,N) cnt*=i+1;
    //cout << tot_dist << endl;
    //cout << cnt << endl;
    cout <<fixed << setprecision(10)<< tot_dist/double(cnt) << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef  unsigned long long int ull;
typedef pair<ll,ll> P;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
int n;
cin>>n;
V<ll> a(n);
set<ll> s;
for(int i=0;i<n;i++){
    cin>>a[i];
    s.insert(a[i]);
}
if(s.size()!=n)cout<<"NO"<<endl;
else cout<<"YES"<<endl;
}

Measured memory_bytes: 11264
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <map>
#include <fstream>
#include <sstream>
#include <iterator>
#include <complex>
using namespace std;



int main()
{
	//dpの匂い
	int N, M;
	cin>>N>>M;
	int state = 1 << N;

	vector<pair<int, int>> keys(M);
	
	for(int i=0; i<M; i++)
	{
		int _cost,_state,_size;
		_state = 0;
		cin>>_cost>>_size;
		for(int j=0; j<_size; j++)
		{
			int index;
			cin>>index;
			_state += 1 << (index-1);
		}
		keys[i] = make_pair(_cost, _state);
	}

	vector<int> cost(state, 1e+9);
	cost[0] = 0;
	vector<int> known;
	known.push_back(0);

	for(int i=0; i<M; i++)
	{
		int known_size = known.size();
		//vector<int> next_known = known;

		for(int j=0; j<known_size; j++)
		{
			int _state = known[j];
			int index = (_state|keys[i].second);
			if(cost[index] == 1e+9)
			{
				known.push_back(index);
			}
			cost[index] = min(cost[index] , cost[_state] + keys[i].first);
		}
		//known = next_known;
		
	}

	if(cost[state-1] != 1e+9)
	{
		cout<<cost[state-1]<<endl;
	}
	else
	{
		cout<<-1<<endl;
	}
}

Measured memory_bytes: 256
N,Ma, Mb = map(int, input().split())
ABC = [ [int(j) for j in input().split()] for _ in range(N)]

dp = [ [ [float("inf")] * (25*Mb+1) for _ in range(25*Ma+1)] for _ in range(N+1)]
dp[0][0][0] = 0
# dp[i][ma][mb] 

for i in range(0, N):
    a,b,c = ABC[i]

    for ma in range(0,10*Ma+1):
        for mb in range(0,10*Mb+1):
            
            dp[i+1][ma+a][mb+b] = min(dp[i+1][ma+a][mb+b],
                    dp[i][ma][mb] + c) 
            dp[i+1][ma][mb] = min(dp[i+1][ma][mb],
                                  dp[i][ma][mb])

ans = float("inf")

for i in range(1,25  + 1):
    if Ma*i <= 100*Ma and Mb*i <= 100*Mb:
        ans = min(ans, dp[N][Ma*i][Mb*i])
    else:
        break
print(ans if ans != float("inf") else "-1")

# print(dp[3][1][2])
# print(dp[N][Ma][Mb])





Measured memory_bytes: 81116
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

#ifndef _DEBUG
#define main_ main
#endif
#define FOR(i,s,e) for (int i = int(s); i != int(e); i++)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

template <typename T>
using keyVal = pair<string, T>;
template<typename T>
bool val_greater(const keyVal<T>& left, const keyVal<T>& right) {
	return left.second > right.second;
}

void init_global() {}

int main_() {
	int A, B, C;
	cin >> A >> B >> C;
	
	bool ok = false;
	FOR(i, 1, B+1) {
		if (((A*i) % B) == C) {
			ok = true;
			break;
		}
	}

	string ans = ok ? "YES" : "NO";
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
using namespace std;
int main(){
  int a,c;
  char b;
  int d;
  for (;;){
    cin >> a >> b >> c;
    if (b=='+')cout << a+c << endl;
    if (b=='-')cout << a-c << endl;
    if (b=='/')cout << a/c << endl;
    if (b=='*')cout << a*c << endl;
    if (b=='?')break;
  }
}



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

struct StDtl
{
  int m_nHigh;
  int m_nArea;

  StDtl(int nHigh) :
    m_nHigh(nHigh), m_nArea(0)
  { }

  ~StDtl() { }
};

struct StSum
{
  bool m_bSumOK;
  int m_nHigh;
  int m_nArea;

  StSum(bool bSumOK, int nHigh, int nArea) :
    m_bSumOK(bSumOK), m_nHigh(nHigh), m_nArea(nArea)
  { }

  ~StSum() { }

};

void fnCroSecSet(list<StDtl>& rltStDtl, list<StSum>& rltStSum)
{
  string sCroSec;
  int nHigh = 0;
 
  cin >> sCroSec;

  for (int i = 0; i < sCroSec.size(); i++)
  {
    for (auto itltStDtl = rltStDtl.begin(); itltStDtl != rltStDtl.end(); ++itltStDtl)
    {
      itltStDtl->m_nArea++;
    }

    if (sCroSec.at(i) == '\\')
    {
      StDtl oDtl(nHigh);
      rltStDtl.push_back(oDtl);
      nHigh--;
    }
    else if (sCroSec.at(i) == '/')
    {
      nHigh++;
      bool bSumOK;
      int iSum = 0;

      if (rltStDtl.size() > 0)
      {
        iSum = rltStDtl.back().m_nArea;
        rltStDtl.pop_back();

        if (rltStDtl.size() == 0)
          bSumOK = false;
        else
          bSumOK = true;

        for (auto itltStSum = rltStSum.begin(); itltStSum != rltStSum.end();    )
        {
          if (itltStSum->m_bSumOK  == true  &&
              itltStSum->m_nHigh < nHigh      )
          {
            iSum += itltStSum->m_nArea;
            itltStSum = rltStSum.erase(itltStSum);
            continue;
          }
          itltStSum++;
        }

        StSum oSum(bSumOK, nHigh, iSum);
        rltStSum.push_back(oSum); 
      }
      else
        for (auto itltStSum = rltStSum.begin(); itltStSum != rltStSum.end(); ++itltStSum)
          itltStSum->m_bSumOK = false;
    }
  }
}

void  fnCrlSecGet(const list<StSum>& cnrltStSum)
{
  int nArea = 0;
  for (auto itltStSum = cnrltStSum.begin(); itltStSum != cnrltStSum.end(); ++itltStSum)
    nArea += itltStSum->m_nArea;

  cout << nArea << endl;
  cout << cnrltStSum.size();
  if (cnrltStSum.size() > 0)
  {
    cout << " ";
    for (auto itltStSum = cnrltStSum.begin(); itltStSum != cnrltStSum.end(); ++itltStSum)
    {
      if (itltStSum != cnrltStSum.begin()) cout << " ";
      cout << itltStSum->m_nArea;
    }
  }
  cout << endl;
}

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

  list<StDtl> ltStDtl;
  list<StSum> ltStSum;

  fnCroSecSet(ltStDtl, ltStSum);
  fnCrlSecGet(ltStSum);

  return 0;
}

Measured memory_bytes: 3760
#include <iostream>
#include <map>
#include <string>

using namespace std;

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

    map<int, int> m;
    m[0] = 1;

    long long res = 0;
    for (int i = s.size() - 1, j = 1, k = 0; i >= 0; i--, j *= 10, j %= 2019) {
        k = ((s[i] - '0') * j + k) % 2019;
        res += m[k];
        m[k]++;
    }

    cout << res << endl;
}


Measured memory_bytes: 3740
#include <bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
#define maxn 200005
#define ll long long

#define DEBUG
#ifdef DEBUG
#define debug(x) cout << #x << ": " << x << "  "
#else
#define debug(x) ;
#endif

int n, x, y;
vector<int> G[maxn];
queue<int> q;
int dx[maxn], dy[maxn];
int vis[maxn];
int ans[maxn];

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

    cin >> n >> x >> y;
    for (int i = 1; i < n; i++) {
        G[i].push_back(i + 1);
        G[i + 1].push_back(i);
    }
    G[x].push_back(y);
    G[y].push_back(x);

    q.push(x);
    vis[x] = 1;
    dx[x] = 0;
    while (!q.empty()) {
        int t = q.front();
        q.pop();
        for (int i = 0; i < G[t].size(); i++) {
            int to = G[t][i];
            if (!vis[to]) {
                vis[to] = 1;
                dx[to] = dx[t] + 1;
                q.push(to);
            }
        }
    }

    memset(vis, 0, sizeof(vis));
    q.push(y);
    vis[y] = 1;
    dy[y] = 0;
    while (!q.empty()) {
        int t = q.front();
        q.pop();
        for (int i = 0; i < G[t].size(); i++) {
            int to = G[t][i];
            if (!vis[to]) {
                vis[to] = 1;
                dy[to] = dy[t] + 1;
                q.push(to);
            }
        }
    }

    for (int i = 1; i <= n; i++) {
        for (int j = i + 1; j <= n; j++) {
            ans[min(min(dy[i] + dy[j], dx[i] + dx[j]),j-i)]++;
        }
    }
    for (int i = 1; i < n; i++) {
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 9084
#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(a) ((a).begin(), (a).end())
typedef long long ll;
const long long INF = 1LL << 60;
// const int INF=1010101010;
// using Graph = vector<vector<int>>;

int main() {
  long long n, k;
  cin >> n >> k;
  long long cnt = 0;
  if (k == 0)
    cout << n * n << endl;
  else {
    for (int i = k + 1; i <= n; i++) {
      cnt += n / i * (i - k);
      cnt += max(n % i - k + 1, (long long)0);
    }
    cout << cnt << endl;
    return 0;
  }
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void){
  int m,a[8],b[8],g,n,dp[8][1001];

  while(cin >> m,m){

    for(int i=0;i<8;i++){
      for(int j=0;j<1001;j++){
	dp[i][j]=0;
      }
    }

    for(int i=0;i<m;i++)
      cin >> a[i] >> b[i];
    
    for(int j=0;j<=b[0];j++){
      dp[0][a[0]*j]++;
    }
   

    for(int i=0;i<m-1;i++){
      for(int j=0;j<1001;j++){
	  for(int k=0;k<=b[i+1];k++){
	    if(j+(a[i+1]*k)<1001)dp[i+1][j+(a[i+1]*k)]+=dp[i][j];
	  }
      }
    }

    cin >> g;
    while(g--){
      cin >> n;
      cout << dp[m-1][n] << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 1188
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(input())
    l1=list(map(int,input().split()))
    l2=list(map(int,input().split()))
    ans=0
    for i in range(n):
        cnt=sum(l1[:i+1])+sum(l2[i:])
        ans=max(ans,cnt)
    print(ans)
resolve()

Measured memory_bytes: 38384
from collections import deque

n, k = map(int, input().split())
array = [int(x) - 1 for x in input().split()]
count = [-1 for x in range(n)]

now = 0
count[now] = 0
queue = deque()
queue.append(now)
dag = False
dag_start = -1
dag_end = -1
while len(queue) != 0:
    now = queue.pop()
    next_index = array[now]
    if count[next_index] != -1:
        dag = True
        dag_start = next_index
        dag_end = now
        break
    count[next_index] = count[now] + 1
    queue.append(next_index)

if count[dag_start] >= k:
    for i in range(n):
        if count[i] == k:
            print(i + 1)
            exit()
now = dag_start
d = [now]
while now != dag_end:
    d.append(array[now])
    now = array[now]
print(d[(k - count[dag_start]) % len(d)] + 1)


Measured memory_bytes: 32736
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>

typedef long long ll;

using namespace std;

int memo[100100];

int rec(int n) {
    if (memo[n] != -1)  return memo[n];
    int res = n;
    for (int pow6 = 1; pow6 <= n; pow6 *= 6) res = min(res, rec(n - pow6) + 1);
    for (int pow9 = 1; pow9 <= n; pow9 *= 9) res = min(res, rec(n - pow9) + 1);
    memo[n] = res;
    return res;
}

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

    for (int i = 0; i <= N; ++i)  memo[i] = -1;
    memo[0] = 0;

    cout << rec(N) << endl;
}


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

using namespace std;

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define popb pop_back
#define popf pop_front
#define all(v) v.begin(), v.end()
#define fori(i, j, k) for (int i = (j); i < (int)(k); i++)
#define forb(i, j, k) for (int i = (j); i >= (int)k; i--)
#define lchild(ind) 2 * ind + 1
#define rchild(ind) 2 * ind + 2
#define bug(val) cout << "# " << val << endl;
#define bugs(val) cout << '_' << val;
#define bugl(val) cout << "## " << val << endl;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef pair<int, pll> pip;
typedef pair<ll, pll> plp;
typedef pair<pll, int> ppi;
typedef pair<pll, ll> ppl;
typedef pair<pll, pll> ppp;
typedef vector<int> vi;
typedef vector<ll> vll;

const int maxn = 1e5 + 1;
const ll inf = 2e18, mod = 1e9 + 7;

ll n, W, w[maxn], v[maxn];
map<ll, ll> dp, dp2;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> W;
	fori (i, 0, n)
		cin >> w[i] >> v[i];
	dp[0] = 0;
	fori (i, 0, n)
	{
		for (pll j : dp)
		{
			dp2[j.ff] = max(dp2[j.ff], dp[j.ff]);
			if (j.ff + w[i] <= W)
				dp2[j.ff + w[i]] = max(dp2[j.ff + w[i]], dp[j.ff] + v[i]);
		}
		dp = dp2;
		dp2.clear();
	}
	ll ans = 0;
	for (pll i : dp)
		ans = max(ans, i.ss);
	cout << ans << endl;
}

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

int main()
{
    int n;
    cin>>n;
    int ar[n];
    for(int i=0; i<n; i++)
        cin>>ar[i];
     int big=0;
     int low=9999999999;
     if(n==2)
     {
        if(ar[0]<ar[1])
        {
            big=ar[1];
            low=ar[0];
        }
        else{
            big=ar[0];
            low=ar[1];
        }
     }
     else{
    for(int i=0; i<n; i++)
    {
      if(ar[i]>big)
            big=ar[i];
      if(ar[i]<low)
        low=ar[i];
    }
     }
    cout<<big-low<<endl;
    return 0;
}


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

using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i < (n); --i)
#define all(x) (x).begin(), (x).end()
#define gsort(x, n) sort((x), (x + n) greater<int>())
#define rv(s) reverse((s).begin(), (s).end())
#define setout(n, x) setw(n) << setfill(x)
#define Fixed(n) fixed << setprecision(n)
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).flont_back(a)
#define eb(x, a) (x).emplaes_back(a)
using pii = pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1e9 + 7;

queue<int> x;
signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int k,a;
    cin>>k;

    rep(i,1,10) x.push(i);

    rep(i,1,k+1){
        a = x.front();
        x.pop();
        if(a % 10 != 0) x.push(10*a+(a%10)-1);
        x.push(10*a+(a%10));
        if(a % 10 != 9) x.push(10*a+(a%10)+1);
    }

    cout<<a<<'\n';
    return 0;
}

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

using namespace std;

main() {
#ifdef HOME
    //freopen("input.txt", "r", stdin);
#endif // HOME
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int a, b;
    cin >> a >> b;
    cout << (a + b - 1) / b;
    return 0;
}


Measured memory_bytes: 256
// AtCoder template
// 最近sabaがかまってくれないからキレて暴れてる
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < n; ++i)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s,t; cin >> s >> t;
    if(s == t.substr(0,s.size())) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3644
use std::io::*;
use std::str::FromStr;
use utils::*;

pub fn main() {
    let i = stdin();
    let mut o = Vec::new();
    run(i.lock(), &mut o);
    stdout().write_all(&o).unwrap();
}

fn run<R: BufRead, W: Write>(i: R, o: &mut W) {
    let mut i = CpReader::new(i);
    let (a, b) = i.read2::<usize, usize>();
    let r = if a + b == 15 {
        "+"
    } else if a * b == 15 {
        "*"
    } else {
        "x"
    };
    writeln!(o, "{}", r).unwrap();
}

mod utils {
    use super::*;

    pub struct CpReader<R: BufRead> {
        r: R,
        s: String,
    }

    macro_rules! fn_read {
        {$f:ident($($v:ident: $t:ident),*)} => {
            pub fn $f<$($t: FromStr),*>(&mut self) -> ($($t),*) {
                let i = &mut self.read_line().split(' ');
                $(
                    let $v = i.next().unwrap().parse().ok().unwrap();
                )*
                ($($v),*)
            }
        };
    }

    impl<R: BufRead> CpReader<R> {
        pub fn new(r: R) -> Self {
            CpReader {
                r: r,
                s: String::new(),
            }
        }
        pub fn read_line(&mut self) -> &str {
            self.s.clear();
            self.r.read_line(&mut self.s).unwrap();
            self.s.trim()
        }

        fn_read! { read2(v1: T1, v2: T2) }
    }
}


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

#define MAX 100
#define MOD 1000000007
#define pi 3.1415926535897932384246433832

#define ll long long
#define ld long double

#define vi vector <int>
#define vll vector<long long>
#define vb vector<bool>

#define vvi vector<vi>
#define vvll vector<vll>

#define all(v) (v).begin(), (v).end()
#define allrev(v) (v).rbegin(), (v).rend()
#define allcomp(v) (v).begin(), (v).end(), comp
#define allrevcomp(v) (v).rbegin(), (v).rend(), comp

#define line cout<<"\n";
#define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);


void solve(){
    int n,a;
    string s;
    cin>>n;
    map<string, int> m;
    vector<string> v;

    for(int i = 0; i < n; i++){
        cin>>s;
        m[s]++;
    }
    int max = 0;
    for(auto i : m)
        if(i.second > max){
            max = i.second;
            v.clear();
            v.push_back(i.first);
        }else if(i.second == max) v.push_back(i.first);

    sort(all(v));
    for(string i : v) cout<<i<<"\n";
}


int main(){
    fast
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int test = 1;
    //cin>>test;
    while(test--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 25584