akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
	int N; cin >> N;
	int X[N];
	int Y[N];
	rep(i, N) {
		cin >> X[i];
		Y[i] = X[i];
	}
	sort(Y, Y + N);
	int medium0 = N / 2 - 1;
	int medium1 = medium0 + 1;
	rep(i, N) {
		if (X[i] <= Y[medium0]) cout << Y[medium1] << endl;
		else cout << Y[medium0] << endl;
	}



			

    return 0;
}


Measured memory_bytes: 3712
#include<iostream>
#include<map>
#include<unordered_map>
#include<set>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef long double ld;
#define mp make_pair
#define pb push_back
const ll mod = 1000000007;
// const ll mod = 998244353;

const ll LLMAX = numeric_limits<long long>::max();

void No() {
	cout << "No" << endl;
}

void Yes() {
	cout << "Yes" << endl;
}

// 約数列挙
vector< ll > divisor(ll n) {
	vector< ll > ret;
	for (ll i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			ret.push_back(i);
			if (i * i != n) ret.push_back(n / i);
		}
	}
	sort(begin(ret), end(ret), greater<ll>());
	return (ret);
}

int main() {
	ll N, Q;
	cin >> N >> Q;
	vvi tree(N, vi(0));
	vi num(N, 0);

	for (int i = 0; i < N-1; i++) {
		ll a, b;
		cin >> a >> b;
		a--; b--;
		tree[a].pb(b);
		tree[b].pb(a);
	}
	for (int i = 0; i < Q; i++) {
		int p, x;
		cin >> p >> x;
		p--;
		num[p] += x;
	}

	queue<ll> que;
	vector<bool> used(N, false);
	que.push(0);

	while (!que.empty()) {
		ll t = que.front();
		que.pop();
		
		used[t] = true;
		for (auto ch : tree[t]) {
			if (used[ch] == false) {
				num[ch] += num[t];
				que.push(ch);
			}
		}
	}

	for (ll n : num) {
		cout << n << " ";
	}
	
	cout << endl;
	return 0;
}

Measured memory_bytes: 17904
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<class F>auto recursive(F f){return[f](auto...a){return f(f,a...);};}
template<class I,class V=typename I::value_type>V sum_up(const I&l,const I&r){V v;for(I i=l;i!=r;i++)v=i==l?*i:v+*i;return v;}
template<class I,class T=iterator_traits<I>>I operator+(I it,int n){for(int i=0;i<n;i++)it++;return it;}
template<class I,class T=iterator_traits<I>>I operator-(I it,int n){for(int i=0;i<n;i++)it--;return it;}
template<class T>using rev_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<class T>using vector2d=vector<vector<T>>;
struct fixprec{int p;fixprec(int p):p(p){}};
ostream&operator<<(ostream&o,fixprec f){return o<<fixed<<setprecision(f.p);}
void R_YESNO(bool p){cout<<(p?"YES":"NO")<<endl;}
void R_YesNo(bool p){cout<<(p?"Yes":"No")<<endl;}
int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    while(true) {
        C -= B;
        if(C <= 0) {
            cout << "Yes" << endl;
            return 0;
        }
        A -= D;
        if(A <= 0) {
            cout << "No" << endl;
            return 0;
        }
    }
    return 0;
}



Measured memory_bytes: 3636
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
const ll P=1e9+7;
int B, W;
ll fact[300000];

// Extended Euclid's greatest common divisor algorithm
// Find (x, y, g)
// where $a*x + b*y = g$ and g is the greatest common divisor of (a, b)
ll ext_gcd(ll a, ll b, ll &x, ll &y){
	if(b == 0){
		x = 1;
		y = 0;
		return a;
	}
	ll nx, ny;
	ll g = ext_gcd(b, a%b, nx, ny);
	x = ny;
	y = nx - a/b *ny;
	return g;
}

// Modular inverse of x given modulo p, y
// x*y = 1 mod p
// <=> x*y + z*p = 1
ll inv_mod(ll x, ll p){
	ll y,z;
	ext_gcd(x, p, y, z);
	return y>=0 ? y : p+(y%p);
}


// Modular factorial of n, also counting p's appearance e
// n! = a * p^e
// return: a % p
// n! = n * (n-1) * ... * (k*p+1) *
//      (k*p) * (k*p-1) * ... ((k-1)*p+1) *
//      ...
//      p * (p-1) * ... * 2 * 1   (k = floor(n/p))
//    = (n%p) * ... * 1 *
//      (k*p) * (p-1) * ... * 1 *
//      p * (p-1) * ... * 1       (mod p, preserving p's multiples)
//    = (n%p)! * p^k * k! * (p-1)^k
//    = (n%p)! * p^k * k! * (p-1)^(k%2)
//
// From the facts:
//   (p-1)! = p-1 (mod p) (c.f. Willson's theorem)
//   (p-2)**2 = 1 (mod p)
ll fact_mod(ll n, ll p, ll &e){
	if(n == 0){
		e = 0;
		return 1;
	}

	ll na = fact_mod(n/p, p, e);

	e += n/p;
	ll a = na * fact[n%p] % p;

	if((n/p)%2) a = a * (p-1)%p;
	return a;
}


