akhauriyash/Code-Regression huggingface dataset:
a, b, c, k = map(int, input().split())
pa = min(a, k)
if k > a:
  pb = min(b, k-pa)
  if k - pa > b:
    pc = k - pa - pb
    print(pa + pc*-1)
  else:
    print(pa)
else:
  print(pa)

Measured memory_bytes: 9180
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#pragma GCC optimize(-O3)
#pragma GCC optimize(0fast)
#pragma GCC optimize("unroll-loops")

#define fi first
#define se second
#define sqr(x) (x) * (x)
#define p_b push_back
#define m_p make_pair
#define pll pair<ll, ll>
#define all(v) v.begin(), v.end()
#define pw(x) (1ll << x)

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
const ll MAXN = 1123456;
const ll N = 1e6;
const ll MOD = 1e9 + 7;

template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

template <typename T> void vout(T s){cout << s << endl; exit(0);}


ll f(ll n, ll x){
    return n / x;
}

ll get(ll l, ll r, ll x){
    return f(r, x) - f(l - 1, x);
}

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

    ll l, r, a, b, ans = 0;
    cin >> l >> r >> a >> b;


    ans += r - l + 1;
    ans -= get(l, r, a);
    ans -= get(l, r, b);

    ans += get(l, r, a * b / __gcd(a, b));

    cout << ans << "\n";

    return 0;
}


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

const int MAXN = 7e2 + 5;

int N, M;
bool mat[MAXN][MAXN];
int clr[MAXN];
bool dp[2 * MAXN][2];
int cnt;

void load() {
	scanf("%d%d", &N, &M);
	while (M--) {
		int a, b;
		scanf("%d%d", &a, &b);
		mat[a][b] = mat[b][a] = true;
	}
}

bool dfs(int x, int c) {
	if (clr[x] != -1)
		return clr[x] == c;
	clr[x] = c;
	cnt += c ? 1 : -1;
	for (int i = 1; i <= N; i++)
		if (i != x && !mat[x][i] && !dfs(i, c ^ 1))
			return false;
	return true;
}

bool ok(int val) {
	return val >= 0 && val < 2 * MAXN;
}

int solve() {
	memset(clr, -1, sizeof clr);
	dp[MAXN][0] = true;
		
	int c = 0;
	for (int i = 1; i <= N; i++)
		if (clr[i] == -1) {
			cnt = 0;
			if (!dfs(i, 0))
				return -1;
			c ^= 1;
			for (int i = 0; i < 2 * MAXN; i++) {
				dp[i][c] = false;
				if (ok(i + cnt))
					dp[i][c] |= dp[i + cnt][c ^ 1];
				if (ok(i - cnt))
					dp[i][c] |= dp[i - cnt][c ^ 1];
			}
		}
	
	int mn = 2 * MAXN;
	for (int i = 0; i < 2 * MAXN; i++)
		if (dp[i][c])
			mn = min(mn, abs(i - MAXN));
	
	int l = (N + mn) / 2;
	int r = (N - mn) / 2;
	return l * (l - 1) / 2 + r * (r - 1) / 2;
}

int main() {
	load();
	printf("%d\n", solve());
	return 0;
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t,a,b;
	t = 1;
	while(t--) {
	 cin >> a >> b;
	 if(a < 9 && b < 9)
	  cout << "Yay!" << endl;
	 else
	  cout << ":(" << endl;
	}
	return 0;
}



Measured memory_bytes: 256
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
#define MOD 1000000007
#define MAX_H 110
#define MAX_W 10
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
ll h,w,k,fr;
ll dp[MAX_H][MAX_W]={};
ll pat_dp[MAX_W][2];
ll pat[MAX_W];
signed main(){
  ll st,le,ri;
  init_io();
  cin >> h >> w >> k;
  if(w==1){
    cout << 1<<endl;
    return 0;
  }
  dp[0][0] = 1;
  pat_dp[0][0] = 0;
  pat_dp[0][1] = 0;
  pat[0] = 1;

  pat_dp[1][0] = 1;
  pat_dp[1][1] = 0;
  pat[1] = 1;

  for(int i=2;i<MAX_W;i++){
    pat_dp[i][0] = pat_dp[i-1][0]+pat_dp[i-1][1];
    pat_dp[i][1] = pat_dp[i-1][0];

    pat_dp[i][0] %= MOD;
    pat_dp[i][1] %= MOD;

    pat[i] = (pat_dp[i][0]+pat_dp[i][1])%MOD;
  }
  for(int i=1;i<=h;i++){
    for(int j=0;j<w;j++){
      st = dp[i-1][j];
      st *= (pat[j]*pat[w-1-j])%MOD;
      st %= MOD;

      le = 0;
      ri = 0;

      if(j!=0){
        le = (dp[i-1][j-1]*(pat[j-1]*pat[w-1-j])%MOD)%MOD;
      }
      if(j!=w-1){
        ri = (dp[i-1][j+1]*(pat[j]*pat[w-2-j]))%MOD;
      }
      dp[i][j] = (st+ri+le)%MOD;
    }
  }
  cout << dp[h][k-1]<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
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; }
ll dp[100010][3];
ll h[100010][3];

