akhauriyash/Code-Regression huggingface dataset:
#ifdef local_mode
    #include <cstdio>
    #include <cassert>
#endif
#include <iostream>
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
#define pb push_back
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)

int main() {
#ifdef local_mode
    ios_base::sync_with_stdio(0), cin.tie(0);
    assert(freopen("in", "r", stdin));
    assert(freopen("out", "w", stdout));
#endif
    
    int n,m;
    cin >> n >> m;
    vector<pii> v(m);
    for (int i = 0; i < m; i++) {
        cin >> v[i].first >> v[i].second;
    }
    sort(v.begin(), v.end());
    int i = 0;
    int cnt = 0;
    while (i < m) {
        int amax = v[i].first;
        int bmin = v[i].second;
        i++;
        while (i < m && v[i].first < bmin) {
            amax = max(amax, v[i].first);
            bmin = min(bmin, v[i].second);
            i++;
        }
        cnt++;
    }
    cout << cnt;
    
    return 0;
}







































Measured memory_bytes: 1024
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using i64 = int64_t;
using f80 = __float80;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

i64 pow_mod(i64 n, i64 k, i64 m){
  i64 r = 1;
  for(;k;k>>=1){
    if(k&1) r=(r*n)%m;
    n=(n*n)%m;
  }
  return r;
}

void Main()
{
  i64 N, K;
  cin >> N >> K;

  i64 ans = 1;
  ans += i64(N) * i64(N+1) * i64(N+1) / 2;
  ans += N+1;
  ans -= i64(N) * i64(N+1) * i64(2*N+1) / 6;
  ans += i64(K-1) * i64(K) * i64(2*K-1) / 6;
  ans -= i64(N+1) * i64(K-1) * i64(K) / 2;
  ans -= K;
  ans %= MOD;

  cout << ans << endl;
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}

Measured memory_bytes: 3692
import math

# doubling

n, k = list(map(int, input().split()))
nums = [-1] + list(map(int, input().split()))
doubling =[[0 for _ in range(n + 1)] for _ in range(62)]

for i in range(62):
	for j in range(1, n + 1):
		if i == 0:
			doubling[i][j] = nums[j]
		else:
			doubling[i][j] = doubling[i - 1][doubling[i - 1][j]]

cur = 1
for i, x in enumerate(bin(k)[2:][::-1]):
	if x == "1":
		cur = doubling[i][cur]
print(cur)


Measured memory_bytes: 218852
#include<bits/stdc++.h> 
using namespace std; 
//python interactive_runner.py python3 local_testing_tool.py 0 -- ./Code
 
#define x first
#define y second
#define rep(i, a,b) for(int i = int(a); i < int(b); ++i)
#define forn(i,b) for(int i = 0; i < int(b); ++i)
typedef pair<int, int> pii;
const int MAXA = 1000000001;
const int MAXN = 10001;
const long long INF = 6000000000000000000;
vector<long long> pr(3);
vector<long long> divv(3);
map<long long,long long> dp;
long long N1,A,B,C,D; 
long long max_co(long long N){
	//cout<<N<<endl;
	if(dp.count(N)){
		return dp[N];
	}
	long long ans = INF;
	if(N==1) return D;
	if(N==0) return 0;
	vector<int> aii(3,0);
	if(N%2 == 0){
		aii[0] = 1;
		long long p = max_co(N/2);
		ans = min(p+A,ans);
		if((N/2)<INF/D){
			ans = min(p+((N/2)*D),ans);
		}
	}
	if(N%3==0){
		aii[1] = 1;
		long long p = max_co(N/3);
		ans = min(p+B,ans);
		if(((N*2)/3)<INF/D){
			ans = min(p+(D*((N*2)/3)),ans);
		}
	}
	if(N%5==0){
		aii[2] = 1;
		long long p = max_co(N/5);
		ans = min(p+C,ans);
		if((N*4)/5 <INF/D){
			ans = min(p+(D*((N*4)/5)),ans);
		}
	}
	forn(i,3){
		if(!aii[i]){
			long long down = ((N/pr[i]))*pr[i];
			long long up   = (N/pr[i])+1;
			if(up<N){
				long long p = max_co(up);
				ans = min(p+divv[i]+(D*((up*pr[i])-N)),ans);	
			}
			
			ans = min(ans,max_co(down)+((N-down)*D));
		}
	}
//	cout<<"ans "<<N<<" "<<ans<<endl;
	dp[N] = ans;
	return ans;
}
void solve(){
	dp.clear();
	cin>>N1>>A>>B>>C>>D;
	dp[0] = 0;
	dp[1] = D;
	divv[0] = A; divv[1] = B; divv[2] = C;
	pr[0] = 2;
	pr[1] = 3;
	pr[2] = 5;
	cout<<max_co(N1)<<'\n';
}
int main(){
	ios_base::sync_with_stdio(false);
	int T;
	cin>>T;
	forn(j,T) solve();
	return 0;
}

Measured memory_bytes: 8972
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
typedef long long ll;

const ll maxn = 1e5 + 1;
ll n,a[maxn],dp[maxn][2];

int main ()
{
	cin >> n;
	
	for ( ll i = 0 ; i < n ; ++ i )
	   cin >> a[i];
	
	dp[0][0] = a[0];
	dp[0][1] = - a[0];
	
	for ( ll i = 1 ; i < n ; ++ i )
	{
		dp[i][0] = max ( dp[i-1][0]+a[i] , dp[i-1][1]-a[i] );
		dp[i][1] = max ( dp[i-1][0]-a[i] , dp[i-1][1]+a[i] );
	}
	
	cout << dp[n-1][0] << endl;
	
	return 0;
	
}

Measured memory_bytes: 2560
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from math import gcd
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, gcd
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().rstrip().split()
def S(): return sys.stdin.readline().rstrip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]