// Modular combination (n, m) given module p
// (n, m) = n!/(n-m)!m!
//        = (a_n * p^(e_n)) / ((a_{n-m} * p^(e_{n-m}) * (a_m * p^e_m))
//        = a_n / (a_{n-m} * a_m) * p^(e_n - e_{n-m} - e_m)
ll comb_mod(ll n, ll m, ll p){
	ll e1,e2,e3;
	ll a1 = fact_mod(n, p, e1);
	ll a2 = fact_mod(m, p, e2);
	ll a3 = fact_mod(n-m, p, e3);

	if(e1 > e2+e3) return 0;
	else return a1*inv_mod(a2*a3%p, p)%p;
}

int main(){
	fact[0] = fact[1] = 1;
	for(int i=2; i<300000; i++) fact[i] = fact[i-1]*i%P;
	cin >> B >> W;

	ll h=0, g=1;
	ll b=2;
	//cout << (2*h+g) << " " << b << " ";
	cout << (2*h+g)*inv_mod(b, P) << endl;
	for(int i=1; i<B+W; i++){
		b = 2*b%P;
		h = 2*h%P;
		g = 2*g%P;
		if(i>=W){
			h = (h+comb_mod(i-1, i-W, P))%P;
			g = (g-comb_mod(i-1, i-W, P)+P)%P;
		}
		if(i>=B){
			g = (g-comb_mod(i-1, B-1, P)+P)%P;
		}
		//cout << (2*h+g)%P << " " << b << " " << h << " " << g << " ";
		cout << ((2*h+g)%P)*inv_mod(b, P)%P << endl;
	}


	return 0;
}


Measured memory_bytes: 4608
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int s;
    cin >> s;
    set<int> st;
    st.insert(s);
    REP(i,1e9){
        if (s % 2 == 0){
            s /= 2;
        }else{
            s = 3 * s + 1;
        }
        if (st.count(s)){
            cout << i + 2 << endl;
            return 0;
        }
        st.insert(s);
    }
    return 0;
}


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

int main() {
    string S, T; cin >> S >> T;
    bool ans = false;
    for (int i = 0; i < S.size(); ++i){
        if (S == T){
            ans = true;
            break;
        }
        S = S.back() + S.substr(0, S.size()-1);
    }
    if (ans){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll n;
  cin >> n;
  vll a(n), b(n);
  REP(i, n)
    cin >> a[i] >> b[i];

  vll c(n);
  ll ans = 0;
  ll cnt =  0;
  for(ll i = n-1; i >= 0; i--){
    if((a[i]+cnt)%b[i] == 0)
      continue;
    ll now = b[i]-(a[i]+cnt)%b[i];
    cnt += now;
  }

  cout << cnt << endl;
}


Measured memory_bytes: 2560
#include <iostream>
#include <string>

using namespace std;

int main(){
	int N;
	int L;
	string sum_string;

	cin >> N >> L;

	string *A = NULL;


	A = new string[N];

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

	string min;
	int min_num;

	for(int i = 0; i < N; i++){
		min = A[i];
		min_num = i;
		for(int j = i + 1; j < N; j++){
			if(A[j] + min < min + A[j]){
				min = A[j];
				min_num = j;
			}
		}
		if(min != A[i]){
			A[min_num] = A[i];
			A[i] = min;
		}
	}

	sum_string = A[0];
	for(int i = 1; i < N; i++){
		sum_string += A[i];
	}



	cout << sum_string << endl;

	delete[] A;
	return 0;
}

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

constexpr int P = 1000000007;

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

    int dp[2001];
    dp[0] = 1;

    for (int i = 1; i <= s; i++) {
        ll t = 0;
        for (int j = 3; j <= i; j++) {
            t += dp[i - j];
        }
        dp[i] = t % P;
    }

    cout << dp[s] << endl;

    return 0;
}

Measured memory_bytes: 3640
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		int[][] card = new int[4][13];
		String mark = "";
		int num =0;
		Scanner scan = new Scanner(System.in);
		int n = Integer.parseInt(scan.next());
		for(int i=0;i<n;i++){
			mark= scan.next();
			num = Integer.parseInt(scan.next());
			if(mark.equals("S")) 	 card[0][num-1]=1;
			else if(mark.equals("H"))card[1][num-1]=2;
			else if(mark.equals("C"))card[2][num-1]=3;
			else 					 card[3][num-1]=4;
		}
		for(int i=0;i<4;i++){
			for(int j=0;j<13;j++){
				if(card[i][j]==0){
					if(i==0) System.out.println("S "+(j+1));
					if(i==1) System.out.println("H "+(j+1));
					if(i==2) System.out.println("C "+(j+1));
					if(i==3) System.out.println("D "+(j+1));
				}
			}
		}
	}
}

Measured memory_bytes: 17156
#include <iostream>
#include <vector>

using namespace std;

const int P = 1000000007;

long long power(long long x, long long t) {
	long long ret = 1;

	for(; t; t >>= 1, x = x * x % P) {
		if(t & 1) {
			ret = ret * x % P;
		}
	}

	return ret;
}

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

	long long ans = 0;

	vector<long long> Pow;

	Pow.resize(k + 1);

	for(int i = 1; i <= k; ++i) {
		Pow[i] = power(i, n);
	}

	vector<long long> mu;
	mu.resize(k + 1);

	mu[1] = 1;

	vector<bool> mark;
	mark.resize(k + 1);

	vector<int> pri;

	for(int i = 2; i <= k; ++i) {
		if(!mark[i]) {
			mu[i] = -1;
			pri.emplace_back(i);
		}

		for(int j = 0; j < pri.size() && i * pri[j] <= k; ++j) {
			mark[i * pri[j]] = true;

			if(i % pri[j] == 0) {
				break;
			}

			mu[i * pri[j]] = -mu[i];
		} 
	}

	for(int i = 1; i <= k; ++i) {
		long long f = 1;

		for(int j = i; j <= k; j += i) {
			ans = (ans + mu[j / i] * Pow[k / j] * i % P + P) % P;
		}
	}

	cout << ans << '\n';

	return 0;
}


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

