akhauriyash/Code-Regression huggingface dataset:
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

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

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

using namespace std;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 1000000000;//10^9
ll MOD  = 1000000007;
//vector<int> dy = {0,0,1,-1};
//vector<int> dx = {1,-1,0,0};

vector<int> pow_change(vector<int> &c, ll n){
  vector<int> res(c.size()), c_(c.size());
  rep(i, c.size()) res[i] = i;
  while(n > 0){
    if(n&1){
      rep(i, c.size()){
        c_[i] = res[c[i]];
      }
      res = c_;
    }
    rep(i, c.size()){
      c_[i] = c[c[i]];
    }
    c = c_;
    n >>= 1;
  }
  return res;
}

int main(void){
  ll N; cin >> N;
  vector<ll> x(N); rep(i, N) cin >> x[i];
  ll M, K; cin >> M >> K;
  vector<ll> a(M); rep(i, M) cin >> a[i];

  vector<ll> d(N-1); rep(i, N-1) d[i] = x[i+1] - x[i];
  vector<int> change(N-1); rep(i, N-1) change[i] = i;
  rep(i, M) swap(change[a[i]-2], change[a[i]-1]);
  change = pow_change(change, K);
  ll position = x[0];
  cout << position << endl;
  rep(i, N-1){
    position += d[change[i]];
    cout << position << endl;
  }
}


Measured memory_bytes: 3952
<?php
fscanf(STDIN, "%d", $a);
fscanf(STDIN, "%d", $b);

$data_array = [1, 2, 3];

foreach ([$a, $b] as $num) {
  if(($key = array_search($num, $data_array)) !== false) {
      unset($data_array[$key]);
  }
}

foreach ($data_array as $result) {
  echo $result;
}

Measured memory_bytes: 4604
import numpy as np
mod = 10**9+7
def MatPower(A, k):
    B = np.identity(len(A), dtype = object)
    while k:
        if k&1:
            B = np.dot(A, B)%mod
        A = np.dot(A, A)%mod
        k//=2
    return B
N, K = map(int, input().split())
a = np.array([list(map(int, input().split())) for _ in range(N)], dtype = object)
v = np.array([1]*N, dtype = object).T
An = MatPower(a, K)
v = np.dot(An, v)%mod
print(v.sum()%mod)

Measured memory_bytes: 18464
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
template<class Read>void in(Read &x){
    x=0;
    int f=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        f|=(ch=='-');
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    x=f?-x:x;
    return;
}
ll x,y;
int main(){
	in(x);in(y);
    cout<<x*y/__gcd(x,y)<<endl;
    return 0;
}


Measured memory_bytes: 384
# グリッドのセルは mod 3 で 3グループ（あまりが0, 1, 2）にわけられる。
# C の上限が 30 と小さいので色分けはせいぜい 24360 パターンしかない
# これらのパターンについて違和感を計算するが
# 愚直にやると少し遅い O(C^3 * N^2)
# C が小さいことを利用して、出現した色の数をカウンタで保持すると、C^3 * C になるので間に合う
# →解説も同様

N, C = map(int, input().split())

D = [[int(x) for x in input().split()] for i in range(C)]
grid = [[int(x) for x in input().split()] for i in range(N)]

from collections import Counter
groups = [Counter(), Counter(), Counter()]
for x in range(N):
    for y in range(N):
        groups[(x + y) % 3][grid[x][y]] += 1

# N <= 500
# Choose(N, 3) = 500 * 500 * 500 / 6
from itertools import permutations
import sys
m = 500 * 500 * 2000
for c1, c2, c3 in permutations(list(range(0, C)), 3):
    score = sum(D[c-1][c1] *cnt for c, cnt in groups[0].items())
    score += sum(D[c-1][c2] *cnt for c, cnt in groups[1].items())
    score += sum(D[c-1][c3] *cnt for c, cnt in groups[2].items())
    m = min(m, score)

print(m)


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

#define int long long

using namespace std;

int get (int x) {
	int res = 0;
	while (x) {
		res += x % 10;
		x /= 10;
	}
	return res;
}

 main () {   
 	int n;
 	cin >> n;
 	int ans = 1e9 + 7;
 	for (int i = 1;i < n;i ++) {
 		ans = min (ans, get (i) + get (n - i));
 	}
 	cout << ans;
    return 0;           		
}

Measured memory_bytes: 256
s = input()
n = len(s)

#左から順番に文字を結合していき+を入れるパターンと入れないパターンについて同様に文字を結合させていく
def dfs(i,f):
    if i == n-1:#すべての文字を使いきったらそのときの計算をする
        return sum(list(map(int,f.split("+"))))
    return dfs(i+1,f+s[i+1]) + dfs(i+1,f+"+"+s[i+1])#+を入れない場合、+をいれる場合
    
print(dfs(0,s[0]))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using namespace std;
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)

int main(){
  double a,b,x,y;
  cin>>a>>b>>x;
  if(x>=b*a*a/2){
  y=a*a*a/(2*a*a*b-2*x);
  }
  else{
  y=2*x/(a*b*b);
  }
  cout << fixed << setprecision(15);
  cout<<90.0-rad_to_deg(atan(y));
}

