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

using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using ull = unsigned long long;
using vb = vector<bool>;
using vvb = vector<vb>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vvs = vector<vs>;
using vc = vector<char>;
using vvc = vector<vc>;
using ii = pair<int,int>;
using vii = vector<ii>;
using vvii = vector<vii>;
using dd = pair<double, double>;
using vdd = vector<dd>;
using vvdd = vector<vdd>;
using Mii = map<int,int>;
using vMii = vector<Mii>;

#define fi first
#define se second
#define INF INT_MAX
#define mod(a,m) (a%m+m)%m
#define PB push_back
#define MP make_pair

vi value, weight;

vvll memo;

ll dp(int pas, int w) {
	int n = weight.size();
	if(pas == n) return 0;
	if(w == 0) return 0;
	ll& ans = memo[pas][w];
	if(ans != -1) return ans;
	ans = dp(pas + 1, w);
	if(weight[pas] <= w) {
		ans = max(ans, value[pas] + dp(pas + 1, w - weight[pas]));
	}
	return ans;
}

int main(){
//	cout.setf(ios::fixed);
//	cout.precision(4);
	int n, w;
	while (cin >> n >> w) {
		weight = vi(n);
		value = vi(n);
		for (int i = 0; i < n; ++i) {
			cin >> weight[i] >> value[i];
		}
		memo = vvll(n, vll(w + 1, -1));
		cout << dp(0, w) << '\n';
	}
}




Measured memory_bytes: 79488
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		String s, t;
		int a, b;
		String u;
		Scanner scan = new Scanner(System.in);
		s = scan.next();
		t = scan.next();
		a = scan.nextInt();
		b = scan.nextInt();
		u = scan.next();

		if(s.equals(u)) {
			System.out.println((a-1) + " " + b);
		} else if(t.equals(u)){
			System.out.println(a + " " + (b-1));
		}
		scan.close();
	}

}


Measured memory_bytes: 23380
// --------------------------------------------------
// Let's entry "square869120Contest #1" !
//
// Link : https://s8pc-1.contest.atcoder.jp/
// --------------------------------------------------

#include <vector>
#include <iostream>
#include <algorithm>

#pragma warning(disable : 4996)

using namespace std;

int main()
{
	int N, M, S;

	scanf("%d", &N);
	scanf("%d", &M);
	scanf("%d", &S);

	vector<int> A(N);
	vector<int> B(N);

	for (int i = 0; i < N; i++)
	{
		scanf("%d", &A[i]);
		scanf("%d", &B[i]);
	}

	vector<vector<int> > dp(N + 1, vector<int>(M + 1, 0));

	for (int i = 1; i <= N; i++)
	{
		for (int j = 1; j <= M; j++)
		{
			dp[i][j] = dp[i - 1][j];

			if (j - B[i - 1] >= 0 && !(j - B[i - 1] < S && S < j))
			{
				dp[i][j] = max(dp[i][j], dp[i - 1][j - B[i - 1]] + A[i - 1]);
			}
		}
	}

	printf("%d\n", *max_element(dp[N].begin(), dp[N].end()));

	return 0;
}

Measured memory_bytes: 38252
h,w = map(int,input().split())
s = [input() for _ in range(h)]

ans = 0

for i in range(h):
    for j in range(w):
        if s[i][j] == '.':
            dis = [[-1] * w for _ in range(h)]
            dis[i][j] = 0
            q = [(i,j)]
            while q:
                l0,l1 = q.pop(0)
                if l0 > 0:
                    if s[l0-1][l1] == '.':
                        if dis[l0-1][l1] > dis[l0][l1] + 1 or dis[l0-1][l1] == -1:
                            dis[l0-1][l1] = dis[l0][l1] + 1
                            q.append((l0-1,l1))
                if l0 < h - 1:
                    if s[l0+1][l1] == '.':
                        if dis[l0+1][l1] > dis[l0][l1] + 1 or dis[l0+1][l1] == -1:
                            dis[l0+1][l1] = dis[l0][l1] + 1
                            q.append((l0+1,l1))
                if l1 > 0:
                    if s[l0][l1-1] == '.':
                        if dis[l0][l1-1] > dis[l0][l1] + 1 or dis[l0][l1-1] == -1:
                            dis[l0][l1-1] = dis[l0][l1] + 1
                            q.append((l0,l1-1))
                if l1 < w - 1:
                    if s[l0][l1+1] == '.':
                        if dis[l0][l1+1] > dis[l0][l1] + 1 or dis[l0][l1+1] == -1:
                            dis[l0][l1+1] = dis[l0][l1] + 1
                            q.append((l0,l1+1))
            dis_max = 0
            for k in dis:
                dis_max = max(max(k), dis_max)
            ans = max(dis_max,ans)

print(ans)


Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
int a[10],x;
char c;
int main(void)
{
    while(cin>>c&&c!='\0')
    {
        if(c=='0') a[x++]=0;
        else if(c=='1') a[x++]=1;
        else
        {
            if(x) x--;
        }
    }
    if(x)
    {
        for(int i=0;i<x;i++) printf("%d",a[i]);
        printf("\n"); 
    }
}

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

int main(){
    int n;
  	cin >> n;
    vector<int> p(n);
    rep(i,n) cin >> p[i];
    int m = 100;
    int sum = 0;
    rep(i,n){
        sum += p[i];
        m = max(m,p[i]);
    }
    cout << sum - m/2 << endl;
}

