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

int main() {
  char c;
  cin >> c;
  if (c == 'a'){
    cout << "vowel" << endl;
  }
  else if (c == 'e'){
    cout << "vowel" << endl;
  }
  else if (c == 'i'){
    cout << "vowel" << endl;
  }
  else if (c == 'o'){
    cout << "vowel" << endl;
  }
  else if (c == 'u'){
    cout << "vowel" << endl;
  }
  else{
    cout << "consonant"<< endl;
  }
}
 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A ,B, C, D;
  cin >> A >> B >> C >> D;
  if (A + B == C + D) {
    cout << "Balanced" << endl;
  } else if (A + B > C + D) {
    cout << "Left" << endl;
  } else {
    cout << "Right" << endl;
  }
}

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

using namespace std;

typedef double db;
typedef long long ll;
typedef long double ld;
typedef unsigned int ui;
typedef unsigned long long ull;

typedef pair < db, db > pdd;
typedef pair < db, ld > pdl;
typedef pair < ld, db > pld;
typedef pair < ld, ld > ldp;

typedef pair < ll, ll > pll;
typedef pair < int, ll > pil;
typedef pair < ll, int > pli;
typedef pair < int, int > pii;

#define F first
#define S second

#define en end()
#define bg begin()

#define rev reverse
#define mp make_pair
#define pb push_back

#define y1 y1234567890
#define um unordered_map

#define all(x) x.bg, x.en
#define sz(x) (int)x.size()
#define len(x) (int)strlen(x)

#define sqr(x) ((x + 0ll) * (x))
#define sqrd(x) ((x + 0.0) * (x))

#define forn(i, n) for (int i = 1; i <= n; i++)

const ll inf = (ll)1e15;
const ll mod = (ll)1e9 + 7;

const db eps = (db)1e-9;
const db pi = acos(-1.0);

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

const int N = 100500;

ll a, b, c;

int main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	//freopen(".err", "w", stderr);

	//srand(time(NULL));

	//cin.tie(NULL);
	//cout.tie(NULL);
	//ios_base::sync_with_stdio(false);

	//cout << setprecision(10) << fixed;
	
	cin >> a >> b >> c;

	cout << min({abs(a / 2 * b * c - (a - a / 2) * b * c), abs(b / 2 * a * c - (b - b / 2) * a * c), abs(c / 2 * b * a - (c - c / 2) * b * a)});
	
	//cerr << (clock() + 0.0) / CLOCKS_PER_SEC;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
const ll mod=1e9+7 ;
typedef vector<vector<ll> > mat;
mat mul(mat A,mat B){
   mat C(3,vector<ll>(3));
   rep(i,3)rep(j,3)rep(k,3)C[i][j]=(C[i][j]+A[i][k]*B[k][j])%mod;
   return C;
}
vector<ll> mul(mat A,vector<ll> x){
    vector<ll> ret(3);
    rep(i,3)rep(j,3)(ret[i]+=A[i][j]*x[j])%=mod;
    return ret;
}
mat A[30];
vector<ll> calc(ll n,vector<ll> x){
    vector<ll> ret=x;
    rep(i,30){
        if(n&(1<<i))ret=mul(A[i],ret);
    }
    return ret;
}
int main(){
    int n,m;
    cin>>n>>m;
    vector<ll> vec;
    ll a[m+2];
    rep(i,m)cin>>a[i+1];
    a[0]=0;a[m+1]=n;
    A[0]={{4,mod-2,1},{1,0,0},{0,1,0}};
    rep(i,30)A[i+1]=mul(A[i],A[i]);
    vec={5,1,0};
    rep(i,m+1){
        vec=calc(a[i+1]-a[i],vec);
        vec[0]+=5*mod-5*vec[2];
        vec[1]+=mod-vec[2];
    }
    cout<<vec[2];
}

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

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

    string S;
    cin >> S;
    int cnt_0 = count(S.cbegin(), S.cend(), '0');
    int cnt_1 = S.size() - cnt_0;
    cout << min(cnt_0, cnt_1)*2 << endl;
}

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

using namespace std;

// input
int x,a;

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

  cin >> x >> a;

  if (x < a) {
    cout << "0" << "\n";
  } else {
    cout << "10" << "\n";
  }
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }


