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

using namespace std;
 
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

#define pb push_back;
#define mp make_pair;
#define fi first;
#define se second;
#define all(x) (x).begin(), (x).end()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())

typedef vector<int> vi;
typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;

const int INF = 1 << 29;
const int MOD = 1e9 + 7;
 
int main() {
  int n, k, q;
  scanf("%d%d%d", &n, &k, &q);
  vi p(n,k);
  forn(i, q){
    int k;
    cin >> k;
    --k;
    p[k]++;
  }
  for(auto s1 : p) {
    //trace(s1-q);
    s1-q < 1 ? puts("No") : puts("Yes");
  }
}

/*
  4
  5 5 5 5 5 5
  5 5 6 5 5 5
  6 5 6 5 5 5
  6 5 7 5 5 5
  6 6 7 5 5 5

  4 
  3 3 3 3 3 3
  3 3 4 3 3 3
  4 3 4 3 3 3
  4 3 5 3 3 3
  4 4 5 3 3 3
*/


Measured memory_bytes: 1024
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
 

//result = Math.pow(num1, num3)
//StringBuffer str = new StringBuffer(hoge1);
//String hoge2 = str.reverse().toString();
//map.containsKey(A)

//Map<String, Integer> map = new HashMap<String, Integer>(n);
/*for ( キーのデータ型 key : マップの名前.keySet() ) {
	データのデータ型 data = マップの名前.get( key );
	
	// keyやdataを使った処理;
}*/
//int i = Integer.parseInt(s);
//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
//ArrayList<String> cc = new ArrayList<>(n);
//Collections.sort(list);
//Array.sort(list);
//Arrays.asList(c).contains("a")
//list.set(1,"walk");
public class Main {
	static int a1[]= {0,-1,0,1};
	static int b1[]= {-1,0,1,0};
	private static Scanner sc = new Scanner(System.in);
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	static int K;
	public static void main(String[] args) {
		int N=sc.nextInt();
		int maxCtn=0;
		int maxAns=1;
		int ctn=0;
		for(int i=1;i<=N;i++) {

			int v=i;
			while(v%2!=1) {
				v=v/2;
				ctn++;
			}
			if(maxCtn<ctn) {
			//	p("ctn"+ctn+"i"+i);
			//	p("a");
				maxCtn=ctn;
				maxAns=i;
			}
			ctn=0;
		}
		p(maxAns);
	}
}


Measured memory_bytes: 21844
N, K = [int(str) for str in input().strip().split()]
A = [int(str) for str in input().strip().split()]

min_index = A.index(min(A))
# ans = min_index // (K - 1) + (N - min_index - 1) // (K - 1)
ans = (N - 1) // (K - 1) + (1 if (N - 1) % (K - 1) else 0)

print(ans)

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

#define pb push_back
#define mp make_pair
#define f1 first
#define s2 second

#define fastio ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define debug(x...) cerr << "[" << #x << "]: " << x << "\n";

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> pl;

ld const PI = 4*atan((ld)1);

int main()
{
	fastio;

	int n;
	string s;
	cin >> n >> s;

	int w = 0, r = 0;
	for (int i = 0; i < s.size(); ++i)
		s[i] == 'W' ? w++ : r++;

	int a = 0, b = 0;
	for (int i = 0; i < r; ++i)
		a += (s[i] == 'W');

	for (int i = n-1; i >= n-w; --i)
		b += (s[i] == 'R');

	cout << min(a, b) << '\n';
	return 0;
}


Measured memory_bytes: 3776
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <queue>
#include <string>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){
    int n,d,x;
    cin >> n >> d >> x;
    int cnt = 0;
    int tmp;
    
    rep(i,n){ 
        cin >> tmp;
        //cout << i << " " << (d-1)/tmp << endl;
        cnt += ((d-1)/tmp);
    }

    cout << cnt+n+x << endl;

    return 0;
}


Measured memory_bytes: 3600
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    String data = scan.next();
    int max=0, i=0;
    for(int j=0;j<3;j++){
     if(data.charAt(j)=='R')i++;
     else i=0;
     if(i>max)max=i;
    }
    System.out.println(""+max);
  }
  
}

Measured memory_bytes: 38588
#include "bits/stdc++.h"
using namespace std;
int solve(set<int> s,int a){
  for(auto it=s.begin();it!=s.end();it++){
    if(a<*it)
      return *it;
  }
  return 0;
}
int main(){
  int n;
  while(1){
    cin>>n;
    if(!n)break;
    bool f[201];
    memset(f,false,sizeof(f));
    set<int> s1,s2;
    for(int i=0;i<n;i++){
      int tmp;
      cin>>tmp;
      f[tmp]=true;
      s1.insert(tmp);
    }
    for(int i=1;i<=2*n;i++){
      if(!f[i])s2.insert(i);
    }
    int field=0,turn=0;
    while(!s1.empty()&&!s2.empty()){
      int card;
      if(turn%2==0){
	card=solve(s1,field);
	s1.erase(card);
	field=card;
      }
      else{
	card=solve(s2,field);
	s2.erase(card);
	field=card;
      }
      turn++;
    }
    if(s1.empty()){
      cout<<s2.size()<<endl;
      cout<<0<<endl;
    }
    else{
      cout<<0<<endl;
      cout<<s1.size()<<endl;
    }
  }
  return 0;
}

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

using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr ll mod = static_cast<ll>(1e9 + 7);

template<long long Mod, int Max>
class Comb
{
public:
	Comb() :fac(Max), finv(Max)
	{
		std::vector<long long> inv(Max);

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

	constexpr long long C(int n, int k) {
		if (n < k) return 0;
		if (n < 0 || k < 0) return 0;
		return fac[n] * (finv[k] * finv[n - k] % Mod) % Mod;
	}

private:
	std::vector<long long> fac;
	std::vector<long long> finv;
};

int n, m;
int k;
Comb<mod, 200005> com;
long long solve(int rows, int columns) {
	ll ans = 0;

	for (int i = 1; i < columns; ++i) {
		ans = (ans + i * static_cast<ll>(rows) * (static_cast<ll>(columns) - i) % mod * rows % mod) % mod;
	}

	ans = ans * com.C(n * m - 2, k - 2) % mod;

	return ans;
}

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

	auto x = solve(n, m);
	auto y = solve(m, n);