int main() {
    int n; cin >> n;
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++){
            cin >> h[i][j];
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++){
            for(int k=0;k<3;k++){
            if(j==k){       continue;
            }else{
                chmax(dp[i+1][k],dp[i][j]+h[i][k]);
            }
            }
        }
    }
    ll ans=0;
    for(int j=0;j<3;j++){
        ans=max(ans,dp[n][j]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 4992
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func getInput() ([]int, []int, []int) {
	sc.Split(bufio.ScanWords)
	sc.Scan()

	N, _ := strconv.Atoi(sc.Text())

	t := make([]int, N+1)
	x := make([]int, N+1)
	y := make([]int, N+1)

	for i := 1; i <= N; i++ {
		sc.Scan()
		t[i], _ = strconv.Atoi(sc.Text())
		sc.Scan()
		x[i], _ = strconv.Atoi(sc.Text())
		sc.Scan()
		y[i], _ = strconv.Atoi(sc.Text())
	}
	return t, x, y
}

func abs(a int) int {
	if 0 < a {
		return a
	}
	return -a
}

func c() {

	t, x, y := getInput()

	can := true
	for i := 0; i < len(t)-1; i++ {
		dt := t[i+1] - t[i]
		dist := abs(x[i+1]-x[i]) + abs(y[i+1]-y[i])
		if dt < dist {
			can = false
		}
		if dist%2 != dt%2 {
			can = false
		}
	}

	if can {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}

func main() {
  c()
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int K;
//---------------------------------------------------------------------------------------------------
string increment(string from) {
	int N = from.size();

	rrep(i, N - 1, 1) {
		int cu = from[i] - '0';
		int nxt = from[i - 1] - '0';

		if (cu < 9 && abs(cu + 1 - nxt) <= 1) {
			from[i]++;
			rep(j, i + 1, N) from[j] = max('0', (char)(from[j - 1] - 1));
			return from;
		}
	}

	int top = from[0] - '0';
	
	if (top < 9) {
		from[0]++;
		rep(j, 1, N) from[j] = max('0', (char)(from[j - 1] - 1));
		return from;
	}

	string res = "1";
	rep(i, 0, N) res += "0";
	return res;
}
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> K;

	string ans = "1";
	rep(k, 0, K - 1) ans = increment(ans);
	cout << ans << endl;
}







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

int main() {
  int h,w;
  cin>>h>>w;
  char vec[55][55];
  int ans[h+2][w+2]={};

  for (int i=0; i<h; i++){
    for (int j=0; j<w;j++){
      cin>>vec[i][j];
      if (vec[i][j]=='#') {
        for (int y = 0; y < 3; y++) {
          for (int x = 0; x < 3; x++) {
            ans[i+y][j+x]++;
          }
        }
      }
    }
  }
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (vec[i][j]=='#') cout<<'#';
      else cout<<ans[i+1][j+1];
    }
    cout<<endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<sstream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<cmath>
#include<cstdio>
#include<cassert>

using namespace std;

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aut(r,v) __typeof(v) r = (v)
#define each(it,o) for(aut(it,(o).begin()); it!=(o).end(); ++it)
#define reach(it,o) for(aut(it,(o).rbegin()); it!=(o).rend(); ++it)
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T1, typename T2> ostream& operator<<(ostream& o, const pair<T1, T2>& p)
{return o<<"("<<p.first<<", "<<p.second<<")";}
template<typename T>string join(const vector<T>&v, string del=", ")
{stringstream s;rep(i,v.size())s<<del<<v[i];return s.str().substr(del.size());}
template<typename T>ostream& operator<<(ostream& o, const vector<T>&v)
{if(v.size())o<<"["<<join(v)<<"]";return o;}
template<typename T>ostream& operator<<(ostream& o, const vector<vector<T> >&vv)
{int l=vv.size();if(l){o<<endl;rep(i,l){o<<(i==0?"[ ":",\n  ")<<vv[i]<<(i==l-1?" ]":"");}}return o;}
template<typename T>ostream& operator<<(ostream& o, const set<T>& st)
{vector<T> v(st.begin(),st.end());o<<"{ "<<join(v)<<" }";return o;}
template<typename T1, typename T2>ostream& operator<<(ostream& o, const map<T1, T2>& m)
{each(p,m){o<<(p==m.begin()?"{ ":",\n  ")<<*p<<(p==--m.end()?" }":"");}return o;}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0));
const double INF = 0x3f3f3f3f;
const double INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
const double mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

const int V = 100000;
ll N, W;
ll dp[V+10];

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");
    cin >> N >> W;
    rep(j,V+1) dp[j] = W+1;
    dp[0] = 0;
    rep(i,N){
        ll w, v;
        cin >> w >> v;
        rrep(j,V+1){
            if(j-v >= 0 && dp[j-v] + w <= W)
                dp[j] = min(dp[j], dp[j-v] + w);
        }
    }
    rrep(j,V+1)
        if(dp[j] <= W){
            cout << j << endl;
            break;
        }
    return 0;
}

Measured memory_bytes: 1024
# doubling
import sys
input = sys.stdin.readline
def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    TO_MAX = 60
    to = [[0 for _ in range(N)] for _ in range(TO_MAX+1)]
    for i in range(N):
        to[0][i] = A[i]-1
    for i in range(TO_MAX):
        for j in range(N):
            to[i+1][j] = to[i][to[i][j]]
    v = 0
    for i in range(TO_MAX+1)[::-1]:
        l = pow(2, i)
        if l <= K:
            v = to[i][v]
            K -= l
    print(v+1)   
if __name__ == "__main__":
    main()

Measured memory_bytes: 217148
#include<bits/stdc++.h>
using namespace std;
const int mod=1000000007;
int x,y;
int frac(int x)
{
	int ans=1;
	for(int i=2;i<=x;i++) ans=1LL*ans*i%mod;
	return ans;
}
int ksm(int a,int b)
{
	int ans=1;
	while(b)
	{
		if(b&1) ans=1LL*ans*a%mod;
		b>>=1;
		a=1LL*a*a%mod;
	}
	return ans;
}
int inv(int a)
{
	return ksm(a,mod-2);
}
int C(int a,int b)
{
	return 1LL*frac(b)*inv(frac(a))%mod*inv(frac(b-a))%mod;
}
int main()
{
	ios::sync_with_stdio(false);
	cin>>x>>y;
	if((x+y)%3||x<(x+y)/3||y<(x+y)/3)
	{
		cout<<0<<endl;
		return 0;
	}
	int n=(2*x-y)/3,m=(2*y-x)/3;
	cout<<C(n,n+m)<<endl;
	return 0;
}

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

