akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define RFOR(i,a,b) for(int i = (int)(b-1);i>=(int)(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;
 
signed main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(20);
  
  string s;
  cin >> s;

  int na = 0, nb = 0, nc = 0;

  REP(i, s.length()){
    if(s[i] == 'a'){
      na++;
    }
    else if(s[i] == 'b'){
      nb++;
    }
    else{
      nc++;
    }
  }

  vec n = {na, nb, nc};

  bool f = true;
  REP(i, n.size()) FOR(j, i + 1, n.size()){
    f &= (abs(n[j] - n[i]) <= 1);
  }

  cout << (f ? "YES" : "NO") << endl;

  return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <vector>
using namespace std;

int N,P[200200]; vector<int> G[200200];

const long long mod = 1000000007;
struct Data{
	long long s,a,l; bool d;
	Data operator *(Data t){
		Data r;
		r.s = s * t.s % mod;
		r.a = (a * t.l + t.a * l) % mod;
		r.l = l * t.l % mod;
		r.d = true;
		return r;
	}
};

vector<Data> go(int x)
{
	vector<Data> ret;
	for (auto y : G[x]){
		vector<Data> nxt = go(y);
		if (ret.size() < nxt.size()) swap(ret,nxt);
		for (int i=(int)ret.size()-1,j=(int)nxt.size()-1;j>=0;i--,j--){
			ret[i] = ret[i] * nxt[j];
		}
	}

	for (int i=(int)ret.size()-1;i>=0;i--){
		if (!ret[i].d) break;
		ret[i].l = (ret[i].s + mod - ret[i].a) % mod;
		ret[i].d = false;
	}
	ret.push_back({2,1,1,false});
	return move(ret);
}

long long fpow(long long a, long long p)
{
	long long r = 1;
	while (p){
		if (p & 1) r = r * a % mod;
		a = a * a % mod;
		p /= 2;
	}
	return r;
}

int main()
{
	scanf ("%d",&N);
	for (int i=1;i<=N;i++){
		scanf ("%d",&P[i]);
		G[P[i]].push_back(i);
	}

	auto p = go(0);

	long long ans = 0, all = fpow(2,N+1);
	for (auto &d : p) ans = (ans + d.a * fpow(d.s,mod-2)) % mod;
	ans = ans * all % mod;
	printf ("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 47088
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;
typedef pair<string, ll> psl;

ll N, Q, T[100000];
string S[100000];

int main(void) {
  cin >> N >> Q;
  REP(i, 0, N) cin >> S[i] >> T[i];

  queue<psl> q;
  REP(i, 0, N) q.push(psl(S[i], T[i]));

  ll time = 0;
  while(q.size()) {
    string s = q.front().first;
    ll t = q.front().second;
    q.pop();

    if(t <= Q) {
      time += t;
      cout << s << " " << time << endl;
    } else {
      time += Q;
      q.push(psl(s, t - Q));
    }
  }
}

Measured memory_bytes: 7316
# include <bits/stdc++.h>
using namespace std;
int main ()
{
	int a,b,c;
	cin>>a>>b>>c;
	long long x=a+b;
	long long  ans;
	if (x==c)
	  { 
	    ans=x+b;
		printf ("%lld\n",ans);	
	  }
	if (x<c)
	  {
	  	ans=x+b+1;
	  	printf ("%lld\n",ans);
	  }
	if (x>c)
	  {
	  	ans=b+c;
	  	printf ("%lld\n",ans);
	  }
 } 

Measured memory_bytes: 256
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
if N % 2 == 1:
    print(0)
    sys.exit()
ans = 0
i = 1
while True:
    div = 5 ** i
    cnt = N // div
    cnt //= 2
    if cnt == 0:
        break
    ans += cnt
    i += 1
print(ans)

Measured memory_bytes: 9184
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner s=new Scanner(System.in);
    int n=s.nextInt();
    int arr[][]=new int[n][n];
     for(int i=0;i<n;i++){
        for(int j=0;j<2;j++){
          arr[i][j]=s.nextInt();
        }
    }
    int flag=0;
    for(int i=0;i<=n-3;i++){
        if(arr[i][0]==arr[i][1] && arr[i+1][0]==arr[i+1][1] && arr[i+2][0]==arr[i+2][1]){
          flag=1;
          break;
    }
   }
    
    if(flag==1)
    System.out.println("Yes");
    else
     System.out.println("No");
  }
}


Measured memory_bytes: 36196
#include <atcoder/dsu>
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    ll n,q;
    cin >> n >> q;
    atcoder::dsu uf(n);
    while(q--){
        ll t,u,v;
        cin >> t >> u >> v;
        if(t==0){
            uf.merge(u,v);
        }else{
            if(uf.same(u,v)){
                print(1);
            }else{
                print(0);
            }
        }
    }
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 3816
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <bitset>
#include <numeric>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[8]={ 0, 1, 0,-1, 1, 1,-1,-1}; // x軸方向への変位
ll dy[8]={ 1, 0,-1, 0, 1,-1, 1,-1}; // y軸方向への変位

int main(void) {
    ll h, w;
    cin >> h >> w;
    string s[h];
    ll ans = 0;
    for(ll i = 0; i < h; i++)
        cin >> s[i];
    for(ll i = 0; i < h; i++){
        for(ll j = 0; j < w; j++){
            if(s[i][j]=='#') continue;
            queue<p> que;
            vector<vector<ll>> dist(h, vector<ll>(w, -1));
            que.push(p(i, j));
            dist[i][j] = 0;
            while(!que.empty()){
                p c = que.front();
                que.pop();
                ll a = c.first, b = c.second;
                for(ll k = 0; k < 4; k++){
                    ll x = a+dx[k], y = b+dy[k];
                    if(x<0 || x>=h || y<0 || y>=w) continue;
                    if(dist[x][y]!=-1 || s[x][y]=='#') continue;
                    dist[x][y] = dist[a][b]+1;
                    ans = max(ans, dist[x][y]);
                   // cout << x <<  " " << y << " " << dist[x][y] << endl;
                    que.push(p(x, y));
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int key=0;
int main(){
    string S;
    cin>>S;
    for(int i=0;i<4;i++){
        if(i>0&&S[i]==S[i-1])
            key=1;
    }
    if(key==0)
    cout<<"Good"<<endl;
    else
    cout<<"Bad"<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#define mod 1000000007
#define MAX 200050
typedef long long ll;
using namespace std;

int main(){
  double A[MAX], S[MAX];
 // double sum = 0;
  int N; cin >> N;
  for(int i=0;i<N;i++){
    cin >> A[i];
    //sum += A[i];
  }
  S[0] = A[0];
  for(int i=1;i<N;i++){
    S[i] = S[i-1] + A[i];
  }
  double mid = S[N-1] / 2.0;
  double s = fabs(S[0] - mid);
  int p = 0;
  for(int i=0;i<N;i++){
    if(fabs(S[i] - mid) < s){
      s = fabs(S[i] - mid);
      p = i;
    }
  }
  cout << (int)(fabs(S[p] - mid) * 2.0) << endl;
  return 0;
}
    

Measured memory_bytes: 3328
#include <stdio.h>
#include <string.h>

int main(){
  int i,j,N,a,b,minj,result=0;
  char A[36][3],B[36][3],C[36][3];
  
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%s",A[i]);
  }
  

  for(i=0;i<N;i++){
    strcpy(C[i],A[i]);
  }
  
  for(i=0;i<N;i++){
    for(j=N-1;j>=i+1;j--){
      if(A[j][1]<A[j-1][1]){
	strcpy(B[j],A[j-1]);
	strcpy(A[j-1],A[j]);
	strcpy(A[j],B[j]);
      }
    }
  }
  for(i=0;i<N;i++){
    for(j=i+1;j<N;j++){
      for(a=0;a<N;a++){
	for(b=a+1;b<N;b++){
	  if(C[i][1]==C[j][1] && strcmp(C[i],A[b])==0 && strcmp(C[j],A[a])==0)
	    result=1;
	}
      }
    }
  }

  for(i=0;i<N-1;i++){
    printf("%s ",A[i]);
  }
  printf("%s\n",A[N-1]);
  if(result==1){
    printf("Not stable\n");
  }
  else printf("Stable\n");


  
  result=0;
  
   for(i=0;i<N;i++){
    strcpy(A[i],C[i]);
  }
  
  for(i=0;i<N;i++){
    minj=i;
    for(j=i;j<N;j++){
      if(A[j][1]<A[minj][1]){
	minj=j;
      }
    }

    strcpy(B[i],A[i]);
    strcpy(A[i],A[minj]);
    strcpy(A[minj],B[i]);

  }
    for(i=0;i<N;i++){
      for(j=i+1;j<N;j++){
	for(a=0;a<N;a++){
	  for(b=a+1;b<N;b++){
	    if(C[i][1]==C[j][1] && strcmp(C[i],A[b])==0 && strcmp(C[j],A[a])==0)
	      result=1;
	  }
	}
      }
    }

    for(i=0;i<N-1;i++){
      printf("%s ",A[i]);
    }
   printf("%s\n",A[N-1]);
    if(result==1){
    printf("Not stable\n");
    }
    else printf("Stable\n");
    
  return 0;
}
 

Measured memory_bytes: 624
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<string>
using namespace std;

long gcd(long x, long y) { if (x > y) { return gcd(y, x); } long r; while (y != 0) { r = x % y; x = y; y = r; }return x; }
long lcm(long x, long y) { return(x / gcd(x, y)) * y; }
void indexsort(long* first, long* last, long* func) { sort(first, last, [&](long a, long b) {return func[a] < func[b]; }); }
//--------------------

int main() {

	string res = "No";
	
	string S; cin >> S;
	long mylength = S.length();
	bool isN = false, isS = false, isW = false , isE = false; //少なくとも一つ出てくるか?

	for (int i = 0; i < mylength; i++) {

		switch (S[i]){
		case 'N': isN = true; break;
		case 'S': isS = true; break;
		case 'W': isW = true; break;
		case 'E': isE = true; break;
		}
	}

	if (isN == isS && isW == isE) res = "Yes";

	cout << res << endl;

}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(a>=-100&&a<=100&&b>=-100&&b<=100&&c>=-100&&c<=100)
    {
        if(a==b&&c!=a)
            cout<<c;
        else if(a==c&&b!=a)
            cout<<b;
        else if(b==c&&a!=b)
            cout<<a;
    }
    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
AB = [tuple(map(int, input().split())) for _ in range(N)]
AB.sort(key=lambda x: x[0])

ans = 0
bought = 0
for a, b in AB:
    m = min(M - bought, b)
    bought += m
    ans += a * m
print(ans)

Measured memory_bytes: 23612
using System;
using System.Linq;


namespace AtC
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] time = new int[5];
            for (int i = 0; i < 5; i++)
                time[i] = int.Parse(Console.ReadLine());
            var newTime = time.OrderByDescending(val => (val - 1) % 10).ToArray();
            for (int i = 0; i < 4; i++)
            {
                var buf = (newTime[i] - 1 + 10);
                newTime[i] = buf / 10 * 10;
            }

            Console.WriteLine(newTime.Sum());
        }
    }
}

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

int main() {
	ll S, W;
	cin >> S >> W;
	if (S > W)
		cout << "safe" << endl;
	else
		cout << "unsafe" << endl;
}

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

ll f(ll x, ll y)
{
	ll a, b, c;
	ll S = x * y;
	ll ans = 1e18; 
	rep(i, x)
	{
		a = i * y; 
		b = (x - i) / 2 * y;
		c = S - a - b;
		ll tmp = max(max(a, b), c) - min(min(a, b), c);
		ans = min(ans, tmp);
		b = (S - a) / (x - i) / 2 * (x - i);
		c = S - a - b;
		tmp = max(max(a, b), c) - min(min(a, b), c);
		ans = min(ans, tmp);
	}
	return ans;
}

signed main(void)
{
	ll h, w;
	cin >> h >> w;
	cout << min(f(h, w), f(w, h)) << endl;
	return 0;
}


Measured memory_bytes: 256
n,q = map(int, input().split())
n += 1
list_queue = []
def initialize(head,tail):
    head = 0
    tail = 0
    return (head,tail)
def enqueue(Q,MAX,head,tail,x):
    Q[tail] = x
    if tail + 1 == MAX:
        tail = 0
    else:
        tail += 1
    return (head, tail)
def dequeue(Q,MAX,head,tail):
    x = Q[head]
    if head + 1 == MAX:
        head = 0
    else:
        head += 1
    return (x,head,tail)

head = 0
tail = 0
list_queue = [0] * n
for i in range(0,n-1):
    head, tail = enqueue(list_queue,n,head,tail,list((map(str, input().split()))))
ans = 0

list_zero = []
for i in range(0,n):
    list_zero.append(0)
#while True:
while (head != tail):
    x,head,tail = dequeue(list_queue,n,head,tail)
    if int(x[1]) <= q:
        ans += int(x[1])
        x[1] = 0
        print(x[0], ans)
    else:
        ans += q
        x[1] = int(x[1]) - q
        head, tail = enqueue(list_queue,n,head,tail,x)


Measured memory_bytes: 14580
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;


public class Test
{	
    public static void Main()
	{
	    int[] nums = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        
        int a = Math.Abs(nums[0]-nums[1]);
        int b = Math.Abs(nums[0]-nums[2]);
        if(a < b) Console.WriteLine("A");
        else Console.WriteLine("B");
        
	}
}

Measured memory_bytes: 13268
N = int(input())
robot = [list(map(int,input().split())) for _ in range(N)]

L = [[0,0] for _ in range(N)]
for i in range(N):
    L[i][0] = robot[i][0]-robot[i][1]
    L[i][1] = robot[i][0]+robot[i][1]-1

L.sort(key = lambda x:x[1])

a = 0
b = -float('inf')

for i in range(N):
    if b < L[i][0]:
        a += 1
        b = L[i][1]

print(a)

Measured memory_bytes: 78296
n = int(input())
s = input()
cnt = [0, 0]
add = [0, 0]
ans = ''
for i in range(n):
    if s[i] == ')':
        cnt[0] += 1
        if cnt[0] > cnt[1]:
            add[1] += 1
            cnt[1] += 1
    else:
        cnt[1] += 1

print('(' * add[1] + s + ')'*(cnt[1] -cnt[0]))


Measured memory_bytes: 3060
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);


ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b){
  ll r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return b;
}


ll LCM(ll a,ll b){
  ll c=a,d=b,r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return c/b*d;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

vector<pair<char,ll>> runlength(string s,vector<pair<char,ll>> p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
    return p;
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
  return p;
}



/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  string s,ans="";
  ll n;
  cin>>s>>n;
  rep(i,(s.size()+n-1)/n){
    ans+=s[i*n];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import static java.lang.Character.*;

import java.util.Scanner;

class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		String str = scan.nextLine();
				for(int i=0; i<str.length(); i++){
					char ch = str.charAt(i);
					if(isLowerCase(ch) == true){
						ch = toUpperCase(ch);
					}else{
						ch = toLowerCase(ch);
					}
					System.out.print(ch);
				}
				System.out.print("\n");
	}

}

Measured memory_bytes: 17424
#include<bits/stdc++.h>
#define mx 100000
#define pb push_back
#define siz(v) v.size();
#define print(a) printf("%d",a)
#define sc1(a) scanf("%d",&a)
using namespace std;
 
typedef unsigned long  ull;
typedef long long int lli;
 
int main()
{
 	int n,m;
 	
 	cin>>n>>m;
 	int arr[n+1];
 	int sum=0;
 	for(int i=0;i<n;++i)
 	{
 		cin>>arr[i];
 		sum+=arr[i];
	}
 		
 	int cnt=0;
 	sort(arr,arr+n,greater<int>());
	double chk=(1/(float)(4*m))*sum;
	for(int i=0;i<n;++i)
	{
		if (chk<=arr[i]) cnt++;
		else
			break;
	}
	if (cnt>=m) cout<<"Yes\n";
	else cout<<"No\n";
 
 
 return 0;
 }

Measured memory_bytes: 256
N = int(input())
H = input().split(" ")
c = [10 ** 7 for i in range(N)]
c[0] = 0
c[1] = abs(int(H[0])-int(H[1]))
for i in range(N-2):
  c[i+2] = min(c[i]+abs(int(H[i])-int(H[i+2])),c[i+1]+abs(int(H[i+1])-int(H[i+2])))
print(c[len(c)-1])

Measured memory_bytes: 14064
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<functional>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
typedef long long int ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<signed(n);i++)
#define EREP(i,n) for(int i=1;i<=signed(n);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
//#define EVEL 1
#ifdef EVEL
#define DEB(X) cout << #X <<":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const ll MOD = 1000000007;
const ll INF = 9e14;
typedef std::pair<ll,ll> P;
struct edge{ int to,cost; };
#define VMAX 100000