	std::cout << (x + y) % mod << std::endl;

	return 0;
}


Measured memory_bytes: 5500
package main

import "fmt"

func main() {
	for {
		var x, y int
		fmt.Scan(&x, &y)
		if x == 0 && y == 0 {
			break
		}
		if x < y {
			fmt.Println(x, y)
		} else {
			fmt.Println(y, x)
		}
	}
}



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

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

  if(S=="Sunny") cout << "Cloudy" << endl;
  else if(S=="Cloudy") cout << "Rainy" << endl;
  else if(S=="Rainy") cout << "Sunny" << endl;


  return 0;
}


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

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

class Dice {
public:
  vector<int> num;
  Dice(const vector<int> &n) : num(n) {;}
  void rotate_x() {
    tie(num[0], num[1], num[2], num[3]) = make_tuple(num[1], num[2], num[3], num[0]);
  }
  void rotate_y() {
    tie(num[1], num[4], num[3], num[5]) = make_tuple(num[4], num[3], num[5], num[1]);
  }
  void rotate_z() {
    tie(num[0], num[5], num[2], num[4]) = make_tuple(num[5], num[2], num[4], num[0]);
  }
  bool eq(const Dice &other) const {
    REP(i, 6) {
      if (num[i] != other.num[i]) { return false; }
    }
    return true;
  }
  void show() {
    cout << " " << num[4] << endl;
    cout << "   " << num[1] << endl;
    cout << num[0] << endl;
  }
};

bool equal(const Dice &a, Dice b) {
  REP(i, 2) {
    REP(j, 3) {
      if (a.eq(b)) return true;
      REP(k , 3) {
        b.rotate_z();
        if (a.eq(b)) return true;
      }
      b.rotate_y();
    }
    b.rotate_z();
    REP(j, 2) b.rotate_y();
  }
  return false;
}

