akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
	using namespace std;
	#define int long long
	#define ld long double
	#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
	#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
	#define RI(i,n) FOR(i,1,(n))
	#define REP(i,n) FOR(i,0,(n)-1) 
	#define mp make_pair
	#define pb push_back
	#define st first
	#define nd second
	#define sz(w) (int) w.size() 
	#define inf 1e9+9
	#define MAX 1e5+5
	#define fast  ios_base::sync_with_stdio(false);  cin.tie(NULL);
	typedef vector<int> vi;
	typedef pair<int,int> pii; 

	int max(int a, int b){return a>b? a:b;}
	int min(int a, int b){return a<b? a:b;}
	const int MOD = 1e9+7;
 

	void helperi(int a[], int k, int n){
		int dp[k+1];
		// dp[i]: no of ways we used i candies so farA
		memset(dp,0, sizeof(dp));  
		dp[0]=1;
		int prefix[k+1]; memset(prefix, 0, sizeof(prefix));
		 
		for(int i=1;i<=n;i++){
			prefix[0]=dp[0];
			dp[0]=0;
			for(int j=1;j<=k;j++)
				prefix[j]=(prefix[j-1]+dp[j])%MOD;

			for(int j=k;j>=0;j--){  
				int sum = prefix[j];
				int l = j - min(a[i-1], j);
				if(l!=0)
					sum-=prefix[l-1];
				dp[j]=sum%MOD;
			}
		}
	
		cout << (dp[k]+MOD)%MOD << endl;
	}


	void solve(){
		
		int n, k; 
		cin >> n >> k;
		int a[n];
		for(int i=0;i<n;i++)
			cin>>a[i];
		//cout << "DONE "
		helperi(a, k, n);
	}


	int32_t main(){ 
		fast
		int t;
		// cin>>t;
		t=1;
		while(t--){
			solve();
		}
	}

Measured memory_bytes: 5228
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <tuple>
#include <iterator>
#include <sstream>
#include <bits/stdc++.h>

using ll = long long;
using namespace std;
#define modmod 1000000007

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,k,n) for(int i=k;i<n;i++)

int main(){
    int N;
    cin >> N;
    ll a[3*N];
    rep(i,3*N) cin >> a[i];

    sort(a,a+3*N,greater<ll>());

    ll result = 0;

    for(int i = 0 ; i < 2*N; i++){
        if(i%2 == 1){
            result += a[i];
        }
    }

    cout << result << endl;
    return 0;

}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;


vi mts {0,2,5,5,4,5,6,3,7,6};

void solve(int N, int M, vi& A){
  vi u(8,-1);
  for (int i=0;i<M;++i){
    int m=mts[A[i]];
    u[m]=max(u[m],A[i]);
  }

  vvi dp(N+10, vi(10,-1));
  dp[0]=vi(10,0);
  for (int i=0;i<N;++i){
    for (int m=2;m<=7;++m){
      if (u[m]==-1){continue;}
      int p=10-u[m];
      dp[i][p]++;
      dp[i][0]++;
      dp[i+m]=max(dp[i+m], dp[i]);
      dp[i][p]--;
      dp[i][0]--;
    }
  }

  for (int n=9;n>=1;--n){
    for (int j=0;j<dp[N][10-n];++j){
      putchar('0'+n);
    }
  }
  putchar('\n');
}

int main(){
  int N,M;cin>>N>>M;
  vi A(M);
  for (int i=0;i<M;++i){
    int a;cin>>a;
    A[i]=a;
  }
  solve(N, M, A);
  return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define vll vector<ll>
#define endl "\n"
#define pll pair<ll,ll>
#define all(x) (x).begin() , (x).end()
#define f first
#define s second
#define pr(x) cout<<x<<endl;
#define pr2(x,y) cout<<x<<" "<<y<<endl;
#define pr3(x,y,z) cout<<x<<" "<<y<<endl;
#define prv(v) for(auto x:v) cout<<x<<" ";
using namespace std;
 
const ll N =(1e5+5);
const ll MOD = 1e9+7;
const ll INF = 1e16;
const ll LOG = 29;

long long binpow(long long a, long long b) {
     a %= MOD;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res * a)%MOD ;
        a = (a * a)%MOD ;

        
        b >>= 1;
    }
    res%=MOD;
    return res;
}
void solve(){
    string s;
    cin>>s;
    ll n = 1ll*s.size();
        
    if(n==2){
        if(s[0]==s[1]){
            cout<<"1 2\n";
            return;
        }
        cout<<"-1 -1\n";
    return;
    }
    for(int i= 0;i<n-2;i++){
        if((s[i] == s[i+1]) || (s[i] == s[i+2]) || (s[i+1] == s[i+2])){
            cout<<i+1<<" "<<i+3<<endl;
            return;
        }
    }   
    for(int i = 0;i<(n-1);i++){
        if(s[i]==s[i+1]){
            cout<<i+1<<" "<<i+2<<endl;
            return;
        }
    }
    cout<<"-1 -1\n";
}




