akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define REPR(i,n) for(int i=n-1; i>=(int)(0); i--)
#define FOR(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define FORR(i,a,b) for(int i=(int)(b)-1; i>=(int)(a); i--)
#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()
//**関数リスト**//
int ctoi(char c) {
	switch (c) {
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.second < secondElof.second;
}
ll nod(ll F) {
	ll keta = 1;
	while (F / 10 > 0) {
		keta++;
		F /= 10;
	}
	return keta;
}
ll gcd(ll x, ll y) {
	ll r;
	if (x < y) {
		swap(x, y);
	}
	while (y > 0) {
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}
ll lcm(ll x, ll y) {
	return x * y / gcd(x, y);
}
ll isPrime(ll x) {
	ll i;
	if (x < 2) {
		return 0;
	}
	else if (x == 2) {
		return 1;
	}
	else if (x % 2 == 0) {
		return 0;
	}
	else {
		for (i = 3; i * i <= x; i += 2) {
			if (x % 1 == 0) {
				return 0;
			}
		}
		return 1;
	}
}
void eratos(vl isPrime) {
	//(注)isPrimeのサイズはN+1にする！実際にはmain内に配置して使用
	ll i, j;
	REP(i, isPrime.size()) {
		isPrime[i] = 1;
	}
	isPrime[0] = 0; isPrime[1] = 0;
	for (i = 2; i * i <= isPrime.size() - 1; i++) {
		if (isPrime[i] == 1) {
			j = i * 2;
			while (j <= isPrime.size() - 1) {
				isPrime[j] = 0;
				j = j + i;
			}
		}
	}
}
ll modinv(ll a, ll m) {
	ll b = m, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
void bitSearch(ll n) {
	//実際にはコピーして中身を改変して使う
	ll i;
	REP(i, pow(2, n)) {
		ll p = i;
		REP(i, n) {
			cout << p % 2;
			p /= 2;
		}
		cout << endl;
	}
}
void dfs(ll now) {
	//中身は毎回書き換えて使用
	stack <ll> S;
	//flagは初期値0
	S.push(now);
	//flag[now]=1;
	while (!S.empty()) {
		ll u = S.top();
		//ll v = ;
		//if(flag[v]==0){flag[v]=1;S.push[v];}else{S.pop();}
	}
}
void bfs(ll now) {
	//中身は毎回書き換えて使用
	queue<ll> Q;
	Q.push(now);
	ll u;
	while (!Q.empty()) {
		u = Q.front();
		Q.pop();
		//ll v=;
		//Q.push(v);
	}
}
//**定義場所**//
ll i, j, k, l, m, n;
ll N, M, K, H, W;
ll MOD = 1000000007;
ll ans = 0;
//***********//
int main() {
	cin >> N;
	vl A(N);
	for (i = 0; i < N; i++) {
		cin >> A[i];
	}
	if (A[0] != 0) {
		cout << -1;
	}
	else {
		ll pre = 0;
		for (i = 1; i < N; i++) {
			if (A[i] > A[i-1] + 1) {
				cout << -1;
				exit(0);
			}else if(A[i] == A[i-1] + 1) {
				pre = A[i];
			}
			else if (A[i] == A[i - 1]) {
				ans += pre;
			}
			else if (A[i] == 0) {
				ans += pre;
				pre = 0;
			}
			else {
				ans += pre;
				pre = A[i];
			}
		}
		ans += pre;
		cout << ans;
	}
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ft first
#define sd second
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll s;
    cin>>s;
    ll a=(ll)sqrt(s)-1;
    while(a*a<s) ++a;
    cout<<0<<" "<<0<<" "<<a<<" "<<1<<" "<<a*a-s<<" "<<a<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
int main() {
  unsigned long long int x,y,out=0;
  cin >> x >> y;

  for(unsigned long long int i=x;i<=y;){
    out++;
    i*=2;
  }
  
  cout << out << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for( ll i = (a); i < (ll)(b); i++ )
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort( (x).begin(),(x).end() )
#define REVERSE(x) reverse( (x).begin(),(x).end() )
#define UNIQUE(x) (x).erase( unique( ALL( (x) ) ) , (x).end() )
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())
#define SHOW(x) cout << #x << " = " << x << endl
#define SHOWA(x,n) for( int yui = 0; yui < n; yui++ ){ cout << x[yui] << " "; } cout << endl

#define pb emplace_back
#define fi first
#define se second

using namespace std;

typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vpl> gr;
typedef vector<vl> ml;
typedef vector<vd> md;
typedef vector<vi> mi;
     
const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ld EPS = 1e-12;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> inline T sq( T a ){ return a * a; }

ll in(){ long long int x; scanf( "%lld" , &x ); return x; }
char yuyushiki[1000010]; string stin(){ scanf( "%s" , yuyushiki ); return yuyushiki; }

// head

int n;
int a[100010];

int main(){

  n = in();
  REP(i, n){
    a[i] = in();
  }
  sort(a, a+n);

  int M = a[n-1];
  int m = a[0];
  REP(i, n){
    if(min(a[i], M - a[i]) > min(m, M - m)){
      m = a[i];
    }
  }

  printf("%d %d\n", M, m);
  
  return 0;
}


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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 1e5 + 5;

void solve(){
	int n;
	cin >> n;
	int ans = 1;
	for(; n > 0; n -= ans, ans++);
	ans--;
	printf("%d\n", ans);
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 256
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int n;
    scanf("%d", &n);
    vector<int> a(n);
    int nOr = 0;
    for(int i = 0; i < n; i++){
        scanf("%d", &a[i]);
        nOr = nOr^a[i];
    }
    for(int i = 0; i < n; i++){
        printf("%d ", nOr^a[i]);
    }
  
    return 0;
}


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

using namespace std;

#define loop(i,a,b) for(int i = a; i<b; i++)
#define square(a) (a)*(a)

typedef long long ll;
typedef string str;


int main ()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int r;
	cin >> r;
	
	const long double pi = 3.141592653;
	cout << (long double)r * 2 * pi;
	
    return 0;
	
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef pair<int, int> ii;
typedef pair<ll, ll> pll;

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

	double a, b, c;
	cin >> a >> b >> c;

	cout << setprecision(12);

	double aire_needed = c / a;
	if ( a * b / 2. > aire_needed ){
		double need_opp = 2. * aire_needed / b;
		cout << 90. - atan(need_opp / b) * 180 / M_PI << "\n";
	}else if ( a * b / 2 == aire_needed ){
		cout << 45. << "\n";
	}else if ( a * b <= aire_needed ){
		cout << 0. << "\n";
	}else{
		double surplus = a * b - aire_needed;
		double need_adj = 2. * surplus / a;
		cout << 90. - atan(a / need_adj) * 180 / M_PI << "\n";
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
typedef long long ll;
const ll mod = 1e9+7;
#define rep(i, n) for(int i = 0; i < n; ++i)
using namespace std;

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

    int n, m; cin >> n >> m;
    vector<bool> broken(n, false);
    rep(i, m) {
        int a; cin >> a;
        broken[a] = true;
    }

    vector<int> dp(n+2);
    dp[n] = 1;
    for(int i = n-1; i >= 0; --i) {
        if(broken[i]) {
            dp[i] = 0;
            continue;
        } else {
            dp[i] = (dp[i+1] + dp[i+2])%mod;
        }
    }
    cout << dp[0] << endl;
    return 0;
}


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

	public void solve(){
    Scanner sc=new Scanner(System.in);
		
		int a=sc.nextInt();
		int b=sc.nextInt();
		int c=sc.nextInt();
		int hoz;
		
		if(a > b){
			hoz=a;
			a=b;
			b=hoz;
		}if(b > c){
			hoz=b;
			b=c;
			c=hoz;
		}if(a > b){
			hoz=a;
			a=b;
			b=hoz;
		}else if(b > c){
			hoz=b;
			b=c;
			c=hoz;
		}if(a > b){
            hoz = a;
            a = b;
            b = hoz;
	}
				
        System.out.println(a+" "+b+" "+c);
}
	
	public static void main(String[] args){
        Main obj =new Main();
        obj.solve();
    }
}

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

const int MaxN=2e5+5;

int N,Q,M;
int Fa[MaxN],Mn[MaxN];
long long Ans;

struct Edge{
	int u,v,w;
	
	bool operator<(const Edge &e)const{
		return w<e.w;
	}
}E[MaxN<<1];

int Get_Fa(int x){
	return x==Fa[x]?x:Fa[x]=Get_Fa(Fa[x]);
}

int main(){
	int i,a,b,c,r1,r2;
	scanf("%d%d",&N,&Q);
	for(i=0;i<N;i++)
		Fa[i]=i,Mn[i]=1<<30;
	while(Q--){
		scanf("%d%d%d",&a,&b,&c);
		E[++M]=(Edge){a,b,c};
		Mn[a]=min(Mn[a],c+1);
		Mn[b]=min(Mn[b],c+2);
	}
	for(i=0;i<N*2;i++)
		Mn[(i+1)%N]=min(Mn[(i+1)%N],Mn[i%N]+2);
	for(i=0;i<N;i++)
		E[++M]=(Edge){i,(i+1)%N,Mn[i]};
	sort(E+1,E+M+1);
	for(i=1;i<=M;i++)
		if((r1=Get_Fa(E[i].u))^(r2=Get_Fa(E[i].v))){
			Fa[r1]=r2;
			Ans+=E[i].w;
		}
	printf("%lld\n",Ans);
	return 0;
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll> ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define tr1(x) cerr << #x << ": " << x << endl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trv(a) cerr<<#a<<": ";for(ll zz=0;zz<a.size();zz++) cerr<<a[zz]<<" ";cerr<<endl
#define mod 1000000007ll
#define inf 9999999999999999ll

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    ll k;
    ll n;
    cin>>n>>k;
    cin>>s;
    k--;
    s[k]=s[k]-'A'+'a';
    cout<<s<<"\n";
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
  int A, B;
  int flag[3];
  for (int i=0; i<3; i++) flag[i] = 0;

  cin >> A; flag[A-1] = 1;
  cin >> B; flag[B-1] = 1;

  for(int i= 0; i< 3;i++){
    if (flag[i] == 0) cout << (i+1) << "\n";
  }
  return 0;


}

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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

typedef vector<int> vint;
typedef set<int> sint;

map<char, sint > st;
string ope;
int idx;

sint expr();
sint get();

sint get() {
  if(ope[idx] == 'c') {
    idx++;
    sint S = get();
    sint T;
    for(int e : st['U']) {
      if(!S.count(e)) T.insert(e);
    }
    return T;
  } else if(isupper(ope[idx])) {
    char c = ope[idx++];
    return st[c];
  } else if(ope[idx] == '(') {
    idx++;
    sint S = expr();
    idx++;
    return S;
  } else {
    assert(false);
  }
}

sint expr() {
  sint S = get();
  while(1) {
    if(idx >= ope.size()) return S;
    if(ope[idx] == ')') return S;
    else if(ope[idx] == 'u') {
      //cout<<"union"<<endl;
      idx++;
      sint T = get();
      sint U;
      for(int e : S) U.insert(e);
      for(int e : T) U.insert(e);
      S = U;//return U;
    } else if(ope[idx] == 'i') {
      //cout<<"intersect" << endl;
      idx++;    
      sint T = get();
      sint U;
      for(int e : S) {
	if(T.count(e)) U.insert(e);
      }
      S = U;//return U;
    } else if(ope[idx] == 'd') {
      //cout << "differnce"<<endl;
      idx++;
      sint T = get();
      sint U;
      for(int e : S) {
	if(!T.count(e)) U.insert(e);
      }
      S = U;//return U;
    } else if(ope[idx] == 's') {
      //cout <<"symmetric"<<endl;
      idx++;    
      sint T = get();
      sint U;
      for(int e : S) {
	if(!T.count(e)) U.insert(e);
      }
      for(int e : T) {
	if(!S.count(e)) U.insert(e);
      }
      S = U;//return U;
    } else {
      assert(false);
    }
  }
}

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  char c;
  int sz;
  while(cin >> c >> sz) {    
    st.clear();
    do {
      rep(i, sz) {
	int e; cin >> e;
	st[c].insert(e);
	st['U'].insert(e);
      }
    } while(cin >> c >> sz, c != 'R');
    cin >> ope;
    idx = 0;
    sint ans = expr();
    if(ans.empty()) {
      cout<<"NULL"<<endl;
      continue;
    }
    bool flag = false;    
    for(int e : ans) {
      if(flag) cout << " ";
      flag = true;      
      cout << e;
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 3152
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int X = scan.nextInt();
		if(X<1200){
			System.out.println("ABC");
		}else {
			System.out.println("ARC");
		}
	}

}


Measured memory_bytes: 21844
#include <iostream>
using namespace std;
       
int main()
{
  while(1){ 
  int i, n, x, y;
  cin >>n;
     
  if(n==0){break;}
  else
  {
  x=0; 
  y=0;
       
  int a[n], b[n];
         
  for(i=1;i<=n;i++)
  {
    cin >>a[i]>>b[i];
    if(a[i]>b[i])
    {
      x += a[i]+b[i];
    }
    else if(a[i]<b[i])
    {
      y += a[i]+b[i];
    }
    else
    {
      x += a[i];
      y += b[i];
    }
   } cout <<x<<" "<<y<<"\n";
  }}
       
      
       
  return 0;
}

Measured memory_bytes: 1236
#include<bits/stdc++.h>
using namespace std;
int main(){
  	int n;
	cin >> n;
  	for(int i=0;i<n;i++){
		long long tp;
      	cin >> tp;
      	if(tp%2==0){
			if(tp%3==0 || tp%5==0)continue;
          	cout << "DENIED";
          	return 0;
        }
    }
  cout << "APPROVED";
}

Measured memory_bytes: 256
import re

N = int(input())
S = input()

num_list = ['{:0=3}'.format(i) for i in range(1, 1000)]
pattern_list = [j[0]+"[0-9]*?"+j[1]+"[0-9]*?"+j[2] for j in num_list]
#print(pattern_list[0])


count = 0
for i in range(10):
  mi = re.search(str(i), S)
  if mi:
    for j in range(10):
      mj = re.search(str(j), S[mi.start()+1:])
      if mj:
        for k in range(10):
          if re.search(str(k), S[mi.start()+mj.start()+2:]):
            #print(i,j,k)
            count += 1
print(count)

Measured memory_bytes: 41072
// skip until line 65
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <istream>
#include <iterator>
#include <sstream>
#include <list>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
using namespace std;

#define BR "\n"
#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define ALL(cont) begin(cont),end(cont)
#define AS_MOD(a, b) ((((a) % (b) ) + (b)) % (b))
#define FEACH(it, cont) for(auto (it) = begin(cont); it!=end(cont);++it)
#define FEACHR(it, cont) for(auto (it) = rbegin(cont); it!=rend(cont);++it)
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define getll() ([](){ll s;scanf("%lld", &s);return s;})()
#define getld() ([](){ld s;scanf("%Lf", &s);return s;})()
#define prl(P) printf("%lld", P)
#define prd(P) printf("%.10Lf", P)
#define pr(P) printf(P)
#define MAX(V, T) V=max(V,T)
#define MIN(V, T) V=min(V,T)

#define DumpArray(cont, from, to) for(int __i=from;__i<to;++__i) {cout<<"(" <<__i<<": " << cont[__i]<<")";} cout<<endl;

/*
 * ***_bound(6)
 * 5 6 6 6 6 6 7 7 7
 *   ^lower    ^upper
 * void reverse(c.begin(), c.end())
 *
 * graph
 * seg tree
 * dp
 * brute force
 */
struct Comparator{
    int operator()(int l, int r) const {
        return r<l;
    }
};
struct Vec;
//set<int, Comparator> S;

// solution below
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
int main() {
    cout.precision(10);
    cout<<fixed;
    ll X,Y,A,B,C;
    vector<P> ps;
    vector<ll> As,Bs,Cs;
    cin >> X >> Y >> A >> B >>C;
    ll t;
    REP(i,A) {
        cin >> t;
        As.pb(t);
    }
    REP(i,B) {
        cin >> t;
        Bs.pb(t);
    }
    REP(i,C) {
        cin >> t;
        Cs.pb(t);
    }
    sort(ALL(Cs));
    reverse(ALL(Cs));
    sort(ALL(As));
    sort(ALL(Bs));
    REP(i,X)
        ps.pb(P(As[A-1-i],0));
    REP(i,Y)
        ps.pb(P(Bs[B-1-i],0));
    sort(ALL(ps));
    ll ans=0;
    int ci=0;
    REP(i,X+Y) {
        if (ci<C&&ps[i].fi<=Cs[ci]) {
            ans+=Cs[ci++];
        } else {
            ans += ps[i].fi;
        }
    }
    cout<<ans<<endl;


}

struct Vec{
    double v[2];
    string to_s(){
        return "("+to_string(v[0])+","+to_string(v[1])+")";
    }
    double& operator[](int t){
        return v[t];
    }
    Vec operator+(Vec t) {
        return {v[0]+t[0],v[1]+t[1]};
    }
    Vec& operator+=(Vec t) {
        v[0]+=t[0];v[1]+=t[1];
        return *this;
    }
    Vec operator-(Vec t) {
        return {v[0]-t[0],v[1]-t[1]};
    }
    Vec& operator-=(Vec t) {
        v[0]-=t[0];v[1]-=t[1];
        return *this;
    }
    Vec operator*(double t) {
        return {v[0]*t,v[1]*t};
    }
    Vec& operator*=(double t) {
        v[0]*=t;v[1]*=t;
        return *this;
    }
    double operator*(Vec t) {
        return v[0]*t[0]+v[1]*t[1];
    }
    Vec operator-(){
        return {-v[0],-v[1]};
    }
    static Vec Z;
};
Vec Vec::Z={0,0};


Measured memory_bytes: 8816
#include<cstdio>
int a[32]={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},n;
int main(){
	scanf("%d",&n),printf("%d",a[n-1]);
	return 0;
} 

Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <cstdlib>
using std::size_t;

struct Node
{
   int key;
   Node *prev, *next;
   Node(): Node(0) {}
   Node(int k): key(k), prev(nullptr), next(nullptr) {}
};
//;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
class List
{
private:
   Node *nil;

public:
   List(): nil(new Node) {
      nil->prev = nil->next = nil;
   }

   const Node* const begin()const { return(nil -> next); }
   const Node* const end()  const { return(nil); }

   const Node* const search(int k) const;
   void push_front(int k);
   void erase(const Node* const u);
   void erase_key(int k);
};
//;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
void List::push_front(int k)
{
   Node *u = (Node*)malloc( sizeof(Node) );
   u -> key = k;

   nil->next->prev   = u;
   u->next           = nil->next;
   nil->next         = u;
   u->prev           = nil;
}

const Node* const List::search(int k) const
{
   Node *i = nil -> next;
   while(i != nil && i->key != k)
      i = i->next;
   return(i);
}

void List::erase(const Node* const u)
{
   if( u == nil )return;
   u->next->prev = u->prev;
   u->prev->next = u->next;
   delete u;
}

void List::erase_key(int k)
{
   erase( search(k) );
}
//;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


static List ls;

int main()
{
   int N;
   char s[32];
   scanf("%d", &N);

   while(N--){
      scanf("%s", s);
      if(strlen(s) == 6){
         int n; scanf("%d", &n);
         if(*s == 'd')
            ls.erase_key(n);
         else
            ls.push_front(n);
      }
      else {
         if(s[6] == 'F')
            ls.erase( ls.begin() );
         else
            ls.erase( ls.end() -> prev );
      }
   }

   printf("%d", ls.begin() -> key);
   for(auto i = ls.begin() -> next; i != ls.end(); i = i->next){
      printf(" %d", i -> key);
   }
   printf("\n");
}




Measured memory_bytes: 34012
n,k=map(int,input().split())
r,s,p=map(int,input ().split())
t=input()
t2=""
for i in range(n):
    if t[i]=="r":
        t2=t2+"p"
    elif t[i]=="s":
        t2=t2+"r"
    else:
        t2=t2+"s"
sum=0
for j in range(n):
    if t2[j]=="r":
        sum+=r
    elif t2[j]=="s":
        sum+=s
    else:
        sum+=p
res=n%k
for x in range(k):
    if res>0:
        flag=1
    else:
        flag=0
    tx=""
    for i in range(n//k+flag):
        tx=tx+t2[x+i*k]
    res-=1
    bef=tx[0]
    cnt=0
    for y in range(len(tx)):
        if tx[y]==bef:
            cnt+=1
        else:
            if bef=="r":
                num=r
            elif bef=="s":
                num=s
            else:
                num=p
            if cnt!=1:
                sum=sum-num*(cnt//2)
            cnt=1
            bef=tx[y]
        if y==len(tx)-1:
            if bef=="r":
                num=r
            elif bef=="s":
                num=s
            else:
                num=p
            if cnt!=1:
                sum=sum-num*(cnt//2)
print(sum)


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

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

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

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

    return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define ll long long
#define pll pair<ll,ll>
#define fr first
#define sc second

const int mod = 1e9 + 7;
using namespace std;


int dp[1001][1001];
int n,m;
string s[1001];
char c[1010];
int main(){
    scanf("%d%d",&n,&m);
    for(int i =0 ;i<n;i++){
        scanf("%s",c);s[i] = c;
    }
    dp[n][m] =1 ;
    for(int i = n;i>=1;i--){
        for(int j = m;j>=1;j--){
            if(i == n && j == m)continue;
            if(s[i-1][j-1] == '#')continue;
            if(i + 1 <= n && s[i][j-1] == '.')dp[i][j] = dp[i+1][j];
            if(j + 1 <= m && s[i-1][j] == '.')dp[i][j] += dp[i][j+1];
            if(dp[i][j] >= mod)dp[i][j] -= mod;
        }
    }
    cout << dp[1][1];
    return 0;
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
//make_tuple emplace_back next_permutation push_back make_pair second first setprecision

#if MYDEBUG
#include "lib/cp_debug.h"
#else
#define DBG(...) ;
#endif

using LL = long long;
constexpr LL LINF=334ll<<53;
constexpr int INF=15<<26;
constexpr LL  MOD=1E9+7;

struct Problem{
    int n,m;
    vector<vector<int>> p;
    Problem(LL n, LL m):n(n),m(m),p (n,vector<int>(m)){};
    bool check(int x){
        vector<int> rank(n),cnt(m),eliminated(m);
        for(int i=0; i<n; ++i){
            cnt[p[i][0]]++;
        }
        while(*max_element(cnt.begin(),cnt.end())>x){
            vector<int> to_delete;
            for(int i=0; i<m; ++i){
                if(cnt[i]>x)to_delete.push_back(i);
            }
            for(auto && i:to_delete){
                eliminated[i]=1;
                cnt[i]=0;
            }
            for(int i=0; i<n; ++i){
                if(eliminated[p[i][rank[i]]]){
                    for(int j=rank[i]; j<m; ++j){
                        if(!eliminated[p[i][j]]){
                            rank[i]=j;
                            cnt[p[i][j]]++;
                            break;
                        }
                        if(j==m-1)return false;
                    }
                }
            }
        }
        return true;
    }
    void solve(){
        for(int i=0; i<n; ++i){
            for(int j=0; j<m; ++j){
                cin >> p[i][j];
                p[i][j]--;
            }
        }
        int lb  = 0, ub = 300;
        while(abs(lb-ub)>1){
            int mid = (lb + ub)/2;
            if(check(mid)){
                ub = mid;
            }else{
                lb = mid;
            }
        }
        cout << ub <<"\n";
    }
};

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    long long n=0,m;
    cin >> n >> m;
    Problem p(n,m);
    p.solve();
    return 0;
}



Measured memory_bytes: 640
import java.util.*;
 
class Main{
    Scanner sc = new Scanner(System.in);
 
    Main(){
    int a=sc.nextInt();
    int b=sc.nextInt();
    System.out.print( (a/b)+" "+(a%b)+" " );
    System.out.printf("%.8f\n", (double)a/b );
    }
 
    public static void main(String[] args){
    new Main();
    }
}


Measured memory_bytes: 26536
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <math.h>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// 最小公倍数
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}*/

// AGきたら次C以外、その次もC以外
// AC来たら次はG以外
// AT来たら次も文字列GC以外
// GA来たら次はC以外


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

	int n;
	cin >> n;

	// AGC, ACG, GACの部分列を含まない
	// AGTC, ATGCの部分列も含まない (Tはなんでもいい)
	// dp[3][2][1][i]:= i文字の最大数3,2,1は一つ前の入力
	vector<vector<vector<vector<ll>>>> dp(4, vector<vector<vector<ll>>>(4, vector<vector<ll>>(4, vector<ll>(n + 1, 0))));
	// AGCTを入れる A = 0, G = 1, C = 2, T = 3;
	int first = 3;
	int second = 3;
	int third = 3;
	dp[first][second][third][0] = 1;
	Rep(i, 1, n + 1) {
		rep(d, 4) {
			rep(c, 4) {
				rep(b, 4) {
					rep(a, 4) {
						//if (dp[b][c][d][i - 1] == 0) continue;
						if (a == 0 && b == 1 && c == 2 ||
							a == 0 && b == 2 && c == 1 ||
							a == 1 && b == 0 && c == 2 ||
							a == 0 && b == 1 && d == 2 ||
							a == 0 && c == 1 && d == 2) { // ダメなパターン
							continue;
						}
						else {
							dp[a][b][c][i] += dp[b][c][d][i - 1];
							dp[a][b][c][i] %= mod;
						}
					}
				}
			}
		}
	}

	ll sum = 0;
	rep(d, 4) {
		rep(c, 4) {
			rep(b, 4) {
				sum += dp[b][c][d][n];
				sum %= mod;
			}
		}
	}

	cout << sum % mod << endl;

	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;

long long ncr(int n,int r){
    long long g = 1;
    for (int i=1;i<=r;i++){
        g *= (n-r+i);
        g /= i;
    }
    return g;
}

int main() {
    int n;
    cin >> n;
    vector<long long> a(n),b(n+1);
    for (auto& i:a) cin >> i;

    for (int j=0;j<n;j++) {
        b[j+1] = b[j] + a[j];
    }

    map<long long,long long> l;
    for (int i=1;i<n+1;i++) {
        l[b[i]]++;
    }

    long long g = 0;
    for( auto i = l.begin(); i != l.end() ; ++i ) {
        if ((i->first)==0) {
            g += i->second;
        }
        if (i->second >=2) {
            g += ncr(i->second,2);
        }
    }
    cout << g << endl;
    return 0;
}

Measured memory_bytes: 15872
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            String s = Console.ReadLine();
            String[] strArr = s.Split(' ');

            int intA = int.Parse(strArr[0]);
            int intB = int.Parse(strArr[1]);
            int intC = int.Parse(strArr[2]);

            String strMessage = null;

            if (intA < intB && intB < intC)
            {
                strMessage = "Yes";
            }else
            {
                strMessage = "No";
            }

            Console.WriteLine(strMessage);
        }
    }
}



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

using namespace std;

int N, M;

int main()
{
    cin >> N;
    set<string> latte;
    for (int i = 0; i < N; i++)
    {
        string U;
        cin >> U;
        latte.insert(U);
    }
    cin >> M;
    bool state = false;
    for (int i = 0; i < M; i++)
{
        string T;
       cin >> T;
        if (latte.find(T) == latte.end())
        {
          cout << "Unknown " << T << endl;
            continue;
        }
        if (state) printf("Closed by ");
       else printf("Opened by ");
        cout << T << endl;
        state = !state;
}
    return 0;
}

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

int main() {
    int N, M;
    cin >> N >> M;
    vector<string> A(N);
    vector<string> B(M);
    for (int i = 0; i < N; i++){
        cin >> A[i];
    }
    for (int i = 0; i < M; i++){
        cin >> B[i];
    }
    bool flag = true;
    for (int i = 0; i + M <= N; i++){
        for (int j = 0; j + M <= N; j++) {
            flag = true;
            for (int k = 0; k < M; k++){
                for (int l = 0; l < M; l++){
                    if (A[i+k][j+l] != B[k][l]){
                        flag = false;
                        break;
                    }
                }
                if (flag == false) {
                    break;
                }
            }
            if (flag) {
                break;
            }
        }
        if(flag){
            break;
        }
    }
    if (flag) {
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}



Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int a,b,c,x,i=0;
    scanf("%d%d%d",&a,&b,&c);
    for(x=a; x<=b;x++){
        if (c%x==0) {
            i++;
        }
        
    }
    printf("%d\n",i);
    return(0);
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    ll A, B;
    cin >> A >> B;

    if(A<=9 && A>=1 && B<=9 && B>=1) cout << A*B << endl;
    else cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::cmp;

fn read<T: std::str::FromStr>() -> T {
    let stdin = stdin();
    let mut buf = String::new();
	stdin.lock().read_line(&mut buf);
	buf.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
	read::<String>().trim().split_whitespace()
        .map(|w| w.parse().ok().unwrap()).collect()
}

fn read_vec_char() -> Vec<char> {
    read::<String>().chars().collect()
}

fn read_mat<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn read_mat_char(n: usize) -> Vec<Vec<char>> {
    (0..n).map(|_| read_vec_char()).collect()
}

fn main() {
    let v = read_vec::<usize>();
    let (n,m) = (v[0],v[1]);
    let mut w = read_mat::<usize>(m);
    w.sort_by(|a,b| a[1].cmp(&b[1]));
    let mut ans = 0;
    let mut prev = 0;
    for e in w {
        if prev <= e[0] {
            ans += 1;
            prev = e[1];
        }
    }
    println!("{}",ans);
}


Measured memory_bytes: 10492
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF (1e9+1)
//#define INF (1LL<<59)

int main(){
	int h,w;
	while(cin>>h>>w&&(h||w)){
		vector<string> fie(h);
		rep(i,h)cin>>fie[i];
		
		vector<vector<int>> dp(h,vector<int>(w,0));
		
		rep(i,h){
			if(fie[i][w-1]=='*')dp[i][w-1]=0;
			else dp[i][w-1]=1;
		}
		rep(i,h){
			for(int j=w-2;j>=0;j--){
				if(fie[i][j]=='*')dp[i][j]=0;
				else dp[i][j] = dp[i][j+1]+1;
			}
		}
		
		
		int maxi = 0;
		rep(i,h){
			rep(j,w){
				int wid = INF;
				rep(k,h){
					if(i+k>=h)continue;
					wid = min(wid,dp[i+k][j]);
					maxi = max<int>(maxi,(k+1)*wid);
				}
			}
		}
		cout<<maxi<<endl;
	}
}

Measured memory_bytes: 4172
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Arrays;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    int n = Integer.parseInt(str[0]);
    int k = Integer.parseInt(str[1]);
    int[] p = new int[n];
    int ans = 0;
    str = in.readLine().split(" ");
    for(int i=0; i<n; i++) {
      p[i] = Integer.parseInt(str[i]);
    }
    Arrays.sort(p);
    for(int i=0; i<k; i++) {
      ans += p[i];
    }
    System.out.println(ans);
  }
}

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

template<typename T>
T in(){T tmp; cin >> tmp; return tmp;}

int n, m;
int book[100];

int search(int low, int high);

int main()
{

    while (scanf("%d %d", &m, &n), m){
        int sum = 0;
        int maxi = 0;

        for (int i = 0; i < n; i++){
            scanf("%d", book + i);
            sum += book[i];
            maxi = max(maxi, book[i]);
        }
        printf("%d\n", search(maxi, min(1500000, sum)));
    }

    return 0;
}

int search(int low, int high)
{
    int mini, maxi;

    mini = low, maxi = high;
    while (mini < maxi){
        int sum;
        int now = 1;
        int middle = (mini + maxi) / 2;
        bool flag = true;

        sum = 0;
        for (int i = 0; i < n; i++){
            if (sum + book[i] > middle){
                now++;
                if (now > m){
                    mini = middle + 1;
                    flag = false;
                    break;
                }
                sum = book[i];
            }
            else {
                sum += book[i];
            }
        }
        if (flag){
            maxi = middle;
        }
    }

    return mini;
}

Measured memory_bytes: 1188
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
 
#define barsik ios::sync_with_stdio(false)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair <int, int> pii;
typedef std::unordered_set <int> u_si;
const double PI = acos(-1);
const long double EPS = 1e-9;
using namespace std;


void solve(){
    int a, b;
    cin >> a >> b;
    int n = b - a;
    cout << n * (n + 1) / 2 - b;
}


int main(){
    
    int q = 1;
    //cin >> q;}
    while(q--) solve();
}
// vse dolzhny vyiti v internet po hhtp


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

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	string s; cin >> s;
	int n=s.size();
	int cnt=0;
	for(int i=0;i<n/2;i++){
		if(s[i]!=s[n-1-i])cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n)-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(b)-1;i>=(a);--i)
