akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define si(c) ((int)(c).size())
#define forsn(i,s,n) for(int i = (int)(s); i<((int)n); i++)
#define dforsn(i,s,n) for(int i = (int)(n)-1; i>=((int)s); i--)
#define all(c) (c).begin(), (c).end()
#define D(a) cerr << #a << "=" << (a) << endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

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

const int N = 1e5 + 10;

int sz;
struct node {
    int nxt[2];
} st[N];

int newNode() {
    st[sz].nxt[0] = st[sz].nxt[1] = -1;
    return sz++;
}

void add(const string &s) {
    int act = 0;
    for (char c : s) {
        int &v = st[act].nxt[c-'0'];
        if (v == -1) v = newNode();
        act = v;
    }
}

ll ans = 0;
void dfs(int u, ll l) {
    int deg = 0;
    forn(c,2) if (st[u].nxt[c] != -1) {
        dfs(st[u].nxt[c], l-1);
        deg++;
    }
    if (deg == 1) {
        ans ^= l & (-l);
    }
}

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

    int root = newNode();
    int n;
    ll l; 
    cin >> n >> l;
    while (n--) {
        string s; cin >> s;
        add(s);
    }
    dfs(0,l);
    cout << (ans ? "Alice" : "Bob") << endl;

    return 0;
}


Measured memory_bytes: 4332
#include <cstdio>
#include <iostream>
#include <queue>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>

