akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<queue>
#include<string>
#include<set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0; i<n; i++)
#define per(i, n) for(int i=n-1; i>=0; i--)
#define reps(i, n) for(int i=1; i<n; i++)
#define pers(i, n)  for(int i=n-1; i>=1; i--)

const int INF = 1001001001;

void solve(){
  int k;  cin >> k;
  queue<unsigned> q;
  reps(i, 10) q.push(i);
  unsigned ans;
  while(k>0){
    ans = q.front();
    q.pop();

    int x=ans;
    if(x%10)  q.push(10*x+x%10-1);
    q.push(10*x+x%10);
    if(x%10!=9) q.push(10*x+x%10+1);

    k--;
  }
  cout << ans << endl;
}

int main(){
  solve();
  return 0;
}


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

#define rep(i, a) for (int i = 0; i < (a); i++ )
#define FOR(i, m, n) for(int i = m; i < n; i++)
 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

int step;

void dfs(vector<vector<int>> &C, set<int> &s, int i, int j) {
    s.insert(i);
    if (i==1) {
        step = min(step,j);
    }
    else {
        rep(k,10){
            if (s.count(k)) continue;
            else {
                dfs(C,s,k,j+C[i][k]);
            }
            s.erase(k);
        }
    }

}

int main(){
    int H,W;
    cin >> H >> W;
    vector<vector<int>> C(10 ,vector<int>(10));

    rep(i,10) {
        rep(j,10) {
            cin >> C[i][j];
        }
    }

    vector<ll> M(10);
    rep(i,10) {
        set<int> s;
        step = INF;
        dfs(C,s,i,0);
        M[i] = step;
    }

    vector<int> A;
    rep(i,H*W) {
        int a;
        cin >> a;
        if (a!=-1) {
            A.push_back(a);
        }
    }

    ll ans = 0;

    rep(i,A.size()) {
        ans += M[A[i]];
    }
    cout << ans << endl;

}

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

int main(){
    int w, h, n;
    cin >> w >> h >> n;
    set<pair<int,int>> x;
    multiset<int> y;
    for(int i = 0; i < n; i++){
        int a, b;
        cin >> a >> b;
        x.insert({a, b});
        y.insert(b);
    }
    int ans = *y.rbegin();
    while(!x.empty()){
        int take = x.begin()->first;
        while(!x.empty() && x.begin()->first == take){
            y.erase(y.find(x.begin()->second));
            x.erase(x.begin());
        }
        ans = min(ans, (y.empty() ? 0 : *y.rbegin())+take);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 12480
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

int n,T,a;
struct node 
 {
 	ll tt;
 	int id;
 }t[2110];

 bool cmp(node a,node b)
 {
 	return a.tt <= b.tt;
 }
int x;
int main()
{
	while(scanf("%d",&n)!=EOF)
	{
		cin>>T>>a;
		a *= 1000;
		rep(i,0,n)
		{
			cin>>x;
			t[i].tt = 1000 * T - x * 6;
			t[i].tt = abs(a - t[i].tt);  
			t[i].id = i+1;
		}
		sort(t,t+n,cmp);
		cout<<t[0].id<<endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;
typedef pair<int, int> P;
static const int INF = 1e9;
static const int dx[] = {1, 0, -1, 0};
static const int dy[] = {0, -1, 0, 1};

void solve()
{
	int n, m;
	while (cin >> n >> m, n || m)
	{
		P start;
		vector< vector<char> > field(m, vector<char>(n));
		for (int i = 0; i < m; ++i)
		{
			for (int j = 0; j < n; ++j)
			{
				cin >> field[i][j];
				if (field[i][j] == '&')
				{
					start.first = j;
					start.second = i;
				}
			}
		}
		queue<P> Que;
		Que.push(start);
		queue<P> wallQue;
		vector< vector<int> > fieldStep(m, vector<int>(n));
		for (int i = 0; i < m; ++i)
		{
			for (int j = 0; j < n; ++j)
			{
				fieldStep[i][j] = INF;
			}
		}
		fieldStep[start.second][start.first] = 0;
		int cnt = 0;
		while (true)
		{
			while (!Que.empty())
			{
				P cur = Que.front();
				Que.pop();
				for (int i = 0; i < 4; ++i)
				{
					P next;
					next.first = cur.first + dx[i];
					next.second = cur.second + dy[i];
					if (!(0 <= next.first && next.first < n && 0 <= next.second && next.second < m) || fieldStep[next.second][next.first] != INF)
					{
						continue;
					}
					else
					{
						if (field[next.second][next.first] == '#')
						{
							fieldStep[next.second][next.first] = cnt + 1;
							wallQue.push(next);
						}
						else
						{
							fieldStep[next.second][next.first] = cnt;
							Que.push(next);
						}
					}
				}
			}
			++cnt;
			while (!wallQue.empty())
			{
				P cur = wallQue.front();
				wallQue.pop();
				for (int i = 0; i < 4; ++i)
				{
					P next;
					next.first = cur.first + dx[i];
					next.second = cur.second + dy[i];
					if (!(0 <= next.first && next.first < n && 0 <= next.second && next.second < m) || fieldStep[next.second][next.first] != INF)
					{
						continue;
					}
					else
					{
						if (field[next.second][next.first] == '#')
						{
							fieldStep[next.second][next.first] = cnt;
							wallQue.push(next);
						}
						else
						{
							fieldStep[next.second][next.first] = cnt;
							Que.push(next);
						}
					}
				}
			}
			if (Que.empty())
			{
				break;
			}
		}
		int minv = INF;
		for (int i = 0; i < n; ++i)
		{
			minv = min(minv, fieldStep[0][i]);
			minv = min(minv, fieldStep[m - 1][i]);
		}
		for (int i = 0; i < m; ++i)
		{
			minv = min(minv, fieldStep[i][0]);
			minv = min(minv, fieldStep[i][n - 1]);
		}
		cout << minv << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1328
#include <iostream>
#include <sstream>
using namespace std;
#include <bits/stdc++.h>
#include<utility>
#include <algorithm>
#include<iterator>
#define  go return 0
#define pb push_back
#define lp(j, n)  for(int j=0; j<(int)(n); ++j)
#define rep(i,n) for(int i=0;i<n;++i)
#define all(v)   ((v).begin()), ((v).end())
#define sz(v)    ( (int)((v).size()) )
#define F first
#define S second
typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<pair<int,int> > vpii;
typedef map<int, int> mii;
const ll N=1e5+5;
ll arr[N],A[N]  ;
bool visited[N]={};
int main()
{

  int n;
  double sum=0;
  cin>>n;
  while(n--)
  {
      double a ; string s;
      cin>>a>>s;
      if(s=="JPY")
        sum+=a;
      else
        sum+=(a*380000.0);
  }
  cout<<sum;

 go;
}


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

ll powmod(ll x,ll y){
    ll res=1;
    for(ll i=0;i<y;i++){
        res=res*x%mod;
    }
    return res;
}
int main(){
    ll n;
    cin>>n;
    ll ans=powmod(10,n)-powmod(9,n)-powmod(9,n)+powmod(8,n);
    ans%=mod;
    ans=(ans+mod)%mod;
    cout<<ans<<"\n";
}


Measured memory_bytes: 3632
package main

import (
	"fmt"
)

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)
	if c-(a+b) <= 0 {
		fmt.Println("No")
	} else if (c-(a+b))*(c-(a+b)) > 4*a*b {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <ctime>
#include <assert.h>
#include <chrono>
#include <random>
#include <numeric>
#include <set>
using namespace std;
typedef long long int ll;
using ull = unsigned long long;

int dp[33][33][901];
int a[33][33];

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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int h,w; cin >> h >> w;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin >> a[i][j];
            for(int k=0;k<901;k++){
                dp[i][j][k]=1e9;
            }
        }
    }
    dp[0][0][0]=0;
    for(int d=0;d<h*w;d++){
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                for(int k=0;k<4;k++){
                    int nx=i+dx[k],ny=j+dy[k];
                    if(0<=nx&&nx<h&&0<=ny&&ny<w){
                        dp[nx][ny][d+1]=min(dp[nx][ny][d+1],dp[i][j][d]+a[nx][ny]*(2*d+1));
                    }
                }
            }
        }
    }
    int res=1e9;
    for(int i=0;i<=h*w;i++){
        res=min(res,dp[h-1][w-1][i]);
    }
    cout << res << endl;
}



Measured memory_bytes: 6424
import java.util.*;
public class Main {
    
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int X = scanner.nextInt();
        for (long i = -1000; i <=1000 ; i++) {
            for (long j = -1000; j <=1000; j++) {
                long a5 = i*i*i*i*i;
                long b5 = j*j*j*j*j;
                if(a5-b5==X){
                    System.out.print(i);
                    System.out.print(" ");
                    System.out.print(j);
                    return;
                }
            }
        }
    }
}

