akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef vector<int> vi;

int main() {FIN
	
	int i;
    string s;
    vi let('z' - 'a' + 1);
    while (getline(cin, s)) {
		for (i = 0; i < s.size(); i++) {
			s[i] = ((char)tolower(s[i]));
			if (s[i] >= 'a' and s[i] <= 'z')
				let[s[i] - 'a']++;
		}
	}
    for (i = 0; i < let.size(); i++)
        cout << ((char)(i + 'a')) << " : " << let[i] << "\n";
    
    return 0;
}



Measured memory_bytes: 3184
#include <stdio.h>
int main(){
  char s[7];
  scanf("%s", s);
  if (s[0] == 'S') {
    puts("Cloudy");
  }else if (s[0] == 'C') {
    puts("Rainy");
  } else {
    puts("Sunny");
  }
  return 0;
}


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

int main(){
    vector<ll> a(3);
    rep(i,3) cin>>a[i];
    if(a[0]%2==0 ||a[1]%2==0 ||a[2]%2==0) cout<<0<<"\n";
    else{
        sort(a.begin(),a.end());
        cout<<a[0]*a[1]*(a[2]-a[2]/2)-a[0]*a[1]*(a[2]/2)<<"\n";
    }
    return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for (int i = a; i < (int)b; ++i)
#define rrep(i, n) for (int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

const int N = 1e6 + 5;

class LinearSieve {
    public:
        vector<int> lp, pr;
        LinearSieve() {}
        LinearSieve(int n) {
            lp.resize(n + 1);
            lp[0] = -1, lp[1] = -1;
            init(n);
        }

        void init(int x) {
            FOR (i, 2, x + 1) {
                if (lp[i] == 0) {
                    lp[i] = i;
                    pr.push_back(i);
                }
                for (int j = 0; j < (int)pr.size() && pr[j] <= lp[i] && (ll)i * pr[j] <= x; ++j) {
                    lp[i * pr[j]] = pr[j];
                }
            }
        }

        bool isPrime(int x) { return lp[x] == x; }

        vector<int> factorlist(int x) {
            vector<int> res;
            while (x != 1) {
                res.push_back(lp[x]);
                x /= lp[x];
            }

            return res;
        }

        vector<pair<int, int> > factorize(int x) {
            vector<int> p = factorlist(x);
            if (p.size() == 0) return {};
            vector<pair<int, int> > res(1, make_pair(p[0], 0));
            rep (i, p.size()) {
                if (res.back().first == p[i]) {
                    res.back().second++;
                } else {
                    res.emplace_back(p[i], 1);
                }
            }

            return res;
        }
};

template<typename T>
T modpower(T a, T n, T mod) {
    T res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

template<typename T>
T modinv(T a, T mod) {
    return modpower(a, mod - 2, mod);
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    LinearSieve ls = LinearSieve(N);
    int n;
    cin >> n;
    ll res = 0;
    map<int, int> mp;
    vector<ll> a(n);
    
    rep (i, n) {
        cin >> a[i];
        auto v = ls.factorize(a[i]);
        rep (j, v.size()) {
            mp[v[j].first] = max(mp[v[j].first], v[j].second);
        }
    }
    ll l = 1;
    for (auto p : mp) {
        rep (i, p.second) {
            l *= p.first;
            l %= MOD;
        }
    }
    rep (i, n) {
        ll tmp = l * modinv(a[i], MOD);
        res += tmp;
        res %= MOD;
    }
    cout << res << endl;
    
    return 0;
}



Measured memory_bytes: 4984
package main

import (
	"fmt"
	"math"
)

func main() {
	var s string
	res := ""
	fmt.Scan(&s)
	for pos, r := range s {
		if r != 'B' {
			res += string(r)
		} else if r == 'B' && res != "" {
			res = res[0: int(math.Min(float64(pos - 1), float64(len(res) - 1)))]
		}
	}
	fmt.Println(res)
}

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

#define int long long
#define pb push_back
#define range(v) v.begin(),v.end()
#define mod (int)(1e9 + 7)
#define inf (int)(1e15)
#define N (int)(2e5 + 10)

using namespace std;


auto solve() {
	int n, m, t;
	cin >> n >> m >> t;
	vector<int> a(n), b(m);
	for (int &i : a) cin >> i;
	for (int &i : b) cin >> i;
	int i = 0, j = 0;
	for (; i < n; i++) {
		if (a[i] > t)break;
		t -= a[i];
	}

	for (; j < m; j++) {
		if (b[j] > t) break;
		t -= b[j];
	}

	int cnt = i + j;
	i--;

	for (; i >= 0; i--) {
		t += a[i];
		while (j < m) {
			if (b[j] > t) break;
			t -= b[j++];
		}

		cnt = max(cnt, i + j);
	}

	return cnt;

}

int32_t main() {
	ios_base::sync_with_stdio(false), cin.tie(nullptr), cin.tie(nullptr);
	int t_c = 1;
//	cin >> t_c;
	while (t_c--) {
		auto ans = solve();
		cout << ans << endl;
	}
}

Measured memory_bytes: 6372
#include <bits/stdc++.h>
#pragma gcc optimize("ofast")
using namespace std;

#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define mod 1000000007
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0);
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(ll x=j;x<n;x++)
#define repr(x,j,n)for(ll x=j;x>n;x--)
typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;

ll modexp(ll a,ll b,ll m)
{
	ll r=1;
	a=a%m;
	while(b>0)
	{
	if(b&1)
		r=(r*a)%m;
	b=b/2;
	a=(a*a)%m;
	}
	return r%m;
}

int main()
{
    string s;
    ll ans=0;
    cin>>s;
    ll c=-1;
    ll n=s.length();
    ll i=0;
    ll l=0,r=0;
    while(i<n)
    {
        if(s[i]=='>')r++;
        else
        {
            if(i-1>=0&&s[i-1]=='<')l++;
            else
            {
                ans+=((l*(l-1))/2);
                ans+=((r*(r-1))/2);
                ans+=max(l,r);
                l=1;
                r=0;
            }
        }
        i++;
    }
                ans+=((l*(l-1))/2);
                ans+=((r*(r-1))/2);
                ans+=max(l,r);
                cout<<ans;

    return 0;
}


Measured memory_bytes: 900
# include<iostream>
# include<vector>
using namespace std;
using vector1 = vector<int>;
using vector2 = vector<vector1>;
int last(int d, int j, vector1 t){ //タイプjのコンテストが最後に開催された日を計算
  for(int i=d; i>=1; i--){
    if(t[i] == j) return i;
  }
  return 0;
}
int penalty(vector1 c, int d, vector1 t){
  int m = 0;
  for(int i=1; i<=26; i++){
    m += c[i] * (d - last(d, i, t));
  }
  return m;
}
int main(){
  int D; cin >> D;
  vector1 c(26+1, 0); for(int i=1; i<=26; i++) cin >> c[i]; //ペナルティーc
  vector2 s(D+1, vector1(26+1)); //満足度s
  for(int i=1; i<=D; i++){
    for(int j=1; j<=26; j++){
      cin >> s[i][j];
    }
  }
  vector1 t(D+1, 0); for(int i=1; i<=D; i++) cin >> t[i];

  vector1 v(D+1, 0);
  for(int i=1; i<=D; i++){
    v[i] = s[i][t[i]];
    v[i] -= penalty(c, i, t);
  }

  int sum = 0;
  for(int i=1; i<=D; i++){
    sum += v[i];
    cout << sum <<"\n";
  };
  return 0;
}

Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,a;
    cin >> n;
    a=1;
    for(int i=2;i*i<=n;i++){
        for(int j=i*i;j<=n;j*=i){
            a=max(a,j);
        }
    }
   
    cout << a << endl;
}

