akhauriyash/Code-Regression huggingface dataset:
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let a: String = input();
    let b: String = input();
    println!(
        "{}",
        if (a == "H" && b == "H") || (a == "D" && b == "D") {
            "H"
        } else {
            "D"
        }
    );
}


Measured memory_bytes: 4352
# Studying https://img.atcoder.jp/abc164/editorial.pdf

# Inputs

N,M,S = gets.split.map(&:to_i)
E = Array.new(N){ [] }
M.times{
	u,v,a,b = gets.split.map(&:to_i)
	E[u-1] << [v-1,a,b]
	E[v-1] << [u-1,a,b]
}
CD = N.times.map{ gets.split.map(&:to_i) }
X = lambda{|u,ds|
	c,d = CD[u]
	x = (ds+c-1)/c
	return c*x, d*x
}

# Tools

class PQ
	def initialize
		@h = [] # min-heap
	end

	def enq v
		@h << v
		up_heap
	end

	def deq
		min = @h[0]
		last = @h.pop
		unless @h.empty?
			@h[0] = last
			dn_heap
		end
		return min
	end

private
	def up_heap
		i = @h.size-1
		up = @h[i]
		while 0 <= (iP = (i-1)/2)
			break unless up < @h[iP]
			@h[i] = @h[iP]
			i = iP
		end
		@h[i] = up
	end

	def dn_heap
		i = 0
		dn = @h[i]
		sz = @h.size
		while (iC = 2*i+1) < sz
			iC += 1 if iC+1 < sz and @h[iC+1] < @h[iC]
			break unless @h[iC] < dn
			@h[i] = @h[iC]
			i = iC
		end
		@h[i] = dn
	end
end

R = lambda{|t,s,u|
	next t<<18 | [s,2450].min<<6 | u
}

# Main

n,T = 0, [nil]*N
２,３,４ = [-1]*N, [0]*N, [nil]*N
Q = PQ.new; Q.enq R[0,S,0]
while r = Q.deq
	t = r>>18
	s = r>>6&4095
	u = r&63

	next if s <= ２[u] # 銭なしの再訪に用なし
	２[u] = s

	unless T[u] # first arrived.
		T[u] = t
		n += 1
		break if n == N # completed.
	end

	least_s = 2450
	E[u].each{|v,a,b|
		z = ２[v]+a
		y = ３[v]+a # z < y
		if z<s
			c,d = s<y ? X[v,y-s] : [0,0]
			Q.enq(４[v] = r) if ４[v] != r = R[t+b+d,s-a+c,v]
		end
		least_s = [[s,z].max+1,least_s].min
	}
	３[u] = least_s

	c,d = X[u,least_s-s]
	Q.enq(４[u] = r) if ４[u] != r = R[t+d,s+c,u]
end

# Output

T.shift
p(*T)


Measured memory_bytes: 14532
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
int n;
int v[1010];
long double ans = 0;

int main() {
  cin >> n;
  for(int i=0; i<n; i++){ 
    cin >> v[i];
  }
  sort(v,v+n);
  reverse(v,v+n);

  for(int i=0; i<n-1; i++){ 
    ans += v[i]/pow(2,i+1);
  }
  ans += v[n-1]/pow(2,n-1);
  
  cout << fixed << setprecision(6) << ans << endl; 
  return 0;
}  


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
static const int INF = 2000000000;

const ll mod = 1000000007;
ll f (ll C){
  ll ans = C*C*C*C*C;
  return ans;
}