using namespace std;
int main(){
    int n,l;
    cin >> n >> l;
    if(l>0){
        cout<< (l+1+(l+n-1))*(n-1)/2 <<endl;
    }else if(l+n-1<0){
        cout<<(l+(l+n-2))*(n-1)/2<<endl;
    }else{
        cout<<(l+(l+n-1))*n/2<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <functional>
#include <string>
#include <stack>
#include <set>
#include <sstream>
#include <iomanip>
#include <limits>
#include <cstring>

using namespace std;
using ll = long long;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<double, double >pd;
typedef pair<string, string> sP;
typedef pair<ll, P> PP;
typedef pair<P, P> PPP;

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1 << 30;
const ll INF2 = 9e18;
const double INF3 = 5e14;
const double eps = 1e-10;
const double PI = acos(-1);
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int tx[8] = { -1,-1,-1,0,0,1,1,1 }, ty[8] = { -1,0,1,-1,1,-1,0,1 };

#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define fr first
#define sc second

ll n, a[200010], k, ans, sum[200010];
vector<ll>b;


struct BIT {
private:
	vector<ll>Bit;
	ll N;
public:
	void init(ll n) {
		N = n;
		Bit.resize(n);
	}
	void add(ll a, ll w) {
		for (int x = a; x < N; x += x & -x) Bit[x] += w;
	}
	ll SUM(ll a) {
		ll ret = 0;
		for (int x = a; x > 0; x -= x & -x) ret += Bit[x];
		return ret;
	}
};


int main() {
	cin >> n >> k;
	b.eb(0);
	for (int i = 0;i < n;i++) {
		cin >> a[i];
		a[i] -= k;
		sum[i + 1] = sum[i] + a[i];
		b.eb(sum[i + 1]);
	}
	sort(ALL(b));
	b.erase(unique(ALL(b)), b.end());
	for (int i = 0;i <= n;i++) {
		sum[i] = lower_bound(ALL(b), sum[i]) - b.begin() + 1;
	}
	BIT bit;
	bit.init(200010);
	for (int i = 0;i <= n;i++) {
		ans += bit.SUM(sum[i]);
		bit.add(sum[i], 1);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 6640
N = int(input())
input_list = [int(i) for i in input().split()]

index = 1
ruiseki_list = [0]*(N+1)
result = 10*9

if N == 2:
    print(abs(input_list[0]-input_list[1]))
else:
    for i in input_list:
        ruiseki_list[index] = ruiseki_list[index-1] + i
        index += 1

    mapped_list = map(lambda x: ruiseki_list[N]-x, ruiseki_list)
    result_list = [abs(a-b) for (a, b) in zip(ruiseki_list, mapped_list)]
    print(min(result_list[2:N]))

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

int main() {
  int n,p;
  vector<int> x;
  ll ans = 10000000;
  ll total = 0;
  int max_x ;

  cin >> n;
  rep(i,n) {
    int tmp;
    cin >> tmp;
    x.push_back(tmp);
  }
  max_x = *std::max_element(x.begin(),x.end());

  rep(i, max_x+1) {
    total=0;
    rep(j,n) {
      total+=pow(x[j]-i,2);
    }
    ans = min(ans,total);
  }
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt (string s) {int v; istringstream sin(s); sin>>v; return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iterator i=(c).begin();i!=(c).end();++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
const double EPS=1e-10;
const double PI=acos(-1.0);

struct P{
	string sides;
	P(string sides):sides(sides){}
};
typedef vector<P> vP;
typedef vector<vP> vvP;
int dx[]={0,1,0,-1},dy[]={-1,0,1,0};

bool match(char l,char r){
	if(l==' '||r==' '){
		return true;
	}
	if(l>r){
		swap(l,r);
	}
	switch(l){
	case 'R':
		return r=='r';
	case 'G':
		return r=='g';
	case 'B':
		return r=='b';
	case 'W':
		return r=='w';
	default:
		assert(r!='R'&&r!='G'&&r!='B'&&r!='W');
		return false;
	}
}

bool ok(vvP &board,P piece,int x,int y){
	REP(i,4){
		int xx=x+dx[i],yy=y+dy[i];
		if(xx>=0&&xx<3&&yy>=0&&yy<3){
			if(!match(board[xx][yy].sides[(i+2)%4],piece.sides[i])){
				return false;
			}
		}
	}
	return true;
}

P rotate(P &p,int a){
	P ret("    ");
	REP(i,4){
		ret.sides[i]=p.sides[(i+a)%4];
	}
	return ret;
}
int aaaa=0;
int dfs(vvP &board,vi used,int n,vP &pieces){
	if(n==9){
		return 1;
	}
	int res=0;
	int x=n%3,y=n/3;
	REP(i,9){
		if(!used[i]){
			REP(j,4){
				P piece=rotate(pieces[i],j);
				if(ok(board,piece,x,y)){
					vi newUsed(used);
					newUsed[i]=1;
					vvP newBoard(board);
					newBoard[x][y]=piece;
					res+=dfs(newBoard,newUsed,n+1,pieces);
				}
			}
		}
	}
	aaaa=max(aaaa,res);
	return res;
}

int main(){
	int N;
	cin>>N;
	REP(i,N){
		vP pieces;
		REP(j,9){
			string sides;
			cin>>sides;
			pieces.push_back(P(sides));
		}
		vvP v(3,vP(3,P("    ")));
		cout<<dfs(v,vi(9),0,pieces)<<endl;
	}
}

Measured memory_bytes: 932
n = int(input())
a = list(map(int, input().split()))
m = 0
id = -1
for i in range(n):
  if abs(a[i]) >= abs(m):
    m = a[i]
    id = i
ope = []
for i in range(n):
  a[i] += m
  ope.append([id+1, i+1])
if m >= 0:
  for i in range(1, n):
    a[i] += a[i-1]
    ope.append([i, i+1])
else:
  for i in range(1, n):
    a[n-i-1] += a[n-i]
    ope.append([n-i+1, n-i])
print(len(ope))
for x in ope:
  print(x[0], x[1])

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


int main(){
	int a[8];
	int cnt5=0;
	int cnt7=0;

	for(int i=0;i<3;i++){
		cin >> a[i];
	}

	for(int i=0;i<3;i++){
		if(a[i] == 5)
			cnt5++;
		else if(a[i]==7)
			cnt7++;
	}

	if(cnt5==2 && cnt7==1)
		cout << "YES" <<endl;
	else
		cout <<"NO" <<endl;

	return 0;
}

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

int main() {
    string s; cin >> s;
    int seen[26] = {0};

    for (int i = 0; i < s.length(); i++) {
        int ch = s[i] - 'a';
        seen[ch]++;
    }

    for (int i = 0; i < 26; i++) {
        if (seen[i] > 1) {
            cout << "no" << endl;
            return 0;
        }
    }

    cout << "yes" << endl;

    return 0;
}

Measured memory_bytes: 256
#coding:utf-8

a0,b0= map(int,input().split())
a1,b1 = map(int,input().split())
a2,b2 = map(int,input().split())

a=[a0,a1,a2,b0,b1,b2]

if a.count(1) > 2:
	print('NO')
elif a.count(2) > 2:
	print('NO')
elif a.count(3) > 2:
	print('NO')
elif  a.count(4) >2:
  print('NO')
else:
	print('YES')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>a
#define pb push_back

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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 gcd(ll a, ll b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

class UnionFind{
  public:
  vi Parent;
  UnionFind(int n){
    Parent = vi(n,-1);
  }

  int root(int a){
    if(Parent[a] < 0) return a;
    else return Parent[a] = root(Parent[a]);
  }

  int size(int a){
    return -Parent[root(a)];
  }

  bool merge(int a, int b){
    a = root(a);
    b = root(b);
    if(a == b) return false;

    if(size(a) < size(b)) swap(a,b);
    Parent[a] += Parent[b];
    Parent[b] = a;

    return true;
  }
};

class Factrial{
  public:
  vl Fac;
  Factrial(int MAX){
    Fac = vl(MAX+1);
    rep(i,MAX) {
      if(i == 0) Fac[i+1] = 1;
      else Fac[i+1] = ((i+1)*Fac[i])%MOD;
    }
  }
};


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

  vi q(n); rep(i,n) q[a[i]] = i;

  rep(i,n) cout << q[i]+1 << endl;
  
}

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

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define fastt ios_base::sync_with_stdio(false); cin.tie(NULL)
#define debug1(x) cout<<#x<<" : "<<x<<endl
#define debug2(x,y) cout<<#x<<" : "<<x<<" "<<#y<<" : "<<y<<endl
#define debug3(x,y,z) cout<<#x<<" : "<<x<<" "<<#y<<" : "<<y<<" "<<#z<<" : "<<z<<endl

typedef long long ll;
typedef pair<ll,ll> pii;
const ll modd=1e9+7;

ll poww(ll a,ll b){
  ll ans=1;
  while(b>0){
    if(b%2==1) ans=(ans*a);
    a=(a*a);
    b=b/2;
  }
  return ans;
}

/*-----------------------------------------------------------------------*/

int main(){
   fastt;
   
   ll n;
   string s;

   cin>>n>>s;

   vector <ll> dp(n+1);

   dp[1]=1;


   for(ll i=1;i<n;i++){
   	  vector <ll> prefix(n+1);
   	    for(ll j=1;j<=n;j++)
   	    	prefix[j]=(dp[j]+prefix[j-1])%modd;
   	   
   	    for(ll j=1;j<=i+1;j++){
   	    	if(s[i-1]=='<'){
                dp[j]=(prefix[j-1]-prefix[0]+modd)%modd;
   	    	}
   	    	else{
                dp[j]=(prefix[i]-prefix[j-1]+modd)%modd;
   	    	}
   	    }
   }
  
   ll ans=0;

   for(ll i=1;i<=n;i++)
   	  ans=(ans+dp[i])%modd;

   cout<<ans<<endl;

   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <deque>
#include <numeric>
#include <utility>
#define sign(a) ((a>0)-(a<0))
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define LL long long
#define INF (LL)(1LL<<60)

using namespace std;


void solve(long long N, long long T, std::vector<long long> A){
    LL mina=A[0], maxv=-1, cnt=1;
    for(LL i=1; i<N; i++){
        if(A[i] < mina)mina=A[i];
        LL tmp = A[i]-mina;
        if(tmp > maxv){
            maxv=tmp;
            cnt=1;
        }else if(tmp == maxv)
            cnt++;
    }
    cout << cnt << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long T;
    scanf("%lld",&T);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, T, std::move(A));
    return 0;
}


Measured memory_bytes: 1024
using System;

using System.Linq;

using System.Collections.Generic;



namespace hello_cs

{

    class Program

    {

        static void Main(string[] args)

        {

            var x = int.Parse(System.Console.ReadLine());

            var t = x / 500;

            var f = (x % 500) / 5;

            Console.WriteLine($"{t * 1000 + f * 5}");

        }

    }

}



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

inline int64_t ceiling_div(int64_t a, int64_t b){ // ceiling(a/b)= floor((a+b-1)/b)
  return (a+b-1)/b;
}

int main(){
  int K,A,B;
  cin >> K >> A >> B;
  
  int target= ceiling_div(A,K)* K;
  string ans=  (target <= B) ? "OK" 
                             : "NG";
  
  cout << ans << endl;
}

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

int main() {
  int d, n;
  cin >> d >> n;
  int x = 1;
  if (n == 100) n++;
  for (int i = 0; i < d; i++) x *= 100;
  cout << x * n << endl;
  return 0;
} 

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

long long candies[100002];
int main()
{
    int n;
    long long x;
    cin >> n >> x;
    for(int i = 1; i <= n; ++i)
        cin >> candies[i];
    long long ans = 0;
    for(int i = 2; i <= n; ++i)
    {
        long long eat = max(0ll, candies[i] + candies[i - 1] - x);
        ans += eat;
        if(eat >= candies[i])
        {
            eat -= candies[i];
            candies[i] = 0;
            candies[i - 1] -= eat;
        }
        else
            candies[i] -= eat;
    }
    ans += max(0ll, candies[1] + candies[2] - x);
    cout << ans << endl;
    return 0;
}


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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

using pll=pair<long long,long long>;//(money,time)
using Edge=pair<int,pll>;
using Graph=vector<vector<Edge>>;
const int MAX=2500;

//入力変数
int N,M;
long long S;
Graph G;
vector<long long>C,D;//money,time

/*
解法

グラフの各頂点に所持金の情報を持たせる
(v,0):=頂点vに到達していて、所持金が0円
(v,1):=頂点vに到達していて、所持金が1円
(v,2):=頂点vに到達していて、所持金が2円
(v,i):=頂点vに到達していて、所持金がi円
ただし 一度到達した島に二度以上行く必要はないので、
(0 <= i <= A_max*n)とする

このとき、
頂点u(所持金s円)から所持金a円(所要時間b秒)を必要とする辺e=(u,v)を通ること
=>頂点(v,s)->頂点(v,s-a)への重みbの辺とみなせる

頂点u(所持金s円)でc円分の補充をする(所要時間d秒)作業
=頂点(u,s)->頂点(u,s+c)への重みdの辺と見なせる

dp[v][s]:=頂点vにいて、所持金sという状態になるのに要する最小の時間

と定義して、ダイクストラ法によって求めていく。

*/

void solve(){
    //2500円以上は必要ないので捨てる
    if(S>=MAX)S=MAX;

    vector<vector<long long>> dp(N,vector<long long>(MAX+1,INF));
    priority_queue
    <pair<long long,pll>,
    vector<pair<long long,pll>>,
    greater<pair<long long,pll> > >que;

    //スタート時の状態
    dp[0][S]=0;

    //(現在時刻,(今いる頂点,所持金))
    que.push(make_pair(0,pll(0,S)));

    //これ以上最短の経路が見つからなくなると終了する
    while(!que.empty()){

        //現在の時間timeと頂点の情報(v,s)
        //p=(time,(v,s))
        auto p=que.top();que.pop();
        
        long long time=p.first;//現在時刻
        int v=p.second.first;//現在いる頂点
        long long s=p.second.second;//所持金

        if(time>dp[v][s])continue;

        //銀貨の補充
        if(s+C[v]<=MAX){
            long long ns=s+C[v];
            long long ntime=time+D[v];
            if(chmin(dp[v][ns],ntime)){
                que.push(make_pair(ntime,pll(v,ns)));
            }
        }

        //辺を張る
        for(auto e:G[v]){
            //現在いる頂点(v,s)から辺を張る
            if(s<e.second.first)continue;
        
            //次の頂点
            int nv=e.first;

            //次の頂点に着いた時の所持金
            long long ns=s-e.second.first; 

            //次の頂点に着いた時の時間
            long long ntime=time+e.second.second;

            //もし、今のところ見つけた(v,s)->(nv,ns)よりも
            //最短の経路であるならばその頂点からまた探索

            if(chmin(dp[nv][ns],ntime)){
                que.push(make_pair(ntime,pll(nv,ns)));
            }
        }
    }
    
    for(int v=1;v<N;v++){
        long long res=INF;
        for(int s=0;s<=MAX;s++)chmin(res,dp[v][s]);
        cout<<res<<endl;
    }
}



int main(){
    cin>>N>>M>>S;
    G.assign(N,vector<Edge>());
    for(int i=0;i<M;i++){
        long long u,v,a,b;
        cin>>u>>v>>a>>b;
        --u,--v;
        G[u].push_back(Edge(v,pll(a,b)));
        G[v].push_back(Edge(u,pll(a,b)));
    }
    C.resize(N);D.resize(N);
    for(int i=0;i<N;i++){
        cin>>C[i]>>D[i];
    }
    solve();
    return 0;

}
/*


*/


Measured memory_bytes: 7216
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
const ll MOD = 998244353;
//const ll MOD = (1e+9) + 7;
typedef pair<ll, ll> P;
const ll INF = (1LL<<62);

int main() {
    long double b;
    cin>>A>>b;
    b *= A;
    cout<<ll(b)<<endl;
}

Measured memory_bytes: 3744
#include <cstdio>


int m[100][100], w, h, xs, ys, xg, yg, n;
int c, d, x, y, col;


bool solve(int X, int Y){
    if(X < 0 || X >= w || Y < 0 || Y >= h) return false;

    if(m[Y][X] != col) return false;
    if(Y == yg && X == xg) return true;

    m[Y][X] = 0;

    if(solve(X + 1, Y)) return true;
    if(solve(X - 1, Y)) return true;
    if(solve(X, Y + 1)) return true;
    if(solve(X, Y - 1)) return true;

    return false;
}


int main(){
    while(scanf("%d %d", &w, &h) != EOF){
        if(w == 0 && h == 0) break;

        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                m[i][j] = 0;
            }
        }

        scanf("%d %d", &xs, &ys);
        scanf("%d %d", &xg, &yg);
        scanf("%d", &n);

        xs--; ys--;
        xg--; yg--;

        for(int i = 0; i < n; i++){
            scanf("%d %d %d %d", &c, &d, &x, &y);
            x--; y--;

            if(d == 0){
                for(int i = y; i < y + 2; i++){
                    for(int j = x; j < x + 4; j++){
                        m[i][j] = c;
                    }
                }
            }else if(d == 1){
                for(int i = y; i < y + 4; i++){
                    for(int j = x; j < x + 2; j++){
                        m[i][j] = c;
                    }
                }
            }
        }

        col = m[ys][xs];
        if(col == 0){
            printf("NG\n");
            continue;
        }
        if(solve(xs, ys)){
            printf("OK\n");
        }else{
            printf("NG\n");
        }

    }

    return 0;
}

Measured memory_bytes: 2636
#include <iostream>

using namespace std;

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

	long long ans = 0;
	for (long long  r = 0; r * R <= N; ++r) {
		for (long long  g = 0; g * G <= N; ++g) {
			long long  x = N - r * R - g * G;
			if (0 <= x && x % B == 0) {
				++ans;
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define print(n) cout<<n<<endl
#define rep(i,a,n) for(int i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define vvl vector<vector<ll>>
#define vvi vector<vector<int>>
const int M=200111;
const int inf=1000000007;
const long long INF=1e18;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};


struct UnionFind {
	vector<int> par;
	UnionFind(int n) : par(n, -1) { }

	int root(int x) {
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool same(int x, int y) {
		return root(x) == root(y);
	}

	bool merge(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y); // merge technique
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x) {
		return -par[root(x)];
	}
};

vvl comb(int n, int r) {
	vvl v(n + 1,vl(n + 1, 0));
	for (int i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int j = 1; j < v.size(); j++) {
		for (int k = 1; k < j; k++) {
			v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
		}
	}
	return v;
}

void sosu(ll x,bool f[]){
	ll y=x;
	for(ll i=2;i<=sqrt(y);i++){
		if(x%i==0){
			x/=i;
			f[i]=true;
			i--;
		}
	}
}

ll __gcd(ll x,ll y){
	if(x<y)swap(x,y);
	while(1){
		ll tmp=x%y;
		x=y;
		y=tmp;
		if(y==0)break;
	}
	return x;
}

int keta(ll a){
	int ke=1;
	while(a/=10)ke++;
	return ke;
}


int main() {
	double PI=3.14159265358979323846;
	double a,b,v;
	cin>>a>>b>>v;
	double theta;
	if(a*a*b>=2*v){
		theta=atan(a*b*b/2/v)*180/PI;
	}else{
		theta=90-atan(pow(a,3)/(2*(a*a*b-v)))*180/PI;
	}
	print(setprecision(18)<<theta);
}


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

using ll=long long;

int main() {
  int a; cin >>a;
  bool ans=true;
  rep(i,1,3) {
    int b; cin >>b;
    if (a!=b) {
      ans=false;
      break;
    }
  }
  cout <<(ans ? "Yes":"No") <<endl;
  return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>  // This will work only for g++ compiler. 


#define for0(i, n) for (int i = 0; i < (int)(n); ++i) // 0 based indexing
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i) // 1 based indexing
#define forc(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i) // closed interver from l to r r inclusive
#define forr0(i, n) for (int i = (int)(n) - 1; i >= 0; --i) // reverse 0 based.
#define forr1(i, n) for (int i = (int)(n); i >= 1; --i) // reverse 1 based

//short hand for usual tokens
#define pb push_back
#define fi first
#define se second

using namespace std;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s,aux1,aux2;
    vector<string> possibles;
    cin >> s;
    int n = s.size();
    for0(i,n){
		if(s[i] == '?'){
			if( i == 0 ) s[i] = 'D';
			else if( i == n-1) s[i] = 'D';
			else{
				if(s[i-1] == 'P' || s[i+1] == 'P') s[i] = 'D';
				else s[i] = 'P';
			}
		}
	}
	cout << s << endl;
}


Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define MOD 1e9 + 7

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

    int n,p,od = 0,ev = 0;
    long long ans = 1;

    cin >> n >> p;

    for(int i = 0;i < n;i++)
    {
        int a;
        cin >> a;
        if(a%2==0) ev++;
        else od++;
    }
    if(od==0)
        ans = (1LL << n);
    else
        ans = (1LL << (n-1));
    if(p==1)
        ans = (1LL << n)-ans;
    cout << ans;
}


Measured memory_bytes: 256
D = int(input())#D=365
c = [0] + list(map(int, input().split()))#0<=c<=100
s = [0] + [[0] + list(map(int, input().split())) for _ in range(D)]#0<=s<=20000

t = [0] + [int(input()) for _ in range(D)]

M = int(input())
dq = [list(map(int, input().split())) for _ in range(M)]


held = [[0] for _ in range(27)]#選んだ日を保持
def culc_value(t):
    last = [0] * 27
    value = 0
    for d in range(1, D+1):
        type = t[d]
        held[type].append(d)
        value += s[d][type]
        last[type] = d
        for i in range(1, 27):
            value -= c[i] * (d - last[i])
    # 最終日+1 を追加、差分修正で前後見るときの後ろの最大値
    for i in range(1, 27):
        held[i].append(D+1)
    #print(held)
    return value


v_lastday = []
value = culc_value(t)

for d, q in dq:
    # 開催日の差分を修正
    value += - s[d][t[d]] + s[d][q]

    # dの前と後のq選択日のみ考えて、その間だけ修正する
    # 変換前のt[d-1]のマイナス計算を直す
    ind = held[t[d]].index(d)
    r = held[t[d]][ind+1]
    l = held[t[d]][ind-1]
    x = r - l
    value -= ((x + 1) * x // 2) * c[t[d]]
    y = d - l
    z = r - d
    value += (((y + 1) * y // 2) + (z + 1) * z // 2) * c[t[d]]

    del held[t[d]][ind]
    t[d] = q
    held[q].append(d)
    held[q] = sorted(held[q])
    #print(held[q])

    # 変換後のqのマイナス計算
    ind = held[q].index(d)
    r = held[q][ind+1]
    l = held[q][ind-1]
    x = r - l
    value += ((x + 1) * x // 2) * c[q]
    y = d - l
    z = r - d
    value -= (((y + 1) * y // 2) + (z + 1) * z // 2) * c[q]

    v_lastday.append(value)

for ans in v_lastday:
    print(ans)


Measured memory_bytes: 26096
N,K = map(int, input().split())
h = list(int(i) for i in input().split())
dp = [float("inf")]*N
dp[0] = 0
for i in range(1,N):
    for j in range(max(0,i-K),i):
        dp[i] = min(dp[i],dp[j]+abs(h[i]-h[j]))
print(dp[-1])

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

int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<char>> a(h, vector<char>(w));
  for (int i=0; i<h; i++){
    for (int j=0; j<w; j++){
      cin >> a.at(i).at(j);
    }
  }
  // h行w列の行列aに"."や"#"を入力
  
  vector<bool> row(h, 1), column(w, 1);
  // 各々の行や列を取り除くか判定するフラグをONにしておく
  
  for (int i=0; i<h; i++){
    for (int j=0; j<w; j++){
      if (a.at(i).at(j) == '#'){
        row.at(i) = 0;
        // ある行の要素w個のうち1つでも"#"があれば
        // 取り除くフラグを解除する
      }
    }
  }
  
  for (int j=0; j<w; j++){
    for (int i=0; i<h; i++){
      if (a.at(i).at(j) == '#'){
        column.at(j) = 0;
        // ある列の要素h個のうち1つでも"#"があれば
        // 取り除くフラグを解除する
      }
    }
  }
  
  for (int i=0; i<h; i++){
    if (row.at(i) == 0){
      for (int j=0; j<w; j++){
        if (column.at(j) == 0){
          cout << a.at(i).at(j);
        }
      }
      cout << endl;
    }
  }
}


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

using namespace std;

#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.length()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>())

int main(){
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	SORT(a,3);
	cout << a[0]+a[1] << endl;

}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter};
use std::io::*;
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

// -----------------------------------------------
// Framework
// -----------------------------------------------

#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($arg:expr),*) => {
        #[cfg(debug_assertions)]
        {
            let entries = [$(&stringify!([$arg]:), &$arg as &Debug),*];
            stderr().write_fmt(format_args!("{:?}\n", entries)).unwrap();
        }
    };
}

#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}

// -----------------------------------------------
// Solution
// -----------------------------------------------

pub fn recurse<X, Y>(x: X, f: &Fn(X, &Fn(X) -> Y) -> Y) -> Y {
    f(x, &|x: X| recurse(x, &f))
}

pub fn main() {
    let S = rl().chars().vec();
    let N = S.len();

    let P = 1_000_000_007_i64;
    let ABC = "ABC".chars().vec();

    let mut dp = vec![vec![0; N + 1]; 3 + 1];
    dp[3][N] = 1;

    for i in (0..N).rev() {
        dp[3][i] = (dp[3][i + 1] * if S[i] == '?' { 3 } else { 1 }) % P;
    }

    for r in (0..3).rev() {
        for i in (0..N).rev() {
            dp[r][i] = if S[i] == ABC[r] {
                (dp[r][i + 1] + dp[r + 1][i + 1]) % P
            } else if S[i] == '?' {
                (dp[r][i + 1] * 3 % P + dp[r + 1][i + 1]) % P
            } else {
                dp[r][i + 1]
            }
        }
    }

    println!("{}", dp[0][0]);
}


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

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


// greedy is wrong solution
//   |
//   V
// digit dp

ll dp[64][2]; //dp[確認している桁数(2)][以前にK以下の数が出たかどうか] = 確認している桁の中の最適解
int main(){
  ll N,K;
  cin >> N >> K;

  VLL A(N);
  rep(i,N) cin >> A[i];

  //init
  rep(i,64) dp[i][0] = dp[i][1] = -1;
  dp[63][0] = 0;

  //桁を上位ビットから探索
  for(int d = 62; d >= 0; d--){
    ll bitCnt = 0;
    //A[x] x = [0,N) d bit目に何個bitが立っているか
    rep(i,N) bitCnt += (A[i] >> d) & 1;

    //現在の時点でKよりも小さいことが確定している場合
    if(dp[d+1][1] != -1) dp[d][1] = dp[d+1][1] + (2 * bitCnt < N ? N-bitCnt : bitCnt) * (1LL << d);

    //現在の時点でKよりも小さいことが確定していない場合
    bool kBitFlag = (K >> d) & 1;
    if(kBitFlag == false) dp[d][0] = dp[d+1][0] + bitCnt * (1LL << d);
    if(kBitFlag == true){
      dp[d][1] = max(dp[d+1][0] + bitCnt * (1LL << d), dp[d][1]);
      dp[d][0] = max(dp[d+1][0] + (N-bitCnt) * (1LL << d), dp[d][0]);
    }
    //cout << d << ": " << dp[d][0] << " , " << dp[d][1] << endl;
  }

  cout << max(dp[0][0], dp[0][1]) << endl;
  return 0;
}


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

#define INF 1e9
using namespace std;
using ll = long long;

int main() {

    ll N; cin >> N;

    vector<ll> H(N);
    for (int i = 0; i < N; ++i) {
        cin >> H[i];
    }

    ll pre = -1;

    for (int i = 0; i < N; ++i) {
        if (pre <= H[i] - 1) {
            pre = H[i] - 1;
        } else if (pre <= H[i]) {
            pre = H[i];
        } else {
            puts("No");
            return 0;
        }
    }

    puts("Yes");
}

Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <cstdio>

using namespace std;

typedef long long ll;
ll a[4];

int main() {
	
	cin >> a[1] >> a[2] >> a[3];
	
	sort(a+1,a+3+1);
	
	if(!(a[1]&1) || !(a[2]&1) || !(a[3]&1))	puts("0");
	else	printf("%lld\n",a[1]*a[2]);
	
	return 0;
	
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

const int M=1000010;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin>>n;
  
  vector<int> A(n);
  rep(i,n) cin>>A[i];

  vector<int> C(M);
  
  rep(i,n){
    if(C[A[i]]!=0){
      C[A[i]]=2;
      continue;
    }
    for(int j=A[i];j<M;j+=A[i]){
      C[j]++;
    }
  }
  
  int cnt=0;
  rep(i,n){
    if(C[A[i]]==1) cnt++;
  }
  
  cout<<cnt<<endl;
  
  return 0;
}

Measured memory_bytes: 7952
import heapq
N = int(input())
q = []
heapq.heapify(q)
for i in range(N):
    a,b = map(int, input().split())
    heapq.heappush(q,(b,a))

time = 0
flg = True
for i in range(N):
    b,a = heapq.heappop(q)
    time += a
    # print(a,b,time)
    if b < time:
        flg = False
if flg:
    print("Yes")
else:
    print("No")

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

int main(){
  string S;
  cin >> S;
  set<char> s;
  s.insert('K');
  s.insert('B');
  s.insert('R');
  for(int i=0;i<S.size()-1;i++){
    if(S.at(i)=='A'){
      if(!s.count(S.at(i+1))){
        cout << "NO" << endl;
        return 0;
      }
    }
  }
  for(auto itr=S.begin();itr!=S.end();){
    if(*itr=='A'){
      itr=S.erase(itr);
    }else{
      itr++;
    }
  }
  if(S=="KIHBR"){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>
#include <deque>
#include <tuple>
#include <map> 
#include <set>
#include <stack>
#include <functional>
#define ll long long
using namespace std;

int main() {
	int X;

	cin >> X;

	if (X >= 30) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 3616
using System;
using System.Collections.Generic;
class itp1_11_a{
  public static void Main(){
    String[] str = Console.ReadLine().Split(' ');
    Dice d = new Dice(str[0], str[1], str[2], str[3], str[4], str[5]);
    Rotate rtt = new Rotate();
    int n = int.Parse(Console.ReadLine());
    for(int x=0; x<n; x++){
      bool top_correct = false;
      String[] order = Console.ReadLine().Split(' ');
      for(int i=0; i<4; i++){
        if(d.top == int.Parse(order[0])){
          top_correct = true;
          break;
        }
        rtt.north(d);
      }
      if(!top_correct){
        for(int i=0; i<4; i++){
          if(d.top == int.Parse(order[0])){
            top_correct = true;
            break;
          }
          rtt.east(d);
        }
      }
      for(int i=0; i<4; i++){
        if(d.front == int.Parse(order[1])){
          break;
        }
        rtt.turn_right(d);
      }
      Console.WriteLine(d.right);
    }
  }
}


class Rotate{
  public void north(Dice d){
    int temp = d.top;
    d.top = d.front;
    d.front = d.bottom;
    d.bottom = d.behind;
    d.behind = temp;
  }
  public void south(Dice d){
    int temp = d.top;
    d.top = d.behind;
    d.behind = d.bottom;
    d.bottom = d.front;
    d.front = temp;
  }
  public void east(Dice d){
    int temp = d.top;
    d.top = d.left;
    d.left = d.bottom;
    d.bottom = d.right;
    d.right = temp;
  }
  public void west(Dice d){
    int temp = d.top;
    d.top = d.right;
    d.right = d.bottom;
    d.bottom = d.left;
    d.left = temp;
  }
  public void turn_right(Dice d){
    int temp = d.front;
    d.front = d.left;
    d.left = d.behind;
    d.behind = d.right;
    d.right = temp;
  }
  public void turn_left(Dice d){
    int temp = d.front;
    d.front = d.right;
    d.right = d.behind;
    d.behind = d.left;
    d.left = temp;
  }
}

class Dice{
  public int top { get; set; }
  public int front { get; set; }
  public int right { get; set; }
  public int left { get; set; }
  public int behind { get; set; }
  public int bottom { get; set; }
  public Dice(){
    top = 1;
    front = 2;
    right = 3;
    left = 4;
    behind = 5;
    bottom = 6;
  }
  public Dice(int t, int f, int r, int l, int be, int bo){
    top = t;
    front = f;
    bottom = bo;
    behind = be;
    right = r;
    left = l;
  }
  public Dice(String t, String f, String r, String l, String be, String bo){
    top = int.Parse(t);
    front = int.Parse(f);
    right = int.Parse(r);
    left = int.Parse(l);
    behind = int.Parse(be);
    bottom = int.Parse(bo);
  }
}



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

// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  int total = 0;
  for (int i = 1; i <= N; i++) {
    int sum = findSumOfDigits(i); // i の各桁の和
    if (sum >= A && sum <= B) { //  i の各桁の和が A 以上 B 以下かどうか
      total += i;
    }
  }
  cout << total << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int X = sc.nextInt();
		int Y = sc.nextInt();
		int n = 0;
		int m = 0;
		int s = 0;

		for(int i = 0;i<X+1;i++) {
			m=X-i;
			n=2*i+4*m;
			if(n==Y) {
				s=1;
			}
		}
		if(s==1) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 35944
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")

#include<bits/stdc++.h>

using namespace std;
#define ll long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define ull unsigned long long
#define repi(i,a) for(auto i = a.begin(); i!= a.end() ;++i) 
#define repdi(i,a) for(auto i = a.begin(); i!=a.end();++i) 
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define MOD 1000000007
#define ff first
#define ss second
#define fast ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0); 
#define nl "\n"
#define INF 1e18
#define sz(a) (ll)a.size() 
#define all(a) a.begin(),a.end()
#define M 998244353
#define limit 100000000

typedef vector<ll> vll;
typedef pair<ll,ll> pii;
typedef vector<pii> vpi;
typedef vector<vector<ll> > vv;


void solve() {
	
	double r; cin >> r;

	cout << fixed << setprecision(12) << (double) 2.0 * (22.0/7.0) * r ;
}


int main() {

    fast;
	int t=1;
	// cin>>t;
	rep(i,0,t) {
		solve() ;
	}
	return 0;
}

Measured memory_bytes: 3756
def resolve():
	n,q=map(int,input().split())
	s=input()
	lr=[list(map(int,input().split())) for i in range(q)]

	t=[0]*(n+1)
	for i in range(n):
		t[i+1]=t[i]+(s[i:i+2]=='AC')
	
	for i in range(q):
		l=lr[i][0]
		r=lr[i][1]

		print(t[r-1]-t[l-1])
resolve()

Measured memory_bytes: 68184
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string x;
    cin >> x;
    if(x[0] == '0'){cout << "Yes" << endl; return 0;}
    int sum = 0;
    for (int i = 0; i < x.length(); ++i){
        sum += x[i]-'0';
    }
    if(sum%9 == 0){cout << "Yes" << endl;}
    else{std::cout << "No" << std::endl;}
    return 0;
}


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

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

    vector<int> a(n);
    rep(i, 0, n) cin >> a[i];

    int sum = accumulate(a.begin(), a.end(), 0);

    cout << (h <= sum ? "Yes" : "No") << endl;
    
    return 0;
}

Measured memory_bytes: 640
n=int(input())
a=list(map(int,input().split()))
for i in range(n-1,-1,-1):
  s=sum(a[i::i+1])
  if s%2!=a[i]:
    a[i]=1-a[i]
print(a.count(1))
print(*[i+1 for i,x in enumerate(a) if x])

Measured memory_bytes: 72156
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(obj) (obj).begin(),(obj).end()
typedef long long ll;
ll mod=2e12;
ll cnt=0;
#define max 100005
#define nil -1
//8.3
struct data{int l,r,p;};

struct data T[max];
int D[max],H[max];

void rec(int i,int p){
    if(i==nil) return;
    D[i]=p;
    if(T[i].r!=nil)rec(T[i].r,p+1);
    if(T[i].l!=nil)rec(T[i].l,p+1);
    return;
}

int hight(int i){
  int l=0,r=0;
  if(T[i].l!=nil) l=hight(T[i].l)+1;
  if(T[i].r!=nil) r=hight(T[i].r)+1;
  return H[i]=(l>r?l:r);
}

int sibling(int i){
  int p=T[i].p;
  if(p==nil) return -1;
  else if(T[p].l==i) return T[p].r;
  else return T[p].l;
}
void print(int i){
    int a;
    cout<<"node "<<i<<": parent = "<<T[i].p<<", sibling = ";
    cout<<sibling(i);
    cout<<", degree = ";
    if(T[i].l!=nil&&T[i].r!=nil) cout<<2;
    else if(T[i].l!=nil||T[i].r!=nil) cout<<1;
    else cout<<0;
    cout<<", depth = "<<D[i]<<", height = "<<H[i];
    if(D[i]==0)cout<<", root";
    else if(T[i].l==nil&&T[i].r==nil)cout<<", leaf";
    else cout<<", internal node";
    cout<<endl;
    return;
}

int main(){
    int n,d,r,l;
    cin>>n;
    for(int i=0;i<n;i++) T[i].p=T[i].l=T[i].r= nil;
    for(int j=0;j<n;j++){
        cin>>d>>l>>r;
        T[d].l=l;
        T[d].r=r;
        if(l!=nil)T[l].p=d;
        if(r!=nil)T[r].p=d;
    }
    for(int i=0;i<n;i++){
        if(T[i].p==nil) r=i;
    }
    rec(r,0);
    hight(r);
    for(int i=0;i<n;i++) print(i);
   return 0;
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const double eps = 1e-8;

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif

int main() {
    int N;
    cin >> N;
    map<string, int> cnt;
    string s;
    int mx = 0;
    for (int i=0; i<N; ++i) {
        cin >> s;
        cnt[s] ++;
        mx = max(mx, cnt[s]);
    }
    vector<string> res;
    for (auto p: cnt) {
        if (p.second == mx) {
            res.push_back(p.first);
        }
    }
    sort(res.begin(), res.end());
    for (string t: res) {
        cout << t << endl;
    }
    return 0;
}

Measured memory_bytes: 26868
N,X = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
k1 = k2 = 0
for i in range (N):
  if sum(A[:i+1]) > X:
    k1 = i
    k2 = 1
    break
  elif sum(A) == X:
    k1 = N
    k2 = 1
    break
if k2 == 0:
  k1 = N - 1
print(k1)

Measured memory_bytes: 9052
import java.util.*;
import java.math.BigInteger;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        int n = Integer.parseInt(line);
        for(int i = 0; i < n; i++) {
            String line1 = sc.nextLine();
            String line2 = sc.nextLine();
            BigInteger a = new BigInteger(line1);
            BigInteger b = new BigInteger(line2);
            BigInteger ab = a.add(b);
            String sum = ab.toString();
            if(sum.length() > 80) {
                System.out.println("overflow");
            }else {
                System.out.println(sum);
            }
        }
    }
}



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

// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

// type
using ll = int_fast64_t;
using ull = uint_fast64_t;
using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
//using pair<T1, T2> = p12;

//container
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
#define ALL(v) v.begin(),v.end()

//repetition
#define REP(n) for(ll i=0; i<(n); i++)
#define REPj(n) for(ll j=0; j<(n); j++)
#define REPinit(i,a,n) for(int i=(a); i<(n); i++)
#define REPinitj(j,a,n) for(int j=(a); j<(n); j++)

//algorithm
#define SORT(c) sort((c).begin(),(c).end())
#define CONTAINER_ALL(a) a.begin(),a.end()

//constant

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//Optimizer
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")


bool judge(int a, int b, int c) {
    if ((a > b && b > c) || (a < b && b < c)) return true;
    return false;
}

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

    int N;
    cin >> N;

    int pos = 0;
    int p;
    REPinit(i, 0, N) {
        cin >> p;
        if (p != (i + 1)) pos++;
    }

    if (pos < 3) cout << "YES" << endl;
    else cout << "NO" << endl;


    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <iomanip>
#include <cmath>
#include <functional>
#include <algorithm>
#include <numeric>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <boost/container/static_vector.hpp>
#include <boost/utility/string_ref.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/math/common_factor_rt.hpp>

template <class... Args>
struct tuple_input_impl;
template <std::size_t i, std::size_t... tail>
struct tuple_input_impl<std::index_sequence<i, tail...>>
{
    template <class... Args>
    static void f(std::tuple<Args...>& x)
    {
        std::cin >> std::get<i>(x);
        tuple_input_impl<std::index_sequence<tail...>>::f(x);
    }
};
template <>
struct tuple_input_impl<std::index_sequence<>>
{
    static void f(...) {}
};

template <class... Args>
std::istream& operator>>(std::istream& in, std::tuple<Args...>& x)
{
    tuple_input_impl<std::index_sequence_for<Args...>>::f(x);
    return in;
}
template <class T1, class T2>
std::istream& operator>>(std::istream& in, std::pair<T1, T2>& x) { return in >> x.first >> x.second; }

template <class T>
T read()
{
    T res;
    std::cin >> res;
    return res;
}
template <class T>
std::vector<T> read(std::size_t n)
{
    std::vector<T> res(n);
    for (std::size_t i = 0; i < n; ++i) std::cin >> res[i];
    return res;
}

template <class T>
void out_impl(T&& v) { std::cout << std::forward<T>(v); }
template <class T, class... Args>
void out_impl(T&& v, Args&&... args)
{
    std::cout << std::forward<T>(v) << ' ';
    out_impl(std::forward<Args>(args)...);
}
template <class... Args>
void out(Args&&... args)
{
    out_impl(std::forward<Args>(args)...);
    std::cout << '\n';
}
template <class... Args>
void out_noreturn(Args&&... args) { out_impl(std::forward<Args>(args)...); }

template <class T>
void print(const T& container)
{
    bool first = true;
    for (auto&& x : container) {
        if (!first) std::cout << ' ';
        std::cout << x;
        first = false;
    }
    std::cout << '\n';
}

void prog()
{
    int n, m;
    std::cin >> n >> m;
    std::vector<int> lamp(m);
    for (int i = 0; i < m; ++i) {
        for (int b : read<int>(read<int>())) {
            lamp[i] |= 1 << (b - 1);
        }
    }
    auto p = read<int>(m);
    int res = 0;
    for (int i = 0; i < (1 << n); ++i) {
        int s = 0;
        for (int j = 0; j < m; ++j) {
            auto x = __builtin_popcount(i & lamp[j]);
            if (x % 2 == p[j]) ++s;
        }
        if (s == m) ++res;
    }
    out(res);
}

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


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  string S, T;
  cin>>S>>T;
  bool can = false;
  bool tmp;
  for(int i=0;i<S.size();++i) {
    tmp = true;
    for(int j=0;j<S.size();++j) {
      if(S[(i+j)%S.size()]!=T[j]) tmp = false;
    }
    if(tmp) can = true;
  }
  if(can) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}



Measured memory_bytes: 3600
N, T = map(int, input().split())
fs = [tuple(map(int, input().split())) for _ in range(N)]
fs = sorted(fs)
dp = [0] * 6005

for a, b in fs:
    for t in range(T + a - 1, a - 1, -1):
        dp[t] = max(dp[t - a] + b, dp[t])
print(max(dp))


Measured memory_bytes: 75060