akhauriyash/Code-Regression huggingface dataset:
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <cstring>
#include <math.h>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <bitset>
using namespace std;
using ll=long long;
#define MOD  1000000007


int flag[60][1000];

int main(int argc, char const *argv[]) {
  int n;
  int f=0;
  memset(flag,0,sizeof(flag));
  std::cin >> n;
  string s[50];
  for(int i=0; i<n; i++) std::cin >> s[i];

  for(int i=0; i<n; i++){
    for(int j=0; j<s[i].size(); j++){
      flag[i][s[i][j]]++;
    }
  }

for(int j='a'-0; j<='a'-0+25; j++){
  int mini=999;
  for(int i=0; i<n; i++){
    if(flag[i][j]<mini) mini=flag[i][j];
  }
  if(mini>0) f=1;
  for(int k=0; k<mini; k++) std::cout << (char)j;
}
if(f==1) std::cout  << '\n';

else if(f==0) std::cout << ' '<< '\n';
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define INF 1e9
#define MAX_V 1001
using namespace std;
typedef map<int,int> M;
M G[MAX_V],rG[MAX_V],g[MAX_V];
bool used[MAX_V];  

int dfs(int v,int t,int f){
  if(v == t)return f;
  used[v]=true;
  
  for(M::iterator it=G[v].begin();it!=G[v].end() ;it++){
    int to=it->first;
    int &cap=it->second;
    if(!used[to] && cap > 0){
      int d = dfs(to ,t , min(f,cap));
      if(d > 0){
	cap -= d;
	G[to][v]+=d;
	return d;
      }
    }
  }
  return 0;
}

int max_flow(int s,int t){
  int flow = 0;
  for(;;){
    memset(used,0,sizeof(used));
    int f = dfs(s, t, INF);
    if(f == 0)return flow;
    flow += f;
  }
}

int visited[MAX_V];
void visit(int pos){
  if(visited[pos])return;
  visited[pos]=1;
  for(M::iterator it=rG[pos].begin();it!=rG[pos].end() ;it++)visit(it->first);
}

int check2(int pos){
  if(used[pos]++) return 0;
  int res=0; 
  for(M::iterator it=G[pos].begin();it!=G[pos].end() ;it++)
    if(it->second)res+=check2(it->first);
  
  for(M::iterator it=g[pos].begin();it!=g[pos].end() ;it++)
    res+=it->second*visited[it->first];
  
  return res;
}

int main(){
  while(1){
    int n,m,s,t;
    cin>>n>>m>>s>>t;
    if(!n&&!m&&!s&&!t)break;
    s--,t--;
    for(int i=0;i<n;i++) rG[i].clear(),G[i].clear(),g[i].clear();
    
    for(int i=0,a,b;i<m;i++){
      cin>>a>>b;
      a--,b--;
      G[a][b]++;
      g[b][a]++;
    }

    int mx=max_flow(s,t);
    for(int i=0;i<n;i++)
      for(M::iterator it=G[i].begin();it!=G[i].end() ;it++){
	int to=it->first,cap=it->second;
	if(cap)rG[to][i]=cap;
      }
    
    memset(visited,0,sizeof(visited));
    memset(used,0,sizeof(used));
    visit(t);
    int cnt=check2(s);
    cout<<mx+(cnt>0)<<" "<<cnt<<endl;
  }
  
}

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

typedef pair<int,int> pi;

vector<pi> f(int n)
{
    int t=n;
    vector<pi> ret;
    for(int i=2; i*i<=n; ++i)
    {
        if(t%i==0)
        {
            pi add(i,0);
            while(t%i==0)
            {
                ++add.se;
                t/=i;
            }
            ret.pb(add);
        }
    }
    if(t>1) ret.pb(pi(t,1));
    return ret;
}

int main()
{
    int p,q;
    cin >>p >>q;

    int g=__gcd(p,q);
    p/=g;
    q/=g;

    vector<pi> d=f(q);
    // rep(i,d.size()) printf("%d: %d\n", d[i].fi,d[i].se);

    ll ans=1;
    rep(i,d.size()) ans*=d[i].fi;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3064
queue,decrease = (int(n) for n in input().split(' '))
targ = []
for q in range(queue):
    targ.append([n for n in input().split(' ')])
length = 0
time = 0
while True:

    if int(targ[length][1]) - decrease <= 0:
        time += int(targ[length][1])
        print(str(targ[length][0]) + " " + str(time))
        targ.pop(length)
        queue -= 1
        if queue == 0:
            break
        length = (length) % queue
        
    else:
        time += decrease
        targ[length][1] = int(targ[length][1]) - decrease
        length = (length + 1) % queue

Measured memory_bytes: 16372
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	ll n,a,b;
	cin>>n>>a>>b;
	if(n>1 && b>=a || n==1 && a==b)
		cout<<((n-2)*(b-a)+1);
	else cout<<'0';
	cout<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int w = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		// 計算
		int result = 0;
		if(min(a, b) + w < max(a, b)) result = max(a, b) - (min(a, b) + w);
		
		// 出力
		System.out.println(result);
	}
	
	public static class Scanner {
		private BufferedReader br; private StringTokenizer tok;
		public Scanner(InputStream is) throws IOException { br = new BufferedReader(new InputStreamReader(is));}
		private void getLine() throws IOException { while(!hasNext()) tok = new StringTokenizer(br.readLine());}
		private boolean hasNext() { return tok != null && tok.hasMoreTokens();}
		public String next() throws IOException { getLine(); return tok.nextToken();}
		public int nextInt() throws IOException { return Integer.parseInt(next());}
		public long nextLong() throws IOException { return Long.parseLong(next());}
		public double nextDouble() throws IOException { return Double.parseDouble(next());}
	}
}



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

