akhauriyash/Code-Regression huggingface dataset:
n = int(input())
a = [0]*(n+1)
b = [0]*(n+1)
c = [0]*(n+1)
for i in range(1,n+1): a[i],b[i],c[i] = map(int,input().split())
dp = [[0,0,0] for i in range(n+1)]
for i in range(1,n+1):
    for j in range(3):
        if j == 0: dp[i][j] = max(dp[i-1][1],dp[i-1][2])+a[i]
        elif j == 1: dp[i][j] = max(dp[i-1][0],dp[i-1][2])+b[i]
        else: dp[i][j] = max(dp[i-1][0],dp[i-1][1])+c[i]
print(max(dp[n]))

Measured memory_bytes: 34676
while True:
    a,b=map(int,input().split())
    
    
    if a == 0 and b == 0: break

    for i in range(a):
        for j in range(b):
            if (i%2==0 and j%2==0) or (i%2==1 and j%2==1):
                print('#', end='')
            else:
                print('.', end='')
        print()
    print()


Measured memory_bytes: 7004
#include<bits/stdc++.h>
#define pi 3.141592653589793238
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define MOD 1000000007
#define INF 999999999999999999 
#define pb push_back
#define ff first
#define ss second
 
#define mt make_tuple
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
 
 
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
 
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////int power(ll x, ll y, ll p)
const int N = 3e5 + 1;
ll fac[N];
int power(ll x, ll y, ll p)
{
    int res = 1;
    x = x % p;
 
    while (y > 0)
    {
 
        if (y & 1)
            res = (res * x) % p;
 
 
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
 
  
ll modi(ll a, ll m)
{
    return power(a, m - 2, m);
 
}

ll nCr(ll n, ll r, ll p)
{
    if(n < r){
        return 0;
    }
    if (r == 0)
        return 1;
    
 
    return (fac[n] * modi(fac[r], p) % p *
        modi(fac[n - r], p) % p) % p;
}
 
int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    fast;
    ll T = 1, i, j;
    fac[0] = 1;
    for(i = 1; i < N; i++){
        fac[i] = i * fac[i - 1];
        fac[i] %= MOD;
    }
    //cin >> T;
    while (T--) {
        ll n;
        cin >> n;
        vector<ll> v(n + 2);
        for(i = 1; i <= n + 1; i++){
            ll x;
            cin >> v[i];
        }
        ll l1, l2, l3;
        map<ll,ll> m;
        for(i = 1; i <= n + 1; i++){
            if(m[v[i]] > 0){
                l1 = m[v[i]] - 1;
                
                l3 = n - i + 1;
                break;
            }
            m[v[i]] = i;
        }   
        for(ll k = 1; k <= n + 1; k++){
            if(k == 1){
                cout << n << endl;
                continue;
            }
            ll ans;
            ans = nCr(n + 1, k, MOD) - nCr(l1 + l3, k - 1, MOD);
            cout << (ans + MOD) % MOD << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 12656
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    ll x;
    cin >> x;
    ll a = x / 500;
    ll b = (x %  500) / 5;
    cout << a * 1000 + b * 5 << endl;
    return 0;
}


Measured memory_bytes: 256
before = %w(A B C D E F G H I J K L M N O P Q R S T U V W X Y Z)
after  = %w(D E F G H I J K L M N O P Q R S T U V W X Y Z A B C)

fukugo = {}
0.upto(before.length-1) do |i|
  fukugo[after[i]] = before[i]
end

s = gets.chomp.chars.to_a
ans = (s.map {|ch| fukugo[ch]}).join("")
puts ans

Measured memory_bytes: 8720
import java.util.*;
public class Main {

	public void doIt(){
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		while(x != 0 || y != 0){
			if(x < y){
				int temp = x;
				x = y;
				y = temp;
			}
			//ツ催妥・ツ古カツ姪アツ青板づーツ仰づ淞づゥ
			int count = 0;
			while(y != 0){
				int temp = x % y;
				x = y;
				y = temp;
				count++;
			}
			System.out.println( x +" " + count);

			x = sc.nextInt();
			y = sc.nextInt();
		}


	}
	public static void main(String[] args) {
		Main obj = new Main();
		obj.doIt();

	}

}

Measured memory_bytes: 12000
import sys
N, M = map(int, input().split())
X = []
for _ in range(N):
    a, b, c = map(int, input().split())
    X.append((a,b,c))
Y = []
for _ in range(M):
    a, b, c = map(int, input().split())
    Y.append((b, c, a))
X.sort(key=lambda x:x[2])
Y.sort(key=lambda x:x[2])

dxs = []
bc = X[0][2]
for _, _, c in X[1:]:
    dxs.append(c-bc)
    bc = c
dys = []
bc = Y[0][2]
for _, _, c in Y[1:]:
    dys.append(c-bc)
    bc = c
#print(dxs, dys)
Ws = set()
for i, (a, b, _) in enumerate(X):
    yi = 0
    for (_, _, z1), (_, _, z2) in zip(Y, Y[1:]):
        if z1==z2 or (a<=z1 and z2<=b):
            Ws.add(((i-1, yi), (i, yi)))
            Ws.add(((i, yi), (i-1, yi)))
        yi += 1

for i, (a, b, _) in enumerate(Y):
    yi = 0
    for (_, _, z1), (_, _, z2) in zip(X, X[1:]):
        if z1 == z2 or (a<=z1 and z2<=b):
            Ws.add(((yi, i-1), (yi, i)))
            Ws.add(((yi, i), (yi, i-1)))
        yi += 1
#print(Ws)

fci = -1
for _, _, c in X:
    if 0<c:
        break
    fci += 1
if fci < 0 or N-1<=fci:
    print("INF")
    sys.exit()
fcj = -1
for _, _, c in Y:
    if 0<c:
        break
    fcj += 1
if fcj < 0 or M-1<=fcj:
    print("INF")
    sys.exit()
#print(fci, fcj)
stack = [(fci, fcj)]
S = 0
vs = set([(fci, fcj)])
while stack:
    i,j = stack.pop()
#    print(i, j)
    S += dxs[i]*dys[j]
    for k, l in [(i+1, j), (i-1, j), (i, j-1), (i, j+1)]:
        if ((i, j), (k, l)) in Ws:
            continue
#        print(S, k, l)
        if k<0 or N-2<k:
            print("INF")
            sys.exit()
        if l<0 or M-2<l:
            print("INF")
            sys.exit()
        if (k, l) in vs:
            continue
        vs.add((k, l))
        stack.append((k, l))
print(S)


Measured memory_bytes: 484188
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
    int n;
    cin >> n;

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

    long long c = 0;
    for (int i = 0; i <= d[n-1]; ++i) {
        auto iter = lower_bound(d.begin(), d.end(), i);
        if (iter - d.begin() == (int)d.size() / 2) c++;
    }
    cout << c << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define what_is(x) cerr<<#x <<" is "<<x<<endl;
#define ll long long 
#define gcd(a,b) __gcd(a,b)
#define pi 2*acos(0.0)
//use emplace_back() instead of push_back()
template<typename T>
void print(T t)
{
	for(const auto& e:t)cout<<e<<" ";
	cout<<endl;
}
ll nod(ll n) 
{ 
    return floor(log10(n) + 1); 
} 
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	string s;
	cin>>s;
	ll n=s.size();
	if(s[n-1]=='s')
	{
		s.push_back('e');
		s.push_back('s');
	}
	else
	{
		s.push_back('s');
	}
	cout<<s<<endl;
	return 0;

}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));
ll n,a[100010];

