akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
template<typename T> using v = vector<T>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
void dump_debug(T list) {
#ifdef MY_DEBUG
    each(e, list) cout << e << " ";
    printf("\n");
#endif
}

inline ll inl() {
    ll x;
    cin >> x;
    return x;
}

inline string ins() {
    string x;
    cin >> x;
    return x;
}

bool is_int(ll i) {
    ll s = sqrt(i) + 0.5;
    return s * s == i;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        ll n, d;
        cin >> n >> d;

        vvl x(n, vl(d));
        rep(i, n) rep(j, d) cin >> x[i][j];

        ll ans = 0;
        rep(i, n - 1) {
            for (long long j = i + 1; j < n; ++j) {
                ll cal = 0;
                rep(k, d) {
                    ll s = x[i][k] - x[j][k];
                    cal += s * s;
                }
                ans += is_int(cal);
            }
        }
        cout << ans << endl;
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 256
import numpy as np
import sys

n = int(next(sys.stdin))
a = np.array(list(map(int, next(sys.stdin).split())))
j = np.arange(n) + 1

if np.any(a.sum() % j.sum() > 0):
    print('NO')
    exit()

s = a.sum() // j.sum()
k = s - (a[1:] - a[:-1])
if np.all(k >= 0) and np.all(k % n == 0):
    print('YES')
else:
    print('NO')


Measured memory_bytes: 31636
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define INF 0x3f3f3f3f
using namespace std;
int main()
{
	int K,X;
	scanf("%d%d",&K,&X);
	for(int i=X-K+1;i<=X+K-1;i++)
	{
		printf("%d ",i);
	}
	return 0;
}

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

using namespace std;

template<typename T> bool chmax( T &a, const T b ) { if ( a <= b ) { a = b; return ( true ); } else { return ( false ); } }
template<typename T> bool chmin( T &a, const T b ) { if ( a >= b ) { a = b; return ( true ); } else { return ( false ); } }

using ll = long long;
using Pint = pair<int, int>;
using Pll  = pair<ll, ll>;

#define eb emplace_back
#define pb push_back
#define mp make_pair

#define F first
#define S second

#define popcnt __builtin_popcountll

#define rep( i, n ) for ( ll i = 0; i < (ll)( n ); ++i )
#define reps( i, n ) for ( ll i = 1; i <= (ll)( n ); ++i )
#define rrep( i, n ) for ( ll i = (ll)( ( n ) - 1 ); i >= 0; --i )
#define rreps( i, n ) for ( ll i = (ll)( ( n ) ); i > 0; --i )
#define arep( i, v ) for ( auto &&i : ( v ) )

#define ALL( c ) ( c ).begin(), ( c ).end()
#define RALL( c ) ( c ).rbegin(), ( c ).rend()
#define UNIQUE( c ) ( c ).erase( unique( ( c ).begin(), ( c ).end() ), ( c ).end() )

template<typename T = ll> constexpr T MAX = numeric_limits<T>::max();
template<typename T> T gcd( const T a, const T b ) { return ( b ? gcd( b, a % b ) : a ); }
template<typename T> T lcm( const T a, const T b ) { return ( a / gcd( a, b ) * b ); }


int main()
{
	ll n; cin >> n;
	vector<ll> a( n ), b( n );
	map<ll, ll> ma, mb;
	rep( i, n ) { cin >> a[i]; ma[a[i]]++; }
	rep( i, n ) { cin >> b[i]; mb[b[i]]++; }
	reps( i, n ) if ( ma[i] + mb[i] > n ) { cout << "No" << endl; return ( 0 ); }

	vector<ll> c( n + 1 ), d( n + 1 );
	reps( i, n )
	{
		c[i] = c[i - 1] + ma[i];
		d[i] = d[i - 1] + mb[i];
	}

	ll sft = -1;
	reps( i, n ) chmax( sft, c[i] - d[i - 1] );

	cout << "Yes" << endl;
	rotate( b.begin(), b.begin() + ( n - sft ), b.end() );
	rep( i, n ) cout << b[i] << " \n"[i == n - 1];

	return ( 0 );
}


Measured memory_bytes: 34016
import bisect
n = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A.sort()
B.sort()
C.sort()
# print(A)
# print(B)
# print(C)
ans = 0
for b in B:
    aindex = bisect.bisect_left(A,b)
    cindex = bisect.bisect_right(C,b)
    # print(aindex,cindex)
    ans += aindex*(n-cindex)
print(ans)

Measured memory_bytes: 23360
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
			　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <iostream>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <memory>
#include <iomanip>
#include <type_traits>

#define rep(i, n) for(Int (i) = 0; (i) < (n); ++(i))
#define all(n) std::begin(n), std::end(n)
#define debug(var) std::cout << #var << ": " << var << "\n"
using Int = int64_t;
constexpr Int INF = INT_MAX;
constexpr Int mod = 1e9 + 7;


void init() {
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
}

void calc() {

	std::string S; std::cin >> S;
	if (S == "ABC")std::cout << "ARC";
	else std::cout << "ABC";

}


int main() {

	init();
	calc();

	return 0;
}

Measured memory_bytes: 3652
N,M = list(map(int,input().split()))
ab = [list(map(int,input().split())) for _ in range(N)]

ab.sort(key=lambda ab:(ab[0]))
s = 0
cnt = 0
for i in range(M):
    s += ab[cnt][0]
    if ab[cnt][1]>1:
        ab[cnt][1] -= 1
    else:
        cnt += 1
print(s)


Measured memory_bytes: 29028
#include<bits/stdc++.h>
using namespace std;
int k,a,b; 
int main(){
	scanf("%d%d%d",&k,&a,&b);
	for(int i=1;i*k<=b;i++){
		if(i*k>=a){
			printf("OK\n");
			return 0;
		}
	}
	printf("NG\n");
	return 0;
}


Measured memory_bytes: 3760
#include <bits/stdc++.h>
//#pragma comment(linker, "/STACK:102400000,102400000")
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <limits.h>
#include <math.h>
#include <algorithm>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <string>
#include <vector>
#include <bitset>
#include <functional>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef double db;
typedef long double ldb;
#define rep(i,a,b) for(i=a;i<b;i++)
#define repu(i,a,b) for(i=a;i<=b;i++)
#define repd(i,a,b) for(i=a;i>=b;i--)
#define repc(i,a,b,c) for(i=a;i<b;i+=c)
#define repcu(i,a,b,c) for(i=a;i<=b;i+=c)
#define repcd(i,a,b,c) for(i=a;i>=b;i-=c)
#define FIN freopen("input.in","r",stdin)
#define FOUT freopen("output.out","w",stdout)
#define CC(a) memset(a,0,sizeof(a))
#define MST(a,b) memset(a,b,sizeof(a))
#define PII pair<int,int>
#define PLL pair<long long,long long>
#define VI vector<int>
#define VL vector<long long>
#define VII vector<PII>
#define VLL vector<PLL>
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back
#define pf push_front
 
template<typename T>inline void gn(T &x){
	x=0;T f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
template<typename T>inline void gt(T x){
	if(!x)return;
	gt(x/10);putchar(x%10+'0');
}
 
const LL MAXN=2e6+10;
LL t,n,m,ans,cnt;
LL MOD=1e9+7,inf=1e10;
db eps=1e-5;

LL f[MAXN];
string s;

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);
	LL i,j,k,l,ca=0;
	cin>>s>>n;
	l=s.size();
	repu(i,0,l-1){
		if(s[i]=='a')continue;
		m='z'-s[i]+1;
		if(n>=m)n-=m,s[i]='a';
	}
	if(n=n%26)s[l-1]=(s[l-1]-'a'+n)%26+'a';
	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 592
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
int n,m;
int a,b;
vector<int> G[100001];
int used[100001];
int main(){
  cin >> n >> m;
  for(int i=0;i<m;i++){
    cin >> a >> b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  deque<int> dq;
  dq.push_front(1);
  used[1]=1;
  int left=1,right=1;
  while(1){
    int f=0;
    for(int i=0;i<G[left].size();i++){
      int v=G[left][i];
      if(used[v]==0){
	dq.push_back(v);
	left=v;
	used[v]=1;
	f=1;
      }
    }
    if(f==0)break;
  }
  while(1){
    int f=0;
    for(int i=0;i<G[right].size();i++){
      int v=G[right][i];
      if(used[v]==0){
	dq.push_front(v);
	right=v;
	used[v]=1;
	f=1;
      }
    }
    if(f==0)break;
  }
  cout << dq.size() << endl;
  for(deque<int>::iterator itr=dq.begin();itr!=dq.end();itr++){
    cout << *itr << " ";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 6912
import java.math.BigDecimal;
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

    int MOD = 998244353;

    public static void main(String[] args) {
        new Main().run();
    }

    void run() {

        long a = sc.nextLong();
        double b = sc.nextDouble();
        long lb = Math.round(b*100);

        System.out.println(a*lb/100);
    }
}


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

int main() {
	ll n, c, k;
	cin >> n >> c >> k;
	vector<ll>t(n); //
	for (int i = 0; i < n; i++)cin >> t.at(i);
	sort(t.begin(), t.end());

	ll ans = 0;
	ll vac = c;
	ll ang = 0;
	for (int i = 0; i < n; i++) {
		ll x = t.at(i);
		if (ang < x) {
			ans++;
			vac = c - 1;
			ang = x + k;
		}
		else {
			if (vac == 0) {
				ans++;
				vac = c - 1;
				ang = x + k;
			}
			else vac--;
		}
		//cout << ans << " " << vac << " " << ang << endl;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <unistd.h>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <cmath>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 1<<30
#define LLINF LLONG_MAX/3
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,n) for(int i=a;i<n;i++)
#define UP(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
using ll = long long;
using Pll = pair<ll,ll>;
using Pii = pair<int,int>;
using Pdd = pair<double,double>;
using dcomplex = complex<double>;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
ll gcd(ll a,ll b){int c=max(a,b);int d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}
ll fact(ll a){ll b=1;for(ll i=1;i<=a;i++)b*=i;return b;}
ll power(ll x,ll n){ll a=1;REP(i,n)a*=x;return a;}
ll nbit(ll n){ll ret=0;while(n){n&=n-1;++ret;} return ret;}
double inf() {return std::numeric_limits<double>::infinity();}

ll N, Z, W;
ll a[2010];

int main(int argc, char const *argv[]) {
  cin >> N >> Z >> W;
  REP(i,N) cin >> a[i];
  if(N==1) cout << abs(a[0]-W) << endl;
  else cout << max(abs(a[N-1]-W),abs(a[N-1]-a[N-2])) << endl;
  return 0;
}


Measured memory_bytes: 256
/*#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>*/
#include <bits/stdc++.h>

using namespace std;
//using namespace __gnu_pbds;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define FOR(i, a, b) for (int i=a; i<b; i++)
#define F0R(i, a) for (int i=0; i<a; i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

const int MOD = 1000000007;
double PI = 4*atan(1);

int N, x, p[200001], visit[200001], num[200001], vnum[200001];
int incycle[200001];
set<int> uni[200001];
vi child[200001], cycle;

void dfs(int node, int po) {
	if (visit[node] == 0) {
		visit[node] = po;
		dfs(p[node],po);
	} else if (visit[node] == po) x = node;
}

void solve(int x) {
	for (int y: child[x]) {
		solve(y);
		uni[x].insert(num[y]);
	}
	for (int i = 0;;++i) {
		if (uni[x].find(i) == uni[x].end()) {
			num[x] = i;
			return;
		}
	}
}

bool test1() {
	int tmp[200001];
	tmp[0] = num[cycle[0]];
	FOR(i,1,cycle.size()) {
		if (tmp[i-1] == num[cycle[i]]) tmp[i] = vnum[cycle[i]];
		else tmp[i] = num[cycle[i]];
	}
	int t = -1;
	if (tmp[cycle.size()-1] == num[cycle[0]]) t = vnum[cycle[0]];
	else t = num[cycle[0]];
	return (t == tmp[0]);
}

bool test2() {
	int tmp[200001];
	tmp[0] = vnum[cycle[0]];
	FOR(i,1,cycle.size()) {
		if (tmp[i-1] == num[cycle[i]]) tmp[i] = vnum[cycle[i]];
		else tmp[i] = num[cycle[i]];
	}
	int t = -1;
	if (tmp[cycle.size()-1] == num[cycle[0]]) t = vnum[cycle[0]];
	else t = num[cycle[0]];
	return (t == tmp[0]);
}

int main() {
	cin >> N;
	FOR(i,1,N+1) cin >> p[i];
	FOR(i,1,N+1) dfs(i,i);
	
	cycle.pb(x); incycle[x] = 1;
	for (int cur = p[x]; cur != x; cur = p[cur]) {
		cycle.pb(cur);
		incycle[cur] = 1;
	}
	FOR(i,1,N+1) if (!incycle[i]) child[p[i]].pb(i);
	FOR(i,1,N+1) vnum[i] = -1;
	
	for (int x: cycle) {
		solve(x);
		for (int i = num[x]+1;;++i) if (uni[x].find(i) == uni[x].end()) {
			vnum[x] = i;
			break;
		}
	}
	if (test1() || test2()) {
		cout << "POSSIBLE";
		return 0;
	}
	cout << "IMPOSSIBLE";
}

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

int main() {
  int x;
  cin >> x;
  if (x >= 30)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

int main() {
    int N;
    int M;

    scanf("%d", &N);
    scanf("%d", &M);
    int *k = malloc((N + 1) * sizeof(int));
    int **s = malloc((M + 1) * sizeof(int*));
    for (int i = 1; i <= M; i++) {
        scanf("%d", &k[i]);
        s[i] = malloc((k[i] + 1) * sizeof(int));
        for (int j = 1; j <= k[i]; j++) {
            scanf("%d", &s[i][j]);
        }
    }

    int *p = malloc((M + 1) * sizeof(int));
    for (int i = 1; i <=M; i++) {
        scanf("%d", &p[i]);
    }

    // N = 2
    int ans = 0;
    for (int i = 0; i < (1 << N); i++) {
        int *state = malloc((N + 1) * sizeof(int));
        for (int j = 1; j <= N; j++) {
            state[j] = ((i >> (j - 1)) % 2 == 1);
        }
        int all_on = 1;
        for (int l = 1; l <= M; l++) {
            int sum_on = 0;
            for (int o = 1; o <= k[l]; o++) {
                sum_on += state[s[l][o]];
           }
            if (p[l] != (sum_on % 2)) {
                all_on = 0;
                break;
            }
        }
        if (all_on == 1)
            ans++;
    }

    printf("%d", ans);

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.Comparator;
public class Main{
    public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    Integer [] a = new Integer[N];
    for(int i = 0;i<N;i++){
      a[i] = sc.nextInt();
    }
    Arrays.sort(a, Comparator.reverseOrder());
    long sum = a[0];

    if(N%2==0){
      for(int i = 1;i<N/2;i++){
        sum += (long)a[i]*2;
        }
    }else{
      int tmp = 0;
      for(int i = 1;i<N/2;i++){
        sum += (long)a[i]*2;
        tmp = i;
      }
        sum += (long)a[tmp+1];
    }
    System.out.println(sum);
  }
}

Measured memory_bytes: 63132
#include<iostream>
#include<fstream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<climits>
#include<set>
#include<map>
#include<cmath>
#include<iomanip>
#include<iterator>
#include<queue>
#include<stack>
#include<cctype>
#include<deque>

//by Skeef79

//НЕ ИСПОЛЬЗУЙ endl, есть свой en!!
//Иногда нужно не просто придумывать решение, а метматически расписать систему уравнений
//для задач с cin/cout в большом кол-ве - gnu , иначе вижуалки. А ваще пробуй два если TL

//для интерактивок - cout<<flush
// cin.tie и sync_with_stdio убирать для интерактивок

typedef long long ll;
typedef long double ld;

#define pb push_back
#define en '\n'
#define for0(i,n) for(int i = 0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(),(x).rend()
#define vec vector
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

const int INF = 1e9 + 1233;
const ll LINF = 1e18 + 1233;

template<typename T> void print(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
}

template <typename T> void Input(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cin >> a[i];
}

const int NMAX = 2 * 100000;
ll a[NMAX];
ll t[4 * NMAX];
ll tAdd[4 * NMAX];

void push(int v, int vl, int vr)
{
	if (tAdd[v] != 0)
	{
		t[v] += tAdd[v] * (ll(vr - vl + 1));
		if (vl != vr)
		{
			tAdd[2 * v + 1] += tAdd[v];
			tAdd[2 * v + 2] += tAdd[v];
		}

		tAdd[v] = 0;
	}
}

ll query(int v, int vl, int vr, int l, int r)
{
	push(v, vl, vr);

	if (r < vl || vr < l)
		return 0;
	if (vl >= l && vr <= r)
		return t[v];
	int vm = vl + (vr - vl) / 2;
	ll ql = query(2 * v + 1, vl, vm, l, r);
	ll qr = query(2 * v + 2, vm + 1, vr, l, r);
	return ql + qr;
}

void modify(int v, int vl, int vr, int l, int r, ll val)
{
	push(v, vl, vr);
	if (r < vl || vr < l)
		return;
	if (vl >= l && vr <= r)
	{
		tAdd[v] = val;
		push(v, vl, vr);
		return;
	}

	int vm = vl + (vr - vl) / 2;
	modify(2 * v + 1, vl, vm, l, r, val);
	modify(2 * v + 2, vm + 1, vr, l, r, val);
	t[v] = t[2 * v + 1] + t[2 * v + 2];
}

int timer = 0;
vector<int> tin, tout;
vector<vector<int>> e;
vector<int> obhod;

void dfs(int v, int p = -1)
{
	tin[v] = timer++;
	
	obhod.pb(v);

	for (auto to : e[v])
	{
		if (to == p)
			continue;
		dfs(to, v);
	}

	tout[v] = timer;
}

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

	int n;
	cin >> n;
	multiset<ld> st;
	for (int i = 0; i < n; i++)
	{
		ld x;
		cin >> x;
		st.insert(x);
	}

	while (st.size() > 1)
	{
		auto it = st.begin();
		ld fst = *it;
		it++;
		ld sec = *it;
		st.erase(st.begin());
		st.erase(st.begin());
		st.insert((fst + sec) / 2);
	}

	cout << *st.begin();

}





Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define sz(v) (int)v.size()
#define pb push_back

using namespace std;
int n,k;
int main(){
    cin >> n >> k;
    if(n%k) cout << 1 << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
bool compare( pair<ll,ll> a , pair<ll,ll> b)
{
    return (a.first - a.second) < (b.first - b.second);
}
int main()
{
    ll n;
    cin>>n;
    ll a[n] , b[n];
    ll suma = 0 ,   sumb = 0;
    pair<ll , ll > arr[n];
    set<ll> s;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        suma += a[i];
        s.insert(a[i]);
        arr[i].first = a[i];
    }
    for(int i=0;i<n;i++)
    {
        cin>>b[i];
        sumb += b[i];
        arr[i].second = b[i];
    }
    if( sumb > suma)
    {
        cout<<-1;
        return 0;
    }
    sort( arr,arr +n, compare );
    ll ans =0;
    ll l =0 , r= n-1;
    while( l<r)
    {
        if( arr[l].first >= arr[l].second ) {
            l++;
            continue;
        }
        if( arr[l].first < arr[l].second )
        {
            ll val1 = arr[l].second - arr[l].first;
            ll val2 = arr[r].first - arr[r].second ;
            if( val2 > val1)
            {
                arr[r].first -= val1;
                arr[l].first += val1;
                l++;
                ans++;
            }
            else if( val1 > val2)
            {
                arr[r].first -= val2;
                arr[l].first += val2;
                ans++;
                r--;
            }
            else if( val1 == val2)
            {
                arr[r].first -= val2;
                arr[l].first += val2;
                ans += 2;
                r--;
                l++;
            }
        }
    }
    if(ans)
cout<<ans+1;
   else cout<<ans;

}

Measured memory_bytes: 11332
#include <iostream>
#include <vector>
#include <string>
#include <set>

using namespace std;

int main(){
  	string s;
  	string abc = "abcdefghijklmnopqrstuvwxyz";
  	cin >> s;
  	vector<int> num(26);
  	int N = s.size();
  	for(int i=0;i<N;i++){
      	int index = abc.find_first_of(s[i]);
      	num[index] = 1;
    }
  	int i=0;
  	for(i=0;i<26;i++){
      	if(num[i]==0) break;
    }
  	if(i == 26) cout << "None" << endl;
    else cout << abc[i] << endl;
}

Measured memory_bytes: 3740
n,m,x=map(int,input().split())
a=[[0]*(m+1)]*n
for i in range(n):
    a[i]=list(map(int,input().split()))

#print(a[0][1]):
pattern=[]
for i in range(2**n):
    tmp = [False]*n
    for j in range(n):
        if i >> j & 1:
            tmp[j] = True
    pattern.append(tmp)

#print(pattern)
kaisu=len(pattern)
ans=10**9
for i in range(kaisu):
    List=[0]*(m+1)
    for j in range(n):
        if (pattern[i][j]==True):
            for l in range(m+1):
                List[l]+=a[j][l]
    flag=0
   # print(List)
    for k in range(1,m+1):
        if (List[k]<x):
            flag=1
            break
    if (flag==0):
        ans=min(ans,List[0])

if (ans<10**9):
    print(ans)
else:
    print(-1)

Measured memory_bytes: 9668
#include <bits/stdc++.h>
#define ll long long
#define all(x) begin(x), end(x)
#define range(x) begin(x), begin(x)
#define what(x) cout << #x << ": " << x << '\n'
#define print(x) for (auto &el: x) cout << el << ' '; cout << '\n'
using namespace std;
 
template<typename S, typename T>
ostream& operator <<(ostream &os, pair<S, T> &m) { 
    os << '[' << m.first << " " << m.second << ']'; 
    return os; 
}

int ans[100010];

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

    int n;
    cin >> n;

    for (ll i = 1; i <= 100; ++i) {
        for (ll j = 1; j <= 100; ++j) {
            for (ll k = 1; k <= 100; ++k) {
                ll val = i * i + j * j + k * k + i * j + j * k + k * i;
                if (val <= 10000LL)
                    ans[val]++;
            }
        }
    }

    for (int i = 1; i <= n; ++i) cout << ans[i] << endl;
    
    

    return 0;
}

Measured memory_bytes: 3672
n,m = map(int,input().split())
tr = [ 10 ** 18 for _ in range(2**n) ]
tr[0] = 0
key = []
for _ in range(m):
  cost,b = map(int,input().split())
  raw = list(map(int,input().split()))
  get = 0
  for i in range(b):
    get += 2 ** (raw[i]-1)
  key.append([get,cost])
#print(key)
key.sort()
#print(key)
for j in range(2**n):
  for k in range(m):
    get,cost = key[k]
    tr[get | j] = min(tr[get | j],cost+tr[j])
    #print(tr,get,j,get | j)
    #print(get^j,get,j)
  #print(tr)
if tr[2**n-1] == 10 ** 18:
  print(-1)
else:
  print(tr[2**n-1])

Measured memory_bytes: 45672
// abc174_d
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <type_traits>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

template <typename A, typename B> bool cmin(A &a, const B &b) {
  return a > b ? (a = b, true) : false;
}
template <typename A, typename B> bool cmax(A &a, const B &b) {
  return a < b ? (a = b, true) : false;
}
const double PI = acos(-1);
const double EPS = 1e-9;
int inf = sizeof(int) == sizeof(long long) ? 2e18 : 1e9 + 10;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
  int N, r = 0, ans = 0;
  cin>>N;
  string C;
  cin>>C;
  for (int i = 0, cnt = (int)C.size(); i < cnt; ++i) {
    if (C[i] == 'R') r++;
  }
  for (int i = 0; i < r; ++i) {
    if (C[i] != 'R') ans++;
  }

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


Measured memory_bytes: 3756
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll MOD = 1e9 + 7;
ll A,B,H, N, M, L, K, W, X, Y, Z;
ll ans = 0;
int main() {
	cin >> K >> A >> B;
	if (B - A > 2) {
		K -= A - 1;
		ans = A + (B - A)*(K / 2);
		if (K & 1)ans++;
	}
	else ans = K + 1;
	cout << ans << endl;
}


Measured memory_bytes: 256
#pragma comment(linker, "/STACK:512000000")
#define _CRT_SECURE_NO_WARNINGS
//#include "testlib.h"
#include <bits/stdc++.h>
using namespace std;

#define all(a) a.begin(), a.end()
typedef long long li;
typedef long double ld;
void solve(bool);
void precalc();
clock_t start;
int main() {
#ifdef AIM
  freopen("/home/alexandero/ClionProjects/ACM/input.txt", "r", stdin);
  //freopen("/home/alexandero/ClionProjects/ACM/output.txt", "w", stdout);
  //freopen("out.txt", "w", stdout);
#else
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
#endif
  start = clock();
  int t = 1;
  cout.sync_with_stdio(0);
  cin.tie(0);
  precalc();
  cout.precision(10);
  cout << fixed;
  //cin >> t;
  int testNum = 1;
  while (t--) {
    //cout << "Case #" << testNum++ << ": ";
    //cerr << testNum << endl;
    solve(true);
    //cerr << testNum - 1 << endl;
  }
  cout.flush();
#ifdef AIM1
  while (true) {
      solve(false);
  }
#endif

#ifdef AIM
  cerr << "\n\n time: " << (clock() - start) / 1.0 / CLOCKS_PER_SEC << "\n\n";
#endif

  return 0;
}

//BE CAREFUL: IS INT REALLY INT?

template<typename T>
T binpow(T q, T w, T mod) {
  if (!w)
    return 1 % mod;
  if (w & 1)
    return q * 1LL * binpow(q, w - 1, mod) % mod;
  return binpow(q * 1LL * q % mod, w / 2, mod);
}

template<typename T>
T gcd(T q, T w) {
  while (w) {
    q %= w;
    swap(q, w);
  }
  return q;
}
template<typename T>
T lcm(T q, T w) {
  return q / gcd(q, w) * w;
}

void precalc() {

}

template<typename T>
void relax_min(T& cur, T val) {
  cur = min(cur, val);
}

template<typename T>
void relax_max(T& cur, T val) {
  cur = max(cur, val);
}

//#define int li
//const int mod = 1000000007;


void solve(bool read) {
  int H, W, h, w;
  cin >> H >> W >> h >> w;
  if (H % h == 0 && W % w == 0) {
    cout << "No\n";
    return;
  }
  cout << "Yes\n";
  const int MAGIC = 1000;
  int sum = 0;
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      int val = MAGIC;
      if (i % h == h - 1 && j % w == w - 1) {
        val = -(w * h - 1) * MAGIC - 1;
      }
      cout << val << " ";
      sum += val;
    }
    cout << endl;
  }
  assert(sum > 0);

}

Measured memory_bytes: 1664
# -*- coding: utf-8 -*-
s = input()
k = int(input())

l = len(s)
ones = 0
i = 0
while s[i] == '1':
    ones += 1
    i += 1
    if i == l:
        break

if ones >= k:
    print('1')
else:
    print(s[i])


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

int a[55], b[55], c[55], d[55];

int main() {
  int n, m; cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> a[i] >> b[i];
  for (int i = 1; i <= m; i++) cin >> c[i] >> d[i];
  
  for (int i = 1; i <= n; i++) {
    int e = 1;
    for (int j = 2; j <= m; j++)
      if (abs(c[j] - a[i]) + abs(d[j] - b[i]) <
          abs(c[e] - a[i]) + abs(d[e] - b[i]))
        e = j;
    cout << e << endl;
  }
}

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

using ll = long long;
// #define int long long

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))