Measured memory_bytes: 256
# include <stdio.h>
# include <string.h>
 
int main(){
 
	char a[200], b[200];
	int aa= 0;
	scanf("%s %s", a, b);
 
	if (strlen(a) > strlen(b))
		printf("GREATER\n");
	if (strlen(b) > strlen(a))
		printf("LESS\n");
	if (strlen(a) == strlen(b)){
		for (int i = 0; i < strlen(a); ++i){
			if (a[i] > b[i]){
				printf("GREATER\n");
				break;
			}
			if (b[i] > a[i]){
				printf("LESS\n");
				break;
			}
			if (a[i] == b[i])
				aa+=1;
 
		}
	}
	if (aa == strlen(a)){
		printf("EQUAL\n");
	}
 
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s,t;
  cin >> s >> t;
  rep(i,s.size()){
    if(i<t.size()){
      cout << s[i] << t[i];
    }else{
      cout << s[i];
    }
  }


  
  return 0;
    

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
    #define LL long long
    #define clr(x,i) memset(x,i,sizeof(x))
    using namespace std;
    const int N=200005;
    int n,m,ind[N][2],vis[N];
    vector<int> G[N];
    char s[N];
    queue<int> q;
    int main()
    {
    	ios::sync_with_stdio(0);
    	cin>>n>>m>>s+1;
    	//cout<<s+1<<endl;
    	for(int i=1;i<=m;i++){
    		int u,v; cin>>u>>v;
    		G[u].push_back(v); G[v].push_back(u);
    		ind[u][s[v]-'A']++; ind[v][s[u]-'A']++;
    	}
    	int tot=0;
    	for(int i=1;i<=n;i++){
    		if(!ind[i][0]||!ind[i][1]) q.push(i),vis[i]=1;
    	}
    	while(!q.empty()){
    		int u=q.front(); q.pop(); tot++;
    		for(int i=0;i<G[u].size();i++){
    			int v=G[u][i];
    			if(!(--ind[v][s[u]-'A'])&&!vis[v]) q.push(v),vis[v]=1;
    		}
    	}
    	if(tot<n) puts("Yes");
    	else puts("No");
    	return 0;
    }

Measured memory_bytes: 13184
use std::cmp::min;
use std::io::*;
const INF: usize = 1 << 60;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let m: usize = itr.next().unwrap().parse().unwrap();
    let s: usize = itr.next().unwrap().parse().unwrap();

    let mut g: Vec<Vec<(usize, usize, usize)>> = vec![Vec::new(); 55];
    let mut e = Vec::new();
    for i in 0..m {
        let u: usize = itr.next().unwrap().parse().unwrap();
        let v: usize = itr.next().unwrap().parse().unwrap();
        let a: usize = itr.next().unwrap().parse().unwrap();
        let b: usize = itr.next().unwrap().parse().unwrap();
        g[u - 1].push((v - 1, a, b));
        g[v - 1].push((u - 1, a, b));
    }
    for i in 0..n {
        let c: usize = itr.next().unwrap().parse().unwrap();
        let d: usize = itr.next().unwrap().parse().unwrap();
        e.push((c, d));
    }

    let mut dp: Vec<Vec<usize>> = vec![vec![INF; 3030]; 55];
    dp[0][min(3003, s)] = 0;

    for _ in 0..10 {
        for i in 0..n {
            for j in 0..3030 {
                dp[i][min(3003, j + e[i].0)] = min(dp[i][min(3003, j + e[i].0)], dp[i][j] + e[i].1);
            }
            for &(v, a, b) in g[i].iter() {
                for j in 0..3030 {
                    if j >= a {
                        dp[v][j - a] = min(dp[v][j - a], dp[i][j] + b);
                    }
                }
            }
        }
    }

    let mut out = Vec::new();
    for i in 1..n {
        let ans = dp[i].iter().min().unwrap();
        writeln!(out, "{}", ans).ok();
    }
    stdout().write_all(&out).unwrap();
}


Measured memory_bytes: 3508
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (1e+18) + 7;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-6;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

ll mod_pow(ll a, ll n) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%mod;
		a = a * a%mod; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 20;
modint fact[max_n], factinv[max_n];
void init() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}

void solve() {
	int h, w, n; cin >> h >> w >> n;
	if (h > w)swap(h, w);
	int ans = (n + w - 1) / w;
	cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(7);
	//init();
	//int t; cin >> t; rep(i, t)solve();
	solve();
	stop
		return 0;
}


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


using namespace std;

int d[2][100000];
vector <int> v[100000];
 
void dfs(int x, int y, int z, int w) {
    int i;
    
    d[w][x] = z;
    
    for (i = 0; i < v[x].size(); i++) {
        if (v[x][i] == y) continue;
        
        dfs(v[x][i], x, z + 1, w);
    }
}
 
int main() {
    int n, c1 = 0, c2 = 0, i;
    
    scanf("%d", &n);
    
    for (i = 0; i < n - 1; i++) {
        int x, y;
        
        scanf("%d %d", &x, &y);
        
        x--;
        y--;
        
        v[x].push_back(y);
        v[y].push_back(x);
    }
    
    dfs(0, -1, 0, 0);
    dfs(n - 1, -1, 0, 1);
    
    for (i = 0; i < n; i++) {
        if (d[0][i] <= d[1][i]) {
            c1++;
        } else {
            c2++;
        }
    }
    
    if (c1 > c2) {
        puts("Fennec");
    } else {
        puts("Snuke");
    }
    
    return 0;
}

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

