akhauriyash/Code-Regression huggingface dataset:
use warnings;
use strict;
use utf8;

chomp(my $line = <STDIN>);
my($n, $m) = split / /, $line;
chomp(my @students = <STDIN>);
my @points = splice @students, $n;

foreach my $s (1..$n){
    my $ans = 1;
    my $min_dist = 2**31 - 1;
    foreach my $p (1..$m){
        my ($sx, $sy) = split / /, $students[$s - 1];
        my ($px, $py) = split / /, $points[$p - 1];
        my $dist = abs($sx - $px) + abs($sy - $py);
        if ($dist < $min_dist){
            $min_dist = $dist;
            $ans = $p;
        }
    }
    print "$ans\n"
}

Measured memory_bytes: 640
// #pragma GCC target("avx2")
#pragma GCC optimize("O3", "unroll-loops")

// #include <bits/extc++.h>
// using namespace __gnu_pbds;

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define double long double
// template <typename T>
// using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using pii = pair<int, int>;
template<typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using Prior = priority_queue<T>;

#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back

#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define RANDOM() random_device __rd; \
                 mt19937 __gen = mt19937(__rd()); \
                 uniform_int_distribution<int> __dis(1, 1E8); \
                 auto rnd = bind(__dis, __gen)

const int INF = 1E18;
const int mod = 1E9 + 7;

int32_t main() {
    fastIO();
    
    int n;
    cin >> n;
    
    int lstA, lstB, lstC, A, B, C;
    cin >> lstA >> lstB >> lstC;
    for (int i = 1; i < n; ++i) {
        cin >> A >> B >> C;
        A += max(lstB, lstC);
        B += max(lstA, lstC);
        C += max(lstA, lstB);
        lstA = A, lstB = B, lstC = C;
    }
    
    cout << max({lstA, lstB, lstC}) << "\n";
    
    return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<algorithm>
#include<climits>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define scan(arg) cin>>arg
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
using namespace std;
typedef long long ll;
int h,w;
int n;
int a[100000];
int main(){
  cin>>h>>w>>n;
  rep(i,n){
    cin>>a[i];
  }
  int c[110][110];
  int num=1;
  rep(i,h){
    int j=0;
    if(i%2==0){
      while(j<w){
	if(w-j-1>=a[num-1]){
	  rep(k,a[num-1]){
	    c[i][k+j]=num;
	  }
	  j+=a[num-1];
	  num++;
	}
	else{
	  rep(k,w-j){
	    c[i][k+j]=num;
	  }
	  a[num-1]-=w-j;
	  j=w;
	}
      }
    }
    else{
      j=w-1;
      while(j>=0){
	if(j+1>=a[num-1]){
	  rep(k,a[num-1]){
	    c[i][j-k]=num;
	  }
	  j-=a[num-1];
	  num++;
	}
	else{
	  rep(k,j+1){
	    c[i][j-k]=num;
	  }
	  a[num-1]-=j+1;
	  j=-1;
	}
      }
    }
  }
  rep(i,h){
    rep(j,w){
      cout<<c[i][j]<<" ";
    }
    cout<<"\n";
  }

  
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x)  cout << #x << " = " << (x) << endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  int n; cin >> n;
  int a[n+2];
  a[0] = 0; a[n+1] = 0;
  REP(i,n) cin >> a[i+1];

  ll s = 0;
  REP(i,n+1) s+=abs(a[i] - a[i+1]);

  for (int i = 1; i <= n; i++) {
    ll ans = s;
    ans += abs(a[i-1] - a[i+1]) - (abs(a[i-1] - a[i]) + abs(a[i] - a[i+1]));
    COUT(ans);
  }
  return 0;
}


Measured memory_bytes: 1664
program main
 implicit none
 integer*8 N,K,Q,ind,i
 integer*8,allocatable::A(:)
 read(*,*) N,K,Q
 allocate(A(1:N))
 A = 0
 do i=1,Q
  read(*,*) ind
  A(ind) = A(ind) + 1
 end do
 
 do i=1,N
  if(Q-A(i) < K) then
   write(*,*) 'Yes'
  else
   write(*,*) 'No'
  end if
 end do
end program main

Measured memory_bytes: 1536
#include<stdio.h>
#include<algorithm>
using namespace std;
double dp[20][1<<16];
double c[20][20];
int m,n;
double solve(int a,int b){
	if(dp[a][b]>-0.5)return dp[a][b];
	if(a==n)return 1;
	if(b==0)return 0;
	double ret=0;
	for(int i=0;i<m;i++){
		if(b&(1<<i)){
			double val=0;
			double ks=1;
			for(int j=a;j<n;j++){
				val+=ks*(1.0-c[i][j])*solve(j,b-(1<<i));
				ks*=c[i][j];
			}
			val+=ks;
			ret=max(ret,val);
		//	ret=max(ret,c[i][a]*solve(a+1,b)+(1.0-c[i][a])*solve(a,b-(1<<i)));
		}
	}
	return dp[a][b]=ret;
}
int main(){
	int a,b;scanf("%d%d",&a,&b);
	m=a;n=b;
	for(int i=0;i<a;i++)for(int j=0;j<b;j++)scanf("%lf",&c[i][j]);
	for(int i=0;i<=b;i++)for(int j=0;j<(1<<a);j++)dp[i][j]=-1;
	printf("%.12f\n",solve(0,(1<<a)-1));
}