#ifdef PRINTERS
#include "printers.hpp"
using namespace printers;
#define tr(a)		cerr<<#a<<" : "<<a<<endl
#else
#define tr(a)    
#endif
#define int 		long long
#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b)	for(int i=a;i<b;i++)
using namespace std;

void solve(){
	int K;
	cin>>K;
	vi x(K);
	rep(i,0,K)cin>>x[i];
	ll min1=0;
	ll max1=LLONG_MAX;
	while(max1-min1>1){
		ll mid=min1+(max1-min1)/2;
		ll temp=mid;
		for(auto i:x){
			temp=(temp/i)*i;
		}
		if(temp<2)min1=mid;
		else max1=mid;
	}
	ll min2=0;
	ll max2=LLONG_MAX;
	while(max2-min2>1){
		ll mid=min2+(max2-min2)/2;
		ll temp=mid;
		for(auto i:x){
			temp=(temp/i)*i;
		}
		if(temp>2)max2=mid;
		else min2=mid;
	}
	if(max1>min2){
		cout<<-1;
	}
	else{
		cout<<max1<<" "<<min2;
	}
}

signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
//	cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cassert>
// #include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
// #include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);
*/
using namespace std;

const double PI = 2 * acos(0);

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<pii, pii> ppiipii;
typedef pair<int, ppiipii> pippiipii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> ppiii;
typedef pair<int, ppiii> pippiii;
typedef pair<int, ll> pill;
typedef pair<int, double> pid;
typedef pair<double, double> pdd;
typedef pair<double, pdd> pddd;
typedef pair<string, string> pss;
// note to self, the below two triggers someone
typedef pair<ll, ll> pll;
typedef pair<ll, int> plli;
typedef long double ld;

int n;
int l[1000000];
bool done[1000000];

int main() {
    scanf("%d", &n);
    for(int i = 0; i < n; i++) {
        scanf("%d", &l[i]);
    }
    vector<int> ret;
    for(int i = n-1; i >= 0; i -= 2) {
        done[i] = true;
        ret.push_back(l[i]);
    }
    for(int i = 0; i < n; i++) {
        if(!done[i]) {
            ret.push_back(l[i]);
            done[i] = true;
        }
    }
    for(int i = 0; i < n; i++) {
        printf("%d", ret[i]);
        if(i == n-1) printf("\n");
        else printf(" ");
    }
}


Measured memory_bytes: 4084
//#include "pch.h"
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
#include <numeric>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265359;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };



signed main() {
	string s, t;

	cin >> s >> t;

	cout << t << s << endl;





	return 0;
}

Measured memory_bytes: 256
# Fast IO (only use in integer input)

import os,io
input=io.BytesIO(os.read(0,os.fstat(0).st_size)).readline

# Fenwick Tree to Calculate Sum

N,Q = map(int,input().split())

MaxLength = 2 ** 19
FenwickTree = []

CurLen = MaxLength
while CurLen != 0:
    FenwickTree.append([0] * CurLen)
    CurLen //= 2

Depth = len(FenwickTree)

def addElem(n,index): # add n to an element in index
    for j in range(Depth):
        FenwickTree[j][index] += n
        index //= 2

def firstNSum(n): # Return the sum of the first n elements (0 to n-1)
    nCpy = n
    summ = 0
    depthCur = 0
    while nCpy != 0:
        if nCpy % 2 != 0:
            summ += FenwickTree[depthCur][nCpy - 1]
        nCpy //= 2
        depthCur += 1
    return summ

c = list(map(int,input().split()))
firstLocColor = [-1] * N
ans = [-1] * Q
queries = []
for i in range(Q):
    l,r = map(int,input().split())
    queries.append((l,r,i))
queries.sort(key = lambda x: x[1])
queryIndex = 0
for i in range(N):
    # Update the Fenwick tree to count ith element
    if firstLocColor[c[i] - 1] == -1:
        addElem(1,i)
        firstLocColor[c[i] - 1] = i
    else:
        addElem(-1,firstLocColor[c[i] - 1])
        addElem(1,i)
        firstLocColor[c[i] - 1] = i
    
    # get query
    while queryIndex < Q and queries[queryIndex][1] - 1 <= i:
        if queries[queryIndex][1] - 1 == i:
            ans[queries[queryIndex][2]] = firstNSum(queries[queryIndex][1]) - firstNSum(queries[queryIndex][0] - 1)
        queryIndex += 1

for elem in ans:
    print(elem)

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

// typedef
// -----------------------------------------------------------------------------
typedef long long ll;
typedef long double ld;

// container util
// -----------------------------------------------------------------------------
#define ALL(c)  (c).begin(),(c).end()
#define SZ(c) ((ll)(c).size())
#define MAX(c) *max_element(ALL(c))
#define MIN(c) *min_element(ALL(c))
#define SORT(c) sort((c).begin(),(c).end())

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

// constant
// -----------------------------------------------------------------------------
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);

// debug
// -----------------------------------------------------------------------------
#define DUMP(x)  cerr << #x << " = " << (x) << endl


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    int X; cin >> X;
    int Y; cin >> Y;
    if (Y >= X * 2 && Y <= X * 4 && Y % 2 == 0) {
        cout << "Yes" << "\n";
    } else {
        cout << "No" << "\n";
    }

}

Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <sstream>

using namespace std;