int main(){
	cin >> n;
	REP(i,0,n) cin >> a[i]; sort(a,a+n); int c=0;
	REP(i,0,n-1){if(a[i]*2<a[i+1]) c=i+1; a[i+1]+=a[i];}
	cout << n-c << endl;
	return 0;
}


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

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

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

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

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

  cout << r * r << endl;

  return 0;
}


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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

int R, G, B, N;

signed main()
{
    cin >> R >> G >> B >> N;

    int ans = 0;
    for(int r = 0; r <= N; ++r) {
        for(int g = 0; g <= N; ++g) {
            int tmp = N - (r * R + g * G);
            if(tmp >= 0) {
                if(tmp % B == 0) { ans++; }
            }

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


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <iomanip>
#include <cmath>
#include <algorithm>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
template<class T> inline void chmin(T& a, T b) {if (a>b) a=b; }
template<class T> inline void chmax(T& a, T b) {if (a<b) a=b; }
inline void print() { cout << endl; }
template <class Head, class... Tail> inline void print(Head&& head, Tail&&... tail) {cout << head; if (sizeof...(tail) != 0) cout << " "; print(forward<Tail>(tail)...);}
template <class T> inline void print(vector<T>& vec) { for (auto& a : vec) {cout << a; if (&a != &vec.back()) cout << " "; } cout << endl;}
template <class T> inline void print(vector<vector<T>>& df) { for (auto& vec : df) { print(vec); }}
typedef long long ll;
const ll LINF = 1e18;
const int INF = 1e9;


int main() {  
    vector<int> n(3); cin >> n[0] >> n[1] >> n[2];
    sort(n.begin(), n.end(), greater<int>());
    int res = n[0] * 10;
    REP(i, 2) res += n[i+1];
    print(res);


    
    return 0;
}

Measured memory_bytes: 888
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);

	static void solve() {
		while (in.hasNext()) {
			char[][] table = new char[12][12];
			for (int i=0; i<12; i++) {
				table[i] = in.next().toCharArray();
			}

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

			int cnt = 0;
			boolean[][] visited = new boolean[12][12];

			for (int i=0; i<12; i++) {
				for (int j=0; j<12; j++) {
					if (visited[i][j] || table[i][j] == '0') continue;
					cnt++;
					ArrayDeque<int[]> que = new ArrayDeque<int[]>();
					que.add(new int[]{i,j});

					while (!que.isEmpty()) {
						int[] cur = que.pollFirst();
						int y = cur[0];
						int x = cur[1];
						visited[y][x] = true;
						for (int k=0; k<4; k++) {
							int nx = x + dx[k];
							int ny = y + dy[k];
							if (nx < 0 || ny < 0 || 12 <= nx || 12 <= ny || table[ny][nx] == '0' || visited[ny][nx]) continue;
							que.add(new int[]{ny,nx});
						}
					}
				}
			}

			out.println(cnt);
			out.flush();
		}
	}

	public static void main(String[] args) {
		long start = System.currentTimeMillis();

		solve();
		out.flush();

		long end = System.currentTimeMillis();
		//trace(end-start + "ms");
		in.close();
		out.close();
	}

	static void trace(Object... o) { System.out.println(Arrays.deepToString(o));}
}

Measured memory_bytes: 93812
N, K = map(int, input().split())

import math
def nCr(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
  
for j in range(K):
  if (K+j)>N:
    print(0)
  else:
    x = (nCr((K-1), j) * nCr(N-K+1, j+1))
    if (x > (10**9+7)):
         print(x%(10**9+7))
    else:
         print(x)

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

using namespace std;
using vi=vector<int>;


int main(void)
{
	int n, m;

	while(scanf("%d%d", &n, &m)==2)
	{
		vi c;
		int ans=-1;

		for(int i=1;i*i<=m;i++)
		{
			if(m%i==0)
			{
				c.push_back(i);
				c.push_back(m/i);
			}
		}
		sort(c.begin(), c.end());
//		for(int x:c) printf("%d ", x); printf("\n");

		for(int x:c)
		{
			if(x>=n)
			{
				ans=m/x;
				break;
			}
		}
		if(ans<0) ans=1;
		printf("%d\n", ans);
	}

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    
    int n,i;
    float x1,x2,x3,x4,y1,y2,y3,y4;
    double AB,CD;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        scanf("%f %f %f %f %f %f %f %f\n",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);
        AB=(y2-y1)/(x2-x1);
        CD=(y4-y3)/(x4-x3);
        
        if(AB==CD)
            printf("YES\n");
        
        else
            printf("NO\n");
        
    }
    return 0;
}




Measured memory_bytes: 2108
import math

def solve(a,b,h,m):
    rad_a = 2*math.pi*((h+m/60)/12)
    rad_b = 2*math.pi*(m/60)

    x_a = a*math.cos(rad_a)
    y_a = a*math.sin(rad_a)
    x_b = b*math.cos(rad_b)
    y_b = b*math.sin(rad_b)

    res = math.sqrt((x_a-x_b)**2 + (y_a-y_b)**2)

    return res




a,b,h,m = map(int, input().split())
print(solve(a,b,h,m))

Measured memory_bytes: 62436
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;


int main(){
    int x;
    cin>>x;
    vector<bool> dp(x+1,false);
    dp[0] = true;
    vector<int> a(6);
    for(int i=0;i<6;i++)a[i] = 100+i;
    for(int i=0;i<=x;i++){
	if( dp[i] ){
	    for(int j=0;j<6;j++){
		if( i + a[j] <= x ){
		    dp[ i + a[j] ] = true;
		}
	    }
	}
    }
    if( dp[x] )cout<<1<<endl;
    else cout<<0<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 20)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね

//ここから編集する


class Combination {
#define MOD 1000000007

public:
    vector<ll> fact;

    Combination(int max_n) {
        //1 ~ n!までの階乗modを求める
        int n = max_n;
        vector<ll> fact(n + 1);
        fact[0] = 1;
        for (int i = 1; i <= n; i++) {
            fact[i] = (fact[i - 1] * i) % MOD;
        }
        this->fact = fact;
    }

    template<typename T>
    //templateをつかってみｔか
    ll pow(T x, int y) {
        if (y == 0) return 1;
        if (y == 1) return x;
        if (y == 2) return (x * x) % MOD;
//        if (y % 2 == 1) return pow(x, y / 2) * pow(x, y / 2) % MOD;
        if (y % 2 == 1) return pow(pow(x, y / 2), 2) * x % MOD;
//        return pow(x, y / 2) * pow(x, y / 2) % MOD;
        return pow(pow(x, y / 2), 2) % MOD;
    }

    ll nCk(int n, int k) {
//        return (fact[n] * pow(fact[n-k],MOD-2) * pow(fact[k],MOD-2)) % MOD;
        return (((fact[n] * pow(fact[n - k], MOD - 2)) % MOD) * pow(fact[k], MOD - 2)) % MOD;
    }
};


int main() {
    Combination c(200000);
    int H,W,A,B;
    cin >> H >> W >> A >> B;
    ll ans = 0;
    REP(i,1,H-A+1){
//        cout << "---"  << endl;
//        cout << "i = " << i << endl;
//        printf("nCk(%d,%d) = %d\n",B+i-1, B, (int) c.nCk(B + i - 1, B));
//        printf("nCk(%d,%d) = %d\n",H+W-B-i-1,H-i, (int) c.nCk(H + W - B - i - 1, H - i));

        ans = (ans + c.nCk(B+i-2,B-1) * c.nCk(H+W-B-i-1,H-i)) % MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3328
#include<iostream>
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
using namespace std;
int main(){
    int x,y;
    int a[12]={0,2,0,1,0,1,0,0,1,0,1,0};
    int i;
    cin >> x >> y;
    x = a[x-1];
    y = a[y-1];
    cout << (x==y?"Yes":"No") << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
template <typename T> bool chmax(T &u, const T z) { if (u < z) {u = z; return true;} else return false; }
template <typename T> bool chmin(T &u, const T z) { if (u > z) {u = z; return true;} else return false; }
#define ll  long long 
const ll INF=1LL<<60;
const ll MOD=1000000007;
const int MAX = 5000000;
long long moto[MAX], gyaku[MAX], inv[MAX];
#define rep(i, n)        for(ll i=0; i<(ll)(n); ++i)
void ncr_shokika() {
    moto[0] = moto[1] = 1;
    gyaku[0] = gyaku[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        moto[i] = moto[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        gyaku[i] = gyaku[i - 1] * inv[i] % MOD;
    }
}
long long ncr(int n, int r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return moto[n] * (gyaku[r] * gyaku[n - r] % MOD) % MOD;
}
int main(){
    ll a;cin>>a;
    cout<<(a+1)%2;
}

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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

ll gcd(ll a, ll b)
{
    if (a < b)
        gcd(b, a);
    if (b == 0)
        return a;
    int r;
    while ((r = a % b))
    {
        a = b;
        b = r;
    }
    return b;
}

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    int x, t;
    cin >> x >> t;

    cout << max(0LL, x - t) << endl;
}


Measured memory_bytes: 256
query = []
n,q = map(int,input().split())
s = input()
for i in range(q):
    l,r = map(int,input().split())
    query.append([l-1,r-1])

flag = False
loc = [0 for i in range(n)]
tot  = 0

for i in range(n):
    if flag and s[i] == "C":
        tot += 1
        loc[i]=tot

    if s[i] == "A":
        flag = True
    else:
        flag = False
    loc[i] = tot

for qs in query:
    print(loc[qs[1]]-loc[qs[0]])


Measured memory_bytes: 22832
#include<iostream>
#include<cmath>
#include<cstdio>
#include<cassert>
#include<climits>
#include<algorithm>
#include<vector>

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

using namespace std;

enum FACE { TOP, BOTTOM, FRONT, BACK, LEFT, RIGHT };
template <class T>
class dice {
public:
  dice() {
    id[TOP] = 0; id[FRONT] = 1; id[LEFT] = 2;
    id[RIGHT] = 3; id[BACK] = 4; id[BOTTOM] = 5;
  }
  T& operator[] (FACE f) { return var[id[f]]; }
  const T& operator[] (FACE f) const { return var[id[f]]; }
  bool operator==(const dice<T>& b) const {
    const dice<T> &a = *this;
    return a[TOP] == b[TOP] && a[BOTTOM] == b[BOTTOM] &&
      a[FRONT] == b[FRONT] && a[BACK] == b[BACK] &&
      a[LEFT] == b[LEFT] && a[RIGHT] == b[RIGHT];
  }
  void roll_x() { roll(TOP, BACK, BOTTOM, FRONT); }
  void roll_y() { roll(TOP, LEFT, BOTTOM, RIGHT); }
  void roll_z() { roll(FRONT, RIGHT, BACK, LEFT); }
  vector<dice> all_rolls() {
    vector<dice> ret;
    for (int k = 0; k < 6; (k&1?roll_y():roll_x()),++k)
      for (int i = 0; i < 4; roll_z(), ++i)
        ret.push_back(*this);
    return ret;
  }
  bool equivalent_to(const dice& di) {
    for (int k = 0; k < 6; (k&1?roll_y():roll_x()),++k)
      for (int i = 0; i < 4; roll_z(), ++i)
        if (*this == di) return true;
    return false;
  }
private:
  void roll(FACE a, FACE b, FACE c, FACE d) {
    T tmp = id[a];
    id[a] = id[b]; id[b] = id[c];
    id[c] = id[d]; id[d] = tmp;
  }
  T var[6];
  int id[6];
};

FACE face[] = {TOP,FRONT,RIGHT,LEFT,BACK,BOTTOM};

int dx[] = {-1,0,0};
int dy[] = {0,-1,0};
int dz[] = {0,0,-1};
FACE dc[] = {RIGHT,FRONT,BOTTOM};
FACE rdc[] = {LEFT,BACK,TOP};
dice<char> field[2][2][2];
bool found;

void dfs(int x,int y,int z,int state,vector<dice<char> >& dices)
{
  if(found)return;
  if(state >= (1<<8)-1)
    {
      found = true;
      return;
    }

  rep(i,8)
    {
      if((state>>i) & 1)continue;
      vector<dice<char> > next = dices[i].all_rolls();
      rep(j,next.size())
	{
	  bool ok = true;
	  rep(k,3)
	    {
	      int nx = x + dx[k];
	      int ny = y + dy[k];
	      int nz = z + dz[k];
	      if(!( 0 <= nx && nx < 2 && 0 <= ny && ny < 2 && 0 <= nz && nz < 2 ))continue;
	      char a = field[nz][ny][nx][dc[k]];
	      char b = next[j][rdc[k]];
	      if(!(a != b && tolower(a) == tolower(b) ))
		{
		  ok = false;
		  break;
		}
	    }

	  int nx = x + 1;
	  int ny = y;
	  int nz = z;
	  if(nx >= 2)nx %= 2, ny++;
	  if(ny >= 2)ny %= 2, nz++;

	  if(ok)
	    {
	      field[z][y][x] = next[j];
	      dfs(nx,ny,nz,state|(1<<i),dices);
	      if(found)return;
	    }
	}
    }

}

int main()
{
  while(true)
    {
      vector<dice<char> > dices((8),dice<char>());
      rep(i,8)
	{
	  rep(j,6)
	    {
	      cin >> dices[i][face[j]];
	      if(dices[i][face[j]] == '0')goto Fin;
	    }
	}

      found = false;
      dfs(0,0,0,0,dices);
      cout << (found?"YES":"NO") << endl;
    }
 Fin:;
  return 0;
}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n); i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)	
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define REVSORT(c) SORT(c);REVERSE(c)
#define ALL(x) (x).begin(),(x).end()
#define LOOP while(true)
#define INF 1e9
const long long MOD = 1000000007;
typedef long long ll;

int main(void){
	int N, X;
	cin >> N >> X;
	int ans = N;
	vector<int> M(N);
	rep(i, N){
		cin >> M[i];
		X -= M[i];
	}
	SORT(M);
	cout << ans + X / M[0] << endl;
}

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

void call(int n)
{
    for (int i=1; i<=n; ++i)
    {
        int x = i;
        if (x%3 == 0)
        {
            cout << " " << i;
        }
        else
        {
            do
            {
                if (x%10 == 3)
                {
                    cout << " " << i;
                    break;
                }
                x /= 10;
            } while (x);
        }
    }
    cout << endl;
}

int main()
{
    int x = 0;
    cin >> x;
    call(x);
    
    return 0;
}

Measured memory_bytes: 1160
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

num = [0]*(n+1)
bc = [0]*(n+1)


for i in range(n):
    num[a[i]] += 1
    num[b[i]] += 1
    bc[b[i]] += 1

if max(num) > n:
    print("No")

else:
    nc = []
    for i in range(n):
        nc.append([num[i+1], i+1])
    nc.sort(reverse = True)

    usenum = []
    tot = 0
    q = []
    rem_num = []
    for i in range(n):
        x, y = nc[i]
        if tot >= n:
            rem_num.append((bc[y], y))
            continue
        tot += x
        usenum.append(y)
        q.extend([y]*bc[y])


    q.reverse()
    usenum = set(usenum)
    a_index = set()
    for i in range(n):
        if a[i] not in usenum:
            a_index.add(i)


    ans = [None]*(n)
    for ai in a_index:
        ans[ai] = q.pop()

    a_remain = set([i for i in range(n)]) - a_index
    a_remain = list(a_remain)
    a_remain.sort()
    from collections import deque
    a_remain = deque(a_remain)


    while q:
        now = q.pop()
        while True:
            ins = a_remain.popleft()
            if a[ins] == now:
                a_remain.append(ins)
                continue
            else:
                ans[ins] = now
                break

    q = []
    for x, y in rem_num:
        q.extend([y]*x)

    while q:
        now = q.pop()
        ins = a_remain.pop()
        ans[ins] = now

    print("Yes")
    print(" ".join(map(str, ans)))


Measured memory_bytes: 221400
#include <stdio.h>

int main(int argc,char* argv[]) {
	int masumax;
	int saikoromax;
	int masu[1000];
	int saikoro[1000];
	int i;
	int nowpos;
	while(1) {
		scanf("%d %d",&masumax,&saikoromax);
		if(masumax==0 && saikoromax==0)break;
		for(i=0;i<1000;i++) {
			masu[i]=0;
			saikoro[i]=0;
		}
		for(i=0;i<masumax;i++) {
			scanf("%d",&masu[i]);
		}
		for(i=0;i<saikoromax;i++) {
			scanf("%d",&saikoro[i]);
		}
		nowpos=0;
		for(i=0;i<saikoromax;i+=0) {
			nowpos+=saikoro[i];
			i++;
			if(nowpos>=masumax)break;
			nowpos+=masu[nowpos];
			if(nowpos>=masumax)break;
		}
		printf("%d\n",i);
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>

using namespace std;

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

	int cnt = 0;

	for(int i = 0; i < N; ++i){
		if(h[i] >= K) cnt++;
	}

	cout << cnt << endl;

	return 0;
}


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

#define endl '\n'

using namespace std;

int main(){

  cin.tie(0);     // cout と cin の同期を切る
  ios::sync_with_stdio(false);  /* cの stdioストリーム (printfとか)と*/

  int a,b,c;

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

  if(a>=2020||(a>=2019&&b>=5&&c>=1)){
    cout<<"TBD"<<endl;
  }else{
    cout<<"Heisei"<<endl;
  }
  

  return 0;

}


Measured memory_bytes: 256
s = input()
switch = -1
prev_c = 'R'
prev_i = 0
ans = [0] * len(s)
for i, c in enumerate(s):
    if prev_c == 'R' and c == 'L':
        switch = i
        prev_c = 'L'
        continue
    if prev_c == 'L' and c == 'R':
        total = i - prev_i
        if (switch - prev_i) % 2 == 0:
            ans[switch - 1] = total // 2
            ans[switch] = total - total // 2
        else:
            ans[switch] = total // 2
            ans[switch - 1] = total - total // 2
        prev_i = i
        prev_c = c
total = len(s) - prev_i
if (switch - prev_i) % 2 == 0:
    ans[switch - 1] = total // 2
    ans[switch] = total - total // 2
else:
    ans[switch] = total // 2
    ans[switch - 1] = total - total // 2
print(*ans)

Measured memory_bytes: 6400
#include "bits/stdc++.h"
#define int long long
#define endl '\n'
using namespace std;
 
typedef long long ll;
typedef long double ld;
#define db(x) cerr << #x << ": " << x << '\n';
#define read(a) int a; cin >> a;
#define reads(s) string s; cin >> s;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define readarr(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}

#define print(a) cout << a << endl;
#define printarr(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;}
#define all(v) v.begin(), v.end()
#define sz(v) (int)(v.size())
#define rz(v, n) v.resize((n) + 1);
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define vvi vector <vi>
#define setprec cout << fixed << showpoint << setprecision(20);
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll N = 2e5 + 1;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	readc(a, v, b);
	readb(w, t);
	
	if (b < a) swap(a, b);
	if (v <= w) {cout << "NO"; return 0;}
	int tim = (b-a)/(v-w);
	if ((b-a) % (v-w)) tim++; 
	
	if (tim <= t) {cout << "YES"; return 0;}
	else {cout << "NO"; return 0;}
	
}



















Measured memory_bytes: 3656
//Moh_K_Imar .......
//28/08/2020  ... 11,38.
//Ya Rab....
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
int main(){
    ll a,b;
    cin>>a>>b;
    string s;
    cin>>s;
    s[b-1]=s[b-1]+32;
    cout<<s<<endl;

    return 0;
}



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

int main() {
    long long  n, rnum, bnum, gnum, jogai;
    long long ans;
    string s;
    cin >> n >> s;

    rnum = 0;
    bnum = 0;
    gnum = 0;
    for (long long i=0; i<n; i++){
        if(s[i]=='R'){
            rnum++;
        }else if(s[i]=='G') {
            gnum++;
        }else{
            bnum++;
        }
    }
    ans = rnum * gnum * bnum;
    //cout << "中間結果: " << ans << endl;
    
    for(long long i=0; i<=(n-3)/2; i++){
        for (long long j=0; j+2*i+2<n; j++) {
            long long i_left = j;
            long long i_middle = j+i+1;
            long long i_right = j+2*i+2;
            //cout << s[i_left] << ", " << s[i_middle] << ", " << s[i_right] << endl;

            if(s[i_left]!=s[i_middle] && s[i_middle]!=s[i_right] && s[i_left]!=s[i_right]){
                ans--;
            }
        }
    }
    if(ans < 0) {
        ans = 0;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))


n = ini() % 10
if n in [2, 4, 5, 7, 9]:
    print("hon")
elif n == 3:
    print("bon")
else:
    print("pon")



Measured memory_bytes: 9128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));

        String line = stdin.readLine();
        String[] arg = line.split("\\s");
        int n = Integer.parseInt(arg[0]);
        int d = Integer.parseInt(arg[1]);

        int cnt = 0;

        for (int i = 0; i < n; i++) {
            line = stdin.readLine();
            arg = line.split("\\s");
            long p = Integer.parseInt(arg[0]);
            long q = Integer.parseInt(arg[1]);
            double x = p * p + q * q;
            if (Math.sqrt(x) <= d) {
                cnt++;
            }
        }
        System.out.println(cnt);
    }
}


