akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {

	public static void main(String[] args) {

		//フィールド
		int n = 0;
		int flag = 0;
		//リスト作成
		Scanner scanner = new Scanner(System.in);
		n = scanner.nextInt();
		ArrayList<Integer> intList = new ArrayList<Integer>();
		for(int i = 0; i < n; i++) {
			int x = scanner.nextInt();
			intList.add(x);
		}

		for(int i = 0; i < intList.size(); i++) {
			for(int j = intList.size() - 1; j > i; j--) {
				if(intList.get(j) > intList.get(j-1)) {
					int x = intList.get(j-1);
					intList.set(j-1, intList.get(j));
					intList.set(j, x);
				}
			}
		}

		for(int i = 0; i < intList.size() - 1; i++) {
			if(intList.get(i) > intList.get(i+1)) {
				flag++;
			}
		}


		System.out.println(flag + 1);
	}
}

Measured memory_bytes: 21844
import numpy as np
import itertools
n,m,x = map(int,input().split())
c = [0] * n
a = [0] * n
for i in range(n):
    p = list(map(int,input().split()))
    c[i] = p[0]
    a[i] = list(p[1:])
p_min = float('inf')

for i in range(n):
    for it in itertools.combinations(a,i+1):
        ans = [0] * m
        for li in it:
            ans += np.array(li)
        if all([item >= x for item in ans]):
            p_ans = 0
            for ind in it:
                p_ans += c[a.index(ind)]
            p_min = min(p_min,p_ans)
if p_min == float('inf'):
    print(-1)
else:
    print(p_min)

Measured memory_bytes: 27228
import sys

readline = sys.stdin.readline

def main():
    N = int(input())
    A = list(map(int, readline().split()))
    count = [0] * (pow(10, 5)+3)
    for a in A:
        count[a] += 1
        count[a+1] += 1
        count[a+2] += 1
    ans = max(count) 
    print(ans)     


if __name__ == "__main__":
    main()


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


int main() {
 string S;
  cin >>S;
  vector<string> w;
  w = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
  for(int i=0;i<7;i++){
   if (S == w.at(i)){
    cout << 7 - i <<endl; 
   }
     
  }
}


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

