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

using namespace std;
using ll = long long;

#pragma region Macros
#define FOR(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define rep(i, n) FOR(i, 0, n)

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

template <class T> string join(const T &v, const string delim = ",")
{
    if (v.empty())
        return "";

    ostringstream res;
    res << v[0];
    for (int i = 1; i < v.size(); i++)
    {
        res << delim << v[i];
    }
    return res.str();
}

#pragma endregion Macros

int main()
{
    vector<string> c(3);
    rep(i,3) cin >> c[i];

    cout << c[0][0] << c[1][1] << c[2][2] << endl;
}


Measured memory_bytes: 3524
#include<iostream>
#include<queue>
#include<vector>
#include<string>
#include<cstdlib>
using namespace std;
#define fr first
#define sc second
#define INF ( 1 << 30 )
int m, n, k, d;
int min_cost[110][1 << 6];
vector< int > cal;
typedef pair < int , int > Pi;
typedef pair < int , Pi > Pii;
struct edge{
  int to, cost;
  edge(){}
  edge( int to, int cost): to(to), cost(cost){};
};
vector < edge > info[110];
int java(string& s){
  if(s[0] == 'H') return 0; //MyHome
  if(s[0] == 'D') return 1; //市役所
  if(s[0] == 'C') return atoi(s.substr(1).c_str()) + 1; //ケーキ屋さん
  if(s[0] == 'L') return atoi(s.substr(1).c_str()) + m + 1; //ランドマーク
}
int bfs(){
  int ret = INF;
  // コスト , 今の場所 , 逝った
  fill_n(*min_cost,110*(1<<6),INF);
  priority_queue< Pii , vector< Pii > , greater< Pii > > que;
  que.push(Pii( 0, Pi( 0, (1<<m) - 1)));
  min_cost[0][(1<<m)-1] = true;
  while(!que.empty()){
    Pii p = que.top();
    que.pop();
    if(p.sc.fr == 1){
      ret = min( ret, p.fr);
    }
    if(min_cost[p.sc.fr][p.sc.sc] < p.fr ) continue;
    for(int i = 0 ; i < info[p.sc.fr].size() ; i++ ){
      edge e = info[p.sc.fr][i];
      int cost = p.fr + e.cost * k, bit = p.sc.sc;
      if( e.to >= 2 && e.to < 2 + m ){
        if((bit >> (e.to-2)) & 1){
          cost -= cal[e.to-2];
          bit &= ~(1 << (e.to-2));
        }else continue;
      }
      if( cost < min_cost[e.to][bit] ){
        que.push(Pii( cost,Pi( e.to, bit)));
        min_cost[e.to][bit] = cost;
      }
    }
  }
  return ret;
}
int main(){
  while(cin >> m >> n >> k >> d , m){
    cal.resize(m);
    for(int i = 0 ; i < m ; i++ ){
      cin >> cal[i];
    }
    for(int i = 0 ; i < d ; i++ ){
      string s1, s2;
      int cost;
      cin >> s1 >> s2 >> cost;
      info[java(s1)].push_back(edge( java(s2), cost));
      info[java(s2)].push_back(edge( java(s1), cost));
    }
    cout << bfs() << endl;
    for(int i = 0 ; i < 110 ; i++ ) info[i].clear();
  }
}

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

int main() {
  int N;

  cin >> N;

  vector<int> vec(N);

  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  
  int i, j, k;
  i = 1;
  j = 1;
  while (true) {
    if (vec.at(j - 1) == -1) {
      cout << -1 << endl;
      break;
    }
    
    if (vec.at(j - 1) == 2) {
      cout << i << endl;
      break;
    }

    k = j;
    j = vec.at(j - 1);
    vec.at(k - 1) = -1;

    i++;
  }
}


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

using namespace std;
int main(){
    long long int n, m, a, sum=0;
    scanf("%lld",&n);
    scanf("%lld",&m);
    for (int i = 0; i < m; ++i) {
        scanf("%lld",&a);
        sum = sum + a;
    }
    if((n-sum)>=0)
        cout<<(n-sum);
    else
        cout<<"-1";
    return 0;
}


Measured memory_bytes: 3688
<?php

$arr = array();

while($line = trim(fgets(STDIN))){
	list($name, $page) = explode(" ", trim($line));
	$name = trim($name);
	$page = intval($page);
	
	if(!array_key_exists($name, $arr)){
		$arr[$name] = array();
	}
	$arr[$name][] = $page;
}

ksort($arr, SORT_STRING);

foreach($arr as $val => $row){
	sort($row);
	
	echo $val."\n";
	echo implode(" ", $row)."\n";
}

Measured memory_bytes: 15304
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<map>
using namespace std;

int read(){
	int x=0,f=1;
	char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=(x<<3)+(x<<1)+c-48;c=getchar();}
	return x*f;
}

int k,m,n;
map<int,int> M;
int main(){
	n=read();
	for(register int i=1;i<=n;i++){
		int x=read();
		if(M[x]){puts("NO");return 0;}
		M[x]=1;
	}
	puts("YES");
	return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<int,int> p;
const int inf=(1<<30);
#define rep(i,a,n)	for(int i=a;i<n;i++)
#define rrep(i,a,n) for(int i=(a-1);i>=n;i--)

	ll h[2];
	ll a[100010];
int main(){
	ll n;
	cin>>n;
	rep(i,0,n)cin>>a[i];
	sort(a,a+n,greater<ll>());
	ll b=0;
	ll cnt=0;
	rep(i,0,n){
		cnt++;
		if(cnt==2){
			h[b]=a[i];
			b++;
			cnt=0;
		}
		if(a[i]!=a[i+1])cnt=0;
		if(b==2)break;
	}
	cout<<h[0]*h[1]<<endl;

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, m;
	cin >> n >> m;
	vector<vector<int>> vec(n, vector<int>(m, 0));
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		for (int j = 0; j < a; j++) {
			int b = 0;
			cin >> b;
			vec.at(i).at(b-1)++;
		}
	}
	int result = 0;
	for (int i = 0; i < m; i++) {
		int counter = 0;
		for (int j = 0; j < n; j++) {
			counter += vec.at(j).at(i);
		}
		if (counter == n) result++;
	}
	cout << result << endl;

}

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define BiSearchRangeNum(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y)