Measured memory_bytes: 60404
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#define MAXN 100000;
#define Amari 1000000007;
#define p pair <int,int>
using namespace std;
int main(int argc,char const* argv[])
{
  int n,m;
  long long ans=0;
  long long inu=1;
  long long saru=1;
  long long combdown=0;
  long long combup=0;
  cin >> n >> m;
   for(int i=1;i<=n;i++)
	{
	  inu=inu*i%Amari;
	}
      for(int i=1;i<=m;i++)
	{
	  saru=saru*i%Amari;
	}
      if(n >= m+2 || m>= n+2)
	{
	  ans=0; 
	} 
      else
	{
	  if(n>m)
	    {
	      combup=saru;
	      ans=inu*combup%Amari;
	    }
	  else if(m>n)
	    {
	      combup=inu;
	      ans=saru*combup%Amari;
	    }
	  else if(n==m)
	    {
	      combup=inu*2;
	      ans=saru*combup%Amari;
	    }
	}
      cout << ans << endl;
      return 0;
}


Measured memory_bytes: 256
/*"Success isn't permanent, failure isn't fatal,
                                      it's the courage to continue that counts"*/
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define ll long long 
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define pb push_back     
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN
const int mod=1e9+7;         
const int N=5e2+4;

int main()
{
	ll sum=0;

	int n;

	scn(n);

	rep(i,1,n+1)
	{
		rep(j,1,n+1)
		{
			rep(k,1,n+1)
			sum+=gcd(i,gcd(j,k));
		}
	}

	lpri(sum);

    return 0;
}

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