mod=10**9+7



a,b,c,d=LI()
print(max(a*c,a*d,b*c,b*d))

Measured memory_bytes: 76768
#include<stdio.h>

int main(void)

{

  int n,cnt=0;

  scanf("%d",&n);

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

    int tmp;

    scanf("%d",&tmp);

   if(tmp==cnt+1) cnt++;

  }

  if(cnt==0) printf("-1");

  else printf("%d",n-cnt);

  return 0;

}

Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
const int fx[4]={0,1,0,-1};
const int fy[4]={1,0,-1,0};
const int N=20+10;
int f[N][N],n,m,ans;
inline int ma(int a,int b){return a>b?a:b;}
char s[N][N];
void dfs(int x,int y,int sum)
{
	if(x>n||x<1||y>m||y<1||s[x][y]=='#')return;
	if(f[x][y]<=sum)return;
	f[x][y]=sum;
	for(int i=0;i<4;i++)
		dfs(fx[i]+x,fy[i]+y,sum+1);
	return;
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		scanf("%s",s[i]+1);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			if(s[i][j]!='#')
			{
				memset(f,0x3f,sizeof(f));
				dfs(i,j,0);
				for(int x=1;x<=n;x++)
					for(int y=1;y<=n;y++)
						if(f[x][y]!=0x3f3f3f3f)ans=ma(ans,f[x][y]);
			}
	printf("%d",ans);
	return 0;
}

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

int main(){
	int x1,y1,x2,y2,x3,y3,x4,y4;
	cin >> x1 >> y1 >> x2 >> y2;
	x3=x2+y1-y2;
	y3=y2-x1+x2;
	x4=x1-y2+y1;
	y4=x2-x1+y1;
	cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  int C = 100;  
  
  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    
    int B = 0;
    for (int j = 0; j < 30; j++) {
      if (A % 2 == 0) {
      B += 1;
      A /= 2;
      }
      else if (A % 2 == 1)
        break;
    }
      if (B <= C)
        C = B;
  }   
      cout << C << endl;
}


Measured memory_bytes: 256
n = int(input())
s = input()
point = 0

# 暗証番号を全探索する
for i in range(1000):
    t = str(i).zfill(3)
    now = 0
    # sで暗証番号が作れるかを検証
    for j in s:
        if j == t[now]:
            now += 1
        if now == 3:
            point += 1
            break

print(point)

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

int main(){

    int n;
    int dif=0;
    cin>>n;
    vector<int> p(n);
    for(int i=0;i<n;i++){
        cin>>p[i];
        if(p[i]!=i+1) dif++;
    }

    cout<<(dif<=2?"YES":"NO")<<endl;






    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
int main()
{
    long long  int n,a,b=0,i,j,k,r=0,g=0,m=0;
    string s;
    cin>>n;
    cin>>s;
    for(i=0; i<n; i++)
    {
    if(s[i]=='R')
        r++;
    else if(s[i]=='G')
        g++;
    else
        m++;
    }
    if(r>=2)
    {
    if(g>0)
    b=b+r*(r-1)*g/2;
    if(r>2)
        b=b+(r-2)*r*(r-1)/6;
    if(m>0)
       b=b+r*(r-1)*m/2;
    }
    if(g>=2)
      {
    if(r>0)
    b=b+g*(g-1)*r/2;
    if(g>2)
        b=b+(g-2)*g*(g-1)/6;
    if(m>0)
       b=b+g*(g-1)*m/2;
    }
      if(m>=2)
    {
    if(g>0)
    b=b+m*(m-1)*g/2;
    if(m>2)
        b=b+(m-2)*m*(m-1)/6;
    if(r>0)
       b=b+m*(m-1)*r/2;
    }
    if((r==0||g==0)||m==0)
    {
     cout<<"0"<<endl;
     return 0;
    }
    a=(n*(n-1)*(n-2))/6;
    for(i=0; i<n; i++)
    {
        for(j=i+1; j<n; j++)
        {
        if((i+j)%2==0&&i!=j){
        if(s[i]!=s[j]&&(s[j]!=s[(i+j)/2]&&s[i]!=s[(i+j)/2]))
            {b=b+1;
            //cout<<s[i]<<" "<<s[j]<<" "<<s[(i+j)/2]<<endl;
            }
        }}
    }
   //cout<<a<<" "<<b<<endl;
   a=a-b;
   cout<<a<<endl;
}


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

int mat[501][501];

int main() {
  int n,m,q;
  cin>>n>>m>>q;
  memset(mat,0,sizeof(mat));
  rep(_i,m) {
    int l,r;
    cin>>l>>r;
    for(int i=1; i<=l; i++) {
      mat[i][r]+=1;
    }
  }
  for(int i=1; i<=n; i++) {
    for(int j=1; j<=n; j++) {
      mat[i][j]=mat[i][j]+mat[i][j-1];
    }
  }
  rep(i,q) {
    int a,b;cin>>a>>b;
    cout<<mat[a][b]<<endl;
  }
  return 0;
}


Measured memory_bytes: 1920
#include <iostream>
#include <vector>
#include <stdlib.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repp(i, j, k) for(int i = j; i < k; i++)

using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	//rep(i, n) cin >> a.at(i);
	
	long long total = 0;
	
	cin >> a.at(0);
	repp(i, 1, n){
		cin >> a.at(i);
		if(a.at(i) < a.at(i-1)){
			int s_height = a.at(i-1) - a.at(i);
			//cout << s_height << endl;
			total += s_height;
			a.at(i) += s_height;
		}
	}
	
	cout << total << endl;
	
	
}


Measured memory_bytes: 4048
/*
======================
[     ___T_          ]
[    | 6=6 | =>HI :-)] 
[    |__o__|         ]
[ >===]__o[===<      ]
[     [o__]          ]
[      .".           ]
[      |_|           ]
[                    ]
======================
 */