// 対象のvectorの [s, e)の範囲でのLIS
vector<int> LIS(vector<int> &x, int s, int e) {
  int INFTY = 1e9+7;
  vector<int> ret(e - s, INFTY);
  ret[0] = x[s];
  int size = 1;
  for (int i = s + 1; i < e; i++) {
    int tmp = x[i];
    if (ret[size - 1] < tmp) {
      ret[size++] = tmp;
    } else {
      *lower_bound(ret.begin(), ret.end(), tmp) = tmp;
    }
  }
  return vector<int> (ret.begin(), ret.begin() + size);
};

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

  vector<int> ans = LIS(a, 0, a.size());

  cout << ans.size() << endl;
};



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

#define trace(...) __f( #__VA_ARGS__ , __VA_ARGS__ )
template <typename Arg1>
void __f( const char* name , Arg1&& arg1 ) {
        cerr << name << " : " << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void __f( const char* na , Arg1&& arg1 , Args&&... args ) {
        const char* c = strchr( na + 1 , ',' );
        cerr.write( na , c - na ) << " : " << arg1 << " , ";
        __f( c + 1 , args... );
}
#define endl "\n"
#define all(V) V.begin(),V.end()
#define Unique(V) sort(all(V)),V.erase(unique(all(V)),V.end())
#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long int LL;
typedef pair <int,int> pii;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const double EPS = 1e-9;
const double PI = acos(-1.0);
const long long INF = 1e18;
const int N = 1e5 + 5;

int n , m;
int k[ 100 ];
int p[ 100 ];
int a[ 100 ][ 100 ];

int main( ) {
        IO;
        #ifdef LOCAL
            freopen( "input.txt" , "r" , stdin );
        #endif // LOCAL
        cin >> n >> m;
        for( int i = 0; i < m; i++ ) {
                cin >> k[i];
                for( int j = 0; j < k[i]; j++ ) {
                        cin >> a[i][j];
                        a[i][j]--;
                }
        }
        for( int i = 0; i < m; i++ ) cin >> p[i];
        int ans = 0;
        int ON[ 20 ];
        for( int i = 0; i < ( 1 << n ); i++ ) {
                memset( ON , 0 , sizeof( ON ) );
                for( int j = 0; j < n; j++ ) {
                        if( i&( 1 << j ) ) {
                                ON[j] = true;
                        }
                }
                bool f = true;
                int cnt = 0;
                for( int x = 0; x < m; x++ ) {
                        cnt = 0;
                        for( int y = 0; y < k[x]; y++ ) {
                                cnt += ( ON[ a[x][y] ] );
                        }
                        if( cnt%2 == p[x] ) f &= true;
                        else f &= false;
                }
                if( f ) ans++;
        }
        cout << ans << endl;
        return 0;
}







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

using namespace std;

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

vector<pair<long long int, int>> fs;

void hoge(long long int base) {
    long long int ret = 1e18;
    for (long long int i = 2; i * i <= base; i++) {
        if (base % i == 0) {
            int cnt = 0;
            while (base % i == 0) {
                base /= i;
                cnt++;
            }
            fs.emplace_back(i, cnt);
        }
    }
    if (base > 1) {
        fs.emplace_back(base, 1);
    }
}

int main()
{
    long long int a, b;

    cin >> a >> b;

    hoge(gcd(a, b));

    cout << fs.size() + 1 << endl;

}


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

using namespace std;

int main()
{
    int a, b, c, d = 0, e = 0;
    char ch;
    while (cin >> a >> ch >> b >> ch >> c) {
        if (pow(a, 2) + pow(b, 2) == pow(c, 2)) {
            d++;
        }
        if (a == b) e++;
    }
    cout << d << "\n" << e << endl;
    return 0;
}

Measured memory_bytes: 3092
#include<stdio.h>
#define NOT_FREE -1
#define FREE 1
#define N 8

int put[N][N],row[N],col[N],dpos[2*N-1],dneg[2*N-1];

void initialize(void){
  int i;
  for(i=0;i<N;i++){
    row[i]=FREE;
    col[i]=FREE;
  }
  for(i=0;i<2*N-1;i++){
    dpos[i]=FREE;
    dneg[i]=FREE;
  }
}

void print(void)
{
  int i,j;

  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(put[i][j]){
        if(row[i]!=j) return;
      }
    }
  }

  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(row[i]==j){
        printf("Q");
      }else{
        printf(".");
      }
    }
    printf("\n");
  }
}
void putqueen(int i)
{
  int j;
  if(i==N){
    print();
    return;
  }
  for(j=0;j<N;j++){
    if(col[j]==NOT_FREE || dpos[i+j]==NOT_FREE || dneg[i-j+N-1]==NOT_FREE){
      continue;
    }
    row[i]=j;
    col[j]=dpos[i+j]=dneg[i-j+N-1]=NOT_FREE;
    putqueen(i+1);
    row[i]=col[j]=dpos[i+j]=dneg[i-j+N-1]=FREE;
  }
}

int main(){
  int i,j,k,r,c;
  initialize();

  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      put[i][j]=0;
    }
  }

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

  return 0;
}