const int mod = 1e9+7;
class mint {
    long long x;
public:
    mint(long long x=0) : x((x%mod+mod)%mod) {}
    mint operator-() const { 
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }

    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};

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

    vector<ll> d(60, 0);
    mint ans = 0;
    rep(i, 60){
        ll x = 0;
        ll y = 0;
        rep(j, n){
            if(a[j]>>i & 1) y++;
            else x++;
        }
        d[i] = x * y; 
    }
    
    rep(i, 60){
        mint tmp = d[i];
        rep(j, i){
            tmp *= 2;
        }
        ans += tmp;
    }
    cout << ans << endl;


}

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

#define llint long long int

using namespace std;

int main(){
    llint A, B, N;

    cin >> A >> B >> N;

    llint x;

    if(B - 1 <= N){
        x = B - 1;
    }else{
        x = N;
    }
    cout << (A * x) / B - A * (x / B) << endl;
}

Measured memory_bytes: 3636
n,k,q=map(int,input().split())
a=[int(input()) for _ in range(q)]
point=[-k]*n
for i in range(q):
  point[a[i]-1]+=1
for i in range(n):
  if point[i]>-2*k+q:
    print('Yes')
  else:
    print('No')
    
  


Measured memory_bytes: 56024
#include<stdio.h>

int main(){

int x,y,z;
scanf("%d %d",&x,&y);
while(x!=0||y!=0){
if(x>y){
z=x;
x=y;
y=z;
}
printf("%d %d\n",x,y);
scanf("%d %d",&x,&y);
}




return 0;
}

Measured memory_bytes: 1028
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int b,c;
    while(cin>>b>>c)
    {
        if(b==2 && c==2)
            cout<<"Yes"<<endl;
        else if((b==4 || b==6 || b==9 || b==11) && (c==4 || c==6 || c==9 || c==11))
             cout<<"Yes"<<endl;
        else if((b==1 ||b==3|| b==5|| b==7|| b==8 || b==10 ||b==12) &&(c==1 ||c==3|| c==5|| c==7|| c==8 || c==10 ||c==12))
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;
int main(){
  int n;
  cin>>n;
  int r[n];
  for(int i=0;i<n;i++)
    cin>>r[i];
  long long maxp=-2100000000;
  int now=r[0];
  for(int i=1;i<n;i++){
    if(maxp<(r[i]-now))
      maxp=(r[i]-now);
    if(now>r[i])
      now=r[i];
  }
  cout<<maxp<<endl;

  return 0;
}

Measured memory_bytes: 3868
using System;

namespace Project
{
	class MainClass
	{
		public static void Main(string[] args)
		{
			while (true)
			{
				string s = Console.ReadLine();
				string[] sar = s.Split(' ');
				int[] a = new int[2];
				a[0] = int.Parse(sar[0]);
				a[1] = int.Parse(sar[1]);
				if (a[0] == 0 && a[1] == 0) { break; }
				else
				{
					Array.Sort(a);
					Console.WriteLine("{0} {1}", a[0], a[1]);
				}
			}
		}
	}
}

Measured memory_bytes: 9452
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
#define ar array
#define pb push_back

template <typename t> void max_self(t &a,t b)
{
	a=max(a,b);
}
bool row_col(pair<int,int> p)
{
	if(p.first==0||p.second==0)
		return 1;
	return 0;
}
int main()
{
	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt","r",stdin);
	// 	freopen("outputc.txt","w",stdout);
	// #endif
	
	//int t;
	//cin>>t;
	//while(t--)
	{
		string s,t;
		cin>>s>>t;
		const int INF=1e9+7;
		int n=s.length();
		int m=t.length();
		vector<vector<pair<int,pair<int,int>>>> dp(n+1,vector<pair<int,pair<int,int>>> (m+1,{-INF,{0,0}}));//matching upto index i in s and j in t
		dp[0][0]={0,{0,0}};
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<m;j++)
			{
				if(s[i]==t[j])
				{
					max_self(dp[i+1][j+1],{dp[i][j].first+1,{i,j}});
				}
				else
				{
					max_self(dp[i+1][j],{dp[i][j].first,{i,j}});
					max_self(dp[i][j+1],{dp[i][j].first,{i,j}});
				}
			}
		}
		pair<int,pair<int,int>> ans={0,{0,0}};
		for(int i=0;i<=n;i++)
		{
			for(int j=0;j<=m;j++)
			{
				max_self(ans,{dp[i][j].first,{i,j}});
			}
		}
		string a;
		pair<int,int> curr=ans.second;
		while(!row_col(curr))
		{
			int i=curr.first;
			int j=curr.second;
			pair<int,int> prev=dp[i][j].second;
			if(prev==make_pair(i-1,j-1))
			{
				a+=s[i-1];
			}
			curr=prev;
		}
		reverse(a.begin(),a.end());
		cout<<a<<'\n';
		
	}
		
}


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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v)
{
    os << "{";
    rep(i, v.size()) os << v[i] << (i == (int)v.size() - 1 ? "" : ", ");
    os << "}";
    return os;
}
template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }
struct in
{
    const size_t n = 0;
    in() = default;
    in(size_t n) : n(n){};
    template <typename T>
    operator T()
    {
        T ret;
        cin >> ret;
        return ret;
    }
    template <typename T>
    operator vector<T>()
    {
        assert(n != 0);
        vector<T> ret(n);
        for (auto &x : ret)
            cin >> x;
        return ret;
    }
};

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    int k = in(), x = in();
    if (500 * k >= x)
        Yes;
    else
        No;
}

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


Measured memory_bytes: 256
import sys
read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    N = int(readline())
    A = list(map(int, readline().split()))
    A.sort(reverse=True)
    ans = 0
    conut = 1
    for i in range(N):
        if i==0:
            ans += A[i]
            conut += 1
            if conut==N:
                break
        else:
            ans += A[i]
            conut += 1
            if conut == N:
                break
            ans += A[i]
            conut += 1
            if conut==N:
                break
    print(ans)