#include<bits/stdc++.h>
using namespace std;
using lli = int64_t;
int main(){
	 ios::sync_with_stdio(false);
	 cin.tie(nullptr);
	 cout.tie(nullptr);
	 int T = 1;
	 for(int t = 1; t <= T; t++){
		 int n;
		 cin >> n;
		 cout << (n + 1) / 2 << "\n";
	 }
}



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

using namespace std;
using ll = long long;
using vi = vector<int>;
using vii = vector<vi>;

const long long int llinf = 1LL << 62;
const int inf = 99999999;
const int dx[4] = { 1,0,-1,0 };
const int dy[4] = { 0,1,0,-1 };

#define Endl endl
#define pr(x) cout << x << endl
#define FOR(i,a,b) for(int i = a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb(a) push_back(a);
#define mp(a,b) make_pair(a,b)
#define atcoder int(1e9) +7;
#define chmax(x,y) x = max(x,y);
#define chmin(x,y) x = min(x,y);
#define all(x) x.begin,x.end();

int main() {
	
	int n;
	cin >> n;
	int t[1010], a[1010];
	rep(i, n)cin >> t[i] >> a[i];

	ll A = 1,B= 1;

	rep(i, n) {
		ll m = max(A / t[i]+((A%t[i] == 0)?0:1), B / a[i] + ((B % a[i] == 0) ? 0 : 1));
		A = m * t[i];
		B = m * a[i];
		//cout << A << ' ' << B << endl;
	}

	pr(A + B);

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
//#pragma comment(linker, "/STACK:1024000000,1024000000")

using namespace std;

#define ll long long
#define SZ(x) ((int)(x).size()) 
#define ALL(v) (v).begin(), (v).end()
#define foreach(i, v) for (__typeof((v).begin()) i = (v).begin(); i != (v).end(); ++ i)
#define reveach(i, v) for (__typeof((v).rbegin()) i = (v).rbegin(); i != (v).rend(); ++ i) 
#define REP(i,a,n) for ( int i=a; i<int(n); i++ )
#define FOR(i,a,n) for ( int i=n-1; i>= int(a);i-- )
#define lson rt<<1, L, m
#define rson rt<<1|1, m, R
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define mp(x, y) make_pair(x, y)
#define pb(x) push_back(x)
#define fi first
#define se second
#define CLR(a, b) memset(a, b, sizeof(a))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define lowbit(x) (x) & (-(x))
const int N = 1e5 + 7;
const int INF = 1e9 + 7;
int n;
int k;
int a[N];
int vis[N];
vector<int> G[N];
int mi[N], mx[N];
void prod(int u, int v){
    if(vis[v]){
        int ok = 1;
        if(vis[u] && (mi[u] - mi[v]) % 2 == 0) ok = 0;
        Max(mi[u], mi[v] - 1);
        Min(mx[u], mx[v] + 1);
        vis[u] = 1;
        if(mi[u] > mx[u]) ok = 0;
        if(!ok){
            puts("No");
            exit(0);
        }
    }
}
void dfs(int u, int f){
    if(f) prod(u, f);
    for(auto v : G[u]){
        if(v == f) continue;
        dfs(v, u);
        prod(u, v);
    }
}
int main(){
#ifdef LOCAL_TEST
    freopen("in.txt","r",stdin);
#endif
    //freopen("out.txt","w",stdout);
    scanf("%d", &n);
    REP(i, 1, n){
        int u, v;
        scanf("%d%d", &u, &v);
        G[u].pb(v);
        G[v].pb(u);
    }
    scanf("%d", &k);
    int v, p;
    CLR(a, -1);
    fill(mi + 1, mi + n + 1, -INF);
    fill(mx + 1, mx + n + 1, INF);
    REP(i, 0, k){
        scanf("%d%d", &v, &p);
        a[v] = p;
        vis[v] = 1;
        mi[v] = mx[v] = p;
    }
    dfs(1, 0);
    dfs(1, 0);
    puts("Yes");
    REP(i, 1, n + 1)
        printf("%d\n", mi[i]);
    return 0;
}


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

using namespace std;

#define REP(i,m) for(int i=0; i<m; i++)
#define FOR(i,n,m) for(int i=n; i<m; i++)
#define INF 1000000007
#define INFL (1LL << 60)
#define MOD 998244353
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define ll long long int
#define P pair<ll, ll>

int main(){
	int a, b, c, d, e, f, g, h;
	cin >> a >> b >> c >> d >> e >> f >> g >> h;
	cout << max(a+b+c+d, e+f+g+h) << endl;
	return 0;
} 


Measured memory_bytes: 3084
h, w = gets.split.map(&:to_i)

(c = {}).default = 0
h.times {gets.chomp.each_char {|e| c[e] += 1}}

(x = {}).default = 0
c.each_value {|e| x[e % 4] += 1}

case 2 * (h % 2) + w % 2
when 3
    puts x[1] + x[3] == 1 && (x[2] + x[3]) * 2 <= h + w - 2 && (h + w - 2 - (x[2] + x[3]) * 2) % 4 == 0 ? "Yes" : "No"
when 2
    puts x[1] + x[3] == 0 && x[2] * 2 <= w && (w - x[2] * 2) % 4 == 0 ? "Yes" : "No"
when 1
    puts x[1] + x[3] == 0 && x[2] * 2 <= h && (h - x[2] * 2) % 4 == 0 ? "Yes" : "No"
when 0
    puts x[1] + x[2] + x[3] == 0 ? "Yes" : "No"
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define um unordered_map
#define fi first
#define se second
#define start auto timeStart = chrono::steady_clock::now()
#define stop auto timeStop = chrono::steady_clock::now()
#define print cout<<chrono::duration_cast<chrono::milliseconds>(timeStop-timeStart).count()<<endl

void solve()
{
   
}

int main()
{   
   fast;

    ll n; cin>>n;
    ll arr[n+1]; arr[0]=0;
    for(ll i=1; i<=n; i++)
        cin>>arr[i];
    ll dp[n+1];
    dp[0]=0;
    dp[1]=0;
    dp[2]=abs(arr[2]-arr[1]);
    
    for(ll i=3; i<=n; i++)
    {
        dp[i] = min(dp[i-2]+abs(arr[i]-arr[i-2]), dp[i-1]+abs(arr[i]-arr[i-1]));
    }
    
    cout<<dp[n]<<endl;
    return 0;
}


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

int main() {
  	int n;
  	cin >> n;
  	long long sum = 0;
  	for (int i = 1; i <= n; ++i) {
  		if (i%3 == 0) continue;
      	if (i%5 == 0) continue;
      	sum += i;
    }
  	cout << sum << endl;
 	return 0; 
}

Measured memory_bytes: 3636
#!/usr/bin/env python3


def main() -> None:
    N, M, X = rmi()
    C, A = [], []
    for n in range(N):
        args = rmi()
        C.append(args[0])
        A.append(args[1:])
    possible = False
    cost = sum(C)
    from itertools import product
    for bitset in product((True, False), repeat=N):
        test = [0] * M
        for n in range(N):
            if bitset[n]:
                test = [t + a for (t, a) in zip(test, A[n])]
        current_cost = sum([c for i, c in enumerate(C) if bitset[i]])
        if X <= min(test):
            cost = min(cost, current_cost)
            possible = True
    w(cost if possible else -1)


def int2bit(decimal: int, digits: int = 0) -> str:
    if digits <= 0:
        return '{:b}'.format(decimal)
    else:
        return ('{:' + str(digits) + 'b}').format(decimal)


def r() -> str:
    return input().strip()


def ri() -> int:
    return int(r())


def rmi(delim: str = ' ') -> tuple:
    return tuple(map(int, input().split(delim)))


def w(data) -> None:
    print(data)


def wm(*data, delim: str = ' ') -> None:
    print(delim.join(map(str, data)))


if __name__ == '__main__':
    import sys
    sys.setrecursionlimit(10 ** 9)
    main()


Measured memory_bytes: 9248
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using LP = pair<ll, ll>;
const double PI = 3.1415926535897932;

/* a と b の最大公約数を返す関数 */
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

int main()
{
	int A[3];
	cin >> A[0] >> A[1] >> A[2];

	int sum = A[0] + A[1] + A[2];
	if (22 <= sum) {
		cout << "bust" << endl;
	}
	else {
		cout << "win" << endl;
	}

	return 0;
}


Measured memory_bytes: 3636
n = int(input())
mod = 10 ** 9 + 7
def factorization(n):
    ans = {}
    for j in range(2, n + 1):
        temp = j
        for i in range(2, int(-(-j**0.5//1))+1):
            if temp%i==0:
                cnt=0
                while temp%i==0:
                    cnt+=1
                    temp //= i
                if i not in ans:
                    ans[i] = cnt % mod
                else:
                    ans[i] += cnt % mod

        if temp!=1:
            if temp not in ans:
                ans[temp] = 1
            else:
                ans[temp] += 1

        if len(ans) == 0 and temp != 1:
            ans[n] = 1
        #print(ans)
    return ans
mod = 10 ** 9 + 7
fact = factorization(n)
ans = 1
for i in fact.values():
    ans *= (i + 1) % mod
    #ans %= mod
print(ans % mod)

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

int main() {
  int W, H, N, X, Y, A;
  cin >> W >> H >> N;

  int B = 0, C = 0, D = 0, E = 0;

  for (int i = 0; i < N; i++) {
    cin >> X >> Y >> A;
    if (A == 1) B = max(B, X);
    else if (A == 2) C = max(C, W - X);
    else if (A == 3) D = max(D, Y);
    else E = max(E, H - Y);
  }

  cout << ((B + C < W && D + E < H) ? (W - B - C) * (H - D - E) : 0) << endl;
}

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

#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())
#define endl "\n"

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
void initialize( void );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;
template <typename T, typename K> struct P {
	T a; K b;
};
typedef struct {
	vector <int> to;
	int cost;
} edge;

int main( void ){
	// initialize();
	int K;
	string S;
	cin >> K >> S;
	if (S.size() <= K)
		cout << S << endl;
	else
		cout << S.substr(0, K) << "..." << endl;
}

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* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}
void initialize( void ){
	cout << fixed << setprecision( 10 );
}


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

ll solve() {
    ll N, s = 0;
    cin >> N;
    vector<ll> A(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> A[i];
        s ^= A[i];
    }
    for ( int i = 0; i < N; i++ ) {
        if ( i > 0 ) cout << " ";
        cout << (s ^ A[i]);
    }
    cout << "\n";
    return 0;
}

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

Measured memory_bytes: 4736
nxt = input().split()
# print(nxt)
N = int(nxt[0])
X = int(nxt[1])
T = int(nxt[2])
# print(N,X,T)
tmp = N/X - int(N/X)
if tmp == 0:
    counter = int(N/X)
else:
    counter = int(N/X) + 1
# print(counter)
print(counter * T)

Measured memory_bytes: 9172
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))


delta = sorted([a - b for a, b in zip(A, B)], reverse=True)
if delta[-1] >= 0:
    print(0)
elif sum(delta) < 0:
    print(-1)
else:
    minus_sum = 0
    minus_cnt = 0
    for i in delta:
        if i < 0:
            minus_sum += i
            minus_cnt += 1

    for i, plus in enumerate(delta):
        if plus > 0:
            minus_sum += plus
        if minus_sum >=0:
            break
    print(minus_cnt + i + 1)


Measured memory_bytes: 18356
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,x;
    cin>>a>>b>>x;
    if(x>=a && a+b>=x){
        cout<<"YES"<<endl;
    }
    
    else if(x<=a){
        cout<<"NO"<<endl;
    }
    
    else cout<<"NO"<<endl;
}