bool IsPrime(int);
int Factorial(int);
int NPR (int, int);
int NCR (int, int);

/***** MAIN *****/
signed main() {
  int a,b,c;
  cin >> a >> b >> c;
  int total = a+b+c;
  if(total >= 22) {
    cout << "bust";
  } else {
    cout << "win";
  }
  cout << "\n";
  return 0;
}
/***** MAIN *****/

bool IsPrime(int a) {
  if(a <= 1) return false;
  if(a == 2) return true;
  if(a%2 == 0) return false;
  for(int i = 3; i*i <= a; i+=2) {
    if(a%i==0) return false;
  }
  return true;
}

int Factorial(int n){
  int ans = 1;
  while(n > 1){
    ans *= n;
    --n;
  }
  return ans;
}

int NPR(int n, int r) {
  return Factorial(n)/Factorial(n-r);
}

int NCR (int n, int r){
  return NPR(n,r)/Factorial(r);
}

Measured memory_bytes: 256
MOD = 10 ** 9 + 7

n = int(input())
s = list(input())
s2 = list(input())

array = []

i = 0
while i < n:
	if i == n - 1:
		array.append("t")
		i += 1
	elif s[i] != s[i + 1]:
		array.append("t")
		i += 1
	else:
		array.append("y")
		i += 2