ll N,M,X,K,Q;
ll A,B,C,D;

ll ans;
bool F=false;
string S,T,U;
int main(){
    cin>>A>>B>>C>>D;
    cout<<A+((C-A)-(D-B))<<" "
        <<B+((C-A)+(D-B))<<" "
        <<A-(D-B)<<" "
        <<B+(C-A)<<endl;
}

Measured memory_bytes: 256
// #pragma warning(disable:4996)
#include <memory.h>
#include <stdio.h>
#include <assert.h>

#include <list>
#include <bitset>
#include <string>
#include <map>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <cstdio>
#include <ctime>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <numeric>

using namespace std;

typedef long long int64;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int > vi;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<ll> vll;

#define ALL(x) (x).begin(), (x).end()
#define CLEAR(x) (x).clear()
#define RESET(x) memset((x), 0, sizeof (x))
#define MP(X,Y) make_pair(X,Y)//NOTES:MP(

#define FOR(i, b, e) for ( int i = (b); i < (e); ++i)
#define RE(i, n) FOR(i, 0, (n))
#define FOREACH(i, x, y) for ( int i = (x); i <= (y); ++i)

const ll maxn = (ll)77777;
const ll maxm = (ll)1e6 + 10;
const ll MOD = 786433;
const ll INF = 1e15;