Measured memory_bytes: 256
#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;

#define ll                 long long
#define LL                 long long
#define pii                pair<int, int>
#define pll                pair<ll, ll>
#define pil                pair<int, ll>
#define pli                pair<ll, int>
#define vi                 vector<int>
#define vl                 vector<ll>
#define vii                vector<pii>
#define vll                vector<pll>
#define vil                vector<pil>
#define vli                vector<pli>
#define pb                 push_back
#define mp                 make_pair
#define ff                 first
#define ss                 second
#define sz(x)              (int)x.size()
#define TN                 typename
#define all(v)             v.begin(), v.end()
#define fill(a, b)         memset(a, b, sizeof(a))
#define endl               '\n'
#define Int                in()
#define Long               Lin()
#define policy_set         tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define policy_multiset    tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>

template <TN T> T gcd(T a, T b) {return !b ? a : gcd(b, a % b);}
template <TN T> T lcm(T a, T b) {return a * (b / gcd(a, b));}
template <TN T> inline void smin(T &a, T b) {a = a < b ? a : b;}
template <TN T> inline void smax(T &a, T b) {a = a > b ? a : b;}

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << endl ;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << ", " ;
    err(++it, args...);
}

inline int in() {int n; scanf("%d", &n); return n;}
inline ll Lin() {ll n; scanf("%lld", &n); return n;}
inline double Din() {double n; scanf("%lf", &n); return n;}