Measured memory_bytes: 2112
maxv = -float('inf')
N = int(input())
R_list = [int(input()) for _ in range(N)]
minv = R_list[0]
for j in range(1, N):
    if R_list[j] - minv > maxv:
        maxv = R_list[j] - minv
    if minv > R_list[j]:
        minv = R_list[j]
      
print(str(maxv))


Measured memory_bytes: 13600
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) (find(all(v),x)!=v.end())
#define incls(s,c) (s.find(c)!=string::npos)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(all(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
//const long double EPS = 1e-14;
const int INF = (1<<30)-1;
const ll LINF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; cin >> x; return x;}
inline ll lin() { ll x; cin >> x; return x;}
inline char chin() { char x; cin >> x; return x;}
inline string stin() { string x; cin >> x; return x;}
inline double din() { double x; cin >> x; return x;}
//template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
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; }
char itoa(int n) { return n + '0';}
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main () {
  string t;
  cin >> t;
  rep(i,t.size()) {
    if (t[i] == '?') t[i] = 'D';
  }
  cout << t << endl;
  return 0;
}

Measured memory_bytes: 3720
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <functional>
#include <array>

using namespace std;

int main(){
    while(true){
        int m, nmin, nmax;
        cin >> m >> nmin >> nmax;
        if(m == 0 && nmin == 0 && nmax == 0) break;
        --nmin, --nmax;

        vector<int> P(m);
        for(int i = 0; i < m; ++i){
            cin >> P[i];
        }
        int gyap = 0;
        int ans = 0;
        for(int i = nmin; i <= nmax; ++i){
            if(gyap <= P[i] - P[i+1]){
                gyap = P[i] - P[i+1];
                ans = i+1;
            }
        }
        cout << ans << endl;
    }
}


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

int main()
{
	int n;
	while(cin >> n){
		if(!n)
			break;
		map<int,int> memo;
		int name,a,b,c,d,e,f,g,h,time=0;
		for(int i=0;i<n;i++){
			cin >> name >> a >> b >> c >> d >> e >> f >> g >> h;
			time = a*60+b+c*60+d+e*60+f+g*60+h;
			memo[time] = name;
		}
		map<int,int>::iterator it = memo.begin();
		cout << it->second << endl;
		it++;
		cout << it->second << endl;
		it = memo.end();
		it--;
		it--;
		cout << it->second << endl;
	}
	return 0;
}

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

int main() {
    int N; cin >> N;
    vector<int> a(N); for (int i = 0; i < N; i++) cin >> a[i];
    map<int, ll> count;
    for (int i = 0; i < N; i++) count[a[i]]++;
    ll ans = 0;
    for (auto x : count) ans += (ll)(x.second - 1) * x.second / 2;

    for (int i = 0; i < N; i++) {
        cout << ans - count[a[i]] + 1 << endl;
    }
}


Measured memory_bytes: 10240
# for i, a in enumerate(iterable)
# q, mod = divmod(a, b)
# divmod(i, y) returns the tuple (i//y, i%y)
# manage median(s) using two heapq https://atcoder.jp/contests/abc127/tasks/abc127_f
# visual studio code shortcut https://qiita.com/TakahiRoyte/items/cdab6fca64da386a690b
# delete line: Ctrl+Shift+k
# choose same words: Ctrl+Shift+l
import sys
from itertools import combinations, permutations # https://docs.python.org/ja/3/library/itertools.html
from math import factorial
def combinations_count(n, r):
    # faster than the following code
    # def combinations_count(n, r):
    #     return factorial(n) // (factorial(n - r) * factorial(r))
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n
    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]
    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot
    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])
    return result
def combination_with_repetition_count(n, r):
    return combinations_count(n + r - 1, r)
from collections import deque, Counter # https://docs.python.org/ja/3/library/collections.html#collections.deque
from heapq import heapify, heappop, heappush, heappushpop, heapreplace,nlargest,nsmallest # https://docs.python.org/ja/3/library/heapq.html
from copy import deepcopy, copy # https://docs.python.org/ja/3/library/copy.html
from functools import reduce
from fractions import gcd # Deprecated since version 3.5: Use math.gcd() instead.
def gcds(numbers):
    return reduce(gcd, numbers)
def lcm(i, y):
    return (i * y) // gcd(i, y)
def lcms(numbers):
    return reduce(lcm, numbers, 1)
# set the inputs
    # open(0).read() is a convenient method:
    # ei) n, m, *i = map(int, open(0).read().split())
    #     min(i[::2]) - mai(i[1::2])
    # ei2) *i, = map(int, open(0).read().split())
    #     don't forget to add comma after *i if only one variable is used
    # R = lambda: map(int, input().split()) :it's fashionable, isn't it?
    # ei1) n, k = R()
    # ei2) v = list(R())
    # ei3) bc = [list(R()) for i in range(m)]

# R = lambda: list(map(int, input().split()))
# n = int().input()
# ab = [R() for i in range(n)]
# c = R()
# c = sorted(c, reverse = True)

R = lambda: list(map(int, input().split()))
n, m = R()
a = [int(input()) for i in range(m)]

# n, m = [100, 5]
# a = [1,23,45,67,89]

dp = [-1] * (n+1)
for i in a:
    dp[i] = 0
dp[0] = 1
if dp[1] != 0:
    dp[1] = 1

for i in range(n+1):
    if dp[i] > -1:
        pass
    else:
        dp[i] = dp[i-1] + dp[i-2]

print(dp[-1] % 1000000007)


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