int fast_read(){ int input; char c=0; while(c<33)c= getchar(); input=0; while(c>33){ input=input*10+c-'0'; c=getchar(); } return input; }

int main() {


	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

	int k, t;
	while (cin >> k >> t) {
		vi a[110];
		RE(i, t) {
			int x;
			cin >> x;
			a[x].push_back(i);
		}
		int p, q;
		vector<pair<pii, int>>match;
		while (true) {
			p = 100;
			while (p > 0 && a[p].empty()) --p;
			if (p <= 0) {
				break;
			}
			int t1 = a[p].back();
			a[p].pop_back();

			q = p;
			while (q > 0 && a[q].empty()) --q;
			if (q <= 0) {
				a[p].push_back(t1);
				break;
			}
			int t2 = a[q].back();
			a[q].pop_back();
			match.push_back(MP(MP(t1, t2), q));
			if (q < p) {
				a[p - q].push_back(t1);
			}
		}
		if (p > 0 && !a[p].empty()) {
			int tt = a[p].back();
			for (auto m : match) {
				if (m.first.first != tt && m.first.second != tt) {
					p -= m.second;
				}
			}
		}
		int ans = max(0, p - 1);
		cout << ans << endl;
	}

	// cout << (float)(clock() - start_time)/CLOCKS_PER_SEC << "s" << endl;
	return 0;
}