if __name__ == '__main__':
    main()


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

const int MAXSIZE = 25;
const int END = -1;
struct StNod
{
  int m_nDept;
  int m_nHigh;
  int m_nParnt;
  int m_nLeft;
  int m_nRigt;

  StNod() :
    m_nDept(END), m_nHigh(END), m_nParnt(END), m_nLeft(END), m_nRigt(END)
  { }
};

void fnInput(vector<StNod> &rvoNod)
{
  StNod oNod;
  rvoNod.resize(MAXSIZE, oNod);

  int nMaxSiz;
  cin >> nMaxSiz;

  for (int i = 0; i < nMaxSiz; i++)
  {
    int nParnt, nLeft, nRigt;
    cin >> nParnt >> nLeft >> nRigt;

    rvoNod[nParnt].m_nLeft = nLeft;
    rvoNod[nParnt].m_nRigt = nRigt;
    if (nLeft != END)  rvoNod[nLeft].m_nParnt = nParnt;
    if (nRigt != END)  rvoNod[nRigt].m_nParnt = nParnt;
  }
}

void fnSetDepth(vector<StNod> &rvoNod, int nx, int nDept)
{
  rvoNod[nx].m_nDept = nDept;
  
  if (rvoNod[nx].m_nLeft != END)
    fnSetDepth(rvoNod, rvoNod[nx].m_nLeft, nDept + 1);

  if (rvoNod[nx].m_nRigt != END)
    fnSetDepth(rvoNod, rvoNod[nx].m_nRigt, nDept + 1);
}

int fnSetHight(vector<StNod> &rvoNod, int nx)
{
  int nLHigh =0, nRHigh = 0;

  if (rvoNod[nx].m_nLeft != END)
    nLHigh = fnSetHight(rvoNod, rvoNod[nx].m_nLeft) + 1;
  if (rvoNod[nx].m_nRigt != END)
    nRHigh = fnSetHight(rvoNod, rvoNod[nx].m_nRigt) + 1;
  
  return rvoNod[nx].m_nHigh = max(nLHigh, nRHigh);
}

void fnBinTree(vector<StNod> &rvoNod)
{
  int nx = 0;
  while (rvoNod[nx].m_nParnt != END)
    nx = rvoNod[nx].m_nParnt;

  int nDept = 0;
  fnSetDepth(rvoNod, nx, nDept);

  int nHigh = fnSetHight(rvoNod, nx);
}

void fnResult(const vector<StNod> &cnrvoNod)
{
  for (int i = 0; i < cnrvoNod.size(); i++)
  {
    if (cnrvoNod[i].m_nDept == END)  break;
    cout << "node " << i << ": parent = " << cnrvoNod[i].m_nParnt << ", sibling = ";

    if (cnrvoNod[i].m_nParnt == END)  cout << END;
    else
    {
      int nx = cnrvoNod[i].m_nParnt;
      if (i == cnrvoNod[nx].m_nLeft)  cout << cnrvoNod[nx].m_nRigt;
      else                            cout << cnrvoNod[nx].m_nLeft;
    }
    
    cout << ", degree = ";
    int nCCnt = 0;
    if (cnrvoNod[i].m_nLeft != END)  nCCnt++;
    if (cnrvoNod[i].m_nRigt != END)  nCCnt++;
    cout << nCCnt << ", depth = " << cnrvoNod[i].m_nDept << ", height = " << cnrvoNod[i].m_nHigh;

    if (!cnrvoNod[i].m_nDept)       cout << ", root";
    else if (!cnrvoNod[i].m_nHigh)  cout << ", leaf";
    else                            cout << ", internal node";
    cout << endl;
  }
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<StNod> voNod;

  fnInput(voNod);
  fnBinTree(voNod);
  fnResult(voNod);
  return 0;
}

Measured memory_bytes: 1200
#include <stdio.h>

int main(){
  int a=1,b=1;
  while(1){
    scanf("%d %d",&a,&b);
    if(a==0&&b==0) break;
    if(a<=b){printf("%d %d\n",a,b);}
    else{printf("%d %d\n",b,a);}
  }
  return 0;
}

Measured memory_bytes: 600
"use strict"

const main = (input) => {
    input = input.split("\n");
    const N = Number(input[0]);
    const A = Number(input[1]);

    if (N % 500 <= A) {
        console.log("Yes");
    } else {
        console.log("No");
    }
};

main(require("fs").readFileSync("/dev/stdin","utf8"));

Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define llu unsigned long long 
#define pb push_back
#define loop(x) for(int i=0;i<x;i++)
#define sc(x) scanf("%lld",&x)
#define pr(x) printf("%lld\n",x)
#define dd fflush(stdout)
#define what_is(x) cerr << #x << " is " << x << endl;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mt make_tuple //use tie
#define eb emplace_back
typedef tuple<int,int,int> State;//use in dijkstra
ll mod=1e9+7;
// ll power(ll x,ll y,ll mod){
//  ll ans=1;
//  while(y>0){
//   if(y&1){
//     ans=ans*x;
//   }
//   x=x*x;
//   y=y/2;
//  }
//  return ans;
// }

int main(){
    // IOS;  
     int n,k;
     cin>>n>>k;
     //ll a[n+2];
     int x;
     vector<ll> dp(k+3);
     //dp[i] will store the number of ways to distributes 
     //i candies till now .
     dp[0]=1;
     ll sum[k+2]={0};
     for(int i=0;i<n;i++){
      scanf("%d",&x);
      for(int j=0;j<=k;j++)
      {
        sum[j]=(((j>0)?sum[j-1]:0)+dp[j])%mod;
      }
      for(int j=k;j>=0;j--){
        //here i can use only c candies.
        int r=j-1;
        int l=j-min(x,j);
        // cout<<l<<" "<<r<<endl;
        if(r>=l)
          dp[j]=(dp[j]+sum[r]-((l>0)?sum[l-1]:0)+mod)%mod;
         
      }
     }
     //cout<<dp[k]<<endl;
     printf("%lld\n",dp[k]);
 }
 