int main() {
  int N;
  cin >> N;
  long long A[87];
  A[0] = 2;
  A[1] = 1;
  
  for(int i=2;i<=N;i++){
    A[i] = A[i-1] + A[i-2];
  }
  cout << A[N] << endl;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;

const int MAX = 100;
const int INF = 1 << 30;

int main(){
    int N;
    int X[MAX];

    cin >> N;
    for(int i = 0;i < N;i++){
        cin >> X[i];
    }

    int ans = INF;
    for(int i = 0;i <= MAX;i++){
        int sum = 0;
        for(int j = 0;j < N;j++){
            sum += pow(X[j] - i,2);
        }
        ans = min(sum,ans);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")
#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;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define shandom_ruffle random_shuffle

using ll=long long;
const int nax=1000*1007;

int n, k;
char wcz[nax];

int main()
{
	scanf("%s%d", wcz+1, &k);
	n=strlen(wcz+1);
	set <string> setel;
	for (int i=1; i<=n; i++)
	{
		string s="";
		for (int j=0; j<k && i+j<=n; j++)
		{
			s+=wcz[i+j];
			setel.insert(s);
		}
	}
	k--;
	while(k)
	{
		setel.erase(setel.begin());
		k--;
	}
	cout << (*setel.begin()) << endl;
	return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
const ll mod=1000000007;
const ll INF=1e15;
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());
#define pb push_back
#define mp make_pair
typedef pair<ll,ll> P;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};

const ll MAXN=100010;
ll memo[MAXN];
vec d[MAXN], D[MAXN];

bool used[MAXN];


void INIT(ll a){
    used[a]=true;
    rep(i,d[a].size()){
        ll b=d[a].at(i);
        if(!used[b]){
            D[a].pb(b);
            INIT(b);
        }
    }
    return;
}

ll dfs(ll x){
    if(memo[x]>=0) return memo[x];
    if(D[x].size()==0) return memo[x]=0;
    ll ret=0;
    rep(i,D[x].size()){
        ll a=D[x].at(i);
        ret^=(dfs(a)+1);
    }
    return memo[x]=ret;
}
int main(){
    ll N; cin>>N;
    rep(i,N-1){
        ll a,b; cin>>a>>b;
        a--; b--;
        d[a].pb(b);
        d[b].pb(a);
    }
    INIT(0);

    rep(i,MAXN) memo[i]=-INF;
    if(dfs(0)) cout<<"Alice"<<endl;
    else cout<<"Bob"<<endl;
    

}

Measured memory_bytes: 18304
#include <stdio.h>
 
struct stack {
    int data[20000];
    int point;
};

int whereDownHill(struct stack *mountain);

void calculateWater(struct stack *mountain, struct stack *width);

int main(void) {
	char str[30000] = {};
	struct stack mountain = {};
	struct stack width = {};
	
	int i = 0;
	int number_puddle = 0;
	int sum_puddle = 0;
	int location_downhill = 0;

	for ( i = 0; i < 20000; i++ ) {
		mountain.data[i] = -3;
	}
	 
	fgets(str,30000, stdin);

	i = 0;
	while(str[i] != '\0' ) {
		switch(str[i]) {
			case '\\':
			    mountain.data[mountain.point] = 0;
			    mountain.point++;
			    //printf("aaaaa\n");
			    break;
			
			case '_':
			    mountain.data[mountain.point] = -1;
			    mountain.point++;
			    break;
			 
			case '/':
			    location_downhill = whereDownHill(&mountain);
			    if ( location_downhill >= 0 ) {
			        calculateWater(&mountain, &width);
			    }
				break;
			
			default:
			    break;
		}
		
		i++;
	}
	

	number_puddle = 0;
	for ( i = 0; i < mountain.point; i++ ) {
	    if ( mountain.data[i] > 0) {
	        number_puddle++;
	        sum_puddle += mountain.data[i];
	    }
	}
	printf("%d\n", sum_puddle);
	printf("%d", number_puddle);

	for ( i = 0; i < mountain.point; i++ ) {
	    if ( mountain.data[i] > 0) {
	        printf(" %d", mountain.data[i]);
	    }
	}
	printf("\n");
	 
	return 0;
}


int whereDownHill(struct stack *mountain)
{
	int point_for_search = 0;
	int location_downhill = 0;
	point_for_search = mountain -> point;
	
	while ( mountain->data[point_for_search] != 0 ) {
		point_for_search--;
		if ( point_for_search < 0  ) {
			break; 
		}
	}
	
	location_downhill = point_for_search;
	
	return location_downhill;
}


void calculateWater(struct stack *mountain, struct stack *width)
{
	int sum_width = 0;
	int sum_water = 0;

	(mountain->point)--;
	while ( (mountain->data)[mountain->point] != 0 ) {
		if ( (mountain->data)[mountain->point] > 0 ) {
			(width->point)--;
			sum_width += (width->data)[width->point];
			sum_water += (mountain->data)[mountain->point];
		} else {
			sum_width++;
		}
		(mountain->point)--;
	}
	sum_water += 1 + sum_width;
	sum_width += 2;
	(mountain->data)[mountain->point] = sum_water;
	(width->data)[width->point] = sum_width;
	(width->point)++;
	(mountain->point)++;
}


Measured memory_bytes: 2112
# coding: utf-8
# Your code here!
N=int(input())
for i in range(N):
    a,b,c=map(int,input().split())
    
    a,b,c=sorted([a,b,c])
    
    if a**2+b**2==c**2:
        print('YES')
    else:
        print('NO')


Measured memory_bytes: 5604
H,W = map(int,input().split())
#s = [['' for j in range(W+2)] for i in range(H+2)]
s = [list(input()) for i in range(H)]
x = [-1, 0, 1, 0]
y = [0, 1 , 0, -1]
for i in range(H):
    for j in range(W):
        if (s[i][j] == "#"):
            flag = False
            for d in range(4):
                if (i+y[d] >= 0 and i+y[d] < H and j+x[d] >= 0 and j+x[d] < W):
                    if(s[i+y[d]][j+x[d]] == "#"):
                        flag = True
            if (flag == False):
                print("No")
                quit()
print("Yes")

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

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v, n) sort(v, v+n)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define ddvi vector<vector<int>>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

// union by size + path having
class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
// ここに処理を記述

    ll N, M, K;
    cin >> N >> M >> K;

    UnionFind uf(N);

    P temp;
    ddvi like(N,vi(0));
    for(int i=0; i<M; i++){
        cin >> temp.first >> temp.second;
        uf.merge(temp.first - 1, temp.second - 1);
        like[temp.first - 1].eb(temp.second - 1);
        like[temp.second - 1].eb(temp.first - 1);
    }
    ddvi block(N,vi(0)); // 友人候補ルートの中でのブロック
    for(int i=0; i<K; i++){
        cin >> temp.first >> temp.second;
        if(uf.issame(temp.first - 1, temp.second - 1)){
            block[temp.first - 1].eb(temp.second - 1);
            block[temp.second - 1].eb(temp.first - 1);
        }
    }

    REP(i,N){
        // cout << uf.size(i) << "/" << like[i].size() << "/" << block[i].size() << " ";
        cout << uf.size(i) - (like[i].size() + block[i].size()) - 1 << " "; // -1 は自分自身
    }
    cout << "\n";

return 0;
}

