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

int main(){

    int n; cin >> n;
    vector<int> a(n + 1);
    for(int i = 0; i < n; i++) cin >> a[i];
    a[n] = 0;
    int pre = 0;
    int cnt = 1;
    int ans = 0;
    for(int i = 0; i <= n; i++){
        if(a[i] == pre) cnt++;
        else{
            ans += (cnt / 2);
            cnt = 1;
            pre = a[i];
        }

        //cout << pre << " " << cnt << " " << endl;
    }

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

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#define IN -1000000
using namespace std;
int main(){
  int n;
  cin>>n;
   int a[n][3];
  for(int i=0;i<n;i++){
    cin>>a[i][0]>>a[i][1]>>a[i][2];
  }
int dp[n][3];
  dp[0][0]=a[0][0];
  dp[0][1]=a[0][1];
  dp[0][2]=a[0][2];
  for(int i=1;i<n;i++){
        for(int j=0;j<3;j++){
        dp[i][j]=IN;
  	dp[i][j]=max(dp[i-1][(j+1)%3]+a[i][j],dp[i-1][(j+2)%3]+a[i][j]);
        }
  }
   cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
    }


Measured memory_bytes: 5948
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);i++)
#define erep(i,a,b) for(int i=a;i<=(int)(b);i++)
#define per(i,a,b) for(int i=(b)-1;i>(a);i--)
#define eper(i,a,b) for(int i=((int)(a));i>=b;i--)
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
const int INF=999999999;
const int MOD=1000000007;

int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int n, a, x[50];
ll dp[51][51][4000];

int main() {
    cin >> n >> a;
    rep(i, 0, n) cin >> x[i];
    dp[0][0][0] = 1;
    rep(i, 0, n) {
        rep(j, 0, n) {
            rep(k, 0, 2500) {
                if (dp[i][j][k]) {
                    dp[i+1][j][k] += dp[i][j][k];
                    dp[i+1][j+1][k+x[i]] += dp[i][j][k]; 
                }
            }
        }
    }
    ll ans = 0LL;
    rep(i, 1, n+1) {
        ans += dp[n][i][i*a];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 78592
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

string s;

int main(){
    cin >> s;

    if(s[0] == s[1] and s[1] == s[2]){
        cout << "Yes" << endl;
    }else if(s[1] == s[2] and s[2] == s[3]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}


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

#define MOD 100000

int sub;
int n, m;
int cnt;
int S;
char pattern[21][21];
int dp[2][1 << 20];

int pow(long long int base, int exp) {
    long long int res;
    if (exp == 0) return 1;
    res = pow(base*base%MOD, exp/2);
    if (exp%2 == 1) {
        res = res * base % MOD;
    }
    return (int)res;
}

int main() {
    scanf("%d%d", &n, &m);
    for (int i=0; i<n; i++) {
        for (int j=0; j<m; j++) {
            scanf(" %c", &pattern[i][j]);
        }
    }

    S = 1 << m;

    int cur = 0;
    int next = 1;
    dp[cur][0] = 1;
    for (int i=0; i<n; i++) {
        for (int j=0; j<m; j++) {
            char que = pattern[i][j] == '?';
            if (que) cnt++;
            for (int k=0; k<S; k++) {
                if ((que || pattern[i][j] == 'I') && !((k >> (m-1)) & 1)) {
                    int newstate = ((k&(~1)) << 1) & (S-1);
                    dp[next][newstate] += dp[cur][k];
                    dp[next][newstate] %= MOD;
                }
                
                if (que || pattern[i][j] == 'J') {
                    int newstate = ((k&(~1)) << 1) & (S-1);
                    if (j != m-1) newstate |= 1;
                    dp[next][newstate] += dp[cur][k];
                    dp[next][newstate] %= MOD;
                }
                
                if (que || pattern[i][j] == 'O') {
                    int newstate = (k << 1) & (S-1);
                    dp[next][newstate] += dp[cur][k];
                    dp[next][newstate] %= MOD;
                }
            }

            swap(cur, next);
            fill(dp[next], dp[next]+S, 0);
        }
    }

    for (int i=0; i<S; i++) {
        sub += dp[cur][i];
        sub %= MOD;
    }
    printf("%d\n", ((pow(3, cnt)-sub)%MOD+MOD) % MOD);
}

Measured memory_bytes: 9216
a=input()
b=input()
c=input()

dict = {"a":a, "b":b, "c":c}

x="a"
y=""
while len(dict["a"])+len(dict["b"])+len(dict["c"])>0:
    try:
        y=dict[x][0]
        dict[x] = dict[x][1:]
        x=y
    except:
        print(x.upper())
        break

Measured memory_bytes: 3064
//In The Name Of Allah
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define double long double 
#define fi first
#define se second
#define pii pair<int, int>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

const int mod = 1e9 + 7;
signed main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
  int n;
  cin >> n;
  pii a[n];
  int z1 = 0, z2 = 0, z3 = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i].fi >> a[i].se;
    if (a[i].fi * a[i].se != 0) {
      int g = __gcd(a[i].fi, a[i].se);
      a[i].fi /= g, a[i].se /= g;
      if (a[i].se < 0) {
        a[i].fi *= -1, a[i].se *= -1;
      }
    } else if (a[i].fi != 0) {
      z2++;
    } else if (a[i].se != 0) {
      z1++;
    } else {
      z3++;
    }
  }
  map<pii, int> cnt;
  set<pii> st;
  for (int i = 0; i < n; i++) {
    int x = a[i].fi, y = a[i].se;
    if (x == 0 || y == 0) continue;
    cnt[{x, y}]++;
    st.insert({x, y}); 
    if (x > 0) {
      st.insert({-y, x});
    } else {
      st.insert({y, -x});
    }
  }
  int N = 2e5 + 1000;
  int p2[N];
  p2[0] = 1;
  for (int i = 1; i < N; i++) {
    p2[i] = p2[i - 1] * 2 % mod;
  }
  int ans = 1;
  for (auto &el : st) {
    if (el.fi < 0) continue;
    ans *= (p2[cnt[el]] + p2[cnt[{-el.se, el.fi}]] + -1) % mod;
    ans %= mod;
  }
  ans *= (p2[z1] + p2[z2] - 1);
  ans += z3 - 1;
  ans = (ans + mod) % mod;
  cout << ans << "\n";
}