Measured memory_bytes: 11304
//二色問題
#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 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)
typedef long long int64;
const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
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; }

using Graph = vector<vector<int>>;

// 二部グラフ判定
vector<int> color;
bool dfs(const Graph &G, int v, int cur = 0) {
    color[v] = cur;
    for (auto next_v : G[v]) {
        if (color[next_v] != -1) {
            if (color[next_v] == cur) return false; // 同じ色が隣接したらダメ
            continue;
        }
        if (!dfs(G, next_v , 1 - cur)) return false;
    }
    return true;
}

//AGC039Bでverify

int main() {
    // 頂点数と辺数
    ll N, M; cin >> N >> M;

    // グラフ入力受取
    Graph G(N);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b; a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    // 探索
    color.assign(N, -1);
    bool is_bipartite = true;
    for (int v = 0; v < N; ++v) {
        if (color[v] != -1) continue; // v が探索済みだったらスルー
        if (!dfs(G, v)) is_bipartite = false;
    }
    ll ans;
    if (is_bipartite) {
        ll B = count(all(color), 0);
        ll W = N - B;
        ans = B * W - M;
    }
    else ans = (N-1) * N / 2 - M;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O0")
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define Rep(i,a,n) for (ll i = (a); i < (n); ++i)
const ll mod = 1e9+7;
const ll INF = 1e18;
#define All(a) (a).begin(),(a).end()
#define Pi acos(-1)
using Graph = vector<vector<ll>>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  chrono::system_clock::time_point start,end;
  start = chrono::system_clock::now();

  ll n, d;
  cin >> n >> d;
  ll ans = 0;
  d *= d;
  rep(i,n) {
    ll a, b;
    cin >> a >> b;
    if (a*a + b*b <= d) ++ans;
  }
  cout << ans << '\n';

  end = chrono::system_clock::now();
  auto elapsed = chrono::duration_cast< chrono::milliseconds >(end - start).count();
  cerr << elapsed << "ms" << '\n';
}

Measured memory_bytes: 3660
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
        int b = sc.nextInt();
        for (int i=0;i<b;i++){a-=sc.nextInt();}
		String s = "Yes";
        if(a>0){s = "No";}
		System.out.println(s);
	}
}


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

int main() {
  int N;
  int AC, WA, TLE, RE;
  AC = 0;
  WA = 0;
  TLE = 0;
  RE = 0;
  
  cin >> N;
  string S[N];
  for(int i = 0; i < N; i++){
    cin >> S[i];
  }
  
  for(int i = 0; i < N; i++){
    if(S[i] == "AC"){
      AC += 1;
    }else if(S[i] == "WA"){
      WA += 1;
    }
    else if(S[i] == "TLE"){
      TLE += 1;
    }
    else if(S[i] == "RE"){
      RE += 1;
    }
  }
  
  cout << "AC x "<< AC << endl;
  cout << "WA x "<< WA << endl;
  cout << "TLE x "<< TLE << endl;
  cout << "RE x "<< RE << endl;
  
 }
    
  
 

Measured memory_bytes: 6720
N, K = [int(a) for a in input().split()]
numbers = list(range(0, N+1))
MOD = 1000000007

ans = 0
for k in range(K, N+2):
    min_ = (numbers[0] + numbers[k-1])*k//2
    max_ = (numbers[(N+1)-k] + numbers[-1])*k//2
    ans = (ans + max_ - min_ + 1) % MOD

print(ans)


