akhauriyash/Code-Regression huggingface dataset:
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
// vector<int> dx={0,1,-1,0};
// vector<int> dy={1,0,0,-1};

struct edge{int to; int cost;};
vector<vector<edge>> graph(0);
vector<int> d(0);
const int MAX_dist=1e9;

void init(int n){
    graph.resize(n);
    d.resize(n,MAX_dist);
}

void dijkstra(int s){
if(d.size()==0){cout<<"You Should init"<<endl;return;}
    priority_queue<P, vector<P>, greater<P>> que;
    d[s]=0;
    que.emplace(0,s);
    while(!que.empty()){
        P p=que.top();
        que.pop();
        int v=p.second;
        if(d[v]<p.first) continue;
        rep(i,graph[v].size()){
            edge e=graph[v][i];
            if(d[e.to]>d[v]+e.cost){
            d[e.to]=d[v]+e.cost;
            que.emplace(d[e.to],e.to);
            }
        }
    }
}

int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int h,w,Ch,Cw,Dh,Dw;
    cin>>h>>w>>Ch>>Cw>>Dh>>Dw;
    Ch --;
    Cw --;
    Dh --;
    Dw --;
    vector<vector<char>> a(h,vector<char>(w));
    rep(i,h)rep(j,w) cin>>a[i][j];

    init(h*w);
    //左右に行く
    rep(i,h){
        rep(j,w){
            if(a[i][j]=='#') continue;
            if(j!=0 && a[i][j-1]=='.') graph[i*w+j].push_back({i*w+j-1,0});
            if(j!=w-1 && a[i][j+1]=='.') graph[i*w+j].push_back({i*w+j+1,0});
        }
    }
    // //上下に行く
    rep(i,h){
        rep(j,w){
            if(a[i][j]=='#') continue;
            if(i!=0 && a[i-1][j]=='.') graph[i*w+j].push_back({i*w+j-w,0});
            if(i!=h-1 && a[i+1][j]=='.') graph[i*w+j].push_back({i*w+j+w,0});
        }
    }

    rep(i,h)rep(j,w){
        if(a[i][j]=='#') continue;
        for(int k=-2;k<=2;k++){
            if(i+k<0 || i+k>=h) continue;
            for(int l=-2;l<=2;l++){
                if(j+l<0 || j+l>=w) continue;
                if(a[i+k][j+l]=='#') continue;
                graph[i*w+j].push_back({(i+k)*w+(j+l),1});
            }
        }
    }

    dijkstra(Ch*w+Cw);
    if(d[Dh*w+Dw]==MAX_dist) cout<<-1<<endl;
    else cout<<d[Dh*w+Dw]<<endl;    
    // rep(i,25) cout<<d[i]<<" ";
    // cout<<endl;
}/*
./problem.exe
*/


Measured memory_bytes: 121172
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

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

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n, x;
	cin >> n >> x;
	if(n == 2){
		if(x == 2){
			cout << "Yes" << '\n';
			cout << 1 << '\n';
			cout << 2 << '\n';
			cout << 3 << '\n';
		}
		else cout << "No" << '\n';
		return 0;
	}
	int num = (1 + (n * 2)) / 2;
	if(num == x){
		cout << "Yes" << '\n';
		rep(i, 2 * n - 1) cout << i + 1 << '\n';
	}
	else{
		int off = num - x;
		if(off == 1){
			cout << "Yes" << '\n';
			cout << 2 * n - 1 << '\n';
			rep(i, 2 * n - 2) cout << i + 1 << '\n';
			return 0;
		}
		else if(off == -1){
			cout << "Yes" << '\n';
			repn(i, 1, 2 * n - 1) cout << i + 1 << '\n';
			cout << 1 << '\n';
			return 0;
		}
		if(off < 0){
			off = abs(off);
			if(n > (off + 1)){
				cout << "Yes" << '\n';
				repn(i, off, 2 * n - 1) cout << i + 1 << '\n';
				rep(i, off) cout << i + 1 << '\n';
				return 0;
			}
			cout << "No" << endl;
		}
		else{
			if(n > (abs(off) + 1)){
				cout << "Yes" << '\n';
				for(int i = 2 * n - 1, cnt = 0; cnt < abs(off); i--, cnt++){
					cout << i << '\n';
				} 
				repn(i, 0, 2 * n - 1 - abs(off)) cout << i + 1 << '\n';
				return 0;
			}
			cout << "No" << endl;
		}
		return 0;
	}
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 3660
package main

import "fmt"

func pi2p(i int) string {
	return string(int('A') + i)
}

func p2pi(p byte) int {
	return int(p - 'a')
}

func main() {
	var ss [3]string
	fmt.Scan(&ss[0], &ss[1], &ss[2])
	pi := 0
	is := make([]int, 3)
	for {
		s := ss[pi]
		i := is[pi]
		if i < len(s) {
			is[pi]++
			pi = p2pi(s[i])
		} else {
			fmt.Println(pi2p(pi))
			break
		}
	}
}


Measured memory_bytes: 512
import java.util.*;
public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int ans = 0;
		for(int i = 1;i <= K;i++){
			for(int j = 1;j <= K;j++){
				for(int k = 1;k <= K;k++){
					ans += gcd(gcd(i,j),k);
				}
			}
		}
		System.out.println(ans);
	}
	public static int gcd (int a, int b) {
	int temp;
	while((temp = a%b)!=0) {
		a = b;
		b = temp;
	}
	return b;
}
}