int main() {
  int n;
  string s;
  cin >> n >> s;
  int count = 0;
  for (int i = 0; i<n-2; i++) {
    if (s.at(i) == 'A' && s.at(i+1) == 'B' && s.at(i+2) == 'C') {
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 3608
import sys
from heapq import*
s=sys.stdin.readline
def g(s,g):
 F=[1e7]*-~n;F[s]=0
 H=[(0,s)]
 while H:
  c,u=heappop(H)
  if u==g:return c
  for f,v in E[u]:
   t=c+f
   if t<F[v]:F[v]=t;heappush(H,(t,v))
 return-1
for e in iter(input,'0 0'):
 n,k=map(int,e.split())
 E=[[]for _ in[0]*-~n]
 for _ in[0]*k:
  f=[*map(int,s().split())]
  if f[0]:
   c,d,e=f[1:]
   E[c]+=[(e,d)];E[d]+=[(e,c)]
  else:print(g(*f[1:]))


Measured memory_bytes: 6268
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 998244353 
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n;
int ans[100005];
map<P,int>id;
vector<int>edge[100005];
set<int>S[100005];
int mx;
void dfs(int v,int u){
    //cout << v << u << endl;
    int idd = 0;;
	rep(i,edge[v].size()){
		if(edge[v][i] == u) continue;
		idd++;
		int to = edge[v][i];
		for(int ii=idd;ii<2000005;ii++) if(S[v].find(ii) == S[v].end()){
			int vv = id[P(min(to,v),max(to,v))]; //cout << v << to <<  endl;
			ans[vv] = ii;
			mx = max(mx,ii);
			S[v].insert(ii);
			S[to].insert(ii);
			break;
		}
		dfs(to,v);
	}
}
int main(){
	cin >> n;
	rep(i,n-1){
		int a,b; cin >> a >> b;
		if(a > b) swap(a,b);
		id[P(a,b)] = i+1;
		edge[a].pb(b);
		edge[b].pb(a);
	}
	dfs(1,-1);
	cout << mx << endl;
	repn(i,n-1) printf("%d\n",ans[i]);
}


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

int main(){
  
  string a;
  cin >> a;
  
  if( a <= "2019/04/30" ){
    
    cout << "Heisei" << endl;
    
  }
  
  else{
    
    cout << "TBD" << endl;
    
  }
  
}


Measured memory_bytes: 256
m,a[9][2],S[2000];
D(d,s){int i=0;if(d==m)S[s]++;else for(;i<=a[d][1];i++)D(d+1,s+i**a[d]);}
main(i){for(;scanf("%d",&m),m;){
for(i=0;i<m;i++)scanf("%d%d",a[i],a[i]+1);
memset(S,0,sizeof(S));D(0,0);
for(scanf("%d",&i);i;i--)scanf("%d",&m),printf("%d\n",S[m]);
}exit(0);}

Measured memory_bytes: 608
#include <cstdio>
#include <algorithm>

using namespace std;

int main()
{
	for(int n,w;scanf("%d%d",&n,&w),n|w;){
		int hist[11]={},vmax=0;
		for(int i=0;i<n;i++){
			int v; scanf("%d",&v);
			vmax=max(vmax,v);
			hist[v/w]++;
		}
		int fmax=*max_element(hist,hist+vmax/w+1);
		double res=0.01;
		for(int i=0;i<=vmax/w;i++)
			res+=(1-1.*i/(vmax/w))*(1.*hist[i]/fmax);
		printf("%f\n",res);
	}
	
	return 0;
}

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

int main()
{
    int n; cin>>n;
    vector<int> a(n); for(auto& e: a) cin>>e; sort(begin(a), end(a));
    vector<int> b(n); for(auto& e: b) cin>>e; sort(begin(b), end(b));
    vector<int> c(n); for(auto& e: c) cin>>e; sort(begin(c), end(c));

    long res=0;
    for(auto& e: b) {
        long i=upper_bound(begin(a), end(a), e-1)-begin(a);
        long j=upper_bound(begin(c), end(c), e)-begin(c);
        res+=i*(n-j);
    }
    cout<<res<<endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll a, p;
    cin >> a >> p;

    ll r = a * 3 + p;
    r /= 2;
    cout << r << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main() {
  int w, h, n;
  std::cin >> w >> h >> n;
  int x[100], y[100], a[100];
  int field[100][100];
  int res = 0;
  for (int i = 0; i < n; i++) {
    std::cin >> x[i] >> y[i] >> a[i];
  }
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      field[i][j] = 1;
    }
  }

  for (int i = 0; i < n; i++) {
    if (a[i] == 1) {
      for (int j = 0; j < h; j++) {
        for (int k = 0; k < x[i]; k++) {
          field[j][k] = 0;
        }
      }
    }
    if (a[i] == 2) {
      for (int j = 0; j < h; j++) {
        for (int k = x[i]; k < w; k++) {
          field[j][k] = 0;
        }
      }
    }
    if (a[i] == 3) {
      for (int j = 0; j < y[i]; j++) {
        for (int k = 0; k < w; k++) {
          field[j][k] = 0;
        }
      }
    }
    if (a[i] == 4) {
      for (int j = y[i]; j < h; j++) {
        for (int k = 0; k < w; k++) {
          field[j][k] = 0;
        }
      }
    }
  }

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

  std::cout << res << "\n";

  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int minv = Integer.MAX_VALUE;
		int maxv = Integer.MIN_VALUE;
		for (int i = 0; i < n; i++) {
			int j = scanner.nextInt();
			if (i > 0)
				maxv = Math.max(maxv, j - minv);
			minv = Math.min(minv, j);
		}
		System.out.println(maxv);
	}
}

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

#define all(x)        (x).begin(),(x).end()
#define eb            emplace_back
#define mp            make_pair
#define pb            push_back
#define fi            first
#define se            second
#define sz(x)         ((int)(x).size())
#define rep(x,y,z)    for(int x=y;x<z;x++)
#define per(x,z,y)    for(int x=z-1;x>=y;x--)
#define trav(y,x)     for(auto& y:x)
#define pii           pair<int, int>
#define pll           pair<ll, ll>
#define vi            vector<int>
#define vpi           vector<pii>

int dbg = 0;
#define cri           if(0)
#define shame         cri cerr<<(++dbg)<<"\n\n";

// aaaaaaaaaaaaaaaa
void solve() {
  int MOD = 2019;
  string s; cin >> s;

  int t = 1;
  vi a(sz(s));
  per(i, sz(s), 0) {
    int x = s[i] - '0';
    a[sz(s) - 1 - i] = (x * t) % MOD;
    t = (10 * t) % MOD;
  }

  vi prfx(sz(s) + 1, 0);
  rep(i, 0, sz(s)) {
    prfx[i + 1] = prfx[i];
    prfx[i + 1] += a[i];
    prfx[i + 1] %= MOD;
  }

  vi f(MOD, 0);
  rep(i, 0, sz(s) + 1)
    f[prfx[i]]++;

  ll ans = 0;
  rep(i, 0, sz(s) + 1) {
    f[prfx[i]]--;
    ans += f[prfx[i]];
  }
  cout << ans << '\n';
}

int main() {
  // int _; scanf("%d", &_); while (_--)
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  // int _; cin >> _; while(_--)
  solve();
	return 0;
}



Measured memory_bytes: 5128
class SwapNumber
	def swap(input)
		result = Array.new
		input.each do |val|
			result << val.sort
		end
		result.each do |val|
			puts "#{val[0]} #{val[1]}"
		end
	end
end

array = Array.new

while line = gets
	array << line.split.map(&:to_i)
	break if (array[-1][0] == 0 && array[-1][1] == 0)
end

array.delete_at(-1) ## [0,0]要素を消す

SwapNumber.new.swap(array)

Measured memory_bytes: 6116
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define P pair<int, int>
#define F first
#define S second
#define prime 1000000007
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 1};
signed main(void) {
    vector<bool> V(200010, true);
    vector<int> Prime;
    V[0] = false;
    V[1] = false;
    for(int i = 2; i < 200010; i++) {
        if(V[i]) {
            Prime.push_back(i);
            for(int j = 2; j * i < 200010; j++) {
                V[i * j] = false;
            }
        }
    }
    int N;
    cin >> N;
    cout << *lower_bound(all(Prime), N) << endl;
}


Measured memory_bytes: 640
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define inf 1e+9
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

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

    int n,ans=0,sum1=0,sum2=0;
	cin >> n;
	int a[n],b[n];
	vector<pint> ab(n);
	rep(i,n){
		cin >> a[i] >> b[i];
	}
	rep(i,n){
		ab[i] = make_pair(b[i],a[i]);
	}
	std::sort(ab.begin(),ab.end());
	
	rep(i,n){
		sum2+=ab[i].second;
		if(sum2>ab[i].first){
			ans++;
			break;
		}
	}

	if(ans==1){
		cout << "No" << endl;
	}
	else{
		cout << "Yes" << endl;
	}
}