Measured memory_bytes: 256
use std::{cmp, io, mem};
use std::collections::HashSet;
use std::collections::VecDeque;

fn main() {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    let mut split = buf.split_whitespace();
    let (h, w): (usize, usize) = (split.next().unwrap().parse().unwrap(), split.next().unwrap().parse().unwrap());
    buf.clear();
    io::stdin().read_line(&mut buf).unwrap();
    let mut split = buf.split_whitespace();
    let (ch, cw): (usize, usize) = (split.next().unwrap().parse().unwrap(), split.next().unwrap().parse().unwrap());
    buf.clear();
    io::stdin().read_line(&mut buf).unwrap();
    let mut split = buf.split_whitespace();
    let (dh, dw): (usize, usize) = (split.next().unwrap().parse().unwrap(), split.next().unwrap().parse().unwrap());
    let s: Vec<_> = (0..h).map(|_| {
        buf.clear();
        io::stdin().read_line(&mut buf).unwrap();
        buf.trim_end().as_bytes().to_owned()
    }).collect();
    let mut queue = VecDeque::new();
    let mut next_queue = VecDeque::new();
    let mut seen = HashSet::new();
    queue.push_back((ch - 1, cw - 1));
    let mut cost = 0i64;
    'outer: loop {
        while let Some((x, y)) = queue.pop_front() {
            if (x, y) == (dh - 1, dw - 1) {
                break 'outer;
            }
            if s[x][y] == b'.' && seen.insert((x, y)) {
                if x != 0 {
                    queue.push_back((x - 1, y));
                }
                if y != 0 {
                    queue.push_back((x, y - 1));
                }
                if x != h - 1 {
                    queue.push_back((x + 1, y));
                }
                if y != w - 1 {
                    queue.push_back((x, y + 1));
                }
                for x in x.saturating_sub(2)..cmp::min(h, x + 3) {
                    for y in y.saturating_sub(2)..cmp::min(w, y + 3) {
                        next_queue.push_back((x, y));
                    }
                }
            }
        }
        cost += 1;
        if next_queue.is_empty() {
            cost = -1;
            break;
        }
        mem::swap(&mut queue, &mut next_queue);
    }
    println!("{}", cost);
}


Measured memory_bytes: 24356
import numpy as np

N,M,C = map(int, input().split())
B = np.array([int(i) for i in input().split()])
A = np.array([[int(i) for i in input().split()] for i in range(N)])

num = 0
for a in A:
  if sum(a * B) + C > 0:
    num += 1

print(num)

Measured memory_bytes: 12448
n=gets.to_i

abs = []
n.times do
  abs << gets.split.map(&:to_i)
end

abs = abs.map { |a,b|
  sum = a+b
  [a,b,sum]
}.sort_by {|a,b,sum| -sum}

tp = 0
ap = 0

f = true
abs.each do |a,b,sum|
  if f
    tp += a
  else
    ap += b
  end
  f = !f
end

p (tp-ap)

Measured memory_bytes: 14840
// ConsoleApplication7.cpp : ??????????????? ??¢????????±????????§????????¨????????? ?????????????????????????????????
//
#include <stdio.h>


int main(int argc, char* argv[])
{
	int W, H, x, y, r;
	char temp[100];

	fgets(temp, sizeof(temp), stdin);
	sscanf(temp, "%d %d %d %d %d", &W, &H, &x, &y, &r);

	// x ????¨±???????????? r <= x <= W - r, y ????¨±???????????? r <= y <= H - r
	if (r <= x && x <= W - r && r <= y && y <= H - r) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}

	return 0;
}

Measured memory_bytes: 2660
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<functional>
using namespace std;
const int MAXN=100005;

int N,cnt1,cnt2;
long long A[MAXN],B[MAXN];