Measured memory_bytes: 35644
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

#define MAX_N 1

typedef long long ll;

const double PI = 3.141592653589793;
const long long MOD = 1e9 + 7;
const long long INF = 1e15;
const int INF_INT = 1e9;

struct UnionFind{
    vector<ll> parent;
    vector<ll> sizes;
    ll N;
    UnionFind(ll n){
        parent.resize(n);
        sizes.resize(n);
        N =  n;
        for(ll i = 0; i < n; i++){
            parent[i] = i;
            sizes[i] = 1;
        }
    }

    ll root(ll s){
        if(parent[s] == s) return s;
        return root(parent[s]);
    }

    bool same(ll s,ll t){
        ll rs = root(s);
        ll rt = root(t);
        if(rs == rt) return true;
        else return false; 
    }

    void integrate(ll s,ll t){
        ll rs = root(s);
        ll rt = root(t);
        if(rs == rt) return;
        if(sizes[rs] >= sizes[rt]){
            parent[rt] = rs;
            sizes[rs] += sizes[rt];
        }
        else{
            parent[rs] = rt;
            sizes[rt] += sizes[rs];
        }
    }

    ll renketu(ll s){
        ll rs = root(s);
        return sizes[rs];
    }
};

int main(){
    ll n,m;
    cin >> n >> m;
    UnionFind uf(n);
    vector<pair<ll,ll>> road(m);
    for(ll i = 0; i < m;i++){
        ll a,b;
        cin >> a >> b;
        --a;--b;
        road[i] = make_pair(a,b);
    }
    ll a = (n * n - n) / 2;
    ll pre = 0;
    ll ans[m+1];
    ans[m] = a;
    for(int i = m-1; i >= 0; --i){
        ll x = road[i].first;
        ll y = road[i].second;
        if(uf.same(x,y)){
            ans[i] = a - pre;
            continue;
        }
        pre += uf.renketu(x) * uf.renketu(y);
        ans[i] = a - pre;
        uf.integrate(x,y);
    }
    for(int i = 1; i <= m; i++){
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 5248
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <numeric>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <thread>
#include <tuple>
#include <limits>
#include <iostream>

using namespace std;

int main() {
  int x, y;
  scanf("%d%d", &x, &y);
  int ans = 0;
  if (x == 3) ans += 1;
  if (x == 2) ans += 2;
  if (x == 1) ans += 3;
  if (y == 3) ans += 1;
  if (y == 2) ans += 2;
  if (y == 1) ans += 3;
  if (x == 1 && y == 1) ans += 4;
  ans *= 100000;
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(vec) vec.begin(), vec.end()
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
ll dp[100010];
ll gcd(ll x, ll y){
  return y == 0 ? x : gcd(y, x % y);
}
ll lcg(ll x, ll y){
  return x * y / gcd(x, y);
}
map<ll, ll> factor(ll n){
  map<ll, ll> ans;
  ll a = 2;
  while (n >= a * a){
    if (n % a == 0){
      ans[a]++;
      n /= a;
    }
    else a++;
  }
  ans[n]++;
  return ans;
}
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(){
    ll n; cin >> n;
  vector<ll> h(n); rep(i, n) cin >> h[i];
  
  //string ans = "Yes";
  //string ans = "No";
  //string ans = "YES";
  //string ans = "NO";
  ll ans = 0;
  rep(i, 100010) dp[i] = INF;
  dp[0] = 0;
  dp[1] = abs(h[1] - h[0]);
  for (int i = 2; i < n; i++){
    chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
    chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
  }
  ans = dp[n - 1];
  
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main(){
	
	bool sbmt[31]={0};
	
	for(int i=0; i<28; ++i){
		int a;
		cin>>a;
		sbmt[a] = true;
	}
	
	for(int i=1; i<=30; ++i){
		
		if(!sbmt[i])
			cout << i << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1160
H,W = map(int,input().split())
C = [list(map(int,input().split())) for i in range(10)]
A = [list(map(int,input().split())) for i in range(H)]

for k in range(10):
    for i in range(10):
        for j in range(10):
            C[i][j] = min(C[i][j], C[i][k]+C[k][j])

ans = 0
for row in A:
    for a in row:
        if a==-1: continue
        ans += C[a][1]
print(ans)

Measured memory_bytes: 3316
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define EPS 1e-9
#define pi 4*atan(1.0)
#define rep(i,n) for(int i=0;i<n;i++)

int m,n;
double v;

int main(){
	while(cin>>m&&m){
		double sum=0,area=0;
		rep(i,m-1){
			cin>>v;
			sum+=v;
			area+=sin(v*pi/180.0);
		}
		area+=sin((360.0-sum)*pi/180.0);
		double area2=0;sum=0;
		cin>>n;
		rep(i,n-1){
			cin>>v;
			sum+=v;
			area2+=sin(v*pi/180.0);
		}
		area2+=sin((360.0-sum)*pi/180.0);
		if(abs(area-area2)<EPS)cout<<0<<endl;
		else cout<<(area>area2?1:2)<<endl;
	}
}

Measured memory_bytes: 0
#include<cstdio>
#include<map>
using namespace std;
map<int,int> M;
int main()
{   
	int n,x,f=1;
	scanf("%d",&n);
	while(n--) scanf("%d",&x),M[x]++;
	scanf("%d",&n);
	while(n--)
	{
		scanf("%d",&x);
		if(M[x]<1) {f=0;break;}
		else M[x]--;
	}
	if(f) printf("YES\n");
	else printf("NO\n");
	return 0;
}

Measured memory_bytes: 9600
#include <iostream>
    #define LL long long
#include<cstdio>
    using namespace std;
    long long NMAX,NMIN;
    int K;
    int A[100005];
    long long eval(long long N){
        for(int i = 1;i <= K;i++){
            N =N - N % A[i];}
        return N;
    }
    int main()
    {
        cin >> K;
        for(int i = 1;i <= K;i++){
            cin >> A[i];
        }
        LL l = 0, r = 1e18;
        while(l <= r){
            LL mid = (l + r) / 2;
            if(eval(mid) >= 2) r = mid - 1;
            else l = mid + 1;
        }
      long long L = l;
        l = 0, r = 1e18;
        while(l <= r){
            LL mid = (l + r) / 2;
            if(eval(mid) <= 2) l = mid + 1;
            else r = mid - 1;
        }

    long long R = r;
//    cout << L << ' '<< R << endl;
    if(L > R) puts("-1");
    else cout << L << ' '<< R << endl;
        return 0;
    }


Measured memory_bytes: 640
n = int (input ())
cnt = [[0 for i in range (10)] for i in range (10)]

for i in range (1, n + 1) :
    q = i % 10
    p = int (str (i)[0])
    cnt[p][q] += 1

ans = 0
for i in range (10) :
    for j in range (10) :
        ans += cnt[i][j] * cnt[j][i]

print (ans)


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

int main() {
int N;
cin>>N;
int C ;
C=N%100%10; //1の位を求めるために100と10の剰余

//あとは場合分けでやるたぶん点でつないでかける
  if(C==3){
   cout<<"bon"<<endl;
 }
  else if(C==0){
    cout<<"pon"<<endl;
  }
  
  else if(C==1){
    cout<<"pon"<<endl;
  }
  
  else if(C==6){
    cout<<"pon"<<endl;
  }
  
  else if(C==8){
    cout<<"pon"<<endl;
  }
  
  else{
    cout<<"hon"<<endl;
  }
  


}
  



Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll A[1010101],B[1010101],cac[1010101],n;
ll caca[1010101];
map<ll,ll> xx;
inline bool check(){
	xx.clear();
	for (int i=1;i<=n;i++) xx[caca[i]]++;
	for (int i=1;i<=n;i++){
		if (A[i]==B[i]){
			if (xx[A[i]]>=2) return 1;
		}else{
			if (xx[A[i]]&&xx[B[i]]) return 1;
		}
	}
	return 0;
}
inline ll get(){
	ll ans=0;
	for (int i=1;i<=n;i++) ans+=caca[i];
	return ans;
}
int main(){
	scanf("%lld",&n);
	for (int i=1;i<=n;i++) scanf("%lld%lld",&A[i],&B[i]);
	ll ans=10101010101010101;
	for (int i=1;i<=n;i++) caca[i]=A[i];
	ans=min(ans,get());
	for (int i=1;i<=n;i++) caca[i]=B[i];
	ans=min(ans,get());
	for (int i=1;i<=n;i++){
		cac[2*i-1]=A[i],cac[2*i]=B[i];
	}
	sort(cac+1,cac+1+2*n);
	for (int i=1;i<=n;i++) caca[i]=cac[i];
	if (check()){
		printf("%lld\n",min(ans,get()));
		return 0;
	}else{
		caca[n]=cac[n+1];
		if (check()) printf("%lld\n",min(ans,get()));
		else{
			caca[n-1]=cac[n];
			if (check()) ans=min(ans,get());
			caca[n-1]=cac[n-1],caca[n]=cac[n+2];
			if (check()) ans=min(ans,get());
			cout<<ans;
		}
	}
	return 0;
}

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

int main()
{
  int a, b, c, d;
  int count = 0;
  cin >> a >> b >> c >> d;
  for(int i=0;i<=100;i++){
    if(a<=i && i<=b && c<=i && i<=d){
      count++;
    }
  }
  if(count != 0){
    count--;
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3

N, M, L = [int(s) for s in input().split()]
edge = [[int(s) for s in input().split()] for _ in range(M)]
dist = [[10 ** 10] * N for _ in range(N)]
graph = [[] for _ in range(N)]
Q = int(input())

for i, j, w in edge:
    dist[i - 1][j - 1] = w
    dist[j - 1][i - 1] = w

for k in range(N):
    for i in range(N):
        for j in range(N):
            dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])

for i in range(N):
    for j in range(N):
        dist[i][j] = 1 if dist[i][j] <= L else 10 ** 10

for k in range(N):
    for i in range(N):
        for j in range(N):
            dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])


for _ in range(Q):
    s, t = [int(a) - 1 for a in input().split()]
    print(dist[s][t] - 1 if dist[s][t] < 10**10 else -1)

Measured memory_bytes: 65880
Imports System.Collections
        Imports System.Collections.Generic
        Imports System.Linq
        Imports System.xml
        Imports System.xml.Linq
         
        Module Module1
          public sub main()
            
        dim N as string = Console.ReadLine()    
        dim intN as integer = convert.todouble(N)
        dim num as integer = 1
        dim sum as long = 0
        dim isRimit as boolean = false
        while (not isRimit)
      if num = intN then 
            isRimit = true
      end if
          select case True
          case num mod 3 = 0 'fizz
            num += 1
          case num mod 5 = 0 'Buzz
            num += 1
          case else
            sum += num
            num += 1        
          End select
        end While
        console.writeLine(sum.tostring())
              
          end sub 
        End Module

Measured memory_bytes: 27540
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N;
	cin >> N;
	vector<pii> A;
	REP(i, N) {
		int a;
		cin >> a;
		A.push_back(pii(a, i));
	}
	SORT(A);
	REP(i, N) {
		cout << A[i].second + 1;
		if (i == N - 1)cout << endl;
		else cout << " ";
	}
	return 0;
}



Measured memory_bytes: 2544
{-# LANGUAGE ScopedTypeVariables #-}
import qualified Data.ByteString.Char8 as BS

main = do
  [r,g,b,n] :: [Int] <- map (read . BS.unpack) . BS.words <$> BS.getLine
  -- n <= 3000
  print (sum [ 1
             | r' <- [0..n `quot` r]
             , g' <- [0..n `quot` g]
             , r * r' + g * g' <= n
             , (n - (r * r' + g * g')) `rem` b == 0
             ] :: Int)


Measured memory_bytes: 764
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
#define pb push_back

using ll = long long;
using namespace std;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
const int INFint = 1e9;
const ll INFll = 1e18;
ll MOD=1e9+7;

ll gcd(ll a, ll b) { return __gcd(a,b); } //最大公約数
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; } //最大公倍数

// aのn乗をMODで割りながら計算する
ll modpow(ll a, ll n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1; // right shift
  }
  return res;
}

int prime[55556];
bool is_prime[55556];

void sieve(int n) {
  int p = 0;
  for (int i(0);i<=n;i++) is_prime[i] = true;
  is_prime[0] = is_prime[1] = false;
  for (int i(2);i<=n;i++){
    if (is_prime[i]){
      prime[p++] = i;
      for (int j(2*i);j<=n;j+=i) is_prime[j] = false;
    }
  }
}

int main(){
  int N;
  cin>>N;
  sieve(55555);
  int cnt(0);
  for (int i(3);i<=55555;i++){
    if (i % 5 == 1 && is_prime[i] == true){
      cnt++;
      cout << i;
      if (cnt != N) cout << " ";
    }
    if (cnt == N) break;
  }
  cout << endl;
  return 0;
}



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

int main(){
    string S,T;
    cin>>S>>T;
    for(int i=0;i<S.length();i++){
        if(S.at(i)!=T.at(i)){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;


}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define INF 1e9
#define endl '\n'
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); --i)
#define FORE(i, a, b) for (int i = (a), e = (b); i < e; ++i)
#define RFORE(i, a, b) for (int i = (b)-1, e = (a); i >= e; --i)
#define ALL(x) (x).begin(), (x).end()
#define SORT(c) sort((c).begin(), (c).end())
#define SORTR(c) sort((c).begin(), (c).end(), greater<int>())
using namespace std;
typedef long long ll;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    cout << max(0, min(B, D) - max(A, C)) << endl;
}


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

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORTASC(c) sort((c).begin(),(c).end())
#define SORTDESC(c,t) sort((c).begin(),(c).end(), std::greater<t>());
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define VMAX(a) *max_element(ALL(a))
#define VMIN(a) *min_element(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double PI  = acos(-1.0);
const long long MOD = 1000000007;

template <class T, class S>
using umap = std::unordered_map<T, S>;
using ll = long long;
using namespace std;

int main() {
    ll n;
    ll p[200010];
    string s;
  
    cin >> n >> s;

    if (s.length() > n){
        cout << s.substr(0, n) + "..." << endl;
    } else {
        cout << s << endl;
    }

    return 0;
}

Measured memory_bytes: 3600
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
#define FAST  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ll long long
#define ar array 
 
 
int main() {
	FAST;
 
	//int t;
	//cin >> t;
	//while(t--) 
	{
		int n;
		cin>>n;
		if(n%1000==0)
		{
			cout<<0<<'\n';
		}
		else
		{
			cout<<1000-n%1000<<'\n';
		}
	}
}


Measured memory_bytes: 3644
#include<algorithm>
#include<bitset>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

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

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

// フラグ生成 (need bitset)
// char to int
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

const int FLAG_NUM = 9;
// 1023 => 00111 11111 ではなく
//         11111 11100 
vector<int> num_to_flags(int x){
    stringstream ss;
    ss << static_cast<std::bitset<FLAG_NUM> >(x);
    string s = ss.str();
    vector<int> V(FLAG_NUM);
    FOR(i, 0, FLAG_NUM){
        V[i] = ctoi(s[FLAG_NUM-i-1]);
    }
    return V;
}

// "1+1+1"
ll eval(string formula){
    // 式を評価
    ll sum = 0;
    ll current = 0;
    for(char c : formula){
        if(c=='+'){
            sum += current;
            current = 0;
        }
        else{
            current = 10 * current + ctoi(c);
        }
    }
    sum += current;
    return sum;
}

ll calc(string s, vector<int> flags){
    stringstream ss;
    FOR(i, 0, s.size()-1){
        ss << s[i];
        if(flags[i]==1){
            ss << '+';
        }
    }
    ss << s.back();
    string formula = ss.str();
    return eval(formula);
}

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

    // input
    string s;
    cin >> s;

    ll L = s.size();
    ll sum = 0;
    FOR(i, 0, pow(2, L-1)){
        auto flags = num_to_flags(i);
        sum += calc(s, flags);
    }

    p(sum);
    
    return 0;
}

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