Measured memory_bytes: 3456
import math
a,b,h,m = input().split()

a = int(a)
b = int(b)
h = int(h)
m = int(m)

deg = abs(30*h + 0.5*m - 6*m)

ans2 = a**2+b**2-2*a*b*math.cos(math.radians(deg))
print(math.sqrt(ans2))

Measured memory_bytes: 9452
#include<stdio.h>

int main(void){
	int a,i,j;


	for(i=1; i<=9; i++){
		for(j=1; j<=9; j++){

			a = i*j;
			printf("%dx%d=%d\n",i,j,a);
		}
	}
	
    return 0;
}

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

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

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

    string s;
    cin >> s;

    string t = "";
    for (int i=0; i<s.size(); ++i) {
        if (s[i] == 'A') {
            t += "A";
        } else if (i+1 < s.size() && s[i] == 'B' && s[i+1] == 'C') {
            t += "D";
            i++;
        } else {
            t += "X";
        }
    }

    long long ans = 0;
    int r = -1;
    for (int i=t.size()-1; i>=0; --i) {
        if (r == -1 && t[i] == 'D') {
            r = i;
            continue;
        }
        if (r != -1) {
            if (t[i] == 'A') {
                ans += r - i;
                r --;
            } else if (t[i] == 'X') {
                r = -1;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

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


int main(){
  int a,b;
  cin>>a>>b;

  if( a < b ) cout<<"a < b"<<endl;
  if( a > b ) cout<<"a > b"<<endl;
  if( a == b ) cout<<"a == b"<<endl;


return 0;
}


Measured memory_bytes: 3052
#include <bits/stdc++.h>
#define range(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, b) for (int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x) cerr << #x << " = " << (x) << endl;
#define int long long
using namespace std;

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}

template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
	rep(i, v.size()) { os << v[i] << (i == v.size() - 1 ? "" : " "); }
	return os;
}
template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
	for (T& x : v) { is >> x; }
	return is;
}

signed main() {
	int n;
	cin >> n;
	vector<int> a(n);
	cin >> a;

	int ans = 0;
	rep(i, a.size()) {
		range(j, i + 1, a.size()) { ans += a[i] * a[j]; }
	}
	cout << ans << endl;
}


Measured memory_bytes: 384
from math import sqrt
def solve():
    N,D = map(int,input().split())
    cnt = 0
    for _ in range(N):
        x, y = map(int,input().split())
        dis = sqrt(x**2 + y**2)
        if dis <= D:
            cnt += 1
    
    print(cnt)

if __name__ == '__main__':
    solve()

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

int main() {

	int n; cin >> n;
	vector<int> h(n);
	int h_max = 0;
	for (int i = 0; i < n; i++) {
		cin >> h[i];
		h_max = max(h_max, h[i]);
	}

	if (n == 1) {
		cout << h[0] << endl;
		return 0;
	}

	vector<vector<int>> c(h_max, vector<int>(n, 0));

	for (int i = h_max - 1; i >= 0; i--) {
		for (int j = 0; j < n; j++) {
			if (i <= h[j] - 1) c[i][j] = 1;
		}
	}

	int ans = 0;
	for (int i = h_max - 1; i >= 0; i--) {		
		for (int j = 0; j < n - 1; j++) {
			if (c[i][j] == 1 && c[i][j + 1] != 1) {
				ans++;
			}
			else if (j == n - 2 && c[i][j + 1] == 1) {
				ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<(o)<<" ";}
#define dumpl(o) if(DBG){cerr<<#o<<" "<<(o)<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
#define MAX 210000
signed main() {
	int N; cin >> N;
	int c[MAX] = {};
	rep(i, 0, N) {
		int a, b; cin >> a >> b;
		c[a + b]++;
	}
	rep(i, 0, MAX - 1) {
		c[i + 1] += c[i]/2;
		c[i] %= 2;
	}
	rep(i, 0, MAX) {
		if (c[i] == 0)continue;
		cout << i << " " << 0 << endl;
	}
	return 0;
}

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

#define ll long long
#define ld long double
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define ppb pop_back
#define vll vector<ll>
#define vi vector<int>
#define endl "\n"

const ll INF = 1000000007;

/*
const int max_size = 100001;
int parent[max_size];
int Size[max_size];

int root(int x){
	while(x!=parent[x]){
		parent[x] = parent[parent[x]];
		x = parent[x];
	}
	return x;
}

void sunion(int x,int y){
	int rx = root(x);
	int ry = root(y);
	if(rx != ry){
		if(Size[rx] > Size[ry]){
			parent[ry] = parent[rx];
			Size[rx] += Size[ry];
		}
		else{
			parent[rx] = parent[ry];
			Size[ry] += Size[rx];
		}
	}
}
*/

const int msize = 1e3+5;
int a[msize][msize];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t=1;
	//cin >> t;
	while(t--){
		int h,w;
		cin >> h >> w;
		char c;
		a[0][0] = 1;
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				cin >> c;
				if(c=='.'){
					if(i-1>=0) a[i][j] += a[i-1][j];
					if(j-1>=0) a[i][j] += a[i][j-1];
					a[i][j] %= INF;
				}
				else a[i][j] = 0;
			}
		}
		cout << a[h-1][w-1] << endl;;
	}
	return 0;
}