int main() {
  ll x;
  cin >> x;
  for (int i = -1000; i < 1000; i++){
    for (int j = -1000; j < 1000; j++){
      ll a = f(i), b = f(j);
      if (a - b == x) {
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }
}

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

#define mod 1000000007
typedef long long ll;

ll fact[1000006], inv[1000006];

ll fp(ll base, ll exp)
{
    if (exp == 0)
        return 1;
    ll ans = fp(base, exp / 2);
    ans = (ans * ans) % mod;
    if (exp % 2 != 0)
        ans = (ans * (base % mod)) % mod;
    return ans;
}

void calcFacAndInv(ll n)
{
    fact[0] = inv[0] = 1;
    for (ll i = 1; i <= n; i++)
    {
        fact[i] = (i * fact[i - 1]) % mod;
        inv[i] = fp(fact[i], mod - 2);
    }
}

ll ncr(ll n, ll r)
{
    return ((fact[n] * inv[r]) % mod * inv[n - r]) % mod;
}

ll npr(ll n, ll r)
{
    return (fact[n] * inv[n - r]) % mod;
}

int main()
{
    ll dp[102][100005], a[100005][2];
    int n, w;
    cin >> n >> w;
    for (int i = 0; i < n; i++)
        cin >> a[i][0] >> a[i][1];
    for (int i = 0; i <= w; i++)
        dp[n][i] = 0;
    for (int i = n - 1; i > -1; i--)
        for (int j = 0; j <= w; j++)
        {
            dp[i][j] = dp[i + 1][j];
            if (j >= a[i][0])
                dp[i][j] = max(dp[i + 1][j - a[i][0]] + a[i][1], dp[i][j]);
        }
    cout << dp[0][w];
    return 0;
}


Measured memory_bytes: 80256
import Control.Monad (replicateM_)

main = do
    count <- fmap read $ getLine :: IO (Int)
    replicateM_ count sub
    where
    sub = do
        line <- getLine
        let
            [a,b,c] = map read $ words line :: [Int]
        if isRightTriangle a b c
            then putStrLn "YES"
            else putStrLn "NO"

isRightTriangle :: Int -> Int -> Int -> Bool
isRightTriangle a b c = or [a*a+b*b==c*c, b*b+c*c==a*a, c*c+a*a==b*b]

Measured memory_bytes: 4120
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

std::string s[100100],ans;
int a[3],n;

bool solve(int i){
	char x = s[i][0], y = s[i][1];
	if(!(a[x-'A']||a[y-'A'])){
		return false;
	}
	if(!a[x-'A']){
		++a[x-'A']; --a[y-'A'];
		ans.push_back(x);
		return true;
	}
	if(!a[y-'A']){
		--a[x-'A']; ++a[y-'A'];
		ans.push_back(y);
		return true;
	}
	if(i==n){
		++a[x-'A']; --a[y-'A'];
		ans.push_back(x);
		return true;
	}
	if(s[i]==s[i+1]){
		if(a[x-'A']>a[y-'A']){
			--a[x-'A']; ++a[y-'A'];
			ans.push_back(y);
		}else{
			++a[x-'A']; --a[y-'A'];
			ans.push_back(x);
		}
		return true;
	}
	if(x == s[i+1][0] || x == s[i+1][1]){
		++a[x-'A']; --a[y-'A'];
		ans.push_back(x);
	}else{
		--a[x-'A']; ++a[y-'A'];
		ans.push_back(y);
	}
	return true;
}

int main(void){
	int i,m=0;
	std::cin >> n >> a[0] >> a[1] >> a[2];
	for(i=0; i<n; ++i){
		std::cin >> s[i];
	}
	for(i=0; i<n; ++i){
		if(!solve(i)){
			std::cout << "No" << std::endl;
			return 0; 
		}
	}
	std::cout << "Yes" << std::endl;
	for(i=0; i<n; ++i){
		std::cout << ans[i] << std::endl;
	}
	return 0;
}


Measured memory_bytes: 6908
using System.Linq;
using System.Collections.Generic;
using static System.Console;
class Z { static void Main() => new K(); }
class K
{
	const long MOD = 1000000007;
	static int[] G => ReadLine().Split().Select(int.Parse).ToArray();
	int N;
	long ans, D;
	long[] ds, dt, cs, ct;
	bool[] done;
	List<E>[] g;
	public K()
	{
		var I = G;
		N = I[0];
		var M = I[1];
		I = G;
		var s = I[0] - 1;
		var t = I[1] - 1;
		g = new List<E>[N];
		for (var i = 0; i < N; i++) g[i] = new List<E>();
		for (var i = 0; i < M; i++)
		{
			I = G;
			int a = I[0] - 1, b = I[1] - 1, c = I[2];
			g[a].Add(new E(b, c));
			g[b].Add(new E(a, c));
		}
		DijkstraFrom(s, ref ds, ref cs);
		DijkstraFrom(t, ref dt, ref ct);
		/*ds = DijkstraFrom(s);
		cs = Count(s, ds);
		ct = Count(t, DijkstraFrom(t));*/
		done = new bool[N];
		ans = cs[t] * cs[t] % MOD;
		D = ds[t];
		DFS(t);
		WriteLine((ans %= MOD) < 0 ? ans + MOD : ans);
	}
	long S(long x) => x * x % MOD;
	void DFS(int u)
	{
		if (done[u]) return;
		done[u] = true;
		if (2 * ds[u] == D) ans -= S(cs[u] * ct[u] % MOD);
		foreach (var e in g[u]) if (ds[e.V] + e.D == ds[u])
			{
				if (2 * ds[u] > D && 2 * ds[e.V] < D) ans -= S(ct[u] * cs[e.V] % MOD);
				DFS(e.V);
			}
	}
	/*long[] Count(int u, long[] d)
	{
		var t = new PriorityQueue();
		for (var i = 0; i < N; i++) t.Enqueue(new E(i, d[i]));
		t.Dequeue();
		var c = new long[N];
		c[u] = 1;
		while (t.Count > 0)
		{
			var v = t.Dequeue().V;
			foreach (var e in g[v]) if (d[e.V] + e.D == d[v]) c[v] = (c[v] + c[e.V]) % MOD;
		}
		return c;
	}*/
	void DijkstraFrom(int u, ref long[] d, ref long[] c)
	{
		d = new long[N]; c = new long[N];
		for (var v = 0; v < N; v++) d[v] = 4011686018427387913L;
		var queue = new PriorityQueue();
		d[u] = 0; c[u] = 1;
		queue.Enqueue(new E(u, 0));
		while (queue.Count > 0)
		{
			var p = queue.Dequeue();
			var v = p.V;
			if (d[v] < p.D) continue;
			foreach (var e in g[v])
			{
				var t = d[v] + e.D;
				if (d[e.V] > t) { queue.Enqueue(new E(e.V, d[e.V] = t)); c[e.V] = c[v]; }
				else if (d[e.V] == t) c[e.V] = (c[e.V] + c[v]) % MOD;
			}
		}
	}
}
struct E
{
	public readonly int V;
	public readonly long D;
	public E(int v, long d) { V = v; D = d; }
	public int CompareTo(E e) => D.CompareTo(e.D);
}
class PriorityQueue
{
	readonly List<E> a = new List<E>();
	public int Count { get; private set; } = 0;
	public void Enqueue(E x)
	{
		var i = Count++;
		a.Add(x);
		while (i > 0)
		{
			var p = (i - 1) / 2;
			if (a[p].CompareTo(x) <= 0) break;
			a[i] = a[p];
			i = p;
		}
		a[i] = x;
	}
	public E Dequeue()
	{
		var v = a[0];
		var x = a[--Count];
		a.RemoveAt(Count);
		if (Count == 0) return v;
		var i = 0;
		while (i * 2 + 1 < Count)
		{
			var l = 2 * i + 1;
			var r = 2 * i + 2;
			if (r < Count && a[r].CompareTo(a[l]) < 0) l = r;
			if (a[l].CompareTo(x) >= 0) break;
			a[i] = a[l];
			i = l;
		}
		a[i] = x;
		return v;
	}
	public E Peek() => a[0];
}


Measured memory_bytes: 53764
import java.util.Scanner;

/*
 class ToiN implements Toi{
	public void exec(String[] args){
		solve();
	}
	public void solve(){
	
	}
}
  */

interface Toi{
	public void exec(String[] args);
}

public class Main {
	public static void main(String[] args){
	Toi toi = new Toi12();
	toi.exec(args);
	}
}

class Toi8 implements Toi{
	public void exec(String[] args){
		solve();
	}
	public void solve(){
		Scanner sc = new Scanner(System.in);
		int[] whxyr = new int[5];
		for(byte i = 0;i < whxyr.length;i++){
			whxyr[i] = sc.nextInt();
		}
		calc(whxyr);
		int[] renewWh = {whxyr[0] - whxyr[4], whxyr[1] - whxyr[4], whxyr[2] + whxyr[4], whxyr[3] + whxyr[4]};
		if(renewWh[0] >= 0 && renewWh[1] >= 0 && renewWh[2] <= whxyr[0] && renewWh[3] <= whxyr[1]){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
	public int[] calc(int[] array){
		int tmp;
		for(byte i = 0;i < array.length - 2;i++){
			if(array[i + 2] < 0){
				tmp = array[i];
				array[i] = array[i + 2];
				array[i + 2] = tmp;
			}
		}
		return array;
	}
}

class Toi9 implements Toi{
	public void exec(String[] args){
		solve();
	}
	public void solve(){
		for(short i = 0;i < 1000;i++){
			System.out.println("Hello World");
		}
	}
}

class Toi10 implements Toi{
	public void exec(String[] args){
		solve();
	}
	public void solve(){
		short[] tmp = new short[10000];
		Scanner sc = new Scanner(System.in);
		for(short i = 0;i < 10000;i++) {
			try {
				tmp[i] = sc.nextShort();
				if (tmp[i] == 0) {
					break;
				}
			}catch (Exception e){
				break;
			}
		}
		for(short i = 1;i <= 10000;i++){
			if(tmp[i-1] == 0){
				break;
			}
			System.out.println("Case " + i + ": " + tmp[i-1]);
		}
	}
}

class Toi11 implements Toi{
	public void exec(String[] args){
		solve();
	}
	public void solve(){
		short[] xy = new short[6000];
		Scanner sc = new Scanner(System.in);
		short point = 0;
		for(short i = 0;i < 3000;i++) {
			try {
				xy[i] = sc.nextShort();
				xy[i+3000] = sc.nextShort();
			}catch (Exception e){
				break;
			}
			if (xy[i] == 0 && xy[i+3000] == 0){
				point = i;
				break;
			}
		}
		for(short i = 1;i <= point;i++){
			if(xy[i-1] < xy[i+3000-1]) {
				System.out.println(xy[i-1] + " " + xy[i+3000-1]);
			}else {
				System.out.println(xy[i+3000-1] + " " + xy[i-1]);
			}
		}
	}
}

class Toi12 implements Toi{
	public void exec(String[] args){
		solve();
	}
	public void solve(){
		short[] abc = new short[5];
		Scanner sc = new Scanner(System.in);
		for (byte i = 0;i < 3;i++){
			abc[i] = sc.nextShort();
		}
		short[] f = new short[5000];
		for(short i = 0;i < 5000;i++){
			f[i] = 0;
		}
		calc(abc[2], f);
		short count = 0;
		for(short i = 0;i < 5000;i++) {
			if (f[i] >= abc[0] && f[i] <= abc[1]) {
				count++;
			} else {
				continue;
			}
		}
		System.out.println(count);
	}
	public void calc(short inputNum,short[] outputArray){
		for(short i = 1,j = 0;i <= inputNum;i++){
			if(inputNum % i ==  0){
				outputArray[j] = i;
				j++;
			}
		}
	}
}


Measured memory_bytes: 26424
//													\[T]/ Praise
//													 (*)  The
//													 / \  Sun



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

typedef long long ll;
typedef long double dbl;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<long long> vl;
typedef vector< pair<int, int> > vii;
#define mp make_pair
#define pb push_back
#define invec(a, n) for(ll i = 0; i < n; i++) {cin >> a[i];}
#define rep(n) for(ll i = 0; i < n; i++)
#define fr(i,j,k) for(ll i = j; i < k; i++)
#define FR(i,j,k) for(ll i = j; i >= 0; i--)
#define MOD 1000000007
#define all(v) v.begin(), v.end()
#define INF 1000000
#define xx first
#define yy second

void fast()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}

int main()
{

	//#ifndef ONLINE_JUDGE
	//freopen("/home/ram/Competitive Programming/IO/in.txt", "r", stdin);
	//freopen("/home/ram/Competitive Programming/IO/out.txt", "w", stdout);
	//#endif

	int n;
	cin >> n;

	vl a(n), dp(n);

	invec(a,n);

	dp[0] = 0;

	dp[1] = abs(a[0]-a[1]);

	fr(i,2,n)
	{
		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] << "\n";

}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin>>n;
  vector<int>value(n);
  vector<int>cost(n);
  for(int i;i<n;i++){
    cin>>value.at(i);
  }
  for(int i;i<n;i++){
    cin>>cost.at(i);
  }
  int sum=0;
  for(int i;i<n;i++){
    if(value.at(i)>cost.at(i)){
      sum+=value.at(i)-cost.at(i);
    }
  }
  cout<<sum<<endl;
  

}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()


const int MAXN = 100, MAXS = 6;
const int T = 1, C = 2, B = 3, TT = 4, CC = 5, BB = 6;
const int DS = 3;
const int res[4][4] = {{0,0,0,0}, {C,B,CC,BB},{B,T,BB,TT},{T,C,TT,CC}};
const int MOD = 10000;

int main()
{
    int n, k; cin >> n >> k;
    long long dp[MAXS + 10][MAXN + 10] = {};
    int s[MAXN + 1] = {};
    int a, b;
    REP(k) {cin >> a; a--; cin >> s[a];}

    if(s[0] > 0) dp[s[0]][0] = 1;
    else dp[T][0] = dp[C][0] = dp[B][0] = 1;

    for(int i = 1; i< n; i++)
        if(s[i] > 0)
        {
            rep(j, 4){(dp[s[i]][i] += dp[res[s[i]][j] ][i - 1]) %= MOD;}
            dp[s[i] + DS][i] = dp[s[i]][i - 1];
        }
        else
        {
            for(int t = 1; t <= 3;t++)
                rep(j, 4) (dp[t][i] += dp[res[t][j] ][i - 1]) %= MOD;
            for(int t = 4; t <= 6; t++)
                dp[t][i] = dp[t - DS][i - 1];
        }
    long long ans  = 0;
    REP(6) (ans += dp[i + 1][n - 1]) %= MOD;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1176
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int main(){

	int num_dice;
	scanf("%d",&num_dice);

	double maximum = -1.0,tmp,tmp_exp;

	int n,m;
	double value[100],prob[100];

	for(int loop = 0; loop < num_dice; loop++){
		scanf("%d %d",&n,&m);
		tmp = 0;

		for(int i = 0; i < m; i++){
			scanf("%lf %lf",&value[i],&prob[i]);
			tmp += prob[i];
		}

		tmp_exp = 0;
		for(int i = 0; i < m; i++){
			tmp_exp += value[i]*prob[i]*(1+(1-tmp)/tmp);
		}
		maximum = max(maximum,tmp_exp);
	}

	int p,q;
	scanf("%d %d",&p,&q);
	tmp = 0;
	for(int i = 0; i < q; i++){
		scanf("%lf %lf",&value[i],&prob[i]);
		tmp += prob[i];
	}
	double parent_exp = 0;
	for(int i = 0; i < q; i++){
		parent_exp += value[i]*prob[i]*(1+(1-tmp)/tmp);
	}

	if(parent_exp+ 0.0000001 < maximum){
		printf("YES\n");
	}else{
		printf("NO\n");
	}

	return 0;
}

Measured memory_bytes: 3212
#include <algorithm>
#include <bitset>
#include <cctype>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

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

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

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#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 range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

const int MAX = 101;
const int N = 10;
const int S = 1001;

int main(void){
    vector< vector< vector<ll> > > dp(S, vector< vector<ll> >(N, vector<ll>(MAX + 1)));

    dp[0][0][0] = 1;
    rep(s, S){
        rep(n, N - 1){
            rep(i, MAX){
                if(dp[s][n][i] == 0) continue;

                range(j, i, MAX){
                    if(S <= s + j) break;

                    dp[s + j][n + 1][j + 1] += dp[s][n][i];
                }
            }
        }
    }

    for(int n, s; cin >> n >> s, n;){
        ll sum = 0;

        rep(i, MAX + 1){
            sum += dp[s][n][i];
        }

        cout << sum << endl;
    }

	return 0;
}

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

int n,k;
void dec(vector<int>&v){
	if(v.back()==1){
		v.pop_back();return;
	}
	v.back()--;
	while(v.size()<n)v.push_back(k);
}
int main(){
	cin>>k>>n;
	if(k%2==0){
		cout<<k/2;
		rep(i,n-1){
			printf(" %d",k);
		}
		cout<<endl;
		return 0;
	}
	vector<int>v(n,(k+1)/2);
	rep(i,n/2){
		dec(v);
	}
	rep(i,v.size()){
		if(i)printf(" ");
		printf("%d",v[i]);
	}
	puts("");
}

Measured memory_bytes: 3456
import sys

A, B, M = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]

t = sys.maxsize
for _ in range(M):
    x, y, c = [int(i) for i in input().split()]
    t = min(t, a[x - 1] + b[y - 1] - c)

print(min(t, sorted(a)[0] + sorted(b)[0]))

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n, m) for (int (i) = (n); (i) < (m); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

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

int f(int m) {
   int cnt = 0;
   while (m > 0) {
      if (m&1) cnt++;
      m/=2;
   }
   return cnt;
}

int main() {
   int n, s;
   vec<int> num;
   for (int i = 0; i <= 9; i++) num.push_back(i);

   while (cin >> n >> s, n) {
      int cnt = 0;
      for (int mask = 0; mask < (1<<10); mask++) {
         int sum = 0;
         if (f(mask) != n) continue;
         for (int i = 0; i < 10; i++) {
            if ((mask>>i)&1) {
               sum += num[i];
            }
         }
         if (sum == s) cnt++;
      }
      cout << cnt << endl;
   }

   return 0;
}


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

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cout << #a << " = " << a << endl;

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	int a, b, c;
	cin >> a >> b >> c;
	if (a + b + c >= 22) cout << "bust";
	else cout << "win";
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}



Measured memory_bytes: 256
N, H = map(int,input().split())
L = []
maxi = 0
for _ in range(N):
    a,b = map(int,input().split())
    maxi = max(maxi, a)
    L.append(b)
 
L = sorted([x for x in L if x > maxi],reverse=True)
throw = 0
for i in range(len(L)):
    throw += L[i]
    if throw >= H:
        print(i + 1)
        quit()
from math import ceil
print(ceil((H - throw) / maxi) + len(L))
    


Measured memory_bytes: 62424
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main() {
    int N;
    cin >> N;
    int a[N];
    for(int i = 0; i < N; i++) cin >> a[i];

    map<int, ll> mp;
    for(int i = 0; i < N; i++) mp[a[i]]++;

    ll all = 0;
    for(auto it = mp.begin(); it != mp.end(); it++) {
        ll c = it -> second;
        all += c * (c - 1) / 2;
    }

    for(int i = 0; i < N; i++) {
        ll res = all;
        ll c = mp[a[i]];
        res = res - c * (c - 1) / 2 + (c - 1) * (c - 2) / 2;
        cout << res << endl;
    }

    return 0;
}

Measured memory_bytes: 10240
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		long a = in.nextLong();
		long b = in.nextLong();
		if(a+b==15) {
			System.out.println("+");
		}else if(a*b==15) {
			System.out.println("*");
		}else {
			System.out.println("x");
		}
	}

}

Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef map<int,int> mii;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<long long> vl;
typedef vector<vector<ll>> vll;
typedef vector<bool> vb;
typedef set<int> si; 
#define fori(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i,b,a) for(int i = (b); i >= (a); --i)
#define all(a) (a).begin(), (a).end()
//#define __builtin_popcountll bitCountLL
//#define __builtin_popcount bitCount
//__builtin_ctz 末尾0的个数, __builtin_clz 前导0的个数
//__builtin_ffs 最后一个1的位置
#define maxn 100005
#define Mod 1000000007
const int INF = 2e9;
const ll ML = 4e18;
    