int main()
{
	scanf("%d",&N);
	for(int i=1,x;i<=N;i++)
	{
		scanf("%d",&x);
		if(x>0)
			A[++cnt1]=x;
		else
			B[++cnt2]=x;
	}
	sort(A+1,A+cnt1+1,greater<long long>());
	sort(B+1,B+cnt2+1);
	if(cnt1==0)
		A[++cnt1]=B[--cnt2];
	if(cnt2==0)
		B[++cnt2]=A[cnt1--];
	long long ans=0;
	for(int i=1;i<=cnt1;i++)
		ans+=A[i];
	for(int i=1;i<=cnt2;i++)
		ans-=B[i];
	printf("%lld\n",ans);
	for(int i=1;i<N;i++)
	{
		if(cnt1>cnt2)
		{
			printf("%lld %lld\n",B[cnt2],A[cnt1]);
			B[cnt2]=B[cnt2]-A[cnt1--];
		}
		else
		{
			printf("%lld %lld\n",A[cnt1],B[cnt2]);
			A[cnt1]=A[cnt1]-B[cnt2--];
		}
	}
	return 0;
}


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

// macros
#define int long long 
#define TIME clock() * 1.0 / CLOCKS_PER_SEC
#define all(c) c.begin(), c.end()
#define PB push_back
#define MP make_pair
#define bitcount __builtin_popcount
#define watch(x) cerr<< (#x) << " is " << (x) <<"\n";
#define sz(x) ((int)((x).size()))
#define UNIQUE(c) (c).resize(unique(all(c)) - (c).begin())
#define pii2ll(p) ((ll)(p).first<<32 | (p).second)

// type definitions
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< vi > vvi;
typedef pair<int, int> pii;
typedef long double ld;

// template functions
template < typename A, typename B >
ostream &operator << ( ostream& os, const pair< A, B > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}
template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "[";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}
template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "{";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}
template < typename A, typename B >
ostream &operator << ( ostream & os, const map< A, B > &v ) {
    os << "[";
    typename map< A, B >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " -> " << it -> second ;
    }
    return os << "]";
}
template<typename T>
T gcd(T a, T b) { if(a==0 or b==0) return a+b; return gcd(b, a%b) ; }
template<typename T>
T lcm(T a, T b) { if(a==0 or b==0) return 0; return a/gcd(a, b)*b; }

// random number generation
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// constants
const long double eps = LDBL_EPSILON;
const int inf = 1e15;
const int modn = 1e9+7;
const int maxn = 2e5+3;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // Your code here
    int n, m;
    cin>>n>>m;
    vvi adj(n);
    for(int i=0; i<m; i++) {
        int u, v;
        cin>>u>>v;
        u--, v--;
        adj[u].PB(v);
    }
    vi dp(n, -1);
    function<int(int) > F = [&](int u)
    {
        if(dp[u]!=-1) return dp[u];
        dp[u] =0;
        for(int v : adj[u]) {
            dp[u] = max(dp[u], 1 + F(v));
        }
        return dp[u];
    };
    int ans = 0;
    for(int i=0; i<n; i++) {
        ans = max(ans, F(i));
    }
    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 9216
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define tll tuple<ll, ll, ll>
#define all(c) c.begin(),c.end()

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
 
const ll inf = 1000000001;
const ll INF = 1e18;
const ll MOD = 1000000007;

char albt[26] = {'a','b','c','d','e','f','g','h','i','j','k','l',
                 'm','n','o','p','q','r','s','t','u','v','w','x',
                 'y','z'};

//vector<ll> g[202020];
//fill(score, score+202020, 0);
//vector<ll> v;

int main(){
  ll a, b;
  cin >> a >> b;
  
  ll ans = a - 2*b;
  if (ans < 0) cout << 0 << endl;
  else cout << ans << endl;
  
  //cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define all(x) begin((x)), end((x))
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
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;
}

class ModCom {
    public:
        ModCom(int _n, long long _mod){
            assert(_n>=2);
            n = _n+1;
            mod = _mod;
            _fac.assign(n,0);
            _finv.assign(n,0);
            _inv.assign(n,0);
            init();
        }

        long long com(int _n, int k){
            if(_n < k){return 0;}
            if(_n < 0 || k < 0){return 0;}
            return _fac.at(_n) * (_finv.at(k) * _finv.at(_n - k) % mod) % mod;
        }

        long long fac(int _n) {
            return _fac.at(_n);
        }

        long long inv(int _n) {
            return _inv.at(_n);
        }

        long long finv(int _n) {
            return _finv.at(_n);
        }

    private:
        int n;
        long long mod;
        vector<long long> _fac;
        vector<long long> _finv;
        vector<long long> _inv;

        void init(void){
            _fac.at(0) = _fac.at(1) = 1;
            _finv.at(0) = _finv.at(1) = 1;
            _inv.at(1) = 1;
            for(int i = 2;i < n; i++){
                _fac.at(i) = _fac.at(i - 1) * i % mod;
                _inv.at(i) = mod - _inv.at(mod % i) * (mod / i) % mod;
                _finv.at(i) = _finv.at(i - 1) * _inv.at(i) % mod;
            }
            return;
        }
};

int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin>>N;
    vector<ll> x(N),csum(N+10, 0);
    rep(i,N) {cin>>x[i];}
    ModCom com(N+100, MOD);
    rep(i,N-1) {
        csum[i+1] = (csum[i] + com.fac(N-1) * com.inv(i+1)) % MOD;
    }
    ll res = 0;
    rep(i,N-1) {
        ll d = x[i+1] - x[i];
        res = (res + d * csum[i+1]) % MOD;
    }
    cout << res << endl;
    return 0;
}


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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 4;
int a[N] = {0}, n, m;
bool d[N] = {0};