Measured memory_bytes: 58288
import java.io.PrintWriter;
import java.util.*;

public class Main {


    static Scanner sc;
    static PrintWriter out;

    public static void main(String[] args) {
        sc = new Scanner(System.in);
        out = new PrintWriter(System.out);
        new Main().solve();
        out.flush();
    }

    public void solve() {
        int n = sc.nextInt();
        int[] x = new int[n];
        int[] y = new int[n];
        long[][] d = new long[4][n];
        for(int i=0; i<n; i++) {
            x[i] = Integer.parseInt(sc.next());
            y[i] = Integer.parseInt(sc.next());
            d[0][i] = x[i]+y[i];
            d[1][i] = x[i]-y[i];
        }
        long min0 = d[0][0];
        long max0 = d[0][0];
        long min1 = d[1][0];
        long max1 = d[1][0];
        for(int i=0; i<n; i++) {
            min0 = Math.min(min0, d[0][i]);
            max0 = Math.max(max0, d[0][i]);
            min1 = Math.min(min1, d[1][i]);
            max1 = Math.max(max1, d[1][i]);
        }
        long res = Math.max(max0-min0, max1-min1);
        out.println(res);


    }



}

Measured memory_bytes: 67228
use proconio::{fastout, input};
use std::cmp;

#[fastout]
fn main() {
    input! {
        n: usize,
        m: usize,
        mut k: u64,
        r#as: [u64; n],
        bs: [u64; m],
    }

    let mut i = 0;
    let mut j = 0;

    while i < n && r#as[i] <= k {
        k -= r#as[i];
        i += 1;
    }
    while j < m && bs[j] <= k {
        k -= bs[j];
        j += 1;
    }

    let mut max = i + j;

    while i > 0 {
        k += r#as[i - 1];
        i -= 1;
        while j < m && bs[j] <= k {
            k -= bs[j];
            j += 1;
        }
        max = cmp::max(max, i + j);
    }

    println!("{}", max);
}


Measured memory_bytes: 9344
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<string.h>
using namespace std;
char s[400];
int dp[400][400][400];
int main(){
	int k;
	scanf("%s",s+1);
	scanf("%d",&k);
	int l=strlen(s+1);
	for(int i=1;i<=l;i++){
		for(int j=0;j<=k;j++){
			dp[i][i][j]=1;
		}
	}
	for(int i=2;i<=l;i++){
		for(int j=1;j+i-1<=l;j++){
			for(int t=0;t<=k;t++){
				dp[j][j+i-1][t]=std::max(dp[j+1][j+i-1][t],dp[j][i+j-2][t]);
				if(s[j]==s[j+i-1]){
					dp[j][j+i-1][t]=std::max(dp[j][j+i-1][t],dp[j+1][j+i-2][t]+2);
				}
				if(t)
					dp[j][j+i-1][t]=std::max(dp[j][j+i-1][t],dp[j+1][j+i-2][t-1]+2);
			}
		}
	}
	printf("%d",dp[1][l][k]);
	return 0;
}

Measured memory_bytes: 187776
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>
#include<cctype>

using namespace std;

typedef pair<int,int> P;
typedef long long ll;

const int INF = 1e9;

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

	int n;
	cin >> n;

	int tmp=n;
	for(int i=0;i*4 <= n;i++){
		tmp -= 4*i;
		if(tmp % 7 == 0){
			cout << "Yes\n";
			return 0;
		}
		tmp = n;
	}
	cout << "No\n";

	return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
d = list(map(int, input().split()))
ok = [1] * 10
for i in d:
    ok[i] = 0

while 1:
    s = str(n)
    fin = 1
    for c in s:
        fin &= ok[int(c)]
    if fin:
        print(s)
        exit()
    n += 1


Measured memory_bytes: 3060
#include<iostream>

#include <vector>
#include <list>
#include<stack>
#include<queue>
#include<array>

#include <set>
#include<map>

#include<string>
#include<stdlib.h>

#include<algorithm>
#include <functional>
#include<math.h>

#include<fstream>
#include<iomanip>

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int,int>;

#define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl

constexpr int INF = (1 << 30);
constexpr ll INFL = (1ll << 60);
constexpr ll MOD = 1000000007;// 10^9+7


struct COMB {
	static constexpr ll LIM = 200'000;

	//�J��Ԃ��ݏ�@
	//in:  x,n,mod
	//out: x^n(Mod mod)
	template<typename T>
	T mod_pow(T x, T n, T mod) {
		T res = 1;
		while (n > 0) {
			if (n & 1)res = (res * x) % mod;
			x = (x * x) % mod;
			n >>= 1;
		}
		return res;
	}

	void make_contents()
	{
		ll tmp = 1;
		fact.push_back(0);
		FOR(i, 1, LIM) {
			tmp *= i;
			tmp %= MOD;
			fact.push_back(tmp);
		}

		tmp = mod_pow(tmp, MOD - 2, MOD);
		//inv.push_back(tmp);
		for (ll i = LIM - 1; i > 0; i--) {
			tmp *= i;
			tmp %= MOD;
			inv.push_back(tmp);
		}
		reverse(inv.begin(), inv.end());
		fact[0] = inv[0] = 1;
		/*�������m�F
		REP(i, LIM) {
		cerr << (fact[i] * inv[i]) % MOD << endl;
		}
		*/
	}