using  namespace std;

int main(){
    int N, count=0, flag=0;
    char check=NULL;
    string S;
    cin >> N;
    cin >> S;
    for(int i=0;i<N;i++){
        if(check!=S[i]){
            count++;
            check=S[i];
        }
    }
    cout << count << endl;
}


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

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

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

const long long INF = 1LL << 60;

long long dp[110000];

int main()
{
  int N;
  cin >> N;
  for (int i = 0; i < 110000; i++)
    dp[i] = INF;

  dp[0] = 0;
  for (int i = 0; i <= N; i++) {
    for (int j = 2; j <= 3; j++) {
      for (int k = 0; k <= 6; k++) {
        if (i + pow(3*j, k) > 100000)
          continue;
        chmin(dp[i + int(pow(3 * j, k))], dp[i] + 1);
      }
    }
  }
  cout << dp[N] << endl;
}

// dp[i]はi円払うのに最適なコストとする
// 配るDPで考える。dp[i]から到達できるのは高々dp[i + pow(3*j, k)]しかないので三重ループ　j=2, 3, k = 0〜6　pow(3*j, k) が > 100000となるときはcontinue これとdp[i] + 1をchmin


Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define ll long long
#define inf 1000000000
#define mp make_pair
#define pii pair<int,int>
#define pb push_back
#define r1 rt<<1
#define r2 rt<<1|1
#define ri register int
#define rep(i,a,b) for(ri i=(a);i<=(b);++i)
#define rep2(i,a,b,c) for(ri i=(a);i<=(b);i+=(c))
#define REP(i,a,b) for(ri i=(a);i>=(b);--i)
#define REP2(i,a,b,c) for(ri i=(a);i>=(b);i-=(c))
using namespace std;