#ifdef _DEBUG
inline void dump() { cerr << endl; }
template<typename Head> void dump(Head&& head) { cerr << head; dump(); }
template<typename Head, typename... Tail> void dump(Head&& head, Tail&&... tail) { cerr << head << ", "; dump(forward<Tail>(tail)...); }
#define debug(...) do {cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; dump(__VA_ARGS__); } while (false)
#else
#define dump(...)
#define debug(...)
#endif

template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////
const ll inf = 1LL<<60;

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

  cout << (n/x)*a + min(a, n%x) << endl;

  return 0;
}


Measured memory_bytes: 3632
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

S = sr()
K = ir()
cand = set()
length = len(S)
for i in range(length):
    for j in range(1, 6):
        cand.add(S[i:i+j])

answer = sorted(list(cand))[K-1]
print(answer)


Measured memory_bytes: 4592
imput = gets.chomp.split(" ").map!{|item| item.to_f}
a = imput[0]
b = imput[1]
h = imput[2]
m = imput[3]

hang = Math::PI*(30*h + m/2)/180
mang = Math::PI*m*6/180
ang = mang - hang

mx = Math.cos(ang)*b
my = Math.sin(ang)*b

puts Math.sqrt((a-mx)**2 + (my)**2)

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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c)
#define Scs(s) scanf("%s", s)
#define Scstr(s) scanf("%s", &s)
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

  int N;
  Scd(N);
  printf("%d\n", 999-(N-1)%1000 );
  
  return 0;
  
}


Measured memory_bytes: 3816
require 'pp'
n = gets.to_i
s = gets.chomp.chars
t = gets.chomp.chars
# p s
# p t
# puts '------------'
size = 2 * n
n.times do |i|
  # p s[i..-1].zip(t[0..(n-i-1)])
  if s[i..-1].zip(t[0..(n-i-1)]).all?{|(a,b)|a==b}
    size = 2 * n - s[i..-1].zip(t[0..(n-i-1)]).size
    break
  end
end
p size

# 5 2 4


Measured memory_bytes: 2300
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    a,b = LI()
    if (a-b)%2 == 0:
        print((a+b)//2)
    else:
        print("IMPOSSIBLE")
    return

#B
def B():
    n = I()
    p = LI()
    k = [p[i] for i in range(n)]
    k.sort()
    s = 0
    for i in range(n):
        s += (p[i] != k[i])
    if s < 3:
        print("YES")
    else:
        print("NO")
    return

#C
def C():
    n = I()
    a = LI()
    b = LI()
    b.append(0)
    ans = 0
    sb = sum(b)
    i = n
    while i >= 0:
        if a[i] > b[i]:
            a[i] -= b[i]
            b[i] = 0
        else:
            b[i] -= a[i]
            a[i] = 0
        if a[i] > b[i-1]:
            a[i] -= b[i-1]
            b[i-1] = 0
        else:
            b[i-1] -= a[i]
            a[i] = 0
        i -= 1

    print(sb-sum(b))
    return

#D
def D():
    s = input()
    n = len(s)
    dp = [[0]*13 for i in range(n+1)]
    f = [0]*13
    dp[0][0] = 1
    for i in range(13):
        f[i] = (i*10)%13
    for i in range(n):
        if not s[i].isdecimal():
            for j in range(13):
                for k in range(10):
                    dp[i+1][(f[j]+k)%13] += dp[i][j]
                    dp[i+1][(f[j]+k)%13] %= mod

        else:
            k = int(s[i])
            for j in range(13):
                dp[i+1][(f[j]+k)%13] += dp[i][j]
                dp[i+1][(f[j]+k)%13] %= mod

    print(dp[n][5])
    return

#E
def E():
    n = I()

    return

#F
def F():
    n = I()

    return

#Solve
if __name__ == "__main__":
    D()


Measured memory_bytes: 63648
import java.util.Scanner;

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

		int N = sc.nextInt();
		int K = sc.nextInt();

		sc.close();

		MAX = Math.max(N - K + 1, K - 1);
		COMinit();

		for(int i = 1;i <= K;i++) {
			long output = COM(N - K + 1, i) * COM(K - 1, i - 1) % MOD;
			System.out.println(output);
		}


	}

	private static int MAX;
	private static int MOD = 1000000007;

	private static long[] fac;
	private static long[] finv;
	private static long[] inv;

	static void COMinit() {
		fac = new long[MAX + 1];
		finv = new long[MAX + 1];
		inv = new long[MAX + 1];

		fac[0] = 1;
		fac[1] = 1;
		finv[0] = 1;
		finv[1] = 1;
		inv[1] = 1;

		for(int i = 2;i <= MAX;i++) {
			fac[i] = fac[i - 1] * i % MOD;
			inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
			finv[i] = finv[i - 1] * inv[i] % MOD;
		}
	}

	static long COM(int n, int k) {
		if(n < k) return 0;
		if(n < 0 || k < 0) return 0;
		return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
	}

}

Measured memory_bytes: 22356
import sys
sys.setrecursionlimit(1000000)

N = int(input())
M = [[] for i in range(N+1)]