if array[0] == "t":
	ans = 3
else:
	ans = 6

if len(array) == 1:
	print(ans)
else:
	for i in range(1, len(array)):
		if array[i-1] == "t":
			ans = (ans * 2) % MOD
		elif array[i] == "y":
			ans = (ans * 3) % MOD

	print(int(ans))

Measured memory_bytes: 3064
t=13
S=input()
d=[0]*t
d[0]=1
for i in range(len(S)):
  n=[0]*t
  for j in range(t):
    for k in range(10):
      if S[i]=='?' or int(S[i])==k:n[(10*j+k)%t]+=d[j]
  for j in range(t):d[j]=n[j]%(10**9+7)
print(d[5])

Measured memory_bytes: 43900
#include "bits/stdc++.h"
using namespace std; 
#define LIM 1000003

#define M 1000000007
#define inf 99999999999999999LL	//long long inf
typedef long long ll;

#define sc(x) scanf("%d",&x);
#define sc2(x,y) scanf("%d%d",&x,&y);
#define sc3(x,y,z) scanf("%d%d%d",&x,&y,&z);
#define scl(x) scanf("%lld",&x);
#define scl2(x,y) scanf("%lld%lld",&x,&y);
#define scl3(x,y,z) scanf("%lld%lld%lld",&x,&y,&z);