struct UnionFind{
    vector<int> d;
    UnionFind(int n = 0): d(n, -1){}
    int find(int x){
        if (d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x, int y){
        x = find(x); y = find(y);
        if (x == y) return false;
        if (d[x] > d[y]) swap(x, y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x, int y) {return find(x) == find(y);}
    int size(int x){return -d[find(x)];}
};

int main(){
    int n, m;
    cin >> n >> m;
    UnionFind uf(n);
    rep(i,m){
        int a, b;
        cin >> a >> b;
        a--; b--;
        uf.unite(a, b);
    }

    int ans = 0;
    rep(i,n) ans = max(ans, uf.size(i));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4056
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
//#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
//#include <list>
#include <iomanip>
//#include <stdlib.h>
//#include <cctype>

using namespace std;

const int MAX_N = 1000000;
#define IOS ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define prec std::cout << std::fixed << std::setprecision(15);
#define endl "\n"
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define ssort(z) sort(z.begin(), z.end())
#define rsort(z) sort(z.rbegin(), z.rend())
#define eerase(z) z.erase(unique(z.begin(), z.end()), z.end())
#define ccnt(z, w) count(z.begin(), z.end(), w)
template <typename T>
void printV(const std::vector<T>& v, const char * const separator = " ")
{
    if(!v.empty())
    {
        std::copy(v.begin(),
                  --v.end(),
                  std::ostream_iterator<T>(std::cout, separator));
        std::cout << v.back() << "\n";
    }
}


Int gcd(Int a, Int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

Int lcm(Int a, Int b) {
    return a / gcd(a, b) * b;
    //a*bは64bit integer overflow
}

int Max(int a, int b, int c) {
    int temp = max(a, b);
    return max(temp, c);
}

int Min(int a, int b, int c) {
    int temp = min(a, b);
    return min(temp, c);
}

bool integer(double num) {
    return floor(num) == num;
}

Int fact(int num) {
    if (num == 0)
        return 1;
    else
        return num * fact(num - 1);
}

void y() {
    cout << "Yes" << endl;
    exit(0);
}

void n() {
    cout << "No" << endl;
    exit(0);
}

void Y() {
    cout << "YES" << endl;
    exit(0);
}

void N() {
    cout << "NO" << endl;
    exit(0);
}

Int yakusu(int n) {
    int cnt = 0;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            cnt++;
            if (i * i != n) cnt++;
        }
    }
    return cnt;
}

/*   kokomade  */

int cnt = 0;
bool is_prime[ 50000 + 1 ];
vector<int> P;
void Eratosthenes( const int N )
{
    for( int i = 0; i <= N; i++ )
    {
        is_prime[ i ] = true;//初期化
    }
    for( int i = 2; i <= N; i++ )
    {
        if( is_prime[ i ] )
        {
            for( int j = 2 * i; j <= N; j += i )
            {
                is_prime[ j ] = false;
            }
            P.emplace_back( i );
        }
    }
}

int main() {
    IOS;
    string str;cin>>str;
    if (str=="Sunny")cout<<"Cloudy";
    if (str=="Cloudy")cout<<"Rainy";

    if (str=="Rainy")cout<<"Sunny";




    cout<<endl;
    return 0;
}

/*
テレビも無ェ ラジオも無ェ
自動車もそれほど走って無ェ
ピアノも無ェ バーも無ェ
巡査 毎日ぐーるぐる
朝起ぎで 牛連れで
二時間ちょっとの散歩道
電話も無ェ 瓦斯も無ェ
バスは一日一度来る
俺らこんな村いやだ 俺らこんな村いやだ
東京へ出るだ 東京へ出だなら
銭コァ貯めで 東京でベコ(牛)飼うだ
*/


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

int main()
{
    string s;

    int A, B, C;
    cin >> A >> B >> C;

    if (A == B && B == C){
        cout << 'Y' << 'e' << 's' << endl;
    }
    else
    {
        cout << 'N' << 'o' << endl;
    }
}

Measured memory_bytes: 256
N, A, B = gets.chomp.split(" ").map(&:to_i)

output = 0

(1..N).each do |i|
  sum = 0
  n = i
  while n > 0
    sum += n % 10
    n   = n / 10
  end
  output += i if sum.between?(A, B)
end

puts output


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

#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int long long
#define endl '\n'
#define eps  1e-9
const double pi=acos(-1);
const int mod=1e9+7;
//_______________________


int32_t main()
{ 
  io;
 
  
  string s;
  cin>>s;

  int ans=100000000,bit=0,cnt=0;

  for(char c: s)
  {
    if((c-'0')!=bit)
      cnt++;
    bit^=1;
  }
  ans=min(ans,cnt);
  bit=1;
  cnt=0;
  for(char c: s)
  {
    if((c-'0')!=bit)
      cnt++;
    bit^=1;
  }
  ans=min(ans,cnt);

  cout<<ans;
  
 return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
using namespace std;

long long pow(long long A, long long P){
	long long a = A, p = P;
	if(p == 0) return 1;
	if(p == 1) return a;
	long long adash = a * a;
	if(p % 2) return pow(adash, p / 2) * a;
	else return pow(adash, p / 2);
}
int main(){
	long long N, K;
	cin >> N >> K;
	vector<long long> A(N);
	for(int i=0;i<N;i++){
		cin >> A[i];
	}
	vector<long long> on(41,0);
	for(int i=0;i<N;i++){
		long long j=0;
		long long Adash = A[i];
		while(Adash > 0){
			if(Adash % 2) on[j]++;
			j++;
			Adash /= 2;
		}
	}
	long long ans = 0;
	for(long long i=0;i<=40;i++){
		if(((K + 1) >> i) % 2 == 0)continue;
		long long ansdash = 0;
		long long Kdash = 0;
		for(int j=0;j<i;j++){
			if(on[j] <= N - on[j]) Kdash += pow(2,j);
		}
		for(int j=i+1;j<=40;j++){
			if(((K + 1) >> j) % 2) Kdash += pow(2,j);
		}
		for(int i=0;i<N;i++){
			ansdash += Kdash ^ A[i];
		}
		ans = max(ansdash,ans);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

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

from math import factorial
if n >1:
    a = factorial(n) / factorial(2) / factorial(n - 2)
else: a= 0

if m > 1:
    b = factorial(m) / factorial(2) / factorial(m - 2)
else: b= 0

print(int(a+b))

Measured memory_bytes: 3060
#include <stdio.h>

typedef struct { char suit, value; } Card;

void bubble(Card A[], int N) {
  int i,j;
  Card t;
  for(i = 0; i<N; i++) {
    for(j = N-1; j >= i; j--) {
      if(A[j].value < A[j-1].value) {
        t = A[j]; A[j] = A[j-1]; A[j-1] = t;
      }
    }
  }
}

void selection(Card A[], int N) {
  int i,j,minj;
  Card t;
  for(i=0;i<N;i++) {
    minj = i;
    for(j=i; j<N; j++) {
      if(A[j].value < A[minj].value) minj = j;
    }
    t = A[i]; A[i] = A[minj]; A[minj] = t;
  }
}

void print(Card A[], int N) {
  int i;
  for(i=0; i<N; i++) {
    if(i>0) printf(" ");
      printf("%c%d",A[i].suit,A[i].value);
  }
  printf("\n");
}

int isStable(Card C1[], Card C2[], int N) {
  int i;
  for(i=0; i<N; i++) {
    if(C1[i].suit != C2[i].suit) return 0;
  }
  return 1;
}

void str2Card(Card *t,char str[]) {
    t->suit  = str[0];
    t->value = str[1] - '0';
}

int main(void) {
  Card C1[100], C2[100];
  int N,i;
  char str[3];

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

  for(i=0; i<N; i++) C2[i] = C1[i];

  bubble(C1,N);
  selection(C2,N);

  print(C1,N);
  printf("Stable\n");
  print(C2,N);
  if(isStable(C1,C2,N)) {
    printf("Stable\n");
  } else {
    printf("Not stable\n");
  }

  return 0;
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REP(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;


int main(){

  int X, Y;
  cin >> X;
  cin >> Y;

  ll ans = 0;

  if (X == 3)
    ans+=100000;
  else if (X == 2)
    ans+=200000;
  else if (X == 1)
    ans+=300000;

  if (Y == 3)
    ans+=100000;
  else if (Y == 2)
    ans+=200000;
  else if (Y == 1)
    ans+=300000;

  if ((X==1) && (Y==1))
    ans+=400000;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#define LL long long
using namespace std;
const int maxn = 2e5 + 5;
int n, a[maxn], b[maxn], L, num;
LL suma[maxn], sumb[maxn], ans;

int main() {
	scanf("%d%d", &L, &n);
	for(register int i = 1; i <= n; ++i) {
		scanf("%d", &a[i]);
		b[i] = L - a[i];
	}
	for(register int i = 1; i <= n; ++i) {
		suma[i] = suma[i - 1] + a[i];
		sumb[i] = sumb[i - 1] + b[i];
	}
	sumb[n + 1] = sumb[n];
	for(register int i = 1; i <= n; ++i) {
		num = min(n - i, i);
		ans = max(ans, a[i] + (suma[i - 1] - suma[i - num] + sumb[i + num] - sumb[i]) * 2);
		if(i < n) ans = max(ans, b[i + 1] + (suma[i] - suma[i - num] + sumb[i + num] - sumb[i + 1]) * 2);
	}
	ans = max(ans, (LL)b[1]);
	for(register int i = 1; i <= n; ++i) {
		num = min(n - i, i - 1);
		ans = max(ans, (suma[i - 1] - suma[i - 1 - num] + sumb[i + num] - sumb[i]) * 2 + max(a[i], b[i]));
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 4864
n = int(input())

cnt = 0
fitn = 0
while(fitn < n):
    cnt += 1
    fitn += cnt
    
    if(fitn > n):
        print("No")
        exit()


numofrow = cnt + 1
ans = []
for i in range(numofrow):
    ans.append([])
offset = 0
finishrow = 0
while(finishrow != numofrow):
    for i in range(cnt-finishrow):
        ans[finishrow].append(i+1+offset)
    finishrow += 1    
    for i in range (numofrow-finishrow):
        ans[i+finishrow].append(i+1+offset)
    
    offset += numofrow-finishrow

print("Yes")
print(numofrow)
for i in range(numofrow):
    print(cnt," ".join(map(str,ans[i])))

Measured memory_bytes: 12212
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] num = new int[n];

		for (int i = 0; i < n; i++) {
			num[i] = sc.nextInt();
		}

		int max = num[0];
		int min = num[0];
		long sum = 0;

		for (int a : num) {
			if (a > max) {
				max = a;
			}
			if (a < min) {
				min = a;
			}
			sum += a;
		}
		System.out.println(min + " " + max + " " + sum);
		}

}



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

int main()
{
  long long n, p, i;
  cin >> n >> p;
  long long ans = 1;
  long long count = 0;
  for(i = 2; i <= 1000000; i++)
  {
    while(p % i == 0)
    {
      p /= i;
      count++;
    }
    count /= n;
    while(count > 0)
    {
      ans *= i;
      count--;
    }
    count = 0;
  }
  if(p != 1 && n == 1)
  {
    ans *= p;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5;
int n;
ll k;
vector<ll>v1,v2;
bool judge(ll m)
{
    m++;
    ll ans=0;
    ll s1=v1.size(),s2=v2.size();
    if(m==0)
    {
        for(int i=0;i<s2;i++)
            if(v2[i]==0) ans+=s1;
        ans+=(ll)s1*(s1-1)/2;
        ans+=(ll)s2*(s2-1)/2;
        ans=(ll)n*(n-1)/2-ans;
        return ans>=k;
    }
    if(m>0)
    {
        for(int i=0;i<s1-1;i++)
        {
            ll x=m/v1[i];
            if(m%v1[i]) x++;
            int k=lower_bound(v1.begin()+i+1,v1.end(),x)-v1.begin();
            ans+=s1-k;
        }
        for(int i=0;i<s2-1;i++)
        {
            if(v2[i]==0) continue;
            ll x=m/v2[i];
            if(m%v2[i]) x++;
            int k=lower_bound(v2.begin()+i+1,v2.end(),x)-v2.begin();
            ans+=s2-k;
        }
        ans=(ll)n*(n-1)/2-ans;
        return ans>=k;
    }
    if(m<0)
    {
        m*=-1;
        ans+=(ll)s1*(s1-1)/2;
        ans+=(ll)s2*(s2-1)/2;
        for(int i=0;i<s1;i++)
        {
            ll x=m/v1[i];
            int k=upper_bound(v2.begin(),v2.end(),x)-v2.begin()-1;
            ans+=k+1;
        }
        ans=(ll)n*(n-1)/2-ans;
        return ans>=k;
    }
}
int main()
{
    scanf("%d%lld",&n,&k);
    for(int i=1;i<=n;i++)
    {
        int x;scanf("%d",&x);
        if(x<0) v1.push_back(-x);
        else v2.push_back(x);
    }
    sort(v1.begin(),v1.end());
    sort(v2.begin(),v2.end());
    ll l=-1e18,r=1e18,ans;
    while(l<=r)
    {
        ll m=l+r>>1;
        if(judge(m)) ans=m,r=m-1;
        else l=m+1;
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 2548
s = input()
f = {}
g = {}

chars = [c for c in s]
#print(chars)

for char in chars:
    f[char] = []
    f[char].append(-1)
    for i, c in enumerate(s):
        if(c==char):
            f[char].append(i)
    f[char].append(len(s))

max_len_all = len(s)
for char in chars:
    max_len = 0
    for i in range(len(f[char])-1):
        max_len = max(max_len, f[char][i+1]-f[char][i])
    g[char] = max_len
    if(g[char]<max_len_all):
        ans = char
        max_len_all = g[char]



#print(f)
#print(g)
print(max_len_all-1)


Measured memory_bytes: 3064
#include <stdio.h>
#define f(c,d)for(c=d%2;c<d;c+=2)
p[2<<19],a,b,m,i,j,o;
x(i,j){if(a)p[i]=60,p[i+1]=62,a--;}
y(i,j){if(b)p[i]=94,p[i+m]=118,b--;}
main(n){
	scanf("%d%d%d%d",&n,&m,&a,&b);
	if(n&1)f(j,m)x(j);
	if(m&1)f(i,n)y(i*m);
	if(n>2&m>2&n&m&a&a>0&b>0)a++,x(0),x(2*m+1),y(2);
	f(i,n)f(j,m)if(p[(o=i*m+j)+1]);else if(a)x(o),x(o+m);else y(o),y(o+1);
	puts(a|b?"NO":"YES");if(!a&!b)for(i=0;i<n*m;++i%m||puts(""))putchar(p[i]?:46);
}

Measured memory_bytes: 5248
#include<bits/stdc++.h>
#define Tp template<typename Ty>
#define Ts template<typename Ty,typename... Ar>
#define Reg register
#define RI Reg int
#define Con const
#define CI Con int&
#define I inline
#define W while
#define N 200000
#define X 998244353
#define Inc(x,y) ((x+=(y))>=X&&(x-=X))
using namespace std;
int n;int a[N+5],b[N+5],f[N+5],g[N+5];
int main()
{
	RI i,j,p,k=0,t=0,cnt=0;string s;
	for(scanf("%d",&n),cin>>s,i=1;i<=n;++i) a[i]=s[i-1]&1;
	for(i=1;i<=n;++i) if(!(n%i)&&(n/i)&1)
	{
		for(f[++k]=i,j=1;j<=i;++j) g[k]=(g[k]<<1|a[j])%X;++g[k];
		for(j=1;j<=i;++j) b[j]=a[j];
		for(j=i+1;j<=n;++j) if(b[j]=b[j-i]^1,a[j]^b[j]) {a[j]<b[j]&&--g[k];break;}
	}
	for(i=1;i<=k;++i) for(j=i+1;j<=k;++j) !(f[j]%f[i])&&Inc(g[j],X-g[i]);
	for(i=1;i<=k;++i) t=(2LL*f[i]*g[i]+t)%X,Inc(cnt,g[i]);
	return printf("%d",t),0;
}

Measured memory_bytes: 2180
#include <stdio.h>

int main(void){
  int N,T;
  scanf("%d%d",&N,&T);

  int t[N];
  for(int i = 0;i < N;i++) scanf("%d",&t[i]);

  long ans = T;
  for(int i = 0;i < N-1;i++){
    if(t[i]+T > t[i+1]) ans += t[i+1]-t[i];
    else ans += T;
  }

  printf("%ld\n",ans);
  return 0;
}

Measured memory_bytes: 896
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#define int long long
#define ll getchar();getchar();return 0;
	using namespace std;
	int a[114];
	signed main() {
		int n,cnt=0,ccnt=0;
		cin >> n;
		for (int i = 0; i < n; i++)cin >> a[i];
		sort(a, a + n);
		reverse(a, a + n);
		for (int i = 0; i < n; i += 2)cnt += a[i];
		for (int j = 1; j < n; j += 2)ccnt += a[j];
		cout << cnt - ccnt << endl;
		ll
	}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
n = int(input())
a = [int(i) for i in input().split()]
ans = [a[n-1]]
if n == 1:
  print(a[0])
  if a[0] == 1:
    print(1)
  exit()
  
for i in range(n-2,-1,-1):
  if i+1 > n//2:
    ans.append(a[i])
  else:
    ans.append((sum(ans[n%(i+1)::(i+1)])-a[i])%2)
    
print(sum(ans))
chk = []
for i,ai in enumerate(ans):
  if ai == 1:
    chk.append(n-i)
print(*chk)

Measured memory_bytes: 14108
a,b,c,d,e,f=map(int,input().split())

ans,index=0,[a*100,0]
base=100*e/(100+e)
for i in range(31):
    for j in range(31):
        for k in range(101):
            for l in range(101):
                w=i*100*a+j*100*b
                s=c*k+d*l
                if w==0:continue
                if w+s>f:break
                den=s*100/(w+s)
                if den<=base and ans<den:
                    ans=den
                    index=[w+s,s]

print(*index)

Measured memory_bytes: 41840
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long s,i,j,n,t;
    int ara[200005];
    scanf("%lld",&n);
    s = 0;
    for(i = 0;i < n;i++){
        scanf("%lld",&ara[i]);
    }
    t = ara[0];
    for(i = 0;i < n;i++){
        if(ara[i] <= t){
            s = s + (t - ara[i]);
        }
        else if(ara[i] > t){
            t = ara[i];
        }
    }
    printf("%lld\n",s);
    return 0;
}


Measured memory_bytes: 4576
fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let input: Vec<i32> = s.split_whitespace().map(|x| x.parse::<i32>().unwrap()).collect();
    let ans = if input[0] <= input[1]{ input[0]} else { input[0] -1 };
    println!("{}",ans);
}


Measured memory_bytes: 4352
#include<iostream>
using namespace std;
int main() {
    int n, k; cin >> n >> k;
    if (n % 2 == 0) {
        if (k <= n / 2) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    } else {
        if (k <= n / 2 + 1) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define SP << " " 
#define LLi long long int

using namespace std;

int imax=2147483647;
long long int llimax=9223372036854775807;
LLi mod=1000000007;

//int型vectorを出力
void PV(vector<int> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

//LLi型vectorを出力
void PVL(vector<LLi> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}
 
LLi modinv(LLi a) {
    LLi b = mod, u = 1, v = 0;
    while (b) {
        LLi t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= mod;
    if (u < 0) u += mod;
    return u;
}

int main(){

	int n;
	LLi sq=0, ans=0;
	vector<LLi> v;

	cin>> n;
	v.resize(n);

	rep(i, n){
		cin >> v[i];
		sq+=v[i]*v[i];
		sq=sq%mod;
		ans+=v[i];
	}

	ans=ans%mod;
	ans=ans*ans;
	ans=ans%mod;
	ans=ans+mod-sq;
	ans=ans%mod;
	ans=ans*modinv(2);
	ans=ans%mod;

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

Measured memory_bytes: 4852
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int Max = 1000000;
int permu(int n){
  if(n==0) return 1;
  else return n*permu(n-1);
}

int main(){
    int N;
    cin >> N;
    int point[N][2];
    for(int i=0;i<N;i++){
      cin >> point[i][0] >> point[i][1];
    }

    double sum = 0;
    int times = permu(N-1);

    for(int i=0;i<N-1;i++){
      for(int j=i+1;j<N;j++){
        double l = sqrt((point[i][0]-point[j][0])*(point[i][0]-point[j][0]) 
          + (point[i][1]-point[j][1])*(point[i][1]-point[j][1]));
        sum += 2*times*l;
      }
    }

    cout << fixed << setprecision(8) << sum/permu(N) <<endl;

    
  	return 0;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{  
   float d,t,s;
   float r;
   cin>>d;
   cin>>t;
   cin>>s;
   
   r=d/s;
   
   if(r<=t)
   {
   cout<<"Yes"; 
   }
   else
   cout<<"No";
}

Measured memory_bytes: 3700
def distance(a,b,c,d):
  return abs(a-c)+abs(b-d)

N,M=map(int, input().split())
Alist = []
Blist = []
for i in range(N):
  a,b=map(int, input().split())
  Alist.append(a)
  Blist.append(b)
Clist = []
Dlist = []
for i in range(M):
  c,d=map(int, input().split())
  Clist.append(c)
  Dlist.append(d)

for i in range(N):
  min_d = 10**10
  a = Alist[i]
  b = Blist[i]
  for k in range(M):
    c = Clist[k]
    d = Dlist[k]
    if min_d > distance(a,b,c,d):
      min_d = distance(a,b,c,d)
      kiroku = k
#    print(a,b,c,d,distance(a,b,c,d),min_d)
  print(kiroku+1)

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


int main ()
{

 int a,p;
 
 cin >> a >> p;
 
if(a>=13)
{
	cout << p << endl;
}
else if(a>=6 && a<=12)
{
	cout << p/2 << endl ;
}
else
{
	cout << "0" << endl;
}

	return 0;
}











Measured memory_bytes: 3160
#include "bits/stdc++.h"
#define int long long int
using namespace std;
const int N = 1e6 + 2; 

int32_t main() {
  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);    
    int n;
    cin >> n;
    int a[n];
    int tot = (n * (n - 1) * (n - 2))/6; 
    for(int i = 0 ; i < n ;i++){
      cin >> a[i];
    }    
    sort(a , a + n);
    for(int i = 0 ; i < n ;i++){
      for(int j = i + 1 ; j < n ; j++){
        int sum = a[i] + a[j];
        int hey = lower_bound(a , a + n , sum) - &a[0];
        tot-=(n - hey);
    }
}
cout << tot;


    return 0;
}

Measured memory_bytes: 384
#include <iostream>

#include <vector>
#include <map>
#include <algorithm>
#include <fstream>
#include<cstdio>
#include<iomanip>

#define REP(i, n) for(int i=0;i<n;i++)
#define REP2(i, s, n) for(int i=s;i<n;i++)
#define REP_1(i, n) for(int i=1;i<n+1;i++)
#define bitSearch(bit, n) for(int bit = 0; bit < (1 << N); bit++)
using namespace std;

void printAns(int a) { cout << a << endl; }

void yesno(bool a) { if (a)cout << "Yes" << endl; else cout << "No" << endl; }

void YESNO(bool a) { if (a)cout << "YES" << endl; else cout << "NO" << endl; }

typedef long long ll;
typedef unsigned long ul;
typedef long double ld;

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

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

ll INF = 10000000;
ll mod = 1000000007;//10^9+7


//番号ズレ注意！！
int main() {
    int A,B;
    cin>>A>>B;
    int ans=0;
    chmax(ans,A+A-1);
    chmax(ans,A+B);
    chmax(ans,B+B-1);
    printAns(ans);
}

Measured memory_bytes: 256
S = list(input())
N = len(S) -1 
all_formula = []
result = 0


for i in range(2**N):
    temp = S
    for j in range(N):
        all_formula.append(S[j])
        if i & 2**j:
            all_formula.append("+")
    all_formula.append(S[-1])
    all_formula.append("+")

all_formula.pop(-1)
all_formula = ''.join(all_formula)
result = eval(all_formula)

print(result)



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

 
int main (){
    int N;
    cin >> N;
    vector<int> A(N),a(N),b(N);
    for(int i=1;i<=N;i++)A[i-1]=i;
    for(int &i:a)cin >> i;
    for(int &i:b)cin >> i;
    int loa=-1,lob=-1;
    int count=0;
    do {
        if(a==A)loa=count;
        if(b==A)lob=count;
        if(loa>=0&&lob>=0)break;
        count++;
    } while (next_permutation(A.begin(), A.end()));

    cout << abs(loa-lob) << endl;
    
}


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

const string YES = "POSSIBLE";
const string NO = "IMPOSSIBLE";

auto solve(long long N, long long M, std::vector<long long> a, std::vector<long long> b){
    auto d = vector< vector<int> >(N + 1, vector<int>());
    for(int i = 0; i < M; ++i) {
        d[a[i]].push_back(b[i]);
    }

    queue<tuple<long long, int>> q;
    q.push(make_tuple(1, 0));
    while(!q.empty()) {
        const auto s = get<0>(q.front());
        const auto n = get<1>(q.front());
        q.pop();

        if(s == N) {
            return YES;
        }
        if(n == 2) {
            continue;
        }

        for(const auto dd : d[s]) {
            q.push(make_tuple(dd, n+1));
        }
    }

    return NO;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> a(M);
    std::vector<long long> b(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&a[i]);
        scanf("%lld",&b[i]);
    }
    auto result = solve(N, M, std::move(a), std::move(b));
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 13176
#include <iostream>
#include <numeric>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)




int main() {
	int N;
	cin >>N;
	
	cout << N*N*N<< endl;
}

Measured memory_bytes: 256
def examB():
    N = I()
    D, X = LI()
    A = [I() for _ in range(N)]
    cur = X
    for i in A:
        cur += (D-1)//i + 1
    print(cur)

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()

Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
const ll INF =1LL<<60;

int N;
ll h[100010];

ll dp[100010];

ll rec(int i){
    if(dp[i]<INF) return dp[i];
    if(i==0) return 0;
    ll res = INF;
    chmin(res,rec(i-1)+abs(h[i]-h[i-1]));
    if(i>1) chmin(res,rec(i-2)+abs(h[i]-h[i-2]));

    return dp[i] = res;
}

int main(){
    int N;cin>>N;
    REP(i,N) cin>>h[i];
    REP(i,100010) dp[i] = INF;
    cout<<rec(N-1)<<endl;
}

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

int cmp_double(const void *a, const void *b) {
    return *(double*)a - *(double*)b;
}

int main(void) {
    int n, i;
    scanf("%d", &n);
    double pot[n];

    for (i = 0; i < n; i++) {
        scanf("%lf", &pot[i]);
    }

    qsort(pot, n, sizeof(double), cmp_double);
    
    for (i = 1; i < n; i++) {
        pot[i] = (pot[i]+ pot[i - 1]) / 2;
    }

    printf("%lf\n", pot[n - 1]);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl

typedef long long ll;
using namespace std;

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

ll lcm(ll a, ll b)
{
    return (a*b)/gcd(a, b);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    //no of factors of c in [a, b] = no of factors of c in [1, b] - no of factors of c in [1, a)
    ll factc = b / c - (a - 1) / c;
    ll factd = b / d - (a - 1) / d;
    ll factlcm = b / lcm(c, d) - (a - 1) / lcm(c, d);
    //answer = no between [a, b] - no of factors of c in [a, b] + no of factors of d in [a, b] - no of factors of lcm in [a, b]
    cout << b - a + 1 - factc - factd + factlcm;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.function.*;
import java.math.*;
public class Main {
    public static void main(String[] args){
Scanner s = new Scanner(System.in);
		int N = s.nextInt();
		int W = s.nextInt();
		int[] wei = new int[N];
		int[] val = new int[N];
		for(int i = 0; i < N; i++) {
			wei[i] = s.nextInt();
			val[i] = s.nextInt();
		}
		
		long[][] dp = new long[N + 1][W + 1];
		for(int i = 1; i < N + 1; i++) {
			for(int w = 1; w < W + 1; w++) {
				if(w - wei[i-1] >= 0) {
					dp[i][w] = Math.max(dp[i-1][w - wei[i-1]] + val[i-1], dp[i-1][w]);
				}else {
					dp[i][w] = dp[i-1][w];
				}
			}
		}
		System.out.println(dp[N][W]);
    }
}

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

int main(int argc, char *argv[])
{
	int i;
    int N, T;
	int c, t;
	int min = 1001;
	
	cin >> N >> T;
	for (i = 0; i < N; i++) {
		cin >> c >> t;
		if (t <= T && c < min) 
			min = c;
	}
	if (min == 1001)
		cout << "TLE";
	else
	   	cout << min;

	cout << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define pb push_back
#define sz(x) (int)(x).size()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;


int main() {
  int n; cin >> n;
  vl v(n), vsum(n);
  rep(i, n){
    cin >> v[i];
    if (i==0){
      vsum[i] = v[i];
    }
    else vsum[i] = vsum[i-1] + v[i];
  }
  int c1, c2, c3;
  vl sum(4);
  ll ans = LINF;
  c1 = 0;
  c3 = 2;
  srep(i, 1, n-2){
    c2 = i;
    while (c1<c2 && abs(vsum[c1]*2 - vsum[c2]) > abs(vsum[c1+1]*2 - vsum[c2])){
      c1 ++;
    }
    sum[0] = vsum[c1];
    sum[1] = vsum[c2] - sum[0];
    
    while (c3<n-1 && abs((vsum[c3]-vsum[c2])*2 - (vsum[n-1]-vsum[c2])) > abs((vsum[c3+1]-vsum[c2])*2 - (vsum[n-1]-vsum[c2]))){
      c3 ++;
    }
    sum[2] = vsum[c3]-vsum[c2];
    sum[3] = vsum[n-1] - vsum[c3];
    
    sort(rng(sum));
    ans = min(ans, sum[3]-sum[0]);
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3328
#include <iostream>
using namespace std;
int main(){
  long long int x,y,a,b,n,nmax;
  cin >> x >> y;
  for(a=x;a<=x;a++){
    n=0;
    for(b=a;b<=y;b*=2) n++;
    if(n>nmax) nmax=n;
  }
  cout << nmax << endl;
  return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
const int INF = 1e18;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for(auto &it : t)cout<<it<<" ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 
map<char,int> m;

void solve(){
m['a'] = 0;
m['b'] = 0;
m['c'] = 0;
m['d'] = 0;
m['e'] = 0;
m['f'] = 0;
m['g'] = 0;
m['h'] = 0;
m['i'] = 0;
m['j'] = 0;
m['k'] = 0;
m['l'] = 0;
m['m'] = 0;
m['n'] = 0;
m['o'] = 0;
m['p'] = 0;
m['q'] = 0;
m['r'] = 0;
m['s'] = 0;
m['t'] = 0;
m['u'] = 0;
m['v'] = 0;
m['w'] = 0;
m['x'] = 0;
m['y'] = 0;
m['z'] = 0;
 string s;
 while(getline(cin, s)){
 for(auto it : s){
    if(it >= 'a' && it <= 'z') m[(it)]++; 
    else if (it >= 'A' && it <= 'Z') m[tolower(it)]++;
  }
 }
  for(auto it : m)  
    cout << it.f << " : " << it.s << endl;
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}



Measured memory_bytes: 3228
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <cmath>
#include <tuple>
#include <map>
#include <unordered_map>
using namespace std;
typedef long long ll;

int main(int argc, char *argv[])
{
    ll n, i;
	ll min, tmp;
	cin >> n;
	min = n - 1;

    for (i = 2; i <= sqrt(n); i++) {
		if (n % i == 0) {
			tmp = i + (n / i) - 2;
			if (min > tmp)
				min = tmp;
		}
	}

	cout << min << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 9999999999
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define p(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
//#define int long long


using namespace std;


int dy[4] = { 0,0,1,-1 };
int dx[4] = { 1,-1,0,0 };
int dxx[8] = { 0,0,1,1,1,-1,-1,-1 };
int dyy[8] = { 1,-1,0,1,-1,0,1,-1 };




ll gcd(ll x, ll y) {
	ll m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}

ll myPow(ll x, ll n, ll m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}

ll pow2(ll a, ll n) {//aのn乗を計算します。
	ll x = 1;
	while (n > 0) {//全てのbitが捨てられるまで。
		if (n & 1) {//1番右のbitが1のとき。
			x = x * a;
		}
		a = a * a;
		n >>= 1;//bit全体を右に1つシフトして一番右を捨てる。
	}
	return x;
}

long long nCr(int n, int r) {
	if (r > n / 2) r = n - r; // because C(n, r) == C(n, n - r)
	long long ans = 1;
	int i;

	for (i = 1; i <= r; i++) {
		ans *= n - r + i;
		ans /= i;
	}

	return ans;
}


const int MOD = 1000000007;

bool arr[1050000];
int sosuu[100010];
void Eratosthenes() {
	ll N = 1050000;
	int c = 0;
	for (int i = 0; i < N; i++) {
		arr[i] = 1;
	}
	for (int i = 2; i < sqrt(N); i++) {
		if (arr[i]) {
			for (int j = 0; i * (j + 2) < N; j++) {
				arr[i *(j + 2)] = 0;
			}
		}
	}

	for (int i = 2; i < N; i++) {
		if (arr[i]) {
			sosuu[c] = i;
			//cout << sosuu[c] << " ";
			c++;
		}
	}
	//cout << endl;
	//cout << c << endl;
}


int dp[41][410][410];
int N, Ma, Mb;
int a[50], b[50], c[50];

int inf = 100000;
int main() {
	cin >> N >> Ma >> Mb;
	REP(i, 41) {
		REP(j, 410) {
			REP(k, 410) {
				dp[i][j][k] = inf;
			}
		}
	}
	//p(dp[0][0][0]);
	REP(i, N) {
		cin >> a[i] >> b[i] >> c[i];
	}
	dp[0][0][0] = 0;
	REP(i, N) {
		FOR(ma,	0, 410) {
			FOR(mb,0, 410) {
				if (dp[i][ma][mb] == inf)continue;
				dp[i + 1][ma][mb] = min(dp[i + 1][ma][mb], dp[i][ma][mb]);
				dp[i + 1][ma + a[i]][mb + b[i]] = min(dp[i][ma + a[i]][mb + b[i]], dp[i][ma][mb] + c[i]);
			}
		}
	}
	int ans = inf;
	FOR(mb,1, 10*N+1) {
		FOR(ma,1, 10*N+1) {
			if (ma*Mb == mb * Ma) {
				ans = min(ans, dp[N][ma][mb]);
				//pe(dp[N][ma][mb]);
			}
		}
		//cout << endl;
	}
	if (ans == inf)p(-1) else p(ans);
}

Measured memory_bytes: 27136
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)

using namespace std;

const double EPS = 1e-8;

int sign(double x){
    if(x > EPS) return 1;
    if(x < -EPS) return -1;
    return 0;
}
typedef complex<double> Point;
typedef vector<Point> Polygon;
struct Line : public vector<Point> {
    Line(const Point& a, const Point& b) {
        push_back(a); push_back(b);
    }
    Point vector() const {
        return back() - front();
    }
};
double dot(Point a, Point b){
    return real(conj(a) * b);
}
double cross(Point a, Point b){
    return imag(conj(a) * b);
}
int ccw(Point a, Point b, Point c) {
    b -= a; c -= a;
    if (cross(b, c) > EPS)   return +1; // 反時計回り
    if (cross(b, c) < -EPS)   return -1; // 時計回り
    if (dot(b, c) < 0)     return +2; // c--a--b の順番で一直線上
    if (norm(b) < norm(c)) return -2; // a--b--c の順番で一直線上
    return 0;                         // 点が線分ab上にある
}
Point crosspointLL(Line l, Line m){
    double A = cross(l.vector(), m.vector());
    double B = cross(l.vector(), l[1] - m[0]);
    if(sign(A) == 0 && sign(B) == 0) return m[0]; // 二直線が重なっている
    if(sign(A) == 0) assert(false); // 直線が交わらない
    return m[0] + m.vector() * B / A;
}

inline Point curr(const Polygon& P, int k){ return P[k]; }
inline Point next(const Polygon& P, int k){ return P[(k + 1) % P.size()]; }
Polygon convex_cut(const Polygon& P, Line l){
  Polygon Q;
  REP(i, P.size()){
    Point A = curr(P, i), B = next(P, i);
    if(ccw(l[0], l[1], A) != -1) Q.push_back(A); //Aが直線lの右側でない
    if(ccw(l[0], l[1], A) * ccw(l[0], l[1], B) < 0)
      Q.push_back(crosspointLL(l, Line(A, B)));
  }
  return Q;
}

Point rotate(Point a, double b){
    return a * polar(1.0, b);
}

int main(){
    int N;
    while(cin >> N && N){
        Polygon P;
        REP(i, N){
            double x, y;
            cin >> x >> y;
            P.push_back(Point(x, y));
        }
        double lb = 0, ub = 100000;
        REP(iter, 100){
            double len = (lb + ub) / 2;
            Polygon Q = P;
            REP(i, N){
                Line l(curr(P, i), next(P, i));
                Line l2(l[0] + polar(len, arg(l.vector()) + M_PI/2), l[1] + polar(len, arg(l.vector()) + M_PI/2));
                Q = convex_cut(Q, l2);
            }
            if(Q.empty()){
                ub = len;
            }else{
                lb = len;
            }
        }
        printf("%.12f\n", lb);
    }
    return 0;
}

Measured memory_bytes: 1320
import java.util.*;

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

        Scanner inp = new Scanner(System.in);
        total = inp.nextInt();

        int[] a = new int[total];

        for (int k = 0; k < total; k++) {
            a[k] = inp.nextInt();
        }

        int swapcount = 0;

        for (int i = 0; i < a.length-1; i++) {
            int mini = i;
            for (int j = i; j < a.length; j++) {
                if (a[j] < a[mini]) {
                    mini = j;
                }
            }

            if (i != mini) {
                int temp = a[i];
                a[i] = a[mini];
                a[mini] = temp;

                swapcount++;
            }
        }

        for (int l = 0; l < total; l++) {
            if (l == 0) {
                System.out.printf("%d", a[l]);
            } else {
                System.out.printf(" %d", a[l]);
            }
        }

        System.out.printf("\n" + swapcount+"\n");
    }
}



Measured memory_bytes: 26564
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    int s, w;
    cin >> s >> w;

    cout << (w >= s ? "unsafe" : "safe") << "\n";
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repr(i, s, e) for(int i=s; i>=e; i--)
#define reps(i, s, e) for(int i=s; i<e; i++)
#define inf 1e18
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<ll>())
#define sz(x) x.size()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T &a, T b){ if(a<b){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){ a=b; return true; } return false; }
template<typename T> T gcd(T a, T b){ if(b==0) return a; return gcd(b, a%b); }
template<typename T> T lcm(T a, T b){ return a*b/gcd(a, b); }
template<typename T> T vdebug(vector<T> v){ for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> T adebug(T arr[], int n){ rep(i, n){ cout << arr[i] << " "; } cout << endl; }
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
int keta(ll num){ int k=0; while(num>0){ num/=10; k++; } return k; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};


ll righte[300010], leftw[300010];

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

    int n;
    string s;
    cin >> n >> s;

    rep(i, n-1){
        if(s[i] == 'W'){
            leftw[i+1] = leftw[i] + 1;
        }else{
            leftw[i+1] = leftw[i];
        }
    }

    repr(i, n-1, 1){
        if(s[i] == 'E'){
            righte[i-1] = righte[i] + 1;
        }else{
            righte[i-1] = righte[i];
        }
    }

    ll res = inf;
    rep(i, n){
        res = min(res, leftw[i] + righte[i]);
    }

    cout << res << endl;

    return 0;
}

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

int main() {
	string s[4];
	s[0] = "Sunny";
	s[1] = "Cloudy";
	s[2] = "Rainy";
	s[3] = "Sunny";
	string a;
	cin >> a;
	string ans;

	for (int i = 0; i <= 3; i++)
	{
		if (a == s[i])
		{
			ans = s[i + 1];
			break;
		}
	
	}
	cout << ans << endl;
	return 0;
}


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

int main() {
  string N,A;
  cin >> N;
if(N[0]==N[1]||N[1]==N[2]||N[2]==N[3]){
  cout<<"Bad"<<endl;
}
  else{
    
  cout <<"Good"<<endl;
  }
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

def gcd(a, b):
    x = max(a, b)
    y = min(a, b)
    if x % y == 0:
        return y
    else:
        return gcd(y, x % y)
a, b, k = map(int, readline().split())
g = gcd(a, b)
l = []
for i in range(1, g + 1):
    if g % i == 0:
        l.append(i)
print(l[-k])

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

#ifdef ONLINE_JUDGE
#define lld I64
#endif

#define endl '\n'
#define ii pair<int,int>
#define ll long long
#define vi vector<int>
#define vii vector<ii>
#define vvi vector<vi>
#define add push_back

int main(){ios_base::sync_with_stdio(false);

    int a, b;
    cin >> a >> b;
    cout << a*b << endl;
    
    return 0;
}


Measured memory_bytes: 3636
#include "iostream"
#include "algorithm"
#include "vector"
#include "string"
#include "cmath"
typedef long long ll;
using namespace std;

int main(int argc, char const *argv[]) {
  ll r, D, x_2000;


  std::cin >> r >> D >> x_2000;

  for (ll i = 0; i < 10; i++) {
    x_2000 = r*x_2000 - D;
    std::cout << x_2000 << '\n';
  }



  return 0;
}


Measured memory_bytes: 256