int main(){
	
	int n;
	
	vector<char> v[10];
	
	int a[10] = {0, 0, 3, 3, 3, 3, 3, 4, 3, 4};
	
	v[1].push_back('.');
	v[1].push_back(',');
	v[1].push_back('!');
	v[1].push_back('?');
	v[1].push_back(' ');
	
	int index = 2;
	int count = 0;
	
	for(int i = 0; i < 26; i++){
		v[index].push_back('a' + i);
		count++;
		if(count >= a[index]){
			count = 0;
			index++;
		}
	}
	
	cin >> n;
	
	for(int loop = 0; loop < n; loop++){
		
		string str;
		
		cin >> str;
		
		int ref = 0;
		int count = 0;
		
		for(int i = 0; i < str.size(); i++){
			if(ref == 0 && str[i] != '0'){
				ref = str[i] - '0';
			}else if(str[i] != '0'){
				count++;
			}else if(ref != 0 && str[i] == '0'){
				printf("%c", v[ref][count % v[ref].size()]);
				ref = 0;
				count = 0;
			}
		}
		printf("\n");
		
	}
	return 0;
}

Measured memory_bytes: 3056
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = (1 << 30) - 1;

int H, W, ans, cost[1111][1111], dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
char grid[1111][1111];
queue<pair<int, pair<int, int>>> que;

int main()
{
    cin >> H >> W;

    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            cin >> grid[i][j];
            cost[i][j] = inf;
            if (grid[i][j] == '#')
            {
                que.emplace(0, make_pair(i, j));
            }
        }
    }

    while (!que.empty())
    {
        auto p = que.front();
        que.pop();
        int y = p.second.first, x = p.second.second, cnt = p.first;
        if (cost[y][x] != inf || (cnt != 0 && grid[y][x] == '#'))
            continue;
        ans = max(cnt, ans);
        grid[y][x] = '#', cnt++;
        for (int i = 0; i < 4; i++)
        {
            int ny = y + dy[i], nx = x + dx[i];
            if ((ny < 0 || ny >= H) || (nx < 0 || nx >= W) || (grid[ny][nx] == '#'))
                continue;
            que.emplace(cnt, make_pair(ny, nx));
        }
    }
    cout << ans << endl;
}

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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		double T = sc.nextDouble();
		int A = sc.nextInt();
		double[] H = new double[N];
		for(int i = 0; i < N; i++) {
			H[i] = sc.nextInt();
		}
		double tmp = 2000000000;
		double ans = 2000000000;
		int res = 0;
		for(int i = 0; i < N; i++) {
			tmp = T - H[i] * 0.006;
			if(Math.abs(tmp - A) < ans) {
				ans = Math.abs(tmp - A);
				res = i;
			}
		}
		System.out.println(res + 1);
	}

}