#define pb push_back
#define mp make_pair
#define fi first
#define se second 
ll power(ll x,ll y,ll z) {	ll ret = 1;	while(y > 0) {	if(y & 1) ret = (ret*x)%z;x = (x*x)%z;y >>= 1;}return ret;}


#define debug(x) cerr<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
#define debug4(x,y,z,a) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#a<<" :: "<<a<<"\n";




int n, k ;
int f(int x) {
	if( x >=1 && x <= 12)
		return 1;
	return 0;
}
int main() {
	int i, j, t;
	string s;
	cin >> s ;
	int a = s[0]-'0' ;
	int b = s[1]-'0' ;
	int c = s[2]-'0' ;
	int d = s[3]-'0' ;
	int emp = a*10 + b ;
	int temp = c*10+d ;
	debug2(emp, temp);
	int xx = f(emp) ;
	int yy = xx ;
	xx += f(temp) ;

	debug2(yy, xx) ;
	if(xx == 0) {
		cout << "NA" << endl ;
	}
	else if(xx == 1) {
		if(yy)
			cout << "MMYY" << endl ;
		else
			cout << "YYMM" << endl ;
 	
	}
	else {
		cout << "AMBIGUOUS" << endl ;
	}
	return 0;
}




Measured memory_bytes: 256
let () = Scanf.scanf "%d %d" (
        fun a b -> 
                if b = 1 then
                        0
                else if b < a then
                        1
                else if (b - a) mod (a - 1) = 0 then
                        ((b - a) / (a - 1)) + 1
                else
                        ((b - a) / (a - 1)) + 2
) |> Printf.printf "%d\n"


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