for i in range(N-1):
    a, b, c = list(map(int, input().split(" ")))
    M[a].append((b,c))
    M[b].append((a,c))

Qn, K = list(map(int, input().split(" ")))

Q = []
for i in range(Qn):
    Q.append(list(map(int, input().split(" "))))

distance = [0]*(N+1)

def dfs(k, parent, dist):
    for n, x in M[k]:
        if n != parent:
            distance[n] = dist + x
            dfs(n, k, dist + x)

dfs(K, 0, 0)
for q in Q:
    print(distance[q[0]] + distance[q[1]])


Measured memory_bytes: 164608
from itertools import*
from math import*
from collections import*
from heapq import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = float("inf")
mod = 10**9+7
from functools import reduce
import sys
sys.setrecursionlimit(10**7)


def f(N,A,B):
    dp = [0]*(N+1)
    for i in range(N+1):
        x = i
        for j in range(3):
            if i >= A[j]:
                y = dp[i-A[j]]+B[j]
                if x < y:
                    x = y
        dp[i] = x
    return dp[N]
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
print(f(f(N,A,B),B,A))

Measured memory_bytes: 230808
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

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

    int n; cin >> n;
    vector<int> v;
    for (int i = 1; i <= n; i++)
        v.push_back(i);

    vector<int> p;
    REP(i, n) {
        int tmp;
        cin >> tmp;
        p.push_back(tmp);
    }

    vector<int> q;
    REP(i, n) {
        int tmp;
        cin >> tmp;
        q.push_back(tmp);
    }

    bool a = false;
    int countP = 0;
    bool b = false;
    int countQ = 0;
    int count = 0;
    while (a == false || b == false) {
        if (v == p) {
            a = true;
            countP = count;
        }
        if (v == q) {
            b = true;
            countQ = count;
        }
        next_permutation(v.begin(), v.end());
        count++;
    }

    cout << abs(countP - countQ) << '\n';
    return 0;
}


Measured memory_bytes: 256
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b) {
  return b ? GCD(b,a%b) : a;
}


ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n;
  cin>>n;
  vector<ll> a(n),b(n),v(n);
  vector<vector<ll>> ans;
  rep(i,n) cin>>a[i];
  rep(i,n) cin>>b[i];
  rep(i,n) v[i]=i+1;
  do{
    ans.push_back(v);
  }while(next_permutation(ALL(v)));
  ll x,y;
  rep(i,ans.size()){
    if(ans[i]==a) x=i;
    if(ans[i]==b) y=i;
  }
  cout<<abs(x-y)<<endl;
}

Measured memory_bytes: 4408
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cassert>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL << 60)
#define EPS (1e-10)
using namespace std;
typedef long long Int;
typedef pair<int, int> P;

Int n, c, ans, q;