int main() {
  string s;
  cin >> s;

  stack<int> st;
  stack<pair<int, int> > area;
  int sum = 0;
  for (int i=0; i<s.size(); i++) {
    char c = s[i];
    if (c == '\\') {
      st.push(i);
    } else if (c == '/' && st.size() > 0) {
      int j = st.top();
      st.pop();
      sum += i - j;
      int temp = i - j;
      while (area.size() > 0 && area.top().first > j) {
        temp += area.top().second;
        area.pop();
      }
      area.push(make_pair(j, temp));
    }
  }

  vector<int> ans;
  while (area.size() > 0) {
    ans.push_back(area.top().second);
    area.pop();
  }
  reverse(ans.begin(), ans.end());

  cout << sum << endl;
  cout << ans.size();
  for (int i=0; i<ans.size(); i++)
    cout << " " << ans[i];
  cout << endl;

  return 0;
}



Measured memory_bytes: 3272
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef unsigned long long int ull;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ff first
#define ss second
#define pb push_back
#define Inf  1e18
#define inf -1e18
#define mod 1000000007
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll,ll>;
using umll = unordered_map<ll,ll>;
using sll = set<ll>;
using msll = multiset<ll>;
using pll = pair<ll,ll>;
 
ll MUL(ll A,ll B){
  return (A%mod*B%mod)%mod;
}
 