Measured memory_bytes: 4004
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll a, x;
  in(x);
  a = 100;
  ll k = 0;
  while(true){
    k++;
    a = a + a / 100;
    if(a >= x){
      out(k);
      memi;
      return 0;
    }
  }
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int main()
{
string a,b,c;
int d,e;
cin>>a>>b>>d>>e>>c;
if (a==c)
cout<<d-1<<" "<<e<<endl;
else
cout<<d<<" "<<e-1<<endl;
return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#pragma GCC optimize("O2")
#define rep(i,N) for(int i=0;i<(int)N;i++)
static inline char CH()
{
  static char buf[100000],*ptr1=buf,*ptr2=buf;
  return ptr1==ptr2&&(ptr2=(ptr1=buf)+fread(buf,1,100000,stdin),ptr1==ptr2)?EOF:*ptr1++;
}
static inline long IN(void)
{
  long x=0;int f=0,c=CH();while(c<48||c>57){f^=c==45,c=CH();}
  while(c>47&&c<58){x=x*10+c-48,c=CH();}return f?-x:x;
}
static inline void OUT(long x){if(x<0)putchar('-'),x=-x;if(x>=10)OUT(x/10);putchar(x%10+48);}
static inline void Radix32(int A[],const int sz)
{
  int temp[200001];const int bit=8;
  rep(k,4)
  {
    int u[256]={},v[256]={};
    rep(i,sz)u[A[i]>>bit*k&((1<<bit)-1)]++;
    rep(i,(1<<bit)-1)u[i+1]+=u[i];
    rep(i,sz){temp[--u[A[sz-1-i]>>bit*k&((1<<bit)-1)]]=A[sz-1-i];}k++;
    rep(i,sz)v[temp[i]>>bit*k&((1<<bit)-1)]++;
    rep(i,(1<<bit)-1)v[i+1]+=v[i];
    rep(i,sz)A[--v[temp[sz-1-i]>>bit*k&((1<<bit)-1)]]=temp[sz-1-i];
  }
}
int main(void)
{
  int N=IN(),x,p=0,m=0,z=0,A[200000];
  long K=IN(),count=0,l=-2e18,r=-l,mid;
  rep(i,N){x=IN();if(x>0)A[m+p++]=x;else if(x<0)A[p+m++]=x;else z++;}
  Radix32(A,m+p);
  if(K>1l*m*p&&K<1l*m*p+1l*z*(N-1)/2)return puts("0"),0;
  if(K<=1l*m*p)r=1l;else l=-1l;
  while(l<=r)
  {
    mid=(l+r)/2;count=0;
    if(mid>=0)
    {
      int plus=p-1,minus=m-1;count+=1l*z*(p+m)+1l*z*(z-1)/2+1l*p*m;if(count>=K){r=mid-1l;continue;}
      rep(i,p){while(i<plus&&1l*A[i]*A[plus]>mid){plus--;}if(i==plus){break;}count+=1l*plus-i;}if(count>=K){r=mid-1l;continue;}
      rep(i,m){while(i<minus&&1l*A[m+p-1-i]*A[m+p-1-minus]>mid){minus--;}if(i==minus){break;}count+=1l*minus-i;}
    }
    else{int low=0;rep(i,m){while(1l*A[low]*A[p+i]>mid&&low<p){low++;}count+=1l*p-low;}}
    if(count>=K)r=mid-1l;else l=mid+1l;
  }
  return OUT(l),0;
}

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

int main() {
  static constexpr int group[] = {-1, 0, 2, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0};

  int x, y;
  cin >> x >> y;
  cout << (group[x] == group[y] ? "Yes\n" : "No\n");
  return 0;
}


Measured memory_bytes: 256
N = int(input())
*A, = map(int, input().split())

d1 = [[0]*60 for _ in range(N+1)]
mod = 10**9+7

for i, n in enumerate(A, start=1):
    for j in range(60):
        d1[i][j] = d1[i-1][j] + ((n>>j)&1)

ans = 0
for i, n in enumerate(A, start=1):
    for j in range(60):
        a = d1[N][j]-d1[i][j] # 1
        if (n>>j)&1:
            a = N-a-i # 0

        ans += a*(1<<j)
    ans %= mod

print(ans)

Measured memory_bytes: 201932
#include<iostream>
#include<stdio.h>

using namespace std;

int main(){
	int n, x;
	char y;
	int C[4][13] = { 0 };
	cin >> n;
	for (int i=1; i <= n; i++){
		cin >> y >> x ;
		if (y == 'S'){
			C[0][x-1] = 1;
		}
		else if (y == 'H'){
			C[1][x-1] = 1;
		}
		else if (y == 'C'){
			C[2][x-1] = 1;
		}
		else if (y == 'D'){
			C[3][x-1] = 1;
		}
	}
	for (int j = 0; j < 4;j++){
		for (int k = 0; k < 13; k++){
			if (C[j][k] == 0){
				if (j == 0){
					cout << "S" << " " << k+1 << endl;
				}
				else if (j == 1){
					cout << "H" << " " << k+1 << endl;
				}
				else if (j == 2){
					cout << "C" << " " << k+1<< endl;
				}
				else if (j == 3){
					cout << "D" << " " << k+1 << endl;
				}
			}
		}
	}
	return 0;
	}


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

int main(){
	int n, ma, mb;
	scanf("%d %d %d", &n, &ma, &mb);
	
	int dp[1+n][420][420];
	for(int i=0; i<1+n; i++) for(int j=0; j<420; j++) std::fill_n(dp[i][j], 420, 10000);
	dp[0][0][0] = 0;

	for(int i=0; i<n; i++){
		int a, b, c;
		scanf("%d %d %d", &a, &b, &c);
		for(int A=0; A<419-a; A++){
			for(int B=0; B<419-b; B++){
				dp[i+1][A][B] = std::min(dp[i+1][A][B], dp[i][A][B]);
				dp[i+1][A+a][B+b] = std::min(dp[i+1][A+a][B+b], dp[i][A][B]+c);
			}
		}
	}
	
	int ans = 10000;
	for(int i=1; i<420; i++){
		for(int j=1; j<420; j++){
			if(i*mb==j*ma) ans = std::min(ans, dp[n][i][j]);
		}
	}
	
	if(ans>=10000) puts("-1");
	else printf("%d\n", ans);
	return 0;
}


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

#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
ll gcd(ll x,ll y){
    if(x%y==0)return y;
    return gcd(y,x%y);
}

int main(void){
    string s,t;
    cin>>s>>t;
    s.push_back(t[t.size()-1]);
    if(s==t)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3596
/**
 * Created by hiramekun at 19:56 on 2019-12-29.
 */
#include <bits/stdc++.h>

using namespace std;

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

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

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */
// 素因数分解
map<ll, ll> prime_factor(ll n) {
    map<ll, ll> mp;
    for (ll i = 2; i * i <= n; ++i) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }
    if (n != 1) mp[n]++;
    return mp;
}

// 素数判定
bool is_prime(ll n) {
    for (int i = 2; i * i <= n; i++) if (n % i == 0) return false;
    return n != 1;
}

// 約数列挙
vector<ll> divisor(ll n) {
    vector<ll> res;
    for (ll i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            res.emplace_back(i);
            if (i != n / i) res.emplace_back(n / i);
        }
    }
    return res;
}