int main() {
  cout << fixed << setprecision(10);
  vector<int> num(6);
  REP(i, 6) cin >> num[i];
  tie(num[0], num[3], num[4]) = make_tuple(num[3], num[4], num[0]);
  Dice a(num);
  REP(i, 6) cin >> num[i];
  tie(num[0], num[3], num[4]) = make_tuple(num[3], num[4], num[0]);
  Dice b(num);
  cout <<  (equal(a, b) ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 3148
#include<iostream>
using namespace std;
#define MAX 200000
#define SENTINEL 2000000000
typedef long long llong;
int L[MAX/2+2],R[MAX/2+2];

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


llong inversion(int A[],int left,int right){
    llong cnt1,cnt2,m;
    int mid;
    if(left+1<right){
        mid=(left+right)/2;
        cnt1 = inversion(A,left,mid);
        cnt2 = inversion(A,mid,right);
        m = merge(A,left,right,mid);
        return cnt1 + cnt2 + m;
    }else{
        return 0;
    }
}

int main(){
    int n,A[MAX];
    //scanf("%d",&n);
    cin >> n;
    for(int i=0;i<n;i++)cin >> A[i];
    llong ans = inversion(A,0,n);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4652
#include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<deque>
#include<sstream>
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<bitset>
#include<time.h>
#include<cstdlib>
#include<cassert>
#define ll long long
#define fi first
#define se second
using namespace std;

int n;
ll a[100001];
                 
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout<<fixed;
#ifdef LOCAL_DEFINE
    freopen("in", "r", stdin); 
    freopen("out","w",stdout);
#endif
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  ll ansa=0;
  ll sum=a[0];
  if(sum<=0){
    sum=1;
    ansa+=1-a[0];
  }
  for(int i=1;i<n;i++){
    ll nowsum=sum+a[i];
    if(nowsum<=0 && i%2==0){
      ansa+=1-nowsum;
      sum=1;
    }else if(nowsum>=0 && i%2==1){
      ansa+=nowsum+1;
      sum=-1;
    }else sum=nowsum;
    //cout<<ansa<<endl;
  }
  ll ansb=0;
  sum=a[0];
  if(sum>=0){
    sum=-1;
    ansb+=a[0]+1;
  }
  for(int i=1;i<n;i++){
    ll nowsum=sum+a[i];
    if(nowsum<=0 && i%2==1){
      ansb+=1-nowsum;
      sum=1;
    }else if(nowsum>=0 && i%2==0){
      ansb+=nowsum+1;
      sum=-1;
    }else sum=nowsum;
  }
  //cout<<ansa<<endl;
  //cout<<ansb<<endl;
  cout<<min(ansa,ansb)<<"\n";
#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
  return 0;
}

Measured memory_bytes: 1024
n, m, k = map(int, input().split())

ans = set()

for i in range(m+1):
    cnt = i * n
    rev = m - i
    for j in range(n+1):
        ans.add(cnt + (rev - i) * j)

if k in ans:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 20872
#include <bits/stdc++.h>
using namespace std;
#define int long long
int solve(int l, int r) {
	int ans = 2019;
	for(int i=l; i<=r; i++) {
		for(int j=l+1; j<=r; j++) {
			ans = min(ans, (i*j)%2019);
		}
	}
	return ans;
}
int32_t main() {
	ios::sync_with_stdio(0);cin.tie(0);
	int l, r;
	cin >> l >> r;
	int ans = 2019;
	if(r-l <= 2222) {
		for(int i=l; i<=r; i++) {
			for(int j=i+1; j<=r; j++) {
				ans = min(ans, (i*j)%2019);
			}
		}
		cout << ans;
	} else
		cout << 0;
}

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

int main(){
  int n,m;
  cin>>n>>m;
  vector<pair<int64_t,int64_t>> p(n);
  for(int i=0;i<n;++i) cin>>p[i].first>>p[i].second;
  sort(p.begin(),p.end());

  int64_t sum=m,ans=0;
  for(int i=0;i<n;++i){
    int64_t a=p[i].first,b=p[i].second;
    if(b<m){
      ans += a*b;
      m -= b;
    }
    else{
      ans += a*m;
      cout<<ans<<endl;
      break;
    }
  }
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using std::queue;
const int N=100005;
int to[N<<1],edge,last[N],Next[N<<1],son[N],a[N],f[N],n,k,deep[N];
int ans;
queue <int> q;
void add(int x,int y){
	to[++edge]=y;
	Next[edge]=last[x];
	last[x]=edge;
}
void dfs(int x,int fa){
	f[x]=fa;
	for (int i=last[x];i;i=Next[i])
		if (to[i]!=fa){
			dfs(to[i],x);
			son[x]++;
		}
}
int main(){
	scanf("%d%d",&n,&k);
	scanf("%d",&a[1]);
	if (a[1]!=1) ans=1;
	for (int i=2;i<=n;i++){
		scanf("%d",&a[i]);
		add(i,a[i]),add(a[i],i);
	}
	dfs(1,0);
	for (int i=1;i<=n;i++) 
		if (son[i]==0) q.push(i),deep[i]=1;
	while (!q.empty()){
		int x=q.front();
		q.pop();
		if (x==1) break;
		if (deep[x]>=k && f[x]!=1){
			deep[x]=0;
			ans++;
		}
		deep[f[x]]=std::max(deep[f[x]],deep[x]+1);
		son[f[x]]--;
		if (!son[f[x]]) q.push(f[x]);
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 8448
#include <bits/stdc++.h>
using namespace std;
 
#define fastio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define lli long long int
#define rep(i,n,z) for(int i=z;i<n;i++)
#define rrep(i,z) for(int i=z;i>=0;i--)
#define nl cout<<endl
#define vi vector<int>
#define vlli vector<long long int>
#define umap unordered_map
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define ipair pair <int,int>
#define llipair pair <lli,lli>
#define pq priority_queue
#define displaymatrix(a,m,n) for(int i=0;i<m;i++){for(int j=0;j<n;j++)cout<<a[i][j]<<" ";cout<<endl;}
#define printarray(a,n) for(int i=0;i<n;i++){cout<<a[i]<<" ";}nl;
#define vinput(a,n) vlli a(n);rep(i,n,0)cin>>a[i]
#define ainput(a,n) rep(i,n,0)cin>>a[i]
#define SO(a) sort(a.begin(),a.end())
#define all(x) (x).begin(),(x).end()
#define SOP(a,comp) sort(a.begin(),a.end(),comp)
#define inf INT_MAX
#define endl '\n'
 
int main()
{
    fastio;
    int n;
    cin>>n;
    map<string,int> M;

    string s;
    rep(i,n,0){
        cin>>s;
        M[s]++;
    }

    cout<<"AC x "<<M["AC"]<<endl;
    cout<<"WA x "<<M["WA"]<<endl;
    cout<<"TLE x "<<M["TLE"]<<endl;
    cout<<"RE x "<<M["RE"]<<endl;
}

Measured memory_bytes: 3576
# coding: utf-8
# Your code here!
import math

def main():
    a, b, c, k = map(int, input().split())
    if k >= a:
        ans = a
        k = k - a
    else:
        print(k)
        return 0
    if k >= b:
        k = k - b
    else:
        print(ans)
        return 0
    if k >= c:
        ans -= c
    else:
        ans -= k
    print(ans)
    
    
main()

Measured memory_bytes: 9064
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while(scanner.hasNextInt()) {
            int a = scanner.nextInt();
            int b = scanner.nextInt();
            System.out.println( (int)Math.floor( Math.log10(a+b) ) + 1 );
        }
    }
}

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

int main(){
	vector<int> v1,v2;
	int w,d,x,res;
	while(1){
		res = 0;
		v1.clear();
		v2.clear();
		cin >> w >> d;
		if(w == 0)break;
		for(int i = 0;i < w;i++){
			cin >> x;
			v1.push_back(x);
		}
		for(int i = 0;i < d;i++){
			cin >> x;
			v2.push_back(x);
		}
		for(int i = 0;i < v1.size();i++){
			for(int j = 0;j < v2.size();j++){
				if(v1[i] == v2[j]){
					res += v1[i];
					v1.erase(v1.begin()+i);
					v2.erase(v2.begin()+j);
					i--;
					break;
				}
			}
		}
		for(int i = 0;i < v1.size();i++){
			res += v1[i];
		}
		for(int j = 0;j < v2.size();j++){
			res += v2[j];
		}
		cout << res <<endl;
	}	
	return 0;
}

Measured memory_bytes: 1216
//Keep Working Hard
  // I__Like__Food  

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define int long long
  #define endl "\n"
  #define all(v) v.begin(),v.end()
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define tracel5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<< ": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
const double PI = 3.1415926535898;
const int N = 200000;
const int INF = (1LL << 30) - 1;



int32_t main()
{




    IOS

    int n,a,b;
    cin >> n >> a >> b;


    bool ok = false;

    for(int i = a; i <= b; i++)
    {
      if(i%n == 0)
      {
        ok = true;
        break;
      }
    }

    if(ok)
    {
      cout << "OK";
    }
    else
    {
      cout << "NG";
    }


    return 0;
}




Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,t;
  cin>>s>>t;
  s+=s;
  for(int i=0;i<s.size()*2-t.size();i++){
    int cnt=0;
    for(int j=0;j<t.size();j++){
      if(s[i+j]==t[j]){
	cnt++;
      }
    }
    if(cnt==t.size()){
      cout<<"Yes"<<endl;
      return(0);
    }
  }
  cout<<"No"<<endl;
  return(0);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=100005;
int n,m,a,b,vis[N],x,y;
vector<int>v[N],path,path2;
void dfs(int x){
	vis[x]=1;
	path.push_back(x);
	for (int i:v[x])
		if (!vis[i]){
			dfs(i);
			return;
		}
}
int main(){
	scanf("%d%d",&n,&m);
	while (m--){
		scanf("%d%d",&x,&y);
		v[x].push_back(y);
		v[y].push_back(x);
	}
	dfs(1);
	swap(path,path2);
	dfs(1);
	printf("%d\n",path2.size()+path.size()-1);
	for (int i=path2.size()-1;i>0;i--)printf("%d ",path2[i]);
	for (int i:path)printf("%d ",i);
}


Measured memory_bytes: 9976
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int a = input.nextInt();
        int b = input.nextInt();
        if (a  == b){
            System.out.println("Draw");
        }else if(a == 1){
            System.out.println("Alice");
        }else if (b == 1)
            System.out.println("Bob");
        else if (a > b)
            System.out.println("Alice");
        else{
            System.out.println("Bob");
        }
    }
}


Measured memory_bytes: 23636
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define speed ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long 
#define ull unsigned long long
#define db double
#define vi vector<ll>
#define vvi vector<vector<int> >
#define vvii vector<vector<pii> >
#define rep(i,a,b) for(int i=a;i<b;i++)
#define endl "\n"
#define pii pair<ll,ll>
#define piii pair<ll,pair<ll,ll> >
#define mem(a,b) memset(a , b , sizeof a ) ; 
#define pb push_back
#define pf push_front
#define F first 
#define S second 
#define mp make_pair
#define all(v) v.begin(),v.end()

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}