Measured memory_bytes: 4224
n,m= map(int,input().split())
l = [[] for i in range(0,n+1)]
for i in range(0,m):
    p,y = map(int,input().split())
    l[p].append((i+1,y))

from operator import itemgetter
for i in range(0,n+1):
    l[i].sort(key=itemgetter(1))

ans = [ 0 for i in range(0,m+1)]

for i in range(0,n+1):
    for index,(city,y)in enumerate(l[i]):
        i = str(i)
        if 6-len(i)!=0:
            i = "0"*(6-len(i)) + i
        index = str(index+1)
        if 6-len(index)!=0:
            index = "0"*(6-len(index)) + index
        ans[city] = i+index
for i in range(1,m+1):
    print(ans[i])


Measured memory_bytes: 35972
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main () {
	ll n,l;
	cin >> n>>l;
	ll a[n];
	for(int i=0;i<n;i++){
		cin >>a[i];
	}
	int pos=-1;
	for(int i=0;i<n-1;i++){
		if(a[i]+a[i+1]>=l){
			pos=i;
			break;
		}
	}
	//cout<<"pos="<<pos<<endl;
	if(pos==-1){
		cout<<"Impossible"<<endl;
	}else{
		cout<<"Possible"<<endl;
		for(int i=0;i<pos;i++){
			cout<<i+1<<endl;
		}
		for(int i=n-1;i>pos;i--){
			cout<<i<<endl;
		}
	}
    return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
int main(){
    int n,k;
    cin>>n>>k;
    int ans=1;
    rep(i,n){
        ans = min(ans*2,ans+k);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
	char n[256];
	scanf("%s", &n);
	if ((n[0] == n[1] && n[1] == n[2]) || (n[1] == n[2] && n[2] == n[3])) printf("Yes");
	else printf("No");
	return 0;
}

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

int main() {
    int n; cin >> n;
    vector<Int> a(n);
    rep(i, n) {
        Int tmp;
        cin >> tmp;
        if (i == 0)
            a[i] = tmp;
        else
            a[i] = tmp + a[i-1];
    }
    Int minv = 1000000000000000000LL;
    for (int i = 0; i < n-1; i++) {
        minv = min(minv, (Int)abs((Int)a[n-1] - (2*a[i])));
    }
    cout << minv << endl;
}

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

int main(){
 ios::sync_with_stdio(0);
 cin.tie(0);
 int n,K;
 cin >> n >> K;
 vector<int> v(n+3),ret(n+3,INT_MAX);
 for (int i=0; i<n; ++i) cin >> v[i];
 ret[0]=0;
 for (int i=0; i<n; ++i){
  for (int k=1; k<=K; ++k) ret[i+k] = min(ret[i+k],abs(v[i]-v[i+k])+ret[i]);
 }
 cout << ret[n-1];
 return 0;
}

Measured memory_bytes: 1024
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int N = in.nextInt();
            int even = 0;
            for (int i = 0; i < N; i++) {
                if (in.nextInt() % 2 == 0) even++;
            }

            out.println(pot(3, N) - pot(2, even));
        }

        private long pot(int d, int n) {
            long ans = 1;
            for (int i = 0; i < n; i++) {
                ans *= d;
            }
            return ans;
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



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

int main() {
  int N, l, r, i, count = 0;
  cin >> N;
  vector<int> h(N);
  for (int i = 0; i < N; i++) cin >> h.at(i);
  vector<int> ch(N, 0);
  l = 0;
  while (l != N) {
    for (i = 0; i < N; i++)
      if (h.at(i) != ch.at(i)) break;
    if (i == N) break;
    for (; l < N; l++)
      if (h.at(l) != ch.at(l)) break;
    for (r = l; r < N - 1; r++)
      if (h.at(r + 1) == ch.at(r + 1)) break;

    for (i = l; i <= r; i++) ch.at(i) += 1;
    count++;
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 3616
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Objects;
import java.util.PriorityQueue;
import java.util.StringTokenizer;
import java.util.stream.Collectors;

public class Main {

	public static void main(String args[]) {
		ConsoleScanner cin = new ConsoleScanner();
		PrintWriter cout = new PrintWriter(System.out);
		solve(cin, cout);
		cout.flush();
	}

	static long now() {
		return System.currentTimeMillis();
	}

	static void trace(Object... objects) {
		assert null != System.out.format("trace:%s\n", Arrays.deepToString(objects));
	}

	private static void solve(ConsoleScanner cin, PrintWriter cout) {
		// assert solve(1) == 1;
		int n = cin.nextInt();
		int[][] abcs = new int[n - 1][];
		for (int i = 0; i < abcs.length; i++)
			abcs[i] = new int[] { cin.nextInt(), cin.nextInt(), cin.nextInt() };
		int q = cin.nextInt();
		int k = cin.nextInt();
		int[][] xys = new int[q][];
		for (int i = 0; i < xys.length; i++)
			xys[i] = new int[] { cin.nextInt(), cin.nextInt() };

		long start = now();

		long[] ans = solve(n, abcs, q, k, xys);
		String ansstr = Arrays.stream(ans).mapToObj(Objects::toString)
				.collect(Collectors.joining(System.lineSeparator()));

		cout.println(ansstr);
		trace("elapsed", now() - start);
	}

	private static long[] solve(int n, int[][] abcs, int q, int k, int[][] xys) {
		ArrayList<int[]> edges = new ArrayList<>();
		for (int[] abc : abcs) {
			edges.add(abc);
			edges.add(new int[] { abc[1], abc[0], abc[2] });
		}
		Collections.sort(edges, Comparator.comparingInt(abc -> abc[0]));
		int[] soe = new int[n + 2];
		for (int i = edges.size() - 1; i >= 0; i--) {
			int[] e = edges.get(i);
			soe[e[0]] = i;
		}
		soe[n + 1] = edges.size();

		// 始点Kからの最短経路
		// ダイクストラ法
		long[] dist = new long[n + 1];
		Arrays.fill(dist, -1L);
		PriorityQueue<long[]> pq = new PriorityQueue<>(Comparator.comparingLong(vals -> vals[1]));
		pq.add(new long[] { k, 0 });
		while (!pq.isEmpty()) {
			long[] arg = pq.poll();
			int v = (int) arg[0];
			long c = arg[1];
			if (dist[v] != -1)
				continue;
			dist[v] = c;
			for (int i = soe[v]; i < soe[v + 1]; i++) {
				int[] e = edges.get(i);
				int to = e[1];
				if (dist[to] != -1)
					continue;
				pq.add(new long[] { to, c + e[2] });
			}
		}

		long[] ans = Arrays.stream(xys).mapToLong(xy -> dist[xy[0]] + dist[xy[1]]).toArray();
		return ans;
	}

	static class ConsoleScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		String next() {
			try {
				while (!st.hasMoreElements())
					st = new StringTokenizer(br.readLine());
				return st.nextToken();
			} catch (IOException e) {
				throw new AssertionError(e);
			}
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}
	}

}


Measured memory_bytes: 76688
{-# LANGUAGE LambdaCase #-}

import Data.IORef
import Control.Monad

main :: IO ()
main = do
  s <- getLine
  st <- newIORef ""
  forM_ s $ \case
      '0' -> modifyIORef st (++ ['0'])
      '1' -> modifyIORef st (++ ['1'])
      'B' -> do
        now <- readIORef st
        unless (null now) $ modifyIORef st init
  putStrLn =<< readIORef st


Measured memory_bytes: 380
<?php
fscanf(STDIN, "%d%d%d", $n, $A, $B);
$a = 0; $b = 0;
$s = trim(fgets(STDIN));
for($i = 0; $i < $n; $i++){
  if($s[$i] == "a"){
    if($a+$b < $A+$B){
      echo "Yes\n";
      $a++;
    }else{
      echo "No\n";
    }
  }elseif($s[$i] == "b"){
    if($a+$b < $A+$B && $b < $B){
      echo "Yes\n";
      $b++;
    }else{
      echo "No\n";
    }
  }else{
    echo "No\n";
  }
}


Measured memory_bytes: 4984
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	x := getNextInt(scanner)
	y := getNextInt(scanner)

	if x > y {
		x, y = y, x
	}
	if x*2 < y || (x+y)%3 != 0 {
		fmt.Println(0)
		return
	}

	c := (x + y) / 3
	fac := make([]int64, c+1)
	fac[0] = 1
	mod := int64(1e9 + 7)
	for i := 0; i < c; i++ {
		fac[i+1] = (fac[i] * int64(i+1)) % mod
	}

	fmt.Fprintln(writer, ((fac[c]*inv(fac[x-c])%mod)*inv(fac[2*c-x]))%mod)
	writer.Flush()
}

func inv(n int64) int64 {
	var ii [32]int64
	mod := int64(1e9 + 7)
	ii[0] = n
	for i := 1; i < 31; i++ {
		ii[i] = (ii[i-1] * ii[i-1]) % mod
	}
	var ans int64
	ans = 1
	m := mod - 2
	for i := 30; i >= 0; i-- {
		for m >= 1<<uint(i) {
			ans = (ans * ii[i]) % mod
			m -= 1 << uint(i)
		}
	}

	return ans
}


Measured memory_bytes: 6016
n,m = map(int,input().split())
p_dict = {}
for i in range(m):
    p,y = map(int,input().split())
    if p not in p_dict.keys():
        p_dict[p] =  [[y,p,i]]
    else:
        p_dict[p].append([y,p,i])
ans = []
for p in p_dict.keys():
    p_dict[p].sort()
    for i in range(len(p_dict[p])):
        p_dict[p][i].append(i+1)
        ans.append(p_dict[p][i])
ans.sort(key=lambda x:x[2])
for y, p, oi, si in ans:  
    print("{:06d}{:06d}".format(p, si))  

Measured memory_bytes: 47404
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;



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

    string S;
    cin >> S;

    if (S == "ABC") {
        cout << "ARC\n";
    } else {
        cout << "ABC\n";
    }

    return 0;
}

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

VV g;
vector<bool> used;
V topo;

void dfs(ll now){
    if(used[now])return;
    used[now]=true;
    for(ll to:g[now]){
        dfs(to);
    }
    topo.push_back(now);
}

int main(){
    ll n,m;
    cin>>n>>m;
    g.assign(n, V());
    rep(i,m){
        ll x,y;
        cin>>x>>y;
        x--;y--;
        g[x].push_back(y);
    }
    used.assign(n, false);
    rep(i,n)dfs(i);
    reverse(topo.begin(), topo.end());
    V dp(n,0);
    rep(i,n){
        for(ll now:g[topo[i]]){
            dp[now]=max(dp[now],dp[topo[i]]+1);
        }
    }
    ll ans=0;
    rep(i,n)ans=max(ans,dp[topo[i]]);
    cout<<ans<<endl;
}


Measured memory_bytes: 9460
#! /usr/bin/env python
# -*- coding: utf-8 -*-
instr = raw_input().split()
inint = map(int,instr)
repetitionr= raw_input()
for i in range(int(repetitionr)):
    inint[inint.index(max(inint))] = max(inint) * 2
print sum(inint)


Measured memory_bytes: 2568
#include <algorithm>
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
 
#define rep(X, S, E) for (int(X) = (S); (X) < (E); ++(X))
#define rrep(X, S, E) for (int(X) = (E)-1; (X) >= (S); --(X))
#define itrep(X, Y) for (auto(X) = (Y).begin(); (X) != (Y).end(); (X)++)
#define all(X) (X).begin(), (X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define print(x) cout << x << endl
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll INF = 9 * 1e15;
const ll MOD = 1e9 + 7;
 
// O(|V||E|)
class Graph {
private:
  ll V; // 0index
  vector<pair<ll, pll>> edges;
  vector<bool> hasNegativeCycles;
  vector<ll> dist;
 
public:
  Graph(ll V);
  void addEdge(ll u, ll v, ll w);
  void bellmanFord(ll src);
  ll getDistance(ll n);
  bool hasNegativeCycle(ll n);
};
Graph::Graph(ll V) {
  this->V = V;
  this->dist = vector<ll>(this->V, INF);
  this->hasNegativeCycles = vector<bool>(this->V, false);
}
void Graph::addEdge(ll u, ll v, ll w) { edges.push_back({w, {u, v}}); }
void Graph::bellmanFord(ll src) {
  this->dist[src] = 0;
  vector<pair<ll, pair<ll, ll>>>::iterator it;
 
  for (ll i = 0; i < this->V - 1; i++) {
    for (it = edges.begin(); it != edges.end(); ++it) {
      ll u = it->second.first;
      ll v = it->second.second;
      ll w = it->first;
      if (this->dist[u] + w < this->dist[v]) {
        this->dist[v] = this->dist[u] + w;
      }
    }
  }
 
  for (it = edges.begin(); it != edges.end(); ++it) {
    ll u = it->second.first;
    ll v = it->second.second;
    ll w = it->first;
    if (this->dist[u] + w < this->dist[v]) {
      this->hasNegativeCycles[v] = true;
    }
    if (this->hasNegativeCycles[u] == true) {
      this->hasNegativeCycles[v] = true;
    }
  }
}
ll Graph::getDistance(ll n) { return this->dist[n]; }
bool Graph::hasNegativeCycle(ll n) { return this->hasNegativeCycles[n]; }
 
void solve(long long N, long long M, std::vector<long long> a,
           std::vector<long long> b, std::vector<long long> c) {
  Graph g(N);
  rep(m, 0, M) { g.addEdge(a[m] - 1, b[m] - 1, -c[m]); }
  g.bellmanFord(0);
 
  if (!g.hasNegativeCycle(N - 1)) {
    print(-g.getDistance(N - 1));
  } else {
    print("inf");
  }
}
 
int main() {
  long long N;
  scanf("%lld", &N);
  long long M;
  scanf("%lld", &M);
  std::vector<long long> a(M);
  std::vector<long long> b(M);
  std::vector<long long> c(M);
  for (int i = 0; i < M; i++) {
    scanf("%lld", &a[i]);
    scanf("%lld", &b[i]);
    scanf("%lld", &c[i]);
  }
  solve(N, M, std::move(a), std::move(b), std::move(c));
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    int n;
    cin >> n;
    vint a(n);
    rep(i, n) cin >> a[i];
    map<ll, ll> mp;
    vll sum(n);
    sum[0] = a[0];
    mp[sum[0]]++;
    srep(i, n, 1) {
        sum[i] = sum[i-1] + a[i];
        mp[sum[i]]++;
    }
    ll ans = 0;
    for(auto x : mp) {
        if (x.fi == 0) ans += x.se;
        ans += (x.se*x.se - x.se)/2;
    }

    cout << ans << endl;
    return 0;
}

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)
 
using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

int main(int argc, char *argv[])
{
    int N;
    cin >> N;

    int tmp = N;
    int sum = 0;
    while(tmp > 0) {
        sum += tmp % 10;
        tmp /= 10;
    }

    if (N % sum == 0) {
        Yes
    } else {
        No
    }
    return 0;
}

Measured memory_bytes: 256
R, G, B, N = input().split()
R = int(R)
G = int(G)
B = int(B)
N = int(N)

ans = 0


for r in range(int(N/R)+1):
  for g in range(int((N-r*R)/G)+1):
    if( (N-r*R-g*G) % B == 0):
        ans = ans+1
        
print(ans)

Measured memory_bytes: 3064
///BOTTOM -UP MAIS RAPIDO MENOS MEMORIA
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>

using namespace std;

int pedras[100100];
int dp[100100]; ///Guardo os valores da funcao frog;

int n,k;
const int inf =1e9;

int main(){

    memset(dp,1000000,sizeof(dp));
    cin >>n>>k;

    for(int i=0;i<n;i++){
        cin >> pedras[i];
    }
    dp[0]=0;

    for(int i=0;i<n;i++){
        for(int j=1;j<=k;j++){
            if(i+j<n){
                dp[i+j]=min(dp[i+j],dp[i]+abs(pedras[i]-pedras[i+j]));
            }
        }
    }

    cout<<dp[n-1];
    ///OUUUUUUUU DO JEITO QUE EU FIZ;
    ///::
    /*
    ///Comeca aki a PROGRAMACAO BOTTOM-UP
    dp[n-1]=0;

    for(int i=n-2;i>=0;i--){

        int menor=inf;

        for(int j=1;j<=k;j++){
            if(i+j<=n-1){
                int cost = abs(pedras[i]-pedras[i+j]);
                ///dp[i]=min(dp[i],dp[i+j]+cost);
                menor = min(menor,dp[i+j]+cost);
            }
        }

        dp[i]=menor;
    }

    cout<<dp[0];
    */
}


/**/
/*
/// TOP-DOWN - RECURSIVA;

#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>

using namespace std;

int pedras[100100];
long long dp[100100]; ///Guardo os valores da funcao frog;

int n,k;
const int inf =1e9;

int frog2(int i,int j){

    if(dp[i] != -1){
        return dp[i];
    }

    int menor = inf;

    if(i>=j) return dp[i]=0;

    ///**OUU ASSIM COM ESSE MEU FOR ,,
    /*
    for(int x=1;x<=k;x++){
        if(i+x <= j){
            long long cost = (frog2(i+x,j)+ abs(pedras[i]-pedras[i+x]));

            if(cost < menor){
                menor = cost;
            }
        }
    }*/

    ///**OUU ASSIM COM OQ VI NA NET,,
/*
    for(int x=1;x<=k;x++){
        if(i+x <= j){
            int cost = (frog2(i+x,j)+ abs(pedras[i]-pedras[i+x]));
            menor = min(menor,cost);
        }
    }

    return dp[i] = menor;
}

int main(){

    memset(dp,-1,sizeof(dp));

    cin >>n>>k;

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

    cout<<frog2(0,n-1)<<endl;
}
*/


Measured memory_bytes: 4336
module Main where

import           Control.Monad
import           Data.List
import           Data.Ord
import           Data.List.Split
import qualified Data.Vector.Unboxed as V

solve :: String -> String -> String
solve [] [] = "No"
solve _ [] = "No"
solve [] _ = "Yes"
solve (a:as) (b:bs)
  | b > a = "Yes"
  | b == a = solve as bs
  | otherwise = "No"

main :: IO ()
main = do
  s <- sort <$> getLine
  t <- sortOn Down <$> getLine
  putStrLn $ solve s t


Measured memory_bytes: 508
kth=[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())
print(kth[K-1])

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

#define rep(i,a,n) for (int i = a;i<=n;++i)
#define per(i,a,n) for (int i = n;i>=a;--i)
#define all(x) (x).begin(), (x).end()     
#define SZ(x) ((int)x.size())

typedef vector<int> VI;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef long double ld;

mt19937 mrand(random_device{}());
ll rnd(ll a, ll b) { return a + mrand() % (b - a + 1); }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

int main() {
      ios::sync_with_stdio(false); cin.tie(0);
#ifdef arrias
      freopen("a.txt", "r", stdin);
#endif
      ld r; cin >> r;
      cout << fixed << setprecision(10) << 2 * acos(-1) * r;
      return 0;
}

Measured memory_bytes: 3860
N, *X = map(int, open(0).read().split())

X = sorted(enumerate(X, 1), key=lambda x: x[1])
x_to_i = {x: i for i, x in X}

T = []
for i, x in X:
    T += [i] * (i - 1)
for i, x in X:
    T += [i] * (N - i)
T = iter(T)

C = [0] * (N + 1)
A = []
for x in range(1, N * N + 1):
    if x in x_to_i:
        i = x_to_i[x]
        if C[i] != i - 1:
            print("No")
            quit()
    else:
        i = next(T)
    C[i] += 1
    A.append(i)

print("Yes")
print(*A)

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

int main(){
  int a, b, c;
  cin >> a >> b >> c;

  int res;
  if(a > b){
    res = b;
    b = a;
    a = res;
  }
  if(b > c){
    res = c;
    c = b;
    b = res;
  }
  if(a > b){
    res = b;
    b = a;
    a = res;
  }

  cout << a << " " << b << " " << c << endl;
}



Measured memory_bytes: 3092
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
const int INF = (1 << 30);
const ll INFL = (1LL << 62);
const ll MOD = 1000000007;
template <class T>
bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}
template <class T>
ll mod_pow(ll a, ll n, T mod) {
    mod = (ll)mod;
    ll res = 1, p = a % mod;
    while (n) {
        if (n & 1) res = res * p % mod;
        p = p * p % mod;
        n >>= 1;
    }
    return res;
}
void print() { std::cout << std::endl; }
template <typename T, typename... A>
void print(const T& first, const A&... rest) {
    cout << sizeof...(rest) << endl;
    std::cout << first;
    if (sizeof...(rest)) std::cout << " ";
    print(rest...);
}
template <typename... A>
void print(const A&... rest) {
    print(rest...);
}
template <typename A>
void print(const std::vector<A>& v) {
    std::for_each(v.begin(), v.end(), [](A x) { std::cout << x << " "; });
    std::cout << std::endl;
}