#define ALL(a) a.begin(),a.end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
    if (a < b) { a = b; return true; }
    return false;
}
template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
    if (a > b) { a = b; return true; }
    return false;
}
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp) {
    os << "{";
    int a = 0;
    for (auto &tp : mp) {
        if (a) os << ", "; a = 1;
        os << tp;
    }
    return os << "}";
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    os << p.first << ":" << p.second;
    return os;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int N, Q; cin >> N >> Q;
    vi a(N);
    REP(i, N) cin >> a[i];

    while (Q--) {
        ll x; cin >> x;
        int r = 0; ll sum = 0, ans = 0;
        REP(l, N) {
            while (r < N and sum <= x) sum += a[r], ++r;
            if (sum > x) {
                ans += r - 1 - l;
            } else {
                ans += r - l;
            }
            sum -= a[l];
        }
        cout << ans << endl;
    }

    return 0;
}



Measured memory_bytes: 3256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int n, m;
    cin >> n >> m;
    VVI e(n);
    REP(i,m){
        int u = in() - 1, v = in() - 1;
        e[u].push_back(v);
    }
    VD dp(n, 1e18);
    double ans = 1e18;
    dp[n - 1] = 0;
    FORR(i,n-2,0){
        double s = 0.0, ma = -1.0;
        for (int x : e[i]){
            s += dp[x];
            chmax(ma, dp[x]);
        }
        if (e[i].size() > 1){
            dp[i] = 1.0 + ((s - ma) / (e[i].size() - 1));
            VD dp2(dp);
            double t = 0.0;
            FORR(j,i-1,0){
                double t = 0.0;
                for (int y : e[j]){
                    t += dp2[y];
                }
                dp2[j] = 1.0 + (t / e[j].size());
            }
            chmin(ans, dp2[0]);
            // cout << i << " " << dp2[0] << endl;
        }
        dp[i] = 1.0 + (s / e[i].size());
    }
    chmin(ans, dp[0]);
    printf("%.15f\n", ans);

    return 0;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