#define deb1(a) cout<<#a<<"=*"<<a<<endl;
#define deb2(a) cout<<#a<<"=@"<<a<<endl;
#define deb3(a) cout<<#a<<"=#"<<a<<endl;
#define deb4(a,b) cout<<#a<<"="<<a<<" and "<<#b<<"="<<b<<endl;
#define deb5(a,b) cout<<#a<<"="<<a<<" and "<<#b<<"="<<b<<endl;


typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;


ll mod=1000000007;
ll vis[212345]={0};
vvi v(212345);
ll d[212345]={0};


ll pow(ll a, ll b, ll m)
{
	ll ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}





int main()
{
speed
ll l,r,d;
cin>>l>>r>>d;
ll c=0;
ll k=d;
while(k<=r)
{
	if(k>=l) c++;
	k+=d;
}
cout<<c<<endl;

}


Measured memory_bytes: 8056
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Collections;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k= sc.nextInt();
		int r=Math.min(n,k);
		long ans=0;
		long[] v=new long[n];
		for(int i=0;i<n; i++){
			v[i]= sc.nextLong();
		}
		for(int i=0; i<=r; i++){
			int sum1=0;
			ArrayList<Long> list1=new ArrayList<>();
			for(int q=0; q<i; q++){
				sum1+=v[q];
				if(v[q]<0){
					list1.add(v[q]);
				}
			}
			for(int j=0; j<=r-i; j++){
				int sum2=0;
				ArrayList<Long> list2=new ArrayList<>();
				for(int o=n-1; o>n-1-j; o--){
					sum2+=v[o];
					if(v[o]<0){
						list2.add(v[o]);
					}
				}
				list2.addAll(list1);
				Collections.sort(list2);
				int count=k-j-i;
				int sum=sum1+sum2;
				if(count==0){
					ans=Math.max(ans,sum);
					break;
				}
				for(int u=0; u<list2.size(); u++){
					count--;
					sum+=-list2.get(u);
					if(count==0){
						break;
					}
				}
				ans=Math.max(ans,sum);
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 23124
#include<iostream>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
	int lim,ans;
	while(cin>>lim,lim){
		ans=0;
		rep(i,54)rep(j,96){
			int a=i*i*i,b=j*(j+1)*(j+2)/6;
			if(a+b>lim)break;
			if(a+b>ans)ans=a+b;
		}
		cout<<ans<<endl;
	}
	return 0;
}

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

int main() {
  int n; cin >> n;
  vector<int> sites(n + 2, 0);
  for (int i = 1; i < n + 1; i++) scanf("%d", &sites.at(i));
  
  int budget = 0;
  for (int i = 0; i < n + 1; i++) budget += abs(sites.at(i) - sites.at(i + 1));
  
  for (int i = 1; i < n + 1; i++) {
    int answer = budget - abs(sites.at(i - 1) - sites.at(i)) 
                        - abs(sites.at(i) - sites.at(i + 1))
                        + abs(sites.at(i - 1) - sites.at(i + 1));
    printf("%d\n", answer);
  }
}

Measured memory_bytes: 1664
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
using namespace std;
int main()
{
  int n,x;
  int sum=0,mi=1000;
  cin>>n>>x;
  vector<int> m(n);
  for(int i=0;i<n;i++)
  {
    cin>>m[i];
    sum+=m[i];
    mi=min(mi,m[i]);
  }

  int ans=(x-sum)/mi+n;
  cout<<ans<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int ans[200100] = {}; 
	for(int i = 1; i <= 200050; i++){
		int d = __builtin_popcount(i); 
		ans[i] = ans[i % d] + 1; 
	}
	int N; string X; 
	cin >> N >> X; 
	int sum = 0; 
	for(int i = 0; i < N; i++){
		if(X.at(i) == '1') sum ++; 
	}
	int remp[200010] = {}; // mod sum+1 
	int sump = 0; 
	int remm[200010] = {}; // mod sum-1 
	int summ = 0; 
	remp[0] = 1; remm[0] = 1; 
	for(int i = 1; i <= 200005; i++){
		remp[i] = remp[i-1] * 2 % (sum + 1); 
	}
	if(sum >= 2){
		for(int i = 1; i <= 200005; i++){
			remm[i] = remm[i-1] * 2 % (sum - 1); 
		}
	}
	for(int i = 0; i < N; i++){
		if(X.at(i) == '1'){
			sump += remp[N-1-i]; sump %= sum + 1; 
		}
	}
	if(sum >= 2){
		for(int i = 0; i < N; i++){
			if(X.at(i) == '1'){
				summ += remm[N-1-i]; summ %= sum - 1; 
			}
		}		
	}
	for(int i = 0; i < N; i++){
		if(X.at(i) == '0'){
			int total = sump + remp[N-1-i]; 
			cout << ans[total % (sum + 1)] + 1 << "\n"; 
		}else{
			if(sum == 1){
				cout << 0 << "\n"; 
			}else{
				int total = sum - 1 + summ - remm[N-1-i]; 
				cout << ans[total % (sum - 1)] + 1 << "\n"; 				
			}
		}
	}
}

Measured memory_bytes: 6080
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
long long int dp[100010] = { 0 };//i番目の段へのたどり着き方
int main() {
	int N,M;
	cin >> N >> M;
	vector<long long int>a(M + 1);
	for (int i = 0; i < M; i++) {
		cin >> a[i];
	}
	a[M] = 0;
	long long int count = 0;
	long long int mod = 1000000007;
	dp[0] = 1;
	if (a[0] != 1) {
		dp[1] = 1;
	}
	else {
		dp[1] = 0;
		count++;
	}
	for (int i = 2; i <= N; i++) {
		if (i != a[count]) { 
			dp[i] += (dp[i - 1] % mod) + (dp[i - 2] % mod); 
		}
		else {
			dp[i] = 0;
			count++;
		}
	}
	cout << dp[N] % mod << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
//#include<iostream>
//#include<vector>
//#include<map>
//#include<math.h>
//#include<algorithm>

#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define rrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define rrep2(i,n,a) for(int i = (int)(n); i >= (int)(a); i--)

#define fi first
#define se second

using namespace std;

using ll = long long;
using v_int = vector<int>;
using v2_int = vector<v_int>;
using v_ll = vector<ll>;
using v2_ll = vector<v_ll>;
using v_string = vector<string>;
using v_bool = vector<bool>;
using v2_bool = vector<v_bool>;
using pii = pair<int, int>;
using mii = map<int, int>;

const double PI = 3.1415926535897932;
const int INF = (int)2e9;
const ll LINF = (ll)2e18;
const ll MOD = 1000000007;
const int dc[8] = {1, -1, 0,  0, 1, -1,  1, -1};
const int dr[8] = {0,  0, 1, -1, 1,  1, -1, -1};

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p) {
    return o << "{" << p.first << "," << p.second << "}";
}
template<typename T> inline
istream& operator>>(istream &is, vector<T> &vec) {
    for(auto &v : vec) { is >> v; }
    return is;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &vec) {
    for(auto &v : vec) { os << v << ",";}
    return os;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<vector<T> > &mat) {
    for(auto &row : mat) { os << row << endl; }
    return os;
}

template<typename T> inline
void chmin(T &a, T b) { a = min(a, b); }
template<typename T> inline
void chmax(T &a, T b) { a = max(a, b); }

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

    int cnt = 0;
    int k = 1;
    rep(i, n) {
        int a;
        cin >> a;
        if(a != k) {
            cnt++;
        } else {
            k++;
        }
    }

    if(cnt == n) {
        cout << -1 << endl;
    } else {
        cout << cnt << endl;
    }

    return 0;
} /*atcoder*/



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