Measured memory_bytes: 256
import sys, math
from functools import lru_cache
from collections import deque
sys.setrecursionlimit(500000)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]


def main():
    S = input()
    if len(S) == 2:
        print(S)
    else:
        print(S[::-1])


if __name__ == '__main__':
    main()

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




int main()
{
    string S;
    cin >> S;
    string ans;

    if(S == "ABC") ans = "ARC";
    if(S == "ARC") ans = "ABC";


    cout << ans << endl;

    return 0;
}
//Ctrl+Shift+Bでコンパイルと実行を行ってデバッグすること

Measured memory_bytes: 3600
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define ub upper_bound
#define lb lower_bound
#define bit __builtin_popcount
#define memset(x) memset(x,0,sizeof(x))

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<vector<int>> matrix;

inline void boost(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

const ll maxn=2e5+123;
const ll inf=1e9+123;
const ll linf=1e18+123;
const ll mod=1e9+7;
const double eps=1e-9;
const double pi=acos(-1);
int dx[8]={0,1,-1,0,1,-1,1,-1};
int dy[8]={1,0,0,-1,1,1,-1,-1};

int main(){
    boost();
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ll a,b,c;
    cin>>a>>b>>c;
    if(a+b+1<=c){
        cout<<b+a+b+1;
        return 0;
    }
    cout<<b+c;
	exit(0);
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int b = in.nextInt();
		in.close();
      	int ans = a > b ? a * 2 - 1
          		: a < b ? b * 2 - 1
                : a + b;
      	System.out.println(ans);
	}
}


Measured memory_bytes: 23764
from collections import defaultdict
n = int(input())
v = list(map(int, input().split()))
d1 = defaultdict(int)
d2 = defaultdict(int)
for i in range(0, n, 2):
  d1[v[i]]+=1
  d2[v[i+1]]+=1
l1 = list(d1.items())
l2 = list(d2.items())
l1.sort(key=lambda x: -x[1])
l2.sort(key=lambda x: -x[1])
t1 = l1[0][1]
t2 = l2[0][1]
t3 = l1[1][1] if len(l1)>1 else 0
t4 = l2[1][1] if len(l2)>1 else 0
if l1[0][0]==l2[0][0]:
  ans = min(n-t1-t4, n-t2-t3)
else:
  ans = n-t1-t2
print(ans)

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

using namespace std;

typedef long long ll;
#define fi first
#define se second
#define pb push_back

const int N = 55, M = 22;
set <int> st[M];
vector <pair <int, int> > v[N];
vector <int> path;
int a[N], b[N], n, m, rstrct, u1[M], u2[M];

void dfs(int x, int par) {
	if (x == u2[rstrct]) {
		for (int y : path) {
			st[rstrct].insert(y);
		}
		return;
	}
	for (auto y : v[x]) {
		if (y.fi != par) {
			path.pb(y.se);
			dfs(y.fi, x);
			path.pop_back();
		}
	}
}

bool vis[N];

ll rec(int x, int mask) {
	if (x == m) {
		memset(vis, 0, sizeof vis);
		int cnt = __builtin_popcount(mask), tot = n - 1;
		for (int i = 0; i < m; i++) {
			if ((1 << i) & mask) {
				for (int j : st[i]) {
					if (!vis[j]) {
						vis[j] = true;
						tot--;
					}
				}
			}
		}
		return (1LL << tot) * ((cnt & 1) ? -1 : 1);
	}
	return rec(x + 1, mask) + rec(x + 1, mask | (1 << x));
}

int main() {
    //ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    scanf("%d", &n);
    for (int i = 1; i < n; i++) {
		scanf("%d %d\n", &a[i], &b[i]);
		v[a[i]].pb({b[i], i});
		v[b[i]].pb({a[i], i});
	}
	scanf("%d", &m);
	for (int i = 0; i < m; i++) {
		scanf("%d %d", &u1[i], &u2[i]);
		rstrct = i;
		dfs(u1[i], u1[i]);
		path.clear();
	}
	printf("%lld", rec(0, 0));
    return 0;
}