ll ADD(ll A,ll B){
  return (A%mod+B%mod)%mod;
}
 
ull power(ll A,ll B) {
    ull RES = 1;
    while (B > 0)
    {
        if (B & 1)
            RES = RES*A;
        B = B>>1;
        A = A*A;
    }
  return RES;
}
 
 const ll maxS = 2e5+10;
 ll n , m ;
 ll arr[maxS];
 

 
 
void testcases(int cases){
	int a;
	cin >> a;
	cout << a + a*a + a*a*a << "\n";
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
    ll t;
    t = 1;
    //t = 1;
    ll Case =1 ;
    while(t--)
    {
      testcases(Case++);
    }
}


Measured memory_bytes: 3648
#include<iostream>
#include<cstdio>
#include<cstring>
#include<map>
using namespace std;
int rooms[5][4][11];
void pp(){
    for(int i=1;i<=4;i++){
        for(int j=1;j<=3;j++)
            for(int k=1;k<=10;k++){
                cout<<' '<<rooms[i][j][k];
                if(k==10) cout<<'\n';
            }
        if(i!=4)
            printf("####################\n");
    }
}

int main()
{   
    memset(rooms,0,sizeof(rooms));
    int n,b,f,r,v;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>b>>f>>r>>v;
        rooms[b][f][r] += v;
    }
    pp();

}