void solve() {
    ll x;
    cin >> x;
    for (ll i = x; i <= 1e5 * 2; ++i) {
        if (is_prime(i)) {
            cout << i << '\n';
            return;
        }
    }
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 256
/* created   : 2019-10-27 23:12:22
 * accepted  : 2019-10-27 23:20:18
 * author    : landcold7
 */
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define mt make_tuple
#ifndef LOCAL
#define trace(...)
#endif
typedef long long ll;

void solve() {
  ll n; cin >> n;
  vector<pair<ll, ll>> a;
  for (ll x = 1; x * x <= n; x++) {
    if (n % x == 0) {
      a.emplace_back(x, n / x);
    }
  }
  ll ans = 1ll << 61;
  for (auto t : a) {
    ans = min(ans, t.x - 1 + t.y - 1);
  }
  cout << ans << '\n';
}

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


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

// varibable settings
#define int long long
const int INF=1e18;

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(a, b, c) make_tuple(a, b, c)
#define divceil(a,b) ((a)+(b)-1)/(b)
#define is_in(x, a, b) ((a)<=(x) && (x)<(b))
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

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

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
  #define cerrendl 42
#endif
//}}}

signed main(){
  int n,h;
  cin>>h>>n;
  vector<int> v(n),w(n);
  rep(i,n) cin>>v[i]>>w[i];

  vector<int> dp(h+1, INF);
  dp[0]=0;
  rep(i,n) rep(j,h+1){
  // rep(i,n) rrep(j,h+1){ // 01 napsack
    chmin(dp[min(j+v[i], h)], dp[j]+w[i]);  // jから配る
  }
  cout<<dp[h]<<endl;
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>
using namespace std;
bool is_int_lround(double x){
  return std::lround(x)==x;
}
int ketasuu(int x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

int main(){
  int N;
  cin >> N;
  vector<string> S(N);
  for(int i =0; i<N ;i++){
    cin >> S.at(i);
    sort(S.at(i).begin(), S.at(i).end());
  }
  sort(S.begin(), S.end());
  long long ans =0,tmp =1;
  for(int i=1; i<N; i++){
    if(S.at(i) ==S.at(i-1)){
      tmp++;
    }
    else{
      ans += tmp*(tmp-1)/2;
      tmp =1;
    }
  }
  ans += (tmp*(tmp-1)) / 2;
  cout << ans <<endl;
}

Measured memory_bytes: 7296
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int n, k, q;
    cin >> n >> k >> q;
    VI cnt(n);
    REP(i,q){
        cnt[in() - 1]++;
    }
    REP(i,n){
        if (k - q + cnt[i] > 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 1024
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<iostream>
#include<string>
#include<vector>
using namespace std;

const long long mod = 1e9 + 7;
int main() {
    int n, k;
    cin >> n >> k;
    if(n+1==k) {
        cout << 1 << endl;
        return 0;
    }

    long long ans = 0;
    vector<long long> dp1(n+1, 0);
    vector<long long> dp2(n+2, -1);
    for(int i = 1, j = n; i <= n; ++i, --j) {
        dp1[i] = dp1[i-1] + j;
        dp2[i+1] = dp2[i] + i;
    }
    for(int i = k; i <= n+1; ++i) {
        if(i < n+1) {
            ans += dp1[i] - dp2[i];
            ans %= mod;
        }
        else {
            ans += 1;
            ans %= mod;
        }
    }
    cout << ans << endl;
    return 0;
}

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

typedef long long int64;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>;

#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define SZ(c) ((int)(c).size())

int main() {
  cin.sync_with_stdio(false);
  cin.tie(nullptr);

  int n; cin >> n;
  int aa = n / 100;
  int bb = n % 100;

  bool mmyy = false;
  bool yymm = false;

  if (1 <= aa && aa <= 12) {
    mmyy = true;
  }
  if (1 <= bb && bb <= 12) {
    yymm = true;
  }

  if (mmyy && yymm) cout << "AMBIGUOUS\n";
  else if (mmyy) cout << "MMYY\n";
  else if (yymm) cout << "YYMM\n";
  else cout << "NA\n";

  return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int s,w;
    cin >> s >> w;
    if(w>=s){
        cout << "unsafe" << endl;
    }else{
        cout << "safe" << endl;
    }

    return 0;
}

Measured memory_bytes: 3604
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<map>
#include<iomanip>
#include<tuple>
#include<bitset>


using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define printfloat(x) cout << fixed << setprecision(7) << (x) << endl;
#define printbit(x) cout << bitset<15>(x) << endl;
using ll = long long int;



long double pi = 3.14159265359;

int n,k;
int h;
int ans =0;
int main(){
    cin >> n >> k;
    rep(i,n){
        cin >> h;
        if(h >= k) ans++;
    }
    cout << ans << endl;



return 0;
}

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

#define MOD 1000000007

int main()
{
    long long n,k;
    cin >> n >> k;

    long long ans = 0;
    for (long long i = k; i <= n + 1; i++)
    {
        //cout << i * (n - i + 1) + 1 << endl;
        ans += i * (n - i + 1) + 1;
        ans %= MOD;
    }

    cout << ans << endl;
}

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

int cnt[26];
signed main() {
	string s; cin >> s;
	int ans = 0;
	for (int i = s.size() - 1; i >= 0; i--) {
		ans += cnt[s[i] - 'a'];
		cnt[s[i] - 'a']++;
	}
	cout << s.size()*(s.size() - 1) / 2 - ans+1 << endl;
	/*int ans = 1;
	map<string, int>mp;

	mp[s]++;
	rep(i, s.size()) {
		for (int j = i + 1; j < s.size(); j++) {
			string t = s.substr(i, j - i + 1);
			string u = t; reverse(u.begin(), u.end());
			string tt = s.substr(0, i) + u + s.substr(j + 1, s.size());
			mp[tt]++;
			if (u == t) {
				//cout << t << endl;
				
			}
			else ans++;
		}
	}
	for (auto p : mp) {
		cout << p.first << ' ' << p.second << endl;
	}
	cout << ans << endl;*/

}

Measured memory_bytes: 640
import collections

n = int(input())
s = []
for i in range(n):
  s_ = sorted(input())
  s.append(s_[0]+s_[1]+s_[2]+s_[3]+s_[4]+s_[5]+s_[6]+s_[7]+s_[8]+s_[9])

c = collections.Counter(s)
count = 0

for i in c:
  if c[i] != 1:
    count += c[i]*(c[i]-1)/2

print(int(count))

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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}

const int N_MAX = 100010;
ll dp[N_MAX][2];

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

    // input
    ll N;
    cin >> N;

    vector<ll> A(N);
    FOR(i, 0, N){
        cin >> A.at(i);
    }

    // 累積GCD left
    vector<ll> L(N);
    ll g = A[0];
    L[0] = g;
    FOR(i, 1, N){
        g = gcd(g, A[i]);
        L[i] = g;
    }

    // 累積GCD right
    vector<ll> R(N);
    g = A[N-1];
    R[N-1] = g;
    for(int i=N-2; i>=0; i--){
        g = gcd(g, A[i]);
        R[i] = g;
    }

    ll ma = 0;
    FOR(i, 0, N){
        if(i==0){
            g = R[1];
        }
        else if(i==N-1){
            g = L[N-2];
        }
        else{
            g = gcd(L[i-1], R[i+1]);
        }

        ma = max(ma, g);
    }

    p(ma);

    return 0;
}

Measured memory_bytes: 2560
import java.io.IOException;

import java.io.BufferedReader;
import java.io.InputStreamReader;

@SuppressWarnings("unchecked")
public class Main {
    public static void main(String[] args) throws IOException {
        final String s;
        final String t;

        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            s = reader.readLine();
            t = reader.readLine();
        }

        final String[] sl = s.split(" ");
        double N = Integer.parseInt(sl[0]);
        double K = Integer.parseInt(sl[1]);

        System.out.println((int)Math.ceil((N - 1) / (K - 1)));
    }
}


Measured memory_bytes: 27820
package main

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

var P, Q, R int
var ans int

func Input(){
	P = NextInt()
	Q = NextInt()
	R = NextInt()
}

func Solve(){
	a := []int{P, Q, R}
	Sort(a)
	ans = a[0] + a[1]
}

func Output(){
	fmt.Println(ans)
}

func main() {
	Initialize()
	for {
		Input()
		Solve()
		Output()
	}
}

// Initilize ===================
var io *IO;
func Initialize(){
	io = NewIO()
}
// IO ====================

type IO struct{
	sc *bufio.Scanner
}
func NewIO() *IO {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return &IO{
		sc: sc,
	}
}
func Next() string{
	ok := io.sc.Scan()
	if !ok {
		os.Exit(0)
	}
	return io.sc.Text()
}
func NextInt() int {
	s := Next()
	a, err:= strconv.Atoi(s)
	if err != nil {
		print(err)
	}
	return a
}
// =============
func Sort( a[]int){
	sort.Ints(a)
}
func Min(nums ...int) int {
	ret := int(nums[0])
	for _, n := range nums {
		if n < ret {
			ret = n
		}
	}
	return ret
}
func Max(nums ...int) int {
	ret := int(nums[0])
	for _, n := range nums {
		if n > ret {
			ret = n
		}
	}
	return ret
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;

#define ll long long int
#define str string
#define ALL(a)  (a).begin(),(a).end()
#define P pair<ll,ll>

using Graph = vector<vector<int>>;

const int dy[] = { 0, 0, 1, -1 }, dx[] = { 1, -1, 0, 0 };
ll INFL = 1ll << 60, INF = 1 << 30, mod = 1e9 + 7, Min = INFL, Max = -1;
ll a, b, c, n, sum, A[500010], B[500000], rui[500000], dp[5000];
str S; bool check = true;	vector<ll> v;



int main() {
	//Code Line
	cin >> a >> b >> n;

	if (a >= n)cout << a - n << ' ' << b << endl;
	else {
		n -= a;
		cout << 0 << ' ' << max((ll)0,b - n) << endl;
	}

	return 0;
}


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

bool notPrime[100001];
int C[100005];
const int MAX_N=100000;



void prec()
{
    for(int i=2;i<=MAX_N;i++){
        if(notPrime[i])continue;
    //prime.push_back(i);
    for(int j=i+i;j<=MAX_N;j+=i)
        notPrime[j]=true;
    }
    for(int i=3;i<=MAX_N;i++){
        if(!notPrime[i]&&!notPrime[(i+2)/2]) C[i]=C[i-1]+1;
        else C[i]=C[i-1];
    }
}





int main()
{
    prec();
    int q;
    cin>>q;
    while(q--){
        int L,R;
        cin>>L>>R;
        cout<<C[R]-C[L-1]<<'\n';

    }



}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    lint n, k;
    cin >> n >> k;
    int ret = 0;
    while (n) {
        ret++;
        n /= k;
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#define rep(i,n) for(int i = 0;i < (n);i++)
using namespace std;
int main(void){
     string s,t;
     cin >> s;
     cin >> t;
     int ans = t.size();
     rep(i,s.size() - t.size() + 1){
           int temp = 0;
           rep(j,t.size()){
                 if(s[i + j] != t[j])temp++;
           }
           ans = min(ans,temp);
     }
     cout << ans << endl;
}


Measured memory_bytes: 3608
#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 fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int long long 
#define rep(i,n) for(int i=0;i<n;i++)
#define repa(i,arr,n) for(int i=arr;i<=n;i++)
#define repd(i,arr,n) for(int i=arr;i>=n;i--)
#define trav(arr,x) for(auto& arr:x)
#define all(c) c.begin(), c.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(arr) arr.size()
#define pi 3.14159265358979323846
#define MAX (1000*1000*1000+7)
#define vi vector<int>
#define pii pair<int,int>
#define pqueue priority_queue<int>
#define pdqueue priority_queue<int,vi,greater<int> >
//#define endl "\n"
 
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
 
const int mod=1e10+7;
int power(int a,int b)
{
    int ans=1;
    while(b)
    {
        if(b&1)
        {
            ans=(ans*a)%mod;
        }
        a=(a*a)%mod;
        b>>=1;
    }
    return ans;
}

int32_t main()
{
    fast;

    int n,m,x,y,ans=0,val;
    cin>>n>>m;

    vi v;

    vi mx(n+2,0);

    rep(i,n)
    {
        cin>>val;
        v.pb(val);
    }

    rep(i,m)
    {
        cin>>x>>y;

        mx[x-1]=max(mx[x-1],v[y-1]);
        mx[y-1]=max(mx[y-1],v[x-1]);
    }

    rep(i,n)
    {
        
        if(mx[i]<v[i]) ans++;
    }
    cout<<ans<<endl;
}

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

class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int[] A = new int[N];
		for (int i = 0; i < N; i++) {
			A[i] = scanner.nextInt();
		}

		Arrays.sort(A);

		boolean flag = false;
		for (int i = 0; i < N - 1; i++) {
			if (A[i] == A[i + 1]) {
				flag = true;
				break;
			}
		}

		if (flag) {
			System.out.println("NO");
		}
		else {
			System.out.println("YES");
		}
	}
}

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

int main() {
    int A, B, C, X;
    cin >> A >> B >> C >> X;

    int res = 0;
    for (int i = 0; i <= A; i++) {
        for (int j = 0; j <= B; j++) {
            for (int k = 0; k <= C; k++) {
                int money = 500 * i + 100 * j + 50 * k;
                if (X == money) res++;
            }
        }
    }
    cout << res << endl;
}

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

int main(){
    double pi = 3.141592653589;
    double r;
    cin >> r;
    
    cout << fixed << setprecision(6) << r*r*pi << " " << setprecision(6) << 2*pi*r << endl;
    return 0;
    
}




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

int main()
{
  int A, B, ans = 0;
  cin >> A >> B;

  for (int i = 0; i < 2; i++) {
    ans += max(A, B);
    if (A == max(A, B)) {
      A--;
    } else {
      B--;
    }
  }

  cout << ans << endl;
}


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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int N;
    Scd(N);

    vi p(N);
    vi q(N);
    vi r(N);
    Rep(i,N) Scd(p[i]);
    Rep(i,N) Scd(q[i]);
    Rep(i,N) r[i] = i+1;

    int a,b,c=0;

    do{
        Rep(i,N+1) if( i == N ) a = c; else if( r[i] != p[i] ) break;
        Rep(i,N+1) if( i == N ) b = c; else if( r[i] != q[i] ) break;
        c++;
    }while ( next_permutation(r.begin(), r.end()) );

    printf ("%d\n", abs(a-b) );

    return 0;
}



Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int K = sc.nextInt();

		int move =0;
		for (int i=0; i<N; i++){
			int x = sc.nextInt();
			move += 2 *(Math.min(x, K - x));
		}
		System.out.println(move);
	}
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef pair<long long, long long> pLL;
typedef long long ll;
int MOD = 1000000007;
int main(){
  int A,B,T;
  cin >> A >> B >> T;
  int t = 0;
  int ans = 0;
  while(t + A <= T+0.5){
    ans += B;
    t += A;
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MAX 3000
int dp[MAX+1][MAX+1];
int lenLCS(string& s, string& t, int i, int j)
{
  if(i>=s.length() || j>=t.length())
    return 0;
  if(dp[i][j]!=-1)
    return dp[i][j];
  if(s[i]==t[j])
    return dp[i][j]=1+lenLCS(s,t,i+1,j+1);
  else{
    return dp[i][j]=max(lenLCS(s,t,i+1,j),lenLCS(s,t,i,j+1));
  }
}
string lcs(string& s, string& t, int len){
  string lcsS="";
  int i=0,j=0;
  while(len>0){
    if(s[i]==t[j]){
      lcsS+=s[i];
      i++;
      j++;
      len--;
    }
    else{
      if(dp[i+1][j]>dp[i][j+1])
        i++;
      else j++;
    }
  }
   return lcsS;
}
int main()
{
  string s,t;
  cin>>s>>t;
  memset(dp,-1,sizeof dp);
  int len=lenLCS(s,t,0,0);
  cout<<lcs(s,t,len);
  return 0;
}


Measured memory_bytes: 39280
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};

int main(void){
    int N;
    cin >> N;
    int A[N];
    rep(i,N) cin >> A[i];
    int min=INF;
    int ans=0;
    rep(i,N){
        if(A[i]<=min) ans++,min=A[i];
    }
    cout << ans << endl;
}

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

int main() {
  long long A,B,C,D,taka,ao;
  cin >> A >> B >> C >> D;
  if (C%B==0) {taka=C/B;} else {taka=C/B+1;}
  if (A%D==0) {ao=A/D;} else {ao=A/D+1;}
  if (taka<=ao) {cout << "Yes" << endl;} else {cout << "No" << endl;}
}

Measured memory_bytes: 3596
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;

// typedef
typedef long long ll;
typedef unsigned long ul;
// #define int long long

// macro
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define DESCEND greater<int>()  // sort 降順 大きい順
#define UNIQUE(vec) (vec).erase(unique(ALL((vec))), (vec).end());  // 必ずsortを行なってから
#define MIN(vec) min_element(ALL((vec)))  // 値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
#define zero_pad(num) setfill('0') << std::right << setw(num)  // 直後の要素をパディング
#define space_pad(num) setfill(' ') << std::right << setw(num)  // 直後の要素をパディング

// func declaration
template <class T> void print2DVec(vector< vector<T> >&);
template <class T> void calcVec(vector<T>&, int, char);
int char_to_int(const char);

// const
const int INF = 10000000;

/*MEMO
・辞書順
abc < abcd, atcoder < atlas
・イテレータ
std::vector<int>::iterator とタイプするのは面倒なので、
 通常は型推論の auto を使用する。
 auto iter = max_element(ALL(vec));
・2次元配列
vector<vector<int>> vec = {{1, 2, 3}, {4, 5, 6}}
・20×10の配列
vector<vector<int>> vec(20, vector<int>(10, 0));
・(n, m)の多次元配列
vector< vector<int> > vec(n, vector<int>(m, 0))  // 0で初期化
*/

int main() {
    cin.tie();
    ios::sync_with_stdio(false);
    
    // input
    int X, t, rest;
    cin >> X >> t;
    rest = (X - t >= 0) ? X - t: 0;
    cout << rest << "\n";
    
    return 0;
}


// function
template <class T> void print2DVec(vector< vector<T> >& vec) {
    REP(i, vec.size()) {
        REP(j, vec.front().size()) {
            cout << vec.at(i).at(j);
        }
        cout << endl;
    }
}

template <class T> void calcVec(vector<T> &vec, int num, char ch) {
    // vec全体への演算
    switch (ch) {
        case '+':
            REP(i, vec.size()) vec.at(i) += num; break;
        case '-':
            REP(i, vec.size()) vec.at(i) -= num; break;
        case '*':
            REP(i, vec.size()) vec.at(i) *= num; break;
        case '/':
            REP(i, vec.size()) vec.at(i) /= num; break;
        case '%':
            REP(i, vec.size()) vec.at(i) %= num; break;
        default:
            cout << "Incorrect Operator" << endl;
    }
}

int char_to_int(const char c) {
    if('0' <= c && c <= '9') return (c - '0');
    return -1;
}


Measured memory_bytes: 384
#include <stdio.h>

int main(){
	int N, i;
	scanf("%d", &N);
	for(i = 1; (i * (i + 1)) / 2 < N; i++);
	for(i = i; N > 0; i--){
		if(i <= N){
			printf("%d\n", i);
			N -= i;
		}
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

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

    ll A,B,C; cin >> A >> B >> C;

    if(B <= C) {
        cout << 2*B + min(A+1, C-B) << endl;
    }
    else {
        cout << B + C << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<60)           //1LL<<63でオーバーフロー
#define inf (1<<29)             //1<<29でオーバーフロー

int main(int argc,char* argv[]){
    string s;
    cin >> s;

    set<char> c;
    bool ans=true;
    for(int i=0;i<s.size();i++){
        if(c.count(s[i])){
            ans=false;
            break;
        }
        c.insert(s[i]);
    }

    if(ans)cout << "yes" << endl;
    else cout << "no" << endl;

    return 0;
}


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

int main() {
  int N, D, X, a;
  cin >> N >> D >> X;
  rep(i, 0, N) {
    cin >> a;
    // 切り上げ
    int b = (D + (a - 1)) / a;
    X += b;
  }

  cout << X << endl;

  return 0;
}


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

ll n,q,a,b,value[200005]={};
bool flag[200005]={};
vector<ll>v[200005];
stack<ll>S;
void DFS(ll V)
{
	S.push(V);
	flag[V]=true;
	while(!S.empty())
	{
		ll p=S.top();
		bool flag1=true;
		for(ll i=0;i<v[p].size();i++)
		{
			if(v[p][i]==p)continue;
			if(!flag[v[p][i]])
			{
				S.push(v[p][i]);
				value[v[p][i]]+=value[p];
				flag1=false;
			}
			flag[v[p][i]]=true;
		}
		if(flag1)S.pop();
	}
}

int main()
{	
	cin>>n>>q;
	for(ll i=0;i<n-1;i++)
	{
		cin>>a>>b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	for(ll i=0;i<q;i++)
	{
		cin>>a>>b;
		value[a]+=b;
	}
	DFS(1);
	for(ll i=1;i<=n;i++)
	{
		if(i==1)cout<<value[i];
		else cout<<" "<<value[i];
	}
	cout<<endl;
	return 0;	
}

Measured memory_bytes: 18032
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define PA pair<ll,ll>
const int mod = 1000000007;
vector<PA >a[110];
ll f[110];
int Q;
void init()
{
	a[1].push_back(PA(1,1));
	f[0]=f[1]=1;
	for(int i=2;i<=90;i++)
		f[i]=f[i-1]+f[i-2];
	for(int i=2;i<90;i++)
	{
		a[i].push_back(PA(f[i-1],f[i]));
		a[i].push_back(PA(f[i-1],f[i+1]));
		for(int j=1;j<a[i-1].size();j++)
		{
			PA t=a[i-1][j];
			a[i].push_back(PA(t.second,t.first+t.second));
		}
	}
}
int main()
{
	//freopen("tt.in","r",stdin);
	init();
	scanf("%d",&Q);
	while(Q--)
	{
		ll x,y,ans=0;
		scanf("%lld%lld",&x,&y);
		if(x>y)swap(x,y);
		if(x==1)
		{
			printf("1 %lld\n",y%mod);
			continue;
		}
		if(x==2&&y==2)
		{
			puts("1 4");
			continue;
		}
		int k=upper_bound(f+1,f+90+1,x)-f;
		k=min(k,(int)(upper_bound(f+1,f+90+1,y)-f-1));
		
		for(int i=0;i<a[k-1].size();i++)
		{
			PA t=a[k-1][i];
			if(t.second<=x)
			{
				ans+=(y-t.first)/t.second;
				ans+=(x-t.first)/t.second;
			}
		}
		printf("%d %lld\n",k-1,ans%mod);
	}
	return 0;
}


Measured memory_bytes: 4096
def main():
    N, P = map(int, input().split())
    *A, = map(int, input().split())

    editorial(N, P, A)

def editorial(N, P, A):
    odds = [a for a in A if a % 2 == 1]
    odd = len(odds)
    even = N - odd

    if odd == 0:
        if P == 1:
            print(0)
        else:
            print(2 ** N)
        return
    
    # ある奇数袋を取り除いて、残りでの組み合わせ(選ぶ選ばないの2通りがN-1)
    ans = 2 ** (N - 1)
    # s = 組み合わせのビスケット枚数
    # P=0,s:奇数であるとき、加えるのは1通り
    # P=0,s:奇数でないとき、加えないのは1通り
    # P=1,s:奇数であるとき、加えないのは１通り
    # P=1,s:奇数でないとき、加えるのは1通り
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		String S = stdIn.next();
		char[] c = S.toCharArray();
		
		if(c[0] == c[1] && c[2] == c[3] && c[1] != c[2]) {
			System.out.println("Yes");
		}
		else if(c[0] == c[2] && c[1] == c[3] && c[1] != c[2]) {
			System.out.println("Yes");
		}
		else if(c[0] == c[3] && c[1] == c[2] && c[0] != c[1]) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}

	}

}

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

using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define endl "\n"
#define f first
#define s second
#define ar array
#define pb push_back
#define sz(X) ((int)(X).size())
#define pcnt __builtin_popcount
#define sort_unique(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define get_pos(c, x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define all(X) (X).begin(), (X).end()
#define ms(c, x)  memset(c,x,sizeof c)
#define  No(x) cout<<(x?"NO":"No")<<endl;
#define  Yes(x) cout<<(x?"YES":"No")<<endl;
#define  nl cout<<endl;
template<typename T>
using osl=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T>
using osg=tree<T, null_type, greater<T>, rb_tree_tag, tree_order_statistics_node_update>;

// for greater use greater<T>
template<typename T>
ostream &operator+(ostream &out, const vector<T> &vec) {
    for (const auto &x : vec) {
        out << x << " ";
    }
    out << "\n";
    return out;
}

template<typename T>
ostream &operator*(ostream &out, const vector<T> &vec) {
    for (const auto &x : vec) {
        out + x;
    }
    return out;
}

template<typename T>
istream &operator>>(istream &in, vector<T> &vec) {
    for (auto &x : vec) {
        in >> x;
    }
    return in;
}

template<class T>
bool ckmin(T &a, const T &b) { return b < a ? a = b, 1 : 0; }

template<class T>
bool ckmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

#ifdef LOCAL

void debug() { cerr << endl; }

template<class T, class... Args>
void debug(const T &t, const Args &... args) {
    cerr << t << " ";
    debug(args...);
}

#define dbg(...) {cerr<<__LINE__<<" [[DEBUG]] ";debug(__VA_ARGS__);};
#else
#define dbg(...) void(0)
#endif
const int mod = 1e9 + 7;
const int mod2 = 998244353;
const ll INF = 1e9 + 6;

ll add(ll a, ll b) {
    a += b;
    return a % mod;
}

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

inline ll power(ll x, ll y, ll p) {
    ll res = 1;
    x = x % p;
    while (y > 0) {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}

inline ll modInverse(ll x, ll p) {
    return power(x, p - 2, p);
}

const int MXN = 1e5 + 5;
void solve() {
    string s;
    cin>>s;
    if(s[sz(s)-1]=='s'){
        cout<<s<<"es"<<endl;
    }
    else{
        cout<<s<<"s"<<endl;
    }

}

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t = 1, tc = 1;
    //cin >> t;
    while (t--) {
        // cout<<"Case #"<<tc<<": " ;
        solve();
        tc++;
    }
#ifdef LOCAL
    cerr << endl << "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
#endif
    return 0;
}
//look if it requires ll

Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
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; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
  int a,b;
  cin >> a >> b;
  int ans = 0;
  chmax(ans,a+a-1);
  chmax(ans,a+b);
  chmax(ans,b+b-1);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

main() {
  int64_t a, b, c;
  cin >> a >> b >> c;

  if (c >= a && c <= b) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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

using namespace std;
vector<int> a;
int main() {
    for(int i = 1;i < 40000;i++) {
        a.push_back(i*i);
    }
    int n;cin>>n;
    int t = upper_bound(a.begin(),a.end(),n)-a.begin();
    cout<<a[t-1]<<endl;
    return 0;
}


Measured memory_bytes: 640