int main()
{
    ios_base::sync_with_stdio(0);
     cin.tie(NULL);
     
    ll t=1;
    while(t--){
        solve();
    }
     
 
 
    return 0;     
    
        
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long
#define inf 1000000000000000008ll
#define xx first
#define yy second
using namespace std;
typedef pair<int, int>pi;
typedef pair<pi, int>pii;
typedef pair<ll, pii>piii;
vector<char>str[1000006];
vector<ll>dis[4][1000006];
char s[1000006];
priority_queue<piii>pq;
int dirx[]= {0, 0, 1, -1};
int diry[]= {1, -1, 0, 0};
int n, m, k;
void dijkstra(int x, int y)
{
    dis[0][x][y]= 0;
    dis[1][x][y]= 0;
    dis[2][x][y]= 0;
    dis[3][x][y]= 0;
    pq.push({0, {{x, y}, 0}});
    pq.push({0, {{x, y}, 1}});
    pq.push({0, {{x, y}, 2}});
    pq.push({0, {{x, y}, 3}});
    while(!pq.empty())
    {
        piii p= pq.top();
        pq.pop();
        int x= p.yy.xx.xx;
        int y= p.yy.xx.yy;
        int z= p.yy.yy;
        if(-p.xx!=dis[z][x][y])continue;
        ll c= ((dis[z][x][y]+k-1)/k)*1ll*k;
        for(int i=0; i<4; i++)
        if(dis[i][x][y]>c)dis[i][x][y]= c, pq.push({ -c, { {x, y}, i } });
        x= p.yy.xx.xx+dirx[z];
        y= p.yy.xx.yy+diry[z];
        if(x>=0 && x<n && y>=0 && y<m && str[x][y]!='@' && dis[z][x][y]>dis[z][p.yy.xx.xx][p.yy.xx.yy]+1)
        dis[z][x][y]= dis[z][p.yy.xx.xx][p.yy.xx.yy]+1, pq.push({ -dis[z][x][y], { {x, y}, z } });
    }
    return;
}
int main()
{
    int x1, y1, x2, y2;
    scanf("%d %d %d", &n, &m, &k);
    scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
    x1--, y1--, x2--, y2--;
    for(int i=0; i<n; i++)
    {
        scanf("%s", s);
        for(int j=0; j<m; j++)
        str[i].push_back(s[j]),
        dis[0][i].push_back(inf), dis[1][i].push_back(inf),
        dis[2][i].push_back(inf), dis[3][i].push_back(inf);
    }
    dijkstra(x1, y1);
    ll res= min(min(dis[0][x2][y2], dis[1][x2][y2]), min(dis[2][x2][y2], dis[3][x2][y2]));
    if(res==inf)puts("-1");
    else
    {
        res= min(min((dis[0][x2][y2]+k-1)/k, (dis[1][x2][y2]+k-1)/k), min((dis[2][x2][y2]+k-1)/k, (dis[3][x2][y2]+k-1)/k));
        printf("%lld\n", res);
    }
    return 0;
}


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

using namespace std;

typedef long long int ll;
 
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; }
 
typedef pair<int,int> pair;

int main(){
  int n,m; cin >> n >> m;
  vector<int> a(m); for(int i=0;i<m;i++) cin >> a[i];

  ll sum=0;
  for(auto v : a) sum+=v;

  ll ans=n-sum;

  if(ans<0) cout << "-1" << endl;
  else cout << ans << endl;

}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
// debug
#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl;
#define ddd(x, y, z)                                                     \
  cerr << "(" #x "," #y "," #z "):(" << x << "," << y << "," << z << ")" \
       << endl;
#define dump(v)              \
  cerr << #v ":[ ";          \
  for (auto macro_vi : v) {  \
    cerr << macro_vi << " "; \
  }                          \
  cerr << "]" << endl;
#define ddump(v)                       \
  cerr << #v ":" << endl;              \
  for (auto macro_row : v) {           \
    cerr << "[";                       \
    for (auto macro__vi : macro_row) { \
      cerr << macro__vi << " ";        \
    }                                  \
    cerr << "]" << endl;               \
  }
#define damp(m)                                                   \
  for (auto macro_pair : m) {                                     \
    cerr << macro_pair.first << ":" << macro_pair.second << endl; \
  }
#define dpair(p) \
  cerr << #p ":" \
       << "(" << p.first << "," << p.second << ")" << endl;
// iterate
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
using ll = long long;

using namespace std;

vector<ll> S(51, -1);
vector<ll> P(51, -1);

