akhauriyash/Code-Regression huggingface dataset:
s=input()
q=int(input())
head=[]
tail=[]
rev=False
for _ in range(q):
  tmp=list(input().split())
  if tmp[0]=='1':
    if rev==False:
      rev=True
    else:
      rev=False
  if tmp[0]=='2':
    if rev==False:
      if tmp[1]=='1':
        head.append(tmp[2])
      if tmp[1]=='2':
        tail.append(tmp[2])
    if rev==True:
      if tmp[1]=='1':
        tail.append(tmp[2])
      if tmp[1]=='2':
        head.append(tmp[2])
head=''.join(map(str,head))
tail=''.join(map(str,tail))
ans=head[::-1]+s+tail
if rev==True:
  ans=ans[::-1]
print(ans)


Measured memory_bytes: 6344
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
const int N=2005,Mod=1e9+7;
int dp[N][N],fac[N*N],inv[N*N];
inline int C(int n,int m){
	return 1ll*fac[n]*inv[m]%Mod*inv[n-m]%Mod;
}
inline int qpow(int a,int b){
	int ans=1;
	while (b){
		if (b&1) ans=1ll*ans*a%Mod;
		a=1ll*a*a%Mod,b>>=1;
	}
	return ans;
}
int main (){
	int n,k;scanf ("%d%d",&n,&k);
	if (k==1) {puts("1");return 0;}
	dp[0][0]=1;fac[0]=1;
	for (int i=1;i<=n*k;i++) fac[i]=1ll*fac[i-1]*i%Mod;
	inv[n*k]=qpow(fac[n*k],Mod-2);for (int i=n*k-1;i>=0;i--) inv[i]=1ll*inv[i+1]*(i+1)%Mod;
    for (int i=0;i<=n;i++) dp[i][0]=1;
	for (int i=1;i<=n;i++)
        for (int j=0;j<=i;j++)
            dp[i][j]=dp[i-1][j]+1ll*dp[i][j-1]*(n-j+1)%Mod*C(n*k-(i+(j-1)*(k-1))-1,k-2)%Mod,dp[i][j]%=Mod;
    printf ("%d",dp[n][n]);
	return 0;
}

Measured memory_bytes: 47360
#include <stdio.h>

int main() {
    int n, min, max;
    scanf("%d", &n);
    int R[n];
    for (int i=0; i<n; i++) {
        scanf("%d", &R[i]);
    }
    max = R[1] - R[0];
    min = R[0];
    for (int j=1; j<n; j++) {
        if ((R[j] - min) > max) {max = R[j] - min;}
        if (R[j] < min) {min = R[j];}
    }
    printf("%d\n", max);
    return 0;
}



Measured memory_bytes: 2584
using System;
using System.Linq;
using System.Collections.Generic;


public class Test
{
	public static void Main( )
	{
		int n = int.Parse( Console.ReadLine().Trim() );
		HashSet<string> dict = new HashSet<string>();
		

		for( int i=0; i<n; i++ ) {
			string[] s = Console.ReadLine().Trim().Split();
			if( s[0] == "insert" ) {
				dict.Add( s[1] );
			} else {
				if( dict.Contains( s[1] ) ) {
					Console.WriteLine( "yes" );
				} else {
					Console.WriteLine( "no" );
				}
			}
		}

		return;
	}
}


Measured memory_bytes: 44292
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char c;
  cin >> c;
  
  if( c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' ) {
     cout << "vowel" << endl;
  }
  else{
    cout << "consonant" << endl;
  }
}

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

int main()
{
    ll n,w;cin>>n>>w;
    vector<ll> wei(n),value(n);
    for(ll i=0;i<n;i++)
    {
        cin>>wei[i]>>value[i];
    }
    vector<ll> dp(w+1);
    for(ll i=0;i<n;i++)
    {
        for(ll wei_inbag=w-wei[i];wei_inbag>=0;wei_inbag--)
        {
            dp[wei_inbag+wei[i]]=max(dp[wei_inbag+wei[i]],dp[wei_inbag]+value[i]);
        }
    }
    ll ans=0;
    for(auto &value:dp)
    {
        ans=max(ans,value);
    }
    cout<<ans<<"\n";
}

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

int main() {
	int64_t n, m;
	cin >> n >> m;
	int64_t ans = 0;
	if (n == 1 && m == 1)ans = 1;
	else if (n == 1)ans = m - 2;
	else if (m == 1)ans = n - 2;
	else ans = (n * m) - n - n - m - m + 4;

	cout << ans << endl;

}


Measured memory_bytes: 256
//do not think about past and stay in this moment
//organize and work - Abhinav IIITA
#include <bits/stdc++.h>
#include <ctime>
using namespace std;
#define int long long
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end() 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int arr[3000000];
void input(int n){
	for(int i=0;i<n;++i)
	cin>>arr[i];
}
// -----------------------------------------------------------------------



void solve(){
	int w,h,n;
	cin>>w>>h>>n;
	int lx=0,ly=0;
	while(n--){
		int x,y,a;
		cin>>x>>y>>a;
		if(a==1){
			lx=max(lx,x);
		}else if(a==2){
			w=min(w,x);
		}else if(a==3){
			ly=max(ly,y);
		}else{
			h=min(h,y);
		}
	}
	if((lx>w) || (ly>h))
	cout<<"0";
	else{
		int ans=(w-lx);
		ans*=(h-ly);
		cout<<ans;
	}
}


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


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


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

int main(){
	int i,x,n;
	cin >> n;
	for(i=1;i<=n;i++){
		x=i;
		if(x%3==0){
			cout << " " <<i;
		}else{
			while(x){
			if(x%10==3){
			cout << " " <<i;
				break;
			}
				x /= 10;
			}
		}
	}
	cout << endl;
}

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

int main() {
	int a[100];
	int n;
	int temp;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}

	for (int i = n - 1; i >= 0; i--) {
		if (i == 0) printf("%d", a[i]);
		else
		printf("%d ", a[i]);
	
	}
	printf("\n");
	return 0;

}


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

