akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#define int long long
#define endl '\n'
using namespace std;
 
typedef long long ll;
#define db(x) cerr << #x << ": " << x << '\n';
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define readarr(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}

#define print(a) cout << a << endl;
#define printarr(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;} cout << endl;
#define all(v) v.begin(), v.end()
#define sz(v) (int)(v.size())
#define rz(v, n) v.resize((n) + 1);
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define vvi vector <vi>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll N = 2e5 + 1;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	readb(n, k);
	readarr(a, n);
	a[0] = 0;
	vvi dp1(n + 1, vi(k + 1, inf)), dp(n + 1, vi(k + 1, inf));
	//dp1: i not taken, dp: either case
	
	dp1[0][0] = 0;
	FOR (i, 1, n)
	{
	    FOR (p, 0, min(i, k))
	    {
	        FORD (j, i - 1, 0)
	            if (p >= (i - j - 1))
	                dp1[i][p] = min(dp1[i][p], dp1[j][p - (i - j - 1)] + max(0LL, a[i] - a[j]));
	        
	        FORD (j, i, 0) 
	            if (p >= (i - j))
	                dp[i][p] = min(dp[i][p], dp1[j][p - (i - j)]);
	    }
	}
	
	cout << dp[n][k];
}

















Measured memory_bytes: 1664
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#include <set>
#define pye cout << "yes" << endl;
#define pno cout << "no" << endl;
#define pYe cout << "Yes" << endl;
#define pNo cout << "No" << endl;
#define pYE cout << "YES" << endl;
#define pNO cout << "NO" << endl;
#define prin(num) cout << num << endl;
#define REP(i, n) for(i=0; i<n; i++)
#define REPR(i, n) for(i=n; i>=0; i--)
#define FOR(i, m, n) for(i=m; i<n; i++)
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 10000000001
#define MAX 100000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll, ll> P;

int main(void) {
    ll a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a+3);
    
    if(a[0]%2==0 || a[1]%2==0 || a[2]%2==0) {
        prin(0)
    }else {
        prin(a[0]*a[1])
    }
    
}


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

int main() {
	int a, b;
	cin >> a >> b;

	if (a == b) cout << "Draw";
	else if (a == 1) cout << "Alice";
	else if (b == 1) cout << "Bob";
	else if (a > b) cout << "Alice";
	else cout << "Bob";
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define PRINTALL(V)                                                            \
  for (auto v : (V)) {                                                         \
    cerr << v << " ";                                                          \
  }                                                                            \
  cerr << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
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;
}
template < class T > using vec = std::vector< T >;
template < class T > void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int N;
  string S;
  cin >> N >> S;
  int p[2] = {0, 0};
  int c[2] = {0, 0};
  REP(i, N) {
    if (S[i] == '(') {
      if (p[1] != 0) {
        p[1]--;
      } else {
        p[0]++;
      }
    } else {
      if (p[0] != 0) {
        p[0]--;
      } else {
        c[1]++;
      }
    }
  }
  print(string(c[1], '(') + S + string(p[0], ')'));
}

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

int main() {
  long long n;
  cin >> n ;
  long long a=7%n, ans=0;
  for(long long i=1;i<=n;i++){
    if(a==0) {
      ans = i;
      break;
    }
    a=(10*a+7)%n;
  }
  if(ans==0) cout << -1 << endl;
  else cout << ans << endl;
}


Measured memory_bytes: 3608
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

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

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	n, k := nextInt(), nextInt()

	cnt := make([]int, n)
	for i := 0; i < k; i++ {
		d := nextInt()
		for j := 0; j < d; j++ {
			cnt[nextInt()-1]++
		}
	}

	ans := 0
	for i := range cnt {
		if cnt[i] == 0 {
			ans++
		}
	}

	puts(ans)
}


Measured memory_bytes: 1804
#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
int dist[105][105];

int main() {
  int v, e; cin >> v >> e;
  for (int i = 0; i < 105; i++) for (int j = 0; j < 105; j++) dist[i][j] = inf;
  for (int i = 0; i < e; i++) {
    int s, t; cin >> s >> t;
    dist[s][t] = 1;
  }
  for (int k = 0; k < 105; k++)
    for (int i = 0; i < 105; i++)
      for (int j = 0; j < 105; j++)
	dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
  int m = inf;
  for (int i = 0; i < 105; i++)
    m = min(m, dist[i][i]);
  cout << (m < inf) << endl;
}



Measured memory_bytes: 3140
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