	ll comb(ll n, ll k) {
		ll res = fact[n];
		res *= inv[k]; res %= MOD;
		res *= inv[n - k]; res %= MOD;
		return res;
	}

private:
	vector<ll> fact, inv;
};


//�ϐ�
ll R, C, ar, ac, br, bc;
COMB comb;





//�T�u�֐�
//����
void input()
{
	cin >> R >> C >> ar >> ac >> br >> bc;
	comb.make_contents();
}


//�v�Z
void calc()
{
	ll mul = 1;
	ll r1 = abs(br - ar);
	ll r2 = (ar <= br ? R - br : br + 1);
	ll r = min(r1, r2);
	if (r1 == r2)mul *= 2;

	ll c1 = abs(bc - ac);
	ll c2 = (ac <= bc ? C - bc : bc + 1);
	ll c = min(c1, c2);
	if (c1 == c2)mul *= 2;

	ll res = comb.comb(r + c, r);
	res *= mul;
	res %= MOD;
	cout << r + c << " " << res << endl;
}


//�o��
void output()
{

}


//�f�o�b�O
void debug()
{
	int N;
	cin>>N;
}


//���C���֐�
int main()
{
	input();
	calc();
	output();
	//debug();
	
	return 0;
}



Measured memory_bytes: 7592
#include<bits/stdc++.h>
using namespace std;
#define N 200010
#define LL long long
typedef struct 
{
    int x,y;
}Node;
Node e[N];
int cmp(Node u,Node v)
{
    return u.y>v.y;
}
int a[N];
int main()
{
    int i,j,k,n,m,d,t;
    LL ans;
    scanf("%d%d",&n,&m);
    for(i=0;i<n;i++)
        scanf("%d",&a[i]);
    for(i=0;i<m;i++)
        scanf("%d%d",&e[i].x,&e[i].y);
    sort(e,e+m,cmp);
    d=n;
    t=n;
    for(i=0;i<m&&d;i++)
    {
        while(d&&e[i].x)
        {
            d--;
            e[i].x--;
            a[t++]=e[i].y;
        }
    }
    sort(a,a+t);
    ans=0;
    for(i=t-1;i>=t-n;i--)
        ans=ans+a[i];
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#define MAX 100000000
using namespace std;
int main()
{
  ll n,l;cin>>n>>l;
  ll f_all=(l-1)*n+n*(n+1)/2,min=abs(l),act=l;
  for(ll i=2;i<=n;i++)
  {
  	ll a=abs(l-1+i);
  	if(a<min)
  	{
	  min=a;act=l-1+i;
	 }
  }
  cout<<f_all-act;
   
  
	
	
	
	
	
 return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
static int n;
    
    static ArrayList<ArrayList<pair>> m;
    static int[]amo;//count of factor
     public static void main(String[] args) {
		// TODO Auto-generated method stub
     int i,j,k,u,v;
     Scanner sca=new Scanner(System.in);
     n=sca.nextInt();
     m=new ArrayList<ArrayList<pair>>();
     for(i=0;i<n;i++){
    	 u=sca.nextInt();
    	 k=sca.nextInt();
        ArrayList<pair> mini=new ArrayList<pair>();
    	 for(j=0;j<k;j++){
    	       v=sca.nextInt();
	       mini.add(new pair(v,sca.nextInt()));
    	 }
	 m.add(mini);
     }
     dijkstra();
    }
    public static void dijkstra(){
	int i,u,v,myn;
		pair hz;
	       	PriorityQueue<pair> qu=new PriorityQueue<pair>((p1,p2)->Integer.compare(p1.getdis(),p2.getdis()));
	  int d[]= new int[n];
	int[] check=new int[n];//checked ->1,yet-> 0checking->2
		for(i=0;i<n;i++){
			d[i]=Integer.MAX_VALUE;
		}
		d[0]=0;
		qu.add(new pair(0,0));
		check[0]=2;
		while(!qu.isEmpty()){
		    hz=qu.poll();
		    u=hz.getnext();
			check[u]=1;
			if(d[u]<hz.getdis())continue;
			myn=m.get(u).size();
			for(i=0;i<myn;i++){
			    v=m.get(u).get(i).getnext();
			 if(check[v]==1)continue;
			 if(d[v]>d[u]+m.get(u).get(i).getdis()){
			     d[v]=d[u]+m.get(u).get(i).getdis();
			     qu.add(new pair(v,d[v]));
			     check[v]=2;
			 }
			}
		}
		for(i=0;i<n;i++){
			if(d[i]==Integer.MAX_VALUE)d[i]=-1;
			System.out.println(i+" "+d[i]);
		}
	}
}
class pair{
    int next,dis;
    pair(int next,int dis){
	this.next=next;
	this.dis=dis;
    }
   public int getnext(){
	return next;
    }
   public  int getdis(){
	return dis;
    }
}



Measured memory_bytes: 277720
#include <stdio.h>

int check_input(int N, int T, int* t)
{
  if((1 <= N && N <= 200000) && (1 <= T && T <= 1000000000)){
    int i,temp,flag;
    temp = 0;
    flag = 1;
    for(i = 0; i < N; i++){
      if(temp > t[i] && temp != 0){
        flag = -1;
        puts("Error: tの制約条件を満たしていません");
        break;
      }
      temp = t[i];
    }
    return flag;
  }else{
    puts("Error: N,Tの制約条件を満たしていません");
    return -1;
  }
}

int solution(int N, int T, int* t)
{
  int i,sum;
  sum = 0;
  for(i = 0; i < N-1; i++){
    if(t[i+1] - t[i] < T){
      sum += t[i+1] - t[i];
    }else{
      sum += T;
    }
  }
  return sum+T;
}

int main()
{
  int N,T,i;
  char line[256], *ch;
  scanf("%d %d", &N, &T);
  int t[N];
  for(i=0; i < N; i++){
    scanf("%d", &t[i]);
  }
  if (check_input(N, T, t) == 1){
    int time = solution(N,T,t);
    printf("%d\n", time);
    return 0;
  }
  else{
    return -1;
  }

}

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

#define sint(a) scanf("%d", &a)
#define sint2(a, b) scanf("%d %d", &a, &b)
#define sll(a) scanf("%lld", &a)
#define sll2(a, b) scanf("%lld %lld", &a, &b)
#define mem(a, i) memset(a, i, sizeof(a))
#define pb push_back
#define int long long
#define ll long long
#define lson node << 1
#define rson (node << 1) + 1
#define endl "\n"

const int maxn = 1e6 + 10;
const int mod = 998244353;
const double pi = acos(-1);

int gcd(int a, int b)
{
  return b ? gcd(b, a % b) : a;
}

int lcm(int a, int b)
{
  return a * b / gcd(a, b);
}

int qpow(int a, int n)
{
  int b = 1;
  while (n)
  {
    if (n & 1)
      b = a * b % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return b;
}

class Prime_Number
{
public:
  int prime[maxn], s, v[maxn];
  void prime_init(int n)
  {
    for (int i = 2; i <= n; i++)
    {
      if (!v[i])
      {
        prime[s++] = i;
        for (int j = 1; j * i <= n; j++)
          v[i * j] = 1;
      }
    }
  }
};

void solve()
{
  string s;
  cin >> s;
  int ans = 0;
  if (s[1] == 'R')
  {
    ans++;
    for (int i = 0; i < 3; i++)
     if(s[i]=='R')
      ans++;
    ans--;
  }
  else
  {
    if (s[0] == 'R' || s[2] == 'R')
      ans++;
  }
  cout << ans;
}
signed main()
{
  solve();
  return 0;
}


Measured memory_bytes: 3624
#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left, bisect_right #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

N = int(input())

if 30<=N:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 65236
# include <iostream>
# include <string>
# include <set>
# include <algorithm>
# include <cmath>
# include <vector>
# include <string>
# include <map>
# include <iomanip>
# include <queue>
# include <stack>
# include <deque>

using namespace std;

int main()
{
    int n, p[60] = {};
    cin >> n;
    for( int i = 1; i <= n; i++ ){
        cin >> p[i];
    }

    for ( int i = 1; i <= n; i ++ ){
        for( int j = 1; j <= n; j ++ ){
            swap( p[i], p[j] );
            bool t = true;
            for( int k = 2; k <= n; k ++ )if( p[k] < p[k - 1] ) t = false;
            if( t ){
                cout << "YES";
                return 0;
            }
            swap( p[i], p[j] );
        }
    }
    cout << "NO";
    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pi M_PI
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;
typedef pair<P,int> PP;

void Main() {
  int n,m;
  cin >> n >> m;
  int d[n][n];
  rep(i,n)rep(j,n) d[i][j]=MAX;
  PP p[m];
  rep(i,m) {
    int x,y,z;
    cin >> x >> y >> z;
    x--,y--;
    d[x][y]=z;
    d[y][x]=z;
    p[i]=PP(P(x,y),z);
  }
  rep(k,n)rep(i,n)rep(j,n) {
    if(d[i][k]!=MAX&&d[k][j]!=MAX) d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
  }
  int ans=0;
  rep(i,m) {
    int x=p[i].F.F,y=p[i].F.S,z=p[i].S;
    if(d[x][y]!=z) ans++;
  }
  pr(ans);
}

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


Measured memory_bytes: 256
N = int(input())
amari = N%10
if amari == 2 or amari == 4 or amari == 5 or amari == 7 or amari == 9:
    print("hon")
elif amari == 0 or amari == 1 or amari == 6 or amari == 8:
    print("pon")
else:
    print("bon")


Measured memory_bytes: 9164
#include<stdio.h>

int main(){
    int i,a,b,c,d,e,f,tmp;
    float x,y;

    while(scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f)!=-1){
        x = (float)(c*e-b*f)/(a*e-d*b);
        y = (float)(c*d-a*f)/(b*d-a*e);
        if(-0.0005<x && x<=0)x=0;
        if(-0.0005<y && y<=0)y=0;
        printf("%.3f %.3f\n",x,y);
    }
    return 0;
}

Measured memory_bytes: 636
import java.lang.*;
import java.util.*;
public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        if(s.charAt(0)!=s.charAt(1)){
            if(s.charAt(2)==s.charAt(3)){
                if(s.charAt(4)==s.charAt(5)){
                     System.out.print("Yes");
                }
                else{
                    System.out.print("No");
                }
            }
            else{
                 System.out.print("No");
            }
        }
        else{
            System.out.print("No");
        }
    }
}