const int N=205;
bool vis[N],ok=1;
int d[N],n,g[N][N];
inline void dfs(ri u){
	vis[u]=1;
	rep(v,1,n){
		if(!g[u][v]) continue;
		if(vis[v]){
			if((d[u]+d[v])&1) continue;
			ok=0;break;
		}
		d[v]=d[u]+1;dfs(v);
	}
}

int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	ios::sync_with_stdio(false);
	cin>>n;
	rep(i,1,n){
		rep(j,1,n){
			char c;cin>>c;
			g[i][j]=(c=='1');
		}
	}
	dfs(1);
	if(!ok){
		cout<<-1;
		return 0;
	}
	ri ans=0;
	rep(i,1,n)
		rep(j,1,n)
			if(!g[i][j])g[i][j]=inf;
	rep(k,1,n)
		rep(i,1,n)
			rep(j,1,n)
				if(i!=j&&i!=k&&j!=k) g[i][j]=min(g[i][j],g[i][k]+g[k][j]);
	rep(i,1,n)
		rep(j,1,n)
			if(g[i][j]<inf) ans=max(ans,g[i][j]);
	cout<<ans+1;
	return 0; 
}

Measured memory_bytes: 512
#include <stdio.h>

#define SIZE 128

int N;
int bubbleSort(int *A);