int main(){
    int n;
    cin >> n;
    string s;
    s = to_string(n);
    if (s[0]=='7' || s[1]=='7' || s[2]=='7'){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3664
from collections import deque

class mf_graph:
    def __init__(self,N):
        self.N = N
        self.graph = [[] for _ in range(N)]
    
    def add_edge(self,v,w,cap):
        edge = [w,cap,None]
        edge[2] = rev_edge = [v,0,edge]
        self.graph[v].append(edge)
        self.graph[w].append(rev_edge)
    
    def bfs(self,s,t):
        self.level = [None]*self.N
        dq = deque([s])
        self.level[s] = 0
        while dq:
            v = dq.popleft()
            nlevel = self.level[v]+1
            for w,cap,_ in self.graph[v]:
                if cap and self.level[w] is None:
                    self.level[w] = nlevel
                    dq.append(w)
        return self.level[t] is not None
    
    def dfs(self,s,v,f):
        if v == s:
            return f
        for rev in self.it[v]:
            w,_,e = rev
            cap = e[1]
            if cap and self.level[w] is not None:
                if self.level[v] > self.level[w]:
                    d = self.dfs(s,w,min(f,cap))
                    if d:
                        e[1] -= d
                        rev[1] += d
                        return d
        self.level[v] == self.N
        return 0
    
    def flow(self,s,t,flow_limit=float('inf')):
        flow = 0
        while self.bfs(s,t):
            *self.it, = map(iter,self.graph)
            f = flow_limit
            while f:
                f = self.dfs(s,t,flow_limit-flow)
                flow += f
        return flow

N,M = map(int, input().split())
S = [list(input()) for i in range(N)]
dc = mf_graph(N*M+2)

s =N*M
t = N*M+1
for i in range(N):
    for j in range(M):
        if (i+j) % 2 == 0:
            dc.add_edge(s,M*i+j,1)
        else:
            dc.add_edge(M*i+j,t,1)

for i in range(N):
    for j in range(M):
        if j+1 < M and S[i][j] == "." and S[i][j+1] == ".":
            u,v = M*i+j,M*i+j+1
            if (i+j) % 2 == 1:
                u,v = v,u
            dc.add_edge(u,v,1)
        if i+1 < N and S[i][j] == "." and S[i+1][j] == ".":
            u,v = M*i+j, M*(i+1)+j
            if (i+j) % 2 == 1:
                u,v = v,u
            dc.add_edge(u,v,1)

print(dc.flow(s,t,10**9))
for u in range(N*M+2):
    for v,cap,_ in dc.graph[u]:
        ui,uj = divmod(u,M)
        vi,vj = divmod(v,M)
        if (ui+uj) % 2 == 0 and cap == 0 and u != s and u != t and v != s and v!= t:
            if ui+1 == vi:
                S[ui][uj] = "v"
                S[vi][vj] = "^"
            elif ui == vi+1:
                S[ui][uj] = "^"
                S[vi][vj] = "v"
            elif uj+1 == vj:
                S[ui][uj] = ">"
                S[vi][vj] = "<"
            elif uj == vj+1:
                S[ui][uj] = "<"
                S[vi][vj] = ">"

for res in S:
    print("".join(res))

Measured memory_bytes: 85160
//#include "stdafx.h"
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <functional>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <assert.h>
#include <functional>
#include <unordered_map>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define REP(i, n)				for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)			for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF						2e9
#define MOD						(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)				(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)				(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)			((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)				(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)				(!IsOdd((x)))						
#define	BitSetV(Val,Bit)		((Val) |= (Bit))			
#define	BitTstV(Val,Bit)		((Val) & (Bit))				
#define ArrayLength(x)			(sizeof( x ) / sizeof( x[ 0 ]))
#define	MAX_QWORD				((QWORD)0xFFFFFFFFFFFFFFFF)
#define	MIN_QWORD				((QWORD)0x0000000000000000)
#define	MAX_SQWORD				((SQWORD)0x7FFFFFFFFFFFFFFF)
#define	MIN_SQWORD				((SQWORD)0x8000000000000000)
#define M_PI					3.14159265358979323846
typedef long long				ll;
typedef unsigned long			DWORD;
typedef unsigned long long int	QWORD;
typedef pair<ll, ll>			P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
/* 素数判定 */
bool isPrime(QWORD p) 
{
	for (QWORD i = 2; i <= sqrt(p); i++) if (p % i == 0) return false;
	return p > 1;
}

// メイン
int main()
{
	// 入力
	ll A, B, C;
	cin >> A >> B >> C;

	ll d = max(A, max(B, C));
	ll ans = d * 10;
	if (d == A) {
		ans += (B + C);
	} else if (d == B) {
		ans += (A + C);
	} else {
		ans += (B + A);
	}

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



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int N = 5005;


int n, k;
bitset< N> seen;
int in[N];

bool chk(int v) {
    if (v >= k) return true;
    seen.reset();
    seen[0] = true;

    for (int i = 1; i <= n; ++i) {
        if (i == v) continue;
        seen |= (seen << in[i]);
    }

    //assert(k - in[v] >= 0);
    for (int i = max(0, k - in[v]); i < k; ++i) if (seen[i]) return true;
    return false;
}

int main() {
    scanf("%d %d", &n, &k);
    for (int i = 1; i <= n; ++i) scanf("%d", in + i);

    sort(in + 1, in + 1 + n);
    int res = 0;
    for (int b = n; b >= 1; b /= 2) {
        while (res + b <= n and chk(res + b) == false) res += b;
    }

    cout << res << endl;
}

Measured memory_bytes: 256
n,k=[int(i) for i in input().strip().split(" ")]
s = input().strip()
r = ""
for i,c in enumerate(s):
    if i != k-1:
        r += c
        continue
    if c == "A":
        r += "a"
    elif c == "B":
        r += "b"
    elif c == "C":
        r += "c"

print(r)


Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
#define MAX_M 100005
#define MAX_Q 100005
#define MAX 200005

int N,M,Q;
int d[MAX_M],a[MAX_M],b[MAX_M];
int e[MAX_Q],s[MAX_Q],t[MAX_Q];
int ans[MAX_Q];

vector<int> X;
vector<int> g[MAX];
vector<int> G[MAX];

int main(){
  scanf("%d %d %d",&N,&M,&Q);
  for(int i=0;i<M;i++){
    scanf("%d %d %d",&d[i],&a[i],&b[i]);
    X.push_back(d[i]);
  }
  for(int i=0;i<Q;i++){
    scanf("%d %d %d",&e[i],&s[i],&t[i]);
    X.push_back(e[i]);
  }
  sort(X.begin(),X.end());
  X.erase( unique( X.begin(), X.end() ), X.end() );
  
  for(int i=0;i<M;i++){
    d[i]=lower_bound(X.begin(),X.end(),d[i])-X.begin();

    g[ d[i] ].push_back(i);
  }
  
  for(int i=0;i<Q;i++){
    e[i]=lower_bound(X.begin(),X.end(),e[i])-X.begin();

    G[ e[i] ].push_back(i);
  }

  set<int> st;
  for(int i=1;i<N;i++)st.insert(i);
  set<int> :: iterator it;
  
  for(int i=0;i<MAX;i++){
    
    for(int id:G[i]){
      int left=s[id], right=t[id];
      it=st.lower_bound(left);
      if( it==st.end() || *it >= right ){
        ans[id]=1;
      }else{
        ans[id]=0;
      }
    }
    
    for(int id:g[i]){
      int left=a[id], right=b[id];
      while(1){
        it=st.lower_bound(left);
        if(it==st.end() || *it >= right)break;
        st.erase(it);
      }
    }
  }
  for(int i=0;i<Q;i++){
    if(ans[i]){
      cout<<"Yes"<<endl;
    }else{
      cout<<"No"<<endl;
    }
  }
  return 0;
}



Measured memory_bytes: 26720
#include <iostream>
#include <cstring>
#include <algorithm>
#include <stack>
const int MAX_W = 500, MAX_H = 500;
int W, H;
std::string map[MAX_H];

struct Rectangle{int height; int pos;};

int getLargestRect(int buffer[], int size){
	std::stack<Rectangle> s;
	buffer[size] = 0;
	int maxv = 0;
	for(int i=0;i<=size;i++){
		Rectangle rect;
		rect.height = buffer[i];
		rect.pos = i;
		if(s.empty()){
			s.push(rect);
		}
		else{
			if(s.top().height < rect.height){
				s.push(rect);
			}
			else if(s.top().height > rect.height){
				int target = i;
				while(!s.empty() && s.top().height >= rect.height){
					int area = (i - s.top().pos) * s.top().height;
					target = s.top().pos;
					maxv = std::max(maxv, area);
					s.pop();
				}
				rect.pos = target;
				s.push(rect);
			}
		}	
	}

	return maxv;
}

//ú
int getLargestRect(){
	int temp[H+1][W+1];
	memset(temp, 0, sizeof(temp));
	for(int j=0;j<W;j++){
		int seq = 0;
		for(int i=0;i<H;i++){
			if(map[i][j] == '*')
				seq = temp[i][j] = 0;
			else
				temp[i][j] = ++seq;
		}
	}

	int maxs = 0;
	for(int i=0;i<H;i++){
		maxs = std::max(maxs, getLargestRect(temp[i], W));
	}
	return maxs;
}

int main(){
	while(std::cin >> H >> W, W && H){
		for(int i=0;i<H;i++){
			std::cin >> map[i];
		}

		std::cout << getLargestRect() << std::endl;
	}
}

Measured memory_bytes: 2172
#include<algorithm>
#include<iostream>
#include<functional>
#include<cmath>
#include<iomanip>
using namespace std;
int main(){
  long int n,count=0,x,aa=0;
  cin>>n>>x;
  long int num[n];
  for(int i=0;i<n;i++){
    cin>>num[i];
    aa+=num[i];
  }
  sort(num,num+n);
  if(aa<x)
    cout<<n-1<<endl;
  else{
    for(int j=0;j<n;j++){
      if(x>=num[j]){
        count++;
        x-=num[j];
      }
    else
      break;
    }
    cout<<count<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  double a, b, h, m;
  cin >> a >> b >> h >> m;
  double pi = 3.141592653589793238462643383279502884197;
  double ang = fabs((h*60+m)/720 - m/60);
  if (ang > 0.5) ang = 1-ang;
  ang *= 2 * pi;
  double ans = sqrt(pow(a,2) + pow(b,2) - 2 * a * b * cos(ang));
  cout << setprecision(14) << ans;
  return 0;
  }

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

struct Benri { Benri() { std::cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(12);}} benri;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using pll = pair<ll, ll>;
using ull = unsigned long long;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
//constexpr int INF = 1001001001;
constexpr ll INF = 1001001001001001001ll;
constexpr double EPS = 1e-10;
using number = long long;



int main() {
    int N; cin >> N;
    vll h(N);
    rep(i, N) cin >> h[i];
    vll dp(N, INF);
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    for (int i = 2; i < N ; i++) {
        dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]),
                    dp[i - 2] + abs(h[i] - h[i - 2]));
    }

    cout << dp[N - 1] << endl;
}


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


int main()
{
    int n;
    cin >> n;
    vector<int> L(n);
    rep(i,n) cin >> L[i];

    int res = 0;
    for(int i = 0; i < n; ++i) {
        for(int j = i + 1; j < n; ++j) {
            for(int k = j + 1; k < n; ++k) {
                if(L[i] == L[j] || L[j] == L[k] || L[k] == L[i]) continue;
                vector<int> v = {L[i],L[j],L[k]};
                sort(v.begin(), v.end());
                res += (v[0] + v[1] > v[2]);
            }
        }
    }
    cout << res << "\n";
    return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
long long ans=0,n,x;
void dfs(long long x,long long y){
    if(x>y) swap(x,y);
    long long r=y/x;
    ans+=2LL*r*x;
    if(y%x==0) {ans-=x;return;}
    dfs(y%x,x);
}
int main(){
    scanf("%lld%lld",&n,&x);
    ans=n;
    dfs(x,n-x);
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#template
def inputlist(): return [int(j) for j in input().split()]
from collections import Counter
#template
#issueから始める
A,B,K = inputlist()
count = 0
while True:
    if A % 2 == 1:
        A -=1
    d = A//2
    B += d
    A -=d
    count +=1
    if count == K:
        break
    if B % 2 == 1:
        B-=1
    da = B//2
    A += da
    B -=da
    count +=1
    if count == K:
        break
print(A,B)

Measured memory_bytes: 3316
import java.util.Iterator;
import java.util.PrimitiveIterator;
import java.util.Scanner;
import java.util.stream.IntStream;
import java.util.stream.Stream;

class Main{
	private void solve(){
		int n=gInt(),in[]=ints(n).toArray();
		long min=2,max=2;
		for(int i:rrep(n-1,0)) {
			/*
			if(in[i]>max) {
				System.out.println(-1);
				return;
			}
			*/
			min=(min-1)/in[i]*in[i]+in[i];
			max=max/in[i]*in[i]+in[i]-1;
		}
		{
			long minmin=min;
			for(int v:in)
				minmin=minmin/v*v;
			if(minmin!=2) {
				System.out.println(-1);
				return;
			}
		}

		System.out.println(min+" "+max);
	}

	public static void main(String[]$){
		new Main().solve();
		System.out.flush();
	}

	static Scanner s=new Scanner(System.in);


	static int gInt(){
		return s.nextInt();
	}

	static long gLong(){
		return s.nextLong();
	}

	static long gDouble(){
		return s.nextLong();
	}


	static Range rep(int i){
		return new Range(i);
	}
	static Range rep(int f,int t,int d){
		return new Range(f,t,d);
	}
	static Range rep(int f,int t){
		return rep(f,t,1);
	}
	static Range rrep(int f,int t){
		return rep(f,t,-1);
	}

	static class Range implements Iterable<Integer>,PrimitiveIterator.OfInt{

		int to,cur,d;

		Range(int from,int to,int d){
			this.cur=from-d;
			this.to=to;
			this.d=d;
		}

		Range(int n){
			this(0,n-1,1);
		}

		@Override
		public Iterator<Integer> iterator(){
			return this;
		}

		@Override
		public boolean hasNext(){
			return cur+d==to||(cur!=to&&(cur<to==cur+d<to));
		}

		@Override
		public int nextInt(){
			return cur+=d;
		}
	}


	static IntStream REPS(int v){
		return IntStream.range(0,v);
	}

	static IntStream REPS(int l,int r){
		return IntStream.rangeClosed(l,r);
	}


	static IntStream ints(int n){
		return REPS(n).map(i->gInt());
	}

	static Stream<String> strs(int n){
		return REPS(n).mapToObj(i->s.next());
	}

}

Measured memory_bytes: 51508
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>
#include <deque>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
ll llmax = 10000000000000000000ll;
using namespace std;
using Graph = vector<vector<int>>;
Graph G;
const int AMAX = 100000;
/*int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}

int n;
vll a;

ll solve(bool isp)
{
	ll sum = 0ll;
	ll ret = 0ll;

	for (int i = 0; i < n; i++)
	{
		sum += a[i];
		if (isp and sum <= 0)
		{
			ret += -sum + 1;
			sum = 1ll;
		}
		if (not isp and sum >= 0)
		{
			ret += sum + 1;
			sum = -1ll;
		}
		isp ^= 1;
	}
	return ret;
}

*/
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int N;
	int ans = 1;
	//ll ans = 10000000000000000000ll;
	cin >> N;
	while(1)
	{

		if (ans > N)
		{
			cout << ans / 2 << endl;
			break;
		}
		ans *= 2;

	}
	
	return 0;

	


}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int fanc(int i, int j, int k){
  int r = i % j;
  while(r!=0){
    i = j;
    j = r;
    r = i % j;
  }
  r = j % k;
  while(r!=0){
    j = k;
    k = r;
    r = j % k;
  }
  return k;

}

int main(){
  int n , ans = 0;
  cin >> n;
  for(int i=1;i <=n;i++){
    for(int j=1;j<=n;j++){
      for(int k=1;k<=n;k++){
        ans += fanc(i,j,k);
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3624
// C - Exception Handling

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const int MOD = 1e9 + 7;

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


	int A[200000];
	int max1 = 0;
	int max2 = 0;;
	for (int i=0; i<N; i++) {
		cin >> A[i];
		if (A[i] >= max1) {
			max2 = max1;
			max1 = A[i];
		} else if (A[i] > max2) {
			max2 = A[i];
		}
	}

	for (int i=0; i<N; i++) {
		if (A[i] == max1) {
			cout << max2 << endl;
		} else {
			cout << max1 << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 2432
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
import cmath as cma
import copy as cp
import sys
def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def barr(n): return [False for _ in range(n)]
sys.setrecursionlimit(10**7)
MOD = 10**9 + 7; EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf

n,y = imap()
b = (2*n + 7*y)%9
a,mod = divmod(y - 1000*n - 4000*b, 9000)
c = n - b - a
ans = [a,b,c] if all([i>=0 for i in [a,c]]) and mod==0 else [-1,-1,-1]
print(*ans)



Measured memory_bytes: 16988
#include<stdio.h>

 void bubbleSort(int[],int);

 int main(){
   int A[100];
   int i,n;
   scanf("%d",&n);
   if(n>=1&&n<=100){

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

void bubbleSort(int A[],int n){
  int num;
  int count=0;
  int j,i,k;

  for(i=0;i<n-1;i++){
    for(j=n-1;j>=i+1;j--){  
      if(A[j]<A[j-1]){
        num=A[j-1];
        A[j-1]=A[j];
        A[j]=num;
        count++; 
      }
    }
  }
  for(k=0;k<n;k++){
    printf("%d",A[k]);
     if(k<n-1)printf(" ");
    }
    printf("\n");
  printf("%d\n",count);
}



Measured memory_bytes: 2704
import java.util.*;

public class Main {

    private static final int[] lp = new int[1000000 + 1];
    private static final List<Integer> pr = new ArrayList<>();

    static  {
        for (int i = 2; i <= 1000000; ++i) {
            if (lp[i] == 0) {
                lp[i] = i;
                pr.add(i);
            }
            for (int j = 0; j < pr.size() && pr.get(j) <= lp[i] && i*pr.get(j) <= 1000000; ++j) {
                lp[(i * pr.get(j))] = pr.get(j);
            }
        }
    }

    public static void main (String[] args) {

        final Scanner in = new Scanner(System.in);

        long N = in.nextLong();

        final long B = (long)Math.sqrt(N) + 1;
        long count = 0;

        final Set<Integer> usedPrimes = new HashSet<>();

        for (int prime = 2; prime <= Math.min(B, 1000000); ++prime) {
            if (lp[prime] == prime && (N > 0) && (N % prime == 0)) {
                long z = prime;
                usedPrimes.add(prime);
                while ((N > 0) && (N % z == 0)) {
                    count++;
                    N = N/z;
                    z = z*prime;
                }

                while ( (N > 0) && (N % prime == 0)) {
                    N = N/prime;
                }
            }
        }

        if (N > 1 && test(N, usedPrimes)) {
            count++;
        }
        System.out.println(count);
    }

    private static boolean test(final long N, final Set<Integer> usedPrimes) {
        for (int up : usedPrimes) {
            if (N % up == 0) {
                return false;
            }
        }

        return true;
    }
}

Measured memory_bytes: 44232
#include<stdio.h>
 
int main(){
  int n;
  scanf("%d", &n);
 
  char s[n];
  scanf("%s",s);
 
  int stone[n][2];
 
  int i,white=0,black=0;
 
  for(i= 0;i<n;i++){
    if(s[i]=='#'){
      black++;
    } else {
      white++;
    }
    stone[i][0] = white;
    stone[i][1] = black;
  }
 
  int min=(black>white)?white:black;
 
 for(i=0;i<n;i++){
   if(min>white-stone[i][0]+stone[i][1]) 
     min=white-stone[i][0]+stone[i][1];
 }
 
 printf("%d\n", min);
 
 return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using PL = pair<ll, ll>;
// Welcome to my source code!

int gcd(int x, int y) {
    if (y == 0) return x;
    return gcd(y, x % y);
}

int main() {
    int x, y;
    cin >> x >> y;
    int ans = gcd(x, y);
    cout << ans << endl;
}


Measured memory_bytes: 3104
# coding: utf-8
import math

n, m = map(int, input().split())
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(r)*math.factorial(n - r))

if n < 2:
  ns = 0
else:
  ns = combinations_count(n, 2)
if m < 2:
  ms = 0
else:
  ms = combinations_count(m, 2)
s = ns + ms
print(s)

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

using namespace std;
typedef unsigned int uint;
typedef long long int ll;
typedef unsigned long long int ull;

#define debugv(v) printf("L%d %s => ",__LINE__,#v);for(auto e:v){cout<<e<<" ";}cout<<endl;
#define debugm(m) printf("L%d %s is..\n",__LINE__,#m);for(auto v:m){for(auto e:v){cout<<e<<" ";}cout<<endl;}
#define debuga(m,w) printf("L%d %s is => ",__LINE__,#m);for(int x=0;x<(w);x++){cout<<(m)[x]<<" ";}cout<<endl;
#define debugaa(m,w,h) printf("L%d %s is..\n",__LINE__,#m);for(int y=0;y<(h);y++){for(int x=0;x<(w);x++){cout<<(m)[x][y]<<" ";}cout<<endl;}
#define debugaar(m,w,h) printf("L%d %s is..\n",__LINE__,#m);for(int y=0;y<(h);y++){for(int x=0;x<(w);x++){cout<<(m)[y][x]<<" ";}cout<<endl;}
#define ALL(v) (v).begin(),(v).end()
#define BIGINT 0x7FFFFFFF
#define E107 1000000007ll
void printbit(int u){if(u==0)cout<<0;else{int s=0,k=0;for(;0<u;u>>=1,k++)s=(s<<1)|(u&1);for(;0<k--;s>>=1)cout<<(s&1);}}

#define TIME chrono::system_clock::now()
#define MILLISEC(t) (chrono::duration_cast<chrono::milliseconds>(t).count())

template<typename T1,typename T2>
ostream& operator <<(ostream &o,const pair<T1,T2> p){o<<"("<<p.first<<":"<<p.second<<")";return o;}

int width,height;
int m,n,kei;

ll data[100010];
ll best[100010];
ll sum[100010];

int main(){
    int i,j;//,k;
    int x,y,a,b;
    
    cin >> n >> kei;
    
    for (i=0;i<n;i++){
        scanf("%lld",data+i);
        best[i+1] = best[i];
        sum [i+1] = sum [i];
        if (0<data[i])
            best[i+1] += data[i];
        sum[i+1] += data[i];
    }
    
    ll score=0;
    ll tmp;
    for (i=0;i<=n-kei;i++){
        tmp =best[i]-best[0];
        tmp+=best[n]-best[i+kei];
        score = max(score,tmp);
        tmp+=sum[i+kei]-sum[i];
        score = max(score,tmp);
    }
    
    
    cout << score << endl;
    
    
    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <numeric>
#include <set>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define INF 999999999
#define MINF -999999999
#define ALL(n) n.begin(),n.end()
#define ll long long
#define MOD 1000000007

map<ll, ll> mp;
ll n, m, now = 0, ans = 0;
int main() {
	cin >> n >> m;
	mp[0] = 1;
	REP(i, n) {
		ll a; cin >> a;
		now += a;
		now %= m;
		ans += mp[now];
		mp[now]++;
	}
	cout << ans << endl;
}



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

int main(){
	int answer=0;
	int n, h;
	std::vector<int> aList;
	std::vector<int> bList;

	std::cin>>n>>h;

	aList.resize(n);
	bList.resize(n);

	for(int i=0; i<n; i++)
		std::cin>>aList[i]>>bList[i];

	std::sort(aList.begin(), aList.end(), [](int x, int y){return x>y;});
	std::sort(bList.begin(), bList.end(), [](int x, int y){return x>y;});

	int bIdx=0;

	while(h>0){
		if(bIdx<n && aList[0] < bList[bIdx]){
			h-= bList[bIdx];
			bIdx++;
			answer++;
		}
		else{
			int numA= h/aList[0];

			if(h%aList[0]>0)
				numA++;

			h=0;
			answer+= numA;
		}


	}

	std::cout<<answer<<std::endl;

	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double L, A, B, C, D;
        L = sc.nextInt();
        A = sc.nextInt();
        B = sc.nextInt();
        C = sc.nextInt();
        D = sc.nextInt();
        if(Math.ceil(A / C) > Math.ceil(B / D)){
        	System.out.println((int)(L - Math.ceil(A / C)));
        }else{
        	System.out.println((int)(L - Math.ceil(B / D)));
        }
    }
}

Measured memory_bytes: 17352
/*
 * Author:  heyuhhh
 * Created Time:  2020/5/5 19:09:28
 */
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <assert.h>
#define MP make_pair
#define fi first
#define se second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define INF 0x3f3f3f3f
#define Local
#ifdef Local
  #define dbg(args...) do { cout << #args << " -> "; err(args); } while (0)
  void err() { std::cout << std::endl; }
  template<typename T, typename...Args>
  void err(T a, Args...args) { std::cout << a << ' '; err(args...); }
  template <template<typename...> class T, typename t, typename... A> 
  void err(const T <t> &arg, const A&... args) {
  for (auto &v : arg) std::cout << v << ' '; err(args...); }
#else
  #define dbg(...)
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
//head
const int N = 2e5 + 5;

int n;
int a[N];
int cnt[N << 1];

void run() {
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    ll ans = 0;
    for (int i = 1; i <= n; i++) if (a[i] <= N) {
        int t = i - a[i];
        if (t >= 0) {
            ans += cnt[t];
        }
        t = i + a[i];
        if (t < N << 1) ++cnt[t];
    }
    cout << ans << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(20);
    run();
    return 0;
}

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

#define pb push_back
#define PQ priority_queue
#define make_unique(x) sort((x).begin(), (x).end()); (x).erase(unique((x).begin(), (x).end()), (x).end())

typedef long long ll;
typedef long double ld;

//__builtin_popcount(x)

using namespace std;

/*const int mod = 1e9 + 7;

ll add(ll a, ll b) {
    ll res = a + b;
    if (res >= mod) res -= mod;
    return res;
}

ll sub(ll a, ll b) {
    ll res = a - b + mod;
    if (res >= mod) res -= mod;
    return res;
}

ll mul(ll a, ll b) {
    return (((a % mod) * (b % mod)) % mod);
}*/

/*vector<int> find_dividers(int x) {
    vector<int> dividers;

    for (int i = 1; i <= sqrt(x); i++) {
        if (x % i == 0) {
           dividers.push_back(i);
            if (i * i != x) {
                dividers.push_back(x / i);
            }
        }
    }

    return dividers;
}*/

/*int nok(int a, int b) {
    return a / __gcd(a, b) * b;
}*/

void solve() {
    int n;
    cin >> n;
    cout << ((n < 30) ? "No" : "Yes") << endl;
}

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

    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }

    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#define UMI 0
#define RIKU 1
using namespace std;

int w,h;
int c[50][50];

void pr(){
  for( int i=0;i<h;i++ ){
    for( int j=0;j<w;j++ )
      cout << c[i][j] << " ";
    cout << endl;
  }
}

void check( int x,int y){
  if( x<0 || x>=h ) return;
  if( y<0 || y>=w ) return;
  if( c[x][y]==UMI ) return;

  c[x][y] = UMI;
  check( x-1, y-1);
  check( x-1, y  );
  check( x-1, y+1);
  check( x  , y-1);
  check( x  , y+1);
  check( x+1, y-1);
  check( x+1, y  );
  check( x+1, y+1);
}

int main(){
  while( cin>>w>>h,w&&h ){
    for( int i=0;i<h;i++ )
      for( int j=0;j<w;j++ )
	cin >> c[i][j];
    //cout << w <<" "<< h<<endl;
    //    pr();
    int sum = 0;
    for( int i=0;i<h;i++ )
      for( int j=0;j<w;j++ )
	if( c[i][j]==RIKU ){
	  ++sum;
	  check(i,j);
	}
    cout << sum << endl;
  }

  return 0;
}

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

#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define INT_MAX_HALF (INT_MAX / 2)
#define EPS (1e-10)

using namespace std;

typedef long long ll;

int main(){

    ll h,w;
    cin >> h >> w;

    if(w == 1 || h == 1){
        cout << 1 << endl;
    }else if(w % 2 == 0 || h % 2 == 0){
        cout << h * w / 2 << endl;
    }else{
        cout << h * w / 2 + 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) throws Exception {
    Scanner sc = new Scanner(System.in);
    Map<String , Integer> map = new HashMap<String , Integer>();
    int plusCard = sc.nextInt();
    
    for(int i = 0 ; i < plusCard ; i++){  //プラスカードの値をセットに入れる
      String fruit = sc.next();
      if(map.containsKey(fruit)){
        map.replace(fruit , map.get(fruit)+1);
      }else{
        map.put(fruit , 1);
    }
}
    int minusCard = sc.nextInt();
    
    for(int i = 0 ; i < minusCard ; i++){  //マイナスカードの値を影響させる
      String fruit = sc.next();
      if(map.containsKey(fruit)){
        map.replace(fruit , map.get(fruit)-1);
      }else{
        map.put(fruit , -1);
      }
    }
    int max = 0;
    
    for(String key : map.keySet()){
      int token = map.get(key);
      if(token > max){
        max = token;
      }
   }
   System.out.println(max);
 }
}

Measured memory_bytes: 21844
n,a,b,c,d=map(int,input().split())
s=input()
if c<d:
  if "#" in s[a-1]+s[b-1]+s[c-1]+s[d-1]:print("No");exit()
  ans="Yes"
  for i in range(c-a):
    if s[a+i-1]==s[a+i]=="#":ans="No"
  for i in range(d-b):
    if s[b+i-1]==s[b+i]=="#":ans="No"
  print(ans)
else:
  if "#" in s[a-1]+s[b-1]+s[c-1]+s[d-1]:print("No");exit()
  ans="No"
  for i in range(d-b+1):
    if s[b+i-2]==s[b+i-1]==s[b+i]==".":ans="Yes"
  for i in range(c-a):
    if s[a+i-1]==s[a+i]=="#":ans="No"
  print(ans)

Measured memory_bytes: 3572
#include <stdio.h>

int main(void)
{
	int num[55], n, i, con, s[55], h[55], c[55], d[55] ;
	char shape[60];
	


	for (i = 0; i < 55; i++) {
		shape[i] = 'Z';
		num[i] = 0;
		s[i] = 0;
		h[i] = 0;
		c[i] = 0;
		d[i] = 0;
	}

	scanf("%d", &n);


	for (i = 0; i < n; i++) {
		
		
		scanf("%s", &shape[i]);
		
		scanf(" %d", &num[i]);
		

	}
	

	for (i = 0; i < n; i++) {
		if (shape[i] == 'S') {
			s[num[i]] = 1;
			
		}
		if (shape[i] == 'H') {
			h[num[i]] = 1;
	
		}

		if (shape[i] == 'C') {
			c[num[i]] = 1;
			
		}
		if (shape[i] == 'D') {
			d[num[i]] = 1;
			
		}
	}

	for (i = 1; i <= 13; i++) {
		if (s[i] == 0) {
			printf("S %d\n", i);
		}
	}
	for (i = 1; i <= 13; i++) {
		if (h[i] == 0) {
			printf("H %d\n", i);
		}
	}for (i = 1; i <= 13; i++) {
		if (c[i] == 0) {
			printf("C %d\n", i);
		}
	}for (i = 1; i <= 13; i++) {
		if (d[i] == 0) {
			printf("D %d\n", i);
		}
	}

	return 0;
}


Measured memory_bytes: 2020
#include <iostream>
#include <complex>
#include <vector>
#include <cmath>

const double EPS=1e-10;

#define equals(a, b) (fabs((a)-b(b))<EPS)
#define X real()
#define Y imag()

using namespace std;

typedef complex<double> Point;
typedef complex<double> Vector;

struct Segment {
    Point p1, p2;
};
typedef Segment Line;

struct Circle {
    Point c;
    double r;
    Circle(Point c=Point(), double r=0.0) :
        c(c),r(r){}
};

typedef vector<Point> Polygon;

double dot(Vector a, Vector b) {
    return a.X*b.X + a.Y*b.Y;
}

double cross(Vector a,Vector b) {
    return a.X*b.Y - a.Y*b.X;
}

Point project(Segment s, Point p) {
    Vector base = s.p2-s.p1;
    double r=dot(p-s.p1,base) / norm(base);
    return s.p1+base*r;
}

Point reflect(Segment s, Point p) {
    return p+(project(s,p)-p)*2.0;
}

int main() {
    Point p0,p1;
    {
        double x1,y1,x2,y2;
        cin>>x1>>y1>>x2>>y2;
        p0=Point(x1,y1);
        p1=Point(x2,y2);
    }
    int q; cin>>q;
    while(q-->0) {
        double x1,y1;
        cin>>x1>>y1;
        Point p2=Point(x1,y1);
        Vector a=p1-p0;
        Vector b=p2-p0;
        if(cross(a,b)>EPS) cout<<"COUNTER_CLOCKWISE"<<endl;
        else if(cross(a,b)<-EPS) cout<<"CLOCKWISE"<<endl;
        else if(dot(a,b)<-EPS) cout<<"ONLINE_BACK"<<endl;
        else if(norm(a)<norm(b)) cout<<"ONLINE_FRONT"<<endl;
        else cout<<"ON_SEGMENT"<<endl;

    }
    return 0;
}

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

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(ull i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)
#define iter(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define riter(i,c) for(auto i=(c).rbegin(); i!=(c).rend(); ++i)

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

#define clr(a,i) memset((a), (i) ,sizeof(a))

int main(){
  long long n=0,ans=0,tmp=0,ma=0;
  std::cin >> n;
  rep(i,n+1){
    tmp+=i;
    if(tmp>=n){
      ma = i;
      break;
    }
  }
  for(long long i=ma; i>0; i--){
    if(n>=i){
      cout << i << endl;
      n-=i;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define For(i, a, b)  for(int i = a, _b = b; i <= _b; ++i)
#define Ford(i, a, b) for(int i = a, _b = b; i >= _b; --i)
#define FileName      "test"
#define ll            long long
#define ld            long double
#define ull           unsigned long long
#define Print(x)      cerr << #x << "is " << x << '\n';
#define pb            push_back
#define X             first
#define Y             second
//#define Karma

using namespace std;

template<typename T> inline void Cin(T &x)
{
    char c;
    T sign = 1;
    x = 0;
    for (c = getchar(); c < '0' || c > '9'; c = getchar())
        if (c == '-') sign = -1;
    for (; c >= '0' && c <= '9'; c = getchar())
        x = x * 10 + c - '0';
    x *= sign;
}
template <typename T> inline void Out(T x) {if(x > 9) Out(x / 10); putchar(x % 10 + '0');}
template <typename T> inline void Cout(T x, char c) {if(x < 0) putchar('-'); x = abs(x); Out(x); putchar(c);}
template <typename T, typename... Args> inline void Cin(T& a, Args&... args) {Cin(a);Cin(args...);}
template <typename T, typename... Args> inline void Cout(T a, char c, Args... args) {Cout(a, c);Cout(args...);}

typedef pair<int, int> pii;
const int N = 2e5 + 7;
const ll oo = 1e18 + 7;

int n, m, l, r, x;
vector<pii> add[N], del[N];

struct TSegment
{
    int l[N << 2], h[N << 2];
    ll st[N << 2], lazy[N << 2];
    #define mid (low + high) / 2
    void Build(int x, int low, int high)
    {
         l[x] = low, h[x] = high;
         if(l[x] == h[x]) return;
         Build(x << 1, low, mid);
         Build(x << 1 | 1, mid + 1, high);
    }
    void Down(int x)
    {
        st[x] += lazy[x];
        if(l[x] == h[x] || !lazy[x]) {lazy[x] = 0; return;}
        lazy[x << 1] += lazy[x], lazy[x << 1 | 1] += lazy[x];
        lazy[x] = 0;
    }
    void Update(int x, int low, int high, ll v)
    {
         Down(x);
         if(low > h[x] || l[x] > high) return;
         if(low <= l[x] && h[x] <= high)
         {
             lazy[x] += v;
             Down(x);
             return;
         }
         Update(x << 1, low, high, v);
         Update(x << 1 | 1, low, high, v);
         st[x] = max(st[x << 1], st[x << 1 | 1]);
    }
    ll Query(int x, int low, int high)
    {
        Down(x);
        if(low > h[x] || l[x] > high) return -oo;
        if(low <= l[x] && h[x] <= high) return st[x];
        return max(Query(x << 1, low, high), Query(x << 1 | 1, low, high));
    }
    #undef mid
} Seg;

void Enter()
{
     Cin(n, m);
     while(m --)
     {
         Cin(l, r, x);
         add[l].emplace_back(l - 1, x), del[r].emplace_back(l - 1, -x);
     }
}

void Solve()
{
     ll res = 0;
     Seg.Build(1, 0, n);
     For(i, 1, n)
     {
         for(pii p: add[i]) Seg.Update(1, 0, p.X, p.Y);
         ll f = Seg.Query(1, 0, i - 1);
         res = max(res, f);
         Seg.Update(1, i, i, f);
         for(pii p: del[i]) Seg.Update(1, 0, p.X, p.Y);
     }
     cout << res;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
#ifdef Karma
    freopen(FileName".inp", "r", stdin);
    freopen(FileName".out", "w", stdout);
#endif // Karma

    Enter();
    Solve();

    return 0;
}


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

#define MAX_V 1000
#define INF 100000001
typedef long long ll;

struct edge { ll to, cost; };
typedef pair<ll, ll> P; // firstは最短距離、secondは頂点の番号
vector<edge> G[MAX_V];
ll d[MAX_V];

void dijkstra(int s) {
	// greater<P>を指定することでfirstが小さい順に取り出せるようにする
	priority_queue<P, vector<P>, greater<P> > que;
	fill(d, d + MAX_V, INF);
	d[s] = 0;
	que.push(P(0, s));
	while (!que.empty()) {
		P p = que.top(); que.pop();
		int v = p.second;
		if (d[v] < p.first) continue;
		for (int i = 0; i < G[v].size(); i++) {
			edge e = G[v][i];
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}

int main(){	
	vector< vector<long long> > c(9-0+1,vector<long long>(9-0+1));
	long long W;
	long long H;
	scanf("%lld",&H);
	scanf("%lld",&W);
	vector< vector<long long> > A(H-1+1,vector<long long>(W-1+1));
	for(int i = 0 ; i <= 9-0 ; i++){
		for(int j = 0 ; j <= 9-0 ; j++){
			scanf("%lld",&c[i][j]);
			edge e = {j,c[i][j]};
			G[i].push_back(e);
		}
	}
	for(int i = 0 ; i <= H-1 ; i++){
		for(int j = 0 ; j <= W-1 ; j++){
			scanf("%lld",&A[i][j]);
		}
	}
	
	ll cost[10];

	for (int i=0; i<=9; i++) {
		dijkstra(i);
		cost[i] = d[1];
	}

	ll res = 0;
	for(int i = 0 ; i <= H-1 ; i++){
		for(int j = 0 ; j <= W-1 ; j++){
			if (A[i][j] != -1) res += cost[A[i][j]];
		}
	}

	cout << res << endl;

	return 0;
}



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

int main(){
    string s;
    vector<int> count(4);
    count[0] = 0;
    count[1] = 0;
    count[2] = 0;
    count[3] = 0;

    while(cin >> s){
        string::size_type comma = s.find(",");
        string bloodtype = s.substr(comma+1);
        if(bloodtype == "A"){
            count[0]++;
        }
        if(bloodtype == "B"){
            count[1]++;
        }
        if(bloodtype == "AB"){
            count[2]++;
        }
        if(bloodtype == "O"){
            count[3]++;
        }
    }

    for(int i=0; i<4; i++){
        cout << count[i] << endl;
    }

    return 0;
}

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

int main()
{
    int N;
    cin >> N;
    int ans = 0;
    int num = 1;
    for (int i = 1; i <= N; i++)
    {
        int temp = i;
        int cnt = 0;
        while (1)
        {
            if (temp % 2 == 0)
            {
                cnt++;
                temp = temp / 2;
            }
            else
            {
                break;
            }
        }
        if (cnt > ans)
        {
            ans = cnt;
            num = i;
        }
    }
    cout << num;

    return 0;
}


Measured memory_bytes: 256
N,M= list(map(int, input().split()))
li=[list(map(int,input().split())) for _ in range(M)]
lisorted=sorted(li)
dic={}
memo=0
for i in lisorted:
    if memo!=i[0]:
        check=1
        dic[i[1]]="{0:06d}".format(i[0])+"{0:06d}".format(check)
        memo=i[0]
    else:
        check+=1
        dic[i[1]]="{0:06d}".format(i[0])+"{0:06d}".format(check)
for i in li:
    print(dic[i[1]])

Measured memory_bytes: 86360