Measured memory_bytes: 1792
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

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

#include <iostream>

using namespace std;

long long dp[104][200004];

int main()
{
    long long sum=0,mo=10000000000,i,j,val;
    for(i=0;i<=100003;i++){for(j=0;j<=100;j++){dp[j][i]=mo;}}
    dp[0][0]=0;
    long long n,wt,ans=0;
    cin>>n>>wt;
    long long w[n+1],v[n+1];
    for(i=1;i<=n;i++){cin>>w[i]>>v[i];sum+=v[i];}
    for(i=1;i<=n;i++)
    {
        for(val=0;val<=sum;val++)
        {
            if(val-v[i]>=0&&dp[i-1][val-v[i]]!=mo){dp[i][val]=min(dp[i][val],dp[i-1][val-v[i]]+w[i]);}
            dp[i][val]=min(dp[i][val],dp[i-1][val]);
            if(dp[i][val]<=wt&&val>=ans){ans=val;}
        }
    }
    cout<<ans;

    return 0;
}


Measured memory_bytes: 82972
#include<bits/stdc++.h>
using namespace std; 
#define ll long long
#define ld long double
#define rep(i,x,y)  for(ll i=x;i<y;++i)
#define For(i,x,y)  for(ll i=x;i<=y;++i) 
#define FOr(i,x,y)  for(ll i=x;i>=y;--i) 
#define pi acos(-1)
#define mk make_pair<ll,ll>
#define pa pair<ll,ll>
#define lf else if
#define max(x,y)    ((x)<(y)?(y):(x))
#define min(x,y)    ((x)<(y)?(x):(y))
#define sqr(x)		(x)*(x)
#define Mul(x,y)    x=x*(y)%mod
#define Add(x,y)    x=(x+(y))%mod
#define Max(x,y)	x=x<(y)?(y):x
#define Min(x,y)	x=x>(y)?(y):x
#define E(x) 		return writeln(x),0
#define p(x)		printf("~%d~\n",x)
#define pp(x,y)		printf("~~%d %d~~\n",x,y)
#define ppp(x,y,z)	printf("~~~%d %d %d~~~\n",x,y,z)
#define f_in(x)		freopen(x".in","r",stdin)
#define f_out(x) 	freopen(x".out","w",stdout)
#define open(x)		f_in(x),f_out(x)
#define fi first
#define se second
typedef complex<double> E;
namespace SHENZHEBEI{
#ifdef LOCAL
    struct _{_(){freopen("cf.in","r",stdin);}}_;
#endif 
#define NEG 1
    const int L=2333333;
    char SZB[L],*S=SZB,*T=SZB;
    inline char gc(){   if (S==T){  T=(S=SZB)+fread(SZB,1,L,stdin); if (S==T) return '\n';  }   return *S++;    }
#if NEG
    inline ll read(){    ll x=0,f=1; char ch=gc();   for (;!isdigit(ch);ch=gc()) if (ch=='-') f=-1;  for (;isdigit(ch);ch=gc())  x=x*10-48+ch;   return x*f; }
    inline void write(ll x){    if (x<0) putchar('-'),x=-x;  if (x>=10)   write(x/10);    putchar(x%10+'0');  }
#else
    inline ll read(){    ll x=0; char ch=gc();   for (;!isdigit(ch);ch=gc());    for (;isdigit(ch);ch=gc())  x=x*10-48+ch;   return x;   }
    inline void write(ll x){    if (x>=10)   write(x/10);    putchar(x%10+'0');  }
#endif
    inline char readchar(){ char ch=gc();   for(;isspace(ch);ch=gc());  return ch;  }
    inline ll readstr(char *s){ char ch=gc();   int cur=0;  for(;isspace(ch);ch=gc());      for(;!isspace(ch);ch=gc())  s[cur++]=ch;    s[cur]='\0';    return cur; }
    inline void writeln(ll x){  write(x);   puts("");   }
}using namespace SHENZHEBEI;
const ll N=1000100;
ll n,x[N],y[N],t[N];
int main(){
	n=read();
	For(i,1,n){
		t[i]=read(),x[i]=read(),y[i]=read();
		ll dis=abs(x[i]-x[i-1])+abs(y[i]-y[i-1]);
		if ((dis^(t[i]-t[i-1]))&1)	return puts("No"),0;
		if (dis>(t[i]-t[i-1]))		return puts("No"),0;
	}puts("Yes");
}

Measured memory_bytes: 11520
import collections, heapq, itertools, math, functools
groupby = itertools.groupby
rs  = lambda: input()
ri  = lambda: int(input())
rm  = lambda: map(int, input().split())
rai = lambda: [int(x) for x in input().split()]

def solve():
    N = ri()
    ans = 0
    for i in range(1, N + 1):
        n = N // i
        ans += i * n * (n + 1) // 2
    return ans
print(solve())

Measured memory_bytes: 9444
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  ll A,B,C;
  ll cnt=0;
  cin>>A>>B>>C;
  if(A==B) cnt++;
  if(A==C) cnt++;
  if(B==C) cnt++;
  if(cnt==3) cout<<1<<endl; 
  else cout<<3-cnt<<endl;
}
	



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

s = []
for i in range(n):
    s.append(input())

ans = ""

for i in range(len(s[0])):
    check = 0
    for j in range(n):
        if not s[0][i] in s[j]:
            check = 1
    if check == 0:
        ans = ans + s[0][i]
        for j in range(1,n):
            re = s[0][i]
            s[j] = s[j].replace(re , '', 1)

ans = ''.join(sorted(ans))
print(ans)

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

bool is_prime(int x){
    if(x==2){
        return true;
    }else if(x < 2 || x % 2 == 0){
        return false;
    }
    for(int i=3;i <= sqrt(x);i += 2){
        if(x % i ==0){
            return false;
        }
    }
    return true;
}

