akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;

public class Main {
  private static void execute(ContestReader reader, PrintWriter out) {
    out.println(reader.nextInt()+ reader.nextInt() + reader.nextInt() >= 22 ? "bust" : "win");
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public String[] next(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public int[] nextInt(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLong(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDouble(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public char[] nextCharArray() {
    return next().toCharArray();
  }
  
  public int[][] nextInt(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public long[][] nextLong(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDouble(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
  
  public char[][] nextCharArray(int n) {
    char[][] matrix = new char[n][];
    for (int i = 0; i < n; i++) {
      matrix[i] = next().toCharArray();
    }
    return matrix;
  }
}


Measured memory_bytes: 21972
import math

n, p = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]

o_cnt = 0
e_cnt = 0

for i in range(n):
    if a[i] % 2 == 1:
        o_cnt += 1
    else:
        e_cnt += 1

ans = 0
for i in range(o_cnt//2):
    ans += (math.factorial(o_cnt)//(math.factorial(i*2+p)*math.factorial(o_cnt-i*2-p)))*2**e_cnt
    if i == o_cnt//2-1:
        if p == 0:
            ans += (math.factorial(o_cnt)//(math.factorial((i+1)*2+p)*math.factorial(o_cnt-(i+1)*2-p)))*2**e_cnt
        print(ans)

if o_cnt == 0:
    if p == 0:
        print(2**e_cnt)
    else:
        print(0)

Measured memory_bytes: 3064
def call(n):
    i = 1
    
    while( i <= n ):
        x = i

        if( x % 3 == 0):
            print(" " + str(i), end = "")
            i = i + 1
            continue

        while True:

            if( x % 10 == 3):
                print(" " + str(i) , end = "")
                break
            x = int(x / 10)

            if x == 0 :
                break

        i = i + 1

    print("\n", end = "")

if __name__ == "__main__":

    n = int(input())
    call(n)


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

#ifndef M_PI
#define M_PI 3.14159265358979
#endif
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

using namespace std;

typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;
typedef long double ld;

const ll INF = 1e15;
const ll MOD = 1e9 + 7;

int main() {
    ll i, j, k;
    ll N;
    cin >> N;

    cout << (1000 - N % 1000) % 1000 << endl;

    return 0;
}


Measured memory_bytes: 3636
package main

import (
	"bufio"

	"fmt"

	"os"

	"strconv"
)

var N int64
var M int64
var root []int64

func main() {
	N = int64(nextInt())
	M = int64(nextInt())
	bridges := make([][]int, int(M))
	for i := int64(0); i < M; i++ {
		bridges[i] = nextInts(2)
	}
	inc := (N * (N - 1)) / 2
	var result []int64
	result = append(result, inc)
	root = make([]int64, N)
	for i := int64(0); i < N; i++ {
		root[i] = int64(-1)
	}
	for i := M - 1; i >= 0; i-- {
		a := int64(bridges[i][0]) - 1
		b := int64(bridges[i][1]) - 1
		ra := getRoot(a)
		rb := getRoot(b)
		if ra > rb {
			inc -= root[ra] * root[rb]
			root[rb] += root[ra]
			root[ra] = rb
		} else if rb > ra {
			inc -= root[ra] * root[rb]
			root[ra] += root[rb]
			root[rb] = ra
		} else {
		}
		result = append(result, inc)
	}
	for i := M - 1; i >= 0; i-- {
		fmt.Printf("%v\n", result[i])
	}
}

func getRoot(a int64) int64 {
	if root[a] < 0 {
		return a
	} else {
		return getRoot(root[a])
	}
}

func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}

func nextString() string {
	return nextReader()
}

func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}

var nextReader func() string

func init() {
	nextReader = NewScanner()
}

func NewScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}

func Min(a int, b int) int {
	if a > b {
		return b
	}
	return a
}

func MaxIn2Values(a int, b int) int {
	if a > b {
		return a
	}
	return b
}

func MinIn2Values(a int, b int) int {
	if a < b {
		return a
	}
	return b
}

func Abs(a int) int {
	if a < 0 {
		return a * -1
	}
	return a
}


Measured memory_bytes: 11392
//Radhe Radhe
#include<bits/stdc++.h>
#define ll long long
#define fixed cout.setf(ios::fixed);
#define Precise cout.precision(7);
using namespace std;
int main()
{
    ll a,b,i,ans[3]={0};
    cin>>a>>b;
    ans[a-1]=1;
    ans[b-1]=1;
    for(i=0;i<3;i++)
    if(ans[i]==0){
        cout<<i+1<<endl;
    }






    return 0;
}





Measured memory_bytes: 3592
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 31;
// clang-format on

int main(void)
{
  int A[3];
  REP(i, 3) cin >> A[i];

  sort(A, A + 3);
  int sum = 0;
  REP(i, 2)
  sum += A[i + 1] - A[i];

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 888
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define PI 3.14159265359
typedef long long LL;

template<class T> inline void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> void print_vector(vector<T> vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << vec[i] << " ";
	}
	cout << "]" << endl;
}
template<class T> void print_pair_vector(vector<pair<T, T> > vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << "(" << vec[i].first << "," << vec[i].second << ") ";
	}
	cout << "]" << endl;
}

const int INF = 1 << 30;

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

	set<int> kagamimoti;
	rep(i, N) {
		int tmp;
		cin >> tmp;
		kagamimoti.insert(tmp);
	}
	cout << kagamimoti.size() << endl;
	return 0;
}

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

int main()
{
    long long n, m, down = 0;
    cin >> n >> m;
    if (n > m)
    {
        swap(n, m);
    }
    if (n == 1)
    {
        if (m == 1)
        {
            down = 1;
        }
        else
        {
            down = m - 2;
        }
    }
    else
    {
        down = (n - 2) * (m - 2);
    }
    cout << down;
    return 0;
}


Measured memory_bytes: 504
#include<bits/stdc++.h>
#define vi vector<int>
#include <algorithm>
#include <iterator>
#include <inttypes.h>
#include<iostream>
using ll = long long;
using namespace std;

int main()
{
   long long w,n;
   cin >> n >> w;
   vector<long long> dp(w+1);
   for(long long item = 0; item<n;item++){
        long long weight,v;
        cin >> weight >> v;

        for(long long i= w-weight;i>=0;i--){
            dp[i+weight] = max(dp[i+weight], dp[i] + v);
        }
   }
   long long res = 0;
   for(long long i= 0;i<=w;i++){
       res = max(res, dp.at(i));
   }

	cout<< res;
   return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>

int main (void)

{

int a,b,d=0,r=0;

double f=0;

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

d=a/b;

r=a%b;

f=(double)a/b;

printf("%d %d %f\n",d,r,f);

return 0;

}

Measured memory_bytes: 632
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<cstring>
using namespace std;
const int maxn=1e3+5;


int main()
{
	int T;
	cin>>T;
	cout<<(T+1)/2<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(int)(a); i++)
typedef long long ll;
template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////
const ll inf = 1LL<<60;

int main()
{
  ll n,m,k; cin>>n>>m>>k;
  ll s = n*m;
  vector<bool> d(n*m+1, false);
  for (int i=0; i<=n; i++) {
    for (int j=0; j<=m; j++) {
      ll t = s - i*(m-j) - (n-i)*j;
      d[t] = true;
    }
  }
  if (d[k]) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 3688
#include <bits/stdc++.h>
#define sz(c)       int(c.size())
#define rep(i,a,b)  for (int i=a; i<(b); ++i)
#define per(i,a,b)  for (int i=(b)-1; i>=(a); --i)
#define fore(c,...) for (auto __VA_ARGS__:(c))
using namespace std;
typedef long long ll;



int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	cout<<fixed<<setprecision(10);

	int H,A;
	cin>>H>>A;
	cout<<(H+A-1)/A<<'\n';
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int M,N,s1,s2,sum=0;
    scanf("%d%d",&N,&M);
        s1=N*(N-1)/2;
        s2=M*(M-1)/2;
        sum=sum+s1+s2;
    printf("%d",sum);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define int long long
using namespace std;

typedef pair<int,int> P;

int N;
P tc[55];

void solve(){
  
  vector<P> times[2];
  
  int ans = 0;
  
  for(int i=0;i<N;i++){
    
    int stime, gtime;
    vector<P> tmp[2];
    
    for(int j=0;j<tc[i].second*2;j++){
      
      if( j == 0 ) stime = 0, gtime = tc[i].first;
      else stime = gtime, gtime = stime + tc[i].first;
      
      for(int k=0;k<(int)times[j%2].size();k++){
	
	int start = times[j%2][k].first;
	int goal = times[j%2][k].second;
	
	if( start + 1 <= stime && gtime <= goal - 1 ) gtime = goal;
	
      }
      
      tmp[j%2].push_back( P( stime, gtime ) );
      
    }
    
    ans = max( ans, gtime );
    
    for(int j=0;j<(int)tmp[0].size();j++) times[0].push_back( tmp[0][j] );
    for(int j=0;j<(int)tmp[1].size();j++) times[1].push_back( tmp[1][j] );
    
  }
  
  cout<<ans<<endl;
  
}

signed main(){
  
  while(1){
  
    cin>>N;
    if( !N ) break;
    
    for(int i=0;i<N;i++) cin>>tc[i].first>>tc[i].second;
  
    sort( tc, tc + N, greater<P>() );
  
    solve();
  
  }
  
  return 0;
}



Measured memory_bytes: 3424
#include<bits/stdc++.h>
#define ll long long int
#define mod 1000000007
#define pie (3.141592653589)
using namespace std;

const int N = 2e5 + 10;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout << fixed;
	cout.precision(10);
	
	int n;
	cin >> n;
	long long sol = 0;
	for(int i = 1; i <= n; i++)
	{
		sol += (n / i);
		if(n % i == 0)
			sol--;
	}
	cout << sol;
	
	return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;
const double pi = acos(-1.0);

ll dp[1100][11000];

int main() {
    ll h, n; cin >> h >> n;
    rep(i, 1100) rep(j, 11000) {
        if(j == 0) dp[i][j] = 0;
        else dp[i][j] = INF;
    }
    rep(i, n) {
        ll a, b; cin >> a >> b;
        rep(j, h+1) {
            chmin(dp[i+1][j], dp[i][j]);
            if(j <= a) chmin(dp[i+1][j], b);
            else chmin(dp[i+1][j], dp[i+1][j-a] + b);
        }
    }
    cout << dp[n][h] << endl;
}


Measured memory_bytes: 98144
#include<iostream>
#include<cstdlib>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;

typedef long long ll;
int main(){
  ll h,n;
  cin >> h >> n;
  ll sum=0,s;
  
  for(ll i=0; i<n; i++){
  	cin >> s;
    sum += s;
  }
  if(h>sum){
  	cout << "No" << endl;
  }else{
  	cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <vector>
#define rep(i,n) for (int i = 0;i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int INF = 1e9;

int main(){
    int n;cin >> n;
    vector<int> a(n);
    rep(i,n){
        int v;cin >> v;
        a[i] = v-i-1;
    }
    sort(a.begin(),a.end());
    int m = 0;
    while(n-2>2*m){
        m++;
    }
    m--;
    int b = a[m+1];
    ll ans = 0;
    rep(i,n){
        //cout << a[i] << endl;
        //cout << b << endl;
        ans += abs(a[i]-b);
    }

    cout << ans << endl;


}

Measured memory_bytes: 4056
#include<bits/stdc++.h>
using namespace std;
#define     siii(a,b,c)       scanf("%d%d%d",&a,&b,&c)
#define     si(a)             scanf("%d",&a)
#define     sii(a,b)          scanf("%d%d",&a,&b)
#define     sl(a)             scanf("%lld",&a);
#define     sll(a,b)          scanf("%lld%lld",&a,&b);
#define     slll(a,b,c)       scanf("%lld%lld%lld",&a,&b,&c);
#define     sd(a)             scanf("%lf",&a);
#define     sdd(a,b)          scanf("%lf%lf",&a,&b);
#define     pb(a)             push_back(a)
#define     deb(a)            printf("### %d ###\n",a)
#define     mp                make_pair
#define     pf                printf
#define     fl(a, b, c)       for(int a= b ;a<c;a++)
#define     mx                100000 //10^5
#define     fread             freopen("input.txt","r",stdin)
#define     CLR(a,b)          memset(a,b,sizeof(a))
#define     ll                long long
#define     D(x)              cout<<#x" = "<<x<<endl;
#define     sz                10000
#define     bl                printf("\n")
#define     spc               printf(" ")


int main()
{
    int n;
    cin>>n;
    int a = n/100;
    int b = n%100;
    if(a > 0 && a <= 12 && b > 0 && b <= 12)
    {
        cout << "AMBIGUOUS";
    }
    else if(a > 0 && a <= 12)
    {
        cout << "MMYY" ;
    }
    else if(b > 0 && b <= 12 )
    {
        cout << "YYMM" ;
    }
    else
    {
        cout << "NA" ;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define rv(s) reverse(s.begin(),s.end());
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;

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

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 GCD(int a, int b) { return b ? GCD(b, a%b) : a; }

int main()
{
  cin.tie( 0 );
  ios::sync_with_stdio( false );
  
  string s,t;
  cin>>s>>t;
  
  int ans=0;
  rep(i,3){
    if(s[i]==t[i])ans++;
  }
  
  cout(ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ld double
#define ll long long
#define pb emplace_back
#define mk make_pair
#define mod 1000000007
#define ff first
#define ss second
#define sz(x) (int)x.size()
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define all(x) x.begin(),x.end()
ll power(ll a, ll b) {ll res = 1; a = a % mod; while (b) {if (b & 1)res = (res * a) % mod; a = (a * a) % mod; b /= 2;} return res;}
ll invmod(ll a) {return power(a, mod - 2);}
int main(void)
{
	FIO
	int t = 1;
	// cin >> t;
	while (t--)
	{
		int n;
		int mxn = 1e6 + 1;
		cin >> n;
		int arr[mxn] = {0};
		arr[0] = 0;
		arr[1] = 1;
		for (int i = 2; i < mxn; i++) {
			if (arr[i] == 0) {
				for (int j = i; j <= mxn; j += i) {
					if (arr[j] == 0)
						arr[j] = i;
				}
			}
		}
		int v[n], freq[mxn] = {0};
		for (int &i : v) cin >> i;
		int gd = 0, fl = 0;
		for (int i = 0; i < n; i++) {
			int tmp = v[i];
			set<int> primes;
			while (tmp > 1 ) {
				primes.insert(arr[tmp]);
				tmp /= arr[tmp];
			}
			for (int j : primes) {
				if (freq[j]) {
					fl = 1;
				}
				// cout << j << " ";
				freq[j]++;
			}
			// cout << "\n";
			gd = __gcd(gd, v[i]);
		}
		if (fl == 0) cout << "pairwise coprime\n";
		else if (gd == 1) cout << "setwise coprime\n";
		else cout << "not coprime\n";
	}
	return 0;
}

Measured memory_bytes: 15316
#include <stdio.h>
int x,y,c;
int main()
{
  int a,b;
  for(;~scanf("%d,%d",&a,&b);)
    {
      x+=a*b;
      y+=b;
      c++;
    }
  b=(float)y/c+0.5;
  a=printf("%d\n%d\n",x,b);
  exit(0);
}

Measured memory_bytes: 592
#include<iostream>
#include<algorithm>

using namespace std;

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

	int kingaku[3];

	kingaku[0] = a + b;
	kingaku[1] = a + c;
	kingaku[2] = b + c;

	int ans = min({ kingaku[0],kingaku[1],kingaku[2] });

	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int P = (int)1e9+7;
		
		int cnt[] = new int[1010];
		
		for(int i=2;i<=n;i++){
			int t = i;
			for(int j=2;j*j<=t;j++){
				while(t%j==0){
					cnt[j]++;
					t/=j;
				}
			}
			if(t>1)
				cnt[t]++;
		}
		
		long ans = 1;
		for(int i=2;i<=n;i++){
			ans *= cnt[i]+1;
			ans%=P;
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 21716
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;

int main()
{
	double m;
	vector<double> v;
	while(cin >> m){
		v.push_back(m);
	}
	sort(v.begin(), v.end());
	cout << v[v.size() - 1] - v[0] << endl;
	return 0;
}

Measured memory_bytes: 1304
#include<iostream>
#include<stack>
#include<queue>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<string>
#include<cstring>
#include<map>
#include<numeric>
#include<sstream>
#include<cmath>
using namespace std;
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define pb push_back
#define f(i,x,y) for(int i = x; i<y; i++ )
#define FORV(it,A) for(vector<int>::iterator it = A.begin(); it!= A.end(); it++)
#define FORS(it,A) for(set<int>::iterator it = A.begin(); it!= A.end(); it++)
#define quad(x) (x) * (x)
#define mp make_pair
#define clr(x, y) memset(x, y, sizeof x)
#define fst first
#define snd second
typedef pair<int, int> pii;
typedef long long ll;
typedef long double ld;

#define N 100000
ll S[N], v[N];
int pd[N];
int W, n;


inline ll teto (ll a, ll b){
	return ((a-1)/b)+1;
	//if (a%b == 0) return a/b;
	//return a/b+1;
}

/*int solve (int E){
	pd[n] = 0;
	pd[n-1] = 1;
	for (int i = n-2; i >= 0; i--){
		int ini = i, fim = n-1;
		while (ini < fim-1){
			int mid = ((ini+fim)>>1);
			ll s = S[mid];
			if (i != 0) s -= S[i-1];
			if (s+mid-i <= W) ini = mid;
			else fim = mid-1;
		}
		int y;
		ll s = S[fim];
		if (i != 0) s -= S[i-1];
		if (s+fim-i <= W) y = fim;
		else y = ini;
		ini = i+1, fim = y;
		while (ini < fim){
			int mid = ((ini+fim)>>1);
			ll s = S[mid];
			if (i != 0) s -= S[i-1];
			if (teto(W-s, mid-i) <= E) fim = mid; //TODO
			else ini = mid+1;
		}
		s = S[y];
		if (i != 0) s -= S[i-1];
		int soma;
		if (teto(W-s, y-i) > E) soma = 0; //TODO
		else soma = pd[ini+1]-pd[y+2];
		if (y == n-1) soma = 1;
		pd[i] = pd[i+1];
		if (soma != 0) pd[i]++;
	}
	return pd[0]-pd[1];
}*/


ll V (int a, int b){
	ll s = S[b];
	if (a != 0) s -= S[a-1];
	return teto(W-s, b-a);
}

bool cabe (int a, int b){
	int mid = b, i = a;
	ll s = S[mid];
	if (i != 0) s -= S[i-1];
	return (s+mid-i <= W);
}

int solve (int E){
	pd[n] = 0;
	pd[n-1] = 1;
    int ini = n-1, fim = n-1;
    for (int i = n-2; i >= 0; i--){
        while (fim >= i){
            if (cabe(i, fim)) break;
            fim--;
        }
        int s;
        ini = min(ini,fim);
        if (V(i, fim) > E) s = 0;
        else{
            while (ini > i){
                if (ini == i+1 || V(i, ini-1) > E) break;
                ini--;
            }
            s = pd[ini+1]-pd[fim+2];
        }
        pd[i] = pd[i+1];
        if (fim == n-1) s = 1;
        if (s) pd[i]++;
        //printf("->i = %d ini = %d fim = %d s = %d %d\n", i,ini, fim, s, pd[i]);
    }
    return pd[0]-pd[1];
}


int main (){
	while (1){
		cin >> W >> n;
		if (W+n == 0) break;
		f (i, 0, n) cin >> S[i];
		f (i, 1, n) S[i] += S[i-1];
		int ini = 1, fim = W/2+1;
        //cout << solve(1) << endl; break;
		while (ini < fim){
			int mid = (ini+fim)/2;
			if (solve(mid)) fim = mid;
			else ini = mid+1;
		}
		printf("%d\n", ini);
	}
	return 0;
}

Measured memory_bytes: 1740
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		int n=in.nextInt();
		int K=in.nextInt();
		int[] a=new int[n];
		for (int i=0;i<n;++i) a[i]=in.nextInt();
		int[] dp=new int[n];
		for (int i=1;i<n;++i) dp[i]=Integer.MAX_VALUE;
		for (int i=0;i<n;++i)
			for (int k=1;i+k<n&&k<=K;++k) dp[i+k]=Math.min(dp[i+k],dp[i]+Math.abs(a[i+k]-a[i]));
		System.out.println(dp[n-1]);
	}
}

Measured memory_bytes: 50576
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<n; i++)
#define pb push_back
#define int long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
typedef pair<int, int> P;

int H, W;
int sx, sy, gx, gy;
char S[1010][1010];
vector<P> G[1000010];
int dist[1000010];
 
signed main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> H >> W >> sx >> sy >> gx >> gy;
    sx -= 1;
    sy -= 1;
    gx -= 1;
    gy -= 1;
    
    rep(i, H) rep(j, W) cin >> S[i][j];
    rep(i, H) rep(j, W) {
        if (S[i][j]=='#') continue;
        rep(k, 4) {
            int ni = i+dx[k];
            int nj = j+dy[k];
            if (ni<0 || ni>=H || nj<0 || nj>=W) continue;
            if (S[ni][nj]=='#') continue;
            G[W*i+j].pb(P(W*ni+nj, 0));
        }
        for (int ni=i-2; ni<=i+2; ni++) {
            for (int nj=j-2; nj<=j+2; nj++) {
                if (ni<0 || ni>=H || nj<0 || nj>=W) continue;
                if (S[ni][nj]=='#') continue;
                G[W*i+j].pb(P(W*ni+nj, 1));
            }
        }
    }
    rep(i, H*W) dist[i] = 100000000;
    deque<int> q;
    q.push_back(W*sx+sy);
    dist[W*sx+sy] = 0;
    while (q.size()) {
        int v = q.front(); q.pop_front();
        rep(i, G[v].size()) {
            int nv = G[v][i].first, w = G[v][i].second;
            if (dist[nv]>dist[v]+w) {
                if (w==0) {
                    dist[nv] = dist[v];
                    q.push_front(nv);
                }
                else {
                    dist[nv] = dist[v]+1;
                    q.push_back(nv);
                }
            }
        }
    }
    //rep(i, H*W) cout << dist[i] << endl;
    int ans = dist[W*gx+gy];
    if (ans==100000000) cout << -1 << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 206012
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int N, A, B, sum=0, ans=0;
    cin >> N >> A >> B;
    for(int i=1; i<=N; i++){
        sum=i/10000 + (i%10000)/1000 + (i%1000)/100 + (i%100)/10 + i%10;
        if(A<=sum && sum<=B){
            ans+=i;
        }
    }
    cout << ans << endl;
    
}

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

using namespace std;
int main()
{
	string s;
	cin >> s;

	int countA = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s.at(i) == 'A') {
			break;
		}
		countA++;
	}

	int countZ = 0;
	for (int i = s.size()-1 ; i > 0; i--) {
		if (s.at(i) == 'Z') {
			break;
		}
		countZ++;
	}

	int ret = s.size() - countA - countZ;

	std::cout << ret << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    char c; cin >> c;
    if(islower(c)) cout << "a" << endl;
    else cout << "A" << endl;
}

Measured memory_bytes: 3648
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<time.h>
#include<math.h>
#include<assert.h>
#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
#define pi 3.1415926535897932384
int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int zt(int a,int b){return max(a,b)-min(a,b);}
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
int nHr(int a,int b){return nCr(a+b-1,b);}
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
int dsum(int x){int r=0;while(x){r+=(x%10);x/=10;}return r;}
int dsumb(int x,int b){int r=0;while(x){r+=(x%b);x/=b;}return r;}
int sankaku(int x){return ((1+x)*x)/2;}
void swap(int *a,int *b){int c;c=(*a);(*a)=(*b);(*b)=c;}
//大きい順
int compareInt(const void* a, const void* b){int aNum = *(int*)a;int bNum = *(int*)b;return bNum - aNum;}

int main(void){
    int N;
    scanf("%d",&N);
    int sum=0;
    for(int i=0;i<=N;i++){
        sum+=i;
    }
    printf("%d",sum);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> list(n);
  for(int i=0; i<n; i++) {
    cin >> list.at(i);
  }
  sort(list.begin(),list.end());
  cout << list.at(list.size()-1)-list.at(0) << endl;
}

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

int mod = 1000000007;

int main()
{
    vector<int> list(3);
    for (int i = 0; i < 3; i++)
    {
        cin >> list[i];
    }
    sort(list.begin(), list.end());

    if (list[0] == 5 && list[1] == 5 && list[2] == 7)
        cout << "YES";
    else
        cout << "NO";
}

Measured memory_bytes: 256
class Dice

  def initialize
    dice   = gets.split.map(&:to_i)
    @action = gets.chomp
    @upper  = dice[0]
    @side   = [ dice[4], dice[2], dice[1], dice[3] ]
    @bottom = dice[5]
  end

  def print_upper
    @action.chars do |str|
      b = @bottom
      u = @upper
      case str
      when "N"
        @upper   = @side[2]
        @bottom  = @side[0]
        @side[2] = b
        @side[0] = u
      when "E"
        @upper   = @side[3]
        @bottom  = @side[1]
        @side[3] = b
        @side[1] = u
      when "S"
        @upper   = @side[0]
        @bottom  = @side[2]
        @side[0] = b
        @side[2] = u
      when "W"
        @upper   = @side[1]
        @bottom  = @side[3]
        @side[1] = b
        @side[3] = u
      end
    end
    puts @upper
  end
end

d = Dice.new
d.print_upper

Measured memory_bytes: 6116
#include <iostream>

using namespace std;

int main()
{
  int R, G, B, N;
  cin >> R >> G >> B >> N;

  int res = 0;
  for (int i = 0; i * R <= N; i++) {
	for (int j = 0; j * G + i * R <= N; j++) {
	  int tmp = N - (i * R + j * G);
	  if (tmp % B == 0)
		res++;
	}
  }

  cout << res << endl;  

  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a;
		a = sc.next();
		boolean r = true;
		
		char b[] = a.toCharArray();
		
		for(int i=0 ; i<a.length()-1 ; i++) {
		    for(int j=i+1 ; j<a.length() ; j++) {
		        if(b[i] == b[j]) {
		            r = false;
		            if(r == false) break;
		        }
		        else {
		            r = true;
		        }
		    }
		    if(r == false) break;
		}
		
		if(r == true) {
		    System.out.println("yes");
		}
		else {
		    System.out.println("no");
		}
	}
}

Measured memory_bytes: 21844
main = do
  [n,x] <- fmap (map read . words) getLine
  as <- fmap (map read . words) getLine
  let f [_] = 0
      f (a:b:as) = y + f (((b-y)`max`0):as)
        where y = (a+b-x)`max`0
  print $ f as

Measured memory_bytes: 36220
#include<bits/stdc++.h>
using namespace std;
 
int main () {
  int n;
  cin >>n;
  vector<string>s(n);
  for(int i=0;i<n;i++){
    cin>> s.at(i);
  }

  sort (s.begin(),s.end());
  int cnt =1;
  if (1 == n){
    cout<<cnt<<endl;
  } else{
  for (int i=0;i<n-1;i++){
    if(s.at(i) != s.at(i+1))cnt++;
  }
  cout<<cnt<<endl;
  }
  return 0;
}

Measured memory_bytes: 9604
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;
constexpr long long int INF = std::numeric_limits<long long int>::max();
constexpr long long int NINF = std::numeric_limits<long long int>::min();
#define int long long int

int v[2][100001];

pair<int, int> find(int n) {
  int a = 0, b;
  for (int i = 0; i <= 100000; i++) {
    if (a < v[n][i]) {
      a = v[n][i];
      b = i;
    }
  }
  return make_pair(a, b);
}

void solve() {
  int N;
  cin >> N;

  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;
    v[i % 2][x]++;
  }

  auto a = find(0);
  auto b = find(1);
  if (a.second != b.second) {
    cout << N - a.first - b.first << endl;
  } else {
    v[0][a.second] = 0;
    auto a2 = find(0);

    v[1][b.second] = 0;
    auto b2 = find(1);

    int ans = min(N - a.first - b2.first, N - a2.first - b.first);
    cout << ans << endl;
  }
}

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


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

#define dforsn(i,s,n) for(int i=int(n-1);i>=int(s);i--)
#define forsn(i,s,n) for(int i=int(s);i<int(n);i++)
#define dforn(i,n) for(int i=int(n-1);i>=0;i--)
#define forn(i,n) for(int i=0;i<int(n);i++)
#define D(a) cerr << #a << " = " << a << endl
#define all(a) a.begin(),a.end()
#define si(a) int((a).size())
typedef pair<int,int> pii;
typedef long long int ll;
typedef vector<int> vi;
#define pb emplace_back
#define mp make_pair
#define snd second
#define fst first

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    
    int x; cin >> x;
    cout << (x/500 * 1000) + (x % 500 / 5 * 5) << endl;

    return 0;
}


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

typedef long long ll;

void bubble(vector<pair<char,int> > &v,int n){
    for(int i=0;i<n;i++){
        for(int j=0;j<n-i-1;j++){
            if(v[j].second>v[j+1].second)swap(v[j],v[j+1]);
        }
    }
}

void select(vector<pair<char,int> > &v,int n){
    for(int i=0;i<n;i++){
        int mij=i,mi=v[i].second;
        for(int j=i;j<n;j++){
            if(mi>v[j].second){
                mi=v[j].second;
                mij=j;
            }
        }
        swap(v[i],v[mij]);
    }
}


int main(){
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<pair<char,int> > card(n);
    string s;
    for(int i=0;i<n;i++){
        cin >> s;
        card[i].first=s[0];
        card[i].second=s[1]-'0';
    }
    vector<pair<char,int> > bs(card);
    vector<pair<char,int> > ss(card);

    bubble(bs,n);
    select(ss,n);

    for(int i=0;i<n;i++)cout << (char)bs[i].first << bs[i].second << (i!=n-1?" ":"\n");
    cout << "Stable\n";
    for(int i=0;i<n;i++)cout << (char)ss[i].first << ss[i].second << (i!=n-1?" ":"\n");
    cout << (bs==ss?"Stable":"Not stable") << endl;
}



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

string s;
bool f;

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> s;
	if(s[0] != 'A') f = true;
	int t = 0;
	for(int i=2; i<s.size()-1; ++i){
		if(s[i] == 'C'){
			t = i;
			break;
		}
	}
	if(t == 0) f = true;
	for(int i=1; i<s.size(); ++i){
		if(i == t) continue;
		if(s[i] < 'a' || 'z' < s[i])
			f = true;
	}
	if(f) cout << "WA\n";
	else cout << "AC\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using ll = long long;

int main(){
  int N;
  cin>>N;
  vi A(N+1),B(N);
  for(int i=0; i<N+1; i++)cin>>A[i];
  for(int i=0; i<N; i++)cin>>B[i];
  ll ans = 0;
  for(int i=0; i<N; i++){
    if(A[i] >= B[i]){
      ans += B[i];
    }else if(A[i] < B[i]){
      ans += A[i];
      int r = B[i] - A[i];
      if(A[i+1] >= r){
        ans += r;
        A[i+1] -= r;
      }else if(A[i+1] < r){
        ans += A[i+1];
        A[i+1] = 0;
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
 
using namespace std;
int main()
{
    long A;
    long B;
    long K;
	int  ans1;
	int  ans2;

    cin >> K;
    cin >> A >> B;
 
    ans1 = A/K;
    ans2 = B/K;
 
	if((ans2-ans1) != 0){
	    cout << "OK" << endl;
	}
	else if(A % K == 0){
	    cout << "OK" << endl;
	}
	else{
	    cout << "NG" << endl;
	}
 
    return 0;
}

Measured memory_bytes: 3632
// ====================================
//   author: M_sea
//   website: https://m-sea-blog.com/
// ====================================
#include <bits/stdc++.h>
#define file(x) freopen(#x".in","r",stdin); freopen(#x".out","w",stdout)
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
typedef long long ll;

int read() {
	int X=0,w=1; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
	while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
	return X*w;
}

const int N=50+10;

char s[N];
int o[256],t[256];

int main() {
	int n=read();
	memset(o,0x3f,sizeof(o));
	for (int i=1;i<=n;++i) {
		scanf("%s",s+1); int l=strlen(s+1);
		for (char j='a';j<='z';++j) t[j]=0;
		for (int j=1;j<=l;++j) ++t[s[j]];
		for (char j='a';j<='z';++j) o[j]=min(o[j],t[j]);
	}
	for (char i='a';i<='z';++i)
		while (o[i]--) putchar(i);
	return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
#define e_b emplace_back
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
using namespace std;
using ll = long long;
using ld = long double;
template<class T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<class T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0;i<N;i++)  cin >> A.at(i);
  A.p_b(-10000);

  ll ans=1000;
  ll kabu=0;
  for(int i=0;i<N;i++){
    ans+=kabu*A.at(i);
    kabu=0;
    if(A.at(i)<A.at(i+1)){
      kabu=ans/A.at(i);
      ans%=A.at(i);
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3628
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
INF = 10 ** 9
def dfs(cur, a, b, c):
    if cur == N:
        return abs(a - A) + abs(b - B) + abs(c - C) - 30 if a * b * c > 0 else INF
    ret0 = dfs(cur + 1, a, b, c)
    ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
    ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
    ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
    return min(ret0, ret1, ret2, ret3)

print(dfs(0, 0, 0, 0))

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<string>
#include<sstream>
#include<cmath>
#include<climits>
#include<algorithm>
#include<bitset>
#include<set>
#include<stack>
#include<queue>
#include<iomanip>
#include<memory.h>
#include<complex>
using namespace std;  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef tuple<int,int> tii;
#define rep(i,n) for(ll i=0;i<(n);i++)  
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second  
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
const double PI = M_PI;  
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define SHOWARRAY(ar,i,j) REP(a,i)REP(b,j)cerr<<ar[a][b]<<((b==j-1)?((a==i-1)?("\n\n"):("\n")):(" "))
#define DIV int(1e9+7)
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}

/* Coding Space*/
using tiii = tuple<int,int,int>;
int ans = INF;

int n,ma,mb;

int dp[41][500][500]; // =cost

int main(){
  cin >> n >> ma >> mb;
  fill_n(dp[0][0],41*500*500,INF);
  dp[0][0][0] = 0;
  rep(i,n){
    int a,b,c; cin >> a>> b >> c;
    rep(j,500)rep(k,500)
      if(dp[i][j][k] != INF){
        dp[i+1][j][k] = min(dp[i+1][j][k],dp[i][j][k]);
        dp[i+1][j+a][k+b] = min(dp[i+1][j+a][k+b],dp[i][j][k] + c);
        if((j+a)*mb == (k+b)*ma) ans = min(ans,dp[i+1][j+a][k+b]);
      }
  }
  cout << (ans==INF?-1:ans) << endl;
}

Measured memory_bytes: 40320
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <queue>
#include <set>
#include<deque>
#include <regex>
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define per(i,n) for(ll i=n-1;i>=0; --i)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
using namespace std;
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; }
const long long INF = 1LL << 60;
typedef long long ll;
const ll MOD = 1000000007;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, cnt = 0, cnter = 1; 
	cin >> n;
	vector<ll>a(n);
	rep(i, n)cin >> a[i];
	for (ll i = 0; i < n; i++) {
		if (a[i] == cnter) {
			cnter++;
			cnt++;
		}
	}
	cout << (cnt == 0 ? -1 : n - cnt) << endl;
}




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

int alpha,beta;

char f(int c) {
    if(c == ' ') return ' ';
    return (char)(((alpha*(c-'a')+beta)%26)+'a');
}

int main() {
    int n;
    string in;
    cin>>n;
    cin.ignore();
    while(n--) {
        getline(cin, in);
        for(alpha = 2; alpha<26000; ++alpha) {
            if(26%alpha == 0) continue;

            for(beta = 0; beta <26; ++beta) {
                string ci = in;
                for(int i=0; i<ci.length(); ++i)
                    ci[i] = f(ci[i]);


                if(ci.find("this") != string::npos || ci.find("that") != string::npos) {
                    cout<<ci<<endl;
                    goto END;
                }
            }
        }
    END:;
    }
}

Measured memory_bytes: 0
/*input
1 2
3 3
3
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
 
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
#define ll long long 
#define ld long double
#define pii pair<int,int>
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define MP make_pair
const ll INF64=4e12;
const int INF=0x3f3f3f3f;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
ll mult(ll a,ll b){
    return ((a%MOD)*(b%MOD))%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1){
            res=(res*a)%MOD;
        }
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
const ll maxn=1e6+5;
const ll maxlg=__lg(maxn)+2;
int main(){
    ios::sync_with_stdio(false),cin.tie(0);
    ll a,v,b,w,t;
    cin>>a>>v>>b>>w>>t;
    if(a!=b and v<=w){
        cout<<"NO";
    }
    else{
        if(a==b) cout<<"YES";
        else{
            if(abs(a-b)<=t*(v-w)){
                cout<<"YES\n";
            }
            else cout<<"NO";
        }
    }
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MOD	1000000007
#define int	long long
#define pii pair<int,int> 
#define vi vector<int>
using namespace std;

int modmul(int a, int b, int mod){
	int res = 0;
	a %= mod;
	while(b > 0){
		if(b&1)
			res = (res+a)%mod;
		a = (a*2)%mod;
		b >>= 1;
	}
	return res;
}


int32_t main(){
	int n;
	cin >> n;
	int a[n+2];
	for(int i = 1; i <= n; i++)
		cin >> a[i];
		
	int dp[n+2][62];
	
	memset(dp,0,sizeof dp);
	
	for(int i = n; i >= 0; i--){
		for(int j = 0; j < 61; j++){
			dp[i][j] = dp[i+1][j];
		}
		for(int j = 0; j < 61; j++){
			if(a[i]&(1LL<<j))
				dp[i][j]++;
		}
	}
	
	int ans = 0;
	for(int i = 1; i <= n-1; i++){
		for(int j = 0; j < 61; j++){
			if(a[i]&(1LL<<j)){
				ans += modmul((1LL<<j),(n-i)-dp[i+1][j],MOD);
			}
			else
				ans += modmul((1LL<<j),dp[i+1][j],MOD);
			ans %= MOD;
		}
	}
	if(ans < 0)
		ans += MOD;
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 147840
a = input()
b = input()
c = input()
a_pos = 0
b_pos = 0
c_pos = 0
now = 'a'

while True:
    if now == 'a':
        if len(a) < a_pos + 1:
            print('A')
            break
        now = a[a_pos]
        a_pos += 1
    elif now == 'b':
        if len(b) < b_pos + 1:
            print('B')
            break
        now = b[b_pos]
        b_pos += 1
    elif now == 'c':
        if len(c) < c_pos + 1:
            print('C')
            break
        now = c[c_pos]
        c_pos += 1

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
using namespace std;
int main() {
  string S;
  cin >>S;
  int a[2]={ };
  for(int i=0; i<3;i++){
    if(S[i]=='a') a[0]++;
    else if(S[i]=='b') a[1]++;
    else a[2]++;
  }
  if(a[0]==1 && a[1]==1 &&a[2]==1) cout <<"Yes"<<endl;
  else cout <<"No"<<endl;
}


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

#define fastIO() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'

int main()
{
 fastIO();
 long long n , cnt = 0 , divCnt;
 cin>>n;
 
 for(int i=1; i<=n; i=i+2) //run with odds 
{	
		divCnt=0;
	for(int j=1; j<=i; j++)
	{
		if(i%j == 0)
		{
			divCnt++;
		}
	}
	if(divCnt == 8) // exact 8 divs.
	{
		cnt++;
	}
}

cout<< cnt << endl;

return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main () {
    int N;
    cin >> N;
    map<string, int> s;
    for (int i = 0; i < N; i++) {
        string _s;
        cin >> _s;
        s[_s]++;
    }
    int M;
    cin >> M;
    map<string, int> t;
    for (int i = 0; i < M; i++) {
        string _t;
        cin >> _t;
        t[_t]++;
    }
    int ans = 0;
    for (auto x: s) {
        ans = max(x.second - t[x.first], ans);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;
const int MOD = 1000000007;

int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

signed main(){
    
    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    
    vector<int> ans(n);
    ans[0] = 0;
    for(int i = 1; i < n; i++){
        int val = a[i - 1] - ans[i - 1];
        ans[i] = val;
    }

    int val = a[n - 1] - ans[n - 1];
    ans[0] = val / 2;

    for(int i = 1; i < n; i++){
        int val = a[i - 1] - ans[i - 1];
        ans[i] = val;
    }
    

    for(int i = 0; i < n; i++){
        if(i + 1 == n) cout << ans[i] * 2 << endl;
        else cout << ans[i] * 2 << " ";
    }
    


    return 0;
}


Measured memory_bytes: 2944
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
 
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef pair<int, int> pi;


pi get(int n){
  int r = n % 10;
  int l = r;
  while (n){
    l = n % 10;
    n /= 10;
  }
  return pi{l, r};
}

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

  map<pi, int> mp;
  rep(i, n+1){
    pi key = get(i);
    if (key.second == 0) continue;
    mp[key]++;
  }

  ll ans = 0;
  for (int i=1;i<10;i++){
    for(int j=1;j<10;j++){
      if (mp[pi(i, j)] < 1) continue;
      ans += mp[pi(i, j)] * mp[pi(j, i)];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256