const int mod        = (int)1e9 + 7;
const ll  Mod        = (ll)1e9 + 7;

inline int add(int a, int b) {a += b; return a >= mod ? a - mod : a;}
inline int sub(int a, int b) {a -= b; return a < 0 ? a + mod : a;}
inline int mul(int a, int b) {return (ll)a * b % mod;}

const int inf        = (int)2e9 + 5;
const ll  Inf        = (ll)1e18 + 5;
const int N          = 2e5 + 5;



int solve() {
    int x;
    cin>>x;
    cout<<(x==1 ? 0 : 1)<<endl;
    return 0;
}

int main() {
    //ios_base::sync_with_stdio(false); cin.tie(NULL);
    int test = 1, tc = 0;
    //scanf("%d", &test);
    //cin >> test;
    while (test--) {
        //printf("Case %d: ", ++tc);
        solve();
    }
    return 0;
}

Measured memory_bytes: 3580
import java.util.*;

class Main {
    static int n;
    static int m;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        m = sc.nextInt();
        String S = sc.next();
        String T = sc.next();
        long ans = help(S,T);
        System.out.println(ans);
    }
    static long help(String s, String t){
        for(int x2=0;x2<=m-1;x2++){
            long cur = ((long)n*x2);
            if(cur%((long)m)==0){
                int now = (int) (cur/((long) m));
                if(now<n){
                    if(s.charAt(now)!=t.charAt(x2)) return -1;
                }
            }
        }
        return ((long)n)/((long)gcd(m,n))*((long)m);
    }
    static int gcd(int m, int n){
        if(m<n){
            int temp = m;
            m = n;
            n = temp;
        }
        if(m%n==0) return n;
        else return gcd(n, m%n);
    }
}


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

using namespace std;
typedef long long ll;
#define sz(x) (ll)((x).size())
#define rep(i,n) for(ll i=0;i<(n);i++)

int main(){
	//input
	ll N; cin>>N;

    set<ll> se;
    rep(i,N){
        ll x; cin>>x;
        se.insert(x);
    }
    if(sz(se)%2==0) cout<<sz(se)-1;
    else cout<<sz(se);
}

Measured memory_bytes: 4992
/*
　　　∫ ∫ ∫
　　　ノヽ
　　（＿　 ）
　（＿　　　 ）
（＿＿＿＿＿＿ ）
　ヽ(´･ω･)ﾉ　
　　 |　 /
　　 UU
*/
#pragma region macro
#include <bits/stdc++.h>
typedef long long int64;
using namespace std;
using P = pair<int64, int64>;
typedef vector<int> vi;
const int MOD = (int)1e9 + 7;
const int64 INF = 1LL << 62;
const int inf = 1<<30;
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; }
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = s; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x << ": " << x << "\n";
#define mp make_pair
#define bn '\n'
template <typename T>
ostream& operator<<(ostream& os, vector<T> &V){
    int N = V.size();
    REP(i,N){
        os << V[i];
        if (i!=N-1) os << " ";
    }
    os << "\n";
    return os;
}
template <typename T,typename S>
ostream& operator<<(ostream& os, pair<T,S> const&P){
    os << "(";
    os << P.first;
    os << " , ";
    os << P.second;
    os << ")";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T> &S){
    auto it=S.begin();
    while(it!=S.end()){
        os << *it;
        os << " ";
        it++;
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, deque<T> &q){
    for(auto it=q.begin();it<q.end();it++){
        os<<*it;
        os<<" ";
    }
     os<<endl;
    return os;
}
vector<pair<int,int>> dxdy = {mp(0,1),mp(1,0),mp(-1,0),mp(0,-1)};
#pragma endregion
//fixed<<setprecision(10)<<ans<<endl;



vector<int> A;
int64 dfs(int l,int r,bool term,vector<vector<vector<int64>>>& memo){
    if(l==r) {
        if(term) return A[l];
        else return -A[l];
        
    }
    if(memo[l][r][term] != -INF){
        return memo[l][r][term];
    }

    int64& res = memo[l][r][term];
    if(term){
        res = max(A[l]+dfs(l+1,r,term^1,memo), A[r]+dfs(l,r-1,term^1,memo));
    }else{
        res = min(-A[l]+dfs(l+1,r,term^1,memo), -A[r]+dfs(l,r-1,term^1,memo));
    }
    return res;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<vector<vector<int64>>> memo(N,vector<vector<int64>>(N,vector<int64>(2,-INF)));
    A.resize(N);
    REP(i,N) {
        cin >> A[i];
    }

    int64 ans = dfs(0,N-1,true,memo);
    cout << ans << bn;
}

Measured memory_bytes: 492928
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define intl long long
void fastio()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
#endif
ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
}
int main()
{
	intl n,k;
	cin>>n>>k;
	intl a[n+1];
	for(intl i=0;i<n;i++)
	{
		cin>>a[i];
	}
	intl dp[n+1];
	dp[0]=0;
	//dp[1]=abs(a[1]-dp[0]);
	for(intl i=1;i<n;i++)
	{
		intl t=1;
		int m=INT_MAX;
		intl x=0;
		while(t<=k)
		{
			if(i-t>=0){
			x=min(((abs(a[i-t]-a[i]))+dp[i-t]),((abs(a[i-t]-a[i])+dp[i-t])));
			if(x<m)
				m=x;
            }else{
                break;
            }
			t++;
		}
		dp[i]=m;
	}
	// for(intl i=0;i<n;i++)
	// {
	// cout<<dp[i]<<" ";
	// }
	cout<<dp[n-1];
}