Measured memory_bytes: 13432
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int res = 40;
  for(int i=0 ; i<N ; i++){
    int A;
    int tmp=0;
    cin >> A;
    while(A%2==0){
      tmp ++;
      A = A/2;
     }
    if(tmp<res) res=tmp; 
    }
   cout<<res<<endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define fi first
#define se second
using namespace std;
const int M=110;
int n,nz;
struct cord{
    int x,y,h;
}a[M],b[M];
inline int get_h(int x,int y,int i)
{return a[i].h+abs(x-a[i].x)+abs(y-a[i].y);}
int check(int x,int y)
{
    int h=get_h(x,y,nz);
    for(int i=0;i<n;i++)
        if(max(0,h-abs(a[i].x-x)-abs(a[i].y-y))!=a[i].h)
            return 0;
    return h;
}
int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        int x,y,h;
        scanf("%d%d%d",&a[i].x,&a[i].y,&a[i].h);
        if(a[i].h) nz=i;
    }
    int h;
    for(int i=0;i<=100;i++)
        for(int j=0;j<=100;j++)
            if(h=check(i,j))
                printf("%d %d %d\n",i,j,h);
    return 0;
}


Measured memory_bytes: 256
//Author: xiaowuga
#include <bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
#define MAX INT_MAX
#define mem(s,ch) memset(s,ch,sizeof(s))
const long long N=100000; 
const long long mod=1e9+7; 
typedef long long LL;
typedef int II;
typedef unsigned long long ull;
#define nc cout<<"nc"<<endl
#define endl "\n"
int main() {
	ios::sync_with_stdio(false);cin.tie(0);
    long long a,b,c;
    cin>>a>>b>>c;
    if(a==b) cout<<c<<endl; 
    else if(a==c) cout<<b<<endl;
    else cout<<a<<endl;
	return 0;
}



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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  vector<int> x(3);
  int ans = 0;
  cin >> x[0] >> x[1] >> x[2];
  while (!(x[0] == x[1] && x[1] == x[2])) {
    sort(x.begin(), x.end());
    if (x[0]+2 <= x[1])
      x[0] += 2;
    else {
      x[0]++;
      x[1]++;
    }
    ans++;
  }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char a[3];
    for(int i=0;i<3;i++)
    {
        cin>>a[i];
    }
    if(a[1]=='B')
    {
        cout<<"ARC";
    }
    else
    {
        cout<<"ABC";
    }
    return 0;
}

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

using namespace std;

#define FOR(i, a, b) for (int i=(a);i<(b);++i)
#define ROF(i, a, b) for (int i=(b)-1;i>=(a);--i)
#define REP(i, n) for (int i=0;i<(n);++i)
#define PRE(i, n) for (int i=(n)-1;i>=0;--i)
#define FOREACH(a, v) for(auto a : v)

#define ALL(a) (a).begin(),(a).end()
#define DEBUG(x) cerr<<#x<<": "<<x<<endl
#define INFILE() freopen("in0.txt","r",stdin)
#define OUTFILE()freopen("out0.txt","w",stdout)

#define INF INT_MAX/3
#define eps 1e-14

#define ll long long
using vint = vector<int>;

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

int main() {
    int X, A, B;
    cin >> X >> A >> B;
    cout << (X - A) % B << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main
{
	
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        long sum = 0;
        for (int i = 1; i <= n; i++) {
        	for (int j = 1; j <= n; j++) {
        		for (int k = 1; k <= n; k++) {
        			sum += findGCD(new int[] {i, j, k} , 3);
        		}
        	}
        }
        System.out.println(sum);
    }
    
    static int gcd(int a, int b) 
    { 
        if (a == 0) 
            return b; 
        return gcd(b % a, a); 
    } 
  
    // Function to find gcd of array of 
    // numbers 
    static int findGCD(int arr[], int n) 
    { 
        int result = arr[0]; 
        for (int i = 1; i < n; i++) 
            result = gcd(arr[i], result); 
  
        return result; 
    } 
}

Measured memory_bytes: 52328
a = [int(input()) for i in range(1)]
n = a[0] 
works = [list(map(int, input().split())) for i in range(n)]
#print(works)
works = sorted(works, key=lambda x: x[1])

time = 0
flag = 0
#print(works[1][0])

for k in range(n):
  time += works[k][0]
  if time > works[k][1]:
    flag = 1
    break
    
if flag == 0:
  print('Yes')
