akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0;i < n;i++)
#define REP(i,n,k) for(int i = n;i < k;i++)
#define P(p) cout << (p) << endl;
#define sP(p) cout << setprecision(15) << fixed << p << endl;
#define vi vector<int>
#define printv(v) for(int i = 0;i < v.size();i++)P(v[i]);
#define printt(a,b) cout << a << " " << b << endl; 
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 1, -1 , 0 , 0};
int dy[] = { 0,  0,  1, -1};
int MOD = 1e9 + 7;

void solve() {
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    P(min(a,b) + min(c,d));
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 256
function Main(input){
		input = input.split(" ");
		var x = new Array(2);
    	var n = parseInt(input[0],10);
    	var a = parseInt(input[1],10);
    	var b = parseInt(input[2],10);
    	//出力
		if (a>=b){
			x[0] = b;
		}else{
			x[0] = a;
		}
		var nn = n/2;
		var aa = a - nn;
		var bb = b - nn;
		x[1] = aa+bb;
		if (x[1]<=0){
			x[1]=0;
		}
		    	console.log('%d %s',x[0],x[1]);
		}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include<cstdint>
#include<unordered_map>
#include<boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define Endl endl
#define F first
#define S second

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;


int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if(a == b && b == c) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main() {
	char s[200000];
	scanf("%s", &s);
	
	int len = strlen(s), beg = 1e9, end = -1;
	bool fa = false, fz = false;
	
	for(int i = 0; i < len; i++) {
		
		if(s[i] == 'A' && !fa) {
			beg = i;
			fa = true;
		}
		if(s[len - i] == 'Z' && !fz) {
			end = len - i;
			fz = true;
		}	
	}
	
	end - beg + 1 > 0 ? printf("%d\n", end - beg + 1) : printf("0\n");
	return 0;
}

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

namespace Atc_0028
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();

            int A = int.Parse(str.Split(' ')[0]);

            int B = int.Parse(str.Split(' ')[1]);

            int C = int.Parse(str.Split(' ')[2]);

            if (A * B <= C)
            {
                Console.WriteLine(A * B);
            }
            else
            {
                Console.WriteLine(C);
            }
        }
    }
}


Measured memory_bytes: 27124
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) { return std::vector<T>(n, std::forward<T>(val)); }
template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}
template<class Cond> struct chain {
  Cond cond; chain(Cond cond) : cond(cond) {}
  template<class T> bool operator()(T& a, const T& b) const { if(cond(a, b)) { a = b; return true; } return false; }
};
template<class Cond> chain<Cond> make_chain(Cond cond) { return chain<Cond>(cond); }

int main() {
  i64 N;
  cin >> N;
  vector<i64> A(N);
  vector<i64> B(N);
  rep(i,0,N) cin >> A[i] >> B[i];
  sort(all(A));
  sort(all(B));
  if(N % 2 == 1) {
    cout << B[N / 2] - A[N / 2] + 1 << endl;
  }
  else {
    cout << B[N / 2] + B[N / 2 - 1] - A[N / 2] - A[N / 2 - 1] + 1 << endl;
  }
}


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

int main() {
  int N; cin >> N;
  int A[N]; for (int i=0; i<N; i++) cin >> A[i];
  
  int v, j;  
  for (int i=0; i<N; i++){
    v = A[i];
    j = i - 1;
    while (j >= 0 && A[j] > v){
      A[j+1] = A[j];
      j--;
      A[j+1] = v;
    }
    for (int k=0; k<N; k++){
      if (k>0) cout << " ";
      cout << A[k];
    }
    cout << endl;
     
  }
  
}


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

int main() {
  int n;
  cin>>n;
  vector<int> l(2*n);
  for(int &x : l) cin>>x;
  sort(l.begin(),l.end());
  int ans=0;
  for(int i=0;i<2*n;i+=2) ans+=l[i];
  cout<<ans<<endl;
}

Measured memory_bytes: 256
using System;
//using System.Collections;
using System.Collections.Generic;
//using System.Linq;

namespace problem
{
  class Test
  {
    static void Main()
    {
      var list = new List<int>();

      while (true)
      {
        var a = int.Parse(Console.ReadLine());
        if (a == 0) break;
        list.Add(a);
      }

      for (int c = 0; c < list.Count; c++)
      {
        Console.WriteLine("Case {0}: {1}", c+1, list[c]);
      }
    }
  }
}


Measured memory_bytes: 9612
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <iomanip>
typedef long long ll;

using namespace std;

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

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