int main() {
    cin >> n >> m;
    for (int i = 1; i <= n; i++) a[i] = 1;
    d[1] = 1;
    while (m--) {
        int x, y; cin >> x >> y;
        if (d[x]) {
            d[y] = 1;
            if (a[x] == 1) d[x] = 0;
        }
        a[x]--;
        a[y]++;
    }
    int res = 0;
    for (int i = 1; i <= n; i++)
    if (a[i] && d[i]) res++;
    cout << res << endl;
}


Measured memory_bytes: 768
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#if defined(DAIJOBU)
#include "/home/ichigo/includes.hpp"
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}

using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


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


Measured memory_bytes: 256
# 整数 a と、英小文字からなる文字列 s が入力されます。
# a が 3200以上なら s と出力し、a が 3200 未満なら red と出力するプログラムを書いてください。

# 標準入力から 整数a と文字列s を取得する
input_a = int(input())
input_s = input()

# a が3200以上／3200未満 なのかを判定する
# # output_s = 'Error: Input Value is OutOfRange. Sorry!'
# # if (input_a <= 2800) or (input_a >= 5000):
# #     output_s = output_s
# else:
output_s = 'pink'
if input_a >= 3200:
    output_s = input_s
elif input_a < 3200:
    output_s = 'red'

# 結果を出力する
print(output_s)


Measured memory_bytes: 9016
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long
#define big 998244353
#define ff first
#define se second
#define pb push_back
#define pii pair<int,int>
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define mp make_pair
#define pi 3.141592653589
int power(int x,int y){
    int r=1,z=x;
    while(y){
        if(y & 1)r*=z;
        z*=z;y=y>>1;}
    return r;}
int powerm(int x,int y,int p){
    int r=1;
    while(y){
        if(y & 1)r=(r*x)%p;
        y=y>>1;
        x=(x*x)%p;}
    return r%p;}
int modinv(int x,int m){
    return powerm(x,m-2,m);}
int logarithm(int a,int b){
    int x=0;
    while(a>1){
        x++;
        a/=b;}
    return x;}
int32_t main(){
    fast;
    string s;
    cin>>s;
    int sum=0;
    for(int i=0;i<s.length();i++)
        sum+=(s[i]-'0');
    if(sum%9)
        cout<<"No";
    else
        cout<<"Yes";
    return 0;
}

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

constexpr int64_t mod{1'000'000'007};

using vi = std::vector<int>;

int N, K;
std::vector<vi> graph;
std::vector<bool> visited;

int64_t rc(int, int);

int main()
{
	scanf("%d%d", &N, &K);
	graph.resize(N);
	for (int i{}; i < N - 1; i++)
	{
		int a, b;
		scanf("%d%d", &a, &b);
		a--; b--;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}
	visited.resize(N);
	printf("%lld\n", rc(0, 0));

	return 0;
}

int64_t rc(int index, int used)
{
	visited[index] = true;
	int64_t ret{K - used};
	int next_used{2};
	if (index == 0) next_used = 1;
	for (int i{}; i < (int)graph[index].size(); i++)
	{
		if (visited[graph[index][i]]) continue;
		ret = ret * rc(graph[index][i], next_used) % mod;
		next_used++;
	}
	return ret;
}

Measured memory_bytes: 9216
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define pll pair<ll,ll>
#define pint pll
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  int h,w,n;
  cin >> h >> w >> n;
  int x=max(h,w);
  int y=min(h,w);
  int ans=0;
  cout << (n+x-1)/x << endl;
return 0;}

Measured memory_bytes: 256
import java.io.*;

public class Main{
public static void main(String[] args){
try{
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	String[] str = br.readLine().split(" ");
	int a = Integer.parseInt(str[0]);
	int b = Integer.parseInt(str[1]);

	int d = a / b;
	int r = a % b;
	double f = (double) a / (double) b;
	
	System.out.printf("%d %d %.5f\n", d, r, f);

}catch(IOException e){
System.out.println(e);
}
}
}

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    lint a, b;
    cin >> a >> b;
    // lint x = 0;
    // for (int i = 0; i < 1000; ++i) {
    //     x ^= i;
    //     cout << x << "\n";
    // }
    lint fb = 0;
    for (lint i = b / 4 * 4; i <= b; ++i) {
        fb ^= i;
    }
    lint fa = 0;
    for (lint i = (a - 1) / 4 * 4; i <= a - 1; ++i) {
        fa ^= i;
    }
    cout << (fb ^ fa) << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<limits.h>
#include<cmath>
#include<queue>
#include<stack>
#define rep(i,n) for(ll i = 0; i < (ll)n; i++)
#define swap(a,b) a^=b;b^=a;a^=b;
#define chmax(a,b) {if(a < b) a = b;}
#define chmin(a,b) {if(a > b) a = b;}
using namespace std;
typedef long long ll;
ll gcd(ll, ll);
vector<bool> to_binary(int);
int sum(vector<int>);
int min(vector<int>);
int max(vector<int>);
ll nCr(ll n, ll r);

const ll INF = 1LL << 60;

typedef tuple<ll, ll> mtupl;

bool mycomp(mtupl x, mtupl y) {
	return get<1>(x) < get<1>(y);
}

vector<vector<ll>> memo;

ll get(int x, int y) {
	if (memo[x][y] != -1)
		return memo[x][y];

	if (x == 0) return 1;
	if (y < x) return 0;

	memo[x][y] = get(x, y - 1) + get(x - 1, y - 1);
	return memo[x][y];
}

ll mpow(ll a, ll b) {
	ll ans = 1;
	for (ll i = 0; i < b; i++) {
		ans *= a;
		ans %= 1000000007;
	}
	return ans;
}

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

int vsum(vector<int> v) {
	int res = 0;
	for (auto it = v.begin(); it != v.end(); it++)
		res += *it;
	return res;
}
int vmin(vector<int> v) {
	int min = INT32_MAX;
	for (auto it = v.begin(); it != v.end(); it++)
		min = std::min(min, *it);
	return min;
}
int vmax(vector<int> v) {
	int max = INT32_MIN;
	for (auto it = v.begin(); it != v.end(); it++)
		max = std::max(max, *it);
	return max;
}