using namespace std;

int main(){
	string s;
	cin>>s;
	int n = s.length(), cnt = 0;
	for (int i = 0; i < n/2; ++i){
		if(s[i] != s[n-i-1]) cnt++;
	}
	printf("%d", cnt);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,K,R,S,P; string T; cin >> N >> K >> R >> S >> P >> T;
    ll ans=0;
    rep(i,N){
        if (i<K){
            if (T[i]=='r') ans+=P;
            if (T[i]=='s') ans+=R;
            if (T[i]=='p') ans+=S;
        }
        else {
            if (T[i]!=T[i-K]){
                if (T[i]=='r') ans+=P;
                if (T[i]=='s') ans+=R;
                if (T[i]=='p') ans+=S;
            }
            else {
                vector<bool> a(3,false);
                if (T[i-K]=='r') a[0]=true;
                if (T[i-K]=='s') a[1]=true;
                if (T[i-K]=='p') a[2]=true;
                if (i+K<N&&T[i+K]=='r') a[0]=true;
                if (i+K<N&&T[i+K]=='s') a[1]=true;
                if (i+K<N&&T[i+K]=='p') a[2]=true;
                rep(j,3){
                    if (!a[j]){
                        if (j==0) T[i]='r';
                        if (j==1) T[i]='s';
                        if (j==2) T[i]='p';
                        break;
                    }
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
import java.util.*;

public class Main{
  static int[] ans;
  static Map<Integer, Integer> map;
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    String S = sc.nextLine();
    int K = Integer.parseInt(sc.nextLine())-1;
    
    char c = S.charAt(K);
    char[] C = new char[N];
    for(int i = 0; i < N; i++){
      if(S.charAt(i) == c){
        C[i] = c;
      }else{
        C[i] = '*';
      }
    }
    
    System.out.println(new String(C));
  }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
typedef long long lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int N;
	int next = 1;
	int ans = -1;
	cin >> N;
	vector<int> a(N, 0);

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

	for (int i = 0; i < N; i++)
	{
		next = a[next - 1];
		if (next == 2)
		{
			ans = i + 1;
			break;
		}
	}
	cout << ans << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 640
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let a: usize = input();
    let b: usize = input();
    let s: String = input();

    let mut ok = true;
    if s.len() != a + b + 1 {
        ok = false;
    }
    for (i, c) in s.chars().enumerate() {
        if (i < a && !c.is_digit(10)) || (i == a && c != '-') || (i > a && !c.is_digit(10)) {
            ok = false;
        }
    }

    println!("{}", if ok { "Yes" } else { "No" });
}


Measured memory_bytes: 4352
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		
			int n=Integer.parseInt(br.readLine().trim());	
			String[] s=br.readLine().split(" ");
			int[] a=new int[n];
			for(int i=0;i<n;i++)
			{
				a[i]=Integer.parseInt(s[i].trim());
			}
			
			algo(a,n);
		
	}
	
	public static void algo(int[] a,int n)
	{
		int xor=0;
		for(int x:a) {
			xor=xor^x;
		}
		StringBuffer sb=new StringBuffer();
		for(int x:a) {
			int y=xor^x;
			sb.append(y+" ");
		}
		System.out.println(sb.toString());
		
	}
	

}


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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = 1e18;
//const ll MOD = 1000000007;
const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair


int main() {
  int n;
  cin >> n;
  int sum = 0;
  int i;
  for (i = 1; i <= n; i++) {
    sum += i;
    if (sum >= n) break;
  }
  for (; i > 0; i--) {
    if (i <= n) {
      cout << i << endl;
      n -= i;
    }
  }
  
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define INF 1e9
#define rep(i, n) for(int i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<int> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<VL> VVL;
typedef pair<int, int> PII;
typedef map<int, int> MP;   //MP a;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
template <class T>  // chmax(max, a);
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> //chmin(min,a)
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}

ll Max=-1000000000,Min=1e9+1;
       
int main(){
    ll x=0,y=0,z=0,n,m,h,k=0,w,sum2=0,ans=0;
    string s,t;
    bool f=true;
    VI a(5);
    cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];
    rep(i,5){
        if(a[i]>=100){
            m = a[i]%100;
            m %= 10;
        }
        else if(a[i]>=10 && a[i]<100)
            m = a[i]%10;
        else
            m = a[i];
        if( m!=0 && Max < 10-m){
            Max = 10-m;
            x = i;
        }
    }
    swap(a[x],a[4]);
    rep(i,5){
        ans += a[i];
        s = to_string(ans);
        if(i != 4){
            if(s[s.size()-1]-'0' != 0){z = 10 - (s[s.size()-1]-'0');}
            else{ z=0; } 
            ans += z;
        }
    }
    cout << ans << endl;
    return 0;
}



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

int main(void){

	int n;
	cin>>n;

	for (int i=0; i<n; i++){
		int a, b, c;
		cin>>a;
		cin>>b;
		cin>>c;
		if (a>b) swap(a, b);
		if (b>c) swap(b, c);
		if (a*a + b*b == c*c)
			cout<<"YES"<<endl;
		else
			cout<<"NO"<<endl;
	}

	return 0;
} 

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

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

  sort(S.begin(), S.end());
  S.erase(unique(S.begin(), S.end()), S.end());

  string ans = "None";

  for (int i = 1; i < S.size(); i++) {
    if (S.at(i) - S.at(i - 1) != 1) {
      ans = S.at(i - 1) + 1;
      break;
    }
  }

  cout << ((S.at(0) != 'a') ? "a" : (S.size() == 25 && S.at(24) == 'y') ? "z" : ans) << endl;
}

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