void solve() {
    int n;
    cin >> n;
    vi a(n);
    fori(i,0,n) cin >> a[i];
    ll r = 1000, s = 0;
    fori(i,0,n - 1) {
        if(a[i] < a[i + 1]) {
            s += r / a[i];
            r %= a[i];
        }
        else if(a[i] > a[i + 1]) {
            r += s * a[i];
            s = 0;
        }
    }
    r += s * a[n - 1];
    cout << r;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
	//cout.precision(30); cout << fixed;
	//freopen("D:\\data_in.txt", "r", stdin);
   solve();
   
    /*
    clock_t start,finish;
    start = clock();
    
    finish = clock();
    cout << "\n" << (double)(finish - start) / (double)(CLOCKS_PER_SEC) * 1000 << "ms" << endl;
    */
    return 0;
}

/***************************************************************
 question:
 idea:
 tag:
 record:
 ***************************************************************/


Measured memory_bytes: 3656
n = gets.to_i
w = gets.chomp.split.map(&:to_i)

l = 0
r = w.inject(:+)
min = r - l
n.times do |i|
  l += w[i]
  r -= w[i]
  c = (r - l).abs
  if min > c then
    min = c
  elsif min < c then
    break
  end
end

puts min

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

int main()
{
  string s;
  cin >> s;
  for(int i=0; i<(s.size()/2); i++) {
    char tmp = s[i];
    s[i] = s[s.size()-1-i];
    s[s.size()-1-i] = tmp;
  }

  cout << s << endl;
}

