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

public class Main{
  public static void main(String[] args){
    Scanner s = new Scanner(System.in);
    int k = s.nextInt();
    int x = s.nextInt();
    int a=x-k+1,b=x+k;
    for(int i=a;i<b;i++)
      System.out.print(i+" ");
  }
}

Measured memory_bytes: 21844
#include<iostream>
#include <string>
#include <iomanip>
#include <vector>
#include <queue>
#include <math.h>
#include <algorithm>
#include <functional>

using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)



signed main()
{
	int n,m;
	cin >> n >> m;
	if(n+m < 10) cout << n+m << endl;
	else cout <<"error" << endl;
}

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

#define long long long

template<class T> inline void MIN(T &a, T b) { if (a > b) a = b; }
template<class T> inline void MAX(T &a, T b) { if (a < b) a = b; }

string s;
char has['Z'];

int main() {

	cin >> s;

	for (char c : s) {
		has[c] = true;
	}

	if (has['N'] == has['S'] and has['W'] == has['E']) printf("Yes\n");
	else printf("No\n");

}

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long



using namespace std;

void file(){
	#ifndef ONLINE_JUDGE
    	freopen("in.txt", "r", stdin);
	#endif
}
int tc;
const int N=1e6+5,M=2e6+5,MOD=1e9+7,OO=1e9;


int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//file();

	int n;

	scanf("%d",&n);
	int cnt = 0;
	std::vector<int> v = {400,800,1200,1600,2000,2400,2800,3200};
	set<int>s;
	for(int i=0;i<n;i++){
		int x;
		scanf("%d",&x);
		auto it = upper_bound(all(v),x);
		if(it==v.end())cnt++;
		else	s.insert(*it);
	}

	printf("%d %d\n",max(sz(s),1),sz(s)+cnt);
}


Measured memory_bytes: 256
num = gets.split.map!{|item| item.to_i}

if (num[2] - num[4]) >= 0	 && (num[2] + num[4]) <= num[0] && (num[3] - num[4]) >= 0 && (num[3] + num[4]) <= num[1]	then
		print "Yes\n"

else
	print "No\n"
end