#define ll          long long
#define uint        unsigned int 
#define ld          long double
#define SAM         ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define mod         1000000007
#define mxn         200005
#define pb          push_back
#define pii         pair<int,int>
#define f           first
#define s           second
#define sz(x)       (int)x.size()
#define all(x)      x.begin(),x.end()

using namespace std;


int main()
{
    SAM;
    int n;
    cin>>n;
    int arr[n],sum=0;
    FOR(i,0,n)
    {
        cin>>arr[i];
        sum^=arr[i];
    }
    
    FOR(i,0,n)
    {
        cout<<(sum^arr[i])<<" ";
    }
   
    return 0;
}


Measured memory_bytes: 4404
//============================================================================
// Name        : c
// Date        : Sun Apr 21 15:39:56 CST 2019
// Author      : landcold7
// Description : Actions speak louder more than words
//============================================================================
#include <bits/stdc++.h>
using namespace std;

#define x first
#define y second
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#ifndef _has_trace
#define trace(...)
#define dbstream ostream
#endif
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;

void solve() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  vi a(n + 1);
  for (int i = 0; i < n; ++i) {
    a[i + 1] = a[i] + (s[i] == '#');
  }
  vi b(n + 1);
  for (int i = n - 1; i >= 0; --i) {
    b[i] = b[i + 1] + (s[i] == '.');
  }
  int ret = n;
  for (int i = 0; i < n; ++i) {
    ret = min(ret, a[i] + b[i + 1]);
  }
  cout << ret << "\n";
}

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