Measured memory_bytes: 5180
#include<stdio.h>

int main(void){
  
  char str[10000];
  int n;
  
  scanf("%d",&n);
  scanf("%s",str);
  
  for(int i=0;i<strlen(str);i++){
    str[i] = str[i] + n;
    if(str[i] > 0x5a){
      str[i] = str[i] - 26;
    }
  }
  printf("%s",str);
  return 0;
}  

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

int main()
{
	int x, y, z,ans = 0;

	cin >> x >> y >> z;

	x -= z;

	for (;;) {
		x -= y + z;
		if (x < 0)break;
		ans++;
	}

	cout << ans;

	return 0;
}

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

using namespace std;
#define BUF (100005)
#define ll long long 

int q;
bool pn[BUF];
int  cnt[BUF];
bool n17[BUF];

bool isprm(int num)
{
    double sqnum = sqrt(num);
    for (int i = 3; i <= sqnum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}


int main(void){
	pn[2]=1;
	for(int i=3;i<BUF;i+=2){
		pn[i] = isprm(i);	
		if(pn[i] && pn[(i+1)/2]) n17[i]=true;
	}

	int c=0;
	for(int i=0;i<=BUF;i++){
		if(n17[i])c++;
		cnt[i] = c;
	}

	
	cin >> q;
	for(int i=0;i<q;i++){
		int l,r;
		cin >> l >> r;

		cout << cnt[r] - cnt[l-1] << "\n";
	}
	return 0;
}


Measured memory_bytes: 1280
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] s = new int[n];
        for (int i = 0; i < n; i++) {
            s[i] = scanner.nextInt();
        }
        int q = scanner.nextInt();
        int[] t = new int[q];
        for (int i = 0; i < q; i++) {
            t[i] = scanner.nextInt();
        }
        int count = 0;
        for (int i = 0; i < q; i++) {
            if (BinarySearch(s, t[i])) {
                count++;
            }
        }
        System.out.println(count);
    }

    static boolean BinarySearch(int[] a, int key) {
        int left = 0;
        int right = a.length;
        while (left < right) {
            int mid = (left + right) / 2;
            if (a[mid] == key) {
                return true;
            }
            else if (key < a[mid]) {
                right = mid;
            }
            else {
                left = mid + 1;
            }
        } 
        return false;
    }
}



Measured memory_bytes: 68124
//Coded by Abhijay Mitra
#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <numeric>
#include <vector>
#include <iterator> 
#include <map>
#include <set>
#include <climits>
#include <queue>
#include <cmath>
#include <stack>
#include <cctype>
#include <bitset>
// #include <bits/stdc++.h>
#define double long double
#define int long long int
#define ll int
#define ibs ios_base::sync_with_stdio(false)
#define cti cin.tie(0)
#define bp __builtin_popcount
#define pb emplace_back
#define koto_memory(a) cout<<(sizeof(a)/1048576.0)<<" MB";
#define res(v) sort(all(v)),v.erase(unique(all(v)), v.end());
#define timer cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
#define deb(x) cout<<"\n["<<#x<<" = "<<x<<"]\n";
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using pii = std::pair<int,int>;
using vpii = std::vector<pii>;
using vvpii = std::vector<vpii>;
#define mp         make_pair
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define per(i,b,a) for (int i = b; i >= a; i--)
#define all(x)     x.begin(), x.end()
using namespace std;
const int N=2e6+10;
const int inf = /*0x3f3f3f3f*/1e18+10;
// const ll M = 998244353 ; // Mulo
// const int M = 1e9+7 ; // Mulo
const double Pi = 3.14159265;
#define F first
#define S second
int n,k;
void solve(){
  n=7;cin>>k;
  if(k&1^1){cout<<-1;return;}
  rep(i,1,1e8){
    if((n%k)==0){cout<<i;return;}
    n*=10;n+=7;if(n>=k)n%=k;
  }
  cout<<-1;
}
int32_t main()
{
  ibs;cti;
  solve();return 0;
  /*,cout<<"\n"*/;
  // cout<<"\n";
  int xx=0;
  int t;cin>>t;while(t--){/*xx++;cout<<"Case "<<xx<<":\n"*/;solve();cout<<"\n";}
  return 0;
}

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