ll gcd(ll A, ll B) {
	if (A == 0 || B == 0) return max(A, B);
	int r = A % B;
	while (r != 0) {
		A = B;
		B = r;
		r = A % B;
	}
	return B;
}

ll _gcd(ll A, ll B) {
	return (B == 0) ? A : gcd(A % B, B);
}

vector<bool> to_binary(int x) {
	vector<bool> res;
	while (x != 0) {
		res.push_back(x % 2);
		x /= 2;
	}
	return res;
}

template<int index>
bool comp(tuple<ll, ll, ll, ll> a, tuple<ll, ll, ll, ll> b) {
	return get<index>(a) < get<index>(b);
}

int vector_finder(std::vector<ll> vec, ll number) {
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return index;
	}
	else { // 発見できなかったとき
		return 0;
	}
}


int len(int x) {
	return (int)log10(x) + 1;
}

int same_vec(vector<int> a, vector<int> b) {
	int res = 1, num = a.size();
	for (int i = 0; i < num; i++) {
		if (a[i] != b[i]) {
			res = 0;
			break;
		}
	}
	return res;
}


ll fibs[100] = { 0 };
ll fib(int n) {
	if (fibs[n] == 0) {
		return fibs[n] = fib(n - 1) + fib(n - 2);
	}
	return fibs[n];
}



int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//Program Start	

	int N;
	cin >> N;

	vector<pair<int, int>> A;

	rep(i, N) {
		int tmp;
		cin >> tmp;
		A.emplace_back(tmp, i);
	}

	sort(A.begin(),A.end());

	for (auto it = A.begin(); it != A.end(); it++) {
		cout << to_string(it->second + 1) + " ";
	}

	cout << endl;

ProgramEndPointLabel:;

	//Program End
#ifndef DEBUG
	system("pause");
#endif // !DEBUG


	return 0;
}




Measured memory_bytes: 2028
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
using namespace std;
typedef long long LL;
const int N=2005;
struct sl{
	LL v,num;
	sl(LL v_=0,LL num_=0){v=v_;num=num_;}
}f[N][N];
LL ans,n,m,z,x,y,len;
string s,c;
sl DP(int l,int r){
	if (l>=r) return f[l][r]=sl(0,1);
	if (f[l][r].num!=0) return f[l][r];
	if (s[l-1]==s[r-1]){
		f[l][r]=DP(l+1,r-1); return f[l][r];
	}
	sl t1,t2;
	t1=DP(l,r-1);t2=DP(l+1,r);
	++t1.v;++t2.v;
	if (t1.v==t2.v){
		f[l][r].v=t1.v;
		if (t1.num+t2.num<=n) f[l][r].num=t1.num+t2.num;
		else f[l][r].num=n+1;
	}
	else if (t1.v<t2.v) f[l][r]=t1;
	else f[l][r]=t2;
	return f[l][r];
}
void getans(int l,int r,int x,int y){
	if (l>r) return;
	if (l==r) {
		c[x]=s[l-1];return;
	}
	if (s[l-1]==s[r-1]) {
		c[x]=s[l-1];c[y]=s[r-1];
		getans(l+1,r-1,x+1,y-1);
	}
	else if (f[l][r-1].v==f[l+1][r].v){
		if (s[l-1]<s[r-1] && n<=f[l+1][r].num) {
			c[x]=c[y]=s[l-1];
			getans(l+1,r,x+1,y-1);
		}
		else if (s[l-1]<s[r-1] && n>f[l+1][r].num){
			c[x]=c[y]=s[r-1];
			n-=f[l+1][r].num;
			getans(l,r-1,x+1,y-1);
		}
		else if (s[l-1]>s[r-1] && n<=f[l][r-1].num){
			c[x]=c[y]=s[r-1];
			getans(l,r-1,x+1,y-1);
		}
		else if (s[l-1]>s[r-1] && n>f[l][r-1].num){
			c[x]=c[y]=s[l-1];
			n-=f[l][r-1].num;
			getans(l+1,r,x+1,y-1);
		}
	}
	else if (f[l][r-1].v<f[l+1][r].v){
		c[x]=c[y]=s[r-1];
		getans(l,r-1,x+1,y-1);
	}
	else {
		c[x]=c[y]=s[l-1];
		getans(l+1,r,x+1,y-1);
	}
}
int main(){
	//freopen("G.in","r",stdin);freopen("G.out","w",stdout);
	cin>>s;
	cin>>n;
	len=s.length();
	DP(1,len);
	ans=f[1][len].v+len;
	c.resize(ans);
	if (f[1][len].num<n) cout<<"NONE"<<endl;
	else{
		getans(1,len,0,ans-1);
		cout<<c<<endl;
	}
}

Measured memory_bytes: 64304
N = int(input())
S = [[]for i in range(N)]
for i in range(N-1):
    a,b,c = map(int,input().split())
    S[a-1].append([b-1,c])
    S[b-1].append([a-1,c])
Q,K = map(int,input().split())
xy = list(list(map(int,input().split()))for i in range(Q))
len_ = [float('inf')]*N
len_[K-1] = 0
queue = [K-1]
hoge = []
while queue != []:
    for i in queue:
        for b,c in S[i]:
            if len_[b] > len_[i]+c:
                hoge.append(b)
                len_[b] = len_[i]+c
    queue = hoge
    hoge = []
for x,y in xy:
    print(len_[x-1]+len_[y-1])

Measured memory_bytes: 75412
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
  double n,m;
  cin>>n>>m;
  vector<ll> v(n);
  for(int i=0;i<n;i++)
    cin>>v[i];
  ll sum=0;
  for(int i=0;i<n;i++)
    sum+=v[i];
  sort(v.begin(),v.end(),greater<ll>());
  double t=(double)sum/(4*m);
  if(v[m-1]<t)
    cout<<"No";
  else cout<<"Yes";
  return 0;
}


