akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <stack>
#define Endl endl
#define mp make_pair
#define rep(N) for(int i=0;i<N;i++)
#define repj(N) for(int j=0;j<N;j++)
#define ll long long 
#define pii pair<int,int>
#define For(I,N) for(int I=0;I<N;I++)
#define cinone(N) int N;cin>>N;
#define scanfone(N) int N;cin>>N;
#define cingroup(N,M) int N[M];for(int yiuytvnm=0;yiuytvnm<M;yiuytvnm++) cin>>N[yiuytvnm];
#define scanfgroup(N,M) int N[M];for(int qrwuoiq=0;qrwuoiq<M;qrwuoiq++) scanf("%d",&N[qrwuoiq]);
typedef unsigned long long ull;
using namespace std;

int main()
{
//	freopen("input.txt","r",stdin);
	int n,k;
	cin>>n>>k;
	int a[n];
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		--a[i];
	}
	int s[n];
	memset(s,0,sizeof(s));
	for(int i=0;i<n;i++)
	{
		s[a[i]]++;
	}
	sort(s,s+n);
	int ans=0;
	int dif=0;
	for(int i=0;i<n;i++)
	{
		if(s[i]==0) continue;
		dif++;
	}
	k=dif-k;
	for(int i=0;i<n;i++)
	{
		if(s[i]==0) continue;
		if(k<=0)
		{
			break;
		}
		ans+=s[i];
		k--;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(void){
  int i,j,k,l;
  int data;
  int count;

  while(1){
    scanf("%d",&data);
    if(data==0)break;
    count=0;
  
    data=1000-data;

    count+=data/500;
    data=data%500;

    count+=data/100;
    data=data%100;

    count+=data/50;
    data=data%50;

    count+=data/10;
    data=data%10;

    count+=data/5;
    data=data%5;

    count+=data/1;
  
    printf("%d\n",count);

  }
  return(0);
}
  

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

using namespace std;

inline int read(){
	char ch=getchar();int x=0,f=1;
    while(ch<'0' || ch>'9') {
       if(ch=='-') f=-1;
	  	  ch=getchar();
	}
    while(ch<='9' && ch>='0') {
	   x=x*10+ch-'0';
	   ch=getchar();
	}
    return x*f;
}

char ch;
int f[300010];
int l[300010],r[300010];
int ans=300100;

int main(){
	int n=read();
	for(int i=1;i<=n;i++){
		cin>>ch;
		if(ch=='E') f[i]=1;
		else f[i]=2;
	}
	for(int i=1;i<=n;i++){
		if(f[i-1]==2) l[i]++;
		l[i]+=l[i-1];
	}
	for(int i=n;i>=1;i--){
		if(f[i+1]==1) r[i]++;
		r[i]+=r[i+1];
	}
	for(int i=1;i<=n;i++)
	{
		ans=min(ans,l[i]+r[i]);
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3712
package main

import "fmt"

func main() {
	var S string
	fmt.Scan(&S)

	rs := []rune(S)
	for i := 2; i < len(rs); i += 2 {
		if checkEvenString(rs[:len(rs)-i]) {
			fmt.Println(len(rs[:len(rs)-i]))
			break
		}
	}
}

func checkEvenString(rs []rune) bool {
	if string(rs[0:(len(rs)/2)]) == string(rs[(len(rs)/2):]) {
		return true
	}
	return false
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int, int> P;

void printVec(std::vector<string> &vec) {
  std::cout << "";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    std::cout << *it << " ";
  }
  std::cout << std::endl;
}

int main() {
  int c;
  cin >> c;
  vector <string> s;

  for (int i = 0; i < c; i++) {
    string str;
    cin >> str;
    s.push_back(str);
  }
  sort(s.begin(), s.end());

  s.erase(unique(s.begin(), s.end()), s.end());

  cout << s.end() - s.begin() << endl;
	return 0;
}


Measured memory_bytes: 11604
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
typedef long long ll;
using namespace std;

int main() {
	ll a,b,c,d;
	string s;
	cin>>a>>b>>s;
	c=s.find('-');
	d=s.rfind('-');
	if(c==a&&d==a){
		cout << "Yes"<<endl;
	}
	else{
		cout << "No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
//Let's join Kaede Takagaki Fan Club !!
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target ("avx")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define all(x) x.begin(),x.end()
template<class T>
void dmp(T a){
	rep(i,a.size()) cout << a[i] << " ";
	cout << endl;
}
template<class T>
bool chmax(T&a, T b){
	if(a < b){
		a = b;
		return 1;
	}
	return 0;
}
template<class T>
bool chmin(T&a, T b){
	if(a > b){
		a = b;
		return 1;
	}
	return 0;
}
template<class T>
void g(T &a){
	cin >> a;
}
template<class T>
void o(const T &a,bool space=false){
	cout << a << (space?' ':'\n');
}
//ios::sync_with_stdio(false);
const ll mod = 1000000007;//998244353
template<class T>
void add(T&a,T b){
	a+=b;
	if(a >= mod) a-=mod;
}
int n, m;
ll dp[5005][5005], bin[5005], revb[5005];
ll dp2[5005][5005];

ll modpow(ll x,ll n){
	ll res=1;
	while(n>0){
		if(n&1) res=res*x%mod;
		x=x*x%mod;
		n>>=1;
	}
	return res;
}
int main(){
	bin[0] = 1;
	for(int i=1;i<5005;i++) bin[i] = bin[i-1] * 2LL % mod;
	rep(i, 5005) revb[i] = modpow(bin[i], mod-2);
	cin >> m >> n;
	rep(i, 5005) dp[i][0] = 1;
	//dp2[i][j] = dp[i][j] * i * rev[i+1]
	
	rep(i, 5005) dp2[i][0] = dp[i][0] * i % mod * revb[i+1] % mod;
	for(int j=1;j<=m;j++){
		for(int i=1;i<=n;i++){
			//same
			dp[i][j] += dp[i][j-1] * (i+1) % mod;
			//small
			//for(int k=1;k<i;k++){
			//	dp[i][j] += dp[k][j-1] * k % mod * bin[i-k-1] % mod;
			//}
			dp[i][j] += dp2[i-1][j-1] * bin[i] % mod;
			dp[i][j] %= mod;
			dp2[i][j] = dp[i][j] * i % mod * revb[i+1] % mod;
			dp2[i][j-1] = dp2[i-1][j-1] + dp2[i][j-1];
			dp2[i][j-1] %= mod;
		}
	}
	cout << dp[n][m] << endl;
}

Measured memory_bytes: 394732
#include <bits/stdc++.h>
#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 INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;

int main()
{
  ll N;
  cin >> N;
  vector<vector<ll>> A(N-1,vector<ll>(3));
  REP(i, N-1){
    REP(j, 3){
      cin >> A.at(i).at(j);
    }
  }
  
  REP(i,N){
    ll now=0;
    FOR(j,i,N-1){
      //now以上のA.at(j).at(2)の倍数とA.at(j).at(1)のmax
      ll x;
      if(now%A.at(j).at(2)==0){
        x=now;
      }else{
        x=(now/A.at(j).at(2)+1)*A.at(j).at(2);
      }
      now=A.at(j).at(0)+max(A.at(j).at(1),x);
    }

    cout << now << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb  					push_back
#define mp 						make_pair
#define all(v) 					((v).begin()) ,((v).end())
#define let(o,v)				memset(o,v,sizeof (o))
typedef long long 				ll;
typedef vector<int>				vi;
typedef vector<vi>				vvi;
typedef vector<string>			vs;

const int MOD = 1e9+7;
const int oo = (int)1e9;
const ll OO = (ll)1e18;
const double PI = acos(-1.0);
const int N = (int)1e5 + 9;

bool isprime(ll n) {
	if (n <= 1)
		return 0;
	for (ll i = 2; i*i <= n; i++)
		if (n%i == 0)
			return false;
	return 1;
}
ll intlog(ll base, ll x) {
	return (log(x) / log(base));
}
bool prime[N];
void primee()
{

	for (int p = 2; p*p <= N; p++)
	{

		if (prime[p] == true)
		{
			for (int i = p * 2; i < N; i += p)
				prime[i] = false;
		}
	}

}
string decToBinary(ll n)
{
	string z = "";
	int i = 0;
	while (n > 0) {

		z += (n % 2) + 48;
		n = n / 2;
		i++;
	}
	reverse(all(z));
	return z;
}
ll gcd(ll a, ll b) {
	return b == 0 ? a : gcd(b, a%b);
}
ll power(ll x, int y)
{
	ll temp;
	if (y == 0)
		return 1;
	temp = power(x, y / 2);
	if (y % 2 == 0)
		return temp * temp;
	else
		return x * temp*temp;
}
int h, w;
string ar[1000];
ll dp[1000][1000];
ll calc(int r, int c) {
	if (r == h - 1 && c == w - 1) {
		return 1;
	}
	ll &ret = dp[r][c];
	if (ret != -1) return ret;
	ret = 0;
	if (r + 1 < h && c < w && ar[r+1][c]=='.') ret = ((ret % MOD) + (calc(r + 1, c) % MOD)) % MOD;
	if (r < h && c + 1 < w && ar[r][c+1]=='.') ret = ((ret % MOD) + (calc(r, c + 1) % MOD)) % MOD;
	return ret % MOD;
}
int main()
{
	let(dp, -1);
	scanf("%d %d", &h, &w);
	for (int i = 0; i < h; i++)
	{
		cin >> ar[i];
	}
	printf("%lld\n", calc(0, 0));
	return 0;
}

Measured memory_bytes: 9216
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<ll, P> E;
#define cost first
#define from second.first
#define to second.second
#define MOD (1000000007ll)
#define l_ength size

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

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

int main(void){
	ll n,ans,cnt=0ll;
	cin >> n;
	n++;
	while(n>10){
		cnt++;
		n /= 10;
	}
	ans = (n-1)+9*cnt;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 764
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  string s; cin >> s;
  map<char, int> mp;
  mp['N'] = 0; mp['W'] = 1; mp['S'] = 2; mp['E'] = 3;
  vector<bool> home(4, false);
  for (char c : s) home[mp[c]] = true;
  cout << ((home[0] ^ home[2]) || (home[1] ^ home[3]) ? "No\n" : "Yes\n");
  return 0;
}


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

using namespace std;


int main(){

	int x[5];

	for (int i = 0; i < 5; i++){
		cin >> x[i];
		x[i] *= (-1);
	}

	sort(x, x + 5);

	printf("%d %d %d %d %d\n", -x[0], -x[1], -x[2], -x[3], -x[4]);

	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using pll = pair<ll,ll>;
using plll = pair<ll,pll>;
using vll = vector<pll>;
using vvll = vector<vll>;

#define ff first
#define ss second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define dmin(a,b) a = min(a,b)

const ll INF = 1e18;

int main() {
    ll n, m, s; cin >> n >> m >> s;
    vvll edges(n, vll(n, pll(INF, INF)));
    vl ans(n, INF);
    rep(i,m) {
        ll u, v, a, b; cin >> u >> v >> a >> b;
        u--; v--;
        edges[u][v] = edges[v][u] = pll(a, b);
    }
    rep(i,n) {
        ll a, b; cin >> a >> b;
        edges[i][i] = pll(-a, b);
    }
    priority_queue<plll> pq;
    map<pll,ll> used;
    pq.push(plll(0, pll(0, s)));
    while (!pq.empty()) {
        ll time = -pq.top().ff;
        ll node = pq.top().ss.ff;
        ll cnt  = pq.top().ss.ss; pq.pop();
        if (cnt < 0) continue;
        dmin(cnt, 2500LL);
        if (used.count(pll(node,cnt))) continue;
        used[pll(node,cnt)] = 1;
        dmin(ans[node], time);
        rep(to,n) {
            ll a = edges[node][to].ff, b = edges[node][to].ss;
            if (a == INF) continue;
            pq.push(plll(-time-b, pll(to, cnt-a)));
        }

        bool finished = true;
        rep(i,n) if (ans[i] == INF) finished = false;
        if (finished) break;
    }
    rep(i,n-1) cout << ans[i+1] << endl;
    return 0;
}


Measured memory_bytes: 20896
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;

typedef long long ll;

long long Merge(int A[],int left,int mid,int right){
  int n1=mid-left;
  int n2=right-mid;
  int i,j,k;
  int L[n1+1],R[n2+1];
  long long res=0;
  for(i=0;i<n1;i++)L[i]=A[left+i];
  for(i=0;i<n2;i++)R[i]=A[mid+i];
  L[n1]=1000000001;
  R[n2]=1000000001;
    
  i=j=0;
  for(k=left;k<right;k++){
    if(L[i]<R[j]){
      A[k]=L[i];
      i++;
    }else{
      A[k]=R[j];
      j++;
      res+= (long long)n1- (long long)i;
    }
  }
  return res;
}
  
long long Merge_Sort(int A[],int left,int right){
  int mid;
  long long res=0;
  if(left+1<right){
    mid=(left+right)/2;
  
    res+=Merge_Sort(A,left,mid);
    res+=Merge_Sort(A,mid,right);
    res+=Merge(A,left,mid,right);
      
  }
  return res;
}
 
int n;
P A[100005];
int B[100005];
int S[100005];


void solve(){
  vector<int> L,R;
  
  for(int i=0;i<n;i++){
    if(i&1)L.push_back(B[i]);
    else R.push_back(1-B[i]);
  }
  
  sort(L.begin(),L.end());
  sort(R.begin(),R.end());
 
  int lc=0,rc=0;
  for(int i=0;i<n;i++){
    if(i&1){
      S[i]=L[lc];
      lc++;
    }else{
      S[i]=1-R[rc];
      rc++;
    }
  }

  int c0=0,c1=1;
  for(int i=0;i<n;i++){
    if(S[i]==0){
      S[i]=c0;
      c0+=2;
    }else{
      S[i]=c1;
      c1+=2;
    }
  }

  ll x=Merge_Sort(S,0,n);
  printf("%lld\n",x);
}

int main(){
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>A[i].first;
    A[i].second=i;
  }
  sort(A,A+n);
  for(int i=0;i<n;i++){
    P p=A[i];
    B[ p.second ] = i%2;
  }

  solve();
  return 0;
}


Measured memory_bytes: 2812
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>

using namespace std;

#define INF 1000000007

const int maxn = 100000+10;
int fac[maxn], invfac[maxn];

#define MOD 1000000007
long long qpow(long long a, long long b){
    long long s = 1;
    while (b > 0) {
        if (b & 1)s = s * a % MOD;
        a = a * a % MOD;
        b >>= 1;
    }
    return s;
}
void init() {
    int n = maxn - 1;
    fac[0] = 1;
    for (int i = 1; i <= n; ++i)
        fac[i] = 1ll * fac[i - 1] * i % MOD;
    invfac[n] = qpow(fac[n], MOD - 2);
    for (int i = n - 1; i >= 0; --i) {
        invfac[i] = 1ll * invfac[i + 1] * (i + 1) % MOD;
    }
}
long long comb(int n, int m) {
    if (n < m) return 0;
    return 1ll * fac[n] * invfac[m] % MOD * invfac[n - m] % MOD;
}


int main(){
  init();
  long long n, k;
  cin >> n >> k;
  vector<long long> a(n);
  long long po = 0;
  long long ne = 0;
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  if(n == 1 || k == 1){
    cout << 0 << endl;
    return 0;
  }
  sort(a.begin(), a.end());
  vector<long long> s(n+1, 0);
  for(int i = 0; i <= n; i++){
    if(i < k-2) continue;
    if(i > 0)s[i] = (s[i-1]+comb(i , k-2))%MOD;
    else s[0] = comb(i, k-2)%MOD;
  }
  for(int i = 0; i < n; i++){
    // if(i+1 >= k)cout << s[i-1] << ' ' << s[n-i-2] << endl;
    // else cout << s[n-i-2] << endl;
    if(i+1 >= k)po = (po+a[i]*s[i-1])%MOD;
    if(n-i >= k)ne = (ne+a[i]*s[n-i-2])%MOD;
  }
  cout << (po + MOD - ne) % MOD << endl;
}


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

int main () {
  string a ;
  cin >> a ;
  vector<int> nul(26) ;
  for(int i = 0 ; i < a.length() ; i++ ) nul[a[i]-'a']++ ; 
  bool can = true ;
  for(int i = 0 ; i < 26 ; i++){
    if(nul[i]%2==1) {
      can = false ;
      break ;
    }
  }
    if(can) cout << "Yes" << endl ;
    else cout << "No" << endl ;
}

Measured memory_bytes: 256
function Main(input) {
    var nums = input.split(" ")
        .map(str => {
            return parseInt(str, 10)
        });
    console.log(nums[0] * nums[1] % 2 === 0 ? 'Even' : 'Odd');
}
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
import java.util.*;

class Main {
	Scanner sc;
	int M = 1_000_000_000+7;
	void calc() {
		sc = new Scanner(System.in);
		int X = sc.nextInt();
		int Y = sc.nextInt();
		if ( (X+Y)%3 != 0 ) {
			System.out.println(0);
			return;
		}
		int N = (X+Y)/3;
		int a = X-N;
		int b = Y-N;
		if (a < 0 || b < 0) {
			System.out.println(0);
			return;
		}
		
		// ans = nCr(a+b, a)
		if (a < b) {
			int t = a; a = b; b = t;
		}
		long u = 1;
		for (int i = a+b; i > a; i--) u = (u * i) % M;
		long l = 1;
		for (int i = b; i >= 1; i--) l = (l * i) % M;
		
		int inv = extgcd((int)l, M)[1];
		
		System.out.println((u * inv)%M);
	}

	/**
	 * 拡張ユークリッド互除法
	 * ax+by=gcd(a,b) となる gcd,x,y を求める。
	 */
	static int[] extgcd(int a, int b) {
		int aa = a, bb = b;
		int x0 = 1, x1 = 0;
		int y0 = 0, y1 = 1;
	
		while (b != 0) {
			int q = a / b;
			int r = a % b;
			int x2 = x0 - q * x1;
			int y2 = y0 - q * y1;
	
			a = b; b = r;
			x0 = x1; x1 = x2;
			y0 = y1; y1 = y2;
		}
		if (bb > 0 && x0 < 0) {
			int n = -x0/bb;
			if (-x0%bb != 0) n++;
			x0 += n*bb; y0 -= n*aa;
		}
	    return new int[]{a, x0, y0};
	}
	
	public static void main(String[] args) {
		new Main().calc();
	}
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i=(a); i<(b); i++)

int main() {
  int r,g,b;
  cin >> r >> g >> b;
  if (((g*10 + b) % 4) == 0) cout << "YES" << endl;
  else cout << "NO" << endl;

return 0;
}

Measured memory_bytes: 3640
N=int(raw_input())
a=map(int,raw_input().split())
c=[0,0,0,0,0,0,0,0]
m=0
for i in range(N):
    b =a[i]/ 400
    if b < 8:
        c[b]+=1
    else:
        m+=1


ans=0
for i in c:
    if i > 0:
        ans+=1

mi=ans
if mi==0:
    mi=1
ma=ans+m
print mi,ma

Measured memory_bytes: 2568
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;
using Tapris = tuple<int, int, int>;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

/*************** using variables ***************/
int n;
vector<int> c, w;
int ruiseki[1005];
bool dp[1005][1005];

/**********************************************/

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

    cin >> n;
    c.resize(n);
    w.resize(n);
    REP(i, n) cin >> c[i] >> w[i];

    ruiseki[0] = w[0];
    FOR(i, 1, n) ruiseki[i] = ruiseki[i-1] + w[i];
    
    REP(i, n) REP(j, n) dp[i][j] = false;
    REP(i, n) dp[i][i] = true;

    for(int len = 2; len <= n; len++){
        REP(l, n){
            int r = l + len - 1;
            if(r >= n) break;
            if(dp[l][r-1]){
                int weight = ruiseki[r-1];
                if(l != 0) weight -= ruiseki[l-1];
                dp[l][r] |= weight <= c[r];
            }
            if(dp[l+1][r]){
                int weight = ruiseki[r] - ruiseki[l];
                dp[l][r] |= weight <= c[l];
            }
        }
    }

    vector<int> ans(n, INF);
    ans[0] = 1;

    for(int r = 1; r < n; r++){
        ans[r] = ans[r-1] + 1;
        for(int l = 0; l < r; l++){
            if(dp[l][r]){
                if(l == 0) ans[r] = min(ans[r], 1);
                else ans[r] = min(ans[r], ans[l-1] + 1);
            }
        }
    }

    cout << ans[n-1] << endl;
}



Measured memory_bytes: 4180
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
n, x = [int(x) for x in input().split()]

total = [1]
p = [1]

for i in range(n):
    total.append(total[-1]*2 + 3)
    p.append(p[-1]*2 + 1)

ans = 0

# print(total)

def solve(x, i):
    global ans
    if x == 0:
        ans += 1
        return
    if i <= 1 + total[x - 1]:
        if i - 1 > 0:
            solve(x - 1, i - 1)
    else:
        ans += 1 + p[x - 1]
        if i - (2 + total[x - 1]) > 0:
            solve(x - 1, i - (2 + total[x - 1]))

solve(n, x)
print(ans)


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

using namespace std;

constexpr int p = 998244353;
constexpr int N = 2e6 + 5, M = 2e6 + 5;

long long sum[M], buk[M], inv[M], prime[M], ntprime[M], miu[M];
long long a[N];
int n, cnt; 

void sieve(int n) {
  inv[1] = 1;
  for (int i = 2; i <= n; ++i)
    inv[i] = (p - p / i) * inv[p % i] % p; 
  cnt = 0; miu[1] = 1;
  for (int i = 2; i <= n; ++i) {
    if (!ntprime[i]) 
      miu[prime[++cnt] = i] = -1;
    for (int j = 1; j <= cnt && prime[j] * i <= n; ++j) {
      ntprime[i * prime[j]] = 1; 
      if (i % prime[j] == 0) {
        miu[i * prime[j]] = 0; 
        break;
      } else {
        miu[i * prime[j]] = p - miu[i]; 
      }
    }
  }
}

int main() {
  scanf("%d", &n); 
  memset(sum, 0, sizeof sum);
  memset(buk, 0, sizeof buk);
  long long s = 0, mx = 0; 
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]); 
    ++buk[a[i]]; 
    s = (s + a[i]) % p; 
    mx = max(mx, a[i]);
  }
  sieve(mx);
  for (int i = 1; i <= mx; ++i) 
    for (int j = 1; j * i <= mx; ++j)
      sum[i] = (sum[i] + buk[i * j] * i % p * j % p) % p; 
  long long ans = 0; 
  for (int g = 1; g <= mx; ++g) {
    long long t = 0; 
    for (int d = 1; d * g <= mx; ++d) 
      t = (t + miu[d] * sum[d * g] % p * sum[d * g] % p) % p; 
    ans = (ans + t * inv[g] % p) % p; 
  }
  printf("%lld\n", ((ans - s + p) * inv[2] % p + p) % p);
  return 0; 
}

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

using namespace std;
using ll = long long;
const long long INF = 1LL<<60;

typedef pair<ll,ll> Pair;

int main(){

ll N,M,K;
ll ans = 0;

cin >> N >> M >> K;

vector<ll> A(N);
vector<ll> B(M);

for(ll i = 0;i < N;++i) cin >> A[i];
for(ll j = 0;j < M;++j) cin >> B[j];

vector<ll> sumA(N+1,0);
vector<ll> sumB(M+1,0);

for(ll i = 0;i < N;++i) sumA[i+1] = sumA[i] + A[i];
for(ll i = 0;i < M;++i) sumB[i+1] = sumB[i] + B[i];

ll sum = sumB[M];
ll left = 0;

for(ll right = M;right >= 0;--right){

  while((sum + A[left]) <= K && left < N){

    sum += A[left];
    ++left;

  }

  if(sum <= K && sum != 0) ans = max(ans,left + right);

  if(right != 0) sum -= B[right - 1];

}

cout << ans << endl;

return 0;

}   


Measured memory_bytes: 9572
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;

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

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

    lint g = gcd(a, b);

    map<lint, lint> pf;
    for(lint i=2; i*i<=g; i++) {
        while(g % i == 0)  ++pf[i], g /= i;
    }
    if(g != 1)  pf[g] = 1;
    cout << pf.size() + 1 << endl;
}

Measured memory_bytes: 256
def root(x):
    if x == p[x]:
        return x
    p[x] = y = root(p[x])
    return y
def unite(x, y):
    px = root(x); py = root(y)
    if px == py:
        return 0
    if px < py:
        p[py] = px
        sz[px] += sz[py]
    else:
        p[px] = py
        sz[py] += sz[px]
    return 1

N, M = map(int, input().split())
*p, = range(N)
sz = [1]*N
E = []
for i in range(M):
    a, b = map(int, input().split())
    E.append((a-1, b-1))

ans = [None]*M
E.reverse()
res = 0
ans[-1] = "%d\n" % (N*(N-1)//2)
for i, (a, b) in enumerate(E[:-1]):
    sa = sz[root(a)]; sb = sz[root(b)]
    if unite(a, b):
        sc = sz[root(a)]
        res += sc*(sc-1)//2 - sa*(sa-1)//2 - sb*(sb-1)//2
    ans[-2-i] = "%d\n" % (N*(N-1)//2 - res)
open(1, 'w').writelines(ans)

Measured memory_bytes: 29272
#include <iostream>
#include <vector>
#include <queue>
#include <cstdio>

using namespace std;

int N, M, L;

static const int INF = 1e7;

struct Edge {
  int B, D, E;
  Edge(int B, int D, int E) : B(B), D(D), E(E) {}
};

struct State {
  int cur;
  int cost;
  int money;
  State(int cur, int cost, int money) : cur(cur), cost(cost), money(money) {}
  bool operator<(const State & rhs) const {
    return cost > rhs.cost;
  }
  void print() {
    printf("%d %d %d\n", cur, cost, money);
  }
};

vector<Edge> Graph[200];

int mini[200][200];

void init() {
  for (int i = 0; i < 200; i++) {
    Graph[i].clear();
  }

  for (int i = 0; i < 200; i++) {
    for (int j = 0; j < 200; j++) {
      mini[i][j] = INF;
    }
  }
}

void solve() {
  priority_queue<State> Q;

  Q.push(State(0, 0, L));

  
  while (!Q.empty()) {
    State cur = Q.top();
    Q.pop();
    //cur.print();

    int c = cur.cur;
    int cost = cur.cost;
    int money = cur.money;

    if (mini[c][money] < cost) {
      continue;
    }
    mini[c][money] = cost;  
    for (int i = 0; i < Graph[c].size(); i++) {
      int dst = Graph[c][i].B;
      int dis = Graph[c][i].D;
      int enm = Graph[c][i].E;
      //      cout << "Edge" << endl;
      //      cout << dst << " " << dis << " " << enm << endl;
      if (money - dis >= 0 && mini[dst][money - dis] > cost) {
        Q.push(State(dst, cost, money - dis));
      }
      if (mini[dst][money] > cost + enm) {
        Q.push(State(dst, cost + enm, money));
      }
    }
  }

  int mn = INF;
  //cout << "N = " << N << endl;
  for (int i = 0; i <= L; i++) {
    //cout << mini[N - 1][i] << " " ;
    mn = min((double)mini[N - 1][i], (double)mn);
  }
  //cout << endl;

  cout << mn << endl;
}

int main() {
  while (true) {
    cin >> N >> M >> L;
    if (N == 0 && M == 0 && L == 0) {
      return 0;
    }
    init();
    for (int i = 0; i < M; i++) {
      int a, b, d, e;
      cin >> a >> b >> d >> e;
      a--, b--;
      Graph[a].push_back(Edge(b, d, e));
      Graph[b].push_back(Edge(a, d, e));
    }
    solve();
  }
}

Measured memory_bytes: 4840
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include<cstdio>
#include <iomanip>


using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;

const int  INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
const int SIZE = 100;

int main() {
	ll n;
	ll one = 0, two = 0, four = 0;
	
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		ll x;
		cin >> x;
		if (x % 4 == 0) four++;
		else if (x % 2 == 0) two++;
		else one++;
	}

	if (two == 0) {
		if (one <= four + 1) cout << "Yes" << endl;
		else cout << "No" << endl;
		return 0;
	}
	else {
		if (one <= four) cout << "Yes" << endl;
		else cout << "No" << endl;
		return 0;
	}
	
}

Measured memory_bytes: 256
import copy

N = int(input())
graph = []
road = []
for _ in range(N):
  A = list(map(int, input().split()))
  graph.append(A)
  road.append(copy.deepcopy(A))

exist = 1
for k in range(N):
  for i in range(N):
    for j in range(N):
      if graph[i][j] > graph[i][k] + graph[k][j]:
        exist = 0
        break
      if graph[i][j] != 0 and graph[i][k] != 0 and graph[k][j] != 0:
        if graph[i][j] == graph[i][k] + graph[k][j]:
          road[i][j] = 0
    if exist == 0:
      break
  if exist == 0:
    break

if exist == 0:
  print(-1)
else:
  ans = 0
  for row in road:
    ans += sum(row)
  print(ans//2)

Measured memory_bytes: 77612
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

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

#define SUM(vec) accumulate(all(vec),0LL) // 配列の中身を全部足す
template<typename T>void print(T&& x){cout<<x<<endl;}// 改行付き出力
ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int ctoi(char c){return c-'0';}


// TODO: write
int main() {
  string s;cin>>s;
  bool ok = true;
  for(int i = 0;i < s.size();++i){
    if(s[i] != s[s.size()-1-i])ok = false;
  }
  
  string t = s.substr(0,(s.size())/2);
  for(int i = 0;i < t.size();++i){
    if(t[i] != t[t.size()-1-i])ok = false;
  }

  string u = s.substr((s.size()+2)/2,s.size());
  for(int i = 0;i < u.size();++i){
    if(u[i] != u[u.size()-1-i])ok = false;
  }

  if(ok)print("Yes");
  else print("No");
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include<queue>
#include<functional>
#define loop(n) for(int i = 0; i < n; i++)
#define FOR(x,y,z) for(int x = y; x < z; x++)
#define REP(i,n) FOR(i,0,n)
#define INF 999999999
#define VEC vector<int>
#define in push_back
#define ans(x) cout<<x<<endl
typedef long long ll;
using namespace std;
priority_queue<int, vector<int>, greater<int>> small;//chiisai
priority_queue<ll>large;//ookii
int main()
{
	ll a, b, c, n;
	cin >> a >> b;
	ll x, y, z;
	x = a;
	y = b;
	z = a + b;
	if (x % 3 == 0 || y % 3 == 0 || z % 3 == 0) {
		cout << "Possible" << endl;
	}
	else {
		cout << "Impossible" << endl;
	}
	return 0;
}


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

int main() {
  // cout << __LINE__ << endl;
  int N;
  int sum=0;
  //cout << __LINE__ << endl;
  //cout << N << endl;
  cin >> N;
  vector<int> price(N);
  //cout << __LINE__ << endl;
  for(int i=0;i<N;i++){
   cin >> price[i];
  }
  //cout << __LINE__ << endl;

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

  for(int i=0;i<N-1;i++){
  sum = sum + price[i];
  }
  //cout << __LINE__ << endl;

  sum = sum + (price[N-1]/2);
  //cout << __LINE__ << endl;

  cout << sum << endl;
}

Measured memory_bytes: 256
n,m = map(int, input().split())
A = []
b = []
for i in range(n):
    L = list(map(int, input().split()))
    A.append(L)
for j in range(m):
    b.append(input())
Ab = []
for k in range(n):
    c = 0
    for l in range(m):
        c +=( int(A[k][l]) * int(b[l]) )
    Ab.append(c)
for i in range(n):
    print(Ab[i])


Measured memory_bytes: 6016
#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)

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

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

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

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;  cin >> n;
    vector<int> s(n);
    int sum = 0;
    rep (i, n) {
      cin >> s[i];
      sum += s[i];
      if (s[i] % 10 == 0) {
        s[i] = -1;
      }
    }
    sort(s.begin(), s.end());
    if (sum % 10 != 0) {
      cout << sum << '\n';
    } else {
      rep(i, n) {
        if (s[i] > 0) {
          sum -= s[i];
          cout << sum << '\n';
          return 0;
        }
      }
      cout << 0 << '\n';
    }

    return 0;
}


Measured memory_bytes: 256
class Dice:
    def __init__(self, label):
        self.d = label

    def roll(self, direction):
        if direction == "N":
            self.d[0], self.d[1], self.d[5], self.d[4] = self.d[1], self.d[5], self.d[4], self.d[0]
        elif direction == "S":
            self.d[0], self.d[1], self.d[5], self.d[4] = self.d[4], self.d[0], self.d[1], self.d[5]
        elif direction == "E":
            self.d[0], self.d[2], self.d[5], self.d[3] = self.d[3], self.d[0], self.d[2], self.d[5]
        elif direction == "W":
            self.d[0], self.d[2], self.d[5], self.d[3] = self.d[2], self.d[5], self.d[3], self.d[0]
        else:
            pass

label = [int(i) for i in input().split()]
q = int(input())

dice1 = Dice(label)

for i in range(q):
    top, front = map(int, input().split())

    # ??¨????????¶???(4 * 6)???????????????????????¢??????
    cmd = "N" * 4 + ("W" + "N" * 4) * 3 + "NE" + "N" * 4 + "EE" + "N" * 4 

    for i in cmd:
        dice1.roll(i)

        if dice1.d[1] == front and dice1.d[0] == top:
            print(dice1.d[2])
            break

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

int main(void){

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

   for(i = 0; i < 10000; i++){
       if((A * i) % B == C){
           cout << "YES" << endl;
           return 0;
       }
   } 
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pop pop_back
#define V vector
#define P pair
#define V2(a,b,c) V<V<int>> a(b,V<int>(c))
#define V2a(a,b,c,d) V<V<int>> a(b,V<int>(c,d))
#define incin(a) int a; cin>>a
//#define min min<int>
//#define max max<int>
template<class T>
 void cou(vector<vector<T>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
/*template<>
 void cou(vector<vector<char>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}*/
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
struct Union{
  vector<int> par;
  Union(int n){
	par= vector<int>(n, -1);
  }
  int find(int x){
    if(par[x]<0)
      return x;
    else
      return par[x]=find(par[x]);
  }
  bool same(int a,int b){
    return find(a)==find(b);
  }
  int Size(int a){
    return -par[find(a)];
  }
  void unite(int a,int b){
    a=find(a);
    b=find(b);
    if(a==b)
      return;
    if(Size(b)>Size(a))
      swap<int>(a,b);
    par[a]+=par[b];
    par[b]=a;
  }
};
int ketas(int a){
  string b=to_string(a);
  int c=0;
  fo(i,keta(a)){
    c+=b[i]-'0';
  }
  return c;
}
/*struct aa{
	vector<int> gt;
  aa(int n){
	gt= vector<int>(n, 1);
  }
	void c(V<int> d,int b){
	if(d[b]==0){
		gt[d[b]-1]++;
		gt[gt.sz-1]++;
	}
	else{
		gt[d[b]-1]++;
		c(d,d[d[b]]-1);
	}
}
void cok(int a){
	cout<<gt[a-1]<<endl;
	fo(i,a-1)
	cout<<gt[i]<<endl;
}
};
*/
signed main(){
	string a;
	cin>>a;
	if(a[5]=='0'&&a[6]-'0'<=4)
		cout<<"Heisei"<<endl;
	else
		cout<<"TBD"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(src,dst)    for(int i=src; i<dst;  i++)
#define rep2(src,dst)   for(int j=src; j<dst;  j++)
#define INF 1000000000000 //1e12
#define MOD 1000000007 //1e9+7
#define PI  acos(-1)
#define ll long long
template<typename T> inline void cMin(T* a, T* b)  {if(*a>*b) *a=*b;}
template<typename T> inline void chMax(T* a, T* b) {if(*a<*b) *a=*b;}
template<typename T> inline int  div(T a, T b)     {return ((a+b-1)/b);}
template<typename T> inline bool eoVerify(T a)     {return (!(a&1)? true : false );}

/***********************
* O(1)                 *
* O(logN)              *
* O(N)                 *
* O(NlogN)             *
* O(N^2)               *
* O(N^3)               *
* O(k^N)               *
* O(N!)                *
************************/


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

    cout << (str == "ABC"? "ARC" : "ABC") << endl;
    return 0;
}


Measured memory_bytes: 3592
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];
		for (int i = 0; i < n; i++) {
			arr[i] = sc.nextInt();
		}
		Arrays.sort(arr);
		long a = 0;
		long b = 0;
		HashSet<Integer> set = new HashSet<>();
		for (int i = n - 1; i >= 0; i--) {
			int x = arr[i];
			if (set.contains(x)) {
				if (a == 0) {
					a = x;
					set.remove(x);
				} else {
					b = x;
					break;
				}
			} else {
				set.add(x);
			}
		}
		System.out.println(a * b);
	}
}


Measured memory_bytes: 51812
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

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(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int dp[50][500][500];

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int n,x,y;
	cin>>n>>x>>y;
	vector<int> a(n),b(n),c(n);
	rep(i,n){
		cin>>a[i]>>b[i]>>c[i];
	}
	rep(i,50)rep(j,500)rep(k,500) dp[i][j][k]=INF;
	dp[0][0][0]=0;
	rep(i,n+1)rep(j,500)rep(k,500){
		chmin(dp[i+1][j][k],dp[i][j][k]);
		if(j-a[i]>=0 && k-b[i]>=0){
			chmin(dp[i+1][j][k],dp[i][j-a[i]][k-b[i]]+c[i]);
		}
	}
	int ans=INF;
	FOR(j,1,500)FOR(k,1,500){
		if(dp[n][j][k]==INF) continue;
		if(y*j==x*k){
			chmin(ans,dp[n][j][k]);
		}
	}
	if(ans!=INF) cout<<ans<<endl;
	else cout<<-1<<endl;
}

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


int main() {
  int n,m;
  cin>>n>>m;
  vector<int>b(m);
  bool flag=false;
  for(int i=0;i<m;i++){
    int a;
    cin>>a;
    if(a==1){
      flag=true;
    }
    b.at(i)=a;
  }
  vector<long>a(n+1,0);
  a.at(0)=1;
  a.at(1)=1;
  if(flag){
    a.at(1)=0;
    b.erase(b.begin());
  }
  for(int i=0;i<n-1;i++){
    a.at(i+2)=(a.at(i)+a.at(i+1))%1000000007;
    if(b.size()!=0){
      if(b.at(0)==i+2){
        a.at(i+2)=0;
        b.erase(b.begin());
      }
    }
  }
  cout << a.at(n);
}

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


int main(){
	string s;
	string t;
	cin>>s>>t;
	int ans=INT_MAX;
	for(int i=0;i<s.length();++i){
		int count=0;
		int flag=0;
		for(int j=0;j<t.length();++j){
			if(i+j>=s.length()){
				flag=1;
				break;
			}
			if(s[i+j]!=t[j]){
				++count;
			}
		}
		if(flag){
			break;
		}else{
			ans=min(count,ans);
			if(ans==0) break;
		}
	}
	cout<<ans;
}


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

namespace ConsoleApp6
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            var h = int.Parse(str[0]);
            var w = int.Parse(str[1]);
            var s = new string[h];
            for (int i = 0; i < h; i++)
            {
                s[i] = Console.ReadLine();
            }

            for (int i = 0; i < h; i++)
            {
                for (int j = 0; j < w; j++)
                {
                    if (s[i][j] == '#')
                    {
                        if (i - 1 >= 0 && s[i - 1][j] == '#') { continue; }
                        else if (j - 1 >= 0 && s[i][j - 1] == '#') { continue; }
                        else if (i + 1 < h && s[i + 1][j] == '#') { continue; }
                        else if (j + 1 < w && s[i][j + 1] == '#') { continue; }
                        else
                        {
                            Console.WriteLine("No");
                            return;
                        }
                    }

                }
            }
            Console.WriteLine("Yes");
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int N,K;
  cin >> N >> K;
  int ans = 0;
  int cnt = 0;
  while (cnt < N) {
    if (ans == 0) {
      cnt += K;
    } else {
      cnt += K-1;
    }
    ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3540
#include<iostream>
using namespace std;
int main(){
	int l,r,d,sum=0;
	cin >> l >> r >> d;
	for(int i=l; i<=r;i++){
		if(i%d==0){
			sum = sum + 1;
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3196
import java.io.*;
import java.util.*;
import java.util.regex.*;

import javax.lang.model.element.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static long cnt=0;
	public static PrintWriter pw = new PrintWriter(System.out);
	public static void main(String[] args) throws Exception {
		solutionA(args);
		if(in!=null){
			in.close();
		}
		pw.flush();
		pw.close();
	}

	public static void solutionA(String[] args) throws Exception{

		long a = nextLong();
		long b = nextLong();
		long x = nextLong();

		long ans = b/x-a/x;
		if(a%x==0){
			ans++;
		}
		pw.println(ans);


	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}

}



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

int main(){
    int n,a,x[55];
    long long d[55][55][2555]={0};
    cin>>n>>a;
    for(int i=1;i<=n;i++) cin>>x[i];
    d[0][0][0]=1;
    for(int i=1;i<=n;i++){
        for(int j=0;j<=i;j++){
            for(int k=0;k<=2550;k++){
                d[i][j][k]+=d[i-1][j][k];
                d[i][j+1][k+x[i]]+=d[i-1][j][k];
            }
        }
    }
    long long ans=0;
    for(int i=1;i<=n;i++) ans+=d[n][i][i*a];
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 60672
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <regex>
#include <sstream>
#define LL long long
using namespace std;
template <typename T>
inline void read(T &t)
{
    int f = 0, c = getchar();
    t = 0;
    while (!isdigit(c))
        f |= c == '-', c = getchar();
    while (isdigit(c))
        t = t * 10 + c - 48, c = getchar();
    if (f)
        t = -t;
}
template <typename T, typename... Args>
inline void read(T &t, Args &... args)
{
    read(t);
    read(args...);
}
int cnt[100005];
char str[100005];
int main(){
    int n,q;
    read(n, q);
    scanf("%s", str + 1);
    for (int i = 1; i <=n;i++){
        if(str[i]=='C' && str[i-1] == 'A')
            cnt[i] = 1;
    }
    for (int i = 1; i <= n; i++)
        cnt[i] += cnt[i - 1];
    for (int i = 1; i <= q;i++){
        int l,r;
        read(l,r);
        cout << cnt[r] - cnt[l] << endl;
    }
}

Measured memory_bytes: 1280
import java.util.*;
import java.io.*;

class Main {
//2 1 1 3
	//2000000000 0 0 
	//2000000000	
	
	public static void main(String[] args)  throws IOException{
		BufferedReader br =new BufferedReader(new InputStreamReader(System.in));
		String s[]=br.readLine().split(" ");
		long a=Long.parseLong(s[0]);
		long b=Long.parseLong(s[1]);
		long c=Long.parseLong(s[2]);
		long k=Long.parseLong(s[3]);
		
		if(a>=k)
		{
			System.out.println(k);
		}
		else
		{
			long sum=0;
			
			sum = sum + (a)*1;
			
			k=k-a;
			//System.out.println(k);
			
			k=k-b;
			//System.out.println(k);
			
			if(k>0)
			{
				sum=sum-k*1;
			}
			
			System.out.println(sum);
			/*
			//long sum=0;
			while(k>0)
			{
				//long sum=0;
				long r=a%k;
				sum=sum+(1*r);
				
				k=k-r;
				
				long r1=b%k;
				sum=sum+(0*r);
				
				k=k-r1;
				
				long r2=c%k;
				sum=sum+(0*)
			}
			*/
			
			
			
			
		}
		
		
		
		
	}

}


Measured memory_bytes: 32608