Measured memory_bytes: 1172
#include<bits/stdc++.h>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
ll bpow(ll,ll,ll);
typedef vector<int> vec;
typedef vector<vec> mat;
mat mul(mat &A,mat &B);
mat pow(mat A,ll n);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};


bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  ll H,W,A[301][301],Q,L,R,sum[900002],D;
  cin >> H >> W >> D;
  map<ll,P > mp;
  REP(i,H)REP(j,W){
    cin >> Q;
    A[i][j] = --Q;
    mp[Q] = P(i,j);
  }
  
  REP(i,900002)sum[i] = 0;
  for(int j=0;j<D;j++){
    P bp = mp[j];
    for(int i=j;i+D<H*W;i+=D){
      P p = mp[i+D];
      sum[i+D] = sum[i] + abs(bp.first-p.first) + abs(bp.second-p.second);
      bp = p;
    }
  }
  
  
  cin >> Q;
  REP(i,Q){
    
    cin >> L >> R;
    L--;R--;
    cout << (sum[R] - sum[L]) << endl;
  }
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

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

ll bpow(ll a, ll n,ll mod){
  int i = 0;
  ll res=1;
  while(n){
    if(n & 1)
      res = (res*a) % mod;
    a = (a*a) % mod;
    n >>= 1;
  }
  return res;
}
const int MOD = 1000000007;
mat mul(mat &A, mat &B){
  mat C(A.size(),vec(B[0].size()));
    REP(i,A.size())REP(k,B.size())REP(j,B[0].size()){
    C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % MOD;
  }
  return C;
}