Measured memory_bytes: 3092
N_D = input()
N_D_l = N_D.split(" ")
N = int(N_D_l[0])
D = int(N_D_l[1])
D_2 = D*D
c = 0
for i in range(N):
  xy = input()
  xyl = xy.split(" ")
  x = int(xyl[0])
  y = int(xyl[1])
  di = x*x + y*y
  if di > D_2:
    pass
  else:
    c = c + 1
print(c)

Measured memory_bytes: 9204
// Last Change: 04/06/2019 17:57:02.
//////////////////////////////////////////////////////////////////////////
// 5/-2=-2, 5%-2=1が出てくる。
// -5/-2=2, -5%-2=-1が出てくる。
//////////////////////////////////////////////////////////////////////////
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

namespace NS {
void LoopUntilZeroInpput() {
  int hogegegege = 0;
  while (cin >> hogegegege && hogegegege != 0) {
  }
}
} // namespace NS

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

  stack<int> S;
  if (N == 0) {
    S.push(0);
  }

  //多くはこっち
  else {
    int tmp;
    while (N != 0) {
      tmp = N % -2;
      if (tmp >= 0) {
        S.push(tmp);
        N /= -2;
      } else {
        S.push(1);
        N = N / (-2) + 1;
      }
    }
  }

  while (!S.empty()) {
    cout << S.top();
    S.pop();
  }
  cout << endl;

  //NS::LoopUntilZeroInpput();
}


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