struct BIG {
	int sum;
	string s;
	void add() {
		int x = s.size();
		for (int i = 1; i < s.size(); i++)
			if (s[i] < 9) {
				x = i;
				break;
			}
		if (x == s.size())
			s.push_back(0);
		for (int i = 0; i <= x; i++)
			sum -= s[i];
		s[0] += 9;
		for (int i = 0; i < x; i++) {
			s[i + 1] += s[i] / 10;
			s[i] %= 10;
		}
		for (int i = 0; i <= x; i++)
			sum += s[i];
	}
	void mul() {
		for (char &c: s)
			c *= 9;
		for (int i = 0; i < s.size(); i++)
			if (s[i] >= 10) {
				if (i == (s.size() - 1))
					s.push_back(0);
				s[i + 1] += s[i] / 10;
				s[i] %= 10;
			}
		sum = 0;
		for (char c: s)
			sum += c;
	}
	void print() {
		string t = s;
		reverse(t.begin(), t.end());
		for (char c: t)
			cerr << (int)c;
		cerr << '\n';
	}
} num;

string n;

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n;
	reverse(n.begin(), n.end());
	for (char &c: n)
		c -= '0';
	num.s = n;
	num.mul();
	for (int k = 1;; k++) {
		num.add();
		if (num.sum <= 9 * k) {
			cout << k;
			return 0;
		}
	}
}


Measured memory_bytes: 1820
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        A = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            A.add(sc.nextInt());
        }

        solve();
    }

    static int N;
    static List<Integer> A;

    static void solve() {

        // An - nの中央値を求める
        List<Integer> calcList = new ArrayList<>();
        for (int i = 0;i < N; i++) {
            calcList.add(A.get(i) - (i+1));
        }


        Collections.sort(calcList);


        if (calcList.size() % 2 == 0) {
            int i1 = calcList.size() / 2 - 1;
            int m1 = calcList.get(i1);
            
            int i2 = calcList.size() / 2;
            int m2 = calcList.get(i2);
            
            System.out.println(Math.min(calc(m1), calc(m2)));
        } else {
            int i = calcList.size() / 2;
            int m = calcList.get(i);

            System.out.println(calc(m));
        }
    }
    
    static long calc(int b) {
        long sum = 0;
        for (int i = 0; i < A.size(); i++) {

            sum += Math.abs(A.get(i) - (b + i + 1) );

        }

        return sum;
    }
}


Measured memory_bytes: 74668
from collections import defaultdict
n, k, q = map(int, input().split())
d = defaultdict(int)
for i in range(q):
    tmp = int(input())
    d[tmp] += 1

for i in range(1, n+1):
    if k+d[i]-q > 0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 16168
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define pb push_back
#define f(i,n) for(int i=0; i<n; ++i)
#define fi(i,st,n) for(int i=st; i<=n; ++i)
#define veci vector<int>
#define vecp vector<pair<int,int> >
#define vecl vector<ll>
int prime[100000+10];

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

ll power(ll a, ll n, ll mod) {
	ll res = 1;
	while(n > 0) {
		if(n&1) {
			res = (res*a)%mod;
		}
		a = (a*a)%mod;
		n = n/2;
	}
	return res;
}

ll sum(int arr[], int n) {
	ll res = 0;
	f(i,n) {
		res += arr[i];
	}
	return res;
}