ll dp[5050 * 5050];

ll f(int w1, int v1, int w2, int v2, int w3, int v3, ll N) {
  CLR(dp, 0);
  for (int i = 0; i <= N; i++) {
    if (i + 1 <= N) chmax(dp[i + 1], dp[i] + 1);
    if (i + w1 <= N) chmax(dp[i + w1], dp[i] + v1);
    if (i + w2 <= N) chmax(dp[i + w2], dp[i] + v2);
    if (i + w3 <= N) chmax(dp[i + w3], dp[i] + v3);
  }
  return dp[N];
}

int main2() {
  int N = nextInt();
  int gA = nextInt();
  int sA = nextInt();
  int bA = nextInt();
  int gB = nextInt();
  int sB = nextInt();
  int bB = nextInt();

  ll N2 = f(
    gA, gB,
    sA, sB,
    bA, bB,
    N);
  ll N3 = f(
    gB, gA,
    sB, sA,
    bB, bA,
    N2);
  cout << N3 << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


Measured memory_bytes: 199552
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define RREP(i, n) for(int i = n; i >= n; i--)

#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))

#define endl "\n"
#define pb push_back
#define rtn return
#define elif else if

//INT_MAX = 2^31 - 1
//LLONG_MAX = 2^63 - 1
#define MOD 1000000007
 
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};