Measured memory_bytes: 35900
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cctype>
#include <sstream>

using namespace std;

#define ALL(c) c.begin() , (c).end()

string to_s(const int & n){
    stringstream ss;
    ss << n; return ss.str();
}

bool replace(string& str, const string& from, const string& to) {
    size_t start_pos = str.find(from);
    if(start_pos == std::string::npos)
        return false;
    str.replace(start_pos, from.length(), to);
    return true;
}

int min_vote(vector<int> & a, bool half){
    sort(ALL(a));
    int rtn = 0;
    for(int i=0; i<a.size()/2+1; i++){
        rtn += half ? a[i]/2+1 : a[i];
    }
    return rtn;
}

string resize_tree(string in, bool half){
    for(int i=0; i<in.size()-2; i++){
        if(in[i] == '[' && in[i+1] == '[' && isdigit(in[i+2])){
            int j=i;
            while(!(isdigit(in[j]) && in[j+1] == ']' && in[j+2] == ']')) j++;
            string leafs(in.begin()+i+1 , in.begin()+j+2);
            //cout << "leafs" << leafs << endl;
            vector<int> reg;
            int a = 0;
            for(int p=0; p<leafs.size(); p++){
                if(isdigit(leafs[p])){
                    a*=10;
                    a+=leafs[p]-'0';
                } else if(leafs[p] == ']'){
                    reg.push_back(a);
                    a=0;
                }
            }
            string resized = to_s(min_vote(reg,half));
            in.replace(i+1, leafs.size(), resized);
        }
    }
    return in;
}

void solve(string in){
    int d = 0;
    while(in[d] == '[') d++;
    for(int i=0; i<d-1; i++){
        in = resize_tree(in, i==0);
    }
    cout << in.substr(1, in.size()-2) << endl;
}

int main(){
    int n; cin >> n;
    while(n--){
        string in; cin >> in;
        solve(in);
    }
}

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

using namespace std;

int main(){
	long long a, b, k;
  	cin >> a >> b >> k;
  	if(a >= k){
    	cout << a - k << " " << b << "\n";
    }
  	else{
    	cout << "0 ";
		long long dump = b + (a - k);
		if(dump <= 0) cout << "0\n";
		else cout << dump << "\n";
    }
  	return 0;
}


Measured memory_bytes: 256
N = int(input())
initials = ['M', 'A', 'R', 'C', 'H']
names = dict()
for init in initials:
  names[init] = set()

for i in range(N):
  si = str(input())
  if si[0] in initials:
    names[si[0]].add(si)
#print(names)

from itertools import combinations
ans = 0
for init in combinations(initials, 3):
  cmb = len(names[init[0]]) * len(names[init[1]]) * len(names[init[2]])
  ans += cmb
  #print(init, cmb)

print(ans)