const int MAX = 1000100;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x, y;
    cin >> x >> y;
    ll s, t;
    bool flag = false;
    rep(a, x + 1) {
        if (a % 2 == 0 && (x - a) * 2 + a / 2 == y) {
            s = a / 2;
            t = x - a;
            flag = true;
        }
    }
    // cout << s << " " << t << endl;
    if (!flag) {
        cout << 0 << endl;
        return 0;
    }
    ll n = s + t;
    ll k = s;

    // cout << n << " " << k << endl;
    // fact[0] = 1;
    COMinit();
    cout << COM(n, k) << endl;
    // rep(i, 1000100){
    //   fact[i+1] = fact[i] * (i+1) % MOD;
    // }
    // ll a = mod_pow(fact[k], MOD-2, MOD);
    // cout << a << endl;
    // cout << ((fact[n] * mod_pow(fact[k], MOD-2, MOD) % MOD) *
    // mod_pow(fact[n-k], MOD-2, MOD) % MOD) << endl;

    return 0;
}

Measured memory_bytes: 23680
#include<bits/stdc++.h>
//#include<ext/pb_ds/tree_policy.hpp>
#define ll long long
#define int long long int
#define mkp make_pair
#define maxN 10000007
#define pb push_back
#define ff first
#define ss second
#define debug1(a) cout<<a<<endl;
#define debug2(a,b) cout<<a<<' '<<b<<endl;
#define debug3(a,b,c) cout<<a<' '<<b<<' '<<c<<endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,a,b) for(int i=a;i<b;i++)
#define pi pair<int,int>
#define pii pair<int,pi>
#define mp map<int,int>
#define ump unordered_map<int,int>
#define  vi vector<int>
#define st set<int>
#define mst multiset<int>
#define pq priority_queue
#define mpq priority_queue<int,vector<int>,greater<int> >
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define in cin>>
#define out cout<<
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> orderedSet;
//typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> orderedMSet;
//*p.find_by_order(index) return value at index
//p.order_of_key(key) return index
void printArray(int arr[],int n)
{
   for(int i=0;i<n;i++)cout<<arr[i]<<' ';
}
void printMp(mp m)
{
  mp ::iterator it;
  for(it=m.begin();it!=m.end();it++)cout<<it->first<<' '<<it->second<<endl;
}
void printUmp(ump m)
{
  ump ::iterator it;
  for(it=m.begin();it!=m.end();it++)cout<<it->first<<' '<<it->second<<endl;
}
void printSt(st s)
{
  st ::iterator it;
  for(it=s.begin();it!=s.end();it++)cout<<*it<<' ';
}
void printMst(mst s)
{
  mst ::iterator it;
  for(it=s.begin();it!=s.end();it++)cout<<*it<<' ';
}
void printVec(vector<int>v)
{
for(int i=0;i<v.size();i++)cout<<v[i]<<' ';
}
void printVec2(vector<int>v[],int n)
{
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<v[i].size();j++)
            cout<<v[i][j]<<' ';
        cout<<endl;
    }
}
 set<pair<int,int>> primeset;