Measured memory_bytes: 25056
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define era(t) t.erase(unique(be(t)),t.end())
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
typedef long long ll;
using namespace std;
const ll mod=1000000007,mod9=1000000009;
template <class T>inline T lcm(T a,T b){return (a*b/__gcd(a,b));}
/*ll fac[100007],finv[100007],inv[100007];
void cominit(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<100007;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;
    }
}
ll com(ll n,ll 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 n;
    cin>>n;
    ll a[n];
    cin>>a[0];
    for(int i=1;i<n;i++){
        cin>>a[i];
        if(a[i]==a[i-1]){
            i--;
            n--;
        }
    }    
    vector<vector<ll> > v(200000);
    vector<vector<ll> > c(n);
    for(ll i=0;i<n;i++){
        v[a[i]-1].pb(i);
    }
    for(ll i=0;i<200000;i++){
        ll niko=v[i].size();
        for(ll j=niko-1;j>0;j--){
            c[v[i][j]].pb(v[i][j-1]);
        }
    }
    ll dp[n];
    dp[0]=1;
    for(ll i=1;i<n;i++){
        dp[i]=dp[i-1];
        if((c[i].size())){
            dp[i]+=dp[c[i][0]];
            dp[i]%=mod;
        }
    }
    cout << dp[n-1]<<endl;
    
    return 0;
}








Measured memory_bytes: 20992
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<ctime>
#include<utility>
#include<functional>
#include<cmath>
#include<vector>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef std::pair<int,int> pii;
typedef std::pair<ll,ll> pll;
void open(const char *s){
#ifndef ONLINE_JUDGE
    char str[100];sprintf(str,"%s.in",s);freopen(str,"r",stdin);sprintf(str,"%s.out",s);freopen(str,"w",stdout);
#endif
}
int rd(){int s=0,c,b=0;while(((c=getchar())<'0'||c>'9')&&c!='-');if(c=='-'){c=getchar();b=1;}do{s=s*10+c-'0';}while((c=getchar())>='0'&&c<='9');return b?-s:s;}
void put(int x){if(!x){putchar('0');return;}static int c[20];int t=0;while(x){c[++t]=x%10;x/=10;}while(t)putchar(c[t--]+'0');}
int upmin(int &a,int b){if(b<a){a=b;return 1;}return 0;}
int upmax(int &a,int b){if(b>a){a=b;return 1;}return 0;}
const ll p=1000000007;
const int N=100010;
int cmp(pii a,pii b)
{
    if(a.first!=b.first)
        return a.first<b.first;
    return a.second>b.second;
}
int n,m,t,t2;
int a[N],b[N],d[N];
pii c[N];
ll e[N];
ll add(ll a,ll b)
{
    a+=b;
    return a>=p?a-p:a;
}
void add(int x,ll v)
{
    for(;x<=t2;x+=x&-x)
        e[x]=add(e[x],v);
}
ll sum(int x)
{
    ll s=0;
    for(;x;x-=x&-x)
        s=add(s,e[x]);
    return s;
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    for(int i=1;i<=m;i++)
        scanf("%d",&b[i]);
    for(int i=1;i<=n;i++)
        if(a[i]>b[1]&&a[i]<b[m])
        {
            int x=lower_bound(b+1,b+m+1,a[i])-b;
            if(b[x]==a[i])
                continue;
            c[++t]=pii(a[i]-b[x-1],b[x]-a[i]);
            d[++t2]=b[x]-a[i];
        }
    sort(d+1,d+t2+1);
    t2=unique(d+1,d+t2+1)-d-1;
    for(int i=1;i<=t;i++)
        c[i].second=lower_bound(d+1,d+t2+1,c[i].second)-d;
    sort(c+1,c+t+1,cmp);
    t=unique(c+1,c+t+1)-c-1;
    ll ans=1;
    for(int i=1;i<=t;i++)
    {
        ll s=sum(c[i].second-1)+1;
        ans+=s;
        add(c[i].second,s);
    }
    ans%=p;
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 2432
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

  int t = 1900 * m + 100 * (n - m);
  for (int i = 0; i < m; i++)
    t *= 2;
  cout << t << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
bool vis[1000005];
int main() {
    ios::sync_with_stdio(0);cin.tie(NULL); cout.tie(NULL);
    ll x,n,i,j;
    cin>>n;
    map<ll,ll> m;
    for(i=0;i<n;i++){
        cin>>x;
        m[x]++;
    }
    memset(vis,false,sizeof(vis));
    ll ans=0;
    for(auto k:m){
        for(j=2*k.first;j<=1000000;j+=k.first)
         vis[j]=true;
    }
    
    for(auto k:m)
    // cout<<k.first<<" "<<vis[k.first]<<"\n";
     if(k.second==1 && vis[k.first]==false)ans++;
    cout<<ans;
    
    return 0;
}

Measured memory_bytes: 17124
import java.util.Arrays;
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if(a > c){
            int temp = a;
            a = c;
            c = temp;
        }
        if(a > b){
            int temp = a;
            a = b;
            b = temp;
        }
        if(b > c){
            int temp = b;
            b = c;
            c = temp;
        }
        System.out.println(a + " " + b + " " + c);
    }
}


Measured memory_bytes: 26240
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc =new Scanner(System.in);
    int K =sc.nextInt();
    int M[] ={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};
    System.out.println(M[K-1]);
  }
}

Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define itc ll t;cin>>t;while(t--)
#define otc ll t=1;while(t--)
#define PI 3.141592653589793238
//ang=(PI*ang)/180.0 in radian
#define Max(a,b,c) max(a,max(b,c));
#define all(v) v.begin(),v.end()
#define ll long long int
#define ld long double
#define pb push_back
#define eb emplace_back
#define gcd(a,b) __gcd(a,b)
#define fi first
#define se second
int dx[4] = {0, -1, 0, 1};
int dy[4] = {1, 0, -1, 0};
int main()
{
/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif*/
	int x, n;
	cin >> x >> n;
	set<int>st;
	int ar[n];
	for (int i = 0; i < n; i++)
	{cin >> ar[i]; st.insert(ar[i]);}

	int r = x;
	int l = x;

	while (1)
	{
		if (st.find(l) == st.end())
		{	cout << l << endl;
			break;
		}
		if (st.find(r) == st.end())
		{	cout << r << endl;
			break;
		}
		r++;
		l--;
	}

	return 0;
}

Measured memory_bytes: 3620
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int n;
LL a[101010];
LL x[101010];
LL sum, oddsum;

int main(){
    cin >> n;
    REP(i, n){
        cin >> a[i];
        if(i % 2)oddsum += a[i];
        sum += a[i];
    }
    x[0] = sum - 2LL * oddsum;
    for(int i = 1;i < n;i++){
        x[i] = (a[i - 1] - x[i - 1]/2) * 2;
    }
    REP(i, n){
        if(i)cout << " ";
        cout << x[i];
    }
    cout << endl;
}

Measured memory_bytes: 2944
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#include <bits/stdc++.h>
const int ZERO = 2 * 80 * 80 * 16;
std::bitset<2 * ZERO + 1> curr[80], next[80];
int a[80][80], b[80][80], nRows, nCols;
int main() {
    std::cin >> nRows >> nCols;
    for (int i = 0; i < nRows; i++) {
        for (int j = 0; j < nCols; j++) {
            std::cin >> a[i][j];
        }
    }
    for (int i = 0; i < nRows; i++) {
        for (int j = 0; j < nCols; j++) {
            std::cin >> b[i][j];
        }
    }
    curr[0][ZERO] = 1;
    for (int r = 0; r < nRows; r++) {
        std::fill(next,next+80,0);
        int d = std::abs(a[r][0] - b[r][0]);
        next[0] = (curr[0] << d) | (curr[0] >> d);
        for (int c = 1; c < nCols; c++) {
            d = std::abs(a[r][c] - b[r][c]);
            next[c] |= (next[c-1] << d) | (next[c-1] >> d);
            next[c] |= (curr[c] << d) | (curr[c] >> d);
        }
        std::copy(next,next+80,curr);
    }
    int answ = ZERO+1;
    for (int x = -ZERO; x <= ZERO; x++) {
        if (curr[nCols-1][x+ZERO]) {
            answ = std::min(answ,std::abs(x));
        }
    }
    assert(answ <= ZERO);
    std::cout << answ << std::endl;
    return 0;
}


Measured memory_bytes: 8448
#include <stdio.h>