else:
  print('No')

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


int main() {
  int a,b;
  cin >> a >> b;
 for(int i=10;i<1010;i++){
   if((i/10 == b) && ((i*8/100)==a)){
     cout << i << endl;
     return 0;
   }
 }

 cout << -1 << endl;
 return 0;
}


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

#define F first
#define S second
#define pb push_back
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),a.end()
#define pw(x) (1LL<<(x))

#define db(x) cerr << #x << " = " << x << endl
#define db2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define db3(x, y, z) cerr << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", " << z << ")\n"
#define dbv(a) cerr << #a << " = "; for (auto xxxx: a) cerr << xxxx << " "; cerr << endl

using namespace std;

typedef long long ll;
typedef double dbl;
const int INF = 1.01e9;



int main() {
#define TASK "A"
#ifdef HOME 
    assert(freopen(TASK".in", "r", stdin));
#endif
    int n;
    scanf("%d", &n);
    ll sum = 0;
    bool ok = 1;
    ll mn = INF;
    for (int i = 0; i < n; i++) {
        ll a, b;
        scanf("%lld%lld", &a, &b);
        sum += a;
        ok &= a == b;
        if (a > b) {
            mn = min(b, mn);
        }
    }

    if (ok) {
        puts("0");
        return 0;
    }

    cout << sum - mn << endl;



    return 0;
}



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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

int main()
{
    int N; cin >> N;
    vector<int> A(N), B(N), C(N);
    rep(i,N) cin >> A[i];
    rep(i,N) cin >> B[i];
    rep(i,N) cin >> C[i];
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());
    ll sum = 0;
    rep(i,N){
        sum += distance(A.begin(), lower_bound(A.begin(), A.end(), B[i])) * distance(upper_bound(C.begin(), C.end(), B[i]), C.end());
    }
    cout << sum << endl;
}

Measured memory_bytes: 1408
#include <stdio.h>

int main (void){
	int a = 0,b = 0;
	scanf("%d %d",&a,&b);
	
	int x = 1000;
	if(b<10)x = 10;
	else if(b<100)x = 100;
	
	int n;
	n = a*x + b;
	
	for(int i = 1;;i++){
		if(i*i == n){
			printf("Yes");
			break;
			}
		else if(i*i > n){
			printf("No");
			break;
			}
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()

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

    int N;
    cin >> N;
    string S;
    cin >> S;
    vector<int> black(N), white(N);
    if (S[0] == '#') black[0]++;
    for (int i = 1; i < N; i++) {
        black[i] = black[i-1];
        if (S[i] == '#') black[i]++;
    }
    if (S[N-1] == '.') white[N-1]++;
    for (int i = N - 2; i >= 0; i--) {
        white[i] = white[i+1];
        if (S[i] == '.') white[i]++;
    }
    int ans = min(white[0], black[N-1]);
    for (int i = 0; i < N - 1; i++) ans = min(ans, black[i] + white[i+1]);
    cout << ans << endl;
}

Measured memory_bytes: 2196
/*
G.Arshad
Indian Institute of Information Technology, Sricity
arshad2117@gmail.com
*/
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ll long long
#define mp make_pair
#define pb push_back
ll fact[100100];
ll moduloexp(ll a,ll b){
	ll res=1;
	while(b){
		if(b&1)res=(1LL*res*a)%MOD;
		b/=2;
		a=(1LL*a*a)%MOD;
	}
	return res;
}
ll comb(ll n,ll r){
	if(n<r)
		return 0;  
	return (1LL*fact[n]*moduloexp((1LL*fact[n-r]*fact[r])%MOD,MOD-2))%MOD;
}
void init(){
	fact[0]=1;
	for(int i=1;i<100010;i++)
		fact[i]=(fact[i-1]*i)%MOD;
}
int A[100010];
int main(){
	ios::sync_with_stdio(false);
	init();
	int n;
	cin>>n;
	set<int> df;
	for(int i=0;i<n;i++){
		cin>>A[i];
		df.insert(A[i]);
	}
	sort(A,A+n);
	reverse(A,A+n);
	double mini = 2*1e9;
	int ind = -1;
	double x = A[0]/2.0;
	for(int i=1;i<n;i++){
		if(abs(x - A[i]) < mini){
			mini = abs(x - A[i]);
			ind = i;
		}
	}
	cout<<A[0]<<" "<<A[ind]<<'\n';
}
	

Measured memory_bytes: 6144
#include<stdio.h>

int main (){
  int X=0;
  char str[50];
  
  scanf("%d",&X);
  scanf("%s",str);
  
  int n = 0;
  for(int i = 0; i <48;i++){
  	if('A' == str[i] ){
      	if('B' == str[i+1]){
        	if('C' == str[i+2]){
              n++;  
            }
        }
    }
  }
  printf("%d",n);	
  
  return 0;
}

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

int main()
{
  int N;
  vector<int> A(N), B(N), C(N);
  cin >> N;
  int ans = 0;
  rep(i, N)
  {
    cin >> A[i];
  }

  rep(i, N)
  {
    cin >> B[i];
    ans += B[i];
  }
  rep(i, N - 1)
  {
    cin >> C[i];
  }
  rep(i, N - 1)
  {
    if (A[i + 1] - A[i] == 1)
      ans += C[A[i] - 1];
  }
  cout << ans << endl;
  return 0;
}

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

vector<ll> prime;//素因数分解で出てきた素数を全て挿入するvector

//O(√n)
//整列済み
/*
void prime_factorize(ll n){
    if(n<=1) return;
    ll l=sqrt(n);
    for(ll i=2; i<=l; i++){
        if(n%i==0){
        prime_factorize(i);
        prime_factorize(ll(n/i));
        return;
        }
    }
    prime.push_back(n);
    return;
}
*/
int main() {
    ll N;
    cin >> N;
    vector<ll> cnt;
    for (ll i=1; i*i<=N; i++) {
        if (N%i==0) {
            cnt.push_back(i+N/i-2);
        }
    }
    sort(cnt.begin(),cnt.end());
    cout << cnt[0] << endl;
    /*
    prime_factorize(N);
    ll n = prime.size();
    vector<ll> vec(n);
    vec[0] = prime[0];
    for (ll i=1; i<n; i++) {
        if (prime[i-1]==prime[i]) {
            vec[i]=vec[i-1]*prime[i];
        }
        else {
            vec[i]=prime[i];
        }
    }
    vector<ll> cnt(n);
    for (ll i=0; i<n; i++) {
        cnt[i] = vec[i] + N/vec[i] - 2;
    }
    sort(cnt.begin(),cnt.end());
    cout << cnt[0] << endl;
    */
}

Measured memory_bytes: 3684
/* Author: Newbie Abhishek Pandey */
                                       
#include<bits/stdc++.h>
#define Abhi_921 ios_base::sync_with_stdio(false); cin.tie(NULL)
#define ll long long
#define ld long double
#define fi(i,j,n) for(int i=j;i<n;i++)
#define fd(i,j,n) for(int i=j;i>n;i--)
#define print(a,n) for(int i=0;i<n;i++){cout<<a[i]<<' ';}cout<<endl;
#define inp(a,n) for(int i=0;i<n;i++) cin>>a[i]
#define printe(v) for(auto &i:v){cout<<i<<' ';}cout<<endl;
#define deb(n1) cout<<n1<<endl;
#define pb push_back
#define eb emplace_back
#define vi vector<ll>
#define vll vector<pair<ll,ll>>
#define umap unordered_map<ll,ll>
using namespace std;
const long long mod=1e9+7;
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
Abhi_921;
int t;
t=1;
while(t--){
int n;
cin>>n;
if(n==0) cout<<"1"<<endl;
else cout<<"0"<<endl;
}
return 0;
}

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