int main()
{
	ll a, b;

	cin>>a>>b;
  ll g;
  g = gcd(a, b);
  auto pf = prime_factorize(g);
  cout << pf.size() + 1 << endl;
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
string s,t;
int n;
int main(){
	
	//code
	cin>>n;
	cin>>s>>t;
	for(int i=0;i<n;i++){
		cout<<s[i]<<t[i];
	}
	//code
	
	return 0;
}


Measured memory_bytes: 256
def is_prime(n):
  for i in range(2, n + 1):
    if i * i > n:
      break
    if n % i == 0:
      return False
  return n != 1

Q = int(input())

dp = {1: 0}

for i in range(10**5)[3::2]:
  if is_prime(i) and is_prime((i+1)//2):
    dp[i] = dp[i-2]+1
  else:
    dp[i] = dp[i-2]

for i in range(Q):
  l, r = list(map(int, input().split()))
  r = dp[r]
  l = dp[l-2] if 3 <= l else 0
  print(r-l)

Measured memory_bytes: 55388
object Main extends App {
  import scala.annotation.tailrec

  val stack = new scala.collection.mutable.Stack[Int]

  @tailrec
  def loop() {
    val line = scala.io.StdIn.readLine()
    if (line == null) return
    else {
      val n = line.toInt
      if (n == 0) println(stack.pop())
      else stack.push(n)
      loop()
    }
  }

  loop()
}

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

using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> v;
    if (n % 2) {
	for (int i = 0; i < n; i++) {
	    v.push_back((i & 1) ? 0 : m);
	}
    } else {
	for (int i = 0; i < n / 2 - 1; i++) {
	    v.push_back(0);
	}
	for (int i = 0; i <= n / 2; i++) {
	    v.push_back(m);
	}
    }
    for (int i = 0; i < n; i++) {
	if (i > 0) cout << " ";
	cout << v[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3156
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;

int main() {
  int N;
  cin >> N;
  vector<vint> a(2,vint(N*2,0));
  vector<vint> idx(2,vint(N+1,-1));

  repeat(i,N*2){
    char c;
    cin >> c;
    cin >> a[c=='B'][i];
    idx[c=='B'][a[c=='B'][i]]=i;
  }

  vector<vector<vint> > cost(2,vector<vint>(N+1,vint(N*2,0)));
  repeat(c,2){
    repeat(i,N+1){
      repeat(j,2*N-1){
        cost[c][i][j+1] = cost[c][i][j] + (a[c][j]>i);
      }
    }
  }
  vector<vint> dp(N+1,vint(N+1,0));
  repeat(b,N+1){
    repeat(w,N+1){
      if(b==0 && w==0) continue;
      int bb = b==0? INF:dp[b-1][w] + cost[1][b][idx[1][b]] + cost[0][w][idx[1][b]];
      int ww = w==0? INF:dp[b][w-1] + cost[0][w][idx[0][w]] + cost[1][b][idx[0][w]];
      dp[b][w] = min(ww,bb);
    }
  }
  cout << dp[N][N] << endl;
  return 0;
}


Measured memory_bytes: 94336
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 2e5 + 5;
int n;
long long k;
int arr[MAX_N];
bool vis[MAX_N];

void solve(){
    vector<int> cycle;
    vector<int> lol;
    int i = 0;
    int curr = 0;
    while(!vis[curr]){
        cycle.emplace_back(curr);
        vis[curr] = true;
        curr = arr[curr];
    }
    //for(int x : cycle)
       // cout << x << " ";
    //cout << "\n";

    //cout << curr << "\n";
    if(k < cycle.size()){
        cout << cycle[k] + 1;
        return;
    }
    for(i = 0; i < cycle.size(); i++){
        if(cycle[i] == curr){
            for(int j = i; j < cycle.size(); j++)
                lol.emplace_back(cycle[j]);
            k -= i;
            break;
        }
    }
    k %= (long long)lol.size();
    cout << lol[k] + 1;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> k;
    int i = 0, j = 0;
    for(i = 0; i < n; i++) {
        cin >> arr[i];
        --arr[i];
    }
    solve();
    return 0;
}

Measured memory_bytes: 6176
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n,k,t=0;
  cin >> n>>k;
  vector<int> p(n);
  for(int i=0;i<n;i++)
  {
    cin  >> p.at(i);
  }
  std::sort(p.begin(), p.end() );
  for(int j=0;j<k;j++)
  {
    t=t+p.at(j);
  }
  cout << t;
  return 0;
}

Measured memory_bytes: 3584
#include<stdio.h>
int main(){
int a, h, m, s;
scanf("%d", &a);
h = a/3600 ;
m = a % 3600 / 60 ;
s = a % 3600 % 60 ;
printf("%d:%d:%d\n", h, m, s); 
return 0;
}

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

const long long mod = 924844033;

long long modpow(long long a, long long b) {
	if (b == 0) return 1;
	return modpow(a * a % mod, b / 2) * (b & 1 ? a : 1) % mod;
}

long long modinv(long long a) {
	return modpow(a, mod - 2);
}

vector<long long> fact, inv_fact;

void init_fact(int n) {
	fact.resize(n);
	fact[0] = 1;
	for (int i = 1; i < n; i++) {
		fact[i] = i * fact[i - 1] % mod;
	}
	inv_fact.resize(n);
	inv_fact[n - 1] = modinv(fact[n - 1]);
	for (int i = n - 2; i >= 0; i--) {
		inv_fact[i] = (i + 1) * inv_fact[i + 1] % mod;
	}
}

long long nPr(int n, int r) {
	if (n < r || n < 0 || r < 0) return 0;
	return fact[n] * inv_fact[n - r] % mod;
}

long long nCr(int n, int r) {
	if (n < r || n < 0 || r < 0) return 0;
	return fact[n] * inv_fact[r] % mod * inv_fact[n - r] % mod;
}

long long nHr(int n, int r) {
	if (n == 0 && r == 0) return 1;
	return nCr(n + r - 1, r);
}

void add(long long &x, long long y) {
	x += y;
	if (x >= mod) x -= mod;
}

int f(int n, int K) {
	vector<int> a(n);
	for (int i = 0; i < n; i++) a[i] = i;

	int ans = 0;
	do {
		bool ok = true;
		for (int i = 0; i < n; i++) {
			if (abs(a[i] - i) == K) ok = false;
		}
		ans += ok;
	} while (next_permutation(a.begin(), a.end()));

	return ans;
}

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

	static long long dp[2020][2020][2]; // pos, num, L/H
	
	vector<int> c(K * 2);
	for (int i = 0; i < min(n, 2 * K); i++) {
		dp[i][0][0] = 1;
		if (i - K >= 0) dp[i][1][0] = 1;
		if (i + K < n) dp[i][1][1] = 1;
		c[i]++;
	}

	for (int i = 2 * K; i < n; i++) {
		c[i % (2 * K)]++;
		for (int j = 0; j <= n; j++) {
			// not take
			add(dp[i][j][0], dp[i - 2 * K][j][0]);
			add(dp[i][j][0], dp[i - 2 * K][j][1]);

			// take L
			add(dp[i][j + 1][0], dp[i - 2 * K][j][0]);

			// take H
			if (i + K < n) {
				add(dp[i][j + 1][1], dp[i - 2 * K][j][0]);
				add(dp[i][j + 1][1], dp[i - 2 * K][j][1]);
			}
		}
	}

	static long long xp0[4040], xp1[4040];
	xp0[0] = 1;

	int sum = 0;
	for (int i = 0; i < min(n, 2 * K); i++) {
		memset(xp1, 0, sizeof(xp1));
		int ii = n - 1 - i;
		for (int j = 0; j <= sum; j++) {
			for (int k = 0; k <= c[i]; k++) {
				(xp1[j + k] += xp0[j] * (dp[ii][k][0] + dp[ii][k][1])) %= mod;
			}
		}
		sum += c[i];
		swap(xp0, xp1);
	}
	
	init_fact(1010101);

	long long ans = 0;
	for (int i = 0; i <= n; i++) {
		if (i % 2 == 0) {
			ans += fact[n - i] * xp0[i] % mod;
		} else {
			ans += mod - fact[n - i] * xp0[i] % mod;
		}
	}
	ans %= mod;
	cout << ans << endl;
}

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

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

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

  rep(i, s.size() - 1) {
    if (s[i] == 'A' && s[i + 1] == 'C') {
      cout << "Yes" << endl;
      return 0;
    }
  }
  
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import math
while(1):
    n=int(input())
    if(n==-1): sys.exit()
    x=1.0
    y=0.0
    r=180.0
    for i in range(n-1):
        r-=90.0
        if r<180.0:
            r+=360.0
        y+= math.sin(r/180.0*math.acos(-1))
        x+= math.cos(r/180.0*math.acos(-1))
        r=math.atan2(y,x)*180.0/math.acos(-1)-180.0
        if r<180.0:
            r+=360.0
    print(x)
    print(y)

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

char s[257][257];
int n;

int check(int i, int j)
{
	int ii, jj;
	int count;
	count = 0;
	for (ii = 1; ii < n-i; ii++) if (s[i+ii][j]=='0') break;
	if (ii>count) count = ii;
	for (jj = 1; jj < n-j; jj++) if (s[i][j+jj]=='0') break;
	if (jj>count) count = jj;
	for (ii = 1, jj = 1; ii < n-i && jj < n-j; ii++, jj++) if (s[i+ii][j+jj]=='0') break;
	if (ii>count) count = ii;
	for (ii = 1, jj = 1; ii <= i && jj < n-j; ii++, jj++) if (s[i-ii][j+jj]=='0') break;
	if (ii>count) count = ii;
	return count;
}

int main()
{
	int i, j;
	int max, t;
	while (scanf("%d",&n)!=EOF, n) {
		for (i = 0; i < n; i++) scanf("%s",s[i]);
		max = 0;
		for (i = 0; i < n; i++)
			for (j = 0; j < n; j++) {
				if (s[i][j]=='1') {
					t = check(i, j);
					if (max < t) max = t;
				}
			}
		printf("%d\n",max);
	}
	return 0;
}

Measured memory_bytes: 0
def main():    
    n,m = map(int,input().split())
    lrc = [tuple(map(int,input().split())) for _ in range(m)]
    lcr = sorted([(i[0]-1,i[2],i[1]-1) for i in lrc],reverse=True)
    INF = float('inf')
    dist = [INF]*n
    check = [False]*n
    check[0] = True
    dist[0] = 0
    enable = True
    while lcr:
        route = lcr.pop(-1)
        mn = route[0]
        mx = route[-1]
        if not check[mn]:
            enable = False
            break
        else:
            d = route[1]+dist[mn]
            for i in range(mx,mn,-1):
                if dist[i] >= d:
                    dist[i] = d
                    check[i] = True
                else:
                    break
    if dist[-1] == INF:
        print(-1)
    elif enable:
        print(dist[-1])
    else:
        print(-1)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 81240
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a,b,c;

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

    if(c>(a-b)){
        printf("%d", (c-(a-b)));
    }
    else{
        printf("%d", 0);
    }

    return 0;
}


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

int main() {
    int X;
    std::cin >> X;

    int max = 0;
    for (int b = 1; b <= 100; ++b) {
        for (int p = 2; p <= 10; ++p) {
            const int v = std::pow(b, p);
            if (X < v) {
                break;
            }
            max = std::max(max, v);
        }
    }

    std::cout << max << std::endl;

    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
'''
------------------------
author : iiou16
time : 11/01/12:09
------------------------
'''


def main():
    A, B = list(map(int, input().split()))
    if A < 10 and B < 10:
        print(A * B)
    else:
        print("-1")


if __name__ == '__main__':
    main()

Measured memory_bytes: 2940
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define reptr(i,n) for(int (i)=(n);(i)>=0;--(i))
#define All(x) (x).begin(),(x).end()
const ll MOD=1e9+7;
using namespace std;

int main(){
  ll N,M;
  cin >> N >> M;
  vector<pair<ll,ll> > p;
  rep(i,N){
    ll a,b;
    cin >> a >> b;
    p.push_back(make_pair(a,b));
  }
  sort(All(p));
  ll ans=0,sum=0;
  rep(i,p.size()){
    ans += p[i].second;
    sum += p[i].first*p[i].second;
    if(ans>M){
      ans -= p[i].second;
      sum -= p[i].first*p[i].second;
      sum += p[i].first*(M-ans);
      break;
    }
  }
  cout << sum << endl;
}


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

int main() {

	int n;

	int t, a;
	int ans = -1;
	double min = 10000000;
	cin >> n;
	cin >> t >> a;

	for (int i = 0; i < n; i++) {
		double h;

		cin >> h;
		double kion = t - h * 0.006;
		if (abs(a - kion) < min) {
			ans = i+1;
			min = abs(a - kion);
		}

	


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

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

const double EPS = 1e-8;
typedef vector<double> Vec;
typedef vector<Vec> Mat;

void show(const Mat &m)
{
	puts("====");
	for (int i = 0; i < m.size(); i++){
		for (int j = 0; j < m[i].size(); j++){
			printf("%f ", m[i][j]);
		}
		puts("");
	}
	puts("====");
}

Vec gauss_jordan(const Mat &A, const Vec &b)
{
	int n = A.size();
	Mat B(n, Vec(n + 1));
	
	for (int i = 0; i < n; i++){
		for (int j = 0; j < n; j++){
			B[i][j] = A[i][j];
		}
		B[i][n] = b[i];
	}
	
	for (int i = 0; i < n; i++){
		int pivot = i;
		for (int j = i; j < n; j++){
			if (abs(B[j][i]) > abs(B[pivot][i])){
				pivot = j;
			}
		}
		swap(B[i], B[pivot]);
		
		if (abs(B[i][i]) < EPS) return Vec();
		
		for (int j = i + 1; j <= n; j++){
			B[i][j] /= B[i][i];
		}
		for (int j = 0; j < n; j++){
			if (i != j){
				for (int k = i + 1; k <= n; k++){
					B[j][k] -= B[j][i] * B[i][k];
				}
			}
		}
		
		//show(B);
	}
	
	Vec x(n);
	for (int i = 0; i < n; i++){
		x[i] = B[i][n];
	}
	
	return x;
}

int main()
{
	while (true){
		Mat A(2, Vec(2));
		Vec b(2);
		
		for (int i = 0; i < 2; i++){
			for (int j = 0; j < 2; j++){
				if (scanf("%lf", &A[i][j]) == EOF) return 0;
			}
			scanf("%lf", &b[i]);
		}
		
		Vec res = gauss_jordan(A, b);
		printf("%.3f %.3f\n", res[0], res[1]);
	}
	
	return 0;
}

Measured memory_bytes: 1256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main(){

    input!{
        n: usize,
        h: [i32;n],
    }

    let mut cnt = 0;
    let mut flag = true;

    for i in 0..n {
        for j in 0..i+1 {
            if h[i] < h[j] {
                flag = false;
            } 
        }
        if flag ==true {
            cnt += 1;
        }
        flag = true;
    }

    println!("{}", cnt);

}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define int long long int
#define db double
#define ull unsigned long long
#define vii vector <int>
#define pii pair <int, int>
#define fi first
#define se second
#define rep(i,a,n)		for(int i=a;i<n;i++)
#define endl '\n'
#define mem(a,b) memset(a, b, sizeof a)
#define mkp make_pair
#define pb push_back
#define mod 1000000007LL
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
using namespace std;
db pi=3.1415926535;
db eps=0.000001;
 
void print(vector <int> &arr){
	for(int i=0;i<arr.size();i++)
		cout<<arr[i]<<" ";
	
	cout<<endl;
}
int ncr(int n, int r)
{
    r=min(r,n-r);
    int A[r],i,j,B[r];
    iota(A,A+r,n-r+1);  //initializing A starting from n-r+1 to n
    iota(B,B+r,1);      //initializing B starting from 1 to r

    int g;
    for(i=0;i<r;i++)
    for(j=0;j<r;j++)
    {
        if(B[i]==1)
            break;
        g=__gcd(B[i], A[j] );
        A[j]/=g;
        B[i]/=g;
    }
    int ans=1;
    for(i=0;i<r;i++)
        ans=(ans*A[i]%mod);
    return ans;
}


int32_t main(){
/////////////////////////////////////////////////////////////////////
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cerr.tie(NULL);
//For fast IO
///////////////////////////////////////////////////////////////////// 
//	std::cout.unsetf ( std::ios::floatfield );  // floatfield not set
//    std::cout.precision(5);
	int a,b,c;
	cin>>a>>b>>c;
	cout<<c<<" "<<a<<" "<<b<<endl;
	return 0;
	}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n, m;
    cin >> n >> m;
    vector<vector<int> > a(n, vector<int>(m));
    for (int i = 0; i < n; i++){
        for (int j = 0; j < m; j++){
            cin >> a.at(i).at(j);
        }
    }
    vector<int> b(m);
    for (int i = 0; i < m; i++)
        cin >> b.at(i);
    
    for (int i = 0; i < n; i++){
        int an = 0;
        for (int j = 0; j < m; j++){
            an += a.at(i).at(j) * b.at(j);
        }
        cout << an << endl;
    }
}



Measured memory_bytes: 3160
//Heaplax
//别让自己后悔
#include<bits/stdc++.h>
#define N 100001
#define int long long
#define LOG(x) cerr<<#x<<" = "<<x<<endl
#define add_edge(u,v) nxt[++cnt]=head[u],head[u]=cnt,to[cnt]=v
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
char ch;bool fs;void re(int& x)
{
	while(ch=getchar(),ch<33);
	if(ch=='-')fs=1,x=0;else fs=0,x=ch-48;
	while(ch=getchar(),ch>33)x=x*10+ch-48;
	if(fs)x=-x;
}
using namespace std;
int n,a[N];
main()
{
	re(n);
	for(int i=1;i<=n;++i)re(a[i]);
	sort(a+1,a+n+1);
	int last=0;
	for(int i=1;i<=n;++i)
	{
		if(a[i-1]*2<a[i])last=i;
		a[i]+=a[i-1];
	}
	printf("%lld\n",n-last+1);
}


Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
#include<algorithm>
typedef long long LL;
const int N=1e6+5;
using namespace std;
int n,tot=1,q,k;
LL dis[N][20];
bool ok[N];
int deep[N],gr[N][20];
int first[N];
struct point{
	int to,next,wi;
}sum[N*2];
void add(int u,int v,int w)
{
	tot++;sum[tot].next=first[u];first[u]=tot;sum[tot].to=v;sum[tot].wi=w;
	tot++;sum[tot].next=first[v];first[v]=tot;sum[tot].to=u;sum[tot].wi=w;
}
void dfs(int x)
{
	ok[x]=1;
	for(int i=1;(1<<i)<=deep[x];i++){
			gr[x][i]=gr[gr[x][i-1]][i-1];
			dis[x][i]=dis[x][i-1]+dis[gr[x][i-1]][i-1];
	}
	for(int i=first[x];i;i=sum[i].next){
		if(ok[sum[i].to])continue;
		gr[sum[i].to][0]=x;
		deep[sum[i].to]=deep[x]+1;
		dis[sum[i].to][0]=sum[i].wi;
		dfs(sum[i].to);
	}
}
LL lca(int x,int y)
{
	LL vv=0;
	if(deep[x]>deep[y])swap(x,y);
	int d=deep[y]-deep[x];
	for(int i=0;(1<<i)<=d;i++)
		if((1<<i)&d){
			vv+=dis[y][i];
			y=gr[y][i];
			
		}
	if(x==y)return vv;
	for(int i=20;i>=0;i--){
		if((1<<i)<=deep[x]&&gr[x][i]!=gr[y][i]){
			vv+=dis[x][i]+dis[y][i];
			x=gr[x][i];y=gr[y][i];
		}
	}
	vv+=dis[x][0]+dis[y][0];
	return vv;
}
int main()
{
	int a,b,t,x1,y1;
	scanf("%d",&n);
	for(int i=1;i<=n-1;i++){
		scanf("%d %d %d",&a,&b,&t);
		add(a,b,t);
	}
	deep[1]=1;
	dfs(1);
	scanf("%d %d",&q,&k);
	for(int i=1;i<=q;i++){
		scanf("%d %d",&x1,&y1);
		LL tt=lca(k,x1);
		tt+=lca(k,y1);
		printf("%lld\n",tt);
	}
	return 0;
}

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

using namespace std;

int main(){
    long long x,y;
    int n,t,a;
    scanf("%d",&n);
    scanf("%lld %lld",&x,&y);
    for (int i=1;i<n;i++) {
        scanf("%d %d",&t,&a);
        if (x<=t && y<=a) {
            x=t;
            y=a;
        } else {
            long long tk=t*max(x/t,y/a);
            long long ak=a*max(x/t,y/a);
            for(int j=0;;j++) {
                if (tk+(t*j)>=x && ak+(a*j)>=y) {
                    x=tk+(t*j);
                    y=ak+(a*j);
                    break;
                }
            }
        }
    }
    printf("%lld\n",x+y);
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace Contest
{
    class ABC
    {
        static void Main()
        {
            Solve();
        }

        private static void Solve()
        {
            int INF = 1001001001;
            int[] INPUT = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = INPUT[0];
            int M = INPUT[1];
            int L = INPUT[2];
            int[,] dp = new int[N, N];

            for (int i = 0; i < N; ++i)
            {
                for (int j = 0; j < N; ++j)
                {
                    dp[i, j] = INF;
                }
                dp[i, i] = 0;
            }

            for (int i = 0; i < M; i++)
            {
                int a = 0;
                int b = 0;
                int c = 0;
                int[] inp = Console.ReadLine().Split().Select(int.Parse).ToArray();
                a = inp[0];
                b = inp[1];
                c = inp[2];
                --a;
                --b;
                dp[a, b] = c;
                dp[b, a] = c;
            }

            for (int k = 0; k < N; ++k)
                for (int i = 0; i < N; ++i)
                    for (int j = 0; j < N; ++j)
                        dp[i, j] = Math.Min(dp[i, j], dp[i, k] + dp[k, j]);

            int[,] dp2 = new int[N, N];
            for (int i = 0; i < N; ++i)
            {
                for (int j = 0; j < N; ++j)
                {
                    dp2[i, j] = INF;
                }
                dp2[i, i] = 0;
            }

            for (int i = 0; i < N; ++i)
                for (int j = 0; j < N; ++j)
                    if (dp[i, j] <= L) dp2[i, j] = 1;

            for (int k = 0; k < N; ++k)
                for (int i = 0; i < N; ++i)
                    for (int j = 0; j < N; ++j)
                        dp2[i, j] = Math.Min(dp2[i, j], dp2[i, k] + dp2[k, j]);

            int q = int.Parse(Console.ReadLine());
            for(int i = 0; i < q; i++)
            {
                int[] inp = Console.ReadLine().Split().Select(int.Parse).ToArray();
                int s = inp[0];
                int t = inp[1];
                --s;
                --t;
                int ans = dp2[s, t] - 1;
                if (dp2[s, t] == INF) ans = -1;

                Console.WriteLine(ans);
            }
            Console.ReadLine();
        }
    }
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define itn long long

typedef long long ll;
typedef pair<int, int> p;


int main()
{
  // #define int long long
  int n;
  cin >> n;
  int count = 0;
  vector<int> v;
  for (int i = 0; i < n; i++)
  {
    int tmp;
    cin >> tmp;
    v.push_back(tmp);
  }

  // set<int> s(v.begin(), v.end());
  // vector<int> vec2(s.begin(), s.end());
  // for(int i : vec2) cout << i << endl;

  for (int i = 0; i < int(v.size()); i++)
  {
    if(v[i] == -1 || v[v[i]-1] == -1 || v[v[v[i]-1]-1] == -1) continue;
    // cout << v[v[v[i]-1]-1] << endl;
    // cout << v[i] << endl;
    if(v[v[v[i]-1]-1] == v[i]){
      count++;
      // cout << "=--------" << endl;
      int tmp = v[i];
      v[i] = -1;
      v[tmp-1] = -1;
      // cout << v[i] << endl;
      // cout << v[tmp-1] << endl;
      // v.erase(v.begin() + i);
      // v.erase(v.begin() + v[i] - 1);
      // v[v[v[i].first-1].first-1].firs
    }
  }



  cout << count << endl;
}

Measured memory_bytes: 892
#include <iostream>
using namespace std;
int main(){
  int n;
  cin >> n;
  double a[n];
  double b[n];
  double x = 0.0;
  for(int i = 0; i < n; i++){
    cin >> a[i];
    b[i] = 1 / a[i];
    x += b[i];
  }
  cout << 1 / x << endl;
  return 0;
}

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

using namespace std;
using ll = long long;

void init();
void solve();

#define rep(i, a) for (int i = 0; i < (int) (a); i++)
#define reps(i, a, b) for (int i = (int) (a); i < (int) (b); i++)
#define rrep(i, a) for (int i = (int) a-1; i >= 0; i--)
#define rreps(i, a, b) for (int i = (int) (a)-1; i >= (int) (b); i--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__ "Yes"
#define FALSE__ "No"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#ifdef LOCAL
#define lcout(a) cout << a;
#define lcoutln(a) cout << a << endl;
#define lcerr(a) cerr << a;
#define lcerrln(a) cerr << a << endl;
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif
#define MOD 1000000007

signed main()
{
	init();
	solve();
}

int n;

void init()
{
	cin >> n;
}

void solve()
{
	string s[2] = {"ABC", "ARC"};
	cout << s[n >= 1200] << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<numeric>
#include<functional>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define ll long long
using namespace std;

int main(){
  int n,k;
  cin>>n>>k;
  int d[k];
  int ans=0;
  map<int,int> mp;
  rep(i,k){
    cin>>d[i];
    int tmp[d[i]];
    rep(j,d[i]){
      cin>>tmp[j];
      mp[tmp[j]-1]++;
    }
  }
  for(auto p:mp){
    ans++;
  }
  cout<<n-ans;
}


Measured memory_bytes: 3636
import java.util.Scanner;

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

		if ("A".equals(S)) {
			System.out.println("T");
		} else if ("T".equals(S)) {
			System.out.println("A");
		} else if ("C".equals(S)) {
			System.out.println("G");
		} else {
			System.out.println("C");
		}
	}
}


Measured memory_bytes: 21204
N,M = map(int,input().split())
p,y = 0,0
my_dict = dict()
def genFrstSix(P):
	str_ = str(P)
	while(len(str(str_))<6):
		str_ = "0"+ str_
		# print(str_)
	return str_
tup,P,Y= [],[],[]
for i in range(M):
	p,y = map(int,input().split())
	tup.append((p,y))
	if p in my_dict.keys():
		my_dict[p].append(y)
	else:
		my_dict[p] = [y]

# print(sorted(my_dict.items(), key =lambda item: x[1]))
for key in my_dict.keys():
	sorted_y = sorted(my_dict[key])
	ys = {y:i+1 for i,y in enumerate(sorted_y)}
	# if key in L.keys():
	my_dict[key] = ys	
	# else:
		# L[key]
# print(my_dict)
for each in tup:
	# print(each)
	# for p,y in each:
	p = each[0]
	y = each[1]
	print('{:06}{:06}'.format(p,my_dict[p][y]))


Measured memory_bytes: 54428
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
using namespace std;

int main(){    
int h,m,sec;
int S;
scanf("%d",&S);
h = S/3600;
m = (S-h*3600)/60;
sec = S-h*3600-60*m;
printf("%d:%d:%d\n",h,m,sec);


    return 0;
    }




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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i, N) cin >> A[i];

  double ans = 0.0;
  rep(i, N) {
    ans += (double)1 / A[i];
  }
  ans = 1 / ans;
  printf("%.10f\n", ans);
}

Measured memory_bytes: 256
import sys
x = []
s = ['','']
for line in sys.stdin:
    h,w = line.split()
    h,w = int(h), int(w)
    if h == 0 and w== 0: break
    tmp = (w+1)/2
    s[0] = ('#.' * tmp)[:w]
    s[1] = ('.#' * tmp)[:w]
    for j in range(h):
        print s[j % 2]
    print
    

Measured memory_bytes: 4232
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n;i>0;i--)
#define rep1(i,s,n) for(int i=s;i<n;i++)
#define max0(a,b,c) max(max(a,b),c)
#define min0(a,b,c) min(min(a,b),c) 
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<string> svec;

int main(){
    ull n,p;
    int ans=0;
    cin>>n;
    for(ull i=(ll)sqrt(n);i>=1;i--){
        if(n%i==0){
            p=n/i;
            break;
        }
    }
    while(p!=0){
        p/=10;
        ans++;
    }
    cout<<ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <cmath>
#include <algorithm>
using namespace std;
int max(int a,int b)
{
    return a>b?a:b;
}
int main()
{
    long long n,z,w;
    long long num[2333];
    cin>>n>>z>>w;
    for(long long i=1;i<=n;i++)
    {
        cin>>num[i];
    }
    if(n==1)
        cout<<abs(num[1]-w)<<endl;
    else
        cout<<max(abs(num[n]-w),abs(num[n-1]-num[n]))<<endl;
    return 0;
}


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

int main(void)
{
    int l,r,d,count=0;
    cin >> l >> r >> d;
    for(int i=l;i<=r;i++)
    {
        if(i%d == 0)
        {
            count++;
        }
    }
    cout << count <<endl;
    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int a[N],b[N];
void add(int l,int r,int x){
    b[l] += x;
    b[r+1] -= x;
}
int main(){
    int n,k,q,x;
    cin >> n >> k >> q;
    add(1,n,k);
    while(q--){
        cin >> x;
        add(1,x-1,-1);
        add(x+1,n,-1);
    }
    for(int i = 1;i <= n; ++i){
        b[i] += b[i-1];
        if(b[i] <= 0) cout << "No\n";
        else cout << "Yes\n";
    }
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
using namespace std;
typedef long long ll;

int main()
{
  string  S;
  ll res=0;
  cin >> S;

  rep(i,1<<(S.length()-1)){
    ll n;
    ll m = S[0] - '0';
    ll sum = 0;
    rep(j,S.length()-1){
      n = S[j+1] - '0';
      if((i>>j & 1) == 0) m = 10*m + n;
      else {
        sum += m;
        m = n;
      }
    }
    sum += m;
    //printf("i:%x sum:%lld\n", i, sum);                                        
    res += sum;
  }

  cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
int gcd(int a,int b){return b ? gcd(b,a%b) : a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}

main() {
    int N; cin >> N;
    int A[N],sum=0;
    rep(i,N){
        cin >> A[i];
        sum+=A[i];
    }
    int pos=0,ans=999999999;
    for(int i=0;i<N-1;i++){
        pos+=A[i];
        ans=min(ans,abs(sum-pos*2));
    }
    if(N==2) cout << abs(A[0]-A[1]) << endl;
    else cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define ll long long
#define pb push_back
#define sz(x) (int)(x).size()
#define mp make_pair
#define f first
#define s second
#define all(x) x.begin(), x.end()

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>; ///find_by_order(),order_of_key()
template<class T1, class T2> ostream& operator<<(ostream& os, const pair<T1,T2>& a) { os << '{' << a.f << ", " << a.s << '}'; return os; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& a) {
	os << '{';
	for(int i=0;i<sz(a);i++)
	{
		if(i>0&&i<sz(a)-1)
			os << ", ";
		os << a[i];
	}
	os << '}';
    return os;
}
const int N=100;
const int K=1e5+5;
int dp[K][2];
vector<int> rem;
int calc(int k,int p)
{
    if(dp[k][p]!=-1)
        return dp[k][p];
    if(p==0)
    {
        dp[k][p]=1;
        for(auto d:rem)
        {
            if(d<=k)
            {
                int a=calc(k-d,1);
                if(a==0)
                    dp[k][p]=0;
            }
        }
    }
    else
    {
        dp[k][p]=0;
        for(auto d:rem)
        {
            if(d<=k)
            {
                int a=calc(k-d,0);
                if(a==1)
                    dp[k][p]=1;
            }
        }
    }
    return dp[k][p];
}
int main()
{
    memset(dp,-1,sizeof(dp));
    int n,k;
    scanf("%i %i",&n,&k);
    for(int i=0;i<n;i++)
    {
        int a;
        scanf("%i",&a);
        rem.pb(a);
    }
    if(calc(k,0)==0)
        printf("First\n");
    else
        printf("Second\n");
    return 0;
}

Measured memory_bytes: 7296
n = gets.to_i
arr = []
n.times { arr << gets.to_i }
$count = 0

def insertion_sort(n, arr, g)
  (g..(n - 1)).each do |sorted_i|
    v = arr[sorted_i]
    j = sorted_i - g
    while(j >= 0 && arr[j] > v) do
      arr[j + g] = arr[j]
      j = j - g
      $count += 1
    end
    arr[j + g] = v
  end
end

def shell_sort(n, arr)
  g = num_line(n)
  m = g.size

  (0..(m - 1)).reverse_each do |i|
    insertion_sort(n, arr, g[i])
  end

  puts m
  puts g.reverse.join(' ')
  puts $count
  arr.each do |e|
    puts e
  end
end

def num_line(n)
  g = []
  i = 0
  num = 0
  while(n > num) do
    num = num * 3 + 1
    break if(num > n)
    g <<  num
    i += 1
  end
  g
end

shell_sort(n, arr)



Measured memory_bytes: 16628
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if (a * b % 2 == 1)
			System.out.println("Odd");
		else
			System.out.println("Even");
	}

}

Measured memory_bytes: 21844
N, Y = map(int, input().split())
for i in range(N+1):
    for j in range(N+1-i):
        k = N - (i + j)
        if i * 10000 + j * 5000 + k * 1000 == Y:
            print(i, j, k)
            exit()
print(-1, -1, -1)


Measured memory_bytes: 8984
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <string>
#define INF 1000000007
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int, int> P;


int main() {

	ll a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;

	ll res1 = 0, res2 = 0;

	res1 = min(a + b, 2*c)*min(x, y);
	
	if (x == y) {
		cout << res1 << endl;
		return 0;
	}

	if (x > y) {
		res2 = min(a, 2 * c)*(x - y);
	}
	else {
		res2 = min(b, 2 * c)*(y - x);
	}

	cout << res1 + res2 << endl;

	return 0;

}

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

int main() {
  int n; cin >> n;
  long long a = 2;
  long long b = 1;
  long long c = 0;
  for (int i = 1; i < n; i++)
  {
    c = a + b;
    a = b;
    b = c;
  }
  if(n == 0){
    cout << 2 << endl;
  } else if(n == 1) {
    cout << 1 << endl;
  } else {
    cout << c << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define reg register
#define mod 924844033
#define G 5
#define Gi 554906420
#define maxn 2000001
using namespace std;
inline int  read() {
    reg int s = 0, t = 0; reg char ch = getchar();
    while(ch > '9' || ch < '0') t |= ch == '-', ch = getchar();
    while(ch >= '0' && ch <= '9') s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
    return t ? -s : s;
}
int inv[maxn], fac[maxn], ifac[maxn], nt[maxn], fi[maxn], go[maxn];
int lim, rev[maxn], cnt, siz[maxn], n, f[maxn], g[maxn];
int ksm(int u, int v){
    int s = 1;
    for(int i = v; i; i >>= 1){
        if(i & 1) s = 1ll * s * u % mod;
        u = 1ll * u * u % mod;
    }
    return s;
}
void add(int u, int v){
    nt[++cnt] = fi[u]; fi[u] = cnt; go[cnt] = v;
}
int C(int x, int y) {
  if (x < 0 || y < 0 || x < y)
    return 0;
  else
    return 1ll * fac[x] * ifac[y] % mod * ifac[x - y] % mod;
}
void dfs(int u, int fa){
    siz[u] = 1;
    for(int i = fi[u]; i; i = nt[i]){
        int v = go[i]; if(v == fa) continue;
        dfs(v, u); siz[u] += siz[v];
    }
    f[siz[u]]++;  f[n - siz[u]]++;
}
void ntt(int *a, int type){
    for(int i = 1; i < lim; i++)
        if(i < rev[i]) swap(a[i], a[rev[i]]);
    for(int i = 1; i < lim; i <<= 1){
        int x = ksm(type == 1 ? G : Gi, (mod - 1) / (i << 1));
        for(int j = 0; j < lim; j += (i << 1)){
            int y = 1;
            for(int k = 0; k < i; k++, y = 1ll * y * x % mod){
                int p = a[j + k], q = 1ll * y * a[j + k + i] % mod;
                a[j + k] = (p + q) % mod, a[j + k + i] = (p - q + mod) % mod;
            }
        }
    } 
}
int main()
{
    n = read();
    for(int i = 1; i < n; i++) {
        int x = read(), y =  read();
        add(x, y); add(y, x);
    }
    dfs(1, 0);
     fac[0] = 1; ifac[0] = 1; inv[0] = 1;
    for(int i = 1; i < maxn; i++){
        inv[i] = (i == 1) ? 1 : 1ll * inv[mod % i] * (mod - mod / i) % mod;
        fac[i] = 1ll *  fac[i - 1] * i % mod;
        ifac[i] = 1ll * ifac[i - 1] * inv[i] % mod;
    }
    int ans = 0;
    for(int i = 1; i <= n; i++)
        f[i] = 1ll * f[i] *fac[i] % mod; 
    for(int i = 0; i <= n; i++) g[i] = ifac[i];
    reverse(f, f + n + 1);
    int len = 0; 
    for(lim = 1; lim <= (n << 1); lim <<= 1, len++);
    for(int i = 1; i < lim; i++)
    rev[i] = (rev[i >> 1] >> 1) | ((i & 1) << (len  - 1));
    ntt(g, 1); ntt(f, 1);
    for(int i = 0; i < lim; i++) g[i] = 1ll * g[i] * f[i] % mod;
    ntt(g, -1); 
    for(int i = 0; i < lim; i++) g[i] = 1ll * g[i] * ksm(lim, mod - 2) % mod;
    reverse(g, g + n + 1);
    for(int i = 1; i <= n; i++){
        ans = 1ll * (n + 1) * C(n, i) % mod;
        ans = (ans - 1ll * g[i] * ifac[i] % mod + mod) % mod;
        printf("%d\n", ans);
    } 
}

Measured memory_bytes: 61696
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
	}

	void solve() {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());
		int c = Integer.parseInt(sc.next());
		int[] B = new int[m];
		int[][] A = new int[n][m];
		for(int i=0;i<m;i++) {B[i] = Integer.parseInt(sc.next());}
		for(int i=0;i<n;i++) {
			for(int j=0;j<m;j++){
				A[i][j] = Integer.parseInt(sc.next());
			}
		}

		int cnt = 0;
		for(int i=0;i<n;i++) {
			long num = c;
			for(int j=0;j<m;j++) {
				num += A[i][j]*B[j];
			}
			if(num>0)cnt++;
		}
		System.out.println(cnt);
	}

}


Measured memory_bytes: 23764
#include <iostream>
#include <vector>
#include <tuple>
#include <queue>

int main(){
  int N,M;
  std::cin >> N >> M;

  std::vector<std::vector<int>> a_arr(M+1);
  for(int i = 0; i < N ; i++){
    int a,b;
    std::cin >> a >> b;
    if(M-a < 0) continue;
    a_arr[M-a].push_back(b);
  }

  std::priority_queue<int> pq;
  long long ans = 0;
  for(int i = M-1; i >= 0; i--){
    for(auto&& it: a_arr[i]){
      pq.push(it);
    }
    if(pq.size() > 0){
      ans += pq.top();
      pq.pop();
    }
  }

  std::cout << ans << std::endl;

  return 0;
}



Measured memory_bytes: 5632
/* B Binary Trees */

#include<stdio.h>

int T[26][3];/*T[n][0]=P, T[n][1]=L(left child), T[n][2]=R(right child)*/

int main(){
  int i,j;
  int n, id, l, r;
  int temp,count, height;

  scanf("%d",&n);

  /* initialize T[n][3]*/
  for(i=0;i<n;i++){
    for(j=0;j<3;j++){
      T[i][j]=-1;
    }
  }

  for(i=0;i<n;i++){
    scanf("%d %d %d",&id,&l,&r);
    T[id][1]=l;
    T[l][0]=id;
    T[id][2]=r;
    T[r][0]=id;
  }

  /*print*/
  for(i=0;i<n;i++){
    printf("node %d: ",i);
    printf("parent = %d, ",T[i][0]);
    if(T[i][0]==-1){
      printf("sibling = -1, ");
    }else if(T[T[i][0]][1]==i){
      printf("sibling = %d, ",T[T[i][0]][2]);
    }else{
      printf("sibling = %d, ",T[T[i][0]][1]);
    }
    printf("degree = ");
    if(T[i][1]!=-1&&T[i][2]!=-1)printf("2, ");
    else if(T[i][1]!=-1||T[i][2]!=-1)printf("1, ");
    else printf("0, ");


    temp=T[i][0];
    printf("depth = ");
    count=0;
    if(temp!=-1){
      while(1){
	count++;
	temp=T[temp][0];
	if(temp==-1)break;
      }
      printf("%d, ",count);
    }else{
      printf("0, ");
    }

    printf("height = ");
    
    
    /* search leaf */
    height=0;
    for(j=0;j<n;j++){
      if(T[j][1]==-1&&T[j][2]==-1&&T[j][0]!=-1){
	/*count height*/
	temp=j;
	count=0;
	while(1){
	  count++;
	  if(T[temp][0]==i){
	    if(height<count){
	      height=count;
	    }
	    break;
	  }else{
	    temp=T[temp][0];
	    if(T[temp][0]==-1){
	      break;
	    }
	  }
	}
      }
    }
    printf("%d, ",height);
    
    /*root, internal node or leaf*/
    if(T[i][0]==-1)printf("root");
    else if(T[i][1]==-1&&T[i][2]==-1)printf("leaf");
    else printf("internal node");
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 0
def is_yy(st):
    st = int(st)
    if (0 <= st <= 99):
        return True
    return False
    
def is_mm(st):
    st = int(st)
    if (1 <= st <= 12):
        return True
    return False

def get_ans(head, tail):
    if (is_yy(head) and is_mm(tail)) and (is_yy(tail) and is_mm(head)):
        return 'AMBIGUOUS'
    elif (is_yy(head) and is_mm(tail)) and not (is_yy(tail) and is_mm(head)):
        return 'YYMM'
    elif not (is_yy(head) and is_mm(tail)) and (is_yy(tail) and is_mm(head)):
        return 'MMYY'
    else:
        return 'NA'

s = input()
head = s[0:2]
tail = s[2:]
print(get_ans(head, tail))
    

Measured memory_bytes: 3064
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = input()
index = int(k) - 1
print(a[index])

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

int main(){
  int n;
  cin >> n;
  string a,b,s;
  cin >>a>>b;
  for(int i=0;i<n;i++){
    s=s+a.at(i)+b.at(i);     
  }
  cout<<s;
}

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

using namespace std;

int nums[105];

void trace(int n) {
    for (int i = 0; i < n - 1; ++i) {
        printf("%d ", nums[i]);
    }
    printf("%d\n", nums[n - 1]);
}

void insert_sort(int n) {
    for (int i = 1; i < n; ++i) {
        int tmp = nums[i];
        int j = i;
        while(j > 0 && tmp < nums[j - 1]) {
            nums[j] = nums[j - 1];
            --j;
        }
        nums[j] = tmp;
        trace(n);
    }
}

int main() {
#ifdef TEST
    freopen("input", "r", stdin);
#endif
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> nums[i];
    }
    if(1 == n) {
        printf("%d\n", nums[0]);
    } else {
        trace(n);
        insert_sort(n);
    }

    return 0;
}



Measured memory_bytes: 3216