Measured memory_bytes: 23252
'''
INPUT SHORTCUTS
N, K = map(int,input().split())
N ,A,B = map(int,input().split())
string = str(input())
arr = list(map(int,input().split()))
N = int(input())
'''


H, n = map(int,input().split())
arr = list(map(int,input().split()))
add = sum(arr)
if add>=H:
	print("Yes")
else:
	print("No")


Measured memory_bytes: 52292
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <stdio.h>
#include <string>
#include <vector>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <stack>
#include <utility>
#include <queue>
using namespace std;
typedef long long int lld;
typedef long double llf;
typedef pair<lld, lld> pii;

const int MAXN = 202;

int n;
int matriz[MAXN][MAXN];

bool oddCycle() {
  int color[n];
  fill(color, color+n, -1);
  queue<int> cola;
  cola.push(0);
  color[0] = 0;
  while(!cola.empty()) {
    int u = cola.front();
    cola.pop();
    for (int v = 0; v < n; ++v) {
      if (matriz[u][v] == 1) {
        if (color[v] == -1) {
          color[v] = color[u]^1;
          cola.push(v);
        } else {
          if (color[u] == color[v]) return true;
        }
      }
    }
  }
  return false;
}

int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  
  cin >> n;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      char c;
      cin >> c;
      matriz[i][j] = c - '0';
    }
  } 

  if (oddCycle()) {
    cout << "-1\n";
  } else {
    // dijkstra
    for (int k = 0; k < n; ++k) {
      for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
          if (i == j) continue;
          if (!matriz[i][k] || !matriz[k][j]) continue;
          if (matriz[i][j] != 0 && matriz[i][j] < matriz[i][k]+matriz[k][j]) continue;
          matriz[i][j] = matriz[i][k] + matriz[k][j];
        }
      }
    }
    int ans = 0;
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
        ans = max(ans, matriz[i][j]);
      }
    }
    cout << ans+1 << "\n";
  }
  return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