typedef long long ll;
typedef unsigned long long ull;

template <typename T>
inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T>
inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T>
inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T>
inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T>
inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

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

	ll n; cin >> n;
	ll pow = 1;
	for(ll i = 1;i <= n;i++){
		pow *= i;
		pow = pow % MOD;
	}
	ll ans = pow % MOD;
	cout << ans << endl;

	rtn 0;
}

Measured memory_bytes: 256
/** MIT License Copyright (c) 2018-2019 Vasilev Daniil **/
#include <bits/stdc++.h>
using namespace std;
template<typename T> using v = vector<T>;
#define int long long
typedef double ld;
typedef string str;
typedef vector<int> vint;
#define rep(a, l, r) for(int a = (l); a < (r); a++)
#define pb push_back
#define fs first
#define sc second
#define sz(a) ((int) a.size())
const long long inf = 4611686018427387903; //2^62 - 1
const long double EPS = 1e-11;
#if 0  //FileIO
const string fileName = "";
ifstream fin ((fileName == "" ? "input.txt"  : fileName + ".in" ));
ofstream fout((fileName == "" ? "output.txt" : fileName + ".out"));
#define get fin >>
#define put fout <<
#else
#define get cin >>
#define put cout <<
#endif
#define eol put endl
void read() {} template<typename Arg,typename... Args> void read (Arg& arg,Args&... args){get (arg)     ;read(args...) ;}
void print(){} template<typename Arg,typename... Args> void print(Arg  arg,Args...  args){put (arg)<<" ";print(args...);}
int getInt(){int a; get a; return a;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//code starts here

void run() {
	int n, a, b;
	read(n, a, b);
	put min(n * a, b);
}
signed main() {srand(time(0)); ios::sync_with_stdio(0); cin.tie(0); put fixed << setprecision(12); run();}


Measured memory_bytes: 256
import sys
N,M,X=map(int,input().split())
L=[list(map(int,input().split())) for i in range(N)]
#print(L)
price=[]
list_X=[X for i in range(M)]
#print(list_X)
for i in range(2**N):
  A=[0 for i in range(M+1)]
  for j in range(N):
    if (i>>j) & 1:
      A = [x+y for (x,y) in zip(A,L[j])] 
  #print(A)
  large = 0
  for i in range(M):
    if A[i+1] >= list_X[i]:
      large += 1
  if large == M:
    price.append(A[0])
  #if A[1:] >= list_X:
    #price.append(A[0])
#print(price)
if price ==[]:
  print(-1)
else:
  print(min(price))

Measured memory_bytes: 9136
#include "bits/stdc++.h"

typedef long long ll;

using namespace std;
int main() {
	int A, B, K, res;
	cin >> A >> B >> K;
	for (int i = min(A,B); i >= 1 ; i--)
	{
		if (A%i==0 && B%i==0) {
			K--;
			if (K==0) {
				cout << i << endl;
			}
		}
	}
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);

		int n,y;

		n = sc.nextInt();
		y = sc.nextInt();

		int i,j,k;



		for(i = 0; i <= n; i++) {
			for(j = 0; j <= n; j++) {
				for(k = 0 ; k <= n; k++) {

					int total = 10000*i+5000*j+1000*k;
					if(i+j+k > n || total > y) {
						break;
					}

					if(total == y && i+j+k == n) {
						System.out.println(i+" "+j+" "+k);
						return;
					}
				}
			}
		}
		System.out.println("-1 -1 -1");

	}

}