int main() {
  cin >> n;
  ans = 0;

  for(Int p = 1; p <= n; p++) {
    c = n / p;
    q = c * p;
    ans += (p + q) * c / 2;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3592
object Main extends App {
  
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt()
  val a = Array.fill(n)(sc.nextLong())
  val asc = a.scanLeft(0L)(_ + _)
  val desc = a.scanRight(0L)(_ + _)
  val diff = asc.zip(desc).map{case (x, y) => math.abs(x - y)}
  println(diff.min)
}


Measured memory_bytes: 80516
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8')

const [a, b, c, d] = stdin
  .split('\n')[0]
  .split(' ')
  .map(Number)

let is = false
if (Math.abs(a - b) <= d && Math.abs(b - c) <= d) is = true
if (Math.abs(a - c) <= d) is = true

console.log(is ? 'Yes' : 'No')


Measured memory_bytes: 7372
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define fi first
#define se second
#define em emplace
#define eb emplace_back
#define mp make_pair
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int(v.size())
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep2(i, n, m) for (ll i = n; i <= (m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (m); --i)

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

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

constexpr ll MOD = 1000000007;

#include <cstdint>

template <std::uint_fast64_t Modulus> class modint {
  using u64 = std::uint_fast64_t;

public:
  u64 a;

  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};

using mint = modint<1000000007>;

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  ll n; cin >> n;
  vll a(n);
  rep(i, n) cin >> a[i];

  vector<mint> sum(n+1, 0);
  rep(i, n) sum[i+1] += sum[i] + a[i];

  mint ans = 0;
  rep(i, n-1) ans += mint(a[i]) * (sum[n] - sum[i+1]);

  cout << ans.value() << endl;

  return (0);
}

Measured memory_bytes: 6368
x=[]
b2=0
b3=0
b1=0
b4=0
a1=input().split()
a1[0]=int(a1[0])
a1[1]=int(a1[1])
a2=input().split()
a2[0]=int(a2[0])
a2[1]=int(a2[1])
a3=input().split()
a3[0]=int(a3[0])
a3[1]=int(a3[1])
x.append(a1[0])
x.append(a1[1])
x.append(a2[0])
x.append(a2[1])
x.append(a3[0])
x.append(a3[1])
for i in range(6):
    if x[i]==1:
        b1+=1
    elif x[i]==2:
        b2+=1
    elif x[i]==3:
        b3+=1
    else:
        b4+=1
if b2==2 and b3==2:
    print('YES')
elif b1==2 and b2==2:
    print('YES')
elif b1==2 and b3==2:
    print('YES')
elif b1==2 and b4==2:
    print('YES')
elif b4==2 and b3==2:
    print('YES')
elif b2==2 and b4==2:
    print('YES')
else:
    print('NO')
                   

Measured memory_bytes: 3064
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    def lca(x,y):
        k = depth[x] - depth[y]
        while k > 0:
            x = par[x][int(math.log(k,2))]
            k = depth[x] - depth[y]
        k = -k
        while k > 0:
            y = par[y][int(math.log(k,2))]
            k = depth[y] - depth[x]
        if x == y:
            return x
        for i in range(17)[::-1]:
            if par[x][i] != par[y][i]:
                x = par[x][i]
                y = par[y][i]
        return par[x][0]
    n,s,t = LI()
    s -= 1
    t -= 1
    v = [[] for i in range(n)]
    f = [0]*n
    for i in range(n-1):
        a,b = LI()
        a -= 1
        b -= 1
        v[a].append(b)
        v[b].append(a)
        f[a] += 1
        f[b] += 1
    l = []
    for i in range(n):
        if f[i] == 1:
            l.append(i)
    par = [[] for i in range(n)]
    par[t].append(t)
    depth = [-1]*n
    depth[t] = 0
    q = deque([t])
    while q:
        x = q.popleft()
        for y in v[x]:
            if depth[y] < 0:
                depth[y] = depth[x]+1
                q.append(y)
                par[y].append(x)
    d = [-1]*n
    d[s] = 0
    q = deque([s])
    while q:
        x = q.popleft()
        for y in v[x]:
            if d[y] < 0:
                d[y] = d[x]+1
                q.append(y)
    for i in range(16):
        for x in range(n):
            par[x].append(par[par[x][i]][i])
    l.sort(key = lambda x:-depth[x])
    for i in l:
        x = lca(i,s)
        if d[x] < depth[x]:
            break
    print(depth[i]-1)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 121248
//abc075_d.cpp
//Sat Aug 11 19:46:35 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	int n,knum;
	cin >> n >> knum;

	int x[n],y[n];
	int x2[n],y2[n];
	for (int i=0;i<n;i++){
		cin >> x[i] >> y[i];
		x2[i] = x[i];
		y2[i] = y[i];
	}

	sort (x2,x2+n);
	sort (y2,y2+n);

	ll area = LLINF;

	for (int i=0;i<n-1;i++){
		for (int j=i+1;j<n;j++){
			int bx = x2[i];
			int tx = x2[j];
			if (bx == tx){
				continue;
			}
			for (int k=0;k<n-1;k++){
				for (int l=k+1;l<n;l++){
					int by = y2[k];
					int ty = y2[l];
					if (by == ty){
						continue;
					}
					int dnum = 0;
					for (int m=0;m<n;m++){
						if (x[m]>=bx && x[m]<=tx && y[m]>=by && y[m]<=ty){
							dnum++;
						}
					}

//					cout << dnum << " " << bx << " " << tx << " " << by << " " << ty << endl;

					if (dnum>=knum){
						ll tempx = tx-bx;
						ll tempy = ty-by;
						ll temparea = tempx*tempy;
						if (area > temparea){
							area = temparea;
						}
					}
				}
			}
		}
	}

	cout << area << endl;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
 
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define speedhack() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define form(i, n) for (size_t i = 0; i < size_t(n); ++i)
#define forn(i, n) for (size_t i = 1; i <= size_t(n); ++i)
template<class T> using ordered_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
long long mod(long long a, long long b) { return (a%b+b)%b; }
long long gcd(long long x, long long y) { return __gcd(x, y); }
long long lcm(long long x, long long y) { return x * 1ll * y / gcd(x, y); }
 
 
const long long MAXN = 1e9 + 9;
const long long SIZE = 3e5 + 5;
const long long MOD = 1e9 + 7;


int N, M, color = 1, res = -1, C[2], D[2], m[1010][1010];

int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
int dy[] = {1, -1, 0, 0, -1, 1, -1, 1};

queue<pair<int, int>> q;

set<int> adj[1001000];

bool used[1010][1010], was[1001000];

bool ok (int i, int j) {
	if (1 <= i && i <= N && 1 <= j && j <= M) return true;
	else return false;
}


void paint (int i, int j) {
	m[i][j] = color;
	used[i][j] = true;
	for (int s = 0; s < 4; s++) {
		if (m[i + dx[s]][j + dy[s]] != 1 && !used[i + dx[s]][j + dy[s]] && ok (i + dx[s], j + dy[s])) 
			paint (i + dx[s], j + dy[s]);
	}
}

void bfs () {
	q.push({m[C[0]][C[1]], 0});
	was[m[C[0]][C[1]]] = true;

	while (!q.empty()) {
		int v = q.front().first;
		int len = q.front().second;
		q.pop();

		if (v == m[D[0]][D[1]]) {
			res = len;
			return;
		}

		for (int to : adj[v]) {
			if (!was[to]) {
				was[to] = true;
				q.push({to, len + 1});
			}
		}
	}

}

int main() { speedhack()

	cin >> N >> M;

	cin >> C[0] >> C[1];
	cin >> D[0] >> D[1];

	forn (i, N) {
		forn (j, M) {
			char c; cin >> c;
			if (c == '#') 
				m[i][j] = 1;
		}
	}

	forn (i, N) {
		forn (j, M) {
			if (m[i][j] != 1 && !used[i][j]) {
				++color;
				paint (i, j);
			}
		}
	}

	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= M; j++) {
			if (m[i][j] != 1) {
				for (int ii = i - 2; ii <= i + 2; ii++) {
					for (int jj = j - 2; jj <= j + 2; jj++) {
						if (ok (ii, jj) && m[ii][jj] > 1) {
							adj[m[ii][jj]].insert(m[i][j]);
							adj[m[i][j]].insert(m[ii][jj]);
						}
					}
				}
			}
		}
	}

	bfs ();

	if (m[C[0]][C[1]] == 1 || m[D[0]][D[1]] == 1)
		res = -1; 

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 79816
#include <iostream>
using namespace std;
int main(){
	int x,y;
	while (1) {
		cin>>x>>y;
		if(x==0&&y==0)break;
		if(x>y){
			cout<<y<<" "<<x<<endl;
		}else{
			cout<<x<<" "<<y<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3100
n = int(input())
V = [int(i) for i in input().split()]

even_dict = {}
odd_dict = {}
for i in range(n):
    if i % 2 == 0:
        if V[i] not in even_dict:
            even_dict[V[i]] = 1
        else:
            even_dict[V[i]] += 1

    else:
        if V[i] not in odd_dict:
            odd_dict[V[i]] = 1
        else:
            odd_dict[V[i]] += 1
            
even_max = max(even_dict, key=even_dict.get)
odd_max = max(odd_dict, key=odd_dict.get)
if len(even_dict) == len(odd_dict) == 1:
    if even_max == odd_max:
        print(n // 2)
    else:
        print(0)

else:
    even_count = sorted(even_dict.values(), reverse=True)
    odd_count = sorted(odd_dict.values(), reverse=True)
    if even_max == odd_max:
        if len(even_dict) != 1 and len(odd_dict) != 1:
            change1 = even_count[0] + odd_count[1]
            change2 = even_count[1] + odd_count[0]
            print(n - max(change1, change2))
        elif len(even_dict) == 1:
            print(n - (even_count[0]+odd_count[1]))
        else:
            print(n - (even_count[1]+odd_count[0]))

    else:
        print(n - (even_count[0]+odd_count[0]))

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

int main(void)
{
  int n;
  int subject[5];
  int sum[100];
  
  while(1)
    {
      for(int i = 0 ; i < 5 ; i++) subject[i] = 0;
      for(int i = 0 ; i < 100 ; i++) sum[i] = 0;

      cin >> n;
      if(n == 0) break;
      
      for(int i = 0 ; i < n ; i++)
	{
	  for(int j = 0 ; j < 5 ; j++)
	    {
	      cin >> subject[j];
	      sum[i] += subject[j];
	    }
	}
      sort(sum, sum + n);
      cout << sum[n-1] << ' ' << sum[0] << endl;
    }
  return 0;
}

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

int main() {
    int r, g, b, n;
    cin >> r >> g >> b >> n;
    int ans = 0;
    for (int i = 0; i <= n; i += r) {
        for (int j = 0; j <= n; j += g) {
            int k = n - i - j;
            if (k >=0 && k % b == 0) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int gcd(int x, int y){
    if (y == 0){
        return x;
    }
    else{
        return gcd(y, x % y);
    }
}

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

    long long ans = 0;

    for (int i = 1; i < K + 1; i++){
        for (int j = 1; j < K + 1; j++){
            for (int k = 1; k < K + 1; k++){
                ans += gcd(gcd(i,j),k);
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <set>
#include <utility>
#include <tuple>

using namespace std;

typedef pair<int, pair<int, int> > P;

int table[2001][20001][3];

/*
void maketable(){
	for (int i = 1; i < 2001; i++){
		for (int j = 1; j < 20001; j++){
			table[i][j][0] = table[i][j][1] = table[i][j][2] = 0;
		}
	}

	table[1][1][0] = 1; table[1][1][1] = table[1][1][2] = 0;
	table[1][10][0] = 0; table[1][10][1] = 0; table[1][10][2] = 1;
	table[1][5][0] = 0; table[1][5][1] = 1; table[1][5][2] = 0;


	for (int i = 2; i < 2001; i++){
		for (int j = 2; j < 20001; j++){
			if (table[i-1][j-1][0] != 0 || table[i-1][j-1][1] != 0 || table[i-1][j-1][2] != 0){
				table[i][j][0] = table[i-1][j-1][0] + 1;
				table[i][j][1] = table[i-1][j-1][1];
				table[i][j][2] = table[i-1][j-1][2];
			}
			else if (j >= 5){
				if (table[i-1][j-5][0] != 0 || table[i-1][j-5][1] != 0 || table[i-1][j-5][2] != 0){
					table[i][j][0] = table[i-1][j-5][0];
					table[i][j][1] = table[i-1][j-5][1] + 1;
					table[i][j][2] = table[i-1][j-5][2];
				}
			}
			else {
				if (j >= 10){
					if (table[i-1][j-10][0] != 0 || table[i-1][j-10][1] != 0 || table[i-1][j-10][2] != 0){
						table[i][j][0] = table[i-1][j-10][0] + 1;
						table[i][j][1] = table[i-1][j-10][1];
						table[i][j][2] = table[i-1][j-10][2];
					}
				}
			}
		}
	}
}
*/



int main(void){

	int n, y;

	cin >> n >> y;

	int a = -1, b = -1, c = -1;
	for (int i = 0; i <= n; i++){
		for (int j = 0; j <= n; j++){
			if (i + j > n)
				break;
			if (i + j*5 + (n - i - j) * 10 == y/1000){
				c = i;
				b = j;
				a = n - j - i;
			}
		}
	}

	cout << a << " " << b << " " << c << endl;

}

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

const int N = 2e5 + 5;

int n, a[N];
map <int, int> ma;

int read() {
    int x = 0, f = 1; char s;
    while((s = getchar()) < '0' || s > '9') if(s == '-') f = -1;
    while(s >= '0' && s <= '9') {x = (x << 1) + (x << 3) + (s ^ 48); s = getchar();}
    return x * f;
}

int main() {
    long long ans = 0;
    n = read();
    for(int i = 1; i <= n; ++ i) a[i] = read(), ++ ma[i - a[i]];
    for(int i = 1; i <= n; ++ i) ans += ma[i + a[i]];
    printf("%lld\n", ans);
    return 0;
}


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

using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VD = vector<double>;
using VVD = vector<VD>;
using VS = vector<string>;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VL = vector<long long>;
using VVL = vector<VL>;

#define sz(var) (int)var.size()
#define REP(var, start, end) for(int var = start; var < (int)end; ++var)
#define CLEAR(var, with) memset(var, with, sizeof(var))
#define ALL(x) x.begin(), x.end()
#define LL long long
#define ULL unsigned long long
#define TIME cout << "Time elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms" << endl;

int a, b, c, d;
int maxArea()
{
    return max(a * b, c * d);
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
//	freopen("tmp.in", "r", stdin);
//	freopen("tmp.out", "w", stderr);
#endif
    cin >> a >> b >> c >> d;

    cout << maxArea() << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

void insersionSort(int A[1000], int n){
    int i, j, k, v;
 
    for(i=1; i<n; i++){
        v = A[i];
        j =i - 1;
        while(j>=0 && A[j]>v){
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
        printf("%d", A[0]);
        for(k=1; k<n; k++){
             printf(" %d", A[k]);
        }
        printf("\n");
    }

}

int main(){
    int N, i, j, k;
    int A[1000];

    scanf("%d", &N);

    for(i=0; i<N; i++){
        scanf("%d", &A[i]);
    }

    printf("%d", A[0]);
    for(k=1; k<N; k++){
         printf(" %d", A[k]);
    }
   printf("\n");

    insersionSort(A, N);

    return 0;
}

Measured memory_bytes: 1856
//b
#include <iostream>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <memory>
#include <functional>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
 
#define REP(i,b,n) for(int i=b;i<n;i++)
#define REPR(i,b,n) for(int i=n-1;i>=b;i--)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define NCLR(mat) memset(mat, -1, sizeof(mat))
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define EACH(i, c) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define BIT(n, b) ((n>>b) & 1)
#define PB push_back
#define MP make_pair
 
using namespace std;
 
static const double PI = acos(-1.0);
static const double EPS = 1e-9;
typedef long long ll;
typedef pair<int, int> pii;
 
int n;
int s[400], l[400], p[400];
int seg = 0;
int m;
int w[400];
queue<int> res;
 
int dp[400][400];
 
bool solve(){
     
    for(int k=0; k<m; ++k){
         
        CLR(dp);
         
        for(int i=0; i<n; ++i){
            for(int j=0; j<=w[k]; ++j){
             
                    if(j<s[i])
                        dp[i+1][j] = dp[i][j];
                    else
                        dp[i+1][j] = max(dp[i][j], dp[i+1][j-s[i]] + p[i]);
            }
        }
         
         
        int ret = 0;
         
        for(int i=w[k]; i>=w[k]-seg; --i){
            if(dp[n][i] != 0)
                ret = max(ret, dp[n][i]);
        }
         
        if(ret == 0)
            return false;
         
        res.push(ret);
    }
     
    return true;
}
 
int main(){
     
    cin >> n;
     
    for(int i=0; i<n; ++i){
        cin >> s[i] >> l[i] >> p[i];
        seg += l[i]-s[i];
    }
     
    cin >> m;
     
    for(int i=0; i<m; ++i){
        cin >> w[i];
    }
     
    if(solve()==false)
        cout << -1 << endl;
    else{
        while(!res.empty()){
            cout << res.front() << endl;
            res.pop();
        }
    }
     
    return 0;
}

Measured memory_bytes: 1844
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int x = sc.nextInt();
		int a[] = new int[m];
		for(int i=0; i<m; i++){
			a[i] = sc.nextInt();
		}
		int num1 = 0;
		int num2 = 0;
		for(int i=0; a[i]<x; i++){
			if(a[i]<x)num1++;
		}
		num2 = m - num1;
		System.out.print(Math.min(num1,num2));
	}
}

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

int main(){
	int n, y, m, d;
	cin >> n;
	for(int i=0 ; i < n ; i++ ){
		cin >> y >> m >> d;
		int ans = 0;
		while( !(y == 1000 && m == 1 && d == 1) ){
			ans++;
			int m_day = ( y % 3 == 0 || m % 2 == 1 )? 20 : 19;
			if( d == m_day ){
				d = 1;
				if( m == 10 ){
					m = 1;
					y++;
				}else{
					m++;
				}
			}else{
				d++;
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1160
#include <cstdio>
#include <algorithm>

using namespace std;

const int N = 2010;
int n, m, a[N][N], b[N][N], c[N][N], sol, s[N], l[N], r[N];
char z[N];

int main()
{
	scanf("%d %d", &n, &m); sol = max(n, m);
	for (int i = 1; i <= n; i++)
	{
		scanf("%s", z + 1);
		for (int j = 1; j <= m; j++) if (z[j] == '#') a[i][j] = 1;
	}
	for (int i = 1; i < n; i++)
		for (int j = 1; j < m; j++)
		{
			int k = a[i][j] + a[i][j + 1] + a[i + 1][j] + a[i + 1][j + 1];
			if (k & 1) c[i][j] = 1;
		}
	for (int i = 1; i < n; i++)
	{
		for (int j = 1; j < m; j++) if (!c[i][j]) b[i][j] = b[i - 1][j] + 1;
		int sz = 0;
		for (int j = 1; j < m; j++)
		{
			while (sz && b[i][j] <= b[i][s[sz]]) sz--;
			if (!sz) l[j] = 1; else l[j] = s[sz] + 1;
			s[++sz] = j;
		}
		sz = 0;
		for (int j = m - 1; j; j--)
		{
			while (sz && b[i][j] <= b[i][s[sz]]) sz--;
			if (!sz) r[j] = m - 1; else r[j] = s[sz] - 1;
			s[++sz] = j;
		}
		for (int j = 1; j < m; j++) if (b[i][j]) sol = max(sol, (b[i][j] + 1) * (r[j] - l[j] + 2));
	}
	printf("%d", sol);
	return 0;
}

Measured memory_bytes: 47488
// 'g++ -std=c++17 -O2 -Wall -Wextra -Wfatal-errors -o sample sample.cpp'
#include<bits/stdc++.h>
#define int long long
#define sz(a) (int)(a).size()
 
using namespace std;

template <class T> bool uax( T& a , T b , bool action = true ) { if(action){ return (a>=b)?( true ):( a=b,false );} return (a>=b)?( true ):( false );}
template <class T> bool uin( T& a , T b , bool action = true ) { if(action){ return (a<=b)?( true ):( a=b,false );} return (a<=b)?( true ):( false );}

void dfs(int v,vector<int>&in_edges,vector<int>&dist,vector<int> arr[]){
	for( int i : arr[v] ){
		uax(dist[i],dist[v]+1);
		in_edges[i]--;
		if( in_edges[i] == 0 ) dfs(i,in_edges,dist,arr);
	}
}

void solve() {
        int n , m ; 
        cin >> n >> m ;
        vector<int>arr[n+1];
        vector<int>in_edges(n+1,0);
        int a , b ;
        for( int i = 0 ; i < m ; i++ ){
			cin >> a >> b;
			arr[a].push_back(b);
			in_edges[b]++;
		}
		for(int i = 0 ; i < n ; i++ ){
			arr[0].push_back(i+1);
			in_edges[i+1]++;
		}
		vector<int>dist(n+1,0);
		dfs(0,in_edges,dist,arr);
		cout << (*max_element(dist.begin(),dist.end())) - 1 << endl;
}
 
int32_t main() {
 
        ios_base::sync_with_stdio(false);
        cin.tie(nullptr);
        cout << fixed;
        cout.precision(10);
 
        int q = 1;
        //cin >> q;
        while (q--) {
            solve();
        }
        cout << endl;
        return 0;
}


Measured memory_bytes: 10100
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
 
int main()
{
    int a[101][101], b[101], c[101];
    int i, j;
    int n, m;
 
    scanf("%d%d", &n, &m);
    for (i = 0; i < n; i++) {
        for (j = 0; j < m; j++) scanf("%d", &a[i][j]);
    }
    for (j = 0; j < m; j++) scanf("%d", &b[j]);
 
    for (i = 0; i < n; i++) {
        c[i] = 0;
        for (j = 0; j < m; j++) c[i] += a[i][j] * b[j];
    }
 
    for (i = 0; i < n; i++) {
        printf("%d\n", c[i]);
    }
    return 0;
}



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

int main(){
  vector<int> V={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int K;cin >> K;
  cout << V[K-1] << endl;
}

Measured memory_bytes: 256
import * as fs from "fs";

const input = (fs.readFileSync("/dev/stdin", "utf8") as string).split("\n");
//const n = +input[0];
//const a = [];
//for(let i=0;i<n;i++){
//	a.push(input[i+1].split(" ").map((x:string):number=>+x));
//}

//const [n, m] = input[0].split(" ").map((x: string): number => +x);
//const a = input[1].split(" ").map((x: string): number => +x);

function compareFunc(a, b){
    return a-b;
}

const n: number = +input[0];
const s: string = input[1];

const nn = Math.floor(n/2);

const s1 = s.substr(0,nn);
const s2 = s.substr(nn);

if(s1 === s2){
    console.log('Yes');
}else{
    console.log('No');
}

Measured memory_bytes: 7372
#include<stdio.h>

int main()
{
   int a,b,c ;
   scanf("%d %d %d",&a,&b,&c) ;

  if(a==b)
   {
       printf("%d",c) ;
   }

   else if(c==b)
   {
       printf("%d",a) ;
   }

  else
   {
       printf("%d",b) ;
       
   } 

   return 0 ;

}


Measured memory_bytes: 128