int main()
{
    int n;

    scanf("%d", &n);

    for (int i = 0; i < 3; i++) {
        if (n % 10 == (n / 10) % 10) {
            puts("Bad");
            return 0;
        }

        n /= 10;
    }

    puts("Good");

    return 0;
}


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

int main(){
    int n,m;
    cin >> n >> m;
    vector<pair<int,char>> array(m);
    for(int i=0;i<m;i++) cin >> array.at(i).first >> array.at(i).second;
    int s,g;
    s = 1;
    for(int i=0;i<n-1;i++) s*=10;
    g = s * 10;
    if(n == 1) s = 0;
    for(int i=s;i<g;i++){
        string str_number = to_string(i);
        bool flag = true;
        for(int j=0;j<m;j++){
            if(str_number.at(array.at(j).first - 1) != array.at(j).second) flag = false;
            
        }
        if(flag){
                cout << str_number << endl;
                return 0;
            }
    }
    cout << -1 << endl;
}

Measured memory_bytes: 3692
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] age)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuffer sb = new StringBuffer();
		int i = 0;
		int j = 0;

		while( true ){
			String input = br.readLine();

			if( input.equals("0") ) break;

			for( i=0 ; i<input.length() ; i++ ){
				j = j + Integer.parseInt(input.substring(i, i+1));
			}
			sb.append(Integer.toString(j)).append("\n");
			j = 0;
		}
		System.out.print(sb);
	}
}

Measured memory_bytes: 24988
def calc(L, R):
    imod = L % 2019
    if (imod == 0):
        print(0)
    elif (R - L > 2019 - imod - 1):
        print(0)
    else:
        m = L * 2019
        for i in range(L, min(R + 1, L + 2019 - imod)):
            for j in range(i + 1, min(R + 1, L + 2019 - imod)):
                x = (i * j) % 2019
                m = min(m, x)
        print(m)


s = input().split(' ')
L = int(s[0])
R = int(s[1])
calc(L, R)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<int,int>;
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;}
const int inf = 1001001001;

int main() {
    char c;
    cin >> c;
    char nc = c+1;
    cout << nc << endl;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			int N = scan.nextInt();
			int[] A  = new int[N];
			
			for(int i=0;i<N;i++) {
				A[i] = scan.nextInt();
				//System.out.println(A[i]);
			}
			
			
			Arrays.sort(A);
			int ok = 1;
			
			//System.out.println(N);
			for(int k = 0;k<N-1;k++) {
				//System.out.println("nono");
				
				if(A[k] == A[k+1]) {	
					ok=0;
					break;
				}
			}
			
			
			System.out.println(ok==1?"YES":"NO");
			

			
			
			
			
		}
		
		
	}
		

}