Measured memory_bytes: 23764
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int sum = 0;
		
		
		while (sc.hasNext()) {
			String s = sc.next();
			char n[] = s.toCharArray();
			int a=0;
			int cnt = 1;
			

			for (int i = n.length-1; i >=0; i--) {
				if (n[i] == '1' || n[i] == '0' || n[i] == '2' || n[i] == '3'
						|| n[i] == '4' || n[i] == '5' || n[i] == '6'
						|| n[i] == '7' || n[i] == '8' || n[i] == '9') {
					a = a + (int)(n[i]-'0') * cnt;
					cnt = cnt * 10;
				} else {
					sum = sum + a;
					cnt = 1;
					a = 0;
				}
				
			}
			sum = sum + a;

		}
		System.out.println(sum);
	}

}

Measured memory_bytes: 17160
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static final int LINES = 5;
	
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);

		while (true) {
			final int H = sc.nextInt();
			
			if(H == 0){
				break;
			}
			
			int[][] map = new int[H][LINES];
			for(int i = H - 1; i >= 0; i--){
				for(int j = 0; j < LINES; j++){
					final int val = sc.nextInt();
					
					map[i][j] = val;
				}
			}
			
			int score = 0;
			while(true){
				boolean updated = false;
				/*
				System.out.println("----------------------------------------");
				for(int i = 0; i < H; i++){
					for(int j = 0; j < LINES; j++){
						System.out.print(map[i][j] + " ");
					}
					System.out.println();
				}
				*/
				for(int i = 0; i < H; i++){
					for(int j = 0; j < LINES; j++){
						if(map[i][j] == 0){
							continue;
						}
						
						int end = j + 1;
						while(end < LINES && map[i][end] == map[i][j]){
							end++;
						}
						
						final int size = end - j;
						//System.out.println(i + " " + j + " " + end + " " + size);
						if(size >= 3){
							for(int k = j; k < end; k++){
								score += map[i][k];
								map[i][k] = 0;
								updated = true;
							}
						}
					}
				}
				
				if(!updated){
					break;
				}
				
				for(int i = 0; i < H; i++){
					for(int j = 0; j < LINES; j++){
						if(map[i][j] == 0){
							
							boolean ok = false;
							for(int k = i + 1; k < H; k++){
								if(map[k][j] != 0){
									ok = true;
									break;
								}
							}
							
							if(!ok){
								break;
							}
							
							for(int k = i + 1; k < H; k++){
								map[k - 1][j] = map[k][j];
							}
							map[H - 1][j] = 0;
							j--;
						}
					}
				}
			}
			
			System.out.println(score);
		}
	}
	

}

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

using namespace std;

int main() {
    vector<int> a {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};
    int k;
    cin >> k;
    cout << a.at(k-1);
}


Measured memory_bytes: 256