ll dfs(int k, ll x) {
  ll mid = S[k] / 2 + 1;
  dd(k, x);
  if (x == 1) {
    if (k == 0) {
      return 1;
    } else {
      return 0;
    }
  } else if (x < mid) {
    return dfs(k - 1, x - 1);
  } else if (x == mid) {
    return P[k - 1] + 1;
  } else if (x < S[k]) {
    return P[k - 1] + 1 + dfs(k - 1, x - (S[k - 1] + 2));
  } else if (x == S[k]) {
    return P[k];
  }
  return 1e18 - 1;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  S[0] = 1, P[0] = 1;
  for (int l = 1; l <= 50; l++) {
    S[l] = 2 * S[l - 1] + 3;
    P[l] = 2 * P[l - 1] + 1;
  }
  ll n, x;
  cin >> n >> x;
  cout << dfs(n, x) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <sstream>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <stack>
#include <stdio.h>
#include <string>
#include <queue>
#include <vector>
using namespace std;

bool N[1000000];

bool primeNumber(int num) {
	if (N[num]) return true;
	else if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return N[num] = true;
}

int main()
{
	int n;
	while (cin >> n && n != EOF) {
		int cnt = 0;
		for (int i = n; i > 1; i--) {
			if (primeNumber(i)) cnt++;
		}
		cout << cnt << endl;
	}
}


Measured memory_bytes: 4052
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int n,k,s,a[N];
int main()
{
    scanf("%d%d%d",&n,&k,&s);
    if(s<1000000000)
    {
        for(int i=1;i<=k;i++) a[i]=s;
        for(int i=k+1;i<=n;i++) a[i]=s+1;
    }
    else
    {
        for(int i=1;i<=k;i++) a[i]=s;
        for(int i=k+1;i<=n;i++) a[i]=1;
    }
    for(int i=1;i<=n;i++) printf(i==n?"%d\n":"%d ",a[i]);
}


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

int main(){
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  if(a>=k){
    cout << k << endl;
  }
  else{
    if(k-a<=b){
      cout << a << endl;
    }
    else{
      cout << a-(k-a-b) << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3636
#create date: 2020-08-03 14:18

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def cut(a, l):
    res = 0
    for ai in a:
        res += max(0, (ai-1)//l)
        #print(ai, max(0, (ai-1)//l), res)
    return res


def main():
    n, k = na()
    a = na()
    ansl, ansr = 0, 10**9
    while ansl + 1 < ansr:
        now = (ansl + ansr) // 2
        #print(ansl, ansr, now, cut(a, now))
        if cut(a, now) <= k:
            ansr = now
        else:
            ansl = now
    print(ansr)

if __name__ == "__main__":
    main()

Measured memory_bytes: 103520
#include<bits/stdc++.h>
#define ll  long long
#define int long long
#define inf 0x3f3f3f3f
#define fi first
#define se second
#define pb push_back
#define pa pair<int,int>
#define mkp(a,b) make_pair(a,b)
const int N=2e5+10;
const int mod=998244353;
using namespace std;

int cross(int x1,int y1,int x2,int y2){return x1*y2-x2*y1;}
int dot(int x1,int y1,int x2,int y2){return x1*x2+y1*y2;}
int32_t main()
{
   //ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);
   int32_t x1,y1,x2,y2; scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
   int32_t q; scanf("%d",&q);
   while(q--)
   {
   	  int32_t x,y; scanf("%d%d",&x,&y);
   	  int p=cross(x-x1,y-y1,x2-x1,y2-y1);
   	  if(p<0) puts("COUNTER_CLOCKWISE");
   	  else if(p>0) puts("CLOCKWISE");
   	  else
   	  {
   	  	 if(dot(x1-x,y1-y,x2-x,y2-y)<=0) puts("ON_SEGMENT");  
   	  	 else if(dot(x-x1,y-y1,x2-x1,y2-y1)<=0) puts("ONLINE_BACK");
   	  	 else  puts("ONLINE_FRONT");
   	  }
   }
return 0;
}
/*
 
*/


Measured memory_bytes: 3172
#include<bits/stdc++.h>
#define endl '\n';
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
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 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; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    vector<ll> d(N);
    rep(i,N){
        cin >> d[i];
    }
    set<ll> se;
    for(int i=0; i<N; i++){
        ll sum = 0;
        for(int j=i; j<min(N,i+6); j++){
            sum *= 10LL;
            sum += d[j];
            se.insert(sum);
        }
    }
    for(ll i=0; i<=1'000'000; i++){
        if(!se.count(i)){
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}


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

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

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

    string s;
    cin >> s;
    vi len(s.size());
    int l = 0;
    for (ui i = 0; i < s.size(); ++i) {
        if (s[i] == 'R') {
            ++l;
            len[i] = l;
        }
        else {
            l = 0;
        }
    }
    l = 0;
    for (int i = s.size() - 1; i >= 0; --i) {
        if (s[i] == 'L') {
            ++l;
            len[i] = l;
        }
        else {
            l = 0;
        }
    }

    vi ans(s.size());
    for (ui i = 1; i < s.size(); ++i) {
        if (s[i] == 'L' && s[i - 1] == 'R') {
            ans[i] = (len[i] - 1)/2 + 1 + len[i - 1]/2;
            ans[i - 1] = (len[i - 1] - 1)/2 + 1 + len[i]/2;
        }
    }
    
    for (ui i = 0; i < s.size(); ++i) {
        cout << ans[i] << ' ';
    }
    cout << '\n';

    return 0;
}

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

template <typename T> T gcd(T x, T y) {
  if (y == 0)
    return x;
  return gcd(y, x % y);
}

template <typename T> T lcm(T x, T y) {
  if (x == 0 || y == 0)
    return 0;
  return x / gcd(x, y) * y;
}

int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}

vector<int> p;
vector<int> r;

void init(int n) {
  p.reserve(n);
  r.reserve(n);
  for (int i = 0; i < n; i++) {
    p[i] = i;
    r[i] = 0;
  }
}

int root(int x) { return p[x] == x ? x : p[x] = root(p[x]); }

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

void unite(int x, int y) {
  x = root(x);
  y = root(y);
  if (x == y)
    return;

  if (r[x] < r[y])
    p[x] = y;
  else {
    p[y] = x;
    if (r[x] == r[y])
      r[x]++;
  }
}

int main() {
  int N;
  cin >> N;
  int ans = 0;
  if (N % 111 > 0)
    ans = ((N / 111) + 1) * 111;
  else
    ans = (N / 111) * 111;

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int main(){
  int N;
  cin>>N;
  double x[N],y[N];
  REP(i,N)cin>>x[i]>>y[i];
  double ans=0;
  REP(i,N)REP(j,N){
    ans+=sqrt(pow((x[i]-x[j]),2)+pow((y[i]-y[j]),2));
  }
  ans/=N;
  //固定小数点
  cout<<fixed;
  //桁数固定
  cout<<setprecision(8);
  cout<<ans<<endl;
  return 0;
}


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

void printCount(std::map <std::string, int> &verdicts, const std::string &verdict){
    std::cout << verdict << " x " << verdicts[verdict] << '\n';
}

int main(int argc, char const *argv[])
{
    std::map <std::string, int> verdicts;
    int N;
    std::cin >> N;
    while(N--){
        std::string verdict;
        std::cin >> verdict;
        ++verdicts[verdict];
    }

    printCount(verdicts, "AC");
    printCount(verdicts, "WA");
    printCount(verdicts, "TLE");
    printCount(verdicts, "RE");

    return 0;
}


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

#define CIN_ONLY if(1)
struct cww{cww(){
    CIN_ONLY{
        ios::sync_with_stdio(false);cin.tie(0);
    }
}}star;
#define fin "\n"
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define DEBUG if(0)
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l,T r)
{bool a=l>r;if(a)l=r;return a;}
template <typename T>inline bool chmax(T &l,T r)
{bool a=l<r;if(a)l=r;return a;}
template <typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}
typedef vector<int> V;
typedef vector<V> VV;
int main(){
    int N;
    cin>>N;
    VV g(N);
    REP(i,N-1){
        int a,b;cin>>a>>b;a--,b--;
        g[a].pb(b);
        g[b].pb(a);
    }
    REC(int,int,int) dfs=[&](int v,int p){
        int ret=0;
        for(auto &u:g[v])if(u!=p)
                             ret^=dfs(u,v)+1;
        return ret;
    };
    if(dfs(0,0))cout<<"Alice"<<endl;
    else cout<<"Bob"<<endl;
    return 0;
}


Measured memory_bytes: 13568
#include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;

typedef long long ll;

int main()
{
	int n,m; scanf("%d%d",&n,&m);
	vector<int> s(n),t(n),p(m+2);
	for(int i=0;i<n;i++) scanf("%d%d",&s[i],&t[i]);
	for(int i=1;i<=m;i++) scanf("%d",&p[i]);
	p[m+1]=1e9+1;
	sort(begin(p),end(p));
	
	vector<int> sum(m+2);
	for(int i=1;i<=m+1;i++){
		sum[i]=p[i]-p[i-1];
		if(i>=2) sum[i]+=sum[i-2];
	}
	
	ll res=0;
	for(int i=0;i<n;i++){
		ll temp=0;
		if(s[i]<t[i]){
			int l=lower_bound(begin(p),end(p),s[i])-p.begin();
			int r=lower_bound(begin(p),end(p),t[i])-p.begin();
			temp=p[l]-s[i];
			if((r^l)%2==0)
				temp+=sum[r]-sum[l]-(p[r]-t[i]);
			else
				temp+=sum[r-1]-sum[l];
		}
		else{
			int l=lower_bound(begin(p),end(p),t[i])-p.begin();
			int r=lower_bound(begin(p),end(p),s[i])-p.begin();
			temp=-(p[r]-s[i]);
			if((r^l)%2==0)
				temp+=sum[r]-sum[l]+(p[l]-t[i]);
			else
				temp+=sum[r]-sum[l-1];
		}
		res+=temp;
	}
	printf("%lld\n",res);
}

Measured memory_bytes: 2580
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
using namespace std;

unsigned long long calc(int L, unsigned long long X, vector<pair<unsigned long long, unsigned long long>>& num)
{
	if (X <= 0)
	{
		return 0;
	}
	if (L < 0)
	{
		return 0;
	}
	if (L == 0)
	{
		return 1;
	}

	auto& n = num[L];
	auto half = n.first / 2;
	auto sum = 0ull;

	if (X > half + 1)
	{
		sum += calc(L - 1, min(half - 1, X - half - 1), num);
		sum += num[L - 1].second;
		++sum;
	}
	else if (X == half + 1)
	{
		sum += num[L - 1].second;
		++sum;
	}
	else
	{
		sum += calc(L - 1, X - 1, num);
	}

	return sum;
}

int main()
{
	int N;
	unsigned long long X;
	cin >> N >> X;

	vector<pair<unsigned long long, unsigned long long>> num;
	num.push_back(make_pair(1ull, 1ull));
	for (auto i = 1; i <= N; ++i)
	{
		auto& prev = num[i - 1];
		num.push_back(make_pair(prev.first * 2 + 3, prev.second * 2 + 1));
	}

	cout << calc(N, X, num) << endl;

	return 0;
}


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

int main(){
  char c;
  cin >> c;
  char res;
  if(c=='A'){
	res = 'T';
  }else if(c=='T'){
    res = 'A';
  }else if(c=='C'){
    res = 'G';
  }else{
	res = 'C';
  }
  cout << res << endl;
  return 0;
}


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

using namespace std;

const int N = 101;
const int W = 100001;
using ll = long long;
ll dp[W], w[N], v[N];

int main() {
    int n, totalWeight;
    cin >> n >> totalWeight;
    for (int i = 1; i <= n; i++) {
        cin >> w[i] >> v[i];
    }
    for (int i = 1; i <= n; i++) {
        for (int weight = totalWeight; weight >= 1; weight--) {
            if (weight - w[i] >= 0) {
                dp[weight] = max(dp[weight], dp[weight - w[i]] + v[i]);
            }
        }
    }
    cout << dp[totalWeight];
    return 0;
}


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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define repr(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = 1e9 + 100;
const long long LLINF = 2e18 + 129;
const long long MOD = 1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

template<typename T>
bool chmax(T &a, T b){
    if(a < b){
        a = b;
        return true;
    }else{
        return false;
    }
}

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

    lint n, m;
    cin >> n >> m;

    set<lint> st;
    rep(i, m){
        lint t;
        cin >> t;
        st.insert(t);
    }

    if(st.count(5)){
        st.erase(2);
        st.erase(3);
    }else if(st.count(3)){
        st.erase(2);
    }
    if(st.count(9)){
        st.erase(6);
    }

    vector<lint> a;
    for(auto x : st){
        a.push_back(x);
    }
    m = a.size();

    vector<lint> v = {IINF, 2, 5, 5, 4, 5, 6, 3, 7, 6};

    vector< vector<lint> > dp(m + 1, vector<lint>(n + 1, -1));
    vector< vector< P > > prev(m + 1, vector< P >(n + 1, make_pair(-1, -1)));

    dp[0][0] = 0;
    REP(i, 1, m + 1){
        rep(j, n + 1){
            if(j >= v[a[i - 1]] && chmax(dp[i][j], dp[i][j - v[a[i - 1]]] + 1)){
                prev[i][j] = make_pair(i, j - v[a[i - 1]]);
            }
            if(chmax(dp[i][j], dp[i - 1][j])){
                prev[i][j] = make_pair(i - 1, j);
            }
        }
    }

    vector<lint> cnt(m);
    int k = m, l = n;
    while(prev[k][l].first > 0){
        P tmp = prev[k][l];
        if(tmp.second != l){
            ++cnt[tmp.first - 1];
        }
        k = tmp.first;
        l = tmp.second;
    }

    repr(i, m){
        rep(j, cnt[i]){
            cout << a[i];
        }
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 1408
//Suplex
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
int a,b,c,k;
int main()
{
	scanf("%d%d%d",&a,&b,&c);
	scanf("%d",&k);
	int fac=1;
	for(int i=1;i<=k;i++) fac=fac*2;
	if(a<b) swap(a,b);
	if(a<c) swap(a,c);
	if(b<c) swap(b,c);
	printf("%d\n",a*fac+b+c);
	return 0;
}

Measured memory_bytes: 256
/*
                                                  __          __
      /\   |   |     /\   |  | |  |     /\   | / |  )   /\   |  )
     /__\  |   |    /__\  |--| |  |    /__\  |<  |-<   /__\  |-<
    /    \ |__ |__ /    \ |  | \__/   /    \ | \ |__) /    \ |  \

*/

#import<bits/stdc++.h>
typedef long long ll;
#define forl(n) for(int i=0; i<n; i++)
#define forll(i,a,b,c) for(int i=a; i<b; i+=c)
#define pb(n) push_back(n)

using namespace std;

int main()
{
    int m=0,b,n;
    cin>>n>>b;
    int p[n],x=0;
    forl(n){cin>>p[i];x+=p[i];}
    if(x%(4*b)==0)x=x/(4*b);
    else x=(x/(4*b))+1;
    forl(n)
    {
        if(p[i]>=x){m++;}
    }
    if(m>=b){cout<<"Yes\n";}
    else{cout<<"No\n";}
}


Measured memory_bytes: 3620
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>

using namespace std;

typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define Fst first
#define Snd second
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repv(t,it,v) for(vector<t>::iterator it = v.begin() ; it != v.end() ; ++it)

const int UF_MAX = 1000000;

class UF{
	int x[UF_MAX];
	
public:
	
	UF(){
		for(int i = 0 ; i < UF_MAX ; ++i) x[i] = -1;
	}
	
	int boss(int a){
		int s = a;
		while(x[s] > -1) s = x[s];
		if(s != a) x[a] = s;
		return s;
	}
	
	void uni(int a , int b){
		int s = boss(a);
		int t = boss(b);
		if(s != t){
			if(x[s] < x[t]){
				x[s] += x[t];
				x[t] = s;
			} else {
				x[t] += x[s];
				x[s] = t;
			}
		}
	}
	
	bool find(int a , int b){
		return boss(a) == boss(b);
	}
	
	int count(int a){
		int b = 0;
		for(int i = 0 ; i < a ; ++i) if(x[i] < 0) ++b;
		return b;
	}
} uf;

int N,M;
int b[100010];

int main(){
	scanf("%d%d" , &N , &M);
	repp(i,0,N){
		int x;
		scanf("%d" , &x);
		repp(j,0,x){
			int y;
			scanf("%d" , &y);
			uf.uni(i,N+y-1);
			b[y] = 1;
		}
	}
	int z = 0;
	repp(i,1,M+1){
		if(!b[i]) ++z;
	}
	printf("%s\n" , uf.count(N+M) - z == 1 ? "YES" : "NO");
	return 0;
}


Measured memory_bytes: 4480
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;

int main() {
	ll INF = -Mod * 100LL;
  int N,M;
  cin >> N >> M;
	vector<P> Graph[N];
  vector<pair<P,int>> D(M); 
	vector<ll> ans(N);
	bool seen[N];
	for (int i = 0; i < N; i++) {
		ans[i] = INF;
		seen[i] = false;
	}
  for (int i = 0; i < M; i++) {
    cin >> D[i].F.F >> D[i].F.S >> D[i].S;
    D[i].F.F--; D[i].F.S--;
		Graph[D[i].F.F].emplace_back(D[i].F.S,D[i].S);
		Graph[D[i].F.S].emplace_back(D[i].F.F,-D[i].S);
  }

	for (int i = 0; i < N; i++) {
		if (!seen[i]) {
			ans[i] = 0;
			stack<int> sta;
			sta.push(i);
			while (!sta.empty()) {
				int a = sta.top();
				sta.pop();
				if (seen[a]) {
					continue;
				} else {
					seen[a] = true;
				}
				for (int j = 0; j < (int)Graph[a].size(); j++) {
					if (!seen[Graph[a][j].F]) {
						sta.push(Graph[a][j].F);
						ans[Graph[a][j].F] = ans[a] + Graph[a][j].S;
					}
				}
			}
		}
	}

	bool answer = true;
	for (int i = 0; i < M; i++) {
		if (ans[D[i].F.S] - ans[D[i].F.F] != D[i].S) {
			answer = false;
		}
	}
	if (answer) cout << "Yes" << endl;
	else cout << "No" << endl;
  return 0;
}

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

int main(){
 string c;
 cin >> c;
 if (c=="a"||c=="e"||c=="i"||c=="o"||c=="u"){
 cout << "vowel" << endl;
 }
else{
cout << "consonant" << endl;
}
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {

    public static void main(String[] args) {
 
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
 
 
        try {
            String buffer[] = br.readLine().split("\\s+");
 
            int N = Integer.parseInt(buffer[0]);
            int M = Integer.parseInt(buffer[1]);
            int L = Integer.parseInt(buffer[2]);
 
            int A[][] = new int[N][M];
            int B[][] = new int[M][L];
 
            String buf_A[] = new String[M];
            String buf_B[] = new String[L];
 
            for(int row = 0; row < N; row++){
                buf_A = br.readLine().split("\\s+");
                for(int col = 0; col < M; col++){
                    A[row][col] = Integer.parseInt(buf_A[col]);
                }
            }
 
            for(int row = 0; row < M; row++){
                buf_B = br.readLine().split("\\s+");
                for(int col = 0; col < L; col++){
                    B[row][col] = Integer.parseInt(buf_B[col]);
                }
            }
 
            Long ans;
 
            for(int A_row = 0; A_row < N; A_row++){
                for(int B_col = 0; B_col < L; B_col++){
                    ans = 0L;
                    for(int B_row = 0; B_row < M; B_row++){
                        ans += A[A_row][B_row]*B[B_row][B_col];
                    }
                    if(B_col == 0){
                        System.out.printf("%d", ans);
                    }else{
                        System.out.printf(" %d", ans);
                    }
                }
                System.out.printf("\n");
            }
 
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}


Measured memory_bytes: 80508
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define MODADD(ADD_X,ADD_Y)  (ADD_X+ADD_Y)%MOD;
#define MODSUB(SUB_X,SUB_Y)  (SUB_X-SUB_Y)+MOD)%MOD;
#define MODMUL(MUL_X,MUL_Y)  (MUL_X*MUL_Y)%MOD;
#define LCM(LCM_X,LCM_Y) (LCM_X*LCM_Y)/__gcd(LCM_X,LCM_Y);
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
int dx[]= {1,0,-1,0,1,-1,1,-1};
int dy[]= {0,1,0,-1,1,-1,-1,1};
int arr[MAX],ans[MAX];
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);

    int n;
    cin>>n;
    for(int i=0; i<n; i++)
    {
        cin>>arr[i];
    }
    int f=0,now=1;
    for(int i=1; i<n; i++)
    {
        if(arr[i]<arr[i-1])
            now=0;
    }
    f=now;
    for(int i=0; i<n; i++)
    {
        for(int j=i+1; j<n; j++)
        {
            swap(arr[i],arr[j]);
            int cur=1;
            for(int k=1; k<n; k++)
            {
                if(arr[k]<arr[k-1])
                    cur=0;
            }
            f=max(f,cur);
            swap(arr[i],arr[j]);
        }
    }
    if(f)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;

    return 0;
}


Measured memory_bytes: 3636
/*
─────────────────────
───────────████████──
──────────███▄███████
──────────███████████
──────────███████████
──────────██████─────
──────────█████████──
█───────███████──────
██────████████████───
███──██████████──█───
███████████████──────
███████████████──────
─█████████████───────
──███████████────────
────████████─────────
─────███──██─────────
─────██────█─────────
─────█─────█─────────
─────██────██────────
─────────────────────
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define int long long
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define reads(s) string s; cin >> s;
#define readarr(a, n) int a[(n) + 1] = {}; fori (i, 1, n) {cin >> a[i];}
#define readmat(a, n, m) int a[(n) + 1][(m) + 1] = {}; fori (i, 1, n) {fori (j, 1, m) cin >> a[i][j];}

#define print(a) cout << a << endl;
#define printarr(a, n) fori (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) fori (i, 1, n) {fori (j, 1, m) cout << a[i][j] << " "; cout << endl;}
#define all(v) v.begin(), v.end()
#define sz(s) (int)(s.size())
#define pb push_back
#define fi first
#define se second
#define rz resize
#define fori(i, a, b) for (int i = (a); i <= (b); i++)
#define ford(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
#define setprec(x) cout << fixed << setprecision(x);
 
using namespace std;
using namespace __gnu_pbds; 
 
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair <int, int>> vpi;
typedef vector < vector <int> > vvi;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int INF = 4e18;
const int mod = 1e9+7; 

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

    #ifndef ONLINE_JUDGE 
        freopen ("INPUT.txt" , "r" , stdin);
        freopen ("OUTPUT.txt" , "w" , stdout);
        freopen ("OUTPUT_ERROR.txt" , "w" , stderr);
    #endif

    //start from here

    reads(s) reads(t)

    readb(a, b)

    reads(str) if(str == s) a--; else b--;

    cout << a << " " << b;

    return 0;
}




Measured memory_bytes: 3600
#include <stdio.h>
#include <vector>
typedef long long ll;

int main(void) {
  ll i, j, k, n, m, b, t;
  scanf("%lld%lld", &n, &m);
  ll a[m], c[m], dp[1 << n];
  for(i = 0; i < m; ++i) {
    c[i] = 0;
    scanf("%lld%lld", &a[i], &b);
    for(j = 0; j < b; ++j) scanf("%lld", &t), c[i] += (1 << --t);
  }
  for(i = 0; i < (1 << n); ++i) dp[i] = 1e9;
  dp[0] = 0;
  for(i = 0; i < m; ++i) for(j = 0; j < (1 << n); ++j) if(dp[j] + a[i] < dp[j | c[i]]) dp[j | c[i]] = dp[j] + a[i];
  printf("%lld", dp[(1 << n) - 1] != 1e9 ? dp[(1 << n) - 1] : -1);
  return 0;
}

Measured memory_bytes: 256
def fold arr
    arr2 = []
    arr.each{|name|
        if @h.key? name
            @h[name] = fold(@h[name])
            @h[name].each{|name2| arr2 << name2}
        else
            arr2 << name
        end
    }
    arr2.uniq!
    arr2
end

while true
    n = gets.to_i
    break if n == 0
    @h = Hash.new{|h, k| h[k] = []}
    firstgroup = nil
    n.times{|i|
        group, members = (gets.chomp)[0..-2].split(":")
        members = members.split(",")
        @h[group] = members
        firstgroup = group if i == 0
    }
    puts fold(@h[firstgroup]).length
end


Measured memory_bytes: 11528
#include <iostream>
#include <queue>

using namespace std;

int main(void) {
	priority_queue<int> Q;
	string order;
	int n;
	while(cin >> order) {
		if (order == "insert") {
			cin >> n;
			Q.push(n);
		} else if (order == "extract") {
			n = Q.top();
			Q.pop();
			cout << n << endl;
		} else if (order == "end") {
			return 0;
		}
	}
}



Measured memory_bytes: 7136
#include <iostream>
#include <string>
#include <limits>
#include <limits.h>
#include <algorithm>

using namespace std;
int main(){
  long long a, b, c, d;
  cin >> a >> b >> c >> d;

  long long tmp = 0;//-10e-18;
  long long ans = LONG_MIN;

  long long array[4] = {a*c, a*d, b*c, b*d};
  sort(begin(array), end(array));

  cout << array[3] << endl;

  //cout << ans << endl;

}

Measured memory_bytes: 3648
n, m = map(int, input().split())
A = [""] * n
for i in range(n):
  A[i] = input()
  
B = [""] * m
for i in range(m):
  B[i] = input()

#pat_match
def pat_match(Temp, temp_w, temp_h, Big_pic, ind_w, ind_h):
  for i in range(temp_h):
    for j in range(temp_w):
      if Temp[i][j] != Big_pic[i + ind_w][j + ind_h]:
        return False
  else:
    return True

#print(pat_match(B, 2, 2, A, 0, 0))
import sys
for i in range(0, n-m+1):
  for j in range(0, len(A[0]) - len(B[0]) + 1):
    if pat_match(B, len(B[0]), m, A, j, i):
      print("Yes")
      sys.exit()
else:
  print("No")
      

Measured memory_bytes: 38256
a = int(input())
b = list(map(int, input().split()))
e = b.copy()
b.sort()
c = b[a // 2 - 1]
d = b[a // 2]
for i in e:
    if i <= c:
        print(b[a // 2])
    else:
        print(b[a // 2 - 1])


Measured memory_bytes: 26772
#include<iostream>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<cstring>
#include<vector>
#include<map>
#include<cmath>
#include<list>
#define ll long long
using namespace std;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3f;
const int MOD = 1e9 + 7;
const double pi = 3.141592653;
using namespace std;
#define ll long long
#define FAST_IO ios::sync_with_stdio(false)
template<class T>
void tomax(T &a, T b) {
    a = max(a, b);
}

template<class T>
void tomin(T &a, T b) {
    a = min(a, b);
}

int main() {
    FAST_IO;
    int k;
    string str;
    cin>>k;
    cin>>str;
    if(k>=str.length()) cout<<str<<endl;
    else {
        for(int i =0;i<k;i++)
            cout<<str[i];
        cout<<"..."<<endl;
    }
}

Measured memory_bytes: 3516
data class Edge(val to: Int)

fun main(arg: Array<String>) {

    val (N, Q) = readLine()!!.split(" ").map { it.toInt() }

    val parents = IntArray(N)
    val neighbors = Array(N) { mutableListOf<Edge>() }
    val points = IntArray(N) { 0 }

    repeat(N - 1) {
        val (a, b) = readLine()!!.split(" ").map { it.toInt() }
        parents[b - 1] = a - 1
        neighbors[a - 1].add(Edge(b - 1))
        neighbors[b - 1].add(Edge(a - 1))
    }

    repeat(Q) {
        val (p, x) = readLine()!!.split(" ").map { it.toInt() }
        points[p - 1] = points[p - 1] + x
    }


    val seen = BooleanArray(N) { false }
    var count = 0
    val queue = java.util.ArrayDeque<Int>()
    queue.addLast(0)
    while (queue.isNotEmpty()) {
        val i = queue.removeFirst()
        seen[i] = true

        for (edge in neighbors[i]) {
            if (!seen[edge.to]) {
                points[edge.to] += points[i]
                queue.addLast(edge.to)
            }
        }

    }

    print(points.joinToString(" "))


}


//data class Edge(val to: Int)
//
//fun main(args: Array<String>) {
//    val (N, Q) = readLine()!!.split(" ").map {it.toInt()}
//
//    var parent = IntArray(N)
//    var points = LongArray(N)
//    var neighbors = Array(N){ mutableListOf<Edge>()}
//    repeat(N-1){
//        val (a,b) = readLine()!!.split(" ").map { it.toInt() }
////        parent[b-1] = a-1
//        neighbors[a-1].add(Edge(b-1))
//        neighbors[b-1].add(Edge(a-1))
//    }
//
//    repeat(Q){
//        val (p,x) = readLine()!!.split(" ").map { it.toInt() }
//        points[p-1] = points[p-1]+ x
//    }
//
//    val queue = ArrayDeque<Int>(N)
//    val seen = BooleanArray(N)
//
//    queue.addLast(0)
//    while (queue.isNotEmpty()){
//        val current = queue.removeFirst()
//        for(e in neighbors[current]){
//            if(seen[e.to]){
//                continue
//            }
//            points[e.to] += points[current]
//            queue.addLast(e.to)
//        }
//        seen[current] = true
//
//    }
//
//    print(points.joinToString(" "))
//
//}


Measured memory_bytes: 149244
#include<bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define EPS (1e-10)

using namespace std;

int main(int argc, char *argv[]) {

	int A,B; cin >> A >> B;

	cout << 6 / A / B << endl;

	return 0;
}


Measured memory_bytes: 3608
H,W,A,B = [int(x) for x in input().split()]
for i in range(H):
    s = ''
    for j in range(W):
        if(j<A and i<B):
            s += '0'
        elif(j<A and i>=B):
            s += '1'
        elif(j>=A and i<B):
            s += '1'
        else:
            s += '0'
    print(s)

Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef vector<ll> vi;
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
  ll r;
  cin >> r;
  if(r<1200){
    print("ABC");
  }
  else if(r<2800){
    print("ARC");
  }
  else{
    print("AGC");
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii=pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c),end(c)
#define rall(c) rbegin(c),rend(c)
#define fore(x,c) for(auto &&x:c)
#define rep(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define rrep(i, a, n) for(int i=(int)(n-1);i>=a;--i)
#define sz(c) ((int)c.size())
#define contains(c,x) (c.find(x)!=end(c))
#define inseg(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(nullptr); ios::sync_with_stdio(0);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int A, B;
    cin >> A>>B;
    cout <<max({A+B,A-B,A*B}) <<endl;
    return (0^_^0);
}



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

int main(){

ll a, b, n;
cin >> n >> a >> b;

if(a*n < b){
    cout << a*n << endl;
}
else if(a*n >b){
    cout << b << endl;
}
else cout << b << endl;

    return 0;
    }

Measured memory_bytes: 384
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    x = int(input())
    ans = 0
    ans += (x // 500) * 1000
    x = x % 500
    ans += (x // 5) * 5
    print(ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Measured memory_bytes: 38256
var x = require('fs').readFileSync('/dev/stdin', 'utf8');
var num = Number(x);
var h = Math.floor( num / 3600 );
var m = Math.floor(  ( num % 3600 ) / 60 );
var s = num % 60;
console.log( h + ":" + m + ":" + s );

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

const int INF = 1012345678;

int main()
{
	int n, a, b = 0;
	cin >> n >> a >> b;
	int ans = 0;
	for (int i = 0; i <= n; i++)
	{
		int sum = 0;
		int n = i;
		while (n > 0)
		{
			sum += n % 10;
			n /= 10;
		}

		if (a <= sum && sum <= b)
		{
			ans += i;
		}
	}


	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc  = new Scanner(System.in);
        int N  = sc.nextInt();
        int r[][]  = new int[N][2];
        for (int i = 0; i< N;i++){
            r[i][0]  =sc.nextInt();
            r[i][1] = sc.nextInt();
        }

        int n_1 = factorial(N-1);
//        double distance[] = new double[n_1];
        int index = 0;
        double result = 0;
        for (int i = 0;i<N-1;i++){
            for(int j = i+1;j<N;j++){
//                distance[index] = Math.sqrt(Math.pow(r[i][0]-r[j][0],2)+Math.pow(r[i][1]-r[j][1],2))*n_1*2;
                result += Math.sqrt(Math.pow(r[i][0]-r[j][0],2)+Math.pow(r[i][1]-r[j][1],2))*n_1*2;
            }
        }
        System.out.println(result/factorial(N));


    }

    static int factorial(int n){
        if(n == 0){
            return 1;
        }
        return n * factorial(n-1);
    }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(n) begin(n),end(n)
using ll = long long;
using P = pair<int,int>;
long long GCD(long long n, long long m) {
    return m ? GCD(m, n % m) : n;
}

int main() {
    ll n, m;
    cin >> n >> m;
    string s, t;
    cin >> s >> t;
    ll g = GCD(n, m);
    bool ok = true;
    ll ans = n*m/g;
    for(ll i = 0; i < g; ++i) {
        if(s[i*n/g]!=t[i*m/g]) ok = false;
    }
    if(ok) cout << ans << endl;
    else cout << -1 << endl;
    return 0;
}

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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

    int n; cin >> n;
    vector<int> t(n);
    for (int i = 0; i < n; i++) cin >> t[i];
    int T = accumulate(t.begin(), t.end(), 0);
    int m; cin >> m;
    for (int i = 0; i < m; i++) {
        int p, x; cin >> p >> x; p--;
        cout << T + x - t[p] << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>

using namespace std;

typedef long long ll;
typedef long double ld;

#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mis map<int,string>
#define msi map<string,int>
#define mll map<ll,ll>
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep1(i,n) for(int i=1; i<=(int)(n); i++)
#define all(c) c.begin(),c.end()
#define srta(a) sort(all(a))
#define srtd(a) sort(all(a),greater<型>())
#define rvs(s) reverse(all(s))
#define psb push_back
#define ppb pop_back
#define isu isupper
#define isl islower

const int I_INF = 1001001001;
const ll LL_INF = 1001001001001001001;
const ld EPS = 0.001;



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

    ll MAX = 10000005;
    vl a(MAX, 1);
    for (int i=2; i<MAX; ++i) {
        for (int j=i; j<MAX; j += i) a[j]++;
    }

    ll ans = 0;
    rep1 (i, N) {
        ans += i*a[i];
    }

    cout << ans << endl;
}


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

int64_t MOD = 1000000007;
int64_t MAX = 9223372036854775807;
double PI = 3.141592653589793;

int main()
{
    int N;
    cin >> N;
    if (N == 1)
        cout << "Hello World";
    else
    {
        int A, B;
        cin >> A >> B;
        cout << A + B;
    }
}

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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main(){
	int n,m; scanf("%d%d",&n,&m);

	int x=m-1,y=m;
	rep(i,(m+1)/2){
		printf("%d %d\n",x+1,y+1);
		x--;
		y++;
	}
	x=0; y=n-2;
	rep(i,m/2){
		printf("%d %d\n",x+1,y+1);
		x++;
		y--;
	}

	return 0;
}


Measured memory_bytes: 3824