Measured memory_bytes: 3816
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N,M,A,B,count=0;
  cin >> N >> M;
  vector<int> height(N);
  vector<int> way(N,0);
  for(int i=0;i<N;i++) {
    cin >> height[i];
  }
  for(int i=0;i<M;i++) {
    cin >> A >> B;
    if(height[A-1]<=height[B-1]) way[A-1]++;
    if(height[B-1]<=height[A-1]) way[B-1]++;
  }
  for(int i=0;i<N;i++){
    if(way[i]==0) count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 4052
#include <iostream>
#include <string.h>
#include <algorithm>
#include <cstring>
#include <math.h>
#define ll long long
ll gcd(ll a,ll b){
    ll s=1,c;
    while(a&&b){
        if((~a&1)&&(~b&1))
            a>>=1,b>>=1,s<<=1;
        else if(~a&1)a>>=1;
        else if(~b&1)b>>=1;
        else if(a>b)a=a-b;
        else c=b-a,b=a,a=c;
    }
    if(!a)return b*s;
    if(!b)return a*s;
}
using namespace std;
int main(){
	int n;
	int ans=0;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
		ans=ans^a[i];
	}
	for(int i=0;i<n;i++){
		int cnt=ans^a[i];
		cout<<cnt<<' ';
	}
}


Measured memory_bytes: 4328
n = int(input())
a = list(map(int, input().split()))

for i in range(n):
    a[i] -= i + 1

a.sort()