int main()
{
    long double a;
    long double b;
    cin >> a >> b;
    ll ans = a*b;
    pri(ans);
    return 0;
}


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

int compare(const void* a, const void* b) {
	return (strcmp((char*)a, (char*)b));
}

int main() {
	int N, ans = 1;
	char S[200000][11];
	scanf("%d", &N);
	for (int i = 0; i < N; i++) scanf("%s", S[i]);
	qsort((void*)S, N, sizeof(S[0]), compare);
	for (int i = 0; i < N - 1; i++) if(strcmp(S[i], S[i + 1]) != 0) ans++;
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 5716
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     

def reverse_str(n):
    n = int(n)
    return str((1 - n) ** 2)

def main():
    s = S()
    dp = [(0, '') for _ in range(len(s)+1)]
    dp[0] = (1, s[0])
    for i in range(1, len(s)):
        prev_let = dp[i-1][1]
        prev_len = dp[i-1][0]
        if s[i] == prev_let:
            dp[i] = (prev_len + 1, s[i])
        elif prev_let == '':
            dp[i] = (prev_len + 1, s[i])
        else:
            if prev_len - 1 == 0:
                prev_let = ''
            else:
                prev_let = reverse_str(s[i])
            dp[i] = (prev_len - 1, prev_let)
    print(len(s) - dp[len(s)-1][0])

main()



Measured memory_bytes: 20168
n = int(input())
a = list(map(int, input().split()))
a.sort()
i = 0
ans = 0
while i < n:
    head = a[i]
    if head + i - 1 >= n:
        ans += n - i
        break
    if a[head+i-1] != a[i]:
        while i < n and head == a[i]:
            i += 1
            ans += 1
    else:
        i += head
        while i < n and head == a[i]:
            i += 1
            ans += 1

print(ans)


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

p = 0
for i in range(1, N):
    p ^= A[i]

ans = [str(p)]
for i in range(1, N):
    t = A[i-1] ^ A[i]
    p = p ^ t
    ans.append(str(p))
print(" ".join(ans))


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

int main(){
  long long X,Y;
  cin >>X>>Y;
  long long ans=0;
  if(X==Y){
    cout<<1<<endl;
    return 0;
  }

  while(X<=Y){   
    X=X*2;
    ans++;
  }
  cout<<ans<<endl;
  return 0;
}

  

Measured memory_bytes: 256
n=int(input())
x=input()
count_x=x.count("1")
px10=0
nx10=0
xi=[0]*n
ans=[0]*(n+1)
for i in range(1,n+1):
    popcount=format(i,"b").count("1")
    fx=i%popcount
    ans[i]=ans[fx]+1
for i in range(n):
    px10+=(int(x[i])*pow(2,n-1-i,count_x+1))%(count_x+1)
    if count_x!=0 and count_x!=1:
        nx10+=int(x[i])*pow(2,n-1-i,count_x-1)%(count_x-1)
for i in range(n):
    if x[i]=="0":
        xi10=(px10+pow(2,n-1-i,count_x+1))%(count_x+1)
        print(ans[xi10]+1)
    else:
        if count_x!=1:
            xi10=(nx10-pow(2,n-1-i,count_x-1))%(count_x-1)
            print(ans[xi10]+1)
        else:
            print(0)




Measured memory_bytes: 81060
#include<stdio.h>
int main(void){
  char k[4];
  int  i,n,t[4]={};
  char s[5][5]={"AC","WA","TLE","RE"};
  scanf("%d",&n);
  for(i=0;i<n;i++){
  scanf("%s\n",k);
  if(k[0]=='A'){
    t[0]++;
  }else if(k[0]=='W'){
    t[1]++;
  }else if(k[0]=='T'){
    t[2]++;
  }else if(k[0]=='R'){
    t[3]++;
  }
  }
  i=0;
  for(i=0;i<4;i++){
    printf("%s x %d\n",s[i],t[i]);
  }
 return 0; 
}


Measured memory_bytes: 1696
#include<iostream>
#include<vector>
#include<bitset>
#include<string>
#include<cmath>
#include<algorithm>
#include<stack>
#include<list>
#include<queue>
#include<map>
#include<numeric>
using namespace std;
#define rep(i,x) for(int i=0;i<x;i++)
#define re(i,x,y) for(int i=x;i<y;i++)
int INF=1e9;
const long long mod=1e9+7;
typedef long long ll;
int main(){
    map<string,int>m;
    int q;
    cin>>q;
    while(q--){
        int t,y;
        string x;
        cin>>t;
        if(t==0){
            cin>>x>>y;
            m[x]=y;
        }
        if(t==1){
            cin>>x;
            if(m.count(x)){
            cout<<m[x]<<endl;
            }
            else{
                cout<<0<<endl;
            }
        }
        if(t==2){
            cin>>x;
            m.erase(x);
        }
        if(t==3){
            string l,r;
            cin>>l>>r;
            map<string,int>::iterator end,it;
            it=m.lower_bound(l);
            end=m.upper_bound(r);
            for(;it!=end;it++){
                cout<<(*it).first<<' '<<(*it).second<<endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 27744
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back

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

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

//scanf("%lld", &);
//cin >> ;
//cout << ans << endl;

ll N, M, K, i, j, k, l, ans, cnt = 0;


int main(){
    ll data, H1, M1, H2, M2, K;
    ll min1, min2;

    cin >> H1 >> M1 >> H2 >> M2 >> K;

    min1 = H1 * 60 + M1;
    min2 = H2 * 60 + M2;

    cout << min2 - min1 - K << endl;

    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define INF 1e9
#define pb push_back
using namespace std;
typedef long long ll;
using pii = pair<ll, ll>;

int main() {
    ll N;
    cin >> N;
    ll ans =0;
    for(int i=1; i<=N;i++){
        if(i%3 != 0 && i%5 != 0){
            ans += i;
        }
    }
    cout << ans << endl;
}

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

using namespace std;

const int N = 330;

inline void smax(int &x, int y) { if (x < y) x = y; }

int dp[N][N][N];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  int k;
  cin >> k;
  int n = (int) s.size();
  if (n == 1) {
    cout << 1 << '\n';
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    dp[i][i][0] = 1;
    if (i < n && s[i - 1] == s[i]) {
      dp[i][i + 1][0] = 2;
    } else if (i < n) {
      dp[i][i + 1][1] = 2;
    }
  }
  for (int i = n; i >= 1; i--) {
    for (int j = i + 1; j <= n; j++) {
      for (int r = 0; r <= k; r++) {
        smax(dp[i][j][r], dp[i + 1][j][r]);
        smax(dp[i][j][r], dp[i][j - 1][r]);
        smax(dp[i][j][r], dp[i][j][r - 1]);
        if (s[i - 1] == s[j - 1]) {
          smax(dp[i][j][r], dp[i + 1][j - 1][r] + 2);
        } else if (r > 0) {
          smax(dp[i][j][r], dp[i + 1][j - 1][r - 1] + 2);
        }
      }
    }
  }
  cout << dp[1][n][k] << '\n';
  return 0;
}


Measured memory_bytes: 62844
#include <iostream>
#include <queue>
#include <string>
using namespace std;
#define rep(i,n)	for(int i=0;i<n;i++)

int main(){
	int n,q;	cin>>n>>q;
	queue<int> time;
	queue<string> name;
	int tt;
	string nt;
	rep(i,n){
		cin>>nt;
		cin>>tt;
		name.push(nt);	time.push(tt);
	}
	int t=0;
	while(time.size()!=0){
		tt=time.front();	time.pop();
		nt=name.front();	name.pop();
		tt-=q;
		if(tt<=0){
			t+=q+tt;
			cout<<nt<<" "<<t<<endl;
		}
		else{
			t+=q;
			time.push(tt);
			name.push(nt);
		}
	}
	return 0;
}

Measured memory_bytes: 4172
from collections import defaultdict

def readInt():
  return int(input())
def readInts():
  return list(map(int, input().split()))
def readChar():
  return input()
def readChars():
  return input().split()

x = readInt()
l = [0]*(x+1)
l[1]=1

for i in range(2,len(l)):
  if l[i]==0:
    j = i*i
    while 1:
      if j>len(l)-1:
        break
      else:
        l[j]=1
        j*=i


for i in range(len(l)-1,-1,-1):
  if l[i]==1:
    print(i)
    break

Measured memory_bytes: 9392
/*
メモ化再帰
*/


# include <iostream>
# include <algorithm>

using namespace std;

int N;
long long height[100010], dp[100010];
const long long INF = 1LL << 60;

int rec(int i) {
  if (dp[i] < INF) return dp[i];
  if (i == 0) return 0;
  
  long long res = INF;
  res = min(res, rec(i - 1) + abs(height[i] - height[i - 1]));
  if (i > 1) res = min(res, rec(i - 2) + abs(height[i] - height[i - 2]));
  
  return dp[i] = res;
}

int main() {
  cin >> N;
  for (int i = 0; i < N; i++) cin >> height[i];
  for (int i = 0; i < N; i++) dp[i] = INF;
  
  cout << rec(N - 1) << endl;
  
  return 0;
}

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

int main()
{
  ll n;
  cin >> n;
  ll i = 1;
  ll j;
  ll ans = 1000000000000, tmp = 0;
  for(ll i = 1; i <= sqrt(n); i++)
  {
    if(n % i == 0)
    {
      j = n / i;
      tmp = j + i - 2;
      ans = min(ans, tmp);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

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

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    const MAX: usize = 100_000;
    let primes = enumerate_primes(MAX);
    let mut s: Vec<usize> = vec![0; MAX + 1];
    let mut i = 3;
    while i <= MAX {
        if primes.contains(&i) && primes.contains(&((i + 1) / 2)) {
            s[i] = s[i - 2] + 1;
        } else {
            s[i] = s[i - 2];
        }
        i += 2;
    }

    let q: usize = iterator.next().unwrap().parse().unwrap();
    let mut result = String::new();
    for _ in 0..q {
        let l: usize = iterator.next().unwrap().parse().unwrap();
        let r: usize = iterator.next().unwrap().parse().unwrap();

        let sl = if l == 1 {
            0
        } else {
            s[l - 2]
        };
        let sr = s[r];
        result.push_str(&format!("{}\n", sr - sl));
    }
    return result.trim().to_string();
}

fn enumerate_primes(n: usize) -> std::collections::HashSet<usize> {
    let mut result = std::collections::HashSet::new();
    for i in 2..(n + 1) {
        let mut is_prime = true;
        let mut x = 2;
        while x * x <= i {
            if i % x == 0 {
                is_prime = false;
                break;
            }
            x += 1;
        }
        if is_prime {
            result.insert(i);
        }
    }
    return result;
}


Measured memory_bytes: 8700
#include <iostream>
using namespace std;
void bubblesort(int A[],int N){
    int count = 0;
    for(int i=0;(N-1)>i;i++){
        for(int j=N-1;j>i;j--){
            if (A[j-1] > A[j]){
                int temp = A[j];
                A[j] = A[j-1];
                A[j-1] = temp;
                count++;
            }
        }
    }
    for(int i=0;i<N-1;i++)cout<<A[i]<<' ';cout<<A[N-1];
    cout<<endl;
    cout<<count<<endl;
}
int main(int argc, const char * argv[]) {
    int N;cin>>N;
    int A[100];
    for(int i = 0;i<N;i++)cin>>A[i];
    bubblesort(A,N);
}




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

int main(){
    double w, h, x, y;
    cin >> w >> h >> x >> y;
    if(w/2 == x && h/2 == y) cout <<  w * h / 2 << ' ' << '1' << endl;
    else cout << w * h / 2 << ' ' << '0' << endl;
    return 0;
}

Measured memory_bytes: 3704
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int mini(ll a,ll b)
{
  if(a>b) return b;
  else return a;
}

int main()
{
  ll x,y,z,k;
  cin>>x>>y>>z>>k;
  ll a[x],b[y],c[z];
  rep(i,x) cin>>a[i];
  rep(i,y) cin>>b[i];
  rep(i,z) cin>>c[i];

  sort(a,a+x);
  sort(b,b+y);
  sort(c,c+z);

  priority_queue<ll> AB,ABC;

  rep(i,x)
  rep(j,y) AB.push(a[i]+b[j]);

  int cnt=0;
  while(cnt<3000 && !AB.empty())
  {
    auto tmp=AB.top();
    AB.pop();
    cnt++;

    rep(i,z) ABC.push(tmp+c[i]);
  }

  while(k--)
  {
    cout<<ABC.top()<<endl;
    ABC.pop();
  }

}

Measured memory_bytes: 43364
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	ll n; cin>>n;
	ll a[n],s=0;
	for(int i=0;i<n;i++) cin>>a[i],s^=a[i];
	for(int i=0;i<n;i++) cout<<(s^a[i])<<" ";
}


Measured memory_bytes: 5068
#include<stdio.h>
int main() {
	int N;
	scanf("%d", &N);

	int a[200], b;
	int i, j;
	int count = 0;
	for (i = 1; i <= N; i++) {
		scanf("%d", &b);
		a[i] = b;
	}
	i=1;
	while(1) {
		i=i*2;
		for (j = 1; j <= N; j++) {
			if (a[j] % i > 0) {
				count = count - j + 1;
				printf("%d", count);
				goto OUT;
			}
			else {
				count += 1;
			}
		}count = count - N + 1;
	}
OUT:
	return 0;
}

Measured memory_bytes: 128
N, K = map(int, input().split())
D = [0] * K
A = [None] * K

for k in range(K):
    D[k] = int(input())
    A[k] = list(map(int, input().split()))

snuke = [0] * N

for k in range(K):
    for d in range(D[k]):
        snuke[A[k][d] - 1] += 1

ans = snuke.count(0)

print(ans)


Measured memory_bytes: 9224
#include <bits/stdc++.h>
using namespace std;
int main () {
  string w;
  cin >> w;
  vector<int> data(26);
  for(char a: w) {
    data.at(a - 'a')++;
  }
  string ans = "Yes";
  for(int i: data) {
    if(i % 2 != 0) ans = "No";
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

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

ll dp[10010][101][2];
int N, D;
string K;

void solve(){
    // dp[dgt][d][isless] := 先頭から確定した桁数dgt, 各桁の数字の和をDで割った値d, K未満フラグisless
    dp[0][0][0] = 1;
    for(int dgt=0; dgt<N; dgt++) for(int d=0; d<D; d++) for(int isless=0; isless<2; isless++) {
        int c = K[dgt] - '0';
        for(int nxt=0; nxt<10; nxt++) {
            //Kのdgt桁よりも小さい値の場合 ... 次のdgt+1桁の 数字の総和d+nxt で isless=1な配列に isless=0,1の両方を加算.
            if (nxt < c) (dp[dgt + 1][(d + nxt) % D][1] += dp[dgt][d][isless]%MOD)%=MOD;
            //Kのdgt桁と同じ値の場合      ... isless=0, 1をそれぞれ加算
            else if(nxt == c) (dp[dgt + 1][(d + nxt) % D][isless] += dp[dgt][d][isless]%MOD)%=MOD;
            //Kのdgt桁よりも大きい値の場合 ... 以前の桁で値が小さいことが分かっているなら更新
            else {
                if(isless) (dp[dgt + 1][(d + nxt) % D][isless] += dp[dgt][d][isless]%MOD)%=MOD;
            }
        }
    }
    // 余りが0かつK未満 + 余りが0かつkと等しい - 1<=x<=Kなのでx=0を除く
    cout << ((dp[N][0][0] + dp[N][0][1])%MOD + MOD - 1)%MOD << endl;
}

int main(void){
    cin >> K >> D;
    N = K.size();
    memset(dp,0,sizeof(dp));
    solve();
    return 0;
}

Measured memory_bytes: 16128
#include<iostream>
using namespace std;
main()
{
	int a,b,c,d,e,f;cin>>a>>b>>c>>d>>e>>f;
	a*=100;b*=100;
	double m=0;
	int all=a,in=0;
	double E=1e2*e/(100+e);
	for(int i=0;i*a<=f;i++)
	{
		for(int j=0;i*a+j*b<=f;j++)
		{
			if(i==0&&j==0)continue;
			for(int k=0;i*a+j*b+k*c<=f;k++)
			{
				for(int l=0;i*a+j*b+k*c+l*d<=f;l++)
				{
					double now=1e2*(k*c+l*d)/(i*a+j*b+k*c+l*d);
					if(m<now&&now<=E)
					{
						m=now;
						all=i*a+j*b+k*c+l*d;
						in=k*c+l*d;
					}
				}
			}
		}
	}
	cout<<all<<" "<<in<<endl;
}


Measured memory_bytes: 256
import scala.io.StdIn.readLine
import scala.collection.mutable.ArrayBuffer

object Main {
  def main(args:Array[String]) = {
    val b = new ArrayBuffer[String]
    var s = "0 0"
    while({s = readLine.trim;s} != "0 0") {
      val n = s.split(" ").map(_.toInt)
      val sum = {
        for(i<-1 to n(0)) yield readLine.split(" ").map(_.toInt).toList
      }.toList.transpose.map(_.sum)
        .zipWithIndex
        .sortWith((x,y) => (x._1 > y._1) || (x._1==y._1 && x._2<y._2))
        .map(_._2+1)
      b+=sum.mkString(" ")
    }
    println(b.mkString("\n"))
  }
}

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

#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define lb(v,n) lower_bound(v.begin(),v.end(),n)
#define ub(v,n) upper_bound(v.begin(),v.end(),n)
#define mae(v) max_element(v.begin(),v.end())
#define mie(v) min_element(v.begin(),v.end())
#define INF 0x7FFFFFFF
#define mod 1000000007
typedef long long ll;
////////////////////////////////////////////////////////////

const int MAX = 2010;
int tate[MAX][MAX] = {} , yoko[MAX][MAX] = {};

int main(){
	int h,w;
	cin >> h >> w;
	bool f[MAX][MAX];

	rep(i,0,h){
		rep(j,0,w){
			char c;
			cin >> c;
			if( c == '#' ) 
				f[i][j] = true;
			else
				f[i][j] = false;
		}
	}

	rep(i,0,h){
		rep(j,0,w){
			if( !f[i][j] ){
				yoko[i][j] = 1;
				if( j > 0 ) yoko[i][j] += yoko[i][j-1];
				tate[i][j] = 1;
				if( i > 0 ) tate[i][j] += tate[i-1][j]; 
			}
		}
	}

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

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

	for( int i = h-1 ; i >= 0 ; i-- ){
		for( int j = w-1 ; j >= 0 ; j-- ){
			if( !f[i][j]){
				if( i < h-1 ){
					if( tate[i+1][j] > tate[i][j] ) tate[i][j] = tate[i+1][j];
				}
				if( j < w-1 ){
					if( yoko[i][j+1] > yoko[i][j] ) yoko[i][j] = yoko[i][j+1];
				}
			}
		}
	}

	int ans = 0;

	rep(i,0,h){
		rep(j,0,w){
			ans = max( ans , tate[i][j] + yoko[i][j] - 1);
		}
	}

	cout << ans << endl;


	ret 0;
}

Measured memory_bytes: 35712
#include <string.h>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iomanip>
#include <deque>

using namespace std;
#define INF 1e9
#define MAX 100005
#define MOD 1000000007
#define Q queue
#define PQ priority_queue
#define fr first
#define sc second
#define pb push_back
#define mp make_pair
#define FOR( i, L, U ) for(int i=(int)L ; i<(int)U ; i++ )
#define FORD( i, U, L ) for(int i=(int)U ; i>=(int)L ; i-- )
#define wa cout<<"Wa"<<endl
#define READ(filename)  freopen(filename, "r", stdin);
#define WRITE(filename)  freopen(filename, "w", stdout);

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int> > vvi;
typedef map<int, int> mii;
typedef map<string, int> msi;
typedef map<int, string> mis;
typedef map<int , vector<int> > mvi;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;

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


int main(){
//	base();
	int n;
	stack<char> st;
	deque<char> q;
	cin>>n;
	int buka=0,tutup;
	char ch;
	char arr[MAX];
	FOR(i,1,n+1){
		cin>>ch;
		arr[i] = ch;
		if (ch==')'){
			if (buka>0){
				buka--;
			}else {
				q.push_front('(');
			}
		}else {
			buka++;
		}
		q.push_back(ch);
	}
	while(buka>0){
		q.push_back(')');
		buka--;
	}
	
	for(deque<char>::iterator it = q.begin();it!=q.end();it++){
		cout<<*it;
	}
	cout<<endl;
	
	
	return 0;
}



Measured memory_bytes: 256
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

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


	string S;
	cin >> S;

	cout << S[0] << S[1] << S[2] << endl;



	Would you please return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
long long counter[200005];
long long arr[200005];
long long comb(int index){
	return counter[index]*(counter[index]-1)/2;
}
int main(){
	int n;
	cin>>n;
	for(int i=0; i<n; i++){
		cin>>arr[i];
		counter[arr[i]]++;
	}
	long long total = 0;
	for(int i=1; i<=n; i++) total+=counter[i]*(counter[i]-1)/2;
	for(int i=0; i<n; i++){
		long long ret = total-comb(arr[i]);
		counter[arr[i]]--;
		ret+=comb(arr[i]);
		counter[arr[i]]++;
		cout<<ret<<'\n';
	}
}

Measured memory_bytes: 6720
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 110;
const ll INF = 2e9+10;

ll a, b;
int main(){
    #ifdef Irene
    freopen("in.txt", "r", stdin);
    #endif // Irene
    //ios_base::sync_with_stdio(false);

    cin >> a >> b;
    cout << a * b / __gcd(a, b) << "\n";
}


Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.ascii;


void main()
{
  int x, y, z;
  readf("%s %s %s", &x, &y, &z);
  writefln("%s %s %s", z, x, y);
}


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

#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;

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

    ll n, d; cin >> n >> d;
    d = d*d;

    vector<ll> v;
    for (int i = 0; i < n; i++)
    {
        ll y, x; cin >> y >> x;
        v.push_back(y*y+x*x);
    }
    int result = 0;
    for (int i = 0; i < v.size(); i++)
        if (v[i] <= d) result++;
    cout << result << endl;

    return 0;
}


Measured memory_bytes: 5300
fn main() {
    let v = read_vec::<usize>();

    if v[0] >= 10 || v[1] >= 10 {
        println!("-1");
    } else {
        println!("{}", v[0] * v[1]);
    }
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}


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

using namespace std;

int main()
{
  	int h, n;
 	cin >> h >> n;
  	
  	long a[n], sum = 0;
  	for (int i = 0; i < n; ++i)
    {
      cin >> a[i];
    	sum += a[i];
    }
  
  if (sum >= h)
    cout << "Yes\n";
  else
    cout << "No\n";
  	return 0;
}

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

using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<string> s(N);
  vector<string> itr(N);

  for (int i = 0; i<N; i++ ){
    cin >> s[i];
    itr[i] = s[i];
  }

  int M;
  cin >> M;
  vector<string> t(M);

  for (int i = 0; i<M; i++ ){
    cin >> t[i];
  }

  std::sort(itr.begin(),itr.end());
  itr.erase(std::unique(itr.begin(),itr.end()),itr.end());


  int max = 0;

  for (int i=0;i<itr.size();i++){
    int sum = 0;
    for(int j=0;j<N;j++){
      if (itr[i]==s[j]) sum++;
    }
    for(int j=0;j<M;j++){
      if (itr[i]==t[j]) sum--;
    }
    if(sum>max) max = sum;
  }

  cout << max << endl;

}

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

using namespace std;

int main()
{
  int N, M;
  bool mat[8][8] = {{}};

  cin >> N >> M;
  for(int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    mat[a][b] = mat[b][a] = true;
  }

  vector< int > path(N);
  iota(begin(path), end(path), 0);
  int ret = 0;
  do {
    bool flag = true;
    for(int i = 1; i < path.size(); i++) flag &= mat[path[i - 1]][path[i]];
    ret += flag;
  } while(next_permutation(begin(path) + 1, end(path)));

  cout << ret << endl;
}

Measured memory_bytes: 256
s = input()

words = ['dream','dreamer','erase','eraser']

while len(s) > 4:
    if s[-5:] == 'dream':
        s = s[:-5]
        continue
    elif s[-7:] == 'dreamer':
        s = s[:-7]
        continue
    elif s[-5:] == 'erase':
        s = s[:-5]
        continue
    elif s[-6:] == 'eraser':
        s = s[:-6]
        continue
    else:
        break

if len(s) > 0:
    print('NO')
else:
    print('YES')

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

int main() {
  int N,A,B,C;
  cin >> N>>A>>B;
  C=A*N;

  if (C<=B) {
    cout << A*N<< endl;
  }
  else if (C>B){

  cout << B<< endl;
}
}


Measured memory_bytes: 256
var
	N,K,i,u,v:Longint;
begin
	read(N,K);
	if (N-1)*(N-2)<K*2 then begin
		writeln(-1);
		exit;
	end;
	K:=(N-1)*(N-2)div 2-K;
	writeln(K+N-1);
	for i:=2 to N do begin
		writeln(1);
		writeln(i);
	end;
	u:=2;
	v:=3;
	for i:=1 to K do begin
		writeln(u);
		writeln(v);
		inc(v);
		if v>N then begin
			inc(u);
			v:=u+1;
		end;
	end;
end.


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef pair<double,double> pdd;
#define SQ(i) ((i)*(i))
#define MEM(a, b) memset(a, (b), sizeof(a))
#define SZ(i) int(i.size())
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REP1(i,j) FOR(i, 1, j+1, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(_a) _a.begin(),_a.end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define X first
#define Y second
#ifdef tmd
#define TIME(i) Timer i(#i)
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,deque<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define TIME(i)
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
#endif
class Timer {
private:
    string scope_name;
    chrono::high_resolution_clock::time_point start_time;
public:
    Timer (string name) : scope_name(name) {
        start_time = chrono::high_resolution_clock::now();
    }
    ~Timer () {
        auto stop_time = chrono::high_resolution_clock::now();
        auto length = chrono::duration_cast<chrono::microseconds>(stop_time - start_time).count();
        double mlength = double(length) * 0.001;
        debug(scope_name, mlength);
    }
};

const ll MOD = 1000000007;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int iNF = 0x3f3f3f3f;
const ll MAXN = 5003;

string s;
int n;
ll dp[MAXN][MAXN];

ll mpow(ll base,ll ep) {
    ll ret = 1;
    while (ep > 0) {
        if (ep & 1) {
            ret = ret * base % MOD;
        }
        base = base * base % MOD;
        ep >>= 1;
    }
    return ret;
}
/********** Good Luck :) **********/
int main()
{
    TIME(main);
    IOS();

    cin >> n >> s;
    dp[0][0] = 1;
    REP1 (i, n) {
        for (int j=0; j<=i; j++) {
            dp[i][j] = j ? dp[i-1][j-1] * 2 : dp[i-1][j];
            dp[i][j] += dp[i-1][j+1];
            dp[i][j] %= MOD;
        }
    }

    debug(dp[n][SZ(s)]);
    cout << dp[n][SZ(s)] * mpow(2, SZ(s) * (MOD - 2) % (MOD - 1)) % MOD << endl;
    return 0;
}


Measured memory_bytes: 193920
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	long long k, n, i, j, ans;
	cin >> k >> n;
	vector<long long> a(n * 2);
	for (i = 0; i < n; i++) {
		cin >> a[i];
		a[i + n] = a[i] + k;
	}

	ans = k;
	for (i = 0; i < n; i++) ans = min(ans, k - (a[i + 1] - a[i]));
	cout << ans << "\n";

	return 0;
}



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

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define ll long long
#define all(x) x.begin(), x.end()
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define pdd pair< double, double >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 2010
#define inf 1e14
#define MOD 1000000007

int main()

{

    string ss;
    cin >> ss;
    bool tf = 1;
    if(ss[0] != 'A') tf = 0;
    ll cnt = 0, idx = 0;
    for(ll i = 2; i < ss.size()-1;i++)
    {

        if(ss[i]=='C')
        {

            cnt++;
            idx = i;
        }
    }
    if(cnt != 1) tf = 0;
    for(ll i = 0; i < ss.size(); i++)
    {

        if(i==0 || i==idx) continue;
        if(ss[i] >= 'A' && ss[i] <= 'Z') tf = 0;
    }
    if(tf) cout << "AC";
    else cout << "WA";
}


Measured memory_bytes: 256
#!/usr/bin/env python
# coding: utf-8

import math


def get_answer(param):
    x = float(param[0])
    h = float(param[1])
    temp1 = (x * x)
    temp2 = math.sqrt((x / 2) ** 2 + h ** 2)
    temp3 = x * temp2 * 2
    return temp1 + temp3


def main():
    params = []
    while 1:
        x = int(raw_input())
        h = int(raw_input())
        if (x == 0) and (h == 0):
            break
        params.append((x, h))
    for param in params:
        print get_answer(param)

if __name__ == '__main__':
    main()

Measured memory_bytes: 7256
#include<stdio.h>

main(){


int a=0;


int b=0;


int c=0;


int d=0;


int e=0;


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


for(d=a;d<b+1;d++){


if(c%d==0){


e=e+1;


}


}


printf("%d\n",e);


return 0;


}

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

int main()
{

    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll p=1;
    p=(a*c);
    p=max(a*d,p);
    p=max(b*c,p);
    p=max(b*d,p);
    cout<<p<<endl;
}


Measured memory_bytes: 3628
import java.util.*;
import java.lang.*;

public class Main{
    
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int[] p = new int[5];
        
        for (int i = 0; i < 5; i++) {
            p[i] = sc.nextInt();
        }
        
        int ans = 0;
        int min = Integer.MAX_VALUE;
        int minrest = Integer.MAX_VALUE;
        
        
        
        for (int i = 0; i < 5; i++) {
            int rest = p[i] % 10;
            if (rest < minrest && rest != 0) {
                minrest = rest;
                min = i;
            }
        }
        
        for (int i = 0; i < 5; i++) {
            if (i != min && p[i] % 10 != 0) {
                p[i] += 10 - p[i] % 10;
            }
            ans += p[i];
        }
        
        System.out.println(ans);

    }
}


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

using namespace std;

#define DB( x ) cout << #x << " = " << x << endl;
#define LEFT(n) (2 * (n))
#define RIGHT(n) (2 * (n) + 1)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> node;
//typedef vector <vector <ll>> matrix;

const ll INF = 1e18;
const double EPS = 1e-9;
const ll MOD = (ll)(23 + 99);
const ll MAXV = (ll)(3000);
const ll MAXE = (ll)(1e6 + 10);

struct edge{
	ll a, b;
	ll c;
};

ll n, m, p;
vector <edge> G;
ll D[MAXV];

int main(){
	cin.sync_with_stdio( 0 );cin.tie( 0 );

	cin >> n >> m >> p;

	for(int i = 0;i < m;i ++){
		ll a, b;
		ll c;
		cin >> a >> b >> c;
		a --, b --;
		G.push_back(edge{a, b, -c + p});
	}

	for(int i = 0;i < n;i ++)
		D[i] = INF;

	D[0] = 0;

	bool ok = true;
	for(ll i = 0;i < 2 * n;i ++){
		for(ll j = 0;j < m;j ++){
			if(D[G[j].a] < INF){
				if(D[G[j].b] > D[G[j].a] + G[j].c){
					D[G[j].b] = D[G[j].a] + G[j].c;
					if(G[j].b == n - 1 && i >= n)
						ok = false;
				}
			}
		}
	}

	if(!ok || D[n - 1] == INF){
		cout << -1 << "\n";
		return 0;
	}
	else
		cout << max(0LL, -D[n - 1]) << "\n";
	return 0;
}


Measured memory_bytes: 576