Measured memory_bytes: 256
//g++ -std=gnu++14 a.cpp

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>
#include <stdio.h>

using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

ll MODP = 998244353;

ll gen(ll x,ll y){
  if(y == 0)return 1;
  if(y == 1)return x%MODP;
  if(y%2 == 1){
    return ((x%MODP)*(gen(x,y-1))%MODP)%MODP;
  }else{
    ll t = gen(x,y/2);
    return ((t%MODP)*(t%MODP))%MODP;
  }
}

ll comb(ll x,ll y){
  if(y == 0)return 1;
  ll res = 1;
  rep(i,y){
    res = ((res%MODP)*((x-i)%MODP))%MODP;
  }
  for(ll i = 1;i <= y;i++){
    res = ((res%MODP)*gen(i,MODP-2))%MODP;
  }
  return res%MODP;
}

int main(){
  ll a,b;
  cin >> a >> b;
  if(a == b){
    string s = "";
    rep(i,b)s += to_string(b);
    cout << s << endl;
  }else if(a < b){
    string s = "";
    rep(i,b)s += to_string(a);
    cout << s << endl;
  }else{
    string s = "";
    rep(i,a)s += to_string(b);
    cout << s << endl;
  }


  return 0;
}


Measured memory_bytes: 3672
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define REP(i, n) FOR(i, 0, n)
const int INF = 1e9;
typedef long long ll;
using namespace std;
int main() {
    int D;
    ll G;
    cin >> D >> G;
    int p[D];
    ll c[D];
    int score = 0;
    int count = 0;
    int max_problem = -1;
    int min_count = INF;
    REP(i, D) cin >> p[i] >> c[i];
    REP(bit, 1 << D) {
        score = 0;
        count = 0;
        REP(i, D) {
            if(bit & (1 << i)){
                score += 100*(i+1)*p[i] + c[i];
                count += p[i];
            }
            if(score >= G) {
                min_count = min(min_count, count);
                continue;
            }
        }
        for(int i = D-1; i >= 0; --i) {
            if(bit & (1 << i)) continue;
            for(int j = 1; j < p[i]; ++j) {
                if(score + 100*(i+1)*j >= G) {
                    min_count = min(min_count, count + j);
                }
            }
        }
    }
    cout << min_count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
inline void init() { cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }

int main() {
    init();

    string s;
    int k;
    cin >> s >> k;
    FOR(i, 0, s.length() - 1) {
        if (s[i] == 'a')continue;
        if (26 - s[i] + 'a' <= k) {
            k -= 26 - s[i] + 'a';
            s[i] = 'a';
        }
    }

    s[s.length() - 1] = (s[s.length() - 1] + k - 'a') % 26 + 'a';
    cout << s << "\n";
}


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

class Main{
	public static void main(String[] args) throws IOException{
		
		BufferedReader br =
				new BufferedReader(new InputStreamReader(System.in));
		
		String str = br.readLine();
		double hankei = Double.parseDouble(str);
		double enshuritsu = Math.PI;
		double menseki = 0;
		double enshu = 0;
		
		menseki = hankei*hankei*enshuritsu;
		enshu = (hankei*2) * enshuritsu;
		
		String resultmenseki = String.format("%.6f", menseki);
		String resultenshu = String.format("%.6f", enshu);
		
		
		System.out.println(resultmenseki + " " +resultenshu);
	}

}

Measured memory_bytes: 24656
s = gets.chomp.split("")
flag = 0

flag += 1 if s[0] == "A"

id = 0
for i in 2..(s.length-2)
  if s[i] == "C"
    flag += 1
    id = i
    break
  end
end

for i in 1..(s.length-1)
  if i != id
    flag -= 1 if s[i] < "a"
  end
end

flag == 2 ? (puts "AC"):(puts "WA")

Measured memory_bytes: 1788
function calc(T,x,y,K)
	g(a,b,c,d)=T[c+1,d+1]-T[c+1,b]-T[a,d+1]+T[a,b]
	if x<=K
		if y<=K
			g(x,y,x+K-1,y+K-1)+g(1,1,x-1,y-1)+g(x+K,1,2K,y-1)+g(1,y+K,x-1,2K)+g(x+K,y+K,2K,2K)
		else
			g(x,y,x+K-1,2K)+g(x,1,x+K-1,y-K-1)+g(1,y-K,x-1,y-1)+g(x+K,y-K,2K,y-1)
		end
	else
		if y<=K
			calc(T,x-K,y+K,K)
		else
			calc(T,x-K,y-K,K)
		end
	end
end
function main()
	lines=readlines()
	N,K=map(x->parse(Int,x),split(shift!(lines)))
	sum=zeros(Int,2K+1,2K+1)
	for s=lines
		x,y,c=split(s)
		sum[mod1(parse(Int,x),2K)+1,mod1(parse(Int,y)+(c=="B" ? K : 0),2K)+1]+=1
	end
	for i=2:2K+1,j=2:2K+1
		sum[i,j]+=sum[i-1,j]+sum[i,j-1]-sum[i-1,j-1]
	end
	ans=0
	for i=1:2K,j=1:2K
		ans=max(ans,calc(sum,i,j,K))
	end
	println(ans)
end
main()


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

int sum[100005];

int main() {
  int n;
  cin >> n;
  
  for (int i = 1; i <= n; ++i) {
    sum[i] = n;
    sum[i] = min(sum[i], sum[i-1]+1);
    for (int j = 1; i - (int)pow(6,j) >= 0; ++j) {
      sum[i] = min(sum[i], sum[i-(int)pow(6,j)]+1);
    }
    for (int j = 1; i - (int)pow(9,j) >= 0; ++j) {
      sum[i] = min(sum[i], sum[i-(int)pow(9,j)]+1);
    }
  }
  cout << sum[n] << endl;
  return 0;
}

Measured memory_bytes: 640