typedef long long ll;
const int MAXN = 1e5 + 10;
ll a[MAXN], x, ans;
int n;

int main() {
	cin >> n >> x;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 1; i < n; i++) {
		if (a[i] + a[i - 1] > x) {
			ans += (a[i] + a[i - 1]) - x;
			a[i] -= (a[i] + a[i - 1]) - x;
		}
		if (a[i] < 0)
			a[i - 1] += a[i], a[i] = 0;
	}
	cout << ans;
}

Measured memory_bytes: 1024
#include <iostream>
#include<stdio.h>
using namespace std;
int main()
{
    int i = 0;
	int temp;
	int max = 0,sum=0;
	cin >> i;
	for (int j = 0; j < i; j++) {
		scanf("%d", &temp);
		if (temp> max)max = temp;
		sum += temp;
		char c = getchar();
		if (c == '\n')break;
	}
	if (max * 2 < sum)printf("Yes");
	else printf("No");
	return 0;
}

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

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n,k,x,y;
    while(cin >> n >> k >> x >> y) {
        cout << (n <= k? n*x : k*x + (n-k)*y) << '\n'; 
    }
    return 0;
}

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

int a[1001][1001];

int main(){
	int a, b;
	cin >> a >> b;
	int ans = 2020;
	for (int i = a; i < b; i++){
		for (int j = i + 1; j <= b; j++){
			if (ans != 0) ans = min((i % 2019) * (j % 2019) % 2019, ans);
			else {
				cout << ans;
				return 0;
			}
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
let s = read_line ()
let _ = 
  (match s with
  | "abc" -> "Yes"
  | "acb" -> "Yes"
  | "bac" -> "Yes"
  | "bca" -> "Yes"
  | "cab" -> "Yes"
  | "cba" -> "Yes"
  | _ -> "No") |> print_endline

Measured memory_bytes: 384
#include <iostream>
#include <vector>

const int INF = 1e8;

int main()
{
	int n;
	std::cin >> n;
	std::vector<int> dp(10, -INF);
	dp[0] = 0;
	while(n--)
	{
		int cur;
		std::cin >> cur;
		std::vector<int> nxt(10, -INF);
		for(int i = 0; i < 10; i++)
			nxt[(i + cur) % 10] = std::max(dp[(i + cur) % 10], dp[i] + cur);
		dp = nxt;
	}
	int ans = 0;
	for(int i = 1; i < 10; i++)
		ans = std::max(ans, dp[i]);
	std::cout << ans << '\n';
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e4+10;

int n,a[N];

int main()
{
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	sort(a+1,a+1+n);
	int ans=0;
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			int x=a[i]+a[j];
			int pos=lower_bound(a+j,a+n+1,x)-a;
			if(pos!=n+1)ans+=pos-1-j;
			else ans+=n-j;
		}
	}
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int deck[51] = {0};
	int n=0;
	int r=0;
	int p[51] = {0};
	int c[51] = {0};
	int downs[51] = {0};
	int ups[51] = {0};
	int i,j;
	int endflag = 0;
	int out[1000]={0};
	int outc=0;

	while(1)
	{
		
		scanf("%d",&n);
		scanf("%d",&r);

		if(n == 0 && r == 0)
		{
			for( i = 0; i < outc ; i++)
				printf("%d\n",out[i]);

			return 0;
		}

		
		for( i = 0; i < r ; i++)
		{
			scanf("%d",&p[i]);
			scanf("%d",&c[i]);
		}



		for(i = 1 ; i < n + 1 ; i++)
		{
			deck[i-1] = n + 1 - i;
		}


		for( j = 0 ; j < r ; j++)
		{
			for(i = 0 ; i < p[j] - 1 ; i++)
			{
				downs[i] = deck[i];
			}
			for(i = 0 ; i < c[j]  ; i++)
			{
				ups[i] = deck[i+p[j]-1];
			}

			for(i = 0 ; i < c[j] ; i++)
			{
				deck[i] = ups[i];
			}
			for(i = 0 ; i < p[j] - 1 ; i++)
			{
				deck[i+c[j]] = downs[i];
			}

			for(i = 0; i < p[j] + c[j] - 1 ; i++)
			{
				ups[i] = 0;
				downs[i] = 0;
			}

		}

		out[outc] = deck[0];
		outc++;

		for(i = 0; i < 50; i++)
			{
				deck[i] = 0;
				p[i] = 0;
				c[i] = 0;
			}


	}


}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define ll long long
#define ull unsigned long long
#define ld long double
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rrep(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define pll pair<long long,long long>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vvc vector<vector<char>>
#define vc vector<char>
#define vvb vector<vector<bool>>
#define vb vector<bool>
#define maxe(x) *max_element(all(x))
#define mine(x) *min_element(all(x))
#define Size(x) ((int)(x).size())
#define umap unordered_map
const long long INF = 1LL << 60;
const long double pi = 3.1415926535897932;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

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

//lis,modpow,uf,modncr,soinsubunkai,yakusurekkyo,gyakugen
//mint,dijkstra

    signed main(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        ll a,b,c;
        cin>>a>>b>>c;
        a+=b;
        a+=c;
        if(a>21)cout<<"bust"<<endl;
        else cout<<"win"<<endl;
    }

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<math.h>
#include<algorithm>
using namespace std;

vector<vector<long long>> cake;
vector<int> pmx = {1,-1,1,-1,1,-1,1,-1};
vector<int> pmy = {1,1,-1,-1,1,1,-1,-1};
vector<int> pmz = {1,1,1,1,-1,-1,-1,-1};

long long search(int pm, vector< vector<long long> > cake, int N, int M){
  long long sum = 0;
  vector<long long> sub;
  for(int i = 0; i< N;i++){
    sub.push_back(cake[i][0]*pmx[pm]+cake[i][1]*pmy[pm]+cake[i][2]*pmz[pm]);
  }
  sort(sub.begin(), sub.end());
  for(int j = 0; j<M; j++){
    sum += sub[N-j-1];
  }
  return sum;
}

int main(){
  int N;
  cin >> N;
  vector<long long> x,y,z;
  int M;
  cin >> M;
  long long a,b,c;
  for(int i = 0; i< N; i++){
    cin >> a >> b >> c;
    cake.push_back({a,b,c});
  }
  long long maxi = 0;
  for(int pm = 0; pm < 8; pm++){
    long long ma = search(pm,cake,N,M);
    if(maxi < ma) maxi = ma;
  }
  cout << maxi << endl;
}


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

using namespace std;

typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldbl;
typedef pair<int, int> pii;
typedef pair<uint, uint> puu;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<uint> vu;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pii> vpii;
typedef vector<puu> vpuu;
typedef vector<pll> vpll;
typedef vector<pull> vpull;
typedef vector<string> vstr;
typedef vector<double> vdbl;
typedef vector<ldbl> vldbl;
#define pb push_back
#define ppb pop_back
#define pfr push_front
#define ppfr pop_front
#define emp emplace
#define empb emplace_back
#define be begin
#define rbe rbegin
#define all(x) (x).be(), (x).end()
#define rall(x) (x).rbe(), (x).rend()
#define fir first
#define sec second
#define mkp make_pair
#define brif(cond) if (cond) break
#define ctif(cond) if (cond) continue
#define retif(cond) if (cond) return
void canhazfast() {ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);}
template<typename T> T gcd(T a, T b) {return b ? gcd(b, a%b) : a;}
template<typename T> T extgcd(T a, T b, T &x, T &y)
{
    T x0 = 1, y0 = 0, x1 = 0, y1 = 1;
    while (b) {
        T q = a/b; a %= b; swap(a, b);
        x0 -= q*x1; swap(x0, x1);
        y0 -= q*y1; swap(y0, y1);
    }
    x = x0; y = y0; return a;
}
int ctz(uint x) {return __builtin_ctz(x);}
int ctzll(ull x) {return __builtin_ctzll(x);}
int clz(uint x) {return __builtin_clz(x);}
int clzll(ull x) {return __builtin_clzll(x);}
int popcnt(uint x) {return __builtin_popcount(x);}
int popcntll(ull x) {return __builtin_popcountll(x);}
int bsr(uint x) {return 31^clz(x);}
int bsrll(ull x) {return 63^clzll(x);}

#define N 1000064

char str[N];
int a[N];

int bipar(int n, int k)
{
    int res = 1;
    while (n > 0 || k > 0) {
        int bn = n&1, bk = k&1;
        res &= bn|~bk;
        n >>= 1;
        k >>= 1;
    }
    return res;
}

int main()
{
    canhazfast();

    int n;
    int c1 = 0;
    int sh = 0;
    int ans = 0;

    cin >> n >> str;
    for (int i = 0; i < n; ++i) {
        a[i] = str[i]-'1';
        if (a[i] == 1) ++c1;
    }
    if (!c1) sh = 1;
    for (int i = 0; i < n; ++i) {
        ans ^= bipar(n-1, i)&(a[i]>>sh);
    }
    /*cerr << "bipar:\n";
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j <= i; ++j) cerr << bipar(i, j) << ' ';
        cerr << '\n';
    }*/
    ans <<= sh;
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define N 100005
#define pb push_back
vector<int> adj[N];
int bfs(int s)
{
	vector<int> d(N,0);
	vector<bool>vis(N,false);
	queue<int> q;
	int mx=-1;
    q.push(s);
    vis[s]=true;
    while(!q.empty())
    {
        int v=q.front();
        q.pop();
        for(auto u:adj[v])
        {
            if(!vis[u]){
                vis[u]=true;
                q.push(u);
                  d[u]=d[v]+1;
                  mx=max(mx,d[u]);
                 //cout<<u<<" "<<v<<" "<<mx<<endl;
            }
        }
    }
   return mx; 
}
int main()
{
   int h,w,i,j,mx=-1,ind;
   vector<int> dot;
   cin>>h>>w;
   char maze[h][w];
   for(i=0;i<h;i++)
   {
   	  for(j=0;j<w;j++)
   	  	cin>>maze[i][j];
   }
   for(i=0;i<h;i++)
    {
   	  for(j=0;j<w;j++)
   	    {
   	  	    if(maze[i][j]=='.')
   	  	    {
   	  		        ind=i*w+j;
   	  		         dot.pb(ind);
   	  		         if((i+1<h) && maze[i+1][j]=='.')
                         adj[ind].pb(ind+w);
                    if((j+1<w) && maze[i][j+1]=='.')
                         adj[ind].pb(ind+1);
                    if((i-1>=0) && maze[i-1][j]=='.')
                         adj[ind].pb(ind-w);
                    if((j-1>=0) && maze[i][j-1]=='.')
                         adj[ind].pb(ind-1);
   	  	    }
   	    }
    }
   for(i=0;i<dot.size();i++)
   {
   	   	   
   	   mx=max(mx,bfs(dot[i]));
   }
  cout<<mx;

 }

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
    
    public static void main(String[] args)throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        int[] array = new int[n];
        String[] strArray = br.readLine().split(" ");
        
        for(int i=0; i<n; i++){
            array[i] = Integer.parseInt(strArray[i]);
        }
        insertionSort(array, n);
    }
    
    public static void insertionSort(int[] A, int N){
        for(int i = 0; i < N; i++){
            int key = A[i];
            int j = i - 1;
            while (j >= 0 && A[j] > key){
                A[j + 1] = A[j];
                j--;
            }
            A[j + 1] = key;
            toArray(A);
        }
    }
    
    public static void toArray(int[] out) {
        StringBuilder sb = new StringBuilder();
        for(int i=0; i < out.length; i++){
            sb.append(out[i]);
            if(i < out.length - 1)
                sb.append(" ");
        }
        System.out.println(sb.toString());
    }
}

Measured memory_bytes: 26944
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define i_inf int(1e9)
#define i_half_inf int(1e5)
#define ll_inf ll(1e9)*ll(1e9)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int n;

void solve() {
    vector<int> ans;
    int sum = 0;
    repone(i, n) {
        if (sum < n) {
            sum += i;
            ans.emplace_back(i);
        } else break;
    }
    each(i, ans) {
        if (i == sum - n) continue;
        else cout << i << endl;
    }
}

int main() {
    cin >> n;
    solve();
    return 0;
}

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

using namespace std;

const double PI = 3.14159265358979323846;
typedef unsigned long long ll;
typedef pair<ll, ll> P;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
const ll INF = 10e10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<string> &o) {
    string a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

ll solve(ll a, ll b) {
    if (a == b) return (a - 1) * 2;
    ll floor = 1, ceil = INF;
    ll lim = a * b - 1;
    while (floor + 1 < ceil) {
        ll mid = (floor + ceil) / 2;
        ll mul = (mid + 1) / 2 * (mid + 1 - (mid + 1) / 2);
        if (mul > lim) ceil = mid;
        else floor = mid;
    }
    return floor - 1;
}

int main() {
    ll q;
    cin >> q;

    rep(i, q) {
        ll a, b;
        cin >> a >> b;

        cout << solve(a, b) << endl;
    }

}





Measured memory_bytes: 256
program redistribution
  implicit none
  integer(8), parameter :: modu = 1000000007
  integer :: s
  integer(8) :: m(3, 3) = 0
  read(*,*) s
  if (s < 6) then
    write(*,'(i0)') s / 3
    stop
  end if
  m(1, 1) = 1
  m(2, 1) = 1
  m(3, 2) = 1
  m(1, 3) = 1
  m = modmatpow(m, s - 6)
  write(*,'(i0)') mod(m(1, 1) * 2 + m(1, 2) + m(1, 3), modu)
contains
  function modmatmul(x, y) result(res)
    integer(8), intent(in) :: x(3, 3), y(3, 3)
    integer(8) :: tmp, res(3, 3)
    integer :: i, j, k
    do j = 1, 3
      do i = 1, 3
        res(i, j) = 0
      end do
      do k = 1, 3
        tmp = y(k, j)
        do i = 1, 3
          res(i, j) = mod(res(i, j) + x(i, k) * tmp, modu)
        end do
      end do
    end do
  end
  function modmatpow(x, n) result(res)
    integer(8), intent(in) :: x(3, 3)
    integer, intent(in) :: n
    integer(8) :: res(3, 3), tmp(3, 3)
    integer :: m, i
    res = 0
    do i = 1, 3
      res(i, i) = 1
    end do
    tmp = x
    m = n
    do while (m > 0)
      if (btest(m, 0)) res = modmatmul(res, tmp)
      tmp = modmatmul(tmp, tmp)
      m = rshift(m, 1)
    end do
  end
end program redistribution

Measured memory_bytes: 2920
#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>
#include <functional>
#include <iostream>

using namespace std;
typedef long long ll;

#define SIZE 500010

struct RMQ{
  int segn2;
  vector<int> data;

  RMQ(int n){
    for(segn2=1; segn2<n; segn2*=2);
    data.assign(segn2*2, 0);
  }

  int query(int a, int b, int l = 0, int r = -1, int k = 0){
    if(r == -1) r = segn2;
    if(a <= l && r <= b) return data[k];
    if(r <= a || b <= l) return 1000000000;
    return min(query(a, b, l, (l+r)/2, k*2+1), query(a, b, (l+r)/2, r, k*2+2));
  }

  void set(int k, int x){
    k += segn2-1;
    data[k] = x;
    while(k > 0){
      k = (k-1)/2;
      data[k] = min(data[k*2+1], data[k*2+2]);
    }
  };
};

struct RMaxQ{
  int segn2;
  vector<int> data;

  RMaxQ(int n){
    for(segn2=1; segn2<n; segn2*=2);
    data.assign(segn2*2, 0);
  }

  int query(int a, int b, int l = 0, int r = -1, int k = 0){
    if(r == -1) r = segn2;
    if(a <= l && r <= b) return data[k];
    if(r <= a || b <= l) return 0;
    return max(query(a, b, l, (l+r)/2, k*2+1), query(a, b, (l+r)/2, r, k*2+2));
  }

  void set(int k, int x){
    k += segn2-1;
    data[k] = x;
    while(k > 0){
      k = (k-1)/2;
      data[k] = max(data[k*2+1], data[k*2+2]);
    }
  };
};

int n, d[SIZE], d2[SIZE];
map<int,int> counter, dict;

int main(){

  scanf("%d", &n);

  for(int i=0;i<n;i++){
    scanf("%d", d+i);
    d2[i] = d[i];
    counter[d[i]]++;
  }

  sort(d2, d2+n, greater<int>());
  
  vector<int> vec;

  int t = 0;
  int cur = d2[n-1];
  
  for(int i=0;i<n;i++){
    if(i != 0 && d2[i-1] == d2[i]){
      t++;
    }else{
      vec.push_back(d2[i]);
      cur = d2[i];
      t++;
    }

    while(cur > 0 && (i == n-1 || cur-1 > d2[i+1]) && t > 2){
      cur--;
      t /= 2;
      vec.push_back(cur);
    }
  }

  if(vec[vec.size()-1] != 0) vec.push_back(0);
  
  reverse(vec.begin(), vec.end());
  
  for(int i=0;i<vec.size();i++){
    //cerr << vec[i] << endl;
    dict[vec[i]] = i; 
  }

  vector<int> arr(vec.size());
  RMQ rmq(vec.size());
  RMaxQ rmaxq(vec.size());
  
  for(int i=0;i<n;i++){
    int p = dict[d[i]];

    //cerr << rmaxq.query(p+1, vec.size()) << endl;
    //cerr << arr[0] << endl;
    
    if((!arr[0] && rmq.query(1, p+1) == 0) ||
       (!arr[0] && rmaxq.query(p+1, vec.size()) == 0)){
      puts("Yes");
    }else{
      puts("No");
      continue;
    }

    arr[p]++;
    rmq.set(p, arr[p]);
    rmaxq.set(p, arr[p]);

    while(arr[p] >= 2){
      arr[p--] -= 2;
      arr[p]++;
      rmq.set(p+1, arr[p+1]);
      rmaxq.set(p+1, arr[p+1]);
      rmq.set(p, arr[p]);
      rmaxq.set(p, arr[p]);
    }
  }

  return 0;
}



Measured memory_bytes: 38984
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char str[100000];
    scanf("%s",str);
    int l=strlen(str);
    int sum=0;;
    for(int i=0;i<l;i++)
    {
        if(str[i]=='-')
        {
            sum=sum-1;
        }
        else if(str[i]=='+')
        {
            sum=sum+1;
        }
    }
     cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.awt.geom.*;

public class Main {
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int h = sc.nextInt();
			int r = sc.nextInt();
			if((h|r) == 0) break;
			Point2D [] house = new Point2D[h];
			for(int i = 0; i < h; i++){
				int x = sc.nextInt();
				int y = sc.nextInt();
				house[i] = new Point2D.Double(x, y);
			}
			int [] size = new int[3];
			int [] deg = new int[3];
			for(int i = 0; i < 3; i++){
				size[i] = sc.nextInt();
			}
			for(int i = 0; i < 3; i++){
				deg[i] = sc.nextInt();
			}
			ArrayList<ArrayList<Point2D>> ps = new ArrayList<ArrayList<Point2D>>();
			for(int i =0; i < 3; i++){
				ps.add(new ArrayList<Point2D>());
				for(int j = 0; j < size[i]; j++){
					ps.get(i).add(new Point2D.Double(sc.nextInt(), sc.nextInt()));
				}
			}
			int [][] wind = new int[r][2];
			for(int i = 0; i < r; i++){
				wind[i][0] = sc.nextInt();
				wind[i][1] = sc.nextInt();
			}
			
			int [] count = new int[h];
			Point2D myhome = new Point2D.Double(0,0);
			//日付ごと
			for(int i = 0; i < r; i++){
				//ある家ごとにみる
				//自分以外の香りが届いているか？
				//すべて届いていないならば、自分の香りが届いているか？trueならばcount++;
				
				for(int j = 0; j < h; j++){
					boolean res = isBadFlourReach(wind[i],deg,ps, house[j]);
					if(! res){
						res = isFlourReach(wind[i],deg[0],myhome, house[j]);
						if(res){
							count[j]++;
						}
					}
				}
			}
			int max = 1;
			for(int i = 0; i < count.length; i++){
				max = Math.max(max, count[i]);
			}
			StringBuilder anshouse = new StringBuilder();
			for(int i = 0; i < count.length; i++){
				if(max == count[i]){
					anshouse.append(" " + (i + 1));
				}
			}
			if(anshouse.length() == 0){
				System.out.println("NA");
			}
			else{
				System.out.println(anshouse.substring(1));
			}
		}
	}
	

	private boolean isFlourReach(int[] wind, int deg, Point2D myhome, Point2D target) {
		double dis = myhome.distance(target);
		if(myhome.distance(target) > wind[1]){
			return false;
		}
		double x = (target.getX() - myhome.getX()) / dis;
		double y = (target.getY() - myhome.getY()) / dis;
		double res = Math.atan2(y, x);
		double resdeg = Math.toDegrees(res);
		double windmax = wind[0] + (double)deg / 2;
		double windmin = wind[0] - (double)deg / 2;
		if(windmin <= resdeg && resdeg <= windmax){
			return true;
		}
		resdeg += 360;
		if(windmin <= resdeg && resdeg <= windmax){
			return true;
		}
		return false;
	}


	private boolean isBadFlourReach(int[] wind, int[] deg, ArrayList<ArrayList<Point2D>> ps, Point2D target) {
		for(int i = 0; i < 3; i++){
			for(int j = 0; j < ps.get(i).size(); j++){
				if(isFlourReach(wind, deg[i], ps.get(i).get(j), target)){
					return true;
				}
			}
		}
		return false;
	}


	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

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