#define I inline
#define fi first
#define se second
#define R register
#define LL long long
#define mp make_pair
#define reg register int
#define pii pair<int,int>
#define fo(i, a, b) for(reg i = a; i <= b; i++)
#define fd(i, a, b) for(reg i = a; i >= b; i--)
#define cr const reg&
using namespace std;
const int N = 51, mod = 1e9 + 7;

I int _max(cr x, cr y) {return x > y ? x : y;}
I int _min(cr x, cr y) {return x < y ? x : y;}
I int read() {
	reg x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar();
	return x * f;
}
I void ptt(LL x) {if(x >= 10) ptt(x / 10); putchar(x % 10 + '0');}
I void put(LL x) {x < 0 ? putchar('-'), ptt(-x) : ptt(x);}
I void pr1(LL x) {put(x), putchar(' ');}
I void pr2(LL x) {put(x), puts("");}

I int pow_mod(reg a, reg k) {reg ans = 1; for(; k; k >>= 1, a = (LL)a * a % mod) if(k & 1) ans = (LL)ans * a % mod; return ans;}

int f[N][2 * N], jc[N], inv[N];

int main() {
	reg n = read();
	jc[0] = 1; fo(i, 1, n) jc[i] = (LL)jc[i - 1] * i % mod;
	inv[n] = pow_mod(jc[n], mod - 2); fd(i, n, 1) inv[i - 1] = (LL)inv[i] * i % mod;
	f[1][n] = f[1][n - 1] = 1;
	fo(i, 1, n - 1) fo(j, 0, 2 * n) if(f[i][j]){
		reg c = j - n;
		fo(a, 0, n - i) fo(b, 0, n - i - a) if((a + b) != 0 && (a + b + c) % 2 == 0 && a + b - abs(c) >= 0){
			reg &u = f[i + a + b][n + (a - b + c) / 2];
			u = (u + (LL)f[i][j] * inv[a] % mod * inv[b]) % mod;
		}
	} pr2((LL)jc[n] * f[n][n] % mod);
	return 0;
}