mat pow(mat A,ll n)
{
  mat B(A.size(),vec(A.size()));
  REP(i,A.size()){
    B[i][i] = 1;
  }
  while(n > 0){
    if ( n & 1) B = mul(B,A);
    A = mul(A,A);
    n >>= 1;
  }
  return B;
}


Measured memory_bytes: 13824
#include<iostream>
using namespace std;
int x[40], n, w, a, b, c, d; char f;
int main() {
	cin >> n >> w;
	for (int i = 1; i <= n; i++) {
		x[i] = i;
	}
	for (int i = 0; i < w; i++) {
		cin >> a >> f >> b;
		c = x[a];
		d = x[b];
		x[a] = d;
		x[b] = c;
	}
	for (int i = 1; i <= n; i++) {
		cout << x[i] << endl;
	}
}

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

using namespace std;

int main() {
    string S;
    cin >> S;
    if(S == "SUN") {
        cout << 7;
    } else if(S == "MON") {
        cout << 6;
    } else if(S == "TUE") {
        cout << 5;
    } else if(S == "WED") {
        cout << 4;
    } else if(S == "THU") {
        cout << 3;
    } else if(S == "FRI") {
        cout << 2;
    } else if(S == "SAT") {
        cout << 1;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,j,k) for(int i=j;i<k;i++)
#define FORD(i,j,k) for(int i=j;i>=k;i--)
#define ll long long
#define ull unsigned long long int
#define ld long double
//Make sure no overflow problems
#define pii  pair<int, int>
#define vi vector<int >
#define pb push_back
#define mp make_pair
#define endl '\n'
#define x first
#define y second
#define VAR(i,n) __typeof(n) i = (n)
#define FOREACH(i,c) for(VAR(i,(c).begin());i!=(c).end();i++)
#define FORDEACH(i,c) for( VAR(i,(c).rbegin()),i!=(c).rend();i++)
#define REP(i,n) FOR(i,0,n)
#define mod 1000000007
#define MEM(a, b) memset(a, (b), sizeof(a))
#define addmod(a,b,mod) (a%mod + b%mod)%mod
#define submod(a,b,mod) (a%mod - b%mod + mod)%mod
//const long long INFLL = (ll)INF * (ll)INF;
const ld EPS = 10e-9;
const int MAX = 1e6;

int main(){
    ios_base:: sync_with_stdio(0); 
    cin.tie(0);
    
    int n, k, x = 1;
    cin >> n >> k;
    while(n--){
        if(x < k)
            x *= 2;
        else
            x += k;
    }
    cout << x;
    return 0;
}

Measured memory_bytes: 256
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
ans,count=0,0

for i in range(n):
  a=list(map(int,input().split()))
  for j in range(m):
    ans+=a[j]*b[j]
    
  ans+=c
  
  if ans>0:
    count+=1
    
  ans=0
  
print(count)

Measured memory_bytes: 9112
from collections import defaultdict
import itertools
N = int(input())
S = [input()[0] for _ in range(N)]
d = defaultdict(int)

for i in S:
    if i in ['M','A','R','C','H']:
        d[i] += 1

e = list(d.values())

f = list(itertools.combinations(e,3))

s = 0
for i,j,k in f:
    s += i*j*k
print(s)

Measured memory_bytes: 4216
#include<cstdio>
#include<iostream>
using namespace std;
int main(){
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	if(A * B >= C * D){
		cout << A * B << endl;
	}
	else{
		cout << C * D << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int i;
  int len,b;
  char aa[100],bb[100],cc[100];
  int ia,ib,ic;
//  scanf("%s %s",&aa,&bb);
//    printf("aa:%s bb:%s\n",aa,bb);
  scanf("%d %d %d",&ia,&ib,&ic);
//    printf("aa:%d bb:%d cc:%d\n",ia,ib,ic);
	if((ia == ib) && (ib == ic)){
		printf("No");
      
    }
  	else if(ia == ib){
		printf("Yes");
    }
  	else if(ib == ic){
		printf("Yes");
    }
  	else if(ic == ia){
		printf("Yes");
    }
  	else{
		printf("No");
    }

  return 0;

}


Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

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

    int n, m;
    cin >> n >> m;
    vs32 h(n);
    rep (i, n) cin >> h[i];

    vector< vs32 > g(n);
    rep (i, m)
    {
        int a, b;
        cin >> a >> b;
        --a, --b;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    int ans = 0;
    rep (u, n)
    {
        bool found = false;
        for (auto v : g[u])
        {
            if (h[u] <= h[v]) found = true;
        }
        if (!found) ++ans;
    }

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



Measured memory_bytes: 8744
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <iomanip>
#include <queue>
using ll =long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;

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

    if(N.at(N.size()-1) == '3'){
        cout << "bon" << endl;
    } else if (N.at(N.size()-1) == '0' or N.at(N.size()-1) == '1' or N.at(N.size()-1) == '6' or N.at(N.size()-1) == '8'){
        cout << "pon" << endl;
    }
    else{
        cout << "hon" << endl;
    }

}

Measured memory_bytes: 3068
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main() {
    long long n, k;
    cin >> n >> k;

    vector<long long> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    vector<long long> f(n);
    for (int i = 0; i < n; i++) {
        cin >> f[i];
    }

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

    long long left = 0, right = 0;
    for (int i = 0; i < n; i++) {
        right = max(right, a[i] * f[n - i - 1]);
    }

    while (true) {
        long long mid = (left + right) / 2;

        long long k_req = 0;
        for (int i = 0; i < n; i++) {
            if (a[i] - mid / f[n - i - 1] > 0) {
                k_req += a[i] - mid / f[n - i - 1];
            }
        }

        if (k_req > k) {
            left = mid + 1;
        } else {
            right = mid;
        }

        if (right - left < 2) {
            k_req = 0;
            for (int i = 0; i < n; i++) {
                if (a[i] - left / f[n - i - 1] > 0) {
                    k_req += a[i] - left / f[n - i - 1];
                }
            }

            if (k_req > k) {
                left = right;
            }

            break;
        }
    }

    cout << left << endl;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
long long  a[6],b[6],n=5,sum,mn=333339;
int main(){
	for(int i=0;i<n;i++){
    	cin>>a[i];
		b[i]=a[i]%10;
	}
	for(int i=0;i<n;i++){
		if(b[i]!=0)
    	mn = min(b[i],mn);
	}
	for(int i=0; i<n; i++){
		if(b[i] == mn){
			sum += a[i];
			a[i] = 0;
			break;
		}
	}
	for(int i=0; i<n; i++){
		if(a[i]%10 != 0)
    		sum += a[i] +10 - a[i]%10;
    	else
    		sum += a[i];
	}
	cout<<sum;
}
//FELAROSSO and aceka.b 2019 

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define endl "\n"
 
typedef unsigned long long ull;
typedef double lf;
typedef long double llf;
typedef long long ll;
 
int main()
{
    char x;
    cin >> x;
    if (x >= 'a' && x <= 'z')
    	cout << "a" << endl;
    else 
    	cout << "A" << endl;
  return 0;
  //
}

Measured memory_bytes: 3632
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
import java.util.Random;

public class Main {
    private static FastScanner sc = new FastScanner();
    private static boolean DEBUG_FLG = false;

    public static void main(String[] args) {
    	int N = sc.nextInt();
    	int K = sc.nextInt();
    	int p = (N-1) * (N-2) / 2;
    	if(K > p) {
    		System.out.println(-1);
    		return;
    	}
    	StringBuilder sb = new StringBuilder();
    	int M = N-1;
    	for(int i=2; i<=N; i++) {
    		sb.append("1 " + i + "\n");
    	}
    	for(int i=2; i<=N; i++) {
    		for(int j=i+1; j<=N; j++) {
    			if(p == K) {
    				System.out.println(M);
    				System.out.print(sb);
    				return;
    			}
    			sb.append(i + " " + j + "\n");
    			M++;
    			p--;
    		}
    	}
		System.out.println(M);
		System.out.print(sb);
    }

    static void debug(long... args) {
    	if(!DEBUG_FLG) return;
    	boolean flg = false;
    	for(long s : args) {
    		if(flg) System.out.print(" ");
    		flg = true;
    		System.out.print(s);
    	}
    	System.out.println();
    }

    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if(ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch(IOException e) {
                    e.printStackTrace();
                }
                if(buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public int nextInt(){
            return Integer.parseInt(next());
        }
        public double nextDouble(){
            return Double.parseDouble(next());
        }
    }

    static void shuffleArray(long[] arr){
        int n = arr.length;
        Random rnd = new Random();
        for(int i=0; i<n; ++i){
            long tmp = arr[i];
            int randomPos = i + rnd.nextInt(n-i);
            arr[i] = arr[randomPos];
            arr[randomPos] = tmp;
        }
    }
}


Measured memory_bytes: 23252
<?php
list($n, $a) = ints();
$p = 1;
foreach(factor($a) as $prime => $count){
  $p*=$prime ** floor($count/$n);
}
echo $p;

function factor($M){
    $rootM = $M**0.5+1;
    for($j = 2; $j <= $rootM; $j++){
        if($M%$j == 0){
            @$map[$j]++;
            $M/=$j;
            $rootM = $M**0.5+1;
            $j--;
        }
    }
    if($M>1){
        @$map[$M]++;
    }
    return $map;
}
function str(){
  return trim(fgets(STDIN));
}
function ints(){
  return array_map("intval", explode(" ", trim(fgets(STDIN))));
}
function int(){
  return intval(trim(fgets(STDIN)));
}
function o(...$val){
    if(count($val)==1)$val = array_shift($val);
    $trace = debug_backtrace();
    echo $trace[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0){
            echo "empty array";
        }elseif(!is_array(current($val))){
            echo "array:";
            echo implode(" ", $val)."\n";
        }else{
            echo "array:array\n";
            foreach($val as $row){
                echo implode(" ", $row)."\n";
            }
        }
    }else{
        echo $val."\n";
    }
}

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

class Combination
{
    int n;
    vector<long long> fact;
    vector<long long> factinv;
    long long MOD = 1e9 + 7;
    long long modpow(long long a, long long n)
    {
        if (n == 0)
            return 1;
        if (n % 2 == 0)
        {
            long long t = modpow(a, n / 2);
            return t * t % MOD;
        }
        return a * modpow(a, n - 1) % MOD;
    }

    long long modinv(long long a)
    {
        // mod is prime
        return modpow(a, MOD - 2);
    }

public:
    Combination(int n) : fact(n), factinv(n)
    {
        fact[0] = 1;
        for (int i = 1; i < n; i++)
        {
            fact[i] = fact[i - 1] * i % MOD;
        }
        factinv[n - 1] = modinv(fact[n - 1]);
        for (int i = n - 2; i >= 0; i--)
        {
            factinv[i] = factinv[i + 1] * (i + 1) % MOD;
        }
    }

    long long ncr(long long n, long long r)
    {
        if (r < 0 || r > n)
            return 0;
        return fact[n] * factinv[r] % MOD * factinv[n - r] % MOD;
    }

    long long npr(long long n, long long r)
    {
        if (r < 0 || r > n)
            return 0;
        return fact[n] * factinv[n - r] % MOD;
    }

    long long nhr(long long n, long long r)
    {
        if (n == 0 && r == 0)
            return 1;
        return ncr(n + r - 1, r);
    }
};

int main()
{
    int n;
    cin >> n;
    Combination comb = Combination(n + 10);
    map<int, vector<int>> m;
    int id = 0;
    rep(i, n + 1)
    {
        int x;
        cin >> x;
        m[x].push_back(i + 1);
        if (m[x].size() == 2)
        {
            id = x;
        }
    }
    long long int mod = 1e9 + 7;
    for (int i = 1; i <= n + 1; i++)
    {
        cout << (comb.ncr(n + 1, i) + mod - comb.ncr(m[id][0] + n - m[id][1], i - 1)) % mod << endl;
    }
}


Measured memory_bytes: 13696
#include<bits/stdc++.h>
#define ll long long
#define endl '\n'
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
int main()
{
   fastio;
   string s;
   cin>>s;
   if(s[s.size()-1]=='s')
   {
       cout<<s+"es"<<endl;
   }
   else
   {
       cout<<s+'s'<<endl;
   }
   return 0;
}

Measured memory_bytes: 3620
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;
#pragma endregion

#pragma region const
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#pragma endregion

#pragma region util
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}
#pragma endregion

#pragma region init
struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

int main()
{
	i64 N;
	cin >> N;
	vector<string> W(N);
	for (auto& v : W)
	{
		cin >> v;
	}

	string cur_str = W[0];
	map<string, int> counter;
	counter[W[0]]++;
	FOR(i, 1, W.size())
	{
		counter[W[i]]++;
		if (counter[W[i]] > 1)
		{
			cout << "No" << endl;
			return 0;
		}

		if (cur_str.substr(cur_str.size() - 1, 1) != W[i].substr(0, 1))
		{
			cout << "No" << endl;
			return 0;
		}

		cur_str = W[i];
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 256
import bisect,collections,copy,itertools,math,numpy,string
def I(): return int(input())
def S(): return input()
def LI(): return list(map(int,input().split()))
def LS(): return list(input().split())
##################################################
N = S()
print('Yes' if N[0]=='7' or N[1]=='7' or N[2]=='7' else 'No')


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

const long N=100000;

int main(){
  long n, w, h;
  long tate[N+1], yoko[N+1];
	
  memset(tate, 0, sizeof(tate));
  memset(yoko, 0, sizeof(yoko));
	
  scanf(" %ld %ld %ld", &n, &w, &h);
	
  for(long i=0; i<n; ++i){
    long x, y, z;
    scanf(" %ld %ld %ld", &x, &y, &z);
		
    //tate direct
    long ta=x-z+1, tb=x+z;
    if(ta<1) ta=1;
    if(tb>w) tb=w;
    tate[ta]++;
    tate[tb+1]--;
		
    //yoko direct
    long ya=y-z+1, yb=y+z;
    if(ya<1) ya=1;
    if(yb>h) yb=h;
    yoko[ya]++;
    yoko[yb+1]--;
  }

	
  for(long i=0; i<=w; ++i) tate[i+1]+=tate[i];
  for(long i=0; i<=h; ++i) yoko[i+1]+=yoko[i];
	
  /*
    for(long i=0; i<=w; ++i) printf("tate[%ld]=%d\n", i, tate[i]);
    for(long i=0; i<=h; ++i) printf("yoko[%ld]=%d\n", i, yoko[i]);
  */
	
  bool ans=true;
  for(long i=1; i<=w; ++i){
    if(tate[i]<=0){
      ans=false;
      break;	
    }	
  }
	
  if(!ans){
    ans=true;
    for(long i=1; i<=h; ++i){
      if(yoko[i]<=0){
	ans=false;
	break;	
      }	
    }
  }
  if(ans) printf("Yes\n");
  else printf("No\n");
	
}

Measured memory_bytes: 2740
#include <iostream>
#include <vector>
#include <algorithm>
#define int long long
using namespace std;

int n, m;
int p[100000], d[100000];	//p ??? 0-indexed (?±??????£???????????????-1)

void input() {
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> d[i] >> p[i];
		p[i]--;
	}
	for (int i = m; i < n; i++) {
		cin >> d[i];
		p[i] = -1;
	}
}

vector<int> childs[200000];
int tree_size;
int type[100000];		//type[i] = ??????i???????????´???(????????????0 <= i < n?????´??????, i?????????????????????????????????1, ????????????????????????-1, ?±??????£????????????0

void make_tree() {
	tree_size = n;
	for (int i = 0; i + 2 < tree_size; i += 3) {
		//??????i, i + 1, i + 2??§?????? -> ????????????tree_size????§????
		childs[tree_size].push_back(i);
		childs[tree_size].push_back(i + 1);
		childs[tree_size].push_back(i + 2);
		tree_size++;
	}
}

/*????????¨*/
//?????????
void make_type(int x) {
	for (int i = 0; i < n; i++) {
		type[i] = -1;
	}
	for (int i = 0; i < m; i++) {
		type[p[i]] = (d[i] >= x);
	}
}

//?????????v???True????????¬???????????????????°???§?????????T?????????????????°?????????????????????
//????????????INF?????????
const int INF = 1145141919;
int dfs(int v) {
	if (v < n) {
		if (type[v] == 1) return 0;
		if (type[v] == 0) return INF;
		return 1;
	}
	
	//????????????3???
	int res[3];
	for (int i = 0; i < 3; i++) {
		res[i] = dfs(childs[v][i]);
	}
	sort(res, res + 3);
	
	if (res[1] >= INF) { return INF; }
	return res[0] + res[1];
}

bool check(int x) {
	make_type(x);
	int res = dfs(tree_size - 1);
	for (int i = m; i < n; i++) { res -= (d[i] >= x); }	//??????
	return (res <= 0);
}

/*?????????*/
signed main() {
	input();
	make_tree();
	
	int st = 0, ed = 1145141919, mid; //oooooxxxxx , [st, ed)
	while (ed - st >= 2) {
		mid = (st + ed) / 2;
		if (check(mid)) {
			st = mid;
		}
		else {
			ed = mid;
		}
	}
	cout << st << endl;
	return 0;
}

Measured memory_bytes: 12512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep_1(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define rep_2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main()
{
    string s;cin>>s;
    bool ans = true;
    int iter = (s.size() - 1)/ 2;
    string first = s.substr(0,iter);
    iter = (s.size() + 3) / 2;
    iter--;
    string last = s.substr(iter, s.size());
    string tmp = s;
    reverse( all(tmp) );
    if(s != tmp) ans = false;
    tmp = first;
    reverse( all(tmp) );
    if(first != tmp) ans = false;
    tmp = last;
    reverse( all(tmp) );
    if(last != tmp) ans = false;

    cout << (ans ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();

		int ans = 0;

		for (int i = 0; i < N; i++) {
			int l = sc.nextInt();
			int r = sc.nextInt();
			ans = ans + r - l + 1;
		}

		System.out.println(ans);

	}
}

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

#define INF (INT32_MAX/2)

int main()
{
	int N, M, X;
	cin >> N >> M >> X;
	vector<long long> C( N );
	vector<vector<long long>> A( N, vector<long long>( M ) );
	for( int i = 0; i < N; i++ ) {
		cin >> C[i];
		for( int j = 0; j < M; j++ ) {
			cin >> A[i][j];
		}
	}

	long long ans = INF;
	for( int mask = 0; mask < 1 << N; mask++ ) {
		long long c = 0;
		vector<long long> x( M );
		for( int i = 0; i < N; i++ ) {
			if( mask >> i & 1 ) {
				c += C[i];
				for( int j = 0; j < M; j++ ) {
					x[j] += A[i][j];
				}
			}
		}
		int flag = 0;
		for( int i = 0; i < M; i++ ) {
			if( x[i] < X ) {
				flag = 1;
				break;
			}
		}
		if( flag == 0 ) ans = min( ans, c );
	}
	if( ans == INF ) ans = -1;

	cout << ans << endl;
}


Measured memory_bytes: 3632
N = int(input())
A=list(map(int,input().split()))
odd_num=0
bai_four=0
for i in range(N):
    if A[i]%2==1:
        odd_num=odd_num+1
    elif A[i]%4==0:
        bai_four=bai_four+1
if N%2==0:
    if odd_num <= bai_four:
        print('Yes')
    else:
        print('No')
else:
    if odd_num <= bai_four+1:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 14252