Measured memory_bytes: 16592
def main():
    q = int(input())
    # 1~10**5 Eratosthenes
    ma = 10**5+1
    prime = [1]*ma # 1:prime 0:not prime
    prime[0],prime[1] = 0,0
    for i in range(2,ma):
        if prime[i] == 0:
            continue
        for j in range(i*2,ma,i):
            prime[j] = 0

    # like 2017
    like = [0]*ma # 1:like 0:not like
    for i in range(ma):
        if i%2 == 0: #odd only 
            continue
        if prime[i] == 1 and prime[(i+1)//2] == 1:
            like[i] = 1

    # ruiseki
    rui = [0]*(ma+1)
    for i in range(ma):
        rui[i+1] = rui[i]+like[i]

    # Query
    for _ in range(q):
        l,r = map(int,input().split())
        print(rui[r+1]-rui[l])

if __name__ == '__main__':
    main()


Measured memory_bytes: 54588
#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>

using namespace std;

//Nayeem Shahriar Joy,Applied Physics And Electronic Engineering,University of Rajshahi.




int main(void)

{
    vector<int>p;
    int a,b,c;
    cin>>a>>b>>c;
    p.push_back(a);
    p.push_back(b);
    p.push_back(c);
    sort(p.begin(),p.end());
    sort(p.begin(),p.end());
    cout<<p[0]<<" "<<p[1]<<" "<<p[2]<<endl;
}

Measured memory_bytes: 3140
#include <iostream>
#include <vector>
#include <string>
using namespace std;
 
int main()
{
	int h, w, k;
	cin >> h >> w >> k;
	auto c = vector<string>(h);
	int all = 0;
	for(int i = 0; i < h; ++i){
		cin >> c[i];
	}
	int ans = 0;
	for(int y = 0; y < (1 << h); ++y){
		for(int x = 0; x < (1 << w); ++x){
			int cnt = 0;
			for(int i = 0; i < h; ++i){
				if(y & (1 << i)) continue;
				for(int j = 0; j < w; ++j){
					if(x & (1 << j)) continue;
					if(c[i][j] == '#') ++cnt;
				}
			}
			if(cnt == k) ++ans;
		}
	}
 
	cout << ans << endl;
 
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int n, m;
  cin >> n >> m;
  vector<vi32> a(n, vi32(m));
  cin >> a;
  rep(i, n) rep(j, m) {
    a[i][j]--;
  }
  int ans = n;
  rep(i, m - 1) {
    vi32 cnt(m);
    rep(j, n) rep(k, m) {
      if (a[j][k] != 1e9) {
        cnt[a[j][k]]++;
        break;
      }
    }
    int ma = -1;
    int ma_m = -1;
    rep(i, m) {
      if (ma < cnt[i]) {
        ma = cnt[i];
        ma_m = i;
      }
    }
    amin(ans, ma);
    rep(j, n) rep(k, m) {
      if (a[j][k] == ma_m) {
        a[j][k] = 1e9;
        break;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
int F[2100010];

int Mul(int a, int b) {
	return ((a % mod) * (b % mod)) % mod;
}

void fact(void) {
	F[0] = 1;
	F[1] = 1;
	for (int i = 2; i <= 2100000; i++) {
		F[i] = Mul(i, F[i - 1]);
	}
}
int square(int x) {
	return (x * x) % mod;
}

int power(int x, int y) {
	if (y == 0) return 1;
	else if (y == 1) return x % mod;
	else if (y % 2 == 0) return square(power(x, y / 2)) % mod;
	else return square(power(x, y / 2)) * x % mod;
}

int Div(int a, int b) {
	return Mul(a, power(b, mod - 2));
}
int P(int n, int r) {
	if (n < r || n < 0 || r < 0) return 0;
	return Div(F[n], F[n - r]);
}

int C(int n, int r) {
	if (n < r || n < 0 || r < 0) return 0;
	int ret;
	ret = Div(F[n], Mul(F[n - r], F[r]));
	return ret;
}
int H(int n, int r) {
	if (n == 0 && r == 0) return 1;
	return C(n + r - 1, r);
}
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    fact();
    int A[100010];
    rep(i, N) cin >> A[i];
    int min_a = 0;
    int max_a = 0;
    sort(A, A + N);
    int P = 1;
    rep(i, N) {
        min_a = (min_a + Mul(A[i] + mod,         Mul(P, Div(K, N - i)))) % mod;
        //cout << Mul(min_a, C(N, K))<< endl;
        max_a = (max_a + Mul(A[N - i - 1] + mod, Mul(P, Div(K, N - i)))) % mod;
        //cout << Mul(max_a, C(N, K))<< endl;
        P = Mul(P, 1 - Div(K, N - i) + mod);
        if (P == 0) break;
    }
    cout << Mul(max_a - min_a + mod, C(N, K)) << endl;

    

    return 0;
}


Measured memory_bytes: 17408
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cmath>
#include <complex>
#include <cctype>
#include <cassert>
#include <sstream>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

#define INF (1<<29)
#define INFL (1ll<<60)
#define EPS (1e-8)
#define PI (acos(-1))
#define MOD 1000000007ll

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

typedef long long ll;
typedef complex<double> P;
typedef complex<double> Vec;
typedef pair<int, int> pii;
typedef pair<int, pii> p;

int n;
int a[112345];
int cnt[112345];

int main() {
	cin >> n;
	REP(i, n) {
		scanf("%d", a + i);
		a[i]--;
		cnt[a[i]]++;
	}
	
	int kcnt = 0, gcnt = 0;
	REP(i, 100000) {
		if (cnt[i] == 0) continue;
		if (cnt[i] & 1) kcnt++;
		else gcnt++;
	}
	
	int ans = gcnt + kcnt;
	if (gcnt & 1) ans--;
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define print(x) cout<<(x)<<endl
#define INF10 1001001001 
#define INF5 100000
#define EPS 1e-10

int W, H, x, y;


int main() {
	cin >> W >> H >> x >> y;

	double ans = (double)W * (double)H / (double)2;


	cout << fixed << setprecision(10) << ans << " ";


	if (x * 2 == W && y * 2 == H) {
		cout << 1 << endl;
	}
	else cout << 0 << endl;





	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>

void solve() {
    int n;
    std::string s;
    std::cin >> n >> s;

    std::vector<int> wfsum(n + 2, 0), rbsum(n + 2, 0);
    for (int i = 1; i <= n; ++i) {
        wfsum[i] = wfsum[i - 1] + (s[i - 1] == 'W');
    }
    for (int i = n; i >= 1; --i) {
        rbsum[i] = rbsum[i + 1] + (s[i - 1] == 'R');
    }

    int ans = n;
    for (int i = 0; i <= n; ++i) {
        int w = wfsum[i], r = rbsum[i + 1];
        ans = std::min(ans, w + r - std::min(w, r));
    }

    std::cout << ans << "\n";
}

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

    solve();

    return 0;
}


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
   ll n;cin >>n;
   ll t,a;cin >>t>>a;
   vector<ll>h(n);
   ll mint=INF;
   ll ans=-1;
    for (int i = 0; i < n; ++i) {
        cin >>h[i];
        ll tmp=abs((1000*t-6*h[i])-1000*a);
        if(tmp<mint){
            ans=i+1;
            mint=tmp;
        }
    }
    cout <<ans<<endl;
   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 100000000000000009
#define int long long
using P = pair<int,int>;
signed main(){
  int n,m;
  cin >> n >> m;
  vint count(n,1);
  vbool judge(n);
  judge[0] = true;
  rep(i,m){
    int x,y;
    cin >> x >> y;
    x--;y--;
    count[x]--;
    count[y]++;
    if(judge[x] == true) judge[y] = true;
    if(count[x] == 0) judge[x] = false;
  }
  int ans = 0;
  rep(i,n){
    if(judge[i] == true) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <cstring>
#include <climits>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <assert.h>
#include <ctime>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>

#define Re register
#define LL long long
#define U unsigned
#define FOR(i,a,b) for(Re int i = a;i <= b;++i)
#define RFOR(i,a,b) for(Re int i = a;i >= b;--i)
#define SFOR(i,a,b,c) for(Re int i = a;i <= b;i+=c)
#define CLR(i,a) memset(i,a,sizeof(i))
#define BR printf("--------------------\n")
#define DEBUG(x) std::cerr << #x << '=' << x << std::endl

const int MAXN = 2000000+5;

char str[MAXN];
int min,ans;

int main(){
	scanf("%s",str+1);
	int len = strlen(str+1);
	if(len <= 3){
		int t = 0;
		FOR(i,1,len) t = (t<<1) + (t<<3) + (str[i]^'0');
		printf("%d\n",std::abs(t-753));
		return 0;
	}min = INT_MAX;
	FOR(i,1,len){
		int j = i + 2;
		if(j > len) break;
		int t = 0;
		FOR(k,i,j) t = (t<<1) + (t<<3) + (str[k]^'0');
		if(min > std::abs(t-753)){
			min = std::abs(t-753);
			ans = t;
		}
	}
	printf("%d\n",min);
	return 0;
} 

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

int n, k;
int a[100000];

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

int main() {
	ios_base::sync_with_stdio(0);
	cin >> n >> k;
	int currGcd = 0;
	int currMx = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		currGcd = gcd(currGcd, a[i]);
		currMx = max(currMx, a[i]);
	}
	
	if (k > currMx || k % currGcd != 0) {
		cout << "IMPOSSIBLE";
	} else {
		cout << "POSSIBLE";
	}
	return 0;
	
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#define debug(x...) cout << #x << " = "; _print(x)
typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll;
#define rep(i,a,b) for (ll i = (a); i < (b); ++i)
#define per(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define mp make_pair 
#define pb push_back
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL) 
const int mod = 1e9 + 7, mxn = 1e5 + 1;

int solve(){
	int n;
	cin>> n;
	vll v(n);
	rep(i, 0, n)
		cin>> v[i];
	ll tot = v[0];
	rep(i, 1, n)
		tot ^= v[i];
	rep(i, 0, n)
		cout<< (ll)(tot^v[i])<< " ";
	return 0;
}
 
int main()
{
    fast;
    int t = 1;
    //cin>> t;
    while(t--){  
        solve();
    }
    return 0;
}
//v.clear(), vis.clear(); vis.resize(n + 1, 0), v.resize(n + 1);
 
/*  inv[1] = 1; // inv is ll
    for(int i=2; i<=mxn; ++i)
        inv[i]=mod-mod/i*inv[mod%i]%mod;*/
        
// lower bound   >=  
// upper bound   >
// vector<int>().swap(vec); //free memory from vec


Measured memory_bytes: 4720
'use strict'

function main(s) {  
  
  // 入力処理
  const input = Number(s.replace(/\n/g, ''));
  const result = new Array(input).fill(0).map((x, i) => i + 1).reduce((a, b) => a + b);
  console.log(result);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

using namespace std;

// Repetitions
#define FOR(i,a,n) for(ll i = ((ll) a); i < ((ll) n); ++i)
#define FORR(i, s, g) for(ll i = ((ll)s - 1); i >= ((ll) g); --i)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) FORR(i, n, 0)

// Container Utils
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define SORTALL(v) sort(ALL(v))
#define SZ(a) int((a).size())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())

// For Debug
#define DMP(x)  cerr << #x << " = " << (x) << endl
#define DBG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

// Aliases
#define PB push_back
#define MP make_pair
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

// I/O Asynchronizing
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;

int main() {
    int n;
    cin >> n;
    vi p(n);
    int j = -1;
    string ans = "YES";
    REP(i, n) {
        cin >> p[i];
        // DBG(i);
        // DBG(p[i]);
        if(j == -1 && i + 1 != p[i]) {
            j = i;
            // DBG("FST");
        }
        else if(i + 1 != p[i] && p[i] == j + 1) {
            ans = "YES";
            // DBG("SND");
        }
        else if(i + 1 != p[i]) {
            ans = "NO";
            // DBG("END");
            break;
        }
    }

    cout << ans << "\n";

    return 0;
}


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


int main(){
  
  long long A, B, X;
  cin >> A >> B >> X;
  
  if(A + B < X || A > X){
    cout << "NO" << endl;
    return 0;
  }
  cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(v) v.begin(), v.end()
#define revall(v) v.rbegin(), v.rend()
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){ if(y<h && y>=0 && x<w && x>=0) return true; return false; }
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; }





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m;cin >> n >> m;
	ll ans = (n - m) * 100LL * pow(2,m) + m * pow(2,m) * 1900LL;
	cout << ans << endl;
}


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

int main() {
  string s;
  string ans = "Good";

  cin >> s;

  for (int i = 0; i < s.size()-1; i++) {
      if (s.at(i) == s.at(i+1)) {
        ans = "Bad";
      }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<long long> Lucas(100);
  Lucas[0] = 2;
  Lucas[1] = 1;
  
  for(int i=2; i<=N; i++){
    Lucas[i] = Lucas[i-2] + Lucas[i-1];
  }
  
  cout << Lucas[N];
}


Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * c.cc: C - Multiplication 3
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

typedef long long ll;

/* global variables */

/* subroutines */

/* main */

int main() {
  ll a;
  char s[8];
  scanf("%lld%s", &a, s);

  ll b0 = 0, b1 = 0;
  char *cpt = s;
  while (*cpt && *cpt != '.') b0 = b0 * 10 + (*(cpt++) - '0');
  if (*cpt == '.') {
    cpt++;
    while (*cpt) b1 = b1 * 10 + (*(cpt++) - '0');
  }
  ll b = b0 * 100 + b1;

  printf("%lld\n", a * b / 100);
  return 0;
}


Measured memory_bytes: 3232
import java.util.Scanner;

class Main{
    public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
    	int a = scan.nextInt();
    	int b = scan.nextInt();
    	int c = scan.nextInt();

    	if(a < b){
    		if(b < c){
    			System.out.println("Yes");
    		}else{
    			System.out.println("No");
    		}
    	}else{
    		System.out.println("No");
    	}

    }
}

Measured memory_bytes: 26160
#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>*/
 
#define pll              pair <long long,long long>
#define pb               push_back
#define ll               long long
#define ff               first
#define ss               second
#define D(x)             cerr<<#x " = "<<(x)<<endl
#define vll              vector <ll>
#define IOS              ios_base::sync_with_stdio(0); cin.tie(NULL);
#define endl             '\n'   
using namespace std;
const ll N = 2e3+2;
vector<ll>g[N];
bool vis[N];
ll d[N];

void bfs(ll k)
{
	queue<ll> q;
	q.push(k);
	vis[k]=1;
	while(!q.empty())
	{
		int node=q.front();
		q.pop();
		for(auto it:g[node])
		{
			if(!vis[it])
			{
				d[it]=d[node]+1;
				vis[it]=1;
				q.push(it);
			}
		}
	}
}
int main()
{
    IOS
 	// freopen("input.txt","r",stdin);
 	// freopen("output.txt","w",stdout);
 	// freopen("error.txt","w",stderr);
 	ll n,x,y;
 	cin>>n>>x>>y;
 	map<ll,ll>mp;
 	for(ll i=1;i<n;i++)mp[i]=0;
 	for(ll i=1;i<n;i++)
 	{
 		g[i].push_back(i+1);
 		g[i+1].push_back(i);
 	}
 	g[x].push_back(y);
 	g[y].push_back(x);
 	for(ll i=1;i<=n;i++)
 	{
 		memset(vis,false,sizeof(vis));
 		memset(d,false,sizeof(d));
 		bfs(i);
 		for(ll j=1;j<=n;j++)
 			if(d[j])
 				mp[d[j]]++;
 	}
 	for(pll x:mp)
 	{
 		//cout<<x.first<<" ";
 		cout<<x.second/2<<endl;
 	}
    return 0;
}

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

int main(void){
  char c;

  cin >> c;

  if(c=='a'||c=='i'||c=='u'||c=='e'||c=='o')
    cout << "vowel" << endl;
  else cout << "consonant" << endl;

  return 0;
}

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

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

ll modSub(ll a, ll b, ll mod) {
	ll c = ((a % mod) - (b % mod)) % mod;
	return ((c < 0) ? c + mod : c);
}
ll modMul(ll a, ll b, ll mod) {
	return ((a % mod) * (b % mod)) % mod;
}

ll modPow(ll a, ll n, ll mod) {
	ll res = 1;
	while (n > 0)
	{
		if (n & 1) {
			res = modMul(res, a, mod);
		}
		a = modMul(a, a, mod);
		n >>= 1;
	}
	return res;
}

ll modDiv(ll a, ll b, ll mod) {
	return modMul(a, modPow(b, mod - 2, mod), mod);
}

ll modCombination(ll n, ll r, ll mod) {
	if (r > n / 2)
		return modCombination(n, n - r, mod);
	ll res = 1;
	for (ll i = 1; i <= r; i++) {
		res = modMul(res, n - i + 1, mod);
		res = modDiv(res, i, mod);
	}
	return res;
}


int main()
{
	ll n, a, b;
	ll mod = 1000000007;
	cin >> n >> a >> b;
	cout << modSub(modSub(modSub(modPow(2, n, mod), 1, mod), modCombination(n, a, mod), mod), modCombination(n, b, mod), mod);
	return 0;
}

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

int main()
{
    string S;
    cin >> S;
    int size = S.size();
    int SS[size];

    for (int i = 0; i < size; i++)
    {
        if (S[i] == '0')
        {
            SS[i] = 0;
        }
        else if (S[i] == '1')
        {
            SS[i] = 1;
        }
    }

    int counter = 0;

    for (int i = 0; i < size - 1; i++)
    {
        if (SS[i] == SS[i + 1])
        {
            if (SS[i] == 0)
            {
                SS[i + 1] = 1;
            }
            else
            {
                SS[i + 1] = 0;
            }
            counter++;
        }
    }

    cout << counter << endl;

    return 0;
}

Measured memory_bytes: 896
#include<iostream>
#include<string>
using namespace std;
int main(){
  string command="";
  string ans="";
  cin>>command;
  for(int i=0;i<command.size();i++){
    if(command.substr(i,1)=="0")ans.append("0");
    if(command.substr(i,1)=="1")ans.append("1");
    if(command.substr(i,1)=="B" && !ans.empty())ans.pop_back();
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <set>
#include <map>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>

using namespace std;

bool solve(const vector<int>& as, list<int>& ret)
{
	for (int i = 0; i < as.size(); i++) {
		int cur = as[i];
		int pos = cur - 1;
		if (ret.size() < pos) return false; 

		auto it = ret.begin();
		for (int i = 0; i < pos; i++) it++;
		ret.insert(it, cur);
	}

	return true;
}

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

	vector<int> as(n);
	for (auto& a : as) {
		cin >> a;
	}

	list<int> ret;
	bool is_ok = solve(as, ret);

	if (!is_ok) {
		cout << -1 << endl;
	}
	else {
		for (auto it = ret.begin(); it != ret.end(); it++) {
			cout << *it << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include <fstream>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <string>
#include <cassert>
#include <deque>
#include <set>
#include <map>
#include <vector>
#include <regex>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;

//#define LOCAL_DEBUG
int main() {
#ifdef LOCAL_DEBUG
	freopen("input1.txt","r", stdin);
#endif
	int N; cin >> N;
	ll p[20001];
	ll a[20001];
	ll b[20001];
	ll diff = 30000;
	for (int i = 1; i <= N; i++) cin >> p[i];
	for (int i = 1; i <= N; i++) a[i] = diff * i;
	for (int i = 1; i <= N; i++) b[i] = diff * (N - i);
	for (int i = 1; i <= N; i++) b[p[i]] += i;
	cout << a[1]; for (int i = 2; i <= N; i++) cout << " " << a[i]; cout << endl;
	cout << b[1]; for (int i = 2; i <= N; i++) cout << " " << b[i]; cout << endl;
 	return 0;
}


Measured memory_bytes: 1152
# 2 * N の配列 https://beta.atcoder.jp/contests/abc034/submissions/2638960
''' こんな感じ
3
100 15
300 20
200 30
'''


# 数字複数
N, Limit = map(int, input().split())

flag = True

CT = []
for i in range(N):
    c, t = map(int,input().split())
    if t <= Limit:
        CT.append([c,t])
        flag = False
    else:
        pass
if flag == True:
    print('TLE')
    exit()

CT.sort()

print(min(CT)[0])



'''
5 70
7 60
1 80
4 50
2 56
3 55
'''



Measured memory_bytes: 3064
MODE = "stdio"
require 'matrix'
line = Array.new

if(defined? MODE)
  line = STDIN.read.split("\n")
else
  tmp = "\
  fAIR, LATER, OCCASIONALLY CLOUDY.
  ".split("\n")
  tmp.each{|s|
    line << s.strip
  }
end
s=line[0]
puts s.swapcase

Measured memory_bytes: 9180
#include <bits/stdc++.h>
#define simplify ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define endl "\n"
using namespace std;

int binomialCoeff(int n,int r){
    int res=1;
    if(r>n-r)r=n-r;
    for(int i=0;i<r;i++){
        res*=(n-i);
        res/=(i+1);
    }
    return res;
}


int power(int x,int n,int mod){
    //(x^n)%mod
    int result=1;
    while(n){
        if(n%2)
            result=(result*x)%mod;
        x=(x*x)%mod;
        n/=2;
    }
    return result;
}

int inverseMod(int x,int mod){
    return power(x,mod-2,mod);
}


int32_t main() {

    simplify
    int n;
    cin>>n;

    int ans=n%1000==0?0:1000-n%1000;
    cout<<ans<<endl;
    

    return 0;
}



Measured memory_bytes: 3652
#include<bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

template<class Ty>
using passive_queue = priority_queue<Ty, vector<Ty>, greater<Ty>>;

struct Problem {

	UL G[100][100];
	UL D[100][100];

	void Solve() {
		UL H, W; cin >> H >> W;
		rep(y, H) rep(x, W) {
			char c; cin >> c;
			G[x][y] = (c == '#') ? 1 : 0;
		}
		rep(x, W) rep(y, H) D[x][y] = 10000;
		D[0][0] = G[0][0];
		rep(x, W) rep(y, H) {
			if (x != 0) {
				UL tmp = D[x - 1][y];
				if (G[x - 1][y] == 0 && G[x][y] == 1) tmp++;
				D[x][y] = min(D[x][y], tmp);
			}
			if (y != 0) {
				UL tmp = D[x][y - 1];
				if (G[x][y - 1] == 0 && G[x][y] == 1) tmp++;
				D[x][y] = min(D[x][y], tmp);
			}
		}
		cout << D[W - 1][H - 1] << endl;
	}

	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


Measured memory_bytes: 384
import scala.io.StdIn._
object Main extends App {
  case class Point(cs: Array[Int]) {
    def isIntDistance(p: Point): Boolean = {
      val sum = cs.zip(p.cs).map{case (c1, c2) => (c1 - c2) * (c1 - c2)}.sum
      val sqrt = Math.sqrt(sum).toInt
      sqrt * sqrt == sum
    }
  }

  val Array(n, d) = readLine.split(" ").map(_.toInt)
  val ps = Array.fill(n)(Point(readLine.split(" ").map(_.toInt)))

  println((0 until n - 1).foldLeft(0){(z, i) =>
    z + (i + 1 until n).count(j => ps(i).isIntDistance(ps(j)))
  })
}

Measured memory_bytes: 25516
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int i, cnt;
  string s;
  
  // stdin
  cin >> s;
  
  // calculate
  cnt = 0;
  for (i=0; i<s.length(); i++) {
    if(s.c_str()[i] == '1') {
      cnt++;
    }
  }
  
  // stdout
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

int main(){
  int n;
  cin >> n;
  ll a[n];
  REP(i,n) cin >> a[i];
  sort(a,a+n);
  ll mindif = INF;
  ll aj;
  REP(i,n){
    if(abs(a[i]*2-a[n-1])<mindif){
      mindif = abs(a[i]*2-a[n-1]);
      aj = a[i];
    }
  }
  cout << a[n-1] << " " << aj << endl;
  return 0;
}


Measured memory_bytes: 1024
MOD = 10**9 + 7

N = int(input())
Ts = list(map(int, input().split()))
As = list(map(int, input().split()))

minTs, maxTs = [1]*N, [10**9]*N
minAs, maxAs = [1]*N, [10**9]*N

minTs[0] = maxTs[0] = Ts[0]
for i in range(1, N):
    if Ts[i-1] < Ts[i]:
        minTs[i] = maxTs[i] = Ts[i]
    else:
        maxTs[i] = Ts[i]

minAs[-1] = maxAs[-1] = As[-1]
for i in reversed(range(N-1)):
    if As[i] > As[i+1]:
        minAs[i] = maxAs[i] = As[i]
    else:
        maxAs[i] = As[i]

ans = 1
for minT, maxT, minA, maxA in zip(minTs, maxTs, minAs, maxAs):
    minH = max(minT, minA)
    maxH = min(maxT, maxA)
    ans *= max(0, maxH - minH + 1)
    ans %= MOD
print(ans)


Measured memory_bytes: 19136
package main 

import (
"fmt"
"strings"
)

var s, t string
func main() {
	fmt.Scan(&s, &t)
	s_array := strings.Split(s, "")
	t_array := strings.Split(t, "")
	ans := len(t_array)
	for i := 0; i < len(s_array)-len(t_array)+1; i++ {
		one_ans := 0
		one_i := i
		for j := 0; j < len(t_array); j ++ {
			if s_array[one_i] != t_array[j] {
				one_ans += 1;
			}
			one_i ++
		}
		if ans > one_ans {
			ans =  one_ans
		}
	}

	fmt.Println(ans)
}

Measured memory_bytes: 1888
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	int sum = 0, t = 1;
	vector<int> ans;
	while (sum < n) {
		ans.push_back(t);
		sum += t;
		t++;
	}
	for (int i = 0; i < (int) ans.size(); i++) {
		if(ans[i] == sum - n) continue;
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int partition(int A[100001],int p,int r){
  int x=A[r],i=p-1,j,a;
  for(j=p;j<r;j++){
    if(A[j]<=x){
      i=i+1;
      a=A[i];A[i]=A[j];A[j]=a;
    }
  }
  a=A[i+1];A[i+1]=A[r];A[r]=a;
  return i+1;
}
int main(){
  int n,A[100001],q,i;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  q=partition(A,0,n-1);
  for(i=0;i<n;i++){
    if(i==q) printf("[%d]",A[i]);
    else printf("%d",A[i]);
    if(i<n-1) printf(" ");
  }
  printf("\n");
  return 0;
}



Measured memory_bytes: 2176
N, K = map(int, input().split())
ans = [None] * N

for _ in range(K):
    D = int(input())
    A = list(map(int, input().split()))
    for d in range(D):
        if ans[A[d]-1] == None:
            ans[A[d]-1] = True

print(ans.count(None))

Measured memory_bytes: 9056
// We only fail when we stop trying
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define endl '\n'
#define D(x) cerr << #x << " = " << (x) << '\n'
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()

const int N = 2e5 + 5;

int n;
int arr[N];
map<int, int> cnt;

int main()
{
  cin >> n;
  for(int i = 0 ; i < n ; i++) {
    cin >> arr[i];
    cnt[arr[i]]++;
  }
  long long ans = 0;
  for(auto p : cnt) {
    int cur = p.second;
    ans += 1LL * cur * (cur - 1) / 2;
  }
  for(int i = 0 ; i < n ; i++) {
    int cur = cnt[arr[i]];
    long long v = ans - cnt[arr[i]] + 1;
    cout << v << endl;
  }
  return 0;
}


Measured memory_bytes: 8320
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.stream.LongStream;

public class Main {

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

    int N = sc.nextInt();

    Map<String, List<String>> smap = new HashMap<>();

    String[] s = new String[N];
    for (int i = 0; i < N; i++) {
      s[i] = sc.next();
    }

    for (int i = N-1; i >= 0; i--) {
      char[] c = s[i].toCharArray();
      Arrays.sort(c);
      String key = new String(c);
      if (smap.get(key) == null) {
        smap.put(key, new ArrayList<>());
      } else {
        smap.get(key).add(s[i]);
      }
    }
    long count = 0L;
    for (Map.Entry<String, List<String>> entry : smap.entrySet()) {
      count += LongStream.rangeClosed(1, entry.getValue().size()).reduce(0, (x, y) -> x + y);
    }

    System.out.println(count);
  }
}



Measured memory_bytes: 76656
using System;

namespace ABC141
{
    class B
    {
        static void Main(string[] args)
        {

            string S = Console.ReadLine();

            bool isFumiyasui = true;
            for (int i = 0; i < S.Length; i++)
            {
                if ((i % 2) == 0)
                {
                    if (S[i] == 'L')
                    {
                        isFumiyasui = false;
                    }
                }

                if ((i % 2) == 1)
                {
                    if (S[i] == 'R')
                    {
                        isFumiyasui = false;
                    }
                }
            }

            if (isFumiyasui)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }

        }
    }
}


Measured memory_bytes: 11092
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
#include <stack>
#include <bitset>

////多倍長整数, cpp_intで宣言
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;

//#pragma GCC target ("avx2")
//#pragma GCC optimization ("Ofast")
//#pragma GCC optimization ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define repeat(i, n, m) for(int i = n; i < (m); ++i)
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a) //少数出力
#define printLdb(a) printf("%.50Lf\n", a) //少数出力
#define printdbd(a) printf("%.16lf\n", a) //少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str()) //string出力
#define all(x) (x).begin(), (x).end()
#define deg_to_rad(deg) (((deg)/360.0L)*2.0L*PI)
#define rad_to_deg(rad) (((rad)/2.0L/PI)*360.0L)
#define Please return
#define AC 0
#define manhattan_dist(a, b, c, d) (abs(a - c) + abs(b - d)) /*(a, b) から (c, d) のマンハッタン距離 */
#define inf numeric_limits<double>::infinity();
#define linf numeric_limits<long double>::infinity()

using ll = long long;
using ull = unsigned long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1e9 + 7;
constexpr ll mod = 998244353;
constexpr long double eps = 1e-6;
const long double PI = acosl(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);
	while (c != '\n' && c != -1 && c != ' ') {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}


double acot(double x) {
	return PI / 2 - atan(x);
}

ll LSB(ll n) { return (n & (-n)); }

template<typename T>
inline T chmin(T& a, const T& b) {
	if (a > b)a = b;
	return a;
}

template<typename T>
inline T chmax(T& a, const T& b) {
	if (a < b)a = b;
	return a;
}

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	int n, x, t;
	scanf("%d%d%d", &n, &x, &t);
	printf("%d\n", (n + x - 1) / x * t);

	Please AC;
}


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

const int MXN = 200005;
map<int, bool> dir[MXN];

void connect(int a, int b) {
	dir[a][b] = true;
	dir[b][a] = true;
}

int main() {
	
	int n, m;
	cin >> n >> m;
	
	for (int i=0; i<m; i++) {
		int a, b;
		cin >> a >> b;
		connect(a, b);
	}
	
	for (int i=1; i<=n; i++) {
		if (dir[1][i] && dir[i][n]) {
			cout << "POSSIBLE" << endl;
			exit(0);
		}
	}
	cout << "IMPOSSIBLE" << endl;
	
}


Measured memory_bytes: 37760
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<LL,LL>
#define I vector<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())
#define ENDL cout<<endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};


int main(){
    int N,K;cin >> N >> K;
    I vec;
    int mi = INF;
    for(int a = 0;a < N;a++){
        int b;cin >> b;
        vec.push_back(b);
        mi = min(mi,b);
    }
    vector<int> dp(K+1,-1);

    for(int a = 0;a <= K;a++){

        for(int c = 0;c < N;c++){
            if(a-vec.at(c) >= 0&&dp.at(a-vec.at(c)) == 0){
                dp.at(a) = 1;
                break;
            }
        }
        if(dp.at(a) == -1)dp[a]=0;
    }
    //for(int a = 0;a<=K;a++)cout<<dp[a]<<" ";
    /*
    for(int a = 0;a <= K;a++){
        for(int b = 0;b < 2;b++){
            cout<<dp[a][b]<<" ";
        }
        ENDL;
    }
    */

    if(dp.at(K)){
        COUT("First");
    }else{
        COUT("Second");
    }
}


Measured memory_bytes: 768
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <math.h>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  int n,a,b;
  cin>>n>>a>>b;
  cout<<min((n*a),b)<<"\n";
  return 0;
  }

Measured memory_bytes: 3612
n=gets.chomp.to_i
s=gets.chomp.split(" ").map{|i|i.to_i}
q=gets.chomp.to_i
t=gets.chomp.split(" ").map{|i|i.to_i}
cnt=0

def binary_search(key,array)
  n=array.size
  left = 0
  right = n-1
  while left <= right
    center = (left + right)/2
    val = array[center]
    return 1 if key == val
    if key > val
      left = center + 1
    else
      right = center - 1
    end
  end
  return 0
end

t.each do |key|
  cnt += binary_search(key, s)
end
puts cnt


Measured memory_bytes: 15636