Measured memory_bytes: 2196
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<bitset>
#include<random>
#include<cstdint>
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
#define shosu setprecision(17)
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<char,P> Q;
ll longinf=(1ll<<60);
ll inf=1ll<<29;
int main(){
      ll n;
      cin>>n;
      ll x;
      cin>>x;
      ll bg[n];
      ll bn[n];
      ll pt[n];
      bn[0]=0;
      pt[0]=1;
      bg[0]=1;
      rep0(i,n){
            bn[i+1]=2*bn[i]+2;
            pt[i+1]=2*pt[i]+1;
            bg[i+1]=bn[i+1]+pt[i+1];
      }
      ll ans=0;
      ll now=(n-1);
      while(now>=-1){
            if(now==-1){
                  if(x>=1) ans++;
                  break;
            }
            if(x>=bg[now]+2){
                  x-=bg[now]+2;
                  ans+=pt[now]+1;
            }
            else x--;
            now--;
      }
      cout<<ans<<endl;
      return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const string EMP = " ";
const ll INF = 1LL<<60;
const ll MOD = 1000000007;
const double PI = acos(-1);

int main(){
  int n,a,b; cin >> n >> a >> b;
  int aa = 0, bb = 0, cc = 0;
  for(int i = 0; i < n; i++){
    int now; cin >> now;
    if(now <= a) aa++;
    else if(a < now && now <= b) bb++;
    else cc++;
  }
  int ans = min({aa,bb,cc});
  cout << ans << endl;
  return 0;
}


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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

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

//main code

int main(int argc, char const* argv[])
{
    int H,W,N;
    cin >> H >> W >> N;
    VI a(N);
    queue<int> colors;
    for (int i = 0; i < N; i++) {
       cin >> a[i]; 
       for (int j = 0; j < a[i]; j++) {
           colors.push(i+1);
       }
    }

    VVI ans(H,VI(W));
    for (int h = 0; h < H; h++) {
        if (h % 2 == 0) {
            for (int w = 0; w < W; w++) {
                ans[h][w] = colors.front();
                colors.pop();
            }
        }
        else {
            for (int w = W-1; w >= 0; w--) {
                ans[h][w] = colors.front();
                colors.pop();
            }
        }
    }

    for (int h = 0; h < H; h++) {
        for (int w = 0; w < W; w++) {
            cout << ans[h][w] << " ";
        }
        cout << endl;
    }
    return 0;
}


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

int main(){
    int N,Q;
    cin >> N >> Q;
    string str;
    cin >> str;
    vector<int> counter(N);
    vector<vector<int>> data(100000,vector<int>(2));

    for(int i = 0;i < Q;i++){
        cin >> data[i][0] >> data[i][1];
    }
    
    //文字列の中にどれくらいACがいるかを確認
    counter[0] = 0;
    for(int i = 1;i < N;i++){
        counter[i] += counter[i - 1];
        if(str.substr(i - 1,2) == "AC") counter[i]++;
    }

    for(int i = 0;i < Q;i++){
        int j = counter[data[i][1] - 1] - counter[data[i][0] - 1];
        cout << j << endl;
      
    }


}

Measured memory_bytes: 6784