int my_ceil(int a, int b){
  return (a + b - 1) / b;
}

int main(){
  int N;
  cin >> N;
  cout << fixed << setprecision(10);
  cout << (double) my_ceil(N, 2) / (double) N << endl;
}

Measured memory_bytes: 3756
#include <stdio.h>

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

int main() {
    long K, a, b, c, d, res = 0;
  	scanf("%ld", &K);
    for (a = 1; a <= K; a++) {
        for (b = 1; b <= K; b++) {
            for (c = 1; c <= K; c++) {
                d = gcd(a, b);
                res += gcd(c, d);
            }
        }
    }
    printf("%.ld\n", res);
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
 
int gcd(int a, int b, int c){
    int result;
    int init = a<b?(a<c?a:c):(b<c?b:c);
    for(int i = init; i >= 1; i--){
            if(a%i == 0 && b%i == 0 && c%i == 0){
                result = i;
                break;
            }
    }
    return result;
}
int main()
{
    ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    int k;
    int sum = 0;
    cin >> k;
 
    for(int i=1;i<=k;i++){
        for(int j=1;j<=k;j++){
            for(int l=1;l<=k;l++){
                sum += gcd(i, j, l);
            }
        }
    }
 
    cout << sum << '\n';
 
    return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;
using UL = unsigned int;
using ULL = unsigned long long;
using LL = long long;

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

// A[i]+x > A[i+1]の時、i+1に与える踏み台はA[i+1]-(A[i]+x)以上必要である。
// それ以上大きいものを与えた時、後ろのやつは必ず増える。
// したがって貪欲に採用するのが最適解である。
int main() {
  LL N; scanf("%lld", &N);
  LL n = 0;
  LL now = 0;
  LL prev = 0;
  rep(i, N){
    scanf("%lld", &now);
    n += max((LL)0, prev-now);
    prev = max(prev, now);
  }
  cout << n << endl;
  return 0;
}



Measured memory_bytes: 3756
package main

import (
	"container/heap"
	"fmt"
)

func main() {
	var n, m int
	fmt.Scan(&n, &m)

	g := make([][]Edge, n+1)
	em := make(map[[2]int]bool)
	var a, b, c int
	for i := 0; i < m; i++ {
		fmt.Scan(&a, &b, &c)
		if a > b {
			a, b = b, a
		}

		g[a] = append(g[a], Edge{b, c})
		g[b] = append(g[b], Edge{a, c})
		em[[2]int{a, b}] = true
	}

	for i := 1; i <= n; i++ {
		_, prevs := dijkstra(g, i)
		for j := 1; j <= n; j++ {
			if i == j {
				continue
			}
			ps := path(prevs, j)
			for k := 1; k < len(ps); k++ {
				a, b := ps[k-1], ps[k]
				if a > b {
					a, b = b, a
				}
				em[[2]int{a, b}] = false
			}
		}
	}

	ans := 0
	for _, v := range em {
		if v {
			ans++
		}
	}

	fmt.Println(ans)
}

// Edge .
type Edge struct {
	to, cost int
}

const inf int = 1e10

func dijkstra(g [][]Edge, s int) ([]int, []int) {
	dists := make([]int, len(g))
	for i := 1; i < len(dists); i++ {
		dists[i] = inf
	}
	prevs := make([]int, len(g))

	pq := make(PriorityQueue, 0)
	heap.Init(&pq)
	heap.Push(&pq, &Item{s, 0})
	dists[s] = 0

	for pq.Len() > 0 {
		item := heap.Pop(&pq).(*Item)
		u := item.pos
		if dists[u] < item.cost {
			continue
		}

		for _, e := range g[u] {
			if dists[e.to] > item.cost+e.cost {
				dists[e.to] = item.cost + e.cost
				prevs[e.to] = u
				heap.Push(&pq, &Item{e.to, dists[e.to]})
			}
		}
	}

	return dists, prevs
}

func path(prevs []int, t int) []int {
	path := make([]int, 0)
	for cur := t; cur != 0; cur = prevs[cur] {
		path = append(path, cur)
	}
	return reverse(path)
}

func reverse(a []int) []int {
	for i := len(a)/2 - 1; i >= 0; i-- {
		opp := len(a) - 1 - i
		a[i], a[opp] = a[opp], a[i]
	}
	return a
}

// Item .
type Item struct {
	pos  int
	cost int
}

// PriorityQueue .
type PriorityQueue []*Item

func (pq PriorityQueue) Len() int { return len(pq) }

func (pq PriorityQueue) Less(i, j int) bool {
	return pq[i].cost < pq[j].cost
}

func (pq PriorityQueue) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
}

// Push .
func (pq *PriorityQueue) Push(x interface{}) {
	item := x.(*Item)
	*pq = append(*pq, item)
}

// Pop .
func (pq *PriorityQueue) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	old[n-1] = nil
	*pq = old[0 : n-1]
	return item
}