Measured memory_bytes: 14316
#include<bits/stdc++.h>
#define maxn 10010
using namespace std;
int res[maxn];
int main()
{
	int n;
	cin >> n;
	int tmp = sqrt(n);
	for (int i = 1; i <= tmp; i++)
		for (int j = 1; j <= tmp; j++)
			for (int k = 1; k <= tmp; k++)
			{
				int tmp = i * i + j * j + k * k + i * j + i * k + j * k;
				if (tmp <= n) res[tmp]++;
			}
	for (int i = 1; i <= n; i++)
		printf("%d\n", res[i]);
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORC(i,a,b,c) for(ll i=(a);i<(b);i+=(c))
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define ff first
#define ss second
#define dd long double
#define mod 1000000007
const ll N=1e6+10;
ll m[N+1];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    ll arr[n];
    REP(i,n){
        ll t;
        cin>>t;
        arr[i]=t;
        m[t]++;
    }
    ll ans=0;
    REP(j,n){
        ll elem=arr[j];
        m[elem]=m[elem]-1;
        vector<ll> fact;
        for(ll i=1;i<=sqrt(elem);i++){
            if(elem%i==0){
                if(elem/i==i){
                    fact.pb(i);
                }
                else{
                    fact.pb(elem/i);
                    fact.pb(i);
                }
            }
        }
        ll flag=1;
        for(auto & x:fact){
            if(m[x]){
                flag=0;
                break;
            }
        }
        if(flag){
            ans++;
        }
        m[elem]++;
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 12940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/
 

 
// void chmod(ll &M){
//     if(M >= mod) M %= mod;
//     else if(M < 0){
//         M += (abs(M)/mod + 1)*mod;
//         M %= mod;
//     }
// }

const ll inf = 1LL<<60;
const int MAX_V = 5050;
const int MAX_E = 5050;

struct Edge{ll from, to, cost; };

int V; // 頂点の数
int E; // 辺の数
vector<ll> d(MAX_V, inf); // 距離
vector<bool> negative(MAX_E, false); // 負の閉路検出
vector<Edge> edge;

void Bellman_Ford(){
    d[0] = 0; // 始点の初期化
    for(int loop=0; loop<V-1; ++loop){
        for(int i=0; i<E; ++i){
            if(d[edge[i].from] == inf) continue;

            if(d[edge[i].to] > d[edge[i].from]+edge[i].cost){
                d[edge[i].to] = d[edge[i].from]+edge[i].cost;
            }
        }
    }

    for(int loop=0; loop<2*V; ++loop){
        for(int i=0; i<E; ++i){
            if(d[edge[i].from] == inf) continue;

            if(d[edge[i].to] > d[edge[i].from]+edge[i].cost){
                d[edge[i].to] = d[edge[i].from]+edge[i].cost;
                negative[edge[i].to] = true;
            }

            if(negative[edge[i].from]) negative[edge[i].to] = true;
            
        }
    }
}
 

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
 
    cin >> V >> E;
    ll p; cin >> p;
    for(int i=0; i<E; ++i){
        int a,b,c; cin >> a >> b >> c;
        --a; --b; c = p-c;
        edge.push_back({a, b, c});
    }

    Bellman_Ford();

    ll ans = -d[V-1];

    if(negative[V-1] || d[V-1] == inf) cout << -1 << endl;
    else cout << max(0LL, ans) << endl;

	return 0;
}

Measured memory_bytes: 640
N = int(input())
S = []
for num in range(N):
    S.append(input())
dic = {}
max=1

for name in S:
    if name in dic.keys():
        dic[name] += 1
        if dic[name] > max:
            max = dic[name]
    else:
        dic[name] = 1

keys = [k for k, v in dic.items() if v == max]
keys.sort()

for key in keys:
    print(key)


Measured memory_bytes: 35220
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

int n, k;
bool cantUse[10] = {};

int powInt(int num, int s){
	if(s == 0) return 1;
	int ret = num;
	for(int i = 1;i < s;i++){
		ret *= num;
	}
	return ret;
}

int main() {
	cin >> n >> k;
	int a;
	for(int i = 0;i < k;i++){
		cin >> a;
		cantUse[a] = true;
	}

		int nowN = n;
	while(true){
		stringstream ss;
		ss << nowN;
		string nowStr = ss.str();

		bool endFlag = true;

		for(int i = 0;i < nowStr.size();i++){
			int nowNum = nowStr[i] - '0';
			if(cantUse[nowNum]){
				int out = nowStr.size() - i;
				int plus = powInt(10, out - 1);
				nowN += plus;
				nowN -= nowN % plus;
				endFlag = false;
				break;
			}
		}

		if(endFlag) {
			cout << nowN << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

bool dir[4];
string S;

int main(void)
{
	cin >> S;
	for(int i = 0; i < S.size(); i++){
		if(S[i] == 'N') dir[0] = true;
		if(S[i] == 'S') dir[1] = true;
		if(S[i] == 'W') dir[2] = true;
		if(S[i] == 'E') dir[3] = true;
	}
	
	if( (dir[0] ^ dir[1]) || (dir[2] ^ dir[3]) ) cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
vector<string> split(string s, char p){vector<string>v;stringstream m(s);string b;while(getline(m,b,p))v.push_back(b);return 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 (a>b) { a = b; return 1; } return 0; }
struct nya{ nya(){ cin.tie(0); ios::sync_with_stdio(false); } }nyan;

int main(){
    string S, T; cin >> S >> T;
    ll ans = 0;
    REP(i, S.length()) {
        if (S[i] != T[i]) ans++;
    }
    cout << ans << "\n";
}


Measured memory_bytes: 3816
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
    int a,b,c,d;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    a=max(a,c);
    b=min(b,d);
    printf("%d\n",b-a<0?0:b-a);
    return 0;
}


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

namespace ABC129
{
    class B
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] W = Console.ReadLine().Split(' ').Select(o => int.Parse(o)).ToArray();

            int min = int.MaxValue;
            int s1 = 0, s2 = W.Sum();
            for (int i = 0; i < N; i++)
            {
                s1 += W[i];
                s2 -= W[i];
                int d = Math.Abs(s1 - s2);
                if (d < min) min = d;
            }
            Console.WriteLine(min);
        }

    }
}


Measured memory_bytes: 13396
#include<stdio.h>
#include<stdlib.h>



int N=100;

int main(){
  int i, j, k, n, c, p[N+1], m[N+1][N+1];
  scanf("%d",&n);
  for(i=1 ; i<=n ; i++)scanf("%d%d",&p[i-1],&p[i]);
  for(i=1 ; i<=n ; i++)m[i][i]=0;
  for(j=2 ; j<=n ; j++){
    for(i=1 ; i<=n-j+1 ; i++){
      c=i+j-1;
      m[i][c]=(1<<21);
      for(k=i ; k<=c-1 ; k++){
        if(m[i][c]>m[i][k]+m[k+1][c]+p[i-1]*p[k]*p[c])m[i][c]=m[i][k]+m[k+1][c]+p[i-1]*p[k]*p[c];
      }
    }
  }
  printf("%d\n",m[1][n]);
  return 0;
}


Measured memory_bytes: 2112
def main():
    H, W = map(int, input().split())
    S = [list(input()) for _ in range(H)]

    left = [[-1]*W for _ in range(H)]
    right = [[-1]*W for _ in range(H)]
    up = [[-1]*W for _ in range(H)]
    down = [[-1]*W for _ in range(H)]

    for i in range(H):
        for j in range(W):
            if S[i][j] == '.':
                if j == 0:
                    left[i][j] = 0
                else:
                    left[i][j] = left[i][j-1] + 1

    for i in range(H):
        for j in range(W):
            if S[-1-i][-1-j] == '.':        
                if j == 0:
                    right[-1-i][-1-j] = 0
                else:
                    right[-1-i][-1-j] = right[-1-i][-1-(j-1)] + 1

    for i in range(H):
        for j in range(W):
            if S[i][j] == '.':
                if i == 0:
                    up[i][j] = 0
                else:
                    up[i][j] = up[i-1][j] + 1

    for i in range(H):
        for j in range(W):
            if S[-1-i][-1-j] == '.':
                if i == 0:
                    down[-1-i][-1-j] = 0
                else:
                    down[-1-i][-1-j] = down[-1-(i-1)][-1-j] + 1
            
    ans = 0
    temp = [0] * W
    for i in range(H):
        for j in range(W):
            temp[j] = left[i][j] + right[i][j] + down[i][j] + up[i][j] + 1
        ans = max(ans, max(temp))
    print(ans)

main()

Measured memory_bytes: 311304
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
#define overload4(_1,_2,_3,_4,name,...) name
#define rep1(n) for(ll i=0;i<(n);++i)
#define rep2(i,n) for(ll i=0;i<(n);++i)
#define rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep4(i,a,b,c) for(ll i=(a);i<(b);i+=(c))
#define rep(...) overload4(__VA_ARGS__,rep4,rep3,rep2,rep1)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define vec vector<ll>
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;}