int main(){
    int n; cin >> n;
    int x;
    int cnt=0;
    for(int i=0; i<n; i++){
        cin >> x;
        if(is_prime(x)){
            cnt++;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3124
#!/usr/bin/env python3
# GRL_3_C: Connected Components - Strongly Connected Components


from collections import namedtuple


DirectedEdge = namedtuple('DirectedEdge', ('src', 'dest'))


def revert(edge):
    return edge._replace(src=edge.dest, dest=edge.src)


class Digraph:
    def __init__(self, v):
        self.v = v
        self._edges = [[] for _ in range(v)]

    def add(self, edge):
        self._edges[edge.src].append(edge)

    def adj(self, v):
        return self._edges[v]

    def edges(self):
        for es in self._edges:
            for e in es:
                yield e

    def reversed(self):
        g = self.__class__(self.v)
        for e in self.edges():
            g.add(revert(e))

        return g


def reverse_post(graph):
    def visit(v):
        if not visited[v]:
            visited[v] = True
            return True
        else:
            return False

    def leave(v):
        if not left[v]:
            left[v] = True
            vs.append(v)
        return False

    visited = [False] * graph.v
    left = [False] * graph.v
    vs = []

    for i in range(graph.v):
        if not visited[i]:
            stack = [(i, leave)]
            stack.extend((e.dest, visit) for e in graph.adj(i))
            while stack:
                v, f = stack.pop()
                if f(v):
                    stack.append((v, leave))
                    for e in graph.adj(v):
                        stack.append((e.dest, visit))
    return reversed(vs)


def scc_kosaraju_sharir(graph):
    class CC:
        def __init__(self, v):
            self._id = [i for i in range(v)]

        def id(self, v, c):
            self._id[v] = c

        def connected(self, u, v):
            return self._id[u] == self._id[v]

    def dfs(v):
        stack = [v]
        while stack:
            w = stack.pop()
            if not visited[w]:
                visited[w] = True
                yield w
                stack.extend([e.dest for e in graph.adj(w)
                              if not visited[e.dest]])

    visited = [False] * graph.v
    i = 0
    cc = CC(graph.v)
    for v in reverse_post(graph.reversed()):
        if not visited[v]:
            for w in dfs(v):
                cc.id(w, i)
            i += 1
    return cc


def run():
    v, e = [int(i) for i in input().split()]
    g = Digraph(v)

    for _ in range(e):
        s, t = [int(i) for i in input().split()]
        g.add(DirectedEdge(s, t))

    cc = scc_kosaraju_sharir(g)
    q = int(input())
    for _ in range(q):
        u, w = [int(i) for i in input().split()]
        if cc.connected(u, w):
            print(1)
        else:
            print(0)


if __name__ == '__main__':
    run()



Measured memory_bytes: 13528
#include <iostream>
using namespace std;
int main(){
  int a[1000],b[1000],n,m,i,j;
  cin>>n>>m;
  for(i=0;i<n;i++) cin>>a[i];
  for(i=0;i<m;i++) cin>>b[i];
  int small[1000][1000]={a[0]*b[0]};
  for(i=1;i<n;i++) small[i][i]=small[i-1][i-1]+a[i]*b[i];
  for(i=1;i<m;i++) small[0][i]=min(a[0]*b[i],small[0][i-1]);
  for(i=1;i<n;i++) for(j=i+1;j<m;j++) small[i][j]=min(small[i-1][j-1]+a[i]*b[j],small[i][j-1]);
  cout<<small[n-1][m-1]<<endl;
  return 0;
}

Measured memory_bytes: 7008
#include <stdio.h>

int minf(int a,int b){
    return a < b ? a : b;
}

int main(void){
    int N,A,B,max,min;
    scanf(" %d %d %d",&N,&A,&B);
    int a = A + B - N;
    
    max = minf(A,B);

    if(a > 0){
        min = a;
        printf("%d %d\n",max,min);
    }else if(a < 0){
        min = 0;
        printf("%d %d\n",max,min);
    }else{
        printf("%d %d\n",max,0);
    }

    return 0;
}

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

// Self settings
// clang-format off
#define MAX_N 100
#define MAX_V 1000
// #define INF 1000000001
#define INF LLONG_MAX
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
// clang-format on

ll N, W;
// ll dp[MAX_N + 1][MAX_V + 1];
ll dp[MAX_N + 1][MAX_N * MAX_V + 1];
ll w[MAX_N], v[MAX_N];

void solve()
{
  REP(i, N + 1) REP(j, MAX_N * MAX_V + 1) dp[i][j] = INF;
  dp[0][0] = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j <= MAX_N * MAX_V + 1; j++) {
      if (j < v[i] || dp[i][j - v[i]] == INF) {
        dp[i + 1][j] = dp[i][j];
      }
      else {
        dp[i + 1][j] = min(dp[i][j], dp[i][j - v[i]] + w[i]);
      }
    }
  }
  ll ans = 0;
  // REP(j, MAX_V + 1) cout << dp[N][j] << " ";
  REP(j, MAX_N * MAX_V + 1) if (dp[N][j] <= W) ans = j;
  cout << ans << endl;
}

int main(void)
{
  cin >> N >> W;
  REP(i, N) cin >> w[i] >> v[i];
  solve();
  return 0;
}


Measured memory_bytes: 79104
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)
	a := make([]int, 26)
	for _, v := range s {
		a[int(v)-97] = 1
	}
	for i, v := range a {
		if v == 0 {
			fmt.Println(string(i + 97))
			return
		}
	}
	fmt.Println("None")
}

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

# A = [20,18,2,18]
Alice = 0
Bob = 0

A.sort(reverse=True)

for i,num in enumerate(A):
    if i%2 == 0:
        Alice+=num
    else:
        Bob+=num