Measured memory_bytes: 6264
#include <bits/stdc++.h>
using namespace std;
//to set precision use fixed,setprecision(number_of_points_after_decimal
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define mod 1000000007
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
void solution(){
    int k;
    string s;cin>>k>>s;
    int n=s.length();
    if(s.length()<=k)
        cout<<s<<endl;
    else{
        rep(i,0,k){
            cout<<s[i];
        }
        cout<<"..."<<endl;   
    }
}



int main() {
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
    cin.tie(0)->sync_with_stdio(0);
    cin.exceptions(cin.failbit);
    solution();
    return 0;
}

Measured memory_bytes: 3656
import java.util.*;
import java.io.*;

public class Main{

     public static void main(String []args){
        Scanner scanner = new Scanner(System.in);
        long [] arr = new long[4];
        long max =0;
        for (int i=0;i<4;i++)
        arr[i] = (long)scanner.nextInt();
        
        
      max = Math.max(arr[0]*arr[1], arr[2]*arr[3]);
        
    System.out.println(max);
        
     }
}



Measured memory_bytes: 35476
#include <stdio.h>
int main(void)
{
	int x, y, i;
	i=0;
	while(1)
	{
		scanf("%d %d\n", &x, &y);
		if(x==0&&y==0)
		{
			break;
		}
		else if(i==3000)
		{
			break;
		}
		i++;
		
		if(y<x)
		{
			printf("%d %d\n", y, x);
		}
		else
		{
			printf("%d %d\n", x, y);
		}
	}
	return 0;
}


Measured memory_bytes: 2724
#include <stdio.h>
int main(){
  
 long n, a, i, max, min, sum;
 scanf("%ld", &n);
 scanf("%ld", &a);
 max = a;
 min = a;
 sum = a;
 for(i = 2; i <= n; i++) {
 scanf("%ld", &a);
 if(a > max) {
 max = a;
 }
 if(a < min) {
 min = a;
 }
 sum += a;
 }
 printf("%ld %ld %ld\n", min, max, sum);
  
 return 0;
}

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

int main(){
    int N;
    cin >> N;
    string s;
    cin >> s;
    int white[N + 1]; //i番目までに白がいくつあるのか。
    white[0] = 0;
    for(int i = 1; i < N+1; i++){
        if(s[i - 1] == 'W') white[i] = white[i-1] + 1;
        else white[i] = white[i-1];
    }
    // cout << white[N] << endl;
    int ans = 1<<30;
    for(int i = 0; i < N+1; i++){
        int w = white[i];
        int r = (N - i) - (white[N] - white[i]);
        int temp = max(w, r);
        if(temp < ans) ans = temp;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4528
import java.util.Scanner;

public class Main {

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

	public static void main(String[] args) {

		int n = sc.nextInt();

		int[] num = new int[n+1];
		String[] s = new String[n+1];
		int[] p = new int[n+1];

		for(int i=0; i<n; i++) {
			num[i] = i+1;
			s[i] = sc.next();
			p[i] = sc.nextInt();
		}

		num[n]=0;
		s[n]="0";
		p[n]=0;

		/* 辞書順にソート */
		for(int j=n; 0<j; j--) {
			for(int k=0; k<j; k++) {
				if(s[k].compareToIgnoreCase(s[k+1]) > 0) {
					num[n] = num[k];
					s[n] = s[k];
					p[n] = p[k];

					num[k] = num[k+1];
					s[k] = s[k+1];
					p[k] = p[k+1];

					num[k+1] = num[n];
					s[k+1] = s[n];
					p[k+1] = p[n];
					/* P順にソート */
				}if(s[k].compareToIgnoreCase(s[k+1]) == 0) {
					if(p[k]<p[k+1]) {
						num[n] = num[k];
						s[n] = s[k];
						p[n] = p[k];

						num[k] = num[k+1];
						s[k] = s[k+1];
						p[k] = p[k+1];

						num[k+1] = num[n];
						s[k+1] = s[n];
						p[k+1] = p[n];
					}
				}
			}
		}

		for(int i=0; i<n; i++) {
			System.out.println(num[i]);
		}
	}
}


Measured memory_bytes: 23124
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
class c{
    public static void Main(){
        long n = long.Parse(Console.ReadLine());
        long[] num = Console.ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();
        long step = 0;
        long cur = num[0];
        for(long i=0; i<n; i++){
            if(num[i] >= cur){
                cur = num[i];
            }
            else{
                step += cur - num[i];
            }
        }
        Console.WriteLine(step);
    }
}


Measured memory_bytes: 44584