void SieveOfEratosthenes(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
        for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p])
          primeset.insert(mkp(p,1));
}

int32_t main()
{
fastio;
int n;in n;int m;in m;
double arr[n];
priority_queue<pair<double,pair<double,double>>> p;
rep(i,n){
    int a;in a;
    p.push(mkp(a,mkp(a,0)));
}
while(m>0){
    double val=p.top().ff;
    double f=p.top().ss.ff;
    double data=p.top().ss.ss;
    data++;
    val=f/pow(2,data);
    p.pop();
    p.push(mkp(val,mkp(f,data)));
    m-=1;
}
int ans=0;
while(!p.empty())
    {
        ans+=p.top().ff;
    p.pop();}
    out ans<<endl;
return 0;
}


Measured memory_bytes: 4724
#include <bits/stdc++.h>
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using cd = complex <double>;

const long long INF = 1e18; 
const int mod = 1e9 + 7;//200003;786433;998244353;
const double Pi = acos(-1);
  
void Fastio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

int n, m;
int Color[100005];
vector <int> Adj[100005];
long long cnt, bi, nbi;

signed main()
{
	Fastio();
	cin >> n >> m;
	for(int i = 1; i <= n; i++)
	{
		Color[i] = -1;
	}
	for(int i = 1; i <= m; i++)
	{
		int u, v;
		cin >> u >> v;
		Adj[u].eb(v);
		Adj[v].eb(u);
	}
	for(int i = 1; i <= n; i++)
	{
		if(Adj[i].size() == 0)
		{
			cnt++;
			continue;
		}
		if(Color[i] != -1)
		{
			continue;
		}
		queue <int> BFS;
		BFS.push(i);
		Color[i] = 0;
		bool ok = true;
		while(BFS.empty() == false)
		{
			int node = BFS.front();
			BFS.pop();
			for(auto x : Adj[node])
			{
				if(Color[x] == -1)
				{
					Color[x] = Color[node] ^ 1;
					BFS.push(x);
				}
				else
				{
					if(Color[x] == Color[node])
					{
						ok = false;
					}
				}
			}
		}
		if(ok)
		{
			bi++;
		}
		else
		{
			nbi++;
		}
	}
	cout << cnt * cnt + cnt * (n - cnt) * 2 + bi * bi * 2 + 2 * bi * nbi + nbi * nbi;
}

Measured memory_bytes: 10616
h,w = gets.chomp.split.map &:to_i
c = []
a = []
10.times{ c << gets.chomp.split.map(&:to_i) }
h.times{ a << gets.chomp.split.map(&:to_i) }

10.times do |k|
  10.times do |i|
    10.times do |j|
      c[i][j] = [c[i][j], c[i][k] + c[k][j]].min
    end
  end
end

need_change = a.flatten.select{|v| v != 1 && v != -1}
if need_change.empty?
  p 0
else
  p need_change.map{|v| c[v][1]}.inject(:+)
end


Measured memory_bytes: 3632