print(Alice-Bob)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
using namespace std;
int main(){
    long long a,b,c;
    cin >> a >> b >> c;
    if(a%2 == 0 || b%2 == 0 || c%2 == 0){
        cout << 0 << endl;
    }
    else{
        long long d = max(a,max(b,c));
        if(c == d){
            cout <<  a*b << endl;
        }else{
            cout << (a*b/d)*c << endl;
        }
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<string>
#include<cstdlib>
//#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long INF = 1LL << 40;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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;
}


// ----------------------------------------------------------------------------
int main(){
  string W;
  cin >> W;
  transform(W.begin(),W.end(),W.begin(),::tolower);
  string S;
  cin >> S;
  int ans=0;
  while(S != "END_OF_TEXT"){
    transform(S.begin(),S.end(),S.begin(),::tolower);
    if(W == S) ans++;

    cin >> S;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3180
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_set>
#include <math.h>
#include <queue>
using namespace std;

int main(){
  int N,M;
  cin >> N >> M;
  priority_queue<unsigned long long> pque;
  for(int i = 0; i < N; i++){
    int tmp;
    cin >> tmp;
    pque.push(tmp);
  }

  for(int i = 0; i < M; i++){
    int max = pque.top();
    pque.pop();
    pque.push(max/2);
  }

  unsigned long long sum = 0;
  for(int i = 0; i < N; i++){
    sum += pque.top();
    pque.pop();
  }
  cout << sum << endl;
  return 0;  
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repa(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#define _GLIBCXX_DEBUG

int main(){
  
  int n;
  cin >> n;
  if(n < 1200)
    cout << "ABC" << endl;
  else
    cout << "ARC" << endl;

}

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

using namespace std;


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

    int n, k;
    cin >> n >> k;
    vector<int>d(k, 0);
    for (int i = 0; i < k; i++) cin >> d[i];

    for (int i = n; i < 10e5; i++) {
        int tmp = i;
        int last = tmp % 10;
        while (tmp > 0 && find(d.begin(), d.end(), last) == d.end()) {
            tmp = tmp / 10;
            last = tmp % 10;
        }
        if (tmp == 0) {
            cout << i;
            break;
        }
    }

    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define ALL(v) v.begin(), v.end()
#define CHMIN(x,y) x = min(x, y)
#define CHMAX(x,y) x = max(x, y)

ld L;

ld solve() {
    return powl(L/3, 3);
}

int main() {
    cin >> L;
    cout << fixed << setprecision(15) << solve() << endl;
}

Measured memory_bytes: 384
//640711C ???????????¬????????°???
//?????????????????????:Maximum Sum Sequence
//????????????????????????15?????????????????°5??????
//

#include <algorithm>
#include <iostream>
using namespace std;

int n,s[5000+10];

int biggest(int n){
    int M=-200000-10;
    for(int p=0;p<n;p++){
//        cout << "s[" << p << "] = " << s[p] << endl;
        if(s[p]>M) M=s[p];
        for(int q=0;q<p;q++){
//            cout << "s[" << p << "]-s[" << q << "] = " << s[p]-s[q] << endl;
            if(s[p]-s[q]>M) M=s[p]-s[q];
        }
    }
    return M;
}

int main(){
    int n;
    while(cin){
        cin >> n;
        if(n==0) break;
        int a[5000+10];
        for(int i=0;i<n;i++){
            cin >> a[i];
            if(i==0) s[i]=a[i];
            else s[i]=s[i-1]+a[i];
        }
        cout << biggest(n) << endl;
    }
}

Measured memory_bytes: 3044
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long int ll;

ll mod=1e9+7;

//繰り返し二乗法
ll power(ll a,ll b){
	ll res=1;
	while(b>0){
		if(b&1)res=res*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return res;
}

struct perm{
private:
	int sz;
	vector<ll> p,invp;
public:
	perm(int n){
		sz=n+1;
		p.resize(sz),invp.resize(sz);
		p[0]=1;
		for(int i=1;i<=sz-1;i++){
			p[i]=p[i-1]*i%mod;
		}
		invp[sz-1]=power(p[sz-1],mod-2);
		for(int i=sz-2;i>=0;i--){
			invp[i]=invp[i+1]*(i+1)%mod;
		}
	}
	ll comb(ll x,ll y){
		if(x<y||y<0)return 0;
		return (p[x]*invp[x-y]%mod)*invp[y]%mod;
	}
};
perm p(1<<22);

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	ll n,a,b,c; cin >> n >> a >> b >> c;
	if(b%2==1){
		cout << 0 << endl;
		return 0;
	}
	ll ans=0;
	for(int q=0;3*q<=c;q++){
		for(int s=0;s<=a&&3*q+s<=c;s++){
			int r=b/2;
			int pp=a-s;
			int x=c-3*q-s;
			ll add=1;
			(add*=(ll)p.comb(pp+q,pp))%=mod;
			(add*=(ll)p.comb(pp+q+s,s))%=mod;
			(add*=(ll)p.comb(pp+q+s+r,r))%=mod;
			if(r)(add*=(ll)p.comb(r+x-1,x))%=mod;
			else{
				if(x)add*=0;
				else add*=1;
			}
			ans+=add;
			ans%=mod;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 65792
n, m = map(int, input().split())
a = [0] * m
for i in range(n):
    b = list(map(int, input().split()))
    for j in range(1, len(b)):
        a[b[j]-1] +=1
res = 0
for item in a:
    if item == n:
        res +=1

print(res)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
void chmax (int& a, int b) { if (a < b) a = b; }
void chmin (int& a, int b) { if (a > b) a = b; }

int max_profit (const vector<int>&a) {
    int mn = a[0], ret = 0;
    for (int i = 1; i < (int)a.size(); i++) {
        chmax(ret, a[i] - mn); chmin(mn, a[i]);
    }
    return ret;
}

int sum_cost (const vector<int>& a, int k) {
    set<int> se;
    set<int> res;
    for (const auto& e : a) {
        se.emplace(e);
        if (se.count(e-k)) {
            res.emplace(e);
            res.emplace(e-k);
        }
    }
    return (int)res.size() / 2;
}
    
int main() {
    int n, t;
    cin >> n >> t;
    vector<int> a(n);
    for (auto&e : a) cin >> e;
    cout << sum_cost(a, max_profit(a)) << endl;
    return 0;
}

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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  string s;
  cin >> s;
  string res = s == "ABC" ? "ARC" : "ABC";
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3620
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
int main(){
    string s;
    cin>>s;
    int n=s.size();
    V<int> sum(n+1,0);
    for(int i=n-1;i>=0;i--){
        if(s[i]=='W')sum[i]=sum[i+1]+1;
        else sum[i]=sum[i+1];
    }
    ll ans=0;
    for(int i=0;i<n;i++)if(s[i]=='B')ans+=sum[i];
    cout<<ans<<endl;
}

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

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


  int n,m;cin>>n>>m;
  cout<<(n*(n-1)+m*(m-1))/2<<endl;
  

  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;

int main() {
#ifdef purple_bro
    freopen("in.txt", "r", stdin);
#endif // purple_bro
    int n, m;

    scanf("%d%d", &n, &m);

    if (abs(n - m) > 1)
        puts("0");
    else {
        int dog = 1, monkey = 1;
        for (int i = 1; i <= n; i++)
            dog = 1LL * dog * i % mod;
        for (int i = 1; i <= m; i++)
            monkey = 1LL * monkey * i % mod;
        int res = 1LL * dog * monkey % mod;
        if (!(n - m))
            res = res * 2 % mod;
        printf("%d\n", res);
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9+5;
const ll INFLL = 1e18l+5;

int main(){
    int n,W;
    cin>>n>>W;
    vector<ll> dp(W+1,0); //dp[i] max val at weight = i
    
    for(int i=0; i<n; i++){
        int w,v;
        cin>>w>>v;

        for(int wa=W-w; wa>=0; --wa){
            dp[wa+w]=max(dp[wa+w],dp[wa]+v);
        }
    }

    cout<<dp[W];
    
}

Measured memory_bytes: 4044
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <unordered_map>

using namespace std;

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

	unordered_map<string, int> mp;
	long long ans = 0;
	for (int i = 0; i < N; i++)
	{
		string s;
		cin >> s;
		sort(s.begin(), s.end());

		if (mp.find(s) != mp.end())
		{
			ans += mp[s];
			mp[s]++;
		}
		else
		{
			mp[s] = 1;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 10660
package main

import (
  "bufio"
  "fmt"
  "os"
)

var sc = bufio.NewScanner(os.Stdin)

func readLine() string {
  sc.Scan()
  return sc.Text()

}

func main() {
  str := readLine()
  if str == "Sunny" {
    fmt.Println("Cloudy")
  } else if str == "Rainy" {
    fmt.Println("Sunny")
  } else {
    fmt.Println("Rainy")
  }
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;

const int N = 100009;

int a[N], b[N], c[N];
LL f[N];


int main()
{
    int n;
    scanf("%d", &n);
    for(int i = 0; i < n; i++) scanf("%d", &a[i]);
    for(int i = 0; i < n; i++) scanf("%d", &b[i]);
    for(int i = 0; i < n; i++) scanf("%d", &c[i]);
    sort(a, a+n);
    sort(b, b+n);
    sort(c, c+n);
    LL ans = 0;

    for(int i = 0; i < n; i++)
    {
        if(b[i] >= c[n-1]) break;
        f[i+1] = 1ll*n - (upper_bound(c, c+n, b[i]) - c);
    }
    f[0] = 0;
    for(int i = 1; i <= n; i++) f[i] += f[i-1];

    for(int i = 0; i < n; i++)
    {
        if(a[i] >= b[n-1]) break;
        int s = upper_bound(b, b+n, a[i]) - b;
        ans += f[n] - f[s];
    }

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



}



















Measured memory_bytes: 2176
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		String s = stdIn.next();
		
		int ans = 0;
		for(int i = 0; i < s.length();i++) {
			int cnt = 0;
			
			if(s.charAt(i)== 'A' ||s.charAt(i)== 'C' ||s.charAt(i)== 'G' || s.charAt(i)=='T') {
				cnt++;
				for(int j = i+1 ;j < s.length();j++) {
					if(s.charAt(j)== 'A' ||s.charAt(j)== 'C' ||s.charAt(j)== 'G' || s.charAt(j)=='T') {
						cnt++;
					}else {
						ans = Math.max(ans, cnt);
						break;
					}
				}
			}
			
			ans = Math.max(ans, cnt);
		}
		System.out.println(ans);
		
		
		
	}

}


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

#include<bits/stdc++.h>
using namespace std;

int main() {
    string n;

    while(1) {
        cin >> n;
        if(n == "0") break;

        int sum = 0;
        for(int i = 0; i < n.size(); i++) {
            sum += n[i] - '0';
        }

        cout << sum << endl;
    }
}


Measured memory_bytes: 3156
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()



int main() {
  ll n, sum = 0;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) {
    cin >> a[i];
    sum += a[i];
  }
  ll cnt = 1e10, sub = 0;
  rep(i, n) {
    sub += a[i];
    cnt = min(cnt, abs(sum-2*sub));
  }
  cout << cnt << endl;
  return 0;
}

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

int main() {
	int N, K; cin >> N >> K;
	vector<int> h(N);
	int dp[111111];
	for(int i=0; i<111111; i++) dp[i]=1e9;

	for(int i=0; i<N; i++) cin >> h[i];
	dp[0] = 0;
	dp[1] = abs(h[1]-h[0]);
	for (int i = 2; i < N; i++) {
		for (int j = 1; j <= K; j++) {
			if((i-j)<0) continue;
			dp[i] = min(dp[i], dp[i-j]+abs(h[i]-h[i-j]));
		}
	}

	cout << dp[N-1] << endl;
}


Measured memory_bytes: 1024