int main() {
	long long n,a,b;cin>>n>>a>>b;
	long long ans=0;
	ans+=(n/(a+b))*a;
	n%=a+b;
	if(a<n){
		ans+=a;
	}else{
		ans+=n;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n, m, p, len = 0;
int k;
int main()
{
	scanf("%d %d", &n, &m);
	p = m;
	while(p > 0)
	{
		p /= 10;
		len++;
	}
	n = n * pow(10, len) + m;
	k = sqrt(n);
	if (n % k == 0)
	{
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <cstring>

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

using i32 = int32_t;
using u32 = uint32_t;
using f32 = float;
using f64 = double;
using i64 = int64_t; 
using u64 = uint64_t; 

#define SELECTER(_1, _2, _3, _4, _5, _6, _7, _8, SELECT, ...) SELECT

#define _FC1(func, type, _1)      func(type, _1);
#define _FC2(func, type, _1, ...) func(type, _1); _FC1(func, type, __VA_ARGS__);
#define _FC3(func, type, _1, ...) func(type, _1); _FC2(func, type, __VA_ARGS__);
#define _FC4(func, type, _1, ...) func(type, _1); _FC3(func, type, __VA_ARGS__);
#define _FC5(func, type, _1, ...) func(type, _1); _FC4(func, type, __VA_ARGS__);
#define _FC6(func, type, _1, ...) func(type, _1); _FC5(func, type, __VA_ARGS__);
#define _FC7(func, type, _1, ...) func(type, _1); _FC6(func, type, __VA_ARGS__);
#define _FC8(func, type, _1, ...) func(type, _1); _FC7(func, type, __VA_ARGS__);

#define _FCN(func, type, ...) SELECTER(__VA_ARGS__, _FC8, _FC7, _FC6, _FC5, _FC4, _FC3, _FC2, _FC1)(func, type, __VA_ARGS__);

constexpr const char *type2fmt(const char *fmt) {
  if(strcmp(fmt, "i32")) return "%d";
  if(strcmp(fmt, "u32")) return "%u";
  if(strcmp(fmt, "f32")) return "%f";
  if(strcmp(fmt, "f64")) return "%lf";
  if(strcmp(fmt, "i64")) return "%lld";
  if(strcmp(fmt, "u64")) return "%llu";
  if(strcmp(fmt, "char*")) return "%s";
  return "";
}

#define _R(type, _1) type _1; { type _t; scanf(type2fmt(#type), &_t); _1 = _t; }
#define _P(type, _1) { const type _t = (_1); printf(type2fmt(#type), _t); putchar('\n'); }

#define RI(...)   _FCN(_R, i32, __VA_ARGS__);
#define RUI(...)  _FCN(_R, u32, __VA_ARGS__);
#define RF(...)   _FCN(_R, f32, __VA_ARGS__);
#define RD(...)   _FCN(_R, f64, __VA_ARGS__);
#define RLL(...)  _FCN(_R, i64, __VA_ARGS__);
#define RULL(...) _FCN(_R, u64, __VA_ARGS__);

#define PI(...)   _FCN(_P, i32, __VA_ARGS__);
#define PUI(...)  _FCN(_P, u32, __VA_ARGS__);
#define PF(...)   _FCN(_P, f32, __VA_ARGS__);
#define PD(...)   _FCN(_P, f64, __VA_ARGS__);
#define PLL(...)  _FCN(_P, i64, __VA_ARGS__);
#define PULL(...) _FCN(_P, u64, __VA_ARGS__);
#define PS(...)   _FCN(_P, char*, __VA_ARGS__);

#define REP(n) for (int _i = 0; _i < n; _i++)

const u64 mod = 1000000007;

int main() {
  vector<u32> H;
  RI(N, T, A); REP(N) { RI(t); H.push_back(t); }

  u32 p; f64 d = 10000;
  for (i32 i = 0; i < N; i++) {
    f64 t = fabs((T - H[i] * 0.006) - A);
    if (t < d) { d = t; p = i; }
  }

  PI(p + 1);

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int idx = 1;
		int x;
		while ((x = sc.nextInt()) != 0) {
			System.out.println("Case " + idx + ": " + x);
			++idx;
		}
	}
}


Measured memory_bytes: 41984
#include<iostream>
#include<algorithm>
#define Z 15000000
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int n,m,a,b,c[15],t;
int head,tail,ans;
int qx[Z],ql[Z];
bool vis[Z];

void BFS(int x,int l){
	if(vis[x])return;
	if(l==m)return;
	if(x==0||x==t){ans=l;return;}
	vis[x]=true;
	int d[3]={-1},e=x,f=0,g=1;
	while(true){
		d[e%3]=max(d[e%3],g);
		e/=3,f++,g*=3;
		if(f==n)break;
	}
	if(d[0]>d[1]){e=x+d[0];if(!vis[e])qx[tail]=e,ql[tail]=l+1,tail++;}
	if(d[0]<d[1]){e=x-d[1];if(!vis[e])qx[tail]=e,ql[tail]=l+1,tail++;}
	if(d[1]>d[2]){e=x+d[1];if(!vis[e])qx[tail]=e,ql[tail]=l+1,tail++;}
	if(d[1]<d[2]){e=x-d[2];if(!vis[e])qx[tail]=e,ql[tail]=l+1,tail++;}
	return;
}
int main(){
	while(true){
		cin>>n>>m;
		if(!n&&!m)break;
		rep(i,3){cin>>a;rep(j,a)cin>>b,c[b-1]=i;}
		int o=0,p=1;
		rep(i,n)o+=p*c[i],p*=3;
		t=p-1;
		head=0,tail=1,ans=-1;
		qx[0]=o,ql[0]=0;
		rep(i,Z)vis[i]=false;
		while(true){
			if(tail==head)break;
			BFS(qx[head],ql[head]);
			if(ans!=-1)break;
			head++;
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 37204
# -*- coding: utf-8 -*-
"""
Big Integers - Division of Big Integers
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=NTL_2_D&lang=jp

"""
import sys


def main(args):
    A, B = map(int, input().split())
    sign = 1 if A*B >= 0 else -1
    print(abs(A) // abs(B) * sign)


if __name__ == '__main__':
    main(sys.argv[1:])



Measured memory_bytes: 5624
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long ll;
int N, K, H[200001]; ll atk;
int main() {
  scanf("%d %d", &N, &K);
  for(int i = 1; i <= N; ++i) {
    scanf("%d", &H[i]);
  }
  sort(H+1, H+N+1);
  for(int i = 1; i <= N-K; ++i) {
    atk += (ll)H[i];
  }
  printf("%ld\n", atk);
}

Measured memory_bytes: 896
from collections import Counter
n = int(input())
if n == 1:
    s0 = list(input())
    s0.sort()
    print("".join(s0))
else:
    s0 = list(input())
    s1 = list(input())
    match = list((Counter(s0) & Counter(s1)).elements())
    for i in range(n-2):
        s = list(input())
        match = list((Counter(match) & Counter(s)).elements())
    match.sort()
    print("".join(match))

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

int main() {
  string s;
  cin >> s;
  long long ans = 0;
  int n = s.size();
  for(int bit = 0; bit < (1 << n - 1); bit++){
    long long t = s.at(0) - '0';
    
    for(int i = 0; i < n - 1; i++){
      if(bit & (1 << i)){
        ans += t;
        t = s.at(i + 1) - '0';
      }
      else{
        t *= 10;
        t += s.at(i + 1) - '0';
      }
    }
    ans += t;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vi = vector<int>;
using vvi = vector<vi>;
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)


ll solve(ll N){
	ll n = sqrt(N);
	ll ans = LLONG_MAX;
	rp(a, 1, n+1){
		if(N%a == 0){
			ll b = N/a;
			ll s;
			if(a == 1){
				s = (b-1);
			}
			else if(b == 1){
				s = (a-1);
			}
			else{
				s = (a-1) + (b-1);
			}
			ans = min(ans, s);
		}
	}
	return ans;
}

int main(){
	ll N; cin>>N;
	ote(solve(N));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 5, mod = 1e9 + 7;


int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    if(a + b >= k) return cout << min(k, a), 0;
    k -= (a + b);
    cout << a - k;



    return 0;
}



Measured memory_bytes: 3612
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

#define REPI(i,a,b) for (ll i=(a);i<(b);i++)
#define REP(i,n) REPI(i,0,n)

typedef long long int ll;

int SURP = 1000000007;

int ceil(int a,int b){
	return (a+b-1)/b;
}

int main(){
	string s;
	ll k;
	cin >> s;
	cin >> k;

	ll l = s.length();
	if (l <= k) k = l;

	char ret = 'n';
	REP(i,k){
		if(s[i] != '1'){
			ret = s[i];
			break;
		}
	}
	if(ret == 'n') ret = '1';

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
//#include "MyMath.h"
#include <map>
#include <set>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <vector>
#include <functional>
#include <math.h>
using namespace std;
const int num = 40, num1 = 10000000;
double numd = 10000000.0;
typedef long long int ll;
const ll INF = 2000000000;
pair<ll, ll> l[1 << (num / 2)], r[1 << (num - num / 2)], a[num / 2], b[num / 2];
int main() {
	int n;
	ll W;
	cin >> n >> W;
	int m = n - n / 2;
	for (int i = 0; i < n / 2; i++)
		cin >> a[i].second >> a[i].first;
	//int k = 0;
	for (int i = 0; i < m; i++)
		/*cin >> b[k].second;
		cin >> b[k++].first;*///????????§k??????????????????
		cin >> b[i].second >> b[i].first;
	for (int i = 0; i < 1 << n / 2; i++) {
		ll v = 0, w = 0; 
		for(int j = 0; j < n / 2; j++)
			if (i >> j & 1) {
				v += a[j].second;
				w += a[j].first;
			}
		l[i] = make_pair(w, v);
	}
	for (int i = 0; i < 1 << m; i++) {
		ll v = 0, w = 0;
		for (int j = 0; j < m; j++)
			if (i >> j & 1) {
				v += b[j].second;
				w += b[j].first;
			}
		r[i] = make_pair(w, v);
	}
	sort(l, l + (1 << n / 2));
	sort(r, r + (1 << m));
	int s = 0;
	for (int i = 1; i < 1 << n / 2; i++) 
		if (l[s].second < l[i].second) {
			l[++s] = l[i];
		}
	int t = 0;
	for (int i = 1; i < 1 << m; i++)
		if (r[t].second < r[i].second) {
			r[++t] = r[i];
		}
	ll maxv = 0;
	for (int i = 0; i <= s; i++) {
		if (W < l[i].first) continue;
		ll w = W - l[i].first;
		maxv = max(maxv, (upper_bound(r, r + t + 1, make_pair(w, INF)) - 1)->second + l[i].second);
	}
	cout << maxv << endl;
	return 0;
}

Measured memory_bytes: 35812
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		new Main().start();
	}
	void start(){
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int m = in.nextInt();
		long count = 1;
		long waru =  1000000007l;
		long waru1 = 1000000007l;

		if(n == m){
			for(long i = 1; i <= n; i++){
				count *= i;
				count %= waru;
			}
			for(long i = 1; i <= m; i++){
				count *= i;
				count %= waru;
			}
			count = count * 2 % waru1;
			System.out.println(count);
		}else if(n - m == 1 || m-n==1){
			for(long i = 1; i <= n; i++){
				count *= i;
				count %= waru;
			}
			for(long i = 1; i <= m; i++){
				count *= i;
				count %= waru;
			}
			System.out.println(count%waru1);
		}else{
			System.out.println(0);
		}
		in.close();
	}
}


Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char ch;
    cin>>ch;
    if(ch=='A')
        cout<<'T'<<endl;
    else if(ch=='T')
        cout<<'A'<<endl;
    else if(ch=='C')
        cout<<'G'<<endl;
    else if(ch=='G')
        cout<<'C'<<endl;
    return 0;
}


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

constexpr int MAXIMUM = 2000000000;

long long merge(int * A, int left, int mid, int right) {
    int n1 = mid - left, n2 = right - mid;
    int L[n1 + 1], R[n2 + 1];
    std::memcpy(L, A + left, sizeof(int) * n1);
    std::memcpy(R, A + mid, sizeof(int) * n2);
    L[n1] = MAXIMUM, R[n2] = MAXIMUM;

    int j = 0, k = 0;
    long long cnt = 0;
    for (int i = left; i < right; i++) {
        if (L[j] <= R[k]) {
            A[i] = L[j];
            j++;
        } else {
            A[i] = R[k];
            k++;
            cnt += n1 - j;
        }
    }
    return cnt;
}

long long mergeSort(int * A, int left, int right) {
    long long count = 0;
    if (left + 1 < right) {
        int mid = (left + right) / 2;
        count += mergeSort(A, left, mid);
        count += mergeSort(A, mid, right);
        count += merge(A, left, mid, right);
    }
    return count;
}

int bubbleSort(int * A, int n) {
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        for (int j = n - 1; j > i; j--) {
            if (A[j] < A[j - 1]) {
                std::swap(A[j], A[j - 1]);
                cnt++;
            }
        }
    }
    return cnt;
}

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

    int A[n];
    for (int i = 0; i < n; i++) {
        std::cin >> A[i];
    }

    // int B[n];
    // std::memcpy(B, A, sizeof(int) * n);
    // int ans = bubbleSort(B, n);
    // std::cout << ans << std::endl;
    
    long long count = mergeSort(A, 0, n);
    std::cout << count << std::endl;
}



Measured memory_bytes: 4696
#pragma GCC optimize("O3")

#include "bits/stdc++.h"
#include "ext/pb_ds/tree_policy.hpp"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/rope"

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define f first
#define s second

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

struct custom_hash 
{
    static uint64_t splitmix64(uint64_t x) 
    {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const 
    {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
int n, d;
int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> d;
    cout << n/(2 * d + 1) + (n%(2 * d + 1) != 0);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define maxn 100005
#define LL long long
using namespace std;

int n;
LL sm[maxn],lsm[maxn];
bool isn[maxn];

int main(){
	scanf("%d",&n);
	LL ans = 0;
	for(int i=1;i<=n;i++){
		scanf("%lld",&sm[i]);
		if(isn[i-1]) ans -= sm[i];
		else ans += sm[i];
		lsm[i] = ans;
		sm[i] += sm[i-1];
		char ch[2];
		if(i<n){
			scanf("%s",ch);
			if(ch[0] == '-')isn[i] = 1;
		}
	}
	int nx = n;
	for(int i=n-1;i>=0;i--) if(isn[i]){
		ans = max(ans , sm[n] - sm[nx] - (sm[nx] - sm[i]) + lsm[i]);
		nx = i;
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 1920
use proconio::input;
use std::cmp::min;
fn main() {
    input!{
        n:usize,
        m:usize,
        x:usize,
        text:[[usize;m+1];n]
    }
    let mut ans = 1000000000;
    for bit in 0..(1<<n){
        let mut cost = 0;
        let mut skill = vec![0; m];
        for i in 0..n{
            if (bit>>i) & 1 == 0 {
                continue;
            }
            cost += text[i][0];
            for j in 0..m{
                skill[j] += text[i][j+1];
            }
        }
        let mut flag = true;
        for i in 0..m{
            if skill[i] < x{
                flag = false;
                break;
            }
        }
        if flag {
            ans = min(ans, cost);
        }
    }
    if ans == 1000000000{
        println!("{}", -1);
    }else{
        println!("{}", ans);
    }

}


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

#define INF 1000010000
#define nl '\n'
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pdd pair<double,double>
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))
#define sz(c) (c).size()
#define rep(i,n) for( int i = 0; i < n; ++i )
#define repi(i,n) for( int i = 1 ; i <= n; ++i )
#define repn(i,n) for( int i = n - 1 ; i >= 0 ; --i )
#define repf(j,i,n) for( int j = i ; j < n ; ++j )
#define die(s) {std::cout << s << nl;}
#define dier(s) {std::cout << s; return 0;}
#define vi vector<int>
typedef long long ll;

using namespace std;

int f(vi & v , int c){
	int l = 0 , r = sz(v) - 1;
	while(r - l > 1){
		int mid = (r + l) / 2;
		if(v[mid] >= c){
			r = mid;
		}else{
			l = mid;
		}
	}
	if(v[r] < c)l = r;
	if(v[l] >= c)return -1;
	return l;
}

int f1(vi & v , int c){
	int l = 0 , r = sz(v) - 1;
	while(r - l > 1){
		int mid = (r + l) / 2;
		if(v[mid] <= c){
			r = mid;
		}else{
			l = mid;
		}
	}
	if(v[r] > c)l = r;
	if(v[l] <= c)l = -1;
	return l;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(0); 

	int n;
	cin >> n;
	
	vi a(n), b(n), c(n);
	
	rep(i , n)cin >> a[i];
	rep(i , n)cin >> b[i];
	rep(i , n)cin >> c[i];
	
	SORT(a);
	SORT(b);
	SORT(c);
	reverse(all(c));
	
	ll ans = 0;
	rep(i , n){
		int e1 = f(a , b[i]);
		int e2 = f1(c , b[i]);
		if(e1 == -1 || e2 == -1)
			continue;
		++e1;
		++e2;
		
		ans += 1ll * e1 * e2;
	}
	cout << ans;

	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using tiii = tuple<int, int, int>;

char A[111][111];
int D[111][111];

int main() {
	memset(A, '?', sizeof(A));
	int H, W; scanf("%d%d",&H,&W);
	for(int i=1; i<=H; i++) {
		for(int j=1; j<=W; j++) {
			scanf(" %c", &A[i][j]);
			D[i][j] = 1e9;
		}
	}
	D[1][1] = A[1][1] == '#' ? 1 : 0;
	priority_queue<tiii> pq; pq.push((tiii){-D[1][1], 1, 1});
	while(pq.size()) {
		int d, x, y; tie(d, x, y) = pq.top(); pq.pop(); d *= -1;
		if(D[x][y] != d) continue;
		if(x+1 <= H) {
			int c = (A[x][y] != A[x+1][y] && A[x+1][y] == '#');
			if(D[x+1][y] > d + c) {
				D[x+1][y] = d+c;
				pq.push((tiii){-D[x+1][y], x+1, y});
			}
		}
		if(y+1 <= W) {
			int c = (A[x][y] != A[x][y+1] && A[x][y+1] == '#');
			if(D[x][y+1] > d + c) {
				D[x][y+1] = d+c;
				pq.push((tiii){-D[x][y+1], x, y+1});
			}
		}
	}
	printf("%d", D[H][W]);
	return 0;
}

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

//Made with <3 by MinumCoklatPanas
typedef long long ll;
const int INF = 1e9;
const ll INFF = 1e18;
const int MAXN = 510;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);
const double INFD = 1E9;
const double EPS = 1e-9;

int mul(int x,int y)
{
    return ((x % MOD) * (y % MOD)) % MOD;
}

int add(int x,int y)
{
    return ((x % MOD) + (y % MOD)) % MOD;
}

int sub(int x,int y)
{
    int ret = ((x % MOD) - (y % MOD)) % MOD;
    if (ret < 0)
        ret += MOD;
    return ret;
}

int modpow(int x,int y)
{
    if (!y) return 1;
    int z = modpow(x,y / 2);
    z = mul(z,z);
    if (y & 1) z = mul(z,x);
    return z;
}

int inv(int x)
{
    return modpow(x,MOD - 2);
}

int bagi(int x,int y)
{
    return mul(x,inv(y));
}

int dp[2010];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    dp[3] = dp[4] = dp[5] = 1;
    for (int i = 6 ; i <= 2000 ; i++)
    {
        dp[i] = 1;
        for (int j = 3 ; j <= i - 3 ; j++)
        {
            dp[i] = add(dp[i],dp[i - j]);
        }
    }
    int n;
    cin >> n;
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n = 0;
	int arr[10000];
	cin >> n;
	int res = 0;
	for (int i = 0; i < n ; i++)
	{
		cin >> arr[i];
	}
	for (int i = 0; i < n-1; i++)
	{
		if( arr[i] == arr[i+1])
		{
			arr[i+1] = 0;
			res++;
		}
	}
	cout << res;
	
}

Measured memory_bytes: 256
from functools import reduce
import math
def gcd(a,b):
    a=abs(a)
    b=abs(b)
    if b == 0:
        return a
    if(a>=b):
        return gcd(b,a%b)
    if(b>a):
        return gcd(a,b%a)

def solve(*numbers):
    return reduce(gcd, numbers)

n, x = (int(i) for i in input().split())
xs = [int(i) for i in input().split()]
new_xs = []
for i in xs:
    new_xs.append(i-x)
print(abs(solve(*new_xs)))

Measured memory_bytes: 14592
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
int n, C[2010], Res = 1e9;
struct AA {
	int b, e;
}D[2010];
char p[2010];
vector<int>E[2010];
void DFS(int a, int pp) {
	D[a].b = D[a].e = 0;
	C[a] = p[a] - '0';
	for (auto &x : E[a]) {
		if (x == pp)continue;
		DFS(x, a);
		C[a] += C[x];
		D[a].e += D[x].e + C[x];
	}
	vector<AA>TP;
	for (auto &x : E[a]) {
		if (x == pp)continue;
		TP.push_back({ D[x].b + C[x], D[x].e + C[x] });
	}
	if (TP.empty())return;
	int pv = -1, Mx = -1;
	for (int i = 0; i < TP.size(); i++) {
		if (Mx < TP[i].e) {
			Mx = TP[i].e;
			pv = i;
		}
	}
	int s = 0;
	for (int i = 0; i < TP.size(); i++) {
		if (i == pv)continue;
		s += TP[i].e;
	}
	D[a].b = max(TP[pv].b - s, D[a].e%2);
}
void Go(int a) {
	DFS(a, 0);
	if (D[a].b == 0) {
		Res = min(Res, D[a].e);
	}
}
int main() {
	int i, a, b;
	scanf("%d", &n);
	scanf("%s", p + 1);
	for (i = 1; i < n; i++) {
		scanf("%d%d", &a, &b);
		E[a].push_back(b);
		E[b].push_back(a);
	}
	for (i = 1; i <= n; i++) {
		Go(i);
	}
	if (Res > 8e8)puts("-1");
	else printf("%d\n", Res/2);
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long x = sc.nextLong();
    long money = 100;
    int count = 0;
    while (x > money) {
      money = (long) ((long) money * 1.01);
      count++;
    }
    System.out.println(count);
  }

}


Measured memory_bytes: 35764
#include <iostream>
#include <bitset>
#include <vector>
#include <sstream>
#include <algorithm>

int main(){

    int purchase_num;
    int max_cap;

    while(std::cin >> purchase_num >> max_cap){
        if(purchase_num == 0 && max_cap == 0) break;
        std::vector<int> price;
        std::string str;
        int input_data;
        int min_price = 0;
        std::cin.ignore();
        std::getline(std::cin, str);
        std::istringstream iss(str);
        while(!iss.eof()){
            iss >> input_data;
            price.push_back(input_data);
        }
        std::sort(price.begin(),price.end(),std::greater<int>());
        for(int i = 0; i < price.size(); ++i){
            if((i+1)%max_cap != 0){
                min_price += price[i];
            }
        }
        std::cout << min_price << std::endl;
    }
    return 0;
}

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

string str[3];

int main() {    
    unordered_set<int> s;
    for (int i = 0; i < 3; ++i) { int k; cin >> k; s.insert(k); };
    cout << s.size() << endl;
    return 0;   
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
#define MAX 500000
ll fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
ll COM(ll n, ll k) {
    if(n < k)
        return 0;
    if(n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
    ll h, w, a, b;
    cin >> h >> w >> a >> b;
    COMinit();
    ll ans = 0;
    for(int i = b; i < w; i++) {
        ans += COM(i + h - a - 1, i) * COM(w - i - 1 + a - 1, a - 1) % MOD;
        ans %= MOD;
    }
    cout << ans << endl;
}

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

int main() {
	int h,n;
	cin>>h>>n;
	
	int sum=0;
	rep(i,n){
		int a;
		cin>>a;
		sum+=a;
	}
	if(sum>=h)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
}


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


int main(void){
  int n,i,a,on=0;
  
  cin >> n;
  for (i=0;i<n;i++){
    cin >> a;
    on+=a%2;
  }
  
  if (on==0) cout << "second" << endl;
  else cout << "first" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A, *B;

  int C[VMAX+1];
  int n, i, j;
  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  for ( i = 0; i <= VMAX; i++ ) C[i] = 0;

  for ( i = 0; i < n; i++ ){
    scanf("%hu", &A[i + 1]);
    C[A[i + 1]]++;
  }

  for ( i = 1; i <= VMAX; i++ ) C[i] = C[i] + C[i - 1];

  for ( j = 1; j <= n; j++ ){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }

  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", B[i]);
  }
  printf("\n");

  return 0;
}

Measured memory_bytes: 8460
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define PB(a,num) FOR(i,0,num) {ll x; scanf("%lld",&x); a.pb(x); }
#define LOWER(a,x) lower_bound(ALL(a), x) - a.begin() - 1;
#define COUNT(a,x)  upper_bound(ALL(a), x) - lower_bound(ALL(a), x);
#define MCOUNT(a,x,y) upper_bound(ALL(a), y) - lower_bound(ALL(a), x);
#define INF 111111111111111111
#define MOD 1000000007
#define pb push_back
#define F first
#define S second
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, tmp = 0, ma = 0, mi = 0;
string s;
bool flag, ok;
ll dx[4] = { 1,-1,0,0 }, dy[4] = { 0,0,1,-1 };
ll ddx[8] = { 1,-1,0,0,1,1,-1,-1 }, ddy[8] = { 0,0,1,-1,1,-1,1,-1 };
#pragma endregion
#define MAX 111111



int main(void) {
  cin >> n >> m;
  if (llabs(n - m) > 1) {
	cout << "Alice" << endl;
  }
  else {
	cout << "Brown" << endl;
  }


  return 0;
}

Measured memory_bytes: 256
from sys import stdin
import math
import itertools
import numpy as np

l = stdin.readline().rstrip().split()
l = [int(s) for s in l]

data = [stdin.readline().rstrip().split() for _ in range(l[0])]
for i in range(len(data)):
	data[i] = [int(s) for s in data[i]]

l = data
c = itertools.combinations(l, 2)
hoge = []
vvv = []
for v in itertools.combinations(l, 2):
    vvv.append(v)

for i in range(len(vvv)):
    vvv[i]
    calc = np.linalg.norm(np.array(vvv[i][0]) - np.array(vvv[i][1]))
    hoge.append(calc.is_integer())

print(hoge.count(True))

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int L,N;
string S;
vector<int> R[101010];
ll sum[101010];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>S>>N;
	L=S.size();
	
	FORR(c,S) c-='a';
	FOR(i,N) {
		cin>>x>>y;
		x--,y--;
		if(y<(L+1)/2) {
			R[x].push_back(y);
		}
		else if(x>=L/2) {
			R[L-1-y].push_back(L-1-x);
		}
		else {
			y=L-1-y;
			if(x<y) R[x].push_back(y-1);
			if(y<x) R[y].push_back(x-1);
		}
	}
	
	
	FOR(i,L/2) {
		if(i) sum[i]+=sum[i-1];
		int dif=((S[L-1-i]-(S[i]+sum[i]))%26+26)%26;
		sort(ALL(R[i]));
		if(R[i].size()>1) {
			FOR(j,R[i].size()-1) {
				if(R[i][j]!=R[i][j+1]) R[R[i][j]+1].push_back(R[i][j+1]);
			}
		}
		if(dif==0) continue;
		if(R[i].empty()) return _P("NO\n");
		sum[i]+=dif;
		sum[R[i][0]+1]-=dif;
	}
	_P("YES\n");
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
//BEGIN CUT HERE
template <typename T,typename E>
struct SegmentTree{
  using G = function<T(T,E)>;
  using H = function<E(E,E)>;
  int n;
  G g;
  H h;
  T ti;
  E ei;
  vector<T> dat;
  vector<E> laz;
  SegmentTree(){};
  SegmentTree(int n_,G g,H h,T ti,E ei):
    g(g),h(h),ti(ti),ei(ei){
    init(n_);
  }
  void init(int n_){
    n=1;
    while(n<n_) n*=2;
    dat.clear();
    dat.resize(n,ti);
    laz.clear();
    laz.resize(2*n-1,ei);
  }
  void build(int n_, vector<T> v){
    for(int i=0;i<n_;i++) dat[i]=v[i];
  }
  void update(int a,int b,E x,int k,int l,int r){
    if(r<=a||b<=l) return;
    if(a<=l&&r<=b){
      laz[k]=h(laz[k],x);
      return;
    }
    update(a,b,x,k*2+1,l,(l+r)/2);
    update(a,b,x,k*2+2,(l+r)/2,r);
  }
  void update(int a,int b,E x){
    update(a,b,x,0,0,n);
  }
  T query(int k){
    T c=dat[k];
    k+=n-1;
    E x=laz[k];
    while(k>0){
      k=(k-1)/2;
      x=h(x,laz[k]);
    }
    return g(c,x);
  }
};
//END CUT HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  int n,q;
  cin>>n>>q;
  SegmentTree<int,int> raq(n,
			   [](int a,int b){return a+b;},
			   [](int a,int b){return a+b;},
			   0,0);
  for(int i=0;i<q;i++){
    int c,s,t,x;
    cin>>c;
    if(c){
      cin>>x;
      cout<<raq.query(x-1)<<endl;
    }else{
      cin>>s>>t>>x;
      raq.update(s-1,t,x);
    }
  }
  return 0;
}

/*
  verified on 2018/03/04
  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_2_E&lang=jp
*/



Measured memory_bytes: 4376
#include<iostream>
#include<vector>
//#include<string>
using namespace std;

int main(void){
  int N, L;
  cin >> N >> L;
  vector<string> data(N);
  for (int i = 0; i < N; i++)
  {
      cin >> data.at(i);
  }
  for (int i = 0; i < N;i++){
    for (int j = i + 1; j < N;j++){
      if (data.at(i)>=data.at(j)){
        string tmp = data.at(i);
        data.at(i) = data.at(j);
        data.at(j) = tmp;
      }
    }
  }

  for (int i = 0; i < N;i++){
    cout << data.at(i);
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll> ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define tr1(x) cerr << #x << ": " << x << endl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define mod 1000000007
#define inf 9999999999999999ll
ll fun(vs &s,ll i,ll j)
{
    ll ans=0;
    queue <ii> q;
    ll n=s.size();
    ll m=s[0].size();
    vector <vector <bool> >vis(n,vb(m,false));
    vis[i][j]=true;
    q.push(mp(i,j));
    vv dis(n,vi(m,0));
    while(!q.empty())
    {
        ll x=q.front().F;
        ll y=q.front().S;
        q.pop();
        ll a1[]={1,0,-1,0};
        ll a2[]={0,1,0,-1};
        for(ll p=0;p<4;p++)
        {
            ll x1=a1[p]+x;
            ll y1=a2[p]+y;
            if(x1>=0 && x1<n && y1>=0 && y1<m && s[x1][y1]=='.' && !vis[x1][y1])
            {
                vis[x1][y1]=true;
                q.push(mp(x1,y1));
                dis[x1][y1]=1+dis[x][y];
                ans=max(ans,dis[x1][y1]);
            }
        }
    }
    return ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,m;
    cin>>n>>m;
    vs s(n,"");
    for(ll i=0;i<n;i++)
        cin>>s[i];
    ll ans=0;
    for(ll i1=0;i1<n;i1++)
    {
        for(ll j1=0;j1<m;j1++)
        {
            if(s[i1][j1]!='#')
                ans=max(ans,fun(s,i1,j1));
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
N = int(input())
A = [int(x) for x in input().split()]

def divise_count(x):
  c = 0
  while x%2==0:
    x = x//2
    c += 1
  return c

ans = 1000000000
for a in A:
  ans = min(ans, divise_count(a))

print(ans)

Measured memory_bytes: 3060
#include<iostream>

using namespace std;

void print(long A[], long n) {
    for (long i = 0; i < n; i++) {
        if (i != 0) {
            cout << " ";
        }
        cout << A[i];
    }
    cout << endl;
}

void insertionSort(long A[], long n) {
    for (long i = 1; i < n; i++) {
        long v = A[i];
        long j = i - 1;
        for (; j >= 0 && A[j] > v; j--) {
            A[j + 1] = A[j];
        }
        A[j + 1] = v;
        print(A, n);
    }
}

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

    print(A, n);
    insertionSort(A, n);

    return 0;
}

Measured memory_bytes: 1164
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Globalization;
using static System.Console;
using Pair = System.Collections.Generic.KeyValuePair<int, int>;

class Program
{
    static void Main()
    {
        var sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        SetOut(sw);
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 };
    readonly int mod = 1000000007;
    readonly string alfa = "abcdefghijklmnopqrstuvwxyz";

    int N;
    void solve()
    {
        N = cin.nextint;
        int k = 1;
        int cnt = 0;


        if (N == 1)
        {
            WriteLine(1);
            return;
        }
        if (N == 2)
        {
            WriteLine(2);
            return;
        }

        var G = new HashSet<int>();
        while (cnt <= N)
        {
            if (cnt == N)
            {
                break;
            }
            cnt += k;
            G.Add(k++);
            

        }
        foreach (var item in G)
        {
            if (item == cnt - N)
            {
                continue;
            }
            WriteLine(item);
        }
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

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

int main (void)
{
    char S[11];
    size_t len;
    int x, ans = 999;

    gets(S);

    len = strlen(S);

    for (int i = 0; i < (len - 2); i++) {
        x = ((S[i] - '0') * 100) + ((S[i + 1] - '0') * 10) + (S[i + 2] - '0');
        if (abs(753 - x) < ans) ans = abs(753 - x);
    }

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

    return 0;
}


Measured memory_bytes: 128
/*
	Bakul Gaur (caesar1551)
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define PrePro ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define fr(i,n) for(ll i = 0; i < n; i++)
#define fre(i,a,b) for(ll i = a; i <= b; i++)
#define fb(i,n) for(ll i = n; i >= 0; i--)
#define fbe(i,a,b) for(ll i = a; i >= b; i--)
#define umap(x,y) unordered_map<x,y>
#define uset(x) unordered_set<x>
#define vv(x) vector<x>
#define pp(x,y) pair<x,y>
#define prar(a,n) fr(i,n){cout << a[i] << " ";}
#define inar(a,n) fr(i,n){cin >> a[i];}
#define mk make_pair
#define pb push_back
#define ff first
#define ss second
#define endl "\n"
#define mod 1000000007
#define MAX 1000001
inline ll gcd(ll a, ll b){
	if(b == 0){
		return a;
	}
	return gcd(b,a%b);
}
inline ll pwr(ll a, ll b, ll modulo = mod){
	if(a == 0 && b == 0){
		return 0;
	}
	ll ans = 1;
	while(b > 0){
		if(b&1){
			ans = ((ans%modulo) * (a%modulo))%modulo;
		}
		b >>= 1;
		a = ((a%modulo) * (a%modulo))%modulo;
	}
	return (ans+modulo)%modulo;
}
inline ll modInverse(ll a, ll p){
	// Only if p is prime.
	return pwr(a,p-2,p);
}



/* #############
   START SOLVING 
   ############# */



void solve(){
	ll n, w;
	cin >> n >> w;
	vv(ll) val(n), weight(n);
	fr(i,n){
		cin >> weight[i] >> val[i];
	}
	vv(vv(ll)) dp(n+1,vv(ll)(w+1,0));
	for(ll i = 1; i <= n; i++){
		for(ll j = 1; j <= w; j++){
			dp[i][j] = dp[i-1][j];
			if(j >= weight[i-1]){
				dp[i][j] = max(dp[i][j], val[i-1] + dp[i-1][j-weight[i-1]]);
			}
		}
	}
	cout << dp[n][w] << endl;
}

int main(){
	PrePro
	/* #ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif */
    ll t = 1;
    // cin >> t;
    fr(i,t){
    	// cout << "Case #" << i+1 << ": ";
    	solve();
    	// cout << endl;
    }
	return 0;
}

Measured memory_bytes: 83116
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(signed i=0;i<n;++i)
#define repi(n) rep(i,n)
#define int long long
#define pb(a) push_back(a)
#define all(v) v.begin(),v.end()
#define yn(b) cout<<((b)?"Yes":"No")<<endl
#define YN(b) cout<<((b)?"YES":"NO")<<endl
#define call(a) for(auto t:a)cout<<t<<" ";cout<<endl
#define ENDL printf("\n");
#define debg(a) cout<<#a<<":"<<a<<endl;
#define SORT(a) sort(all(a));
#define INF 1LL<<60
#define out(i) cout<<i<<endl;
#define m_p make_pair
typedef long long ll;
typedef string str;
typedef vector<int> V;
typedef pair<int,int> P;
int min(int a,int b){if(a>b)return b;return a;}
int max(int a,int b){if(a>b)return a;return b;}
int gcd(int a,int b){if(b==0)return a; return gcd(b,a%b);}
int lcm(int a,int b){return a/gcd(a,b)*b;}
V sum(114514);
int partsum(int a,int b){
  return sum[b]-sum[a];
}

signed main(){
  int n,m;
  cin>>n>>m;
  str s;
  cin>>s;
  V l(m),r(m);
  rep(i,m)cin>>l[i]>>r[i],l[i]--,r[i]--;
  sum[0]=0;
  rep(i,n-1)if(s[i]=='A'&&s[i+1]=='C')sum[i+1]=1;
  for(int i=1;i<=n;++i)sum[i]+=sum[i-1];
  rep(i,m){
    cout<<partsum(l[i],r[i])<<endl;
  }

  
   return 0;
}



Measured memory_bytes: 3584
#include<bits/stdc++.h>
#define mod 1000000007
#define pb push_back 
#define ll long long
using namespace std;
int main()
 {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
	ll t;
	cin>>t;
	cout<<3*t*t<<endl;
	return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
 
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
 
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}
 
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
 
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
 
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
 
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
 
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
 
fn main() {
  input! {
    h:usize, w:usize,
    m:[[i32;w];h],
  };
  let mut vd = vec![0; h];
  let mut mvs = vec![];
  for y in 0..h {
    let mut p = m[y][0];
    for x in 0..(w-1) {
      if p % 2 == 0 {
        p = m[y][x+1];
      } else { 
        p = m[y][x+1] + 1;
        mvs.push((y+1, x+1, y+1, x+2));
      }
     }
      vd[y] = p;
   };
   let mut p = vd[0];
    for y in 0..(h-1) {
      if p % 2 == 0 {
          p = vd[y+1];
        } else { 
          p = vd[y+1] + 1;
          mvs.push((y+1, w, y+2, w));
        }
    }
    println!("{}", mvs.len());
    for ref v in mvs {
    println!("{} {} {} {}", v.0, v.1, v.2, v.3);
    }
}

Measured memory_bytes: 13304
import java.math.*;
import java.util.*;
	
	public class Main {
	
		public static void main(String[] args) {
		
			Scanner sc = new Scanner(System.in);
			String C = sc.next();
			char[] cchar = C.toCharArray();
			cchar[0]++;
			
			System.out.println(cchar[0]);
			
			
		}
				
	}
	
	

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#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;
    cin >> n;
    switch (n%10)
    {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9: puts("hon"); break;
    case 0:
    case 1:
    case 6:
    case 8: puts("pon"); break;
    case 3: puts("bon"); break;
    }
    return 0;
}

Measured memory_bytes: 3596
package main

import (
	"fmt"
	"strings"
)

func main() {
	var n int
	var s string
	fmt.Scan(&n, &s)

	ans := 0
	for i := 1; i < n; i++ {
		first := s[:i]
		second := s[i:]

		count := 0
		for char := range classifiedChars(first) {
			if strings.Contains(second, char) {
				count++
			}
		}
		if ans < count {
			ans = count
		}
	}
	fmt.Println(ans)
}

func classifiedChars(str string) map[string]struct{} {
	table := make(map[string]struct{})
	arr := strings.Split(str, "")
	for _, s := range arr {
		table[s] = struct{}{}
	}
	return table
}


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

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

	if ((s[2] == s[3]) && (s[4] == s[5]))
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}


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

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
inline bool valid(int x, int w) { return 0 <= x && x < w; }

void iostream_init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.setf(ios::fixed);
    cout.precision(12);
}

int main(){
    iostream_init();
    string s;
    cin >> s;
    int w;
    cin >> w;
    for(int i = 0; i < s.size(); i += w) {
        cout << s[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

S = str(input())
if S == "AAA" or S == "BBB":
    print("No")
else:
    print("Yes")



Measured memory_bytes: 67436
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    a,b = LS()

    return min(a,b) * int(max(a,b))


print(main())





Measured memory_bytes: 5460