Measured memory_bytes: 6104
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <deque>
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
void print(vec v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(vecll v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(map<int,int> mp){for(auto e:mp)cout<<e.first<<" "<<e.second<<endl;cout<<endl;}


#define INF 1e9+7
#define LLINF 1e18+7
const ll MOD=1e9+7;
const int N=500000;

main(){
    string s;
    cin>>s;
    s.erase(unique(all(s)),s.end());
    cout<<s.size()-1;
}

Measured memory_bytes: 512
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
//#define int long long
template<typename T> inline bool chmax(T& a,T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> inline bool chmin(T& a,T b) { if (a > b) { a = b; return true; } return false; }

int main() {
    string S;
    cin >> S;
    for (auto c : S) {
        if (c == ',') cout << " ";
        else cout << c;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>

using namespace std;
typedef long long int ll;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;

    string s;
    cin >> s;
    int red_count = 0;
    int blue_count = 0;
    for(int i=0; i<s.length(); i++){
        if(s[i] == 'R'){
            red_count++;
        }else{
            blue_count++;
        }
    }

    if(red_count > blue_count){
        cout << "Yes" << '\n';
    }else{
        cout << "No" << '\n';
    }


    return 0;
}

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

using namespace std;

typedef long long int ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> pli;
typedef std::pair<ll, ll> pll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int H[1005];

int main()
{
	int N, T, A;
	cin >> N >> T >> A;
	REP(i, N)
	{
		cin >> H[i];
	}

	int j = 0;
	double m = T - H[0] * 0.006;
	REP(i, N)
	{
		double t = T - H[i] * 0.006;
		if (fabs(t-A) < fabs(m-A))
		{
			m = t;
			j = i;
		}
	}
	cout << j + 1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

struct topological_sort{
    vector<vector<int>> G;
    vector<int> indegree;
    vector<int> degree;
    int V;

    topological_sort(int V) : V(V) {
        G.resize(V); 
        indegree.resize(V);
        degree.resize(V);
    }
    void add_edge(int a, int b) {
        G[a].push_back(b);
        indegree[b]++;
    }
    vector<int> sort() {
        queue<int> q;
        vector<int> sorted;
        int deg = 1;
        for (int i = 0; i < V; i++) {
            if (indegree[i] == 0) {
                q.push(i);
                degree[i] = deg;
            }
        }
        while (!q.empty()) {
            queue<int> q_tmp;
            deg++;
            while (!q.empty()) {
                int v = q.front(); q.pop();
                for (int i = 0; i < G[v].size(); i++) {
                    int u = G[v][i];
                    indegree[u]--;
                    if (indegree[u] == 0) {
                        q_tmp.push(u);
                        degree[u] = deg;
                    }
                }
                sorted.push_back(v);
            }
            swap(q,q_tmp);
        }
        return sorted;
    }
};

P change(P x) {
    if (x.first > x.second) swap(x.first,x.second);
    return x;
}

int to_id(P x, vvint &to) {
    return to[x.first][x.second];
}

int main() {
    int n; cin >> n;
    topological_sort ts(n*(n-1)/2);
    vvint to(n,vint(n));
    vector<P> from(n*(n-1)/2);
    int num = 0;
    rep(i,n)rep(j,i) {
        to[j][i] = num;
        from[num] = P(j,i);
        num++;
    }
    vvint data(n,vint(n-1));
    rep(i,n)rep(j,n-1) {
        int x; cin >> x;
        x--;
        data[i][j] = x;
    }
    vvint back(n*(n-1)/2);
    rep(i,n)rep(j,n-2) {
        P p1 = P(i,data[i][j]);
        P p2 = P(i,data[i][j+1]);
        p1 = change(p1);
        p2 = change(p2);
        ts.add_edge(to_id(p1,to),to_id(p2,to));
        back[to_id(p2,to)].push_back(to_id(p1,to));
    }
    vint res = ts.sort();
    if (res.size() != n*(n-1)/2) {cout << -1 << endl; return 0;}
    cout << ts.degree[res.back()] << endl;
}


Measured memory_bytes: 75680
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int K[4];
    rep(i, 4) cin >> K[i];
    sort(K, K + 4);
    int C[4] = {1, 4, 7, 9};
    rep(i, 4) {
        if (C[i] != K[i]) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;

    return 0;
}


Measured memory_bytes: 256
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#if defined(DAIJOBU)
#include "/home/ichigo/includes.hpp"
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long lint;
typedef vector<lint> vlint;
typedef vector<vlint> vvlint;
typedef pair<lint, lint> plint;
typedef double ld;

template<class T> bool chmin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool chmax(T &a, T b) { return a < b ? (a = b, true) : false; }



int main() {
    ios::sync_with_stdio(false);
	cin.tie(0);
	
	string s;
	cin >> s;
	int ans = 0;
	forn(i, s.size()){
		if(s[i] == '+')ans++;
		else ans--;
	}
	cout << ans << '\n';
	return 0;
}



Measured memory_bytes: 256
N, K = map(int, input().split())
MOD = 10**9 + 7
ans = 0
for k in range(K, N+2):
    l = (k*(2*N-k+1)//2)%MOD
    a = (k*(k-1)//2)%MOD
    ans += (l-a+1)%MOD
print(ans%MOD)

Measured memory_bytes: 9192
#include<bits/stdc++.h>
#define lint long long
#define st first
#define nd second
#define INF 0x3f3f3f3f

using namespace std;


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	string n; cin>>n;
	
	int x = int(n.back() - '0');
	if(x == 3)
		cout<<"bon\n";
	else if(x == 2 || x== 4 || x==5 ||x==7 || x==9)
		cout<<"hon\n";
	else cout<<"pon\n"; 	

	return 0;	
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define MAX 100007
    
#define REP(i, N) for(int (i)=1; (i) <= (N); (i)++)
#define PER(i, N) for(int (i)=(N)-1; (i) >= 0; (i)--)
    
using namespace std;
typedef long long ll;
typedef pair<ll, int> pii;

int main(){
    
    int k; cin >> k;

    int ans = 0;
    REP(i, k){
        REP(j, k){
            REP(x, k) ans += __gcd(i, __gcd(j, x));
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
int main() {
	int m, k;
	scanf("%d%d", &m, &k);

	if (m == 1) {
		if (k == 0) puts("0 0 1 1");
		else puts("-1");
		return 0;
	}

	int max = (1<<m)-1;
	if (max < k) {
		puts("-1");
		return 0;
	}

	printf("%d ", k);
	for (int i = 0 ; i <= max; i++) {
		if (i == k) continue;
		printf("%d ", i);
	}
	printf("%d ", k);
	for (int i = max; i >= 0; i--) {
		if (i == k) continue;
		printf("%d ", i);
	}
	printf("\n");
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <math.h>
#include <cmath>
using namespace std;
int main(){
    int n;
	double x[100] = {0},y[100] = {0},p_1 = 0,p_2 = 0,p_3 = 0,p_infinity = -1;
	scanf("%d",&n);
	for(int i = 0; i < n; i++) scanf("%lf",&x[i]);
	for(int i = 0; i < n; i++) scanf("%lf",&y[i]);
	for(int i = 0; i < n; i++){
		p_1 += abs(x[i] - y[i]);
		p_2 += (x[i] - y[i])*(x[i] - y[i]);
		p_3 += abs((x[i] - y[i])*(x[i] - y[i])*(x[i] - y[i]));
		p_infinity = (p_infinity >= abs(x[i] - y[i]))? p_infinity:abs(x[i] - y[i]);
 	}
	printf("%.6lf\n",p_1);
	printf("%.6lf\n",sqrt(p_2));
	printf("%.6f\n",cbrt(p_3));
	printf("%.6lf\n",p_infinity);

}


Measured memory_bytes: 2936
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;
const ll mod = (ll)1e9+7;
const int INF = 0x3f3f3f3f;

int a[100001];

int mpow(int b, int e)
{
    int ret=1;
    for(int i=0; i<e; i++)
    {
        ret=ret*b%mod;
    }
    return ret;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, in;
    cin >> n;
    int t=n%2;
    for(int i=0; i<n; i++)
    {
        cin >> in;
        if(a[in]==2||in%2==t||in>n)
        {
            cout << 0;
            return 0;
        }
        a[in]++;
    }
    if(t&&a[0]!=1)
    {
        cout << 0;
        return 0;
    }
    cout << mpow(2, n/2);
}

//TODO: 50


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

using namespace std;

int main(){
	int a,x, result,inst;
	string b;
	
	cin >> a >> b;
	result = 0;
	inst=0;
	x= 0;
	
	for(int i=0; i<a; i++){
		
		if (b.at(i) == 'W') x-- ;
		else x++;
		
		
		if(result <= x) {
			result = x;
			inst = i;
		}
	}
	
	result = 0;
	
	for(int i=inst-1; i>=0; i--){
		if(b.at(i) == 'W') result++;
	}
	for(int i=inst+1; i<a; i++){
		if(b.at(i) == 'E') result++;
	}
	
	cout << result << endl;
}


Measured memory_bytes: 900
#include<stdio.h>

int main(){

	int N,a[100];
	int i,j,b,min,temp,count=0;

	scanf("%d",&N);

	for(i=0;i<N;i++){
		scanf("%d",&a[i]);
	}

	for(i=0;i<N-1;i++){
		min = i;
		b=0;
		for(j=i;j<N;j++){
			if(a[j] < a[min]) {
				min = j;
				b=1;
			}
		}
		if(b == 1){
			temp = a[i];
			a[i] = a[min];
			a[min] = temp;
			count++;
		}
	}

	for(i=0;i<N;i++){
		printf("%d",a[i]);
		if(i==N-1)printf("\n");
		else printf(" ");
	}
	printf("%d\n",count);

	return 0;
}

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

const int N   = 3e5+7;
const int MOD = 1e9+7;
const int INF = (~(1<<31));

int fre(){
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
}

inline int read(){
	int x=0,f=1;char ch=getchar();
	for(;ch<'0'||'9'<ch;ch=getchar())if(ch=='-') f=-1;
	for(;'0'<=ch&&ch<='9';ch=getchar())x=(x<<3)+(x<<1)+ch-'0';
	return x*f;
}

#define lal puts("****");
#define pb  push_back
#define mp  make_pair
#define x   first
#define y   second

/*****************************************************************/

char s[11];

int main(){
    scanf("%s",s);
    if(s[0]==s[2]) puts("Yes");
    else           puts("No");
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
typedef long long ll;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> a(N);
    rep(i, N) cin >> a[i];
    vector<bool> dp(K + 10, false);
    // dp[i]:=先手の操作前にのこりi個のとき、Firstが勝つかどうか
    dp[0] = false;
    for(int i = 0; i <= K; i++) {
        if(dp[i] == false) {
            for(int x : a) {
                if(i + x <= K) {
                    dp[i + x] = true;
                }
            }
        }
    }
    if(dp[K]) {
        cout << "First" << endl;
    } else {
        cout << "Second" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<stack>

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(n) n.begin(),n.end()
#define SIZE 2048

struct P{
  int x,y;
  P(int x1, int y1){
    x=x1,y=y1;
  }
};

int compress(vector<int> &x1, vector<int> &x2, int W){
  vector<int> xs;
  unsigned int size = x1.size();

  for(int i=0; i<size; i++){
    for(int d=-1; d<=1; d++){
      int tx1 = x1[i] + d, tx2 = x2[i] + d;
      if(0<=tx1 && tx1 <=W) xs.push_back(tx1);
      if(0<=tx2 && tx2 <=W) xs.push_back(tx2);
    }
  }

  sort(all(xs));
  xs.erase(unique(all(xs)), xs.end());
  int end = 0;

  for(int i=0; i<size; i++){
    x1[i] = find(all(xs), x1[i]) - xs.begin();
    x2[i] = find(all(xs), x2[i]) - xs.begin();
    if(end<x2[i])
      end = x2[i];
  }

  return xs.size()-1;
}

void dfs(bool Map[SIZE][SIZE], P start, int W, int H){
  static const int dx[] = {0, 0, -1, 1}, dy[] = {1, -1, 0, 0};
  stack<P> st;
  st.push(start);
  while(st.size()){
    P s = st.top();
    st.pop();
    rep(i, 4){
      P t = P(s.x+dx[i], s.y+dy[i]);
      if(t.y>=0 && t.x>=0 && t.y<H && t.x<W && Map[t.y][t.x]==false){
	Map[t.y][t.x]=true;
	st.push(t);
      }
    }
  }
}

bool board[SIZE][SIZE];

int main(){
  int W,H,N;

  while(cin>>W>>H, W|H){
    cin>>N;
    
    vector<int> x1, x2, y1, y2;
    rep(i,N){
      int a, b, c, d;
      cin>>a>>b>>c>>d;
      x1.push_back(a);
      y1.push_back(b);
      x2.push_back(c);
      y2.push_back(d);
    }

    W = compress(x1, x2, W);
    H = compress(y1, y2, H);

    rep(i, H) rep(j, W) board[i][j]=false;

    rep(i, N){
      for(int x=x1[i]; x<x2[i]; x++){
	for(int y=y1[i]; y<y2[i]; y++){
	  board[y][x] = true;
	}
      }
    }

    /*
    rep(y, H){
      rep(x, W){
	if(board[y][x]==false)
	  cout << ".";
	else
	  cout << "@";
      }
      cout << endl;
    }
    */

    int count = 0;
    rep(y, H){
      rep(x, W){
	if(board[y][x]==false){
	  count++;
	  dfs(board, P(x, y), W, H);
	}
      }
    }

    cout << count << endl;

  }
  return 0;
}

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

main(){
  ll ans=0,n,i,j,sl;
  string s;
  cin >> s;
  sl=s.length();
  n=s.length()+1;
  vector<ll> a(n);
  for(i=0;i<n;i++) a[i]=-1;
  
  for(i=0;i<n;i++){
    if(s[i]=='>' && s[i+1]=='<') a[i+1]=0;
  }
  if(s[0]=='<') a[0]=0;
  if(s[s.length()-1]=='>') a[n-1]=0;
  
  for(i=0;i<n-1;i++){
    if(a[i]==0){
      while(s[i]=='<'){
        a[i+1]=a[i]+1;
        i++;
      }
    }
  }
  for(i=n-1;0<i;i--){
    if(a[i]==0){
      while(s[i-1]=='>'){
        if(a[i-1]<a[i]+1) a[i-1]=a[i]+1;
        i--;
      }
    }
  }
  
  
  for(i=0;i<n;i++) ans+=a[i];
  //for(i=0;i<n;i++) cout << a[i];
  cout << ans << endl;
}
  

Measured memory_bytes: 4740
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;cin>>N;
  vector<int>V(N+1);
  for(int X=1;X<=N;X++){
    cin>>V[X];
  }
  int I=0;
  for(int X=1;X<=N;X++){
    if(V[X]>V[X-1]){
      I+=V[X]-V[X-1];
    }
  }
  cout<<I<<endl;
}


Measured memory_bytes: 3620
#include <stdio.h>

int main() {
  int a, b, c = 1;
  scanf("%d", &a);
  scanf("%d", &b);
  if (a == 1) c = (b == 2) ? 3: 2;
  if (a == 2) c = (b == 1) ? 3: 1;
  if (a == 3) c = (b == 1) ? 2: 1;
  printf ("%d\n", c);
}


Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main()
{string s;
cin>>s;
bool t=true;
long int l=s.length();
long int m=((l-1)/2);
long int h=((l+3)/2);
char x[1000];
for(int i=0;i<m;i++)
    x[i]=s[i];
for(int i=m,j=m+1;i<l,j<l;i++,j++){
    x[i]=s[j];
}
for(int i=0,j=h-2;i<m,j<l-1;i++,j++)
    {
    if(x[i]!=x[j])
     {t=false;
     break;}}
     if(t==false)
        cout<<"No";
     else
        cout<<"Yes";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
long long maximum;
long long mod = 1000000007;
const int INF = 1001001001;
vector<vector<int>> dp;

int main(){
  ll m;
  cin >> m;
  ll number = 0;
  ll digit = 0;
  ll d,c;
  for(ll i=0;i<m;i++){
    cin>>d;
    cin>>c;
    number += (d * c);
    digit += c;   
  }
  cout << digit -1+ abs(number-1)/9 << endl;
}


Measured memory_bytes: 256
fun main(args:Array<String>?): Unit {
    val t = readLine()!!.trim().toInt()
    val dices = Array(t){
        val (_, m) = readLine()!!.trim().split(' ').map(String::toInt)
        List(m){
            val (v, r) = readLine()!!.trim().split( ' ').map(String::toDouble)
            Pair(v, r)
        }.let{it.sumByDouble { (v, r) -> v * r } / it.sumByDouble { (_, r) -> r }}
    }
    val (_, q) = readLine()!!.trim().split(' ').map(String::toInt)
    val estimated = List(q){
        val (v, r) = readLine()!!.trim().split(' ').map(String::toDouble)
        Pair(v, r)
    }.let{it.sumByDouble { (v, r) -> v * r } / it.sumByDouble { (_, r) -> r }}
    println(
            if (dices.any{it > estimated + 0.0000001}) "YES" else "NO"
    )
}


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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    string S;
    cin >> S;
    vector<string> match = {"dream", "dreamer", "erase", "eraser"};
    bool flag = true;
    ll tail = S.size() - 1;
    while (flag)
    {
        bool isMatch = false;
        REPV(iter, match)
        {
            ll len = (*iter).size();
            if (tail - len + 1 >= 0)
            {
                if (S.substr(tail - len + 1, len) == *iter)
                {
                    isMatch = true;
                    tail -= len;
                    break;
                }
            }
        }
        if (!isMatch)
        {
            flag = false;
        }
        else
        {
            if (tail == -1) break;
        }
        
    }
    string ans;
    if (flag) ans = "YES";
    else ans = "NO";

    cout << ans << endl;
}


Measured memory_bytes: 512
import itertools

N, M = map(int, input().split())
AB, ans = [tuple(map(int, input().split())) for _ in range(M)], 0

for p in itertools.permutations(range(1, N + 1)):
    if p[0] == 1:
        ans += 1
        for i in range(N - 1):
            if not (min(p[i], p[i + 1]), max(p[i], p[i + 1])) in AB:
                ans -= 1
                break

print(ans)


Measured memory_bytes: 3188
#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <string.h>
#include <string>
#include <cmath>
#include <cstdio>
#include <functional>
#include <map>
#include <typeinfo>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<double, double> pd;
typedef pair<ll, ll> pl;

int attack[100001];

int main()
{
  int h, n;
  scanf("%d %d", &h, &n);
  
  int sum = 0;
  for(int i = 0; i < n; i++)
  {
    scanf("%d", &attack[i]);
    sum += attack[i];
  }
  
  if(h <= sum)
    printf("Yes\n");
  else
    printf("No\n");
  
  
  
  return 0;
}


Measured memory_bytes: 640
// AOJ 0302 (http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0302)
#include<cstdio>
#include<algorithm>
#include<vector>
#include<limits>
#define rep(i,a) for(int i=0;i<(a);++i)
#define all(a) (a).begin(), (a).end()

typedef long long ll;
typedef std::pair<ll, ll> Pt;

struct Dat
{ 
	ll x, y, b;

	Dat( ll x, ll y, ll b )
	:	x(x), y(y), b(b)
	{}

	bool operator< ( const Dat &rhs ) const
	{ return b < rhs.b; }
};

Pt minPt( const Pt &lhs, const Pt &rhs )
{ return Pt( std::min( lhs.first, rhs.first ), std::min( lhs.second, rhs.second ) ); }

Pt maxPt( const Pt &lhs, const Pt &rhs )
{ return Pt( std::max( lhs.first, rhs.first ), std::max( lhs.second, rhs.second ) ); }

struct Pts
{ 
	Pt lb, rt;

	Pts()
	{}

	Pts( const Pt &lb, const Pt &rt )
	:	lb(lb), rt(rt)
	{}

	bool operator< ( const Pts &rhs ) const
	{ return std::make_pair( lb, rt ) < std::make_pair( rhs.lb, rhs.rt ); }

	ll area() const
	{ return (rt.first-lb.first)*(rt.second-lb.second); }
};

const int MAX_N = 200000;
const ll INF = std::numeric_limits<ll>::max()>>2;

int N, d;
std::vector<Dat> vs;

struct SegTree
{
	std::size_t sz;
	std::vector<Pts> seg;

	SegTree( std::size_t n )
	{
		sz = 1;
		while( sz < n )
			sz <<= 1;

		seg.resize( 2*sz-1 );
		rep( i, seg.size() )
		{
			seg[i].lb = Pt( INF, INF );
			seg[i].rt = Pt( 0, 0 );
		}
	}

	void update( int k, const Dat &x )
	{
		k += sz-1;
		seg[k].lb = minPt( seg[k].lb, Pt( x.x, x.y ) );
		seg[k].rt = maxPt( seg[k].rt, Pt( x.x, x.y ) );

		while( k )
		{
			k = k-1>>1;
			seg[k] = Pts( minPt( seg[2*k+1].lb, seg[2*k+2].lb ), maxPt( seg[2*k+1].rt, seg[2*k+2].rt ) );
		}

		return;
	}

	Pts query( int a, int b, int k, int l, int r )
	{
		if( b <= l || r <= a )
			return Pts( Pt( INF, INF ), Pt( 0, 0 ) );
		else if( a <= l && r <= b )
			return seg[k];
		
		Pts pl = query( a, b, 2*k+1, l, l+r>>1 ),
		    pr = query( a, b, 2*k+2, l+r>>1, r );

		return Pts( minPt( pl.lb, pr.lb ), maxPt( pl.rt, pr.rt ) );
	}
};

int main()
{
	scanf( "%d%d", &N, &d );
	rep( i, N )
	{
		ll x, y, b;
		scanf( "%lld%lld%lld", &x, &y, &b );
		vs.push_back( Dat( x, y, b ) );
	}

	std::sort( all(vs) );

	SegTree st( N );
	
	rep( i, N )
		st.update( i, vs[i] );

	int s = 0, t = 0;
	ll ans = 0;

	for( s = 0; s < N; ++s )
	{
		while( t < N && vs[t].b-vs[s].b <= d )
			++t;
		if( t == N-1 )
			++t;

		ans = std::max( ans, st.query( s, t, 0, 0, st.sz ).area() );
	}

	printf( "%lld\n", ans );

	return 0;
}

Measured memory_bytes: 23584
#include<iostream>
#include<string>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a, p;
  for (int i = 1; i <= n; i++) {
   	int ai;
    cin >> ai;
    a.push_back(ai);
    if (i > n/2)
      p.push_back(ai);
    else
      p.push_back(0);
  }

  for (int i = n/2; i >= 1; i--) {
  	int pi = 0;
    for (int j = i*2; j <= n; j += i) {
      pi += p[j-1];
    }
    pi %= 2;
    p[i-1] = a[i-1]^pi;
  }
  
  int z = 0;
  for (int i = n; i >= 1; i--) {
    if (p[i-1] == 0) {
      z++;
    }
  }
  
  cout << n - z << endl;
  for (int i = 1; i <= n; i++) {
    if (p[i-1] == 1) {
      cout << i << " ";
    }
  }
  cout << endl;
  
  return 0;
}


Measured memory_bytes: 2668
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
    WRITER:kakitamasziru/OxOmisosiru
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
//#include <unordered_map> // unordered_map
//#include <unordered_set> // unordered_set
#include <bitset> // bitset
//#include <cctype> // isupper, islower, isdigit, toupper, tolower
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

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; }
const long long INF = 100100100100100;
const int MOD = 1000000007;
typedef pair<int,int> P;
//NのM乗を求める(繰り返し二乗法)
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}
long long nCr(long long n, long long r) {
    long long A = 1, B = 1;
    //Aが分子Bが1/r!
    for (long long i = n - r + 1; i <= n; i++) {
        A = A * i % MOD;
    }
    for (long long i = 1; i <= r; i++) {
        B = B * i % MOD;
    }
    B = mod_pow(B, MOD - 2);
    B %= MOD;
    //Bは割るのではなく掛ける
    return (A * B) % MOD;
}

int main() {
    int N,M;cin >> N >> M;
    long long ans = 0;
    priority_queue<long long>Q;
    for(int i = 0;i<N;i++){
        int A;cin >> A;
        Q.push(A);
    }

    for(int i = 0;i<M;i++){
        long long X = Q.top();
        Q.pop();
        Q.push(X/2);
    }

    while(!Q.empty()){
        ans += Q.top();
        Q.pop();
    }

    cout << ans << endl;
    
    // PLEASE GIVE ME THE "ACCEPTED" !
}

Measured memory_bytes: 1400
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
    int n;
    cin >> n;
    int probs[n];
    for(int i=0;i<n; i++){
        cin >> probs[i];
    }
        
    
    sort(probs, probs+sizeof(probs)/sizeof(probs[0]));
    cout << probs[n/2] - probs[n/2-1] << endl;
}

Measured memory_bytes: 640
from collections import deque

MOD = 10**9 + 7


def main():
    N = int(input())
    adj = [set() for _ in range(N)]
    for _ in range(N-1):
        x, y = map(int, input().split())
        adj[x-1].add(y-1)
        adj[y-1].add(x-1)
    memo = [[0] * 2 for _ in range(N)]
    q = deque([(0, -1)])
    while len(q):
        cur, prev = q.pop()
        adjs = set([x for x in adj[cur] if x != prev])
        if len(adjs) == 0:
            memo[cur][0] = 1
            memo[cur][1] = 1
            continue
        rec = []
        black = 1
        white = 1
        for a in adjs:
            if memo[a][0] != 0:
                black = (black * memo[a][0]) % MOD
                white = (white * (memo[a][0] + memo[a][1])) % MOD
            else:
                rec += [(a, cur)]
        if len(rec):
            q.append((cur, prev))
            for r in rec:
                q.append(r)
        else:
            memo[cur][0] = white
            memo[cur][1] = black
    print(sum(memo[0]) % MOD)


if __name__ == "__main__":
    main()


Measured memory_bytes: 108060
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <math.h>
#include <deque>
#include <queue>
#include <map>
#include <iterator>
#include <set>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e) { std::cout << e << std::endl; }
template<typename T> void view(const std::vector<T>& v) { for (const auto& e : v) { std::cout << e << " "; } std::cout << std::endl; }
template<typename T> void view(const std::vector<std::vector<T> >& vv) { for (const auto& v : vv) { view(v); } }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

const int INF = 1e9;

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

	int n, k;
	cin >> n >> k;
	vector<int> h(n+1);
	for (int i = 1; i <= n; i++) {
		cin >> h[i];
	}
	vector<int> dp(n + 1, INF);
	dp[1] = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= k; j++) {
			if (i - j < 1) continue;
			dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
		} 
	}
	cout << dp[n] << endl;
}

Measured memory_bytes: 1024
#include"bits/stdc++.h"
using namespace std;
#define MAX 3002

int n;
int m;
long long int X;

struct st {
	int a;
	int b;
	long long int c;
};
vector<st> v;
bool cmp(st a, st b) {
	return a.c < b.c;
}
int belong[MAX];
inline int root(int b) {
	if (belong[b] == -1)return b;
	return belong[b] = root(belong[b]);
}
void merge(int a, int b) {
	a = root(a);
	b = root(b);
	if (a == b)return;
	belong[a] = b;
}

vector<pair<int, long long int> > g[MAX];

bool flag[MAX];

inline long long int dfs(int cur, int pr, int goal) {
	if (cur == goal)return 0;
	long long int z = LLONG_MIN;
	for (auto go : g[cur]) {
		if (go.first == pr)continue;
		long long int tmp = dfs(go.first, cur, goal);
		if (tmp >= 0) {
			tmp = max(tmp, go.second);
		}
		z = max(z, tmp);
	}
	return z;
}

map<long long int, int> mp;
long long int p2[MAX];

#define MOD 1000000007



int main() {
	p2[0] = 1;
	for (int i = 1; i < MAX; i++) {
		p2[i] = p2[i - 1];
		p2[i] *= 2LL;
		p2[i] %= MOD;
	}
	cin >> n >> m;
	scanf("%lld", &X);
	for (int i = 0; i < m; i++) {
		int a, b, c;
		scanf("%d%d%d", &a, &b, &c);
		a--;
		b--;
		v.push_back({ a,b,c });
	}
	sort(v.begin(), v.end(), cmp);
	memset(belong, -1, sizeof(belong));
	long long int sum = 0;
	for (int i = 0; i < v.size(); i++) {
		int a = v[i].a;
		int b = v[i].b;
		if (root(a) != root(b)) {
			merge(a, b);
			sum += v[i].c;
			g[a].push_back(make_pair(b, v[i].c));
			g[b].push_back(make_pair(a, v[i].c));
			flag[i] = true;
		}
	}
	int ng = 0;
	int valid = 0;
	for (int i = 0; i < v.size(); i++) {
		if (flag[i] == false) {
			long long int dim=dfs(v[i].a, -1, v[i].b);
			long long int U = -dim + sum + v[i].c;
			if (U < X) {
				ng++;
			}
			if (U == X) {
				valid++;
			}
		}
		else {

		}
	}
	long long int ans = 0;
	if (sum == X) {
		ans+= (p2[n - 1] - 2)*p2[m - (n - 1)];
	}
	if (valid) {
		long long int ava = p2[m - (n - 1) - ng - valid];
		long long int ava2 = (p2[valid] - 1);
		ava *= ava2;
		ava %= MOD;
		ava *= 2LL;
		ava %= MOD;
		ans += ava;
	}
	ans %= MOD;
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  string str;
  cin >> str;

  str.at(5) = ' ';
  str.at(13) = ' ';

  cout << str << endl;
}


Measured memory_bytes: 3608
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define INSERT '0'
#define MOVE '1'
#define ERASE '2'
#define END 1000000001

typedef struct Cell {
	int data;
	struct Cell* prev;
	struct Cell* next;
} Cell;

Cell* newCell(int data) {
    Cell* cell = malloc(sizeof(Cell));
    cell->data = data;
    cell->prev = NULL;
    cell->next = NULL;
    return cell;
}

void print(Cell *cell) {
    // 先頭まで移動する
	while (cell->prev != NULL) {
		cell = cell->prev;
	}

	do {
	    if (cell->data != END) {
			printf("%d\n", cell->data);
			cell = cell->next;
		}
	} while (cell->next != NULL);
}

int isEnd(Cell *cursor) {
	return (cursor != NULL && cursor->data == END);
}

int isFront(Cell *cursor) {
	return (cursor != NULL && cursor->prev == NULL);
}

Cell* insert(Cell *cursor, int data) {
	if (isFront(cursor)) {
		Cell *new = newCell(data);
		new->next = cursor;
		cursor->prev = new;
		return new;
	}

	Cell *new = newCell(data);
	Cell *prev = cursor->prev;
	new->prev = prev;
	new->next = cursor;
	prev->next = new;
	cursor->prev = new;
	return new;
}

Cell* move(Cell *cursor, int d) {
	if (d == 0) {
		return cursor;
	}

	if (d < 0) {
		for (;d < 0; d++) {
			if (isFront(cursor)) {
				printf("Cursor is already front.\n");
				exit(1);
			}

			cursor = cursor->prev;
		}
		return cursor;
	}

	for (;d > 0; d--) {
		if (cursor->next == NULL) {
			printf("Cursor has no next.\n");
			exit(2);
		}

		cursor = cursor->next;
	}
	
	return cursor;
}

Cell* erase(Cell *cursor) {
	if (isEnd(cursor)) {
		return cursor;
	}
	
	if (isFront(cursor)) {
	    Cell *next = cursor->next;
	    next->prev = NULL;
	    free(cursor);
	    return next;
	}

	Cell *prev = cursor->prev;
	Cell *next = cursor->next;
	prev->next = next;
	next->prev = prev;
	free(cursor);
	return next;
}


void answer() {
	Cell *cursor;
	int q = 0;
	char a[15];

	fgets(a, 15, stdin);
	q = atoi(a);
	cursor = newCell(END);

	while (q--) {
	    fgets(a, 15, stdin);
		if (a[0] == INSERT) {
            cursor = insert(cursor, atoi(a+2));
		} else if (a[0] == MOVE) {
		    cursor = move(cursor, atoi(a+2));
		} else if (a[0] == ERASE) {
		    cursor = erase(cursor);
		}

	}

	print(cursor);
}

int test() {
	Cell *cur = newCell(END);
	cur = insert(cur, 1);
	cur = insert(cur, 2);
	cur = insert(cur, 3);
	cur = move(cur, 1);
	cur = erase(cur);
	print(cur);
	return 0;
}

int main(void){
	answer();
}




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



int main()
{
    string str;
    cin >> str;
    for(int i = 1; i < 3; i++)
        if(str[i] != str[i-1])
        {
            cout << "Yes";
            return 0;
        }
    cout << "No";
}


Measured memory_bytes: 384
// UNNECESSARY
// #include <chrono>//std::chrono::/system_clock/steady_clock/high_resolution_clock/duration
// #include <cstdio>//printf/scanf/fopen/fclose/fprintf/fscanf/snprintf/putc/puts/getc/gets
// #include <fstream>//ifstream/ofstream

// DATA STRUCTURES
#include <array>
#include <bitset>
#include <list>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <valarray>
#include <vector>

// MISCELLANEOUS
#include <algorithm>//min/max/sort(rand-access it)/merge
#include <cassert>
#include <climits>//INT_MAX/INT_MIN/ULLONG_MAX
#include <cmath>//fmin/fmax/fabs/sin(h)/cos(h)/tan(h)/exp/log/pow/sqrt/cbrt/ceil/floor/round/trunc
#include <cstdlib>//abs/atof/atoi/atol/atoll/strtod/strtof/..., srand/rand, calloc/malloc, exit, qsort
#include <iomanip>//setfill/setw/setprecision/fixed/scientific
#include <iostream>//cin/cout/wcin/wcout/left/right/internal/dec/hex/oct/fixed/scientific
#include <iterator>
#include <limits>//numeric_limits<type>::max/min/lowest/epsilon/infinity/quiet_NaN/signaling_NaN
#include <new>
#include <string>//stoi/stol/stoul/stoll/stoull/stof/stod/stold/to_string/getline
#include <utility>//pair

#ifndef REP
#define REP(i,n) for (int i = 0; i < n; ++i)
#endif

#ifndef REPST
#define REPST(i,n) for (size_t i = 0; i < n; ++i)
#endif

#ifndef READ
#define READ(x) std::cin >> x
#endif

typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> plli;
typedef std::pair<ull, int> puli;
typedef std::pair<double, int> pdi;
typedef std::pair<ll, ll> pllll;
typedef std::pair<ull, ull> pulul;
typedef std::pair<double, double> pdd;
typedef std::tuple<int, int, int> ti3;
typedef std::tuple<int, int, int, int> ti4;

const bool debug = true;

// --------------------------------------------------------------------------------------

using namespace std;

int main(void)
{
    int n;
    cin >> n;

    int count = 0;

    REP(i,n) {
        int a;
        cin >> a;
        while (a % 2 == 0) {
            ++count;
            a /= 2;
        }
    }

    cout << to_string(count) << endl;
    return 0;
}


Measured memory_bytes: 256
// AOJ 0365 Swapping Characters
// 2018.4.19 bal4u

#include <stdio.h>
#include <stdlib.h>

// BIT library
int bit[200005]; int n;

int sum(int i)
{
	int s = 0;
	while (i) {
		s += bit[i];
		i -= i & -i;
	}
	return s;
}

void add(int i)
{
	while (i <= n) {
		bit[i]++;
		i += i & -i;
	}
}

void sub(int i)
{
	while (i <= n) {
		bit[i]--;
		i += i & -i;
	}
}

char s[200005];
int  c['z'+1];

void calc(int ch)
{
	while (c[ch] < n && s[c[ch]] != ch) c[ch]++;
}

int main()
{
	int k, i, j, f;
	char b[15], *p;

	fgets(p=s, sizeof(s), stdin);
	while (*p > ' ') p++; n = p-s;
	fgets(b, 15, stdin), k = atoi(b);

	for (i = 1; i <= n; i++) add(i);
	for (i = 'a'; i <= 'z'; i++) calc(i);
	for (i = 0; i < n; i++) for(j = 'a'; j <= 'z'; j++) {
		if (c[j] == n) continue;
		if ((f = sum(c[j])) <= k) {
			k -= f;
			sub(c[j]+1);
			putchar(j);
			c[j]++;
			calc(j);
			break;
		}
	}
	putchar('\n');
	return 0;
}


Measured memory_bytes: 2576
#include<stdio.h>
#include<string.h>

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char ch){
  if( ch == 'A' ) return 1;
  else if( ch == 'C' ) return 2;
  else if( ch == 'G' ) return 3;
  else if( ch == 'T' ) return 4;
  else return 0;
}

long long getKey(char str[]){
  long long sum=0, p=1, i;
  for( i = 0 ; i < strlen(str) ; i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key % M; }
int h2(int key){ return 1+(key%(M-1)); }

int find(char str[]){
  long long key, i, h;
  key = getKey(str);
  for( i = 0 ; ;  i++ ){
    h = ( h1(key) + i*h2(key)) % M;
    if( strcmp(H[h],str) == 0 ) return 1;
    else if( strlen(H[h]) == 0 ) return 0;
  }
  return 0;
}

int insert(char str[]){
  long long key, i, h;
  key = getKey(str);
  for( i = 0 ; ; i++ ){
    h = ( h1(key) + i * h2(key)) % M;
    if( strcmp(H[h],str) == 0 ) return 1;
    else if( strlen(H[h]) == 0 ){
      strcpy(H[h], str);
      return 0;
    }
  }
  return 0;
}

int main(){
  int i, n, h;
  char str[L], com[9];
  for( i = 0 ; i < M ; i++ ) H[i][0] = '\0';
  scanf("%d", &n);
  for( i = 0 ; i < n ; i++ ){
    scanf("%s %s", com, str);

    if( com[0] == 'i' ){
      insert(str);
    }
    else{
      if( find(str) ){
	printf("yes\n");
      }
      else printf("no\n");
    }
  }
  return 0;
}



Measured memory_bytes: 16072
IDENTIFICATION DIVISION.
PROGRAM-ID. PROGRAM_ID.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 LN           PIC X(500).
01 N            PIC 9(3).
01 cur          PIC 9(10) VALUE 1.
01 i            PIC 9(18) VALUE 1.
01 j            PIC 9(18).
01 len          PIC 9(10). 
01 A            PIC 9(4) VALUE 1.
01 FLG          PIC 9(1) VALUE 1.

PROCEDURE DIVISION.
MAIN.
    ACCEPT N.
    ACCEPT LN.
    PERFORM N TIMES
        PERFORM VARYING j FROM cur BY 1 UNTIL LN(j:1) = SPACE
        END-PERFORM
        COMPUTE len = j - cur
        MOVE LN(cur:len) TO A
        IF FUNCTION MOD(A, 2) = ZERO AND FUNCTION MOD(A, 3) NOT = ZERO
            AND FUNCTION MOD(A, 5) NOT = ZERO THEN
            MOVE ZERO TO FLG
            EXIT PERFORM
        END-IF
        COMPUTE cur = j + 1
        ADD 1 TO i
    END-PERFORM.
    IF FLG = 1
        DISPLAY "APPROVED"
    ELSE
        DISPLAY "DENIED"
    END-IF.

MAIN-EXIT.
    STOP RUN.


Measured memory_bytes: 636
'use strict';

function ary_counter(ary) {
  let c = 0;
  ary.forEach(a => ++c);
  return c;
}

function main(stdin) {
  const l = [];
  let res = 'Yes';

  for (let i = 0; i < 4; ++i) {    
    const c = stdin.charCodeAt(i);
    l[c] = l[c] || 0;
    ++l[c];
  }

  if (ary_counter(l) !== 2) res = 'No'; 
  
  console.log(res);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include <stdio.h>

int main(void) {
    int A, B, C[10], i;
    C[1]=1; C[2]=1; C[3]=1;
    scanf("%d%d", &A, &B);
    C[A]=0; C[B]=0;
    for (i=1; i<=3; i++) {
        if (C[i]==1) printf("%d", i);
    }
    return 0;
}

Measured memory_bytes: 128
package main

import (
        "fmt"
)

func solution(n int, ss []string) int {
        gifts := make(map[string]int)
        for _, s := range ss {
                gifts[s]++
        }
        return len(gifts)
}

func main() {
        var n int
        fmt.Scan(&n)
        ss := make([]string, 0, n)
        for i := 0; i < n; i++ {
                var s string
                fmt.Scan(&s)
                ss = append(ss, s)
        }
        fmt.Println(solution(n, ss))
}

Measured memory_bytes: 27088
using namespace std;
#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx")
#pragma optimize("O3")
#pragma optimize("unroll-loops")
#include<iostream>
#include<algorithm>
#include<ctime>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#include<numeric>
#include<queue>
#include<deque>
#include<cfloat>
#include<functional>
#include<tuple>
#include<math.h>
#include<bitset>
#include<stack>
#include<set>
#include<random>
#include<stdlib.h>
#define rip(i,n) for(ll i=0;i<n;i++)
#define Rip(i,n) for(ll i=1;i<n;i++)
#define all(V) V.begin(),V.end()
#define ll long long
#define ld long double
#define MOD 998244353
#define mod MOD
#define sec setprecision
constexpr double eps = 1e-9;
constexpr double PI = 3.141592653589793238462643383279;
ll gcd(ll a, ll b) {
	if (a % b == 0)	return(b);
	else return(gcd(b, a % b));
}
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void cominit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (ll i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
vector<ll> soinnsuubunnkai(ll n) {
	vector<ll>a;
	while (n % 2 == 0) {
		a.push_back(2);
		n /= 2;
	}
	ll f = 3;
	while (f * f <= n) {
		if (n % f == 0) {
			a.push_back(f);
			n /= f;
		}
		else f += 2;
	}
	if (n != 1)
		a.push_back(n);
	return(a);
}
// 二項係数計算
long long 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;
}
ll pow(ll a, ll b) {
	a = a % mod;
	if (b == 0)return(1);
	else if (b % 2 == 0)return(pow((a * a) % mod, b / 2));
	else return(a * (pow(a, b - 1)));
}
void solve() {
	int n;
  cin>>n;
  cout<<(n+1)/2<<endl;
}
int main() {
	solve();
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>
#include <iomanip>
#include <sstream>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
#define ll long long
#define PL pair<long long, long long>
#define P pair<int,int>
#define mk make_pair
#define en endl
#define WHITE 0
#define BLACK 2
#define GRAY 1
#define RE return 0
#define int ll

int now[30];
int inde=0;
int a;

void solve(int sum,int t){
//  cout<<"  sum:  "<<sum<<"   t:  "<<t<<en;
  if(sum==a){
    cout<<now[0];
    for(int i=1;i<inde;i++){
      cout<<" "<<now[i];
    }
    cout<<en;
    return;
  }
  for(int i=t;i>=1;i--){
    if(sum+i<=a){
      now[inde++]=i;
      solve(sum+i,i);
      inde--;
    }
  }
  return ;
}
signed main(){
  while(cin>>a&&a){
    solve(0,a);
  }
}



Measured memory_bytes: 2992
#include <iostream>

using namespace std;

int search(int* a, int N, int* s) {
	for(int i = 0; i < N; i++) {
		for(int j = i+1; j < N; j++) {
			if(a[i] == a[j]) {
				*s = j - i;
				return i;
			}
		}
	}
	return -1;
}

int main(void) {
	
	while(true) {
		int L, N = 21;
		int* a = new int[N];
		int i = 0, j;
		
		cin >> a[0] >> L;
		if(a[0] == 0 && L == 0) break;
		//cout << a[0] << ", " << L << endl;
		
		for(i = 1; i < N; i++) {
			int* n = new int[L];
			int ai = a[i-1], min = 0, max = 0;

			for(int k = 0; k < L; k++, ai /= 10) {
				int tmp = ai % 10;
				//cout << tmp << " ";
				int h;
			
				for(h = 0; h < k && n[h] <= tmp; h++) ;
				if(h != k) {
					int tmp2 = n[h];
					n[h] = tmp;
					tmp = tmp2;
					//ai = ai / 10;
			
					for(h++; h < k; h++) {
						tmp2 = n[h];
						n[h] = tmp;
						tmp = tmp2;
					}
				}
				n[h] = tmp;
			}
			
			//cout << endl;
			for(/*min = 0, */int k = 0; k < L; k++) {
				min = min * 10 + n[k];
			}
			//cout << min << endl;
			for(/*max = 0, */int k = L-1; k >= 0; k--) {
				max = max * 10 + n[k];
				//cout << n[k];// << endl;
			}
			//cout << max << endl;
		
			//i++;
			a[i] = max - min;
			//cout << i << ": " << max << "-" << min << "= " << a[i] << endl;
			if(a[i-1] == a[i]) {
				N = i+1;
				break;
			}
		}
		
		int s;
		j = search(a, N, &s);
		cout << j << " ";
		cout << a[j] << " " << s << endl;
	}

	return 0;
}

Measured memory_bytes: 1224
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

A = int(input())
B = int(input())
C = int(input())
X = int(input())

X //= 50
ans = 0
for a in range(A+1):
    tmp = 10*a
    if tmp > X:
        break
    for b in range(B+1):
        tmpB = 2*b+tmp
        if tmpB > X:
            break
        else:
            r = X-tmpB
            if r <= C:
                ans += 1
print(ans)


Measured memory_bytes: 3064