b = a[n//2]

print(b * (n//2) - sum(a[:n//2]) + sum(a[n//2:]) - b * (n - n//2))

Measured memory_bytes: 104440
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+7;

int main()
{
	string s;
	cin>>s;
	char c='S';
	int len=0,ans=0;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='R')len++;
		else len=0;
		ans=max(ans,len);
	}
	printf("%d\n",ans);
}


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

public class Test
{
    
	public static void Main()
	{
        int n = int.Parse(Console.ReadLine());
        long ans = 1;
        long divide = 1000000007;
        for(int i = 1; i <= n ; i++){
            ans = i * ans % divide;
        }
        Console.WriteLine(ans);
    }                                                                                                                                   
}

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

int main(){
    string s,p;
    cin >> s >> p;
    s+=s;
    for(int i=0;i<s.size()-p.size();i++){
        if(s.substr(i,p.size())==p){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3192
#include <iostream>

using namespace std;

int main(void) {
    int64_t N;
    cin >> N;

    int64_t ans = 0;
    int64_t mn = 1, mx;
    for(int64_t j=1; j*j<N; j++) {
        mn = N/(j+1);
        mx = N/j;
        ans += (mx*(mx+1)/2 - mn*(mn+1)/2) * (j*(j+1)/2);
    }

    for(int64_t i=1; i<=mn; i++) {
        int64_t j = N/i;
        ans += i*j*(j+1)/2;
    }

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


Measured memory_bytes: 3604
unittest
{
	assert( [ "?ABC" ].solve == 4 );		// 追加ケース
	assert( [ "ABC?" ].solve == 4 );		// 追加ケース
	
	assert( [ "A??C" ].solve == 8 );
	assert( [ "ABCBC" ].solve == 3 );
	assert( [ "????C?????B??????A???????" ].solve == 979596887 );
}



import std.conv;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto s = input.front.to!( dchar[] );
	
	// dp[ i文字目 ][ ABCのうちj文字一致した ] = パターン数
	const M = 10L ^^ 9 + 7;
	auto dp = new ModWorld!M[][]( 1 + s.length, 3 );
	auto q = ModWorld!M( 1L );
	foreach( i, c; s )
	{
		dp[ i + 1 ][ 0 ] = dp[ i ][ 0 ];
		dp[ i + 1 ][ 1 ] = dp[ i ][ 1 ];
		dp[ i + 1 ][ 2 ] = dp[ i ][ 2 ];
		
		// ?の場合、ここまでの全パターンが3倍になる
		if( c == '?' )
		{
			dp[ i + 1 ][ 0 ] *= 3;
			dp[ i + 1 ][ 1 ] *= 3;
			dp[ i + 1 ][ 2 ] *= 3;
		}
		
		// 文字がABCと一致しているか判定
		if( c == 'A' || c == '?' ) dp[ i + 1 ][ 0 ] += q;
		if( c == 'B' || c == '?' ) dp[ i + 1 ][ 1 ] += dp[ i ][ 0 ];
		if( c == 'C' || c == '?' ) dp[ i + 1 ][ 2 ] += dp[ i ][ 1 ];
		
		// ?の場合、ここからの全パターンが3倍になる
		if( c == '?' ) q *= 3;
	}
	return dp[ $ - 1 ][ $ - 1 ];
}

// モジュラ整数型（n mod M）
struct ModWorld( long M )
{
	long n;
	
	void opUnary( string OP )() if( OP == "++" ){ this.n = ( this.n + 1 ) % M; }
	void opUnary( string OP )() if( OP == "--" ){ this.n = ( this.n + M - 1 ) % M; }
	void opOpAssign( string OP )( ModWorld r ) if( OP == "+"  ){ this.n = ( this.n + r.n ) % M; }
	void opOpAssign( string OP )( ModWorld r ) if( OP == "-"  ){ this.n = ( this.n + M - r.n ) % M; }
	void opOpAssign( string OP )( ModWorld r ) if( OP == "*"  ){ this.n = ( this.n * r.n ) % M; }
	void opOpAssign( string OP )( ModWorld r ) if( OP == "/"  ){ this *= r ^^ ModWorld( M - 2 ); }
	void opOpAssign( string OP )( ModWorld r ) if( OP == "^^" )
	{
		auto a = this.n;
		this.n = 1L;
		for( auto i = r.n; 0 < i; i >>= 1 )
		{
			if( i & 1 ) this.n = ( this.n * a ) % M;
			a = ( a * a ) % M;
		}
	}
	auto opBinary( string OP )( ModWorld r ){ auto l = this; l.opOpAssign!OP( r ); return l; }
	
	void opAssign( long r ){ this.n = r; }
	void opOpAssign( string OP )( long r ){ this.opOpAssign!OP( ModWorld( r ) ); }
	auto opBinary( string OP )( long r ){ return this.opBinary!OP( ModWorld( r ) ); }
	auto opBinaryRight( string OP )( long l ){ return ModWorld( l ).opBinary!OP( this ); }
	auto opEquals( long r ){ return this.n == r; }
	
	auto toString(){ return this.n.to!string; }
}


Measured memory_bytes: 8296
package main

import (
	"fmt"
)

func findSumOfDigits(n int) int {
	sum := 0
	for n > 0 {
		sum += n % 10
		n /= 10
	}
	return sum
}

func main() {
	var n int
	fmt.Scan(&n)

	result := "No"
	if n%findSumOfDigits(n) == 0 {
		result = "Yes"
	}
	fmt.Println(result)
}


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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int nxt = 1, ans = 0;
    rep(i,n) {
        if (nxt == a[i]) {
            ++nxt;
        } else {
            ++ans;
        }
    }
    if (ans == n) ans = -1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
// @ts-check

read(function(err, input) {
  var args = input.split(' ');
  var a = Number(args[0]);
  var b = Number(args[1]);

  var k = harmony(a, b);
  if (Number.isNaN(k)) {
    console.log('IMPOSSIBLE');
  } else {
    console.log(k);
  }
});

/**
 * @param {(err: Error | null, input?: string) => void} callback
 */
function read (callback) {
  var input = '';
  process.stdin.setEncoding('utf8');
  process.stdin.on('readable', () => {
    /** @type {string | Buffer} */
    var chunk;
    while ((chunk = process.stdin.read()) !== null) {
      input += chunk;
    }
  });

  process.stdin.on('end', () => {
    callback(null, input);
  });
  process.stdin.on('error', () => {
    var error = new Error('Failed to read from stdin');
    callback(error);
  });
}

/**
 * @param {number} a
 * @param {number} b
 * @returns {number}
 */
function harmony(a, b) {
  var s = (a + b);
  if (s % 2 === 0) {
    var k = s / 2;
    return k;
  } else {
    return NaN;
  }
}


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

using namespace std;

int main(){
  vector<string> s(3);
  string t;
  for(int i=0;i<3;i++){
    cin>>s[i];
    char x=s[i][0];
    int y=x-'a';
    x=y+'A';
    t+=x;
  }
  cout<<t<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>

using namespace std ;

int main(void){
    long long int K;
    int ans=0,num=0;
    string S;
    bool flag = false;
    
    cin >> S >> K;
    
    // K文字目まで1があれば1
    for(int i=0; i<K; i++){
        if(S[i] != '1') {
            flag = true;
            // cout << i << endl;
            break;
        }
    }

    // cout << S[1] - '0' << endl; //文字to数値 変換
    if(!flag){
        ans=1;
    } else {
        // そうでなければ初めて出現する2以上の数字
        for(int i=0; i<100; i++){
            if( S[i] - '0' > 1){
                ans = S[i] - '0';
                break;
            }
        }
    }
  
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

int main() {
	int a,b,t;
	cin>>a>>b>>t;
	cout<<t/a*b<<endl;
	return 0;

}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL;
LL C(LL n,LL m)
{
    LL sum=1;
    for(LL i=1;i<=m;i++)
        sum=sum*(n+1-i)/i;
    return sum;
}
LL foo[56];
int cmp(LL a,LL b)
{
    return a>b;
}
int main()
{
    LL n,a,b;
    cin>>n>>a>>b;
    for(int i=0;i<n;i++)
        cin>>foo[i];
    sort(foo,foo+n,cmp);
    LL goo=0;
    LL koo=0;
    LL soo=0;
    for(LL i=0;i<a;i++)
    {
        soo+=foo[i];
    }
    for(LL i=0;i<n;i++)
    {
        if(foo[i]==foo[a-1])
        {
            goo++;
            if(i<a)
                koo++;
        }
    }
    LL sum=0;
    if(koo==a)
    {
        for(int i=a;i<=b;i++)
        {
            sum+=C(goo,i);
        }
    }
    else
    {
        sum+=C(goo,koo);
    }
    cout<<fixed<<setprecision(15)<<(double)soo/a<<endl;
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,mod=1000000007;
const long long llinf=9223372036854775807ll;
int a,b; 
int main(){
	cin>>a>>b;
	b+=a*3;
	cout<<b/2;
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    import bisect
    
    mod=10**9+7
    N=I()
    L=LI()
    L.sort()
    ans=0
    for i in range(N):
        for j in range(i+1,N):
            a=L[i]
            b=L[j]
            ab=a+b
            num=bisect.bisect_left(L,ab)
            
            # print(i,j,num-j)
            ans+=num-j-1
            
                
    print(ans)
    

main()


Measured memory_bytes: 74304
#include "bits/stdc++.h"

using namespace std;

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

    size_t N;
    cin >> N;

    vector<int> l(N);
    for (auto &elem : l) {
        cin >> elem;
    }

    sort(l.begin(), l.end());

    int64_t res = 0;
    for (int mid = 0; mid < N; ++mid) {
        for (int low = mid - 1; low >= 0; --low) {
            auto it = lower_bound(l.begin(), l.end(), l[mid] + l[low]);
            int64_t ng = distance(it, l.end());
            res += (N - 1 - mid) - ng;
        }
    }

    cout << res << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vv vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define INF 100000000000
#define eps 1e-7
#define mod 1000000007
#define int ll
using namespace std;
int N;
int A[20];
int B[20];
int C[20];
int btotal = 0;
int ctotal = 0;


signed main(void) {

    cin >> N;
    rep(i,N){
        cin >> A[i];
    }
    rep(i,N){
        cin >> B[i];
        btotal += B[i];
    }

    rep(i,N-1){
        cin >> C[i];
    }

    rep(i,N-1){
        int a = A[i];
        int b = A[i+1];
        if(a+1==b){
            ctotal+=C[A[i]-1];
        }
    }

    cout << ctotal+btotal << endl;

    return 0;
}


Measured memory_bytes: 256
N = int(input())
p = list(map(float, input().split()))
dp = [[0] * (N+1) for i in range(N+1)]
dp[0][0] = 1
for i in range(1,N+1):
    dp[i][0] = dp[i-1][0] * (1-p[i-1])
    for j in range(1,i+1):
        dp[i][j] = dp[i-1][j] * (1-p[i-1]) + dp[i-1][j-1] * p[i-1]
print(sum(dp[N][(N//2+1):(N+1)]))

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

int main()
{
    int n;
    cin >> n;
    vector <int> p(n);
    int count=0;
    rep(i,n) cin>>p[i];
    for(int i=n-1;i>=1;i--){
        if(p[i]<p[i-1]){
            p[i-1]--;
        }
    }
    for(int i=1;i<n;i++){
        if(p[i]<p[i-1]){
            count=1;
        }
    }
    if(count==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

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

    vector<string> s(n);
    vector<int> t(n);
    rep(i,n) cin >>s[i] >>t[i];

    int ss = 0, idx = 0;
    int succ = 0, total = 0;
    int miss = 0;
    while(ss<n)
    {
        cout << "? " << s[ss] << '\n';
        fflush(stdout);

        char c;
        cin >>c;

        char f = s[ss][idx];
        if('A'<=f && f<='Z') f = f-'A'+'a';

        ++total;
        if(f == c)
        {
            s[ss][idx] = '_';

            ++succ;
            ++idx;
        }
        else ++miss;

        if(idx==s[ss].size() || miss>t[ss])
        {
            if(miss>t[ss]) --h;

            ++ss;
            idx = 0;
            miss = 0;
        }

        if(h==0) break;
    }

    if(h>0)
    {
        int R = 1000*succ/total;
        printf("! Game Clear %d.%d\n", R/10, R%10);
        fflush(stdout);
    }
    else
    {
        printf("! Game Over\n");
        fflush(stdout);
    }
    return 0;
}

Measured memory_bytes: 3340
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const ll mod = 1000000007;
const ll INF = 1001001001;
const ll LINF = 1001001001001001001;

void prvec(vector<ll> vec){ //for debug
    ll n = vec.size();
    cout << "------------------------------------\n" ;
    rep(i,n) cout << i << " " << vec.at(i) << "\n";
    cout << "------------------------------------\n" ;
}

void pr2d(vector<vector<ll>> vec){ // for debug
    ll h = vec.size();
    ll w = vec.at(0).size();
    cout << "------------------------------------\n" ;
    rep(i,h){
        rep(j,w){
            cout << vec.at(i).at(j) << " ";
        }
        cout << "\n";
    }
    cout << "------------------------------------\n" ;
}

ll n;
vector<vector<ll>> hen,dp;

ll f(ll num, ll col, ll prev = -1){
    if(dp[num][col]!=-1) return dp[num][col];
    ll ret = 1;
    if(col == 0){ //col==black
        for(auto i:hen[num]){
            if(i==prev) continue;
            ret = (ret*f(i,1,num)%mod);            
        }
    }else{ //col==1==white
        for(auto i:hen[num]){
            if(i==prev) continue;
            ret = (ret*((f(i,0,num)+f(i,1,num))%mod)%mod);            
        }
    }
    dp[num][col] = ret;
    return ret;
}


int main(){
    cin >> n;
    hen.resize(n,vector<ll>(0));
    dp.resize(n,vector<ll>(2,-1));
    rep(i,n-1){
        ll x,y; cin >> x >> y;
        x--; y--;
        hen.at(x).emplace_back(y);
        hen.at(y).emplace_back(x);
    }
    cout << (f(0,0) + f(0,1))%mod << endl;
    return 0;
}

Measured memory_bytes: 19584
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
#define MOD 1000000007
ll powll(ll a,ll b){ll r=1;rep(i,b){r*=a;}return r;}
#define swap(a,b) do{ll w=(a);(a)=(b);(b)=w;}while(0)
#define swapd(a,b) do{double w=(a);(a)=(b);(b)=w}while(0)

//your code here!
ll boolPRI(ll x){
    if(x==2) return 1;
    if(x%2==0) return 0;
    for(ll i=3; i<=sqrt(x); i+=2){
        if(x%i==0) return 0;
    }
    return 1;
}
/*int main(void){
    ll A, B, ans=1;
    scanf("%lld %lld", &A, &B);
    if(min(A,B)!=1 && boolPRI(min(A,B))){
        if(max(A,B)%min(A,B) ==0 ) puts("2");
        else puts("1");
        return 0;
    }
    double end = sqrt(A)+1;
    for(ll i=2; i<=end; i++){
        if(A%i==0 && B%i==0 && boolPRI(i)) ans++;
    }
    printf("%lld\n", ans);
    return 0;
}*/

ll gcd(ll A, ll B){
    ll w, gcd=A, b=B;
    if(gcd<b) swap(gcd, b);
    while(b){
        w=gcd%b;
        gcd=b;
        b=w;
    }
    return gcd;
}

int main(void){
    ll A, B, ans=1;
    scanf("%lld %lld", &A, &B);
    ll g = gcd(A, B), i=2;
    while(g>=i*i){
        if(g%i==0){
            ans++;
            while(g%i==0) g /= i;
        }
        i++;
    }
    printf("%lld\n", ans + (g>1));
}


Measured memory_bytes: 128
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

fn gcd(a: u64, b: u64) -> u64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}

fn main() {
    input!{
        n: usize,
        aa: [u64; n],
    };
    let mut a = aa[0];
    for b in &aa[1..] {
        a = gcd(a, *b);
    }
    println!("{}", a);
}


Measured memory_bytes: 6396
#include <iostream>
#include<algorithm>
using namespace std;
static const int MAX = 1000;
static const int VMAX = 10000;

int n,A[MAX], s;
int B[MAX], T[VMAX+1];

int solve(){
	int ans = 0;
	
	bool V[MAX];
	for(int i=0; i<n; i++){
		B[i] = A[i];
		V[i] = false;
	}
	sort(B, B+n);
	for(int i = 0; i<n; i++) T[B[i]] = i;
	for(int i = 0; i<n; i++){
		if( V[i] ) continue;
		int cur = i;
		int S = 0;
		int m = VMAX;
		int an = 0;
		while( 1 ){
			V[cur] = true;
			an++;
			int v = A[cur];
			m = min(m,v);
			S += v;
			cur = T[v];
			if ( V[cur] ) break;
		}
		ans += min(S + (an - 2)* m, m+S+(an+1)*s);
	}
	return ans;
}


int main(){
	cin >> n;
	s = VMAX;
	for(int i=0; i<n; i++){
		cin >> A[i];
		s = min(s, A[i]);
	}
	int ans = solve();
	cout << ans << endl;
	
	return 0;
}





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

ll gcd(ll x,ll y) {return y ? gcd(y,x%y) : x;} 
ll lcm(ll x,ll y) {return x/gcd(x,y)*y;}


int main(){
    ll n,k;
    cin >> n >> k;
    vector<ll> a(n);
    vector<ll> b(n,0);
    rep(i,n){
        cin >> a[i];
        a[i]--;
    }
    ll now=0,cnt=1;
    while(1){
        if(k==0){
            cout << now+1 << endl;
            return 0;
        }
        if(b[now]) break;
        b[now]=cnt;
        now=a[now];
        cnt++;
        k--;
    }
    
    cnt=cnt-b[now];
    k=k%cnt;
    
    for(ll i=0;i<k;i++){
        now=a[now];
    }
    
    cout << now+1 << endl;

    return 0;
}











Measured memory_bytes: 6432
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"
//#include <intrin.h>  //AtCoder (gcc) 上ではこれがあると動かない。__popcnt用のincludeファイル。
using namespace std;
using Graph = vector<vector<int>>;

typedef long long ll;
typedef long double ld;


#define int long long
#define rep(i, n) for(long long i = 0; i < (n); i++)
#define sqrt(d) pow((long double) (d), 0.50)

const int INF = 2e9;
const ll large_P = 1e9 + 7;



//繰り返し2乗法
//N^aの、Mで割った余りを求める。
ll my_pow(ll N, ll a, ll M) {
	ll tempo;
	if (a == 0) {
		return 1;
	}
	else {
		if (a % 2 == 0) {
			tempo = my_pow(N, a / 2, M);
			return (tempo * tempo) % M;
		}
		else {
			tempo = my_pow(N, a - 1, M);
			return (tempo * N) % M;
		}
	}
}



//N_C_a を M で割った余り
ll my_combination(ll N, ll a, ll M) {
	ll answer = 1;

	rep(i, a) {
		answer *= (N - i);
		answer %= M;
	}

	rep(i, a) {
		answer *= my_pow(i + 1, M - 2, M);
		answer %= M;
	}

	return answer;
}



ll my_gcd(ll& a, ll& b) {
	if (b == 0) return a;
	ll temp = a % b;
	return my_gcd(b, temp);
}



// long long型 n を、base 進法での、i 桁目の数が入った vector にする。
void ll_to_vector(ll base, ll n, vector<ll>& v) {
	ll tempo = n;

	ll n_digit = floor(log10(n) / log10(base)) + 1;
	v.assign(n_digit, 0);

	//ll n_digit = v.size();

	for (ll i = 0; i < n_digit; i++) {
		v.at(i) = tempo / pow(base, n_digit - 1 - i);
		tempo -= v.at(i) * pow(base, n_digit - 1 - i);
	}
}



int char_to_int(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2; case '3': return 3; case '4': return 4;
	case '5': return 5; case '6': return 6; case '7': return 7; case '8': return 8; case '9': return 9;
	default: return 0;
	}
}


//エラトステネスの篩で、prime で ないところに false を入れる。
//true で初期化された vector を代入する必要がある。
void prime_judge(vector<bool>& prime_or_not) {

	prime_or_not.at(0) = false;
	prime_or_not.at(1) = false;

	ll n = prime_or_not.size() - 1;
	ll region = sqrt(n) + 1;

	for (ll i = 2; i <= n / 2; i++) {
		prime_or_not.at(2 * i) = false;
	}


	for (ll i2 = 1; i2 < n / 2; i2++) {
		ll i = 2 * i2 + 1;  //ここからは奇数のみ探索
		if (i < region && prime_or_not.at(i)) {
			ll j = i * i;
			while (j < n + 1) {
				prime_or_not.at(j) = false;
				j += 2 * i;
			}
		}
	}
};



map<int, int> divide_to_prime(int target) {
	map<int, int> res;

	//sqrt(target) まで調べる。
	int upper_lim = ceil(sqrt(target));
	vector<bool> prime_or_not(upper_lim + 1, true);

	if (upper_lim < 20) prime_or_not.assign(25, true);
	prime_judge(prime_or_not);

	int tempo = target;
	rep(i, upper_lim + 1) {
		if (prime_or_not.at(i)) {
			while (tempo % i == 0) {
				tempo /= i;
				res[i]++;
			}
		}
	}

	if (tempo != 1) res[tempo]++; //sqrt(target) より大きな素因数は高々1つしかない。



	return res;
}





signed main() {
	int N, M;
	cin >> N >> M;

	vector<int> A(N);
	rep(i, N) cin >> A.at(i);

	//sort(A.begin(), A.end());
	priority_queue<int, vector<int>, less<int>> que;

	int res = 0;

	rep(i, N) {
		que.push(A.at(i));
		res += A.at(i);
	}


	rep(i, M) {
		int temp = que.top(); que.pop();
		if (temp == 0) break;

		res -= temp;
		temp /= 2;
		res += temp;

		que.push(temp);
	}


	cout << res << endl;
}

Measured memory_bytes: 2168
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


class Main {
    public static void main(String[] args) throws IOException {
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); 
    	
      	int n = Integer.parseInt(br.readLine());
      	String a[] = br.readLine().split(" ");
      	StringBuilder sb = new StringBuilder();
       	for(int i = n - 1; i >= 0; i--) {
        	sb.append(a[i] + " ");
        }
      
      	String result = sb.toString().trim();
      	System.out.println(result);

    }
}


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

#define REP(i,init, n) for(lli i=init;i<n;i++)
#define REPE(i,init, n) for(lli i=init;i<=n;i++)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

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

lli parent[100001]; // parent[i]: i が含まれる木の根の番号
lli depth[100001];  // depth[i] : i は自身が含まれる木のどれくらいの深さにいるか(最低1)
                 //            ただし、根の depth のみが参照される



void init(lli n) {
    REPE(i, 1, n) {
        parent[i] = i;
        depth[i] = 1;
    }
}

lli find(lli x) {
    if (parent[x] == x)
        return x;
    else
        return parent[x] = find(parent[x]);
}

void unite(lli x, lli y) {
    lli x_root = find(x);
    lli y_root = find(y);
    if (x_root == y_root)
        return;

    if (depth[x_root] < depth[y_root]) {
        parent[x_root] = y_root;
    }
    else {
        parent[y_root] = x_root;
        if (depth[x_root] == depth[y_root])
            depth[x_root]++;
    }
}

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

int main() {
    int n, m;
    cin >> n >> m;
    init(n);

    int p[n+1];
    REP(i, 0, n) {
        cin >> p[i+1];
    }
    REP(i, 0, m) {
        int x, y;
        cin >> x >> y;
        unite(x, y);
    }

    // p[i] は、p[i]番目になりたい。
    // p[i]はi番目だということがわかっている。
    // iの根とp[i]の根が同じであれば、p[i]はp[i]番目になれる。
    lli ans = 0;
    REPE(i, 1, n) {
        //cout << "i   : " << i << endl;
        //cout << "p[i]: " << p[i] << endl;
        //cout << "find(i): " << find(i) << endl;
        //cout << "find(p[i]): " << find(p[i]) << endl;

        if (same(p[i], i)) {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 2176
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
 
using namespace std;
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define SWAP(a,b) (a += b,b = a - b,a -= b)
#define ll long long

const int MOD = 1e9 + 7;

int main() {
    int a, b, n;
    cin >> n;

    cout << n * 800 - (n / 15) * 200 << endl;

}

Measured memory_bytes: 768
#coding: utf-8

h,w = map(int,raw_input().split())

a = []

for i in range(h): a.append(raw_input())

flags = [True] * (h+w)

for i in range(h):
    for j in range(w):
        if a[i][j] == "#":
            flags[i] = False
            flags[h+j] = False

i = 0
while True:
    if i>h-1: break
    if flags[i]:
        del a[i]
        del flags[i]
        h -= 1
        i -= 1
    i += 1

i = 0
while True:
    if i>w-1: break
    if flags[h+i]:
        w -= 1
        del flags[h+i]
        for j in range(h):
            a[j] = a[j][:i] + a[j][i+1:]
        i -= 1
    i += 1

for i in range(h):
    print a[i]



Measured memory_bytes: 2696
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
bool z=true;
int main(void){
	string s; cin>>s;
	for(int i=0;i<s.size();i++){
		if(s[i]!=s[s.size()-1-i]) z=false;
	}
	for(int i=0;i<(s.size()-1)/2;i++){
		if(s[i]!=s[(s.size()-1)/2-1-i]) z=false;
	}
	for(int i=(s.size()+1)/2;i<s.size();i++){
		if(s[i]!=s[s.size()-i+(s.size()+1)/2-1]) z=false;
	}
	if(z){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"
#define fcout cout << fixed << setprecision(18)

#define MOD 1000000007 // 1e9+7
#define PI 3.1415926535
/*
3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
*/
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1
#define LINF 1000000000000000001 // 1e18+1

int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
//---------------------------
int n,ma,mb,i,j,k;
int a[50],b[50],c[50];
ll dp[500][500];

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  cin>>n>>ma>>mb;
  REP(i,n){
    cin>>a[i]>>b[i]>>c[i];
  }
  for(i=0;i<500;i++){
    for(j=0;j<500;j++){
      dp[i][j]=INF;
    }
  }
  dp[0][0]=0;
  for(i=0;i<n;i++){
    for(j=450;j>=0;j--){
      for(k=450;k>=0;k--){
        if(j+a[i]>=400 || k+b[i]>=400)continue;
        dp[j+a[i]][k+b[i]]=min(dp[j+a[i]][k+b[i]], dp[j][k] + c[i]);
      }
    }
  }
  ll ans=INF;
  int ca=ma, cb=mb;
  while(ca < 450 && cb < 450){
    ans=min(ans, dp[ca][cb]);
    ca+=ma;
    cb+=mb;
  }
  if(ans>=INF)ans=-1;
  P(ans);
  return 0;
}


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

#define ll long long
#define INF 99999999
#define INF_LL 1LL << 60
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n); i >= 0; i--)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define RREP(i, a, n) for(int i = (int)(n); i >= a; i--)
#define all(x) (x).begin(),(x).end()

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

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

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

    int key = N%10;
    if( key == 3 ) cout << "bon" << endl;
    else if( key == 0 || key == 1 || key == 6 || key == 8 ) cout << "pon" << endl;
    else cout << "hon" << endl;
}


Measured memory_bytes: 3444
<?php
    fscanf(STDIN, '%d %d', $dot_num, $dim_num);

	for($i = 0; $i < $dot_num; $i++){
		$input_line = rtrim(fgets(STDIN));
      $dots[] = explode(' ', $input_line);
    }

    $cnt = 0;
	for($i = 0; $i < $dot_num; $i++){
      for($j = $i + 1; $j < $dot_num; $j++){
        if(distZ($dots[$i], $dots[$j])){
            $cnt++;
        }
      }
    }
	echo $cnt;


    function distZ($x, $y){
        $pdt = 0;
        foreach($x as $key => $value){
            $pdt += ($value - $y[$key]) ** 2;
        }
        $sqrt = $pdt ** (1/2);
        if($sqrt - (int)$sqrt == 0){
            return true;
        }else{
            return false;
        }
    }

Measured memory_bytes: 4728
#include<bits/stdc++.h>
using namespace std;
const int N = 1010;
long long ans1[N], ans2[N], n, t[N], a[N];

int main()
{
	scanf("%lld", &n);
	for (int i = 0; i < n; i++)
		scanf("%lld%lld", &t[i], &a[i]);
	ans1[0] = t[0];
	ans2[0] = a[0];
	for (int i = 1; i < n; i++)
	{
		long long x = max((ans1[i - 1] - 1) / t[i], (ans2[i - 1] - 1) / a[i]) + 1;
		ans1[i] = x * t[i];
		ans2[i] = x * a[i];
	}
	printf("%lld\n", ans1[n - 1] + ans2[n - 1]);
	return 0;
}

Measured memory_bytes: 256
n,k = map(int,input().split())
if k > n*(n-1)//2-n+1:
    print(-1)
else:
    ans = []
    for i in range(1,n):
        ans.append((i,n));
    now = 1
    nxt = 2
    cnt = n*(n-1)//2-n+1-k
    for _ in range(cnt):
        ans.append((now,nxt))
        nxt += 1
        if nxt == n:
            now += 1
            nxt = now + 1
    print(len(ans))
    for i,j in ans:
        print(i,j)


Measured memory_bytes: 3956
n,y = map(int,input().split())
y+=10000
a=-1
b=0

for i in range(y//10000+1):
	b = 0
	a += 1
	y -= 10000
	for j in range(y//5000+1):
		y -=j*5000
		if y==1000*(n-a-b) and n-a-b>-1:
			print(a,b,n-a-b)
			break
		b +=1
		y +=j*5000
		
	else:
		continue
	break
else:
	print(-1,-1,-1)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
 
int main() {
  int a,b;
  cin >> a >> b;
  
  if(b==1){
    cout << 0 << endl;
    return 0;
  }
  
  int n=1;
  
  while(a*n-n+1<b){
    n+=1;
  }
  
  cout << n << endl;

}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.util.StringTokenizer;

public class Main {
	static long N = 1000000007;

	static long exponentiation(long base, long exp) {
		long t = 1L;
		while (exp > 0) {
			if (exp % 2 != 0)
				t = (t * base) % N;

			base = (base * base) % N;
			exp /= 2;
		}
		return t % N;
	}

	public static void main(String args[]) throws Exception {
		MyScanner sc = new MyScanner();
		long k = sc.nextLong();
		long principal = 100L;
		/*double amt = k / 100.0;
		BigDecimal x = new BigDecimal(Double.toString(amt));
		BigDecimal base = new BigDecimal("1.01");*/
		int i = 1;
		for(i = 1; ; i++) {
			
			principal += (principal / 100);
			//base = base.multiply(new BigDecimal("1.01"));
			
			if(principal >= k)
				break;
		}
		System.out.println(i);
	}

	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}
}

Measured memory_bytes: 32812
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int num[N];
  rep(i, N) {
    cin >> num[i];
  }
  
  sort(num, num + SIZE_OF_ARRAY(num), greater<>());
  int alice = 0, bob = 0;
  rep(i, N) {
    if (i % 2) {
      alice += num[i];
    } else {
      bob += num[i];
    }
  }
  cout << abs(alice - bob) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>
using namespace std;
int main() {
  int n,m,i,j,k,tmp,count=0;
  int *a;
  cin >> n;
  cin >> m;

  a=(int *)malloc(sizeof(int)*m);

  for(j=0;j<m;j++){
      a[j]=0;
  }

  for(i=0;i<n;i++){
      cin >> k;
      for(j=0;j<k;j++){
          cin >> tmp;
          a[tmp-1]++;
      }
  }
  
  for(j=0;j<m;j++){
      if(a[j]==n){
        count++;
      }
  }
  cout << count << endl;
  return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void solve() {
    ll N, K, R, S, P;
    cin >> N >> K >> R >> S >> P;
    string T;
    cin >> T;
    ll ans = 0;
    vector<char> X(N, 'a');
    rep(i, N) {
        if (T[i] == 'r') {
            if (i - K >= 0 && X[i - K] == 'r') {
                X[i] = 'a';
            } else {
                X[i] = T[i];
                ans += P;
            }
        } else if (T[i] == 's') {
            if (i - K >= 0 && X[i - K] == 's') {
                X[i] = 'a';
            } else {
                X[i] = T[i];
                ans += R;
            }
        } else {
            if (i - K >= 0 && X[i - K] == 'p') {
                X[i] = 'a';
            } else {
                X[i] = T[i];
                ans += S;
            }
        }
    }
    cout << ans << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 512