Measured memory_bytes: 29068
import numpy as np
import math

N = int(input())
X = list(map(int, input().split()))

mean_num_1 = int(np.mean(X))
mean_num_2 = math.ceil(np.mean(X))

result_1 = 0
result_2 = 0
for i in X:
    result_1 += abs(mean_num_1 - i) ** 2
    result_2 += abs(mean_num_2 - i) ** 2
    
print(min(result_1, result_2))

Measured memory_bytes: 27180
#include <bits/stdc++.h>
#include <map> // pair
using namespace std;
int main(){
  long long int X,Y,ans;
  cin>>X>>Y;
  ans = 0;
  while(1){
    ans++;
    X=X*2;
    if(X>Y)break;
  }

  cout<<ans<<endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from collections import deque

INF = float('inf')


if __name__ == '__main__':
    K = int(input())
    q = deque([1, 2, 3, 4, 5, 6, 7, 8, 9])

    if K < 10:
        print(K)
        exit()

    counter = 0
    while True:
        counter += 1
        x = q.popleft()
        amari = x % 10
        if counter != K:
            if amari > 0:
                q.append(x * 10 + (amari - 1))
            q.append(x * 10 + amari)
            if amari < 9:
                q.append(x * 10 + (amari + 1))
        else:
            print(x)
            exit()


Measured memory_bytes: 40816