int main(void) {
    int N;
    scanf("%d", &N);

    unsigned long long result = 0;
    int i = 0;
    for (i = 1; i <= N; i++) {
        if (i % 3 != 0) {
            if (i % 5 != 0) {
            result += (unsigned long long)i;
            }
        }
    }

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

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

typedef long long int ll;
typedef long double ld;

//****************************************************                
#define lp(var,start,end) for (ll var = start; var <end ; ++var)
#define rlp(var,start,end) for(ll var = start; var>=end ; var--)
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define pll pair<ll,ll> 
#define vpll vector<pll>
#define all(X) X.begin(),X.end()
#define endl "\n" //comment it for interactive questions
#define trace1(a) cerr << #a << ": " << a << endl;
#define trace2(a,b) cerr << #a << ": " << a << " " << #b << ": " << b << endl;
#define trace3(a,b,c) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << endl;
#define trace4(a,b,c,d) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << #d << ": " << d << endl;
#define OC freopen("input.txt" , "r", stdin); freopen("output.txt" , "w", stdout) 
#define MOD (ll)1e9+7; //change it for other mods
#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
        //*******************************************************
//Some Functions

ll powmod(ll a,ll b)
{
   ll res = 1;
   while(b > 0) {
      if(b & 1) res = (res * a) % MOD;
      a = (a*a)%MOD;
      b = b >> 1; 
  }
  return res % MOD;
}

void solve()
{
    ll x,y;
    cin >> x >> y;
    cout << (x*y)/__gcd(x,y) << "\n";
}

int main()
{
    FAST_IO;
    #ifndef ONLINE_JUDGE 
      // OC;
    #endif
    ll t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 256
n=int(input())
s=input()
accuml=[0]*n
accumr=[0]*n
for i in range(1,n):
    accuml[i]+=accuml[i-1]
    accumr[n-i-1]+=accumr[n-i]
    if s[i-1]=="W":
        accuml[i]+=1
    if s[n-i]=="E":
        accumr[n-i-1]+=1
ans=10**18
for i in range(n):
    ans=min(ans,accuml[i]+accumr[i])
print(ans)
#print(accuml)
#print(accumr)

Measured memory_bytes: 33112
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cassert>
#include <bitset>

//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;

//std::cout << std::fixed << std::setprecision(10)
//std::ios::sync_with_stdio(false);
constexpr long long MOD = 1000000007;

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

int hist[100001] = {};

int main()
{
  int N;
  std::cin >> N;
  std::vector<int> a(N);
  for(auto& val: a)
    std::cin >> val;
  int Q;
  std::cin >> Q;
  std::vector<std::pair<int, int>> q(Q);
  for(auto& p: q)
    std::cin >> p.first >> p.second;
  long long sum = 0;
  for(auto val: a)
  {
    sum += val;
    hist[val]++;
  }
  for(auto& [b, c]: q)
  {
    sum -= (long long)b * hist[b];
    sum += (long long)c * hist[b];
    hist[c] += hist[b];
    hist[b] = 0;
    std::cout << sum << "\n";
  }

  return 0;
}



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

int main() {
   ll x;
   cin >> x;
   //ll inf = 1000000000;
   ll ans = 0;
   ll money = 100;
   while (true)
   {
       money *= 1.01;
       ans++;
       if (money >= x)  break;
   }   
   cout << ans;
   return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <stack>
using ll = long long;
using uint = unsigned int;
using graph = std::vector<std::vector<ll>>;
using wGraph = std::vector<std::vector<std::pair<ll,ll>>>;
#define rep(i,n) for (int i=0; i < int(n); i++)

using namespace std;
ll MOD7 = 1000000007;
ll MOD9 = 1000000009;
vector<ll> InputVec(ll N){
    vector<ll> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    return A;
}
void OutputVec(vector<ll> A){
    for (int i = 0; i < A.size(); ++i) {
        cout << A[i] << ",";
    }
    cout << endl;
}
vector<vector<ll>> InputVec2d(ll H,ll W){
    vector<vector<ll>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<ll>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        for (int xi = 0; xi < W; ++xi) {
            cin >> A[yi][xi];
        }
    }
    return A;
}
vector<vector<char>> InputVec2dStr(ll H,ll W){
    vector<vector<char>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<char>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        string S;
        cin >> S;
        for (int xi = 0; xi < W; ++xi) {
            A[yi][xi] = S[xi];
        }
    }
    return A;
}
void OutputVec2d(vector<vector<ll>> A){
    for (int yi = 0; yi < A.size(); ++yi) {
        for (int xi = 0; xi < A[yi].size(); ++xi) {
            cout << A[yi][xi] << ",";
        }
        cout << endl;
    }
}
graph InputGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    return G;
}
graph InputDGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
    }
    return G;
}
void OutputGraph(graph G){
    for (int i = 0; i < G.size(); ++i) {
        cout << i << ":";
        for (int j = 0; j < G[i].size(); ++j) {
            cout << G[i][j]<< ",";
        }
        cout << endl;
    }
}
void OutputAnswerBool(bool b,bool isUpperCase = false){
    if(b){
        if(isUpperCase){
            cout << "YES" << endl;
        }else{
            cout << "Yes" << endl;
        }
    }else{
        if(isUpperCase){
            cout << "NO" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

int main() {
    ll N;
    cin >> N;
    string s,t;
    cin >> s >> t;
    ll same = 0;
    for (int i = 0; i < N; ++i) {
        ll judge = true;
        for (int j = 0; j <= i; ++j) {
            if(s[N - 1 - i + j] != t[j]){
                judge = false;
            }
        }
        if(judge){
            same = i + 1;
        }
    }
    cout << 2 * N - same << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdlib>  // abs() for integer 絶対値求めやつ
#include <cmath>    // abs() for float, and fabs()
#include <algorithm>
#include <vector>
#include <string>
#define rep(i,n) for(int i = 0; i < (n);i++)
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
using namespace std;
#define INF 2000000000
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
//input power
	int a , b, c , d;
int main(){
	cin >> a >> b >> c >> d;
	int ans = 0;
	rep(i,101){
		if(a<=i&&i<=b-1&&i>=c&&i<=d-1){
			ans++;
		}
	}
	cout<<ans<<endl;

}

Measured memory_bytes: 256
#include <iostream>

int main(int argc, const char * argv[])
{
    int mokeke[5];
    
    for (int i = 0; i < 5; i++) {
        scanf("%d", &mokeke[i]);
    }
    
    int min = 10;
    
    for (int i = 0; i < 5; i++) {
        int r = mokeke[i] % 10;
        
        if (0 < r && r < min) {
            min = r;
        }
    }
    
    int sum = min - 10;
    
    for (int i = 0; i < 5; i++) {
        if (mokeke[i] % 10 == 0) {
            sum += mokeke[i];
        } else {
            sum += mokeke[i] - (mokeke[i] % 10) + 10;
        }
    }
    
    printf("%d", sum);
    
    return 0;
}

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

using namespace std;
#define ALL(x)              (x).begin(),(x).end()
#define REP(i, n)           for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n)       for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define INF                 (ll)2e9
#define MOD                 (1000 * 1000 * 1000 + 7)
#define Ceil(x, n)          (((((x))+((n)-1))/n))
#define CeilN(x, n)         (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)        ((x)-(x)%(n))
#define IsOdd(x)            (((x)&0x01UL) == 0x01UL)
#define IsEven(x)           (!IsOdd((x)))
#define M_PI                3.14159265358979323846
typedef long long           ll;
typedef pair<ll, ll>	    P;

/*-----------------------------------------------------------------------------
　処理
 -----------------------------------------------------------------------------*/
int main()
{
	string N;
	
	cin >> N;

	string ans = "No";
	REP(i, 3) {
		if (N[i] == '7') ans = "Yes";
	}

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


Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
using namespace std;
int GCD(int a, int b) {
  if(b == 0) return a;
  if(a % b == 0) return b;
  return GCD(b, a % b);
}

int N, K;
bool solve() {
  cin >> N >> K;
  int gcd = 0;
  int mx = 0;
  for(int i = 0; i < N; ++i) {
    int a;
    cin >> a;
    gcd = GCD(gcd, a);
    mx = max(mx, a);
  }
  if(mx < K) return false;
  if(K % gcd != 0) return false;
  return true;
}

int main() {
  cout << (solve() ? "" : "IM") << "POSSIBLE" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
const int INF = 1000000000;
using ll=long long;
using P = pair<int,int>;
int main()
{
    int n,x,y;
    cin >> n >> x >> y;
    --x;--y;
    vector<int> ans(n);
    rep(sv,n){
        vector<int> dist(n,INF);
        queue<int> q;
        auto push = [&](int v,int d){
            if(dist[v]!=INF) return;
            dist[v]=d;
            q.push(v);
        };
        push(sv,0);
        while(!q.empty()){
            int v=q.front();q.pop();
            int d=dist[v];
            if(v-1>=0)push(v-1,d+1);
            if(v+1<n)push(v+1,d+1);
            if(v==x)push(y,d+1);
            if(v==y)push(x,d+1);
        }
        rep(i,n)ans[dist[i]]++;
    }
    rep(i,n)ans[i]/=2;
    for(int i=1;i<=n-1;i++)
        cout << ans[i] << endl;
}

Measured memory_bytes: 256
var
	b:boolean;
	n,i,j,k,t,max:longint;
	x,y,h:array[0..200] of longint;
function g(a,b:longint):longint;
begin
	if a>b then exit(a) else exit(b);
end;
begin
	read(n);
	for i:=1 to n do read(x[i],y[i],h[i]);
	for i:=0 to 100 do
		for j:=0 to 100 do
		begin
			for k:=1 to n do
				if h[k]<>0 then
				begin
					//h[k]=h-abs(x[k]-i)-abs(y[k]-j);
					max:=abs(x[k]-i)+abs(y[k]-j)+h[k];
					break;
				end;
                        if max<1 then continue;
			b:=true;
			for k:=1 to n do
				if h[k]<>g(0,max-abs(x[k]-i)-abs(y[k]-j)) then
				begin
					b:=false;
					break;
				end;
			if b then
			begin
				writeln(i,' ',j,' ',max);
				halt;
			end;
		end;
end.


Measured memory_bytes: 128
def main():
    import sys
    input = sys.stdin.readline
    from collections import defaultdict
    N, P = map(int, input().split())
    S = input().rstrip()
    if P in (2, 5):
        ans = 0
        for i, c in enumerate(S):
            if int(c) % P == 0:
                ans += i + 1
        print(ans)
        sys.exit()
    num = 0
    d = 1
    counter = defaultdict(int)
    counter[0] += 1
    for c in S[::-1]:
        num += int(c) * d
        num %= P
        counter[num] += 1
        d *= 10
        d %= P
    ans = 0
    for v in counter.values():
        ans += (v * (v-1)) // 2
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 4580
N, M = (int(i) for i in input().split())
cos = [0] * M
bit = [0] * M
for i in range(M):
    a, b = (int(j) for j in input().split())
    cos[i] = a
    c = [int(j) for j in input().split()]
    bit[i] = sum([2 ** (j-1) for j in c])

DP = [[float("inf")] * 2**N for counter1 in range(M+1)]
for i in range(M):
    DP[i][0] = 0

for i in range(M):
    a = cos[i]
    bi = bit[i]
    for j in range(2**N):
        DP[i+1][j|bi] = min(DP[i+1][j|bi], DP[i][j] + a)
        DP[i+1][j] = min(DP[i+1][j], DP[i][j])

ans = DP[M][2**N-1]
if ans == float("inf"):
    print(-1)
else:
    print(ans)

Measured memory_bytes: 191508
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#define MOD 1000000007
int n, m, f[1 << 15], g[15][1 << 15], h[15][1 << 15], bin[150];
inline void up(int &x, int y) {
	if ((x += y) >= MOD) x -= MOD;
}
inline int lowbit(int x) { return x & -x; }
int main() {
	scanf("%d%d", &n, &m);
	bin[0] = 1;
	for (int i = 1, u, v; i <= m; i++) {
		scanf("%d%d", &u, &v);
		u--, v--;
		g[u][1 << v] = 1;
		bin[i] = (bin[i - 1] << 1) % MOD;
	}
	for (int i = 0; i < n; i++) {
		for (int d = 1; d < (1 << n); d++) {
			g[i][d] = g[i][d - lowbit(d)] + g[i][lowbit(d)];
		}
	}
	f[0] = 1;
	for (int d = 1; d < (1 << n); d++) {
		for (int x = d; x; x = (x - 1) & d) {
			if ((x & 1) == ((x >> 1) & 1)) {
				int tmp = 1;
				for (int i = 0; i < n; i++) {
					if ((d >> i) & 1) {
						if ((x >> i) & 1) {
							tmp = 1LL * tmp * bin[g[i][d - x]] % MOD;
						} else {
							tmp = 1LL * tmp * (bin[g[i][x]] - 1) % MOD;
						}
					}
				}
				up(f[d], 1LL * tmp * f[d - x] % MOD);
			}
		}
	}
	printf("%d\n", (bin[m] - f[(1 << n) - 1] + MOD) % MOD);
	return 0;
}

Measured memory_bytes: 2176
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
using namespace std;

#define ISEQ(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000000;

typedef struct {
  int to, cost;
} edge;
vector<edge> G[100*101];
int d[100*101];
bool used[100*101];

void dijkstra(int s, int n) {
  for (int i = 0; i < n; i++) {
    d[i] = INF;
    used[i] = false;
  }
  d[s] = 0;
  priority_queue<P, vector<P>, greater<P> > que;
  que.push(P(0, s));
  while (!que.empty()) {
    P p = que.top(); que.pop();
    int v = p.second;
    if (d[v] < p.first) continue;
    used[v] = true;
    for (int i = 0; i < G[v].size(); i++) {
      edge e = G[v][i];
      if (!used[e.to] and d[e.to] > d[v] + e.cost) {
	d[e.to] = d[v] + e.cost;
	que.push(P(d[e.to], e.to));
      }
    }
  }
}

int main() {
  while (true) {
    int n ,m, l;
    scanf("%d%d%d", &n, &m, &l);
    if (n == 0) break;
    
    l++;
    for (int i = 0; i < n*l; i++)
      G[i].clear();
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < l-1; j++)
	G[i+n*j].push_back(edge{i+n*(j+1), 0});
    }

    for (int i = 0; i < m; i++) {
      int a, b, d, e;
      scanf("%d%d%d%d", &a, &b, &d, &e);
      a--; b--;
      for (int j = 0; j < l; j++) {
	G[a+n*j].push_back(edge{b+n*j, e});
	G[b+n*j].push_back(edge{a+n*j, e});
      }
      for (int j = 0; j+d < l; j++) {
	G[a+n*j].push_back(edge{b+n*(j+d), 0});
	G[b+n*j].push_back(edge{a+n*(j+d), 0});
      }
    }
    
    dijkstra(0, n*l);

    printf("%d\n", d[n*l-1]);
  }  
}

Measured memory_bytes: 8108
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define MAX 1000000000000000
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ii>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a);  a = (a * a);  b/=2;  }  return res; }
#define rs resize
long long readLI(){  register char c;  for(c = getchar(); !(c>='0' && c<='9'); c = getchar());  register long long a=c-'0';
    for(c = getchar(); c>='0' && c<='9'; c = getchar())
        a = (a<<3)+(a<<1)+c-'0';
    return a;
}
const ll N = 1009;
ll k,n,ans = MAX;
void go(ll a,ll c)
{
    if(c == n){
        ans = min(ans,a);
        return;
    }
    go(2*a,c + 1);
    go(a + k,c + 1);
}
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>n>>k;
    go(1,0);
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  string s;
  cin >> s;
  ll k=s.size();
  if(k==26){
    if(s=="zyxwvutsrqponmlkjihgfedcba"){
      cout << -1 << endl;
    }
    else{
      ll i=26;
      bool y=true;
      ll j;
      while(y&&i>0){
        if(s[i-1]<s[i]){
          j=i-1;
          y=false;
        }
        i--;
      }
      string t="";
      rep(i,j){
        t+=s[i];
      }
      //cout << t << endl;
      bool z;
      ll cnt=0;
      if(j!=0){
      rep(i,26){
        z=true;
        rep(k,j){
          if(s[k]==abc[i]){
            z=false;
          }
          else if(abc[i]<=s[j]){
            z=false;
          }
        }
        if(cnt==0){
          if(z){
            t+=abc[i];
            cnt++;
          }
        }
      }
      cout << t << endl;
    }
      if(j==0){
        char c=s[0];
        rep(i,25){
          if(c==abc[i]){
            c=abc[i+1];
            break;
          }
        }
        cout << c << endl;
      }
    }
  }
  else{
    char c;
    rep(i,26){
      c=abc[i];
      bool ok=true;
      rep(j,k){
        if(s[j]==c){
          ok=false;
        }
      }
      if(ok){
        break;
      }
    }
    cout << s << c << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;
//const ll MOD=998244353;

int num[5];
 
int main(){
  rep(i,5) num[i]=-1;
  int N,M; cin>>N>>M;
  map<int,int> mp;
  rep(i,M){
    int S,C; cin>>S>>C;
    if(N!=1&&S==1&&C==0){
      cout<<-1<<endl;
      return 0;
    }
    if(num[S]!=-1){
      if(num[S]!=C){
        cout<<-1<<endl;
        return 0;
      }
    }else{
      num[S]=C;
    }
  }
  for(int i=1;i<=N;i++){
    if(num[i]!=-1) cout<<num[i];
    else if(N!=1&&i==1) cout<<1;
    else cout<<0;
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=5e5+5;
typedef pair<double,long long>P;
long long n,L,tot,l=1,r,v[N],t[N];
#define se second
#define fi first
double ans;
P q[N];
int main(){
	scanf("%lld%lld",&n,&L);
	for(int i=1;i<=n;i++)	scanf("%lld%lld",&t[i],&v[i]);
	for(int i=1;i<=n;i++){
		while(l<=r&&tot+v[i]>L){
			long long k=min(tot+v[i]-L,q[l].se);
			ans-=q[l].fi*k,tot-=k,q[l].se-=k;
			if(!q[l].se)	++l;
		}
		q[++r]=P(t[i],v[i]);
		tot+=v[i],ans+=t[i]*v[i];
		while(l<r&&q[r].fi<q[r-1].fi){
			q[r-1].fi=(q[r-1].fi*q[r-1].se+q[r].fi*q[r].se)/(q[r-1].se+q[r].se);
			q[r-1].se+=q[r].se;
			--r;
		}
		printf("%.7lf\n",ans/L);
	}
	return 0;
}


Measured memory_bytes: 24704
package main

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

var sc = bufio.NewScanner(os.Stdin)

const initBufSize, maxBufSize = 10000, 1000000

func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextInts(n int) []int {
	res := make([]int, n)
	for i := range res {
		res[i] = nextInt()
	}
	return res
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func abs(n int) int {
	return int(math.Abs(float64(n)))
}

func pow(r, n int) int {
	return int(math.Pow(float64(r), float64(n)))
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initBufSize), maxBufSize)
	n := nextInt()
	k := nextInt()

	//すぬけ君1～Nがお菓子を持っていたら"1"、持っていなかったら"-1"とする
	sunuke := make(map[int]int)
	for i := 0; i < n; i++ {
		sunuke[i+1] = -1
	}

	var d, snack, count int
	count = n
	for i := 0; i < k; i++ {
		//K番目のお菓子を持っているすぬけ君の人数
		d = nextInt()
		for j := 0; j < d; j++ {
			//お菓子を持っているすぬけ君の番号
			snack = nextInt()
			for k := 0; k < n; k++ {
				if sunuke[snack] == -1 {
					sunuke[snack] *= -1
					count--
				}
			}
		}
	}
	fmt.Println(count)
}


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

int main(){

    int c, n, m; cin >> c >> n >> m;
    vector<int> s(n);
    vector<int> p(n);
    for(int i = 0; i < n; i++) cin >> s[i] >> p[i];
    
    vector<vector<int> > dp(n + 1, vector<int> (c + 1, 0));
    for(int i = 0; i < n; i++){
        for(int j = 0; j <= c; j++){
            //take  
            if(j + s[i] <= c) dp[i + 1][j + s[i]] = max(dp[i + 1][j + s[i]], dp[i][j] + p[i]);
            //no
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
        }
    }

    for(int i = 1; i <= c; i++){
        dp[n][i] = max(dp[n][i], dp[n][i - 1]);
        //ans = max(ans, dp[n][i]);
    }

    for(int i = 1; i <= m; i++){
        cout << dp[n][c / i] * i << endl;
    }

    return 0;
}


Measured memory_bytes: 383232
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
using ull = unsigned long long;
using P = pair<int, int>;


ull E = 1000000007;
ull e = 10007;
const double pi = 3.14159265359;

int main() {
    int N;
    cin >> N;
    vector<int> h;
    int M = 0;
    for (int i = 0; i < N; ++i) {
        int tmp;
        cin >> tmp;
        M = max(M, tmp);
        h.push_back(tmp);
    }

    int ans = 0;
    for (int i = 0; i < M; ++i) {
        for (int j = 0; j < N;) {
            while (h[j] == 0) ++j;
            if (j >= N) break;
            while (h[j] != 0) --h[j++];
            ++ans;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 380
//
//Created by just_sort 2016/10/1 14:00
//Copyright (c) 2016 just_sort.All Rights Reserved
//

#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
char s[12];
int main()
{
    cin>>s;
    for(int i = 0; i < 4; i++) printf("%c",s[i]);
    printf(" ");
    for(int i = 4; i < 12; i++) printf("%c",s[i]);
    printf("\n");
}


Measured memory_bytes: 256
import itertools
n,k=map(int,input().split())
p=list(map(int,input().split()))
l=[]
for i in range(n):
    exp=(p[i]+1)/2
    l.append(exp)
cumsum=[0]+list(itertools.accumulate(l))
ans=0
for i in range(n-k+1):
    sum_num=cumsum[i+k]-cumsum[i]
    if sum_num>ans:
        ans=sum_num
print(ans)

Measured memory_bytes: 34724