void solve(){
    ll n,k;cin>>n>>k;
    k=min(k,n);
    vec h(n)    ;
    rep(i,n)cin>>h[i];
    sort(all(h));
    ll sum=0;
    rep(i,n-k){
        sum+=h[i];
    }
    cout<<sum<<endl;
}

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


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>

using namespace std;

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

    vector<int> vh(N);
    int sum = 0;
    for(auto& e : vh)
    {
        cin >> e;
        sum += e;
    }


    int ans = 0;
    while(sum)
    {
        ans++;
        int nz = 0;
        for(; nz < N; ++nz)
            if(vh[nz]) break;
        int z = nz;
        for(; z < N; ++z)
        {
            if(vh[z])
            {
                vh[z]--;
                sum--;
            }
            else
            {
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
class Simulator:
    def __init__(self, exist_mp, cnt_mp, birth_num, death_num, limit):
        self.exist_mp = exist_mp
        self.cnt_mp = cnt_mp
        self.birth_num = birth_num
        self.death_num = death_num
        self.birth_list = []
        self.death_list = []
        self.limit = limit

    def check(self):
        self.birth_list = []
        self.death_list = []
        for z in range(1, 6):
            for y in range(1, 6):
                for x in range(1, 6):
                    if not self.exist_mp[z][y][x] and\
                       self.cnt_mp[z][y][x] in self.birth_num:
                        self.birth_list.append((x, y, z))
                    if self.exist_mp[z][y][x] and\
                       self.cnt_mp[z][y][x] not in self.death_num:
                        self.death_list.append((x, y, z))

    def birth(self):
        for x, y, z in self.birth_list:
            self.exist_mp[z][y][x] = 1
            self.cnt_mp[z][y][x] -= 1
            for nz in (z - 1, z, z + 1):
                for ny in (y - 1, y, y + 1):
                    for nx in (x - 1, x, x + 1):
                        self.cnt_mp[nz][ny][nx] += 1

    def death(self):
        for x, y, z in self.death_list:
            self.exist_mp[z][y][x] = 0
            self.cnt_mp[z][y][x] += 1
            for nz in (z - 1, z, z + 1):
                for ny in (y - 1, y, y + 1):
                    for nx in (x - 1, x, x + 1):
                        self.cnt_mp[nz][ny][nx] -= 1

    def run(self):
        while self.limit > 0:
            self.check()
            self.birth()
            self.death()
            self.limit -= 1

    def print_mp(self):
        for z in range(1, 6):
            for y in range(1, 6):
                print(*self.exist_mp[z][y][1:6],sep="")
            if z != 5:print()


case = 1
while True:
    n = int(input())
    if n == 0:break
    if case != 1:print()
    exist_mp = [[[0] * 7 for _ in range(7)]]
    for z in range(5):
        mp = [[0] * 7]
        for _ in range(5):
            mp.append([0] + list(map(int, list(input()))) + [0])
        mp.append([0] * 7)
        exist_mp.append(mp)
        if z != 4:input()
    exist_mp.append([[0] * 7 for _ in range(7)])

    cnt_mp = [[[0] * 7 for _ in range(7)] for _ in range(7)]
    for z in range(1, 6):
        for y in range(1, 6):
            for x in range(1, 6):
                if exist_mp[z][y][x]:
                    cnt_mp[z][y][x] -= 1
                    for nz in (z - 1, z, z + 1):
                        for ny in (y - 1, y, y + 1):
                            for nx in (x - 1, x, x + 1):
                                cnt_mp[nz][ny][nx] += 1
    s = input()
    if s == "":
        birth_num = set(list(map(int, input().split()))[1:])
        death_num = set(list(map(int, input().split()))[1:])
    else:
        birth_num = set(list(map(int, s.split()))[1:])
        death_num = set(list(map(int, input().split()))[1:])
    simulator = Simulator(exist_mp, cnt_mp, birth_num, death_num, n)
    simulator.run()
    print("Case {}:".format(case))
    simulator.print_mp()
    case += 1


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

int main(){
  int N, K;
  cin >> N >> K;
  int m=1;
  while(m<=3000){
    if(floor((double)m*0.08)==N && floor((double)m*0.1)==K){
      cout << m <<endl;
      return 0;
    }
    m++;
  }
  cout << -1 <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>

#define rep0(i, n) for (i = 0; i < n; i++)
#define rep(s, i, n) for (i = s; i < n; i++)
using namespace std;

const int M = 1000000007;
int  N;
long long a[200000],ans,sum,d;

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}


int main()
{
    cin >>N;

    int i,j;
    rep0(i,N)
    {
        cin>>j;
        a[i]=j%M;
        sum+=a[i];
        sum%=M;
        d+=a[i]*a[i]%M;
        d%=M;
    }
/*
    rep0(i,N-1){
        rep(i+1,j,N)
        ans+=a[i]*a[j]%M;
        ans%=M;
    }*/
    sum=(sum*sum-d)%M;
    ans=sum*modinv(2,M)%M;
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 5184
#include<map>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
#define N 100005
#define inf (1ll<<60)
#define rep(i,j,k) for (ll i=j;i<=k;++i)
#define per(i,j,k) for (ll i=j;i>=k;--i)
using namespace std;
inline ll read(){
	char ch=getchar(); ll x=0,f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	while (ch>='0'&&ch<='9') { x=x*10+ch-'0'; ch=getchar(); }
	return x*f;
}
ll n,m,ans,tot,num,dfn[N],low[N],head[N];
struct edge{ ll to,next; }e[N<<1];
void add(ll u,ll v){
	e[++tot]=(edge){v,head[u]}; head[u]=tot;
}
void tarjan(ll u,ll last){
	dfn[u]=low[u]=++num;
	for (ll i=head[u],v=e[i].to;i;i=e[i].next,v=e[i].to){
		if (v==last) continue;
		if (dfn[v]) low[u]=min(low[u],dfn[v]);
		else{
			tarjan(v,u),low[u]=min(low[u],low[v]);
			if (low[v]==dfn[v]) ++ans;
		}
	}
}
int main(){
	n=read(); m=read();
	rep(i,1,m){
		ll u=read(),v=read();
		add(u,v); add(v,u);
	}
	rep(i,1,n) if (!dfn[i]) tarjan(i,-1);
	printf("%lld",ans);
}

Measured memory_bytes: 2176
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
using namespace std;
int a, b, c;
int main()
{
	scanf("%d%d%d", &a, &b, &c);
	if(b - a == c - b)printf("YES\n");
	else printf("NO\n");
}

Measured memory_bytes: 128
W, H, N = map(int, input().split())

lst = []
for i in range(N):
    xya = list(map(int, input().split()))
    lst.append(xya)

sikaku_x = [0, W]
sikaku_y = [0, H]

for v in lst:
    x, y, a = v[0], v[1], v[2]
    if a == 1:
        if x > sikaku_x[0]:
            sikaku_x[0] = x
    elif a == 2:
        if x < sikaku_x[1]:
            sikaku_x[1] = x
    elif a == 3:
        if y > sikaku_y[0]:
            sikaku_y[0] = y
    else:
        if y < sikaku_y[1]:
            sikaku_y[1] = y
    if sikaku_x[0] >= sikaku_x[1] or sikaku_y[0] >= sikaku_y[1]:
        print(0)
        exit()

print((sikaku_x[1] - sikaku_x[0]) * (sikaku_y[1] - sikaku_y[0]))


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

int main(){
    int n, m;
    cin>>n>>m;
    int a[n], sum=0;
    for(int i=0; i<n;i++) {
        cin >> a[i];
        sum+=a[i];
    }
    sort(a, a+n);
    if(a[n-m] >= (double)sum/(4*m) ) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
H,W = map(int,input().split())
B = []
C = []

for h in range(H):
  A = list(map(int,input().split()))
  w = 0
  for w in range(1,W):
    if A[w-1]%2:
      C.append((h+1,w,h+1,w+1))
      A[w]+=1
  B.append(A[w])
  
  if h and B[-2]%2:
    C.append((h,W,h+1,W))
    B[h]+=1
    
print(len(C))
for c in C:
  print(*c)


Measured memory_bytes: 28104
N, M = map(int, raw_input().split())
Q = [map(int, raw_input().split()) for _ in range(M)]
 
cnt = [0 for _ in range(N)]
for a, b in Q:
    cnt[a-1] += 1
    cnt[b-1] += 1
 
for k in range(N):
    if cnt[k] % 2 != 0:
        print "NO"
        exit()
print "YES"

Measured memory_bytes: 22388
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9+7;
 
int main(){
	
	ll a;
	double b;
	cin>>a>>b;
	ll c = (b+(1e-5))*100;
	cout << a*c/100 << endl;
	
	
}


Measured memory_bytes: 3732
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)

int main(){
	int A, B;
	cin >> A >> B;
	int cnt = 1;
	int i = 0;
	while (cnt < B) {
		cnt += (A - 1);
		i++;
	}
	cout << i << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    // Here your code !
    long long N,A,B;
    long long min,max,ans;
    scanf("%lld %lld %lld",&N,&A,&B);
    min = A*(N-1)+B;
    max = A+(N-1)*B;
    ans = max-min+1;
    if(N != 1 && A<=B){
        printf("%lld\n",ans);
    }else if(N == 1 && A<B){
        printf("0\n");
    }else if(N == 1 && A == B){
        printf("1\n");
    }else{
        printf("0\n");
    }
    return 0;
}

Measured memory_bytes: 128
// codeforces.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <bits/stdc++.h>
using namespace std;
using ll =long long int;
constexpr ll mod = 1e12;
int main()
{
	ll x, k; cin >> x >> k; ll ans = 0;
	vector<ll>a(x); ll res = x - k;
	for (auto& ele : a)cin >> ele; sort(a.begin(), a.end());
	for (int i = 0; i < res; ++i) {
		ans += a[i];
	}
	cout << ans;
	return 0;
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file


Measured memory_bytes: 1792
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (int64_t)(n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

#define chmax(a, b) (a) = max(a, b)
#define chmin(a, b) (a) = min(a, b)

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int X;
  cin >> X;
  cout << (X >= 30 ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 3104
#!/usr/bin/env python3
import sys


def solve(N: int, A: int, B: int, C: int, D: int, E: int):
    x = min(A,B,C,D,E)
    ans = 5+int(N/x)
    if(N%x == 0):
        ans -= 1
    print(ans)
    return


# Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    E = int(next(tokens))  # type: int
    solve(N, A, B, C, D, E)

if __name__ == '__main__':
    main()


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

int main(){
  char ch;
  int counter[26] = {};

  while (cin >> ch)
    {
        if (isupper(ch))
        {
          ch = tolower(ch);
        }
      counter[(int)(ch - 'a')]++;
    }
  for (int i = 0; i < 26; ++i)
    {
      ch = 'a' + i;
      cout << ch << " : " << counter[i] << endl;
    }
}

Measured memory_bytes: 1140
def Z_algo(S):
    n = len(S)
    LCP = [0]*n
    i = 1
    j = 0
    c = 0#最も末尾側までLCPを求めたインデックス
    for i in range(1, n):
        #i番目からのLCPが以前計算したcからのLCPに含まれている場合
        if i+LCP[i-c] < c+LCP[c]:
            LCP[i] = LCP[i-c]
        else:
            j = max(0, c+LCP[c]-i)
            while i+j < n and S[j] == S[i+j]: j+=1
            LCP[i] = j
            c = i
    LCP[0] = n
    return LCP
  
ans = 0
N = int(input())
S = input()
for i in range(N):
    LCP = Z_algo(S[i:])
    for j, l in enumerate(LCP):
        tmp = min(l, j)
        ans = max(ans, tmp)
print(ans)

Measured memory_bytes: 52572
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<int> v(5);
    for(int i = 0; i < 5; i++) cin >> v[i];
    int k; cin >> k;
    bool ok = true;
    for(int i = 0; i < 5; i++)
    {
        for(int j = i + 1; j < 5; j++)
        {
            if(abs(v[i] - v[j]) > k) ok = false;
        }
    }
    cout << (ok ? "Yay!" : ":(") << endl;
    return 0;
}



Measured memory_bytes: 256
//#include <bits/stdc++.h>
//#pragma GCC optimize(2)
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<cstring>
#include<bitset>
#include<stack>
#include<time.h>



#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define ALL(x) x.begin(),x.end()
#define sz(a) ((int)a.size())
#define getmid ((l+r)>>1)
#define mst(var,val) memset(var,val,sizeof(var))
#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define lowbit(x) x&(-x)
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ls rt<<1
#define rs rt<<1|1
using namespace std;
#ifdef local
#define dbg(args...) cout << #args << " -> ", err(args);
void err(){ cout << endl; }
template<typename T, typename... Args>
void err(T a, Args... args){ cout << a << ' '; err(args...); }
#else
#define dbg(args...)
#endif // local

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <double, double> pdd;
const int inf=0x3f3f3f3f;
const long long INF=0x3f3f3f3f3f3f3f3fLL;
const double PI=acos(-1.0);
const long double eps=1e-8;
const int mod=1e9+7;
const int maxn=1e6+100;
const int N=1e5+10;
const int M=1e6+10;
const ll mm=(1LL<<32);

template <class T>
inline void read(T &x)
{
    x = 0;
    char c = getchar();
    bool f = 0;
    for (; !isdigit(c); c = getchar())
        f ^= c == '-';
    for (; isdigit(c); c = getchar())
        x = x * 10 + (c ^ 48);
    x = f ? -x : x;
}

template <class T>
inline void write(T x)
{
    if (x < 0)
    {
        putchar('-');
        x = -x;
    }
    T y = 1;
    int len = 1;
    for (; y <= x / 10; y *= 10)
        ++len;
    for (; len; --len, x %= y, y /= 10)
        putchar(x / y + 48);
}
ll qpow(ll a,ll b,ll mod)
{
    ll ans=1;
    while(b)
    {
        if(b&1)
            ans=(ans*a)%mod;
        b>>=1;
        a=(a*a)%mod;
    }
    return ans;
}

int main()
{
#ifdef local
      freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
#endif // local
    IOS;cout.tie(0);
    int n;cin>>n;
        int a=0,b=0,c=0,d=0;
        string s;
    rep1(i,n)
    {
        cin>>s;
        if(s[0]=='A') a++;
        else if(s[0]=='W') b++;
        else if(s[0]=='T') c++;
        else d++;
    }
    cout<<"AC x "<<a<<endl;
    cout<<"WA x "<<b<<endl;
    cout<<"TLE x "<<c<<endl;
    cout<<"RE x "<<d<<endl;
    return 0;
}


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

using namespace std;

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

    vector<long long> a(n + 1);
    for (int i = 0; i < n + 1; ++i) {
        cin >> a[i];
    }

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

    auto ans = 0L;
    for (int i = 0; i < n; ++i) {
        if (a[i] >= b[i]) {
            ans += b[i];
            a[i] -= b[i];
            b[i] = 0;
        } else {
            ans += a[i];
            b[i] -= a[i];
        }

        if (a[i + 1] >= b[i]) {
            ans += b[i];
            a[i + 1] -= b[i];
        } else {
            ans += a[i + 1];
            a[i + 1] = 0;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
n = int(input())
x = 0
for i in range(1, n+1):
    if(i%3 == 0):
        print(" %d" %i, end = "")
    else:
        x = i
        while(x):
            if x % 10 == 3:
                print(" %d" %i, end = "")
                break
            x //= 10
print()


Measured memory_bytes: 5872
N = int(input())

xyh_list = list()

for i in range(N):
    x,y,h = map(int, input().split())
    xyh_list.append((x,y,h))
    
for i in range(N):
    h = xyh_list[i][2]
    if h != 0:
        no_zero_h = i
        break


break_flag = 0

for i in range(0,101):
    for j in range(0,101):
        
        x = xyh_list[no_zero_h][0]
        y = xyh_list[no_zero_h][1]
        h = xyh_list[no_zero_h][2]
        H = h + abs(x-i) + abs(y-j)
        
        if 1 <= H:
            for k in range(0,N):
                x = xyh_list[k][0]
                y = xyh_list[k][1]
                h = xyh_list[k][2]
                
                if (h != 0 and h + abs(x-i) + abs(y-j) != H) or (h == 0 and H - abs(x-i) - abs(y-j) > 0):
                    break
            else:
                print(i,j,H)
                break_flag = 1
                
        if break_flag == 1:
            break
            
    if break_flag == 1:
        break

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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 100005

int t , p;

int main()
{
    _FastIO;
    cin >> t;
    cout << 10 - int(t/200) << endl;
}


Measured memory_bytes: 3648
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		String[] S = new String[]{A, B, C};
		int min = A.Length + B.Length + C.Length;
		
		HashSet<int>[][] L = new HashSet<int>[3][];
		for(int i=0;i<3;i++){
			L[i] = new HashSet<int>[3];
			for(int j=0;j<3;j++){
				L[i][j] = new HashSet<int>();
			}
		}
		
		for(int i=0;i<3;i++){
			for(int j=0;j<3;j++){
				if(i == j) continue;
				var s = S[i];
				var t = S[j];
				for(int k=-t.Length;k<=s.Length;k++){
					bool chk = true;
					for(int l=0;l<s.Length;l++){
						int ti = l - k;
						if(ti < 0 || ti >= t.Length) continue;
						if(s[l] == t[ti]) continue;
						if(s[l] == '?') continue;
						if(t[ti] == '?') continue;
						chk = false;
						break;
					}
					if(chk){
						L[i][j].Add(k);
					}
				}
				
			}
		}
		
		//for(int i=0;i<3;i++) for(int j=0;j<3;j++) Console.WriteLine("{0},{1}:{2}",i,j,String.Join(" ",L[i][j]));
		int[] a = new int[]{0,1,2};
		do {
			int i = a[0];
			int j = a[1];
			int k = a[2];
			foreach(var ij in L[i][j]){
				foreach(var ik in L[i][k]){
					int la = 0, ra = S[i].Length;
					int lb = ij, rb = ij + S[j].Length;
					int lc = ik, rc = ik + S[k].Length;
					if(lb <= lc && lc < rb){
						if(!L[j][k].Contains(lc - lb)) continue;
					}
					if(lc <= lb && lb < rc){
						if(!L[k][j].Contains(lb - lc)) continue;
					}
					int l = Math.Min(la, lb);
					l = Math.Min(l, lc);
					int r = Math.Max(ra, rb);
					r = Math.Max(r, rc);
					min = Math.Min(min, r - l);
				}
			}
			
		} while(NextPermutation(a));
		
		Console.WriteLine(min);
		
	}
	String A,B,C;
	public Sol(){
		A = rs();
		B = rs();
		C = rs();
	}
	
	static public bool NextPermutation<T>(T[] A)where T:IComparable<T>{
		for(int i=A.Length-2;i>=0;i--){
			if(A[i].CompareTo(A[i+1])<0){
				int trgt=Array.FindLastIndex(A,x=>A[i].CompareTo(x)<0);
				Swap(ref A[i],ref A[trgt]);
				Array.Reverse(A,i+1,A.Length-(i+1));
				return true;
			}
		}
		Array.Reverse(A);
		return false;
	}
	static void Swap<T>(ref T x, ref T y){
		T t=x;x=y;y=t;
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    int N; cin >> N;
    ll tmp = 0, d=0, cnt = 0;
    rep1(i, N){
        tmp += i;
        if(tmp >= N){
            d = tmp - N;
            cnt = i;
            break;
        }
    }
    rep1(i, cnt){
        if(i != d) cout << i << endl;
    }
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 4352
#include <iostream>
#include<stdio.h>
#define MAXSIZE 10000
#define PI 3.141592653589
using namespace std;
int main(){
  int n;
  std::cin >> n;

  for(int i=1;i<=n;i++){
    if(i%3==0){
      std::cout << " "<<i;
      continue;
    }

    int j=i;

    while(j>=10){
      if(j%10==3){
        std::cout << " "<<i;
        break;
      }else{
        j=j/10;
      }
    }
    if(j==3){
      std::cout << " "<<i;
    }


  }
  std::cout  << '\n';

}

Measured memory_bytes: 3096
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cmath>

using namespace std;

int main() {
    int a, b, k;
    cin >> a >> b >> k;
    int cnt = 0, i;
    for (i = 100; i >= 1; i--) {
        if (a%i == 0 && b%i == 0) {
            cnt++;
        }
        if (cnt == k) {
            break;
        }
    }
    cout << i << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>
#include<bitset>
#include<cassert>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}



int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	map<int, int> tyofuku;
	vector<int> x,b;
	rep(i, n) {
		tyofuku[a[i]] += 1;
	}
	for (auto p:tyofuku){
		b.push_back(p.first);
		if (p.second == 1)
			x.push_back(p.first);
	}
	int ans = 0;
	int max = 1e6 + 5;
	vector<int> dp(max, 0);
	rep(i,b.size()){
		for (int j = b[i]; j <= max; j += b[i]){
			dp[j] += 1;
		}
	}
	rep(i, x.size())
	{
		if (dp[x[i]] == 1){
			ans++;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 18916
import sys
readline = sys.stdin.readline

N,K = map(int, readline().split())
A = list(map(int,readline().split()))
DIV = 10 ** 9 + 7

# dp[i][j] : i人目までにj個配るときの場合の数
# 数式変形で以下
# dp[i][j] = dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - Ai-1 - 1]

dp = [[0] * (K + 1) for i in range(N + 1)]
for i in range(N + 1):
  dp[i][0] = 1 # 0個配る方法は常に1通り
  
for i in range(1, N + 1):
  for j in range(1, K + 1):
    if j - A[i - 1] - 1 >= 0:
      dp[i][j] = (dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - A[i - 1] - 1]) % DIV
    else:
      dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % DIV
      
print(dp[N][K])

Measured memory_bytes: 146756
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef pair<ll,P> T;
typedef pair<int,ll> Pl;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
int N,M,X;
int H[100100];
struct edge{
	int to;
	ll cost;
	edge(int to,ll cost):to(to),cost(cost){}
};
vector<edge> g[100100];
bool used[100100];
Pl dist[100100];
int main(){
	scanf("%d %d %d",&N,&M,&X);
	for(int i=0;i<N;i++)scanf("%d",&H[i]);
	for(int i=0;i<M;i++){
		int a,b,t;
		scanf("%d %d %d",&a,&b,&t);
		a--;b--;
		g[a].pb(edge(b,t));
		g[b].pb(edge(a,t));
	}
	priority_queue<T,vector<T>,greater<T> > q;
	q.push(T(0,P(0,X)));
	while(!q.empty()){
		T a = q.top();
		q.pop();
		ll cost = a.fi;
		int v = a.sec.fi,h = a.sec.sec;
		if(used[v])continue;
		//printf("%lld %d %d\n",cost,v,h);	
		dist[v]=Pl(h,cost);
		used[v]=true;
		for(int i=0;i<g[v].size();i++){
			edge e = g[v][i];
			if(used[e.to])continue;
			ll add;
			if(h<e.cost){
				if(H[v]>=e.cost){
					add = e.cost-h+e.cost;
					q.push(T(cost+add,P(e.to,0)));
				}
			}else if(h>e.cost+H[e.to]){
				add = h-e.cost-H[e.to]+e.cost;
				q.push(T(cost+add,P(e.to,H[e.to])));
			}else{
				add = e.cost;
				q.push(T(cost+add,P(e.to,h-e.cost)));
			}
		}
	}
	//for(int i=0;i<N;i++)printf("%d %lld\n",dist[i].fi,dist[i].sec);
	if(!used[N-1])printf("-1\n");
	else printf("%lld\n",dist[N-1].sec+H[N-1]-dist[N-1].fi);
	return 0;
}

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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
#define endl        "\n"
#define repp(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a,b) 	for(int i=a;i<=b;i++)
#define IOS         ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int N=1e5 + 5;
const int M=1e9 + 7;

int32_t main()
{
	IOS;
	//memset(dp,-1,sizeof(dp));
	int n;
	cin >> n;
	rep(i,1,9)
	{
		rep(j,1,9)
		{
			if((i*j)==n)
			{
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
}


Measured memory_bytes: 256