Measured memory_bytes: 256
hoge = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14,
        1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

k = int(input()) - 1
print(hoge[k])


Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>

using namespace std;

int main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int x,y,z;
    while(cin>>x>>y>>z)
    {
        if(y>=x*z)
            cout<<z<<endl;
        else
            cout<<y/x<<endl;
    }
    return 0;
}


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

int main() {
	cin.tie(0)->sync_with_stdio(false);
	int n; cin >> n;
	ll res = 0;
	vector<ll> s(n);
	for (int i = 0; i < n; i++) {
		ll a, b; cin >> a >> b;
		s[i] = a + b;
		res -= b;
	}
	sort(s.rbegin(), s.rend());
	for (int i = 0; i < n; i += 2)
		res += s[i];
	cout << res << '\n';
	return 0;
}

Measured memory_bytes: 3976
import java.io.*;
import java.math.*;
import java.util.*;
 
public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;
 
    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);
 
    private void solve(Scanner sc) {
        int N = sc.nextInt();
        int[] a = new int[N];
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < N; ++i) {
            a[i] = sc.nextInt();
            max = Math.max(max, a[i]);
            min = Math.min(min, a[i]);
        }
 
        _out.println((max - min));
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();
 
        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();
 
        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

Measured memory_bytes: 21716
/**** [ AkJn ] ****/
#include <bits/stdc++.h>
using namespace std;

#define fastIO ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define endl '\n'
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ld long double
#define ll long long
#define fr(i,a,n) for(ll i=a; i<n; i++)
#define fre(i,a,n) for(ll i=a; i<=n; i++)
const ll mod = 1e9 + 7;

/* CHECK THESE POINTS BEFORE SUBMITTING
 * Read the question carefully.
 * Read the code once before final submission.
 * Check the extremities of the constraints.
 * 0 is better than -1.
*/

int main() {
    fastIO

	int n,k;
	cin>>n>>k;
	std::map<int, int> m;
	for (int i = 0; i < k; ++i)
	{
		int temp;
		cin>>temp;
		m[temp] = 1;
	}

	while(1){
		int temp = n, temp2=n;
		while(temp!=0){
			if(m[temp%10]==1){
				n++;
				break;
			}
			temp/=10;
		}
		if(temp2==n){
			cout<<n;
			break;
		}
	}

	return 0;
}

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

map<int, vector<int> > edges;
vector<int> dist;

int getDist(int vertex) {
    if (dist[vertex] != -1) return dist[vertex];
    if (edges.find(vertex) == edges.end()) return dist[vertex] = 0;

    int ans = 0;
    vector<int> toVerticies = edges[vertex];
    for (int i = 0; i < toVerticies.size(); i++) {
        ans = max(ans, 1 + getDist(toVerticies[i]));
    }
    return dist[vertex] = ans;
}

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

    int numVerticies, numEdges, x, y;
    cin >> numVerticies >> numEdges;
    for (int i = 0; i < numEdges; i++) {
        cin >> x >> y;
        edges[x].push_back(y);
    }

    dist.assign(numVerticies + 1, -1);

    int ans = 0;
    for (int i = 1; i <= numVerticies; i++) {
        ans = max(ans, getDist(i));
//      cout << "Max dist from " << i << " is " << dist[i] << '\n';
    }
    cout << ans << '\n';
}


Measured memory_bytes: 17024
#include <stdio.h>
#include <stdlib.h>
#define NIL NULL
 
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
 
Node root;
void Tree_insert(int);
void Tree_print(int);
void preorder(Node u); 
void inorder(Node u); 

int main(){
  int n,x,i;
  char c[10];
 
  scanf("%d",&n);
 
  for(i=0; i<n; i++){
    scanf("%s",c);
     
    if(c[0] == 'i'){
      scanf("%d",&x);
      Tree_insert(x);
    }
     
    if(c[0] == 'p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
   
  return 0;
}
 
void Tree_insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
   
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
 
   
  while(x!=NIL){
    y=x;
     
    if(z->key < x->key){
      x = x->left;
    }
     
    else{
      x = x->right;
    }
  }
    z->parent = y;
 
    if(y==NIL){
      root=z;
    }
     
    else if(z->key < y->key){
      y->left = z;
    }
     
    else {
      y->right = z;
    }
   
}
 
void inorder(Node u){
 
  if(u != NIL){
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  }
 
}
 
void preorder(Node u){
 
  if(u!=NIL){
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
  }  
}

Measured memory_bytes: 24040
import sys
range = xrange
input = raw_input
 
def main():
  n = int(input())
  A = [int(x) for x in input().split()]
  B = [int(x) for x in input().split()]
 
  DP = [0]*(n+1)
  DP[n] = n
  for j in range(3):
      sell = A[j]
      extra = B[j] - sell
      if extra > 0:
          for i in reversed(range(len(DP) - sell)):
              DP[i] = max(DP[i], DP[i + sell] + extra)
  n = max(DP)
  A,B = B,A
 
  DP = [0]*(n+1)
  DP[n] = n
  for j in range(3):
      sell = A[j]
      extra = B[j] - sell
      if extra > 0:
          for i in reversed(range(len(DP) - sell)):
              DP[i] = max(DP[i], DP[i + sell] + extra) 
  print(max(DP))
 
main()

Measured memory_bytes: 227820