int main(void){
  int i, A[SIZE] ={0};
  scanf("%d", &N);
  for (i = 0; i < N; i++)
    scanf("%d", &A[i]);
  int cnt = bubbleSort(A);

  for (i = 0; i < N; i++) {
    printf("%d", A[i]);
    if (i < N - 1)
      printf(" ");
  }
  printf("\n%d\n", cnt);
  return 0;
}

int bubbleSort(int *A){
  int flg = 1, i = 0, j, tmp, cnt = 0;
  while(flg) {
    flg = 0;
    for (j = N - 1; i < j; j--) {
      if (A[j] < A[j - 1]) {
	tmp = A[j];
	A[j] = A[j - 1];
	A[j - 1] = tmp;
	cnt++;
      }
      flg = 1;
    }
    i++;
  }
  return cnt;
}

Measured memory_bytes: 604
int main(void)
{
    char O[51];
    char E[51];
    char P[102]="AAA";
    int i;
    
    scanf("%s",O);
    scanf("%s",E);
    for(i=0;i<100;i++){
        if(i%2==0){
            P[i]=O[i/2];
        }else{
            P[i]=E[i/2];
            
        }
    }
        printf("%s",P);
    return 0;
   
}

Measured memory_bytes: 128
#include<stdio.h>
int main(void)
{
	int w,n,z,x,i,k,c;
	while(1){
		scanf("%d",&n);
		 if(n==0) break;
	c=0;
	k=0;	 
	for(i=0;i<12;i++){
			scanf("%d %d",&z,&x);
			k+=z-x;
			if(k>=n){
				c++;
			}
	}
	if(k<n){
		printf("NA\n");
	}
	else{
		printf("%d\n",12-c+1);
	}
    }	
	return 0;
}