void seive() {
	prime[1] = 0;
	for(int i=2; i<=100000; i++) {
		prime[i] = 1;
	}
	for(ll i=2; i<=100000; i++) {
		if(prime[i]) {
			for(ll j=i*i; j<=100000; j+=i) {
				prime[j] = 0;
			}
		}
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t = 1;
//	cin>>t;
	while(t--){
		ll n;
		cin>>n;
		int arr[n];
		f(i,n) cin>>arr[i];
		sort(arr,arr+n);
		ll ans = 0;
		for(int i=0; i<n; i++) {
			for(int j=i+1; j<n; j++) {
				for(int k=j+1; k<n; k++) {
					if(arr[k] < arr[i] + arr[j] and arr[i] != arr[j] and arr[j] != arr[k]) {
						ans++;
					}
				}
			}
		}
		cout<<ans<<"\n";
 	}
 	return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define ppb pop_back
#define INF 1e18
typedef long long ll;

using namespace std;

int main(int argc,char* argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    ll n;cin>>n;
    vector<ll>a(5);
    rep(i,5)cin>>a[i];
    ll min = a[0];
    rep(i,5)
    {
        if(min > a[i])min = a[i];
    }
    ll ans = 4+(n + (min - 1)) / min;
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

const ll MOD = 998244353;
const ll MAX_N = 3e5 + 10;
ll Inv[MAX_N];
ll fact[MAX_N];
ll factInv[MAX_N];
void Inv_init(){
    Inv[1] = 1;
    for(int i = 2; i < MAX_N; i++) {
        Inv[i] = Inv[MOD%i] * (MOD - MOD/i) % MOD;
    }
}
void fact_init(){
    fact[0] = fact[1] = factInv[0] = factInv[1] = 1;
    for(int i = 2; i < MAX_N; i++){
        fact[i] = (fact[i-1] * i) % MOD;
        factInv[i] = (factInv[i-1] * Inv[i])%MOD;
    }
}

// a^b % MOD;
ll powmod(ll a,ll b) {ll res=1;a%=MOD; for(;b;b>>=1){if(b&1)res=res*a%MOD;a=a*a%MOD;}return res;}
// 逆元 1/a % MOD
ll inversemod(ll a) { return powmod(a,MOD - 2);}
ll nCr(ll n,ll r) {
    if(n < r) return 0;
    return (fact[n] * (factInv[r] * factInv[n-r] % MOD)) % MOD;
}

void init(){
    Inv_init();
    fact_init();
}

inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }

ll solve(){
    ll res = 0;
    ll N,A,B,K; cin >> N >> A >> B >> K;
    for(ll x = 0; x <= N; x++){
        ll T = K - A*x;
        if(T < 0) continue;
        if(T%B != 0) continue;
        ll y = T/B;
        if(y > N) continue;
        (res += nCr(N,x)*nCr(N,y))%=MOD;
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    init();
    cout << solve() << endl;
    return 0;
}


Measured memory_bytes: 7296
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) int(a.size())
const int N=2e5+10;

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

int n,T,tt,ans;
pii a[N];
multiset<int> s;
ll sum[N];

bool cmp(pii a,pii b) {
	return 1ll*a.se*(b.fi-1)<1ll*(a.fi-1)*b.se;
}

int main() {
	cin>>n>>T;++T;
	for(int i=1;i<=n;i++) a[i].fi=gi()+1,a[i].se=gi()+1;
	sort(a+1,a+n+1,cmp);
	//for(int i=1;i<=n;i++) cerr<<a[i].fi<<' '<<a[i].se<<'\n';
	s.insert(1);
	for(int i=1;i<=n;i++) {
		if(a[i].fi>=2) {
			int now=2;vector<pii> vec;
			while(1) {
				auto it=s.lower_bound(now);
				if(it==s.end()) break;
				auto pre=it;--pre;
				if(1ll*a[i].fi*(*pre)+a[i].se<*it) vec.pb(mp(*it,1ll*a[i].fi*(*pre)+a[i].se));
				now=(*it)<<1;
			}
			ll tmp=1ll*a[i].fi*(*s.rbegin())+a[i].se;
			if(tmp<=T) s.insert(tmp);
			for(auto x:vec) {
				//assert(s.find(x.fi)!=s.end());
				s.erase(s.find(x.fi)),s.insert(x.se);
			}
		}
		else break;
		//for(auto x:s) cerr<<x<<' ';
		//cerr<<'\n';
	}
	for(int i=1;i<=n;i++) if(a[i].fi==1) sum[++tt]=a[i].se;
	sort(sum+1,sum+tt+1);
	for(int i=1;i<=tt;i++) sum[i]+=sum[i-1];
	auto it=s.begin();
	//cerr<<T<<endl;
	for(int i=0,j=tt;it!=s.end();i++) {
		while(*it+sum[j]>T) --j;
		//cerr<<*it<<' '<<sum[j]<<'\n';
		ans=max(ans,i+j);++it;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int f[210],p[110][20];
int n;
int hehe(int x,int y)
{
	if(x+y==0) return 0;
	if(x%2==0 || y%2==0) return hehe(x/2,y/2);
	if(x%2==y%2) return hehe(x/2,y/2)+1;
	return hehe(x/2,y/2);
}
int main()
{
	scanf("%d",&n);
	for(register int i=1;i<=n;++i)
		for(register int j=9;j>=0;--j)
		{
			int x;
			scanf("%d",&x);
			f[i]+=x*(1<<j);
		}
	for(register int i=1;i<=n;++i)
		for(register int j=0;j<=10;++j) scanf("%d",&p[i][j]);
	int haha=1<<10;
	int xh=-2147483647;
	for(register int i=1;i<haha;++i)
	{
		int sum=0;
		for(register int j=1;j<=n;++j)
		{
			int now=hehe(i,f[j]);
			sum+=p[j][now];
		}
		if(sum>xh) xh=sum;
	}
	cout<<xh<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String[] Spade = new String[13];
        String[] Heart = new String[13];
        String[] Club = new String[13];
        String[] Daiya = new String[13];
        for (int i = 0; i < 13; i++) {
            Spade[i]="S "+(i+1);
        }
        for (int i = 0; i < 13; i++) {
            Heart[i]="H "+(i+1);
        }
        for (int i = 0; i < 13; i++) {
            Club[i]="C "+(i+1);
        }
        for (int i = 0; i < 13; i++) {
            Daiya[i]="D "+(i+1);
        }
        int maisu=scanner.nextInt();
        for(int i=0; i<maisu; i++){
            String shurui=scanner.next();
            int kazu=scanner.nextInt();
            if(shurui.equals("S")){
                Spade[(kazu-1)]="0";
            }
            else if(shurui.equals("H")){
                Heart[(kazu-1)]="0";
            }
            else if(shurui.equals("C")){
                Club[(kazu-1)]="0";
            }
            else {
                Daiya[(kazu-1)]="0";
            }   
        }
        for(int i=0; i<13; i++){
            if(!Spade[i].equals("0")){
            System.out.println(Spade[i]);
        }
        }
        for(int i=0; i<13; i++){
            if(!Heart[i].equals("0")){
            System.out.println(Heart[i]);
        }
        }
        for(int i=0; i<13; i++){
            if(!Club[i].equals("0")){
            System.out.println(Club[i]);
        }
        }
        for(int i=0; i<13; i++){
            if(!Daiya[i].equals("0")){
            System.out.println(Daiya[i]);
        }
        }
    }
}

Measured memory_bytes: 26148
using System;

namespace ABC055_A_Restaurant
{
	internal class Program
	{
		public static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			int x = 800 * n;
			int y = 200 * (n / 15);
			
			Console.WriteLine(x - y);
		}
	}
}

Measured memory_bytes: 11092
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;

int main() {
	int n, k;
	string s;
	cin >> s;
	string a[2] = {};
	for (int i = 0; i < s.size(); ++i) {
		a[0] += (i % 2 == 0 ? '1' : '0');
			a[1] += (i % 2 == 0 ? '0' : '1');
	}
	int ans[2] = {};
	for (int j = 0; j < 2; ++j) {
		for (int i = 0; i < s.size(); ++i) {
			if (s[i] != a[j][i])++ans[j];
		}
	}
	cout << min(ans[0], ans[1]) << endl;
	return 0;
}

Measured memory_bytes: 768