Measured memory_bytes: 64632
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		dPA();

	}

	private static void dPA() {
		Scanner scanner = null;
		int numFrog = 0;
		int numK = 0;

		try {
			scanner = new Scanner(System.in);
			numFrog = scanner.nextInt();
			numK = scanner.nextInt();
			int[] heightArray = new int[numFrog];

			for (int i = 0; i < numFrog; i++) {
				heightArray[i] = scanner.nextInt();
			}

			int[] koufukuArray = new int[numFrog];
			Arrays.fill(koufukuArray, Integer.MAX_VALUE);
			koufukuArray[0] = 0;
			koufukuArray[1] = Math.abs(heightArray[1] - heightArray[0]);
			for (int i = 0; i < heightArray.length; i++) {
				for (int j = 1; j <= numK; j++) {
					if (i + j >= heightArray.length) {
						break;
					}
					int val1 = Math.abs(heightArray[i + j] - heightArray[i]);
					koufukuArray[i + j] = Math.min(koufukuArray[i + j], val1 + koufukuArray[i]);
				}
			}
			System.out.println(koufukuArray[koufukuArray.length - 1]);

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}

Measured memory_bytes: 51856
#include <bits/stdc++.h>
using namespace std;
int main(){
	char c[10005];
    int n;
	cin >> n;
    cin>>c;
    int len = strlen(c);
    for(int i = 0; i < len; ++i) {
        c[i] -= 'A';
    }
    for(int i = 0; i < len; ++i) {
        c[i] += n;
        c[i] %= 26;
    }
    for(int i = 0; i < len; ++i) putchar(c[i] + 'A');
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

     static Scanner scanner;

     public static void main(String[] args) {
         scanner = new Scanner(System.in);

         long X=gl();

         long A=0;
         long B=0;
         while(true) {
        	 long A5=(long)Math.pow(A, 5);
        	 if(A5>=0) {
        		 long B5=A5-X;
        		 double div=1d/5d;
        		 double d=Math.pow(Math.abs(B5), div);
        		 B=B5>=0 ? Math.round(d) : -Math.round(d);
        		 if(A5-Math.pow(B, 5)==X) {
        		     break;
        	     }
        		 A5=-A5;
        		 B5=A5-X;
        		 d=Math.pow(Math.abs(B5), div);
        		 B=B5>=0 ? Math.round(d) : -Math.round(d);
        		 if(A5-Math.pow(B, 5)==X) {
        			 A=-A;
        		     break;
        	     }
        	 } else {
        		 break;
        	 }
        	 A++;
         }


         System.out.println(A + " " + B);
     }

     // 文字列として入力を取得
     public static String gs() {
          return scanner.next();
     }

     // intとして入力を取得
     public static int gi() {
          return Integer.parseInt(scanner.next());
     }

     // longとして入力を取得
     public static long gl() {
          return Long.parseLong(scanner.next());
     }

     // doubleとして入力を取得
     public static double gd() {
          return Double.parseDouble(scanner.next());
     }
}

Measured memory_bytes: 38836
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    // Your code here!
    int a,b;
    cin >> a >> b;
    
    if( a > b * 2){
        cout << a - b * 2 << endl;
    }
    else{
        cout << '0' << endl;
    }
    
}

Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    vector<vector<int>> c;
    for (int i = 0; i < 3; i++) {
        c.push_back(vector<int>());
        for (int j = 0; j < 3; j++) {
            int a;
            cin >> a;
            c[i].push_back(a);
        }
    }
    for (int a1 = 0; a1 <= 100; a1++) {
        int b1 = c[0][0] - a1;
        int b2 = c[0][1] - a1;
        int b3 = c[0][2] - a1;
        int a2 = c[1][0] - b1;
        int a3 = c[2][0] - b1;
        if (a2 + b2 == c[1][1] && a3 + b3 == c[2][2] && a2 + b3 == c[1][2] && a3 + b2 == c[2][1]) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
using namespace std;
const int MAXN = 2e5 + 1;
int n, m, i, j, k, z;
long a[MAXN], b[MAXN];
signed main()
{
    scanf("%d %d %d", &n, &m, &k);
	for (i = 1; i <= n; ++i)
		scanf("%d", &a[i]), a[i] += a[i - 1];
	for (i = 1; i <= m; ++i)
		scanf("%d", &b[i]), b[i] += b[i - 1];
	z = 0, i = 0, j = m;
	while (a[i] <= k && i <= n)
	{
		while (b[j] > k - a[i])
			--j;
		if (i + j > z)
			z = i + j;
		++i;
	}
	printf("%d", z);
}

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

using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VD = vector<double>;
using VVD = vector<VD>;
using VS = vector<string>;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VL = vector<long long>;
using VVL = vector<VL>;

#define sz(var) (int)var.size()
#define REP(var, start, end) for(int var = start; var < (int)end; ++var)
#define CLEAR(var, with) memset(var, with, sizeof(var))
#define ALL(x) x.begin(), x.end()
#define LL long long
#define ULL unsigned long long

int n;
VL health;
LL A, B;
bool canVanishall(LL numHits)
{
	if(numHits == 2)
		int a = 10;
	LL ans = 0, extra = A - B;
	REP(i, 0, n)
	{
		LL remain = max(0ll, health[i] - B * numHits);
		if(remain == 0ll) continue;
		ans += (remain % extra == 0ll) ? remain / extra : remain / extra + 1;
	}
	return ans <= numHits;
}

int minExplosions()
{
	sort(ALL(health));

	LL lo = 0, hi = (LL)1e9 + 1;
	while(lo + 1 < hi)
	{
		LL mid = (lo + hi) / 2;
		if(canVanishall(mid))
			hi = mid;
		else
			lo = mid;
	}
	return hi;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
//	freopen("tmp.in", "r", stdin);
//	freopen("tmp.out", "w", stderr);
#endif
	cin >> n >> A >> B;

	health = VL(n);
	REP(i, 0, n) cin >> health[i];

	cout << minExplosions() << endl;

	return 0;
}

Measured memory_bytes: 1024
n = int(input())
S = []
H = []
C = []
D = []
for i in range(n):
    mark, num = input().split()
    if mark == "S":
        S.append(int(num))
    elif mark == "H":
        H.append(int(num))
    elif mark == "C":
        C.append(int(num))
    elif mark == "D":
        D.append(int(num))
marks = ['S', 'H', 'C', 'D']
cards = [sorted(S), sorted(H), sorted(C), sorted(D)]
for i in range(4):
    mark = marks[i]
    for num in range(1,14):
        if not(num in cards[i]):
            print('{0} {1}'.format(mark, num))

Measured memory_bytes: 7624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    int q;
    cin >> q;
    for(int i = 0; i < q; i++)
    {
        ll a, b;
        cin >> a >> b;
        if(a == b)
        {
            cout << 2*(a-1) << endl;
            continue;
        }
        ll sum = a * b;
        sum--;
        ll sq = sqrt(sum);
        ll ans = 2 * sq - 1;
        if(sum / sq == sq)
        {
            cout << ans-1 << endl;
            continue;
        }
        if(sq * (sq+1) >= a*b)
        {
            cout << ans-2 << endl;
            continue;
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int i, n, min, maxdif, a[200000];
	maxdif = -1000000000;

	scanf("%d", &n);

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

	min = a[0];

	for (i = 1; i < n; i++) {
		if (maxdif < a[i] - min) { maxdif = a[i] - min; }
		if (a[i] < min) { min = a[i]; }
	}

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

	return 0;
}

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

typedef long long ll;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(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;
}

//これを使うときにはCOMinit();を忘れずに

int main(void){
    int N, K; cin >> N >> K;
    K = min(N-1, K);
    COMinit();
    //0..K部屋の空きができる
    //n部屋にr人を分ける（1人もいなくても構わない）
    //(n-1+r)Cr
    ll ans = 0;
    for(int i = 0; i <= K; i++){
        ll keisuu = COM(N, i);
        ll people = i;
        ans = (ans + keisuu*COM((N-i)-1+people, people)) % MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 12160
#include"bits/stdc++.h"

using namespace std;

int main() {
	string S;
	cin >> S;
	int cnt = 0;
	sort(S.begin(), S.end());
	for (int i = 0; i < S.length(); i++) {
		if (S[i] == S[i + 1]) {
			cnt++;
		}
	}

	cout << (cnt >= 1 ? "no" : "yes") << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <climits>
#include <bitset>
#include <sstream>
#include <iomanip>

using namespace std;

typedef long long ll;

#define mkp make_pair
#define eb emplace_back
#define sz(s) (ll)(s.size())
const int N = 3e6 + 123;
const int mod = 1e9 + 7;
const int INF = INT_MAX;

#define int ll

#define all(s) s.begin(), s.end()

int ans = 0;

vector <pair <int, int> > g[N];

int por[N];

void dfs(int v, int color, int pr) {
	int res = 1;
	
	for (pair <int, int> toi : g[v]) {
		int to = toi.first;
		if (pr == to)
			continue;
		int pos = toi.second;
		if (color == res)
			++res;
		por[pos] = res;
		dfs(to, res, v);
		res += 1;
	}
}

main (){
	clog << "Ready\n";
	
	int m;
	cin >> m;
	for (int i = 1; i < m; ++ i) {
		int x, y;
		cin >> x >> y;
		g[x].eb(mkp(y, i));
		g[y].eb(mkp(x, i));
	}
	
	int pos = -1;
	for (int i = 1; i < m; ++ i) {
		if (ans < sz(g[i])) {
			pos = i;
			ans = sz(g[i]);
		}
	}
	
	cout << ans << '\n';
	
	dfs(pos, 0, -1);
	
	for (int i = 1; i < m; ++ i) {
		cout << por[i] << '\n';
	}
	
    cout << '\n';
	return 0;
}


Measured memory_bytes: 79616
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */
int main() {
  
  lint n, k; cin >> n >> k;
  vector<lint> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i]--;
  }

  // ダブリング前処理
  vector<vector<int>> doubling(62, vector<int> (n));

  for (int j = 0; j < n; j++) {
    doubling[0][j] = a[j];
  }

  for (lint i = 1; i < 62; i++) {
    // 2^i 個先は，2^{i - 1} 個先の
    for (int j = 0; j < n; j++) {
      doubling[i][j] = doubling[i - 1][doubling[i - 1][j]];
    }
  }

  int cur = 0;
  for (lint i = 0; i < 62; i++) {
    if(k & (1LL << i)) {
      cur = doubling[i][cur];
    }
  }
  cout << cur + 1 << endl;
  return 0;
}



Measured memory_bytes: 54172
/**
*    author:  yuya1234
*    created: 22.07.2020 13:59:52
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
long double eps = 1.0E-14;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define FORV(i,v) for(auto i=v.begin(); i!=v.end();i++)

#define SORT(s) sort((s).begin(),(s).end())
#define SORTD(s) sort((s).rbegin(),(s).rend())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define SZ(x) ((int)(x).size())
#define MEMSET(v, h) memset((v), h, sizeof(v))

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<class T>T lcm(T a,T b){return gcd(a,b)*(a/gcd(a,b))*(b/gcd(a,b));}

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

  int n;
  cin>>n;

  vector<int> v;
  int sum=0;

  FOR(i,1,n)
  {
    sum+=i;
    v.emplace_back(i);
    if(sum>=n)break;
  }

  int key=sum-n;

  for(auto vv:v)
  {
    if(vv!=key)cout<<vv<<endl;
  }

  return 0;
}

Measured memory_bytes: 3624
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=tf-8
#

"""
"""

from collections import defaultdict
import bisect

import sys
input = sys.stdin.readline

def solve(n, a):
    mm = 0
    ans = 0
    for aa in a:
        ans += max(mm-aa,0)
        mm = max(mm,aa)
    print(ans)
            

def main():
    n = int(input())
    a = list(map(int,input().split()))
    solve(n, a)


if __name__ == "__main__":
    main()

Measured memory_bytes: 104216
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

template <typename T>
struct BIT {
  int n;
  vector<T> d;
  BIT(int n = 0) : n(n), d(n + 1) {}
  void add(int i, T x = 1) {
    for(i++; i <= n; i += i & -i) {
      d[i] += x;
    }
  }
  T sum(int i) {
    T x = 0;
    for(i++; i; i -= i & -i) {
      x += d[i];
    }
    return x;
  }
};

int n, q;
string s;
vi ans;
vector<BIT<int>> bit;

void f() {
  int i;
  char c;
  cin >> i >> c;
  i--;
  int ci = s[i] - 'a';
  int cj = c - 'a';
  s[i] = c;
  bit[ci].add(i, -1);
  bit[cj].add(i);
}

void g() {
  int l, r;
  cin >> l >> r;
  l--;
  r--;
  int num = 0;
  rep(i, 26) {
    int a = bit[i].sum(r);
    if(l > 0) a -= bit[i].sum(l - 1);
    if(a) num++;
  }
  ans.push_back(num);
}

int main() {
  cin >> n >> s >> q;
  bit = vector<BIT<int>>(26, BIT<int>(n));
  rep(i, s.size()) {
    char c = s[i];
    int ci = c - 'a';
    bit[ci].add(i);
  }
  rep(i, q) {
    int type;
    cin >> type;
    if(type == 1)
      f();
    else
      g();
  }
  for(int v : ans) cout << v << endl;
}

Measured memory_bytes: 53636
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <cstdio>
#include <numeric>
#include <queue>

using namespace std;

using ll=long long;

ll N, K;
const ll mod = 1e9+7;

ll sum[200005];

int main()
{
    cin >> N >> K;
    for(int i = 1;i <= N;i++)
    {
        sum[i] = sum[i-1] + i;
    }
    ll ans = 0;
    for(int i = K;i < N+1;i++)
    {
        ans += (sum[N] - sum[N-i]) - sum[i-1] + 1;
        ans %= mod;
    }
    ans = (ans + 1) % mod;
    cout << ans << endl;
   return 0;
}

Measured memory_bytes: 4716
#include <bits/stdc++.h>
#include <iostream>
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define INF 1350851717672992089
#define ll long long int
#define ld long double
#define pi pair<int, int>
#define vi vector<ll>
#define vp vector<pair<ll, ll>>
#define pb push_back
#define mp make_pair
#define M 1000000007
#define F first
#define S second
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    int a[n];
    for (int i=0; i<n; i++)
        cin>>a[i];
    int dp[n];
    dp[0]=0;
    dp[1]=abs(a[1]-a[0]);
    for (int i=2; i<n; i++)
    {
        int temp=M;
        for (int j=1; j<=min(k,i); j++)
            temp=min(temp,dp[i-j]+abs(a[i]-a[i-j]));
        dp[i]=temp;
    }
    cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1152
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long llong;

static const int MAX = 50;
llong dp[MAX + 1][MAX * MAX * 2 + 1];

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

    int x[n + 1];
    int y;
    for (int i = 1; i <= n; i++){
        cin >> y;
        x[i] = y - A;
    }

    for (int i = 0; i <= n; i++){
        for (llong j = 0; j <= MAX * MAX * 2; j++){
            if ((i == 0) && (j == MAX * MAX)) dp[i][j] = 1;
            else if ((i > 0) && (((j - x[i]) < 0) || ((j - x[i]) > MAX * MAX * 2))) dp[i][j] = dp[i - 1][j];
            else if ((i > 0) && ((0 <= (j - x[i])) || ((j - x[i]) <= MAX * MAX * 2))) dp[i][j] = dp[i - 1][j] + dp[i - 1][j - x[i]];
            else dp[i][j] = 0;
        }
    }

    cout << dp[n][MAX * MAX] - 1 << endl;

    return 0;
}

Measured memory_bytes: 2304
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

int a[5];
int main()
{
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a + 3);
    if (a[0] + a[1] == a[2]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

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

    int sum = 0;
    rep(i, N) sum += i + 1;

    vector<pair<int, int>> ret;

    if (sum % 2 == 0) {
        sum /= 2;
        set<int> s1, s2;
        for (int i = N; i >= 1; i--) {
            if (sum >= i) {
                s1.insert(i);
                sum -= i;
            } else {
                s2.insert(i);
            }
        }
        for (int n1 : s1) for (int n2 : s2) {
            ret.push_back(mp(n1, n2));
        }
    } else {
        vector<int> sums(N, 0);
        if (N % 2) {
            REP(i, 1, N - 1) {
                ret.push_back(mp(i, N));
                sums[i - 1] += N;
                sums[N - 1] += i;
            }
            REP(i, 1, N - 1) {
                REP(j, i + 1, N - 1) {
                    if (i + j == N) continue;
                    ret.push_back(mp(i, j));
                    sums[i - 1] += j;
                    sums[j - 1] += i;
                }
            }
        } else {
            REP(i, 1, N) {
                REP(j, i + 1, N) {
                    if (i + j == N + 1) continue;
                    ret.push_back(mp(i, j));
                    sums[i - 1] += j;
                    sums[j - 1] += i;
                }
            }
        }
        rep(i, N) cerr << sums[i] << " ";
        cerr << endl;
    }

    cout << ret.size() << endl;
    for (auto pr : ret) cout << pr.first << " " << pr.second << endl;

    return 0;
}


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

int main()
{
    int n;
    cin >> n;
    cout << n<<":";
    int fac=2;
    vector<int> factors;
    if (n%fac==0)
    {
        while (n%fac==0)
        {
            factors.push_back(fac);
            n=n/fac;
        }
    }
    fac++;
    while (fac*fac<=n)
    {
        if (n%fac==0)
        {
            while (n%fac==0)
            {
                n/=fac;
                factors.push_back(fac);
            }
        }
        fac+=2;
    }
    if (n!=1) factors.push_back(n);
    for (int i=0;i<factors.size();i++) cout << " " << factors[i];
    cout << endl;
    return 0;
}


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

using namespace std;

int main() {

    int a, b, c, d;
    cin >> a >> b >> c >> d;

    int x3, y3, x4, y4;

    int x = c - a;
    int y = d - b;

    x3 = c - y;
    y3 = d + x;
    x4 = a - y;
    y4 = b + x;

    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;

    return 0;
}

Measured memory_bytes: 256