Measured memory_bytes: 1040
#include <iostream>
#include <map>
using namespace std;
typedef long long ll;
ll n;
map<string, ll> mp;
string str[110];
int main(void){
    // Your code here!
    cin >> n;
    for (ll i = 0; i < n; i++) cin >> str[i];
    for (ll i = 0; i < n; i++) mp[str[i]]++;
    for (auto itr = mp.begin(); itr != mp.end(); ++itr){
        if (itr->second > 1) {
            cout << "No" << endl;
            return 0;
        }
    }
    for (ll i = 1; i < n; i++){
        if (str[i - 1][str[i - 1].length() - 1] != str[i][0]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
n,m = list(map(int,input().split()))
ks = [list(map(int,input().split())) for i in range(m)]
p = list(map(int,input().split()))

ans = 0
for i in range(2**n):
    flag = True
    for j in range(m): #電球
        cnt = 0
        for k in range(1,len(ks[j])):
            w = ks[j][k]
            if i >> (w-1) & 1 :
                cnt+=1
        if cnt%2 != p[j]:
            flag = False
    if flag:
        ans+=1
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;

int main(){
  int k;
  char s[101];
  cin >> k >> s;
  int sl = strlen(s);
  if(sl <= k) cout << s;
  else {
    for (int i = 0; i < k; i++) {
      cout << s[i];
    }
    cout << "...";
  }
  cout << endl;
  return 0;
}

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

//a,b,c
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a>b){
        int tmp=a;
        a=b;
        b=tmp;
    }
    if(b>c){
        int tmp=b;
        b=c;
        c=tmp;        
    }
    if(a>b){
        int tmp=a;
        a=b;
        b=tmp;        
    }
    //cout<<a<<b<<c<<endl;
    if(c==a+b)  cout<<"Yes"<<endl;
    else        cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

int N, A, B, used[100], rings[100], G[100][199];

int rec(int pos)
{
	int ret = 1; used[pos] = 1;

	for(int i = 0; i < rings[pos]; i++)
	{
		if(!used[G[pos][i]])
		{
			ret = max(ret, rec(G[pos][i]) + 1);
		}
	}

	used[pos] = 0;

	return ret;
}

int main()
{
	int N, A, B;

	while(true)
	{
		scanf("%d", &N);
 
		if(N == 0) { break; }

		memset(used, 0, sizeof(used));
		memset(rings, 0, sizeof(rings));

		for(int i = 0; i < N; i++)
		{
			scanf("%d", &A); A--;
			scanf("%d", &B); B--;

			G[A][rings[A]] = B; rings[A]++;
			G[B][rings[B]] = A; rings[B]++;
		}

		int nodes = 0;

		for(int i = 0; i < 100; i++)
		{
			if(rings[i])
			{
				nodes++;
			}
		}

		int ret = 0;

		for(int i = 0; i < 100; i++)
		{
			ret = max(ret, rec(i));

 			if(ret == nodes) break;
		}
 
		printf("%d\n", ret);
	}

	return 0;
}

Measured memory_bytes: 3156
ws = input()

hash_map = {}

for w in ws:
    if w in hash_map.keys():
        hash_map[w] += 1
    else:
        hash_map[w] = 1

is_beatiful = True
for k in hash_map.keys():
    if hash_map[k] % 2 != 0:
        is_beatiful = False

print("Yes" if is_beatiful else "No")


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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

signed main(){

	lli n,k;
	cin>>n>>k;

	vector<lli> a(n),f(n);
	REP(i,0,n)cin>>a[i];
	REP(i,0,n)cin>>f[i];

	sort(a.begin(),a.end());
	sort(f.rbegin(),f.rend());

	lli small = 0, large = 1e18;

	while(small<large)
	{
		lli middle = (small+large)/2;

		vector<lli> ans;
		REP(i,0,n)ans.push_back(middle/f[i]);

		lli cnt=0;
		REP(i,0,n){
			cnt += max(0LL,a[i]-ans[i]);
		}

		if(cnt<=k){
			large = middle;
		}
		else{
			small = middle+1;
		}
	}
	cout<<large<<endl;

	return 0;
}

Measured memory_bytes: 7028
import sys
from collections import defaultdict, deque
import math

# import copy
from bisect import bisect_left, bisect_right
# import heapq

# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline

getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = 10 ** 20
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)

def solve():
    a, b = getList()
    if a == b:
        print("Draw")
        return
    if a == 1:
        print("Alice")
        return
    if b == 1:
        print("Bob")
        return
    if a > b:
        print("Alice")
    else:
        print("Bob")

def main():
    n = getN()
    for _ in range(n):
        solve()


if __name__ == "__main__":
    # main()
    solve()

Measured memory_bytes: 65644
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<cassert>
#include<queue>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
struct cww {
    cww() {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;

const int MAXN = 100100;
const int MOD = 1e9+7;
int cnt[MAXN];

int solve(int N) {
    ll ans = 1;
    if (N % 2 == 1) {
        if (cnt[0] != 1)
            return 0;
        for (int i = 2; i < N; i += 2) {
            if (cnt[i] != 2)
                return 0;

            ans*=2;
            ans%= MOD;
        }
        return ans;
    } else {
        for (int i = 1; i < N; i+=2) {
            if (cnt[i] != 2)
                return 0;

            ans*=2;
            ans%=MOD;
        }
        return ans;
    }
}

int main() {
    int N;
    cin >> N;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        cnt[a]++;
    }
    cout << solve(N) << endl;
    return 0;
}



Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(any{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

int main() {
	long long a;
    scanf("%lld",&a);
    long long b;
    scanf("%lld",&b);
    long long x;
    scanf("%lld",&x);

	cout << setprecision(20);
	if (x <= a*a*b/2){
		double y = 2.0*x/(a*b);
		cout << atan(b/y) * 180 / M_PI;
	} else {
		double y = 2.0*x/(a*a) - b;
		cout << atan((b-y)/a) * 180 / M_PI;
	}
	return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <math.h>
#include <string.h>
#include <string>
#include <queue>
#include <stack>
using namespace std;
typedef long long int ll;
int size[4];
char a[110];
char b[110];
char c[110];
int pt[4]={1,1,1,1};
int curplay;
int main(void)
{
	scanf("%s",&a[1]);
	scanf("%s",&b[1]);
	scanf("%s",&c[1]);
	size[1]=strlen(&a[1]);
	size[2]=strlen(&b[1]);
	size[3]=strlen(&c[1]);
	curplay=1;
	while(size[curplay]!=0)
	{
		size[curplay]--;
		pt[curplay]++;
		if(curplay==1)
		{
			curplay=a[pt[curplay]-1]-'a'+1;
		}
		else if(curplay==2)
		{
			curplay=b[pt[curplay]-1]-'a'+1;
		}
		else if(curplay==3)
		{
			curplay=c[pt[curplay]-1]-'a'+1;
		}
	}
	printf("%c",curplay+'A'-1);
}



Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.Closeable;
import java.io.IOException;
import java.util.NoSuchElementException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author HBonsai
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ASecurity solver = new ASecurity();
        solver.solve(1, in, out);
        out.close();
    }

    static class ASecurity {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            String S = in.next();
            for (int i = 1; i < S.length(); i++) {
                if (S.charAt(i) == S.charAt(i - 1)) {
                    out.println("Bad");
                    return;
                }
            }
            out.println("Good");
        }

    }

    static class FastScanner implements Closeable {
        private final InputStream in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;

        public FastScanner(InputStream in) {
            this.in = in;
        }

        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }

        private int readByte() {
            if (hasNextByte()) return buffer[ptr++];
            else return -1;
        }

        private static boolean isPrintableChar(int c) {
            return 33 <= c && c <= 126;
        }

        public boolean hasNext() {
            while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
            return hasNextByte();
        }

        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while (isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }

        public void close() {
            try {
                in.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

    }
}



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

int main()
{
string v[3];
cin >> v[0] >> v[1] >> v[2] ;
sort(v,v+3);
do{
bool a[5000]={};
bool b[5000]={};
bool c[5000]={};
ll aa=v[0].size();
ll bb=v[1].size();
ll cc=v[2].size();
rep(i,aa)rep(j,bb)if(i+j<aa&&v[0][i+j]!='?'&&v[1][j]!='?'&&v[0][i+j]!=v[1][j]){a[i]=1;break;}
rep(i,aa)rep(j,cc)if(i+j<aa&&v[0][i+j]!='?'&&v[2][j]!='?'&&v[0][i+j]!=v[2][j]){b[i]=1;break;}
rep(i,bb)rep(j,cc)if(i+j<bb&&v[1][i+j]!='?'&&v[2][j]!='?'&&v[1][i+j]!=v[2][j]){c[i]=1;break;}

rep(i,2001)rep(j,2001){
  ll f[3]={aa,bb+i,cc+i+j};
  sort(f,f+3);
  if(!a[i]&&!b[i+j]&&!c[j])ans=min(ans,f[2]);
}
}while(next_permutation(v,v+3));
cout << ans << endl;
return 0;
}

Measured memory_bytes: 384
package main

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

type UnionFind struct {
	Parents []int
	Sizes   []int
}

func NewUnionFind(n int) (uf UnionFind) {
	initParents := make([]int, n)
	initSizes := make([]int, n)
	for i := 0; i < n; i++ {
		initParents[i] = i
		initSizes[i] = 1
	}
	uf.Parents = initParents
	uf.Sizes = initSizes
	return
}

func (uf UnionFind) Root(x int) int {
	if uf.Parents[x] == x {
		return x
	}
	uf.Parents[x] = uf.Root(uf.Parents[x])
	return uf.Parents[x]
}

func (uf UnionFind) Unite(x, y int) bool {
	rootX := uf.Root(x)
	rootY := uf.Root(y)
	if rootX == rootY {
		return false
	}
	uf.Parents[rootX] = rootY
	uf.Sizes[rootY] = uf.Sizes[rootY] + uf.Sizes[rootX]
	return true
}

func (uf UnionFind) MaxSize() (result int) {
	for _, val := range uf.Sizes {
		if result < val {
			result = val
		}
	}
	return
}

func friends(N int, As [][2]int) int {
	uf := NewUnionFind(N)
	for _, val := range As {
		uf.Unite(val[0]-1, val[1]-1)
	}
	ans := uf.MaxSize()
	return ans
}

func main() {
	stdin := bufio.NewScanner(os.Stdin)
	stdin.Scan()
	nm := strings.Split(stdin.Text(), " ")
	N, _ := strconv.Atoi(nm[0])
	M, _ := strconv.Atoi(nm[1])
	var As [][2]int
	for i := 0; i < M; i++ {
		stdin.Scan()
		pair := strings.Split(stdin.Text(), " ")
		var element [2]int
		element[0], _ = strconv.Atoi(pair[0])
		element[1], _ = strconv.Atoi(pair[1])
		As = append(As, element)
	}
	result := friends(N, As)
	fmt.Println(result)
}


Measured memory_bytes: 13296
<?php
fscanf(STDIN, "%d", $max);
fscanf(STDIN, "%d %d", $base, $wish);
$data = trim(fgets(STDIN));

$base *= 1000;
$wish *= 1000;
$checkList = explode( " ", $data );

$res = 0;
$cc = abs($base- $checkList[0]*6-$wish);
for( $i=1; $i<$max; $i++ )
{
   $check = abs($base-$checkList[$i]*6 -$wish);
  if( $cc > $check )
  {
    $res = $i;
    $cc = $check;
  }
 
}

echo $res+1;


Measured memory_bytes: 4604
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        k: usize
    };

    let mut v = vec![1.0; n];

    for i in 1..=n {
        let mut cur = i;
        let mut count = 0;

        if cur >= k {
            break;
        }

        while cur < k {
            cur *= 2;
            count += 1;
        }

        v[i - 1] = 1.0 / 2i32.pow(count) as f64;
    }

    println!("{}", 1.0 / n as f64 * v.iter().sum::<f64>());
}


Measured memory_bytes: 2768
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

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

int main() {
  int n;
  cin>>n;
  
  int C[10][10];
  rep(i,10){
    rep(j,10) C[i][j]=0;
  }
  for(int i=1;i<=n;i++){
    int a=i;
    while(a>=10) a/=10;
    C[a][i%10]++;
  }
  
  int sum=0;
  rep(i,10){
    rep(j,10){
      sum+=C[i][j]*C[j][i];
    }
  }
  
  cout<<sum<<endl;
  
  return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
a = []
for i in range(m):
  x,y = map(int,input().split())
  x-=1
  y-=1
  a.append([x,y])
aru = [0]*n
aru[0] = 1
kazu = [1]*n
for i in range(m):
  x,y = a[i]
  if  aru[x]== 1:
    aru[y] = 1
  kazu[x]-=1
  if kazu[x] == 0:
    aru[x] = 0
  kazu[y]+=1
print(sum(aru))

Measured memory_bytes: 21068
#include <iostream>
#include <stdio.h>
using namespace std;

int main(){
  double a,b,c,d,e,f,x,y;
  while(cin >> a >> b >> c >> d >> e >> f){
    x = (c*e - b*f) / (a*e - b*d);
    y = (c*d - a*f) / (b*d - a*e);
    if(x == 0) x = 0;
    if(y == 0) y = 0;
    printf("%.3f %.3f\n",x,y);
  } 
  return 0;
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

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

    int N, K;
    cin >> N >> K;
    // K-1人が1個ずつもらいあと残りを一人がもらえばいい。
    // N - (K-1)  が答え

    if(K > 1){
        cout << N - (K-1) - 1 << endl;
    }else{
        cout << 0 << endl;
    }

    return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cctype>
#include <iostream>
#include <string>
#include <vector>
#define ll long long
#define rgi register int
#define rgl register long long
#define il inline

using namespace std;

const int oo = 0x3f3f3f3f;

il int read()
{
	rgi x = 0, f = 0, ch;
	while(!isdigit(ch = getchar())) f |= ch == '-';
	while(isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
	return f ? -x : x;
}

int main()
{
	int n = read();
	if(n & 1)
		printf("%.6f", (double)(n + 1 >> 1)/(n));
	else
		printf("%.6f", (double)(n >> 1)/(n));
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m;
int a[100];
int cost[100]={1000000,2,5,5,4,5,6,3,7,6};
string dp[20000];//价值为i,最大数值 
char temp[10000];
char *tt=temp;
map<string,string> maxies;
bool better(string a,string b){//is a larger in b?(not string comparison)
	if(a.size()!=b.size())
	  return a.size()>b.size();
	return (strcmp(a.data(),b.data())<0?false:true);
}
string tostr(int x){
	string ret="";
	while(x!=0){
		ret=ret+(char)(x%10+'0');
		x/=10;
	}
	return ret;
}
string gmax(string s){
	if(maxies.count(s))
	   return maxies[s];
	if(s.size()==1)
	   return maxies[s]=s;
	string tt=s;
	tt=(char*)(s.data());
	sort(temp,temp+s.size());
	reverse(temp,temp+s.size());
	return maxies[tt]=s;
}
int main()
{
	cin>>n>>m;
	for(int i=1;i<=m;i++)
	   cin>>a[i];
	sort(a+1,a+m+1);
	if(binary_search(a+1,a+m+1,1)){
		if(n%2==0){
		    for(int i=1;i<=n/2;i++)
		       cout<<1;
			return 0;
		}
	}
	for(int i=0;i<=n;i++)
	   dp[i]="";
	int mcost=cost[a[1]];
	for(int i=1;i<=m;i++){
	    dp[cost[a[i]]]=tostr(a[i]);
		mcost=min(mcost,cost[a[i]]);
	}
	for(int i=0;i<=n;i++){
		dp[i]=gmax(dp[i]);
		for(int j=1;j<=m;j++){
			if(i-cost[a[j]]<mcost)
			   continue;
			if(better(gmax(dp[i-cost[a[j]]]+tostr(a[j])),dp[i])&&a[j]){
			    dp[i]=gmax(dp[i-cost[a[j]]]+tostr(a[j]));
			}
		}
		dp[i]=gmax(dp[i]);
	}
	string ss=gmax(dp[n]);
	printf("%s\n",ss.data());
	return 0;
}


Measured memory_bytes: 238080