akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

int main(){
    int n, k; cin>>n>>k;
    string s; cin>>s;
    if(s[k-1] == 'A') s[k-1] = 'a';
    else if(s[k-1] == 'B') s[k-1] = 'b';
    else s[k-1] = 'c';
    cout << s << endl;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,A,B;
int dp[404][404];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>A>>B;
	
	FOR(i,404) FOR(j,404) dp[i][j]=1<<30;
	dp[0][0]=0;
	FOR(i,N) {
		int a,b,c;
		cin>>a>>b>>c;
		for(y=403;y>=0;y--) {
			for(x=403;x>=0;x--) if(dp[x][y]<1<<30) {
				dp[x+a][y+b]=min(dp[x+a][y+b],dp[x][y]+c);
			}
		}
	}
	
	int ret=1<<30;
	FOR(x,404) FOR(y,404) if(dp[x][y]<ret && x) {
		if(x*B==y*A) ret=dp[x][y];
	}
	if(ret==1<<30) ret=-1;
	cout<<ret<<endl;
	
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 896
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<queue>
#include<deque>
#include<algorithm>
#include<stack>
#include<vector>
using namespace std;
int a,b;
int main()
{
	scanf("%d%d",&a,&b);
	if(a>8||b>8)
	{
		printf(":(");
	}
	else
	{
		printf("Yay!");
	}
	return 0;
}

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

vector<int> forintinput(int n) {
	vector<int> x;
	for(int i = 0;i < n;i++){
		int ia;
		cin >> ia;
		x.push_back(ia);
	}
	return x;
}
int main(){
	int n,m;
	cin >> n >> m;
	vector<int> a(m);
	int cnt = 0;
	for(int i = 0;i < m;i++){
		cin >> a[i];
		cnt += a[i];
	}
	if(cnt > n){
		cout << -1 << endl;
		return 0;
	}else{
		cout << n - cnt << endl;
	}
}

Measured memory_bytes: 3616
#!/usr/bin/env python3
import sys,collections
n = int(sys.stdin.readline())
A = list(map(int,sys.stdin.readline().split()))
def partition(A,p,r):
  x = A[r]
  i = p
  for j in range(p,r):
    if A[j] <= x:
      A[i],A[j] = A[j],A[i]
      i += 1
  A[i],A[r] = A[r],A[i]
  return i
q = partition(A,0,len(A)-1)
print(" ".join([str(e) if i != q else "["+str(e)+"]" for i,e in enumerate(A)]))



Measured memory_bytes: 17164
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;
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; }
template<class T> inline bool int_ceil(T a, T b) { T res = a / b; if(a % b != 0) res++; return res; }
template<typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define print(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define print(...)
#endif

int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	int n; cin >> n;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];


	vector<ll> b(n+1);
	rep2(i, 1, n+1) b[i] = b[i-1] + a[i-1];
	// print(b);
	ll ans = LLINF;
	rep(j, 2){
		// print(j);
		ll sign = 1;
		ll now = 0;
		ll sum = 0;
		if(j) sign = -1;
		rep2(i, 1, n+1){
			// print(now, b[i], sign, (now + b[i]) * sign);
			if( (now + b[i]) * sign < 1) {
				sum += 1 - (now + b[i]) * sign;
				now += (1 - (now + b[i]) * sign) * sign;
			}
			sign *= -1;
		}
		chmin(ans, sum);
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 4780
import math


def a():
    x = int(input())

    if x < 600:
        print(8)
    elif x < 800:
        print(7)
    elif x < 1000:
        print(6)
    elif x < 1200:
        print(5)
    elif x < 1400:
        print(4)
    elif x < 1600:
        print(3)
    elif x < 1800:
        print(2)
    else:
        print(1)


def b():
    a, b, c = map(int, input().split())
    k = int(input())
    count = 0

    while b <= a:
        b *= 2
        count += 1

    while c <= b:
        c *= 2
        count += 1
    if count <= k:
        print('Yes')
    else:
        print('No')


def c():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))

    for i in range(k, n):
        if a[i] > a[i-k]:
            print('Yes')
        else:
            print('No')


def d():
    n = int(input())
    a = list(map(int, input().split()))
    a = [a[1]] + a + [a[n-2]]
    money = 1000
    kabu = 0
    for i, v in enumerate(a[1:n+1], 1):
        if (v > a[i-1] and v >= a[i+1]) or (v >= a[i-1] and v > a[i+1]):
            # sell
            money += kabu * v
            kabu = 0
        elif (v < a[i-1] and v <= a[i+1]) or (v <= a[i-1] and v < a[i+1]):
            # buy
            temp = money // v
            money -= temp * v
            kabu += temp
        # print(money,kabu)
    money += kabu * a[n]
    print(money)


# a()
# b()
# c()
d()


Measured memory_bytes: 9336
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<iostream>
#include<fstream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<functional>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};




signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n;
    ll a[100010]={};
    ll cnt[100010]={};
    cin>>n;
    rep(i,n){
        cin>>a[i];
    }
    if(a[0]!=0){
        cout<<0<<endl;
        return 0;
    }
    ll ans=3;
    cnt[0]=1;
    rep2(i,1,n){
        ll now=a[i];
        if(now==0){
            ans*=(3-cnt[0]);
            ans%=MOD;
            cnt[0]++;
        }
        else{
            if(cnt[now-1]-cnt[now]<0){
                cout<<0<<endl;
                return 0;
            }
            ans*=(cnt[now-1]-cnt[now]);
            ans%=MOD;
            cnt[now]++;
        }
        // cout<<i<<" "<<ans<<endl;
    }
    cout<<ans%MOD<<endl;
    return 0;
}

Measured memory_bytes: 1792
mod = 1000000007
n, m = gets.split(' ').map(&:to_i)
breaking = Hash.new(false)
m.times { breaking[gets.to_i - 1] = true }
counts = [!breaking[0] ? 1 : 0]
counts.push(!breaking[1] ? counts[0] + 1 : 0)
2.upto(n - 1) do |i|
  if breaking[i]
    counts.push(0)
  else
    counts.push((counts[i - 1] + counts[i - 2]) % mod)
  end
end
puts counts[n - 1]

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

int main() {
  int N;  //ボールの合計個数
  int K;  //ロボットBの配置されているx座標の値
  
  int X[N];  //ボールが配置されているx座標
  
  int sum = 0;  //移動距離の総和
  
  cin >> N >> K;  //入力
  
  for (int i = 1; i <= N; i++){
    cin >> X[i];  //入力
    
    if (X[i] < K - X[i]){
    	sum += 2 * X[i];
    } else if (X[i] >= K - X[i]){
    	sum += 2 * (K - X[i]);
    }
  }
  //出力
  cout << sum << endl;
  
}


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

int main() {
    int n;
    while(cin >> n, n){
        int cnt = 0;
        bool ok = false;
        for(int i=0;i<n;i++){
            int k;
            cin >> k;
            if(k>0) cnt++;
            if(k>1) ok = true;
        }
        if(ok){
            cout << cnt+1 << endl;
        }
        else{
            cout << "NA" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,a,b,a1=1;
	scanf("%d %d %d",&n,&a,&b);
	a1=n*a;
	if(a1>b)
		printf("%d",b);
	else
		printf("%d",a1);	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ld double
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
int main()
{
	boost;
	int n, k, q, x, i;
	cin >> n >> k >> q;
	int arr[n], d[n];
	memset(d, 0, sizeof d);
	fo(i, 0, n)
	arr[i] = k;
	fo(i, 0, q){
		cin >> x;
		d[x - 1]++;
	}
	fo(i, 0, n){
		if(arr[i] - (q - d[i]) <= 0)
		cout << "No\n";
		else
		cout << "Yes\n";
	}
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
string s1, s2;
int main()
{
    cin >> s1 >> s2;
    if (s1.length() > s2.length()) printf("GREATER\n");
    else if (s1.length() < s2.length()) printf("LESS\n");
    else if (s1 > s2) printf("GREATER\n");
    else if (s1 < s2) printf("LESS\n");
    else printf("EQUAL\n");
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define _LIBCPP_DEBUG 0
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;
int INF = 1 << 30;

vector<ll> vec;

void dfs(string S){

    if(S.length() > to_string(3234566667).length())
        return;

    vec.push_back(stoll(S));

    if(S[S.length()-1]!='9'){
        char tmp = S[S.length()-1];
        dfs(S+to_string((S[S.length()-1]-'0')+1));
    }
    dfs(S+to_string(S[S.length()-1]-'0'));

    if(S[S.length()-1]!='0'){
        dfs(S+to_string((S[S.length()-1]-'0')-1));
    }

}

int main(void){

    int K; cin>>K;
    for (int i = 1; i < 10; ++i) {
        dfs(to_string(i));
    }

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

    cout<<vec[K-1]<<endl;

    return 0;
}

Measured memory_bytes: 2420
N = int(input())
X = list(map(int,input().split()))

Y = sum(X)/len(X)
Y_floor = sum(X)//len(X)
Y_ceil = Y_floor+1
if  abs(Y-Y_floor)>=abs(Y-Y_ceil):
    Z=Y_ceil
else:
    Z = Y_floor

counter = 0 
for i in X:
    counter += (i-Z)**2

print(counter)

Measured memory_bytes: 38256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#define LL long long
using namespace std;
int main() {
	LL i, j, k;
	LL T;
	scanf("%lld", &T);
	while(T--){
		LL x, y;
		scanf("%lld%lld", &x, &y);
		LL L = 0, R = 1e9, ret;
		while(L <= R){
			LL mid = L+R>>1;
			if(mid*mid < x*y){ ret = mid; L = mid+1; }
			else R = mid-1;
		}
		LL p = ret;
		LL ans = 2*p;
		if(x <= p) ans--;
		if(y <= p) ans--;
		if(p*(p+1) >= x*y) ans--;
		printf("%lld\n", ans);
	}
	return 0;
}

Measured memory_bytes: 128
/*
 * Shubham Jain
 */
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl '\n'
#define MOD 10000000009

int main() {
    ll n,m ,i,j,a,b,c;
    cin>>n;
    ll k=n;
    ll ans=LONG_LONG_MIN;
    if(n<=2){cout<<"0"<<endl;return 0;}
    for(i=1;i<n/2;i++){
        if(k/i>=3){
            //m=k/i;
         //   cout<<i<<endl;
            ans=max(ans,i);
        }
        else break;
    }
    cout<<ans<<endl;
return 0;
}


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

int main() {
    int ans = 0;
    string str;
    cin >> str;
    rep(i, str.length() / 2) {
        if(str.at(i) != str.at(str.length() - i - 1)) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        int h = sc.nextInt();
        int w = sc.nextInt();

        while(h != 0 || w != 0){
            for (int i = 0; i < h; i++) {
                for (int j = 0; j < w; j++) {
                    if((i == 0 || i == h-1) || (j == 0 || j == w-1)){
                        System.out.print("#");
                    }else{
                        System.out.print(".");
                    }
                }
                System.out.println("");
            }
            System.out.println("");

            h = sc.nextInt();
            w = sc.nextInt();
            
        }


        sc.close();
    }
}


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

#define ll long long
#define vec vector<ll>
#define sortv(a); sort(a.begin(), a.end());
#define rev(a); reverse(a.begin(), a.end());
#define FOR(i,a,b) for (ll i = (ll)(a); i < (b); i++)
#define ROF(i,a,b) for (ll i = (ll)(b)-1; i >= (a); i--)

ll MOD = 1000000007;
ll INF = 1LL << 60;

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	int n;
	cin >> n;
	vec a(n), b(n-1);
	FOR(i,0,n-1) {
		cin>>b[i];
	}
	a[n-1]=INF;
	for(int i=n-2;i>=0;i--) {
		a[i+1]=min(a[i+1],b[i]);
		a[i]=b[i];
	}
	ll out=0;
	FOR(i,0,n) {
		out+=a[i];
	}
	cout<<out;
}

Measured memory_bytes: 256
#include <stdio.h>
	int w, h;
	int X[50][50];
void A( int i, int j ){
	X[i][j] = 0;
	int k,i1,j1;
	int x[8]={0,0,-1,1,1,1,-1,-1};
	int y[8]={-1,1,0,0,1,-1,-1,1};
	for( k = 0 ; k < 8 ; k++ ){
		i1 = i + x[k];
		j1 = j + y[k];
		if( j1 < w && i1< h && j1 > -1 && i1 > -1 ){
			if( X[i1][j1] == 1 ){
				A( i1, j1 );
			}
		}
	}
}
int main(){
	int i, j;
	int c;
	while(1){
		c = 0;
		scanf("%d %d",&w,&h);
		if( w == 0 && h == 0 ){ break; }
		for( i = 0 ; i < h ; i++ ){
			for( j = 0 ; j < w ; j++ ){
				scanf("%d", &X[i][j]);
			}
		}
		for( i = 0 ; i < h ; i++ ){
			for( j = 0 ; j < w ; j++){
		if( X[i][j]==1 ){
       		A(i, j);
            c++;
		}
	}
}
	printf("%d\n", c);				
}
return 0;	
}

Measured memory_bytes: 824
#include <bits/stdc++.h>
#define mp make_pair
#define ll long long
using namespace std;


int main() {
  ll n,l;
  cin>>n>>l;
  int s=0,min=INT_MAX,sum=0;;
  for(int i=1;i<=n;i++) {
      int k=l+i-1;
      if(min>abs(k)) {
          min=abs(k);
          if(k<0) {
              s=-1;
          }
      }
      sum+=k;
  }
  if(s==-1) {
      min=-min;
  }
  sum-=min;
  cout<<sum;
}

Measured memory_bytes: 256
STDOUT.sync = true
n,t,e = gets.split.map(&:to_i)
boiltimes=(t-e..t+e) #2880*100 = 288000
sc = gets.split.map(&:to_i)
c=0
sc.each do |xi|
  c+=1
  if xi<=t+e
    boiltimes.each do |j|
      if j%xi==0
        puts c
        exit
      end
    end
  end
end

puts -1

Measured memory_bytes: 2324
#include<iostream>

using namespace std;

int main()
{
	// ??\?????¨?????°??£?¨?
	int H;
	int W;

	// ???????????????
	while (1)
	{
		// ??\???
		cin >> H >> W;

		if (H == 0 && W == 0)
		{ // ??\?????±???0?????´??????????????????
			break;
		}

		// ????????????(????????????)
		for (int cnth = 1; cnth <= H; cnth++)
		{
			// ?¨??????????
			if (cnth % 2 != 0)
			{ // ?\???°????????´??????1??????#??§??????????§?
				for (int cntw = 1; cntw <= W; cntw++)
				{
					if (cntw % 2 != 0)
					{ // ?\???°????????´???
						cout << "#";
					}
					else
					{ // ??¶??°????????´???
						cout << ".";
					}
				}
			}
			else
			{ // ??¶??°????????´??????1??????.??§??????????§?
				for (int cntw = 1; cntw <= W; cntw++)
				{
					if (cntw % 2 != 0)
					{ // ?\???°????????´???
						cout << ".";
					}
					else
					{ // ??¶??°????????´???
						cout << "#";
					}
				}
			}
			// ?????????????¬??????????#or.??????
			cout << endl;
		}
		// 1???????????????
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
#define rep(i, n)for(int i=0; i<n; i++)

int main(){
  int N;
  long long K;
  cin >> N >> K;
  int A[N];
  rep(i, N)
    cin >> A[i];
  //

  int m[N+1];
  rep(i, N)
    m[i+1] = A[i];

  pair<int, bool> visit[N+1];
  rep(i, N+1)
    visit[i] = make_pair(0, false);

  int now = 1;

  int roop = 1;
  int count = 1;
  rep(i, K){
    if(visit[now].second == true){
      roop = i-visit[now].first;
      count = i;
      break;
    }
    visit[now] = make_pair(i, true);
    now = m[now];
  }

  K -= (long long)count;
  roop = K%(long long)roop;

  
  rep(i, roop)
    now = m[now];

  cout << now <<endl;
  
  return 0;
}


Measured memory_bytes: 6664
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<ll>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;
int main(){
  ll a,v,b,w,t;
  cin >> a >> v >> b >> w >> t;
  if(abs(a-b)<=t*(v-w)){
    cout << "YES" << endl;
  }
  else cout << "NO" << endl;
}   


Measured memory_bytes: 3672
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main(void)
{
	vector< pair <double, int> > data1, data2, data3, data4;
	int num;
	double time;

	for (int i = 0; i < 8; i++){
		cin >> num >> time;
		data1.push_back(make_pair(time, num));
	}
	for (int i = 0; i < 8; i++){
		cin >> num >> time;
		data2.push_back(make_pair(time, num));
	}
	for (int i = 0; i < 8; i++){
		cin >> num >> time;
		data3.push_back(make_pair(time, num));
	}
	sort(data1.begin(), data1.end());
	sort(data2.begin(), data2.end());
	sort(data3.begin(), data3.end());
	cout << data1[0].second << " " << data1[0].first << endl;
	cout << data1[1].second << " " << data1[1].first << endl;
	cout << data2[0].second << " " << data2[0].first << endl;
	cout << data2[1].second << " " << data2[1].first << endl;
	cout << data3[0].second << " " << data3[0].first << endl;
	cout << data3[1].second << " " << data3[1].first << endl;

	for (int i = 0; i < 6; i++)
	{
		data4.push_back(data1[i+2]);
		data4.push_back(data2[i+2]);
		data4.push_back(data3[i+2]);
	}
	sort(data4.begin(), data4.end());

	cout << data4[0].second << " " << data4[0].first << endl;
	cout << data4[1].second << " " << data4[1].first << endl;

	return 0;
}

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

using namespace std;

const int maxn = 1e5 + 5;
const int INF = 0x7f7f7f7f;

typedef long long ll;



ll a[maxn];
ll sum[maxn];
vector <ll> vt;

bool cmp(int a , int b) {
	return a > b;
}

int main() {
	ll n , m , v , p;
	ios::sync_with_stdio(0);
	cin >> n >> m >> v >> p;
	vt.push_back(0); 
	for(int i = 1 ; i <= n ; i++) {
		cin >> a[i];
	}
	sort(a + 1 , a + n + 1, cmp);
	int ans = p;
	for(int i = 1 ; i <= n ; i++) {
		sum[i] = sum[i - 1] + a[i];
	} 
	for(int i = p + 1 ; i <= n ; i++) {
		if(a[i] + m < a[p]){
			break;
		}
		else {
			if(m * v <= (p - 1) * m + (n - i + 1) * m+ (a[i] + m) * (i - p) - (sum[i - 1] - sum[p - 1])) {
				ans ++;
			}
			else {
				break;
			}
		}
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 1792
n = list(str(input()))
maxi = 0
#print(n)
for i in range(len(n)):
  #print(int(n[i])-1, int(n[i])-1 + (len(n)-i-1)*9)
  maxi = max(maxi, int(n[i])-1 + (len(n)-i-1)*9)
print(max(sum(map(int, n)), maxi))

Measured memory_bytes: 9044
local s = io.read()
if s == "zyxwvutsrqponmlkjihgfedcba" then
  print(-1)
elseif #s < 26 then
  for i = 1, 26 do
    local c = string.char(i + 96)
    if not s:find(c) then
      print(s .. c)
      break
    end
  end
else
  local found = false
  for pos = 25, 1, -1 do
    local left = pos == 1 and "" or s:sub(1, pos - 1)
    local cur = s:sub(pos, pos)
    local cur_i = string.byte(cur) - 96
    for i = cur_i + 1, 26 do
      local c = string.char(i + 96)
      if not left:find(c) then
        print(left .. c)
        found = true
        break
      end
    end
    if found then break end
  end
end


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

int main() {
  int n,i,x=0;
  cin >> n;
  
  for(i=0;i<n;i++) {
    int a,b;
    cin >> a >> b;
    x += b-a+1;
  }

  cout << x << endl;
}



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

int main(){
    long long k;cin>>k;
    vector<long long>a(50);
    if(k<50){
        for(int i=0;i<50;++i){
            if(i<k){
                a[i]=50;
            }
            else{
                a[i]=50-k-1;
            }
        }
    }
    else{
        long long m=k/50,l=k%50;
        for(int i=0;i<50;++i){
            if(i<l){
                a[i]=50+m;
            }
            else{
                a[i]=50+m-l-1;
            }
        }
    }
    cout<<50<<endl;
    for(int i=0;i<50;++i){
        if(i<49)cout<<a[i]<<" ";
        else cout<<a[i]<<endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
using namespace std;
bool solve(int n) {
	vector<int> v;
	while (n > 0) {
		v.push_back(n % 10);
		n /= 10;
	}
	return v[0] == v[1] && v[0] == v[2] || v[1] == v[2] && v[1] == v[3];
}
int main(void) {
	int n; cin >> n;
	string ans = solve(n) ? "Yes" : "No";
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import math
H, W = list(map(int, input().split()))

sum = float(H*W)
if sum%2 == 0:
    if H == 1 or W == 1:
        print(1)
    else:
        print(H*W//2)
else:
    if H == 1 or W == 1:
        print(1)
    else:
        print(math.floor(H*W/2)+1)

Measured memory_bytes: 3060
#include<stdio.h>

int main(){
	int a, b;
	scanf("%d %d", &a, &b);
	while(a!=0 && b!=0){
		for(int i=0; i<a; i++){
			for(int j=0; j<b; j++){
				if((i+j)%2==0) printf("#");
				else printf(".");
			}
			printf("\n");
		}
		printf("\n");
		scanf("%d %d", &a, &b);
	}
}


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

using namespace std;

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

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

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

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

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

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll n;
    cin >> n;
    ll ans = 0;
    repone(i, n) {
        if (i % 3 != 0 && i % 5 != 0) ans += i;
    }
    cout << ans << '\n';
}

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


Measured memory_bytes: 3588
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <cassert>
#include <unordered_map>
using namespace std;


/*
boolですべての島を用意して１から来れて、ｎへ行ける島があるか調べる
*/
int main(){
    int n, m;
    cin >> n >> m;
    vector<bool> vis(n+1, false);
    //bool型のvector. 要素数n+1, すべてfalseで初期化
    bool can = false;

    for(int i = 0; i < m; ++i){
        int a, b;
        cin >> a >> b;
        
        //1から出ている船とき
        if(a == 1){
            if(vis[b]){
                can = true;
                break;
            }
            vis[b] = true;
        }
        //ｎへ行ける船のとき
        else if(b == n){
            if(vis[a]){
                can = true;
                break;
            }
            vis[a] = true;
        }
    }

    
    if(!can) cout << "IM";
    cout << "POSSIBLE" << endl;

}

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

int main(){
	int n, k = 100000;
	cin >> n;
	for(int i = 0;i<n;i++){
		k *= 1.05;
		if(k%1000>0){
			k = k - (k % 1000) + 1000;
		}
	}
	cout << to_string(k) << endl;
	return 0;
}

Measured memory_bytes: 3248
#include <iostream>
#include <vector>

using namespace std;

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

    int result { 0 };

    for (int i { 1 }; i <= N; ++i) {

        int count { 1 };
        int num { i };
        while (num = num / 10) {
            count++;
        }

        result += (count % 2);
    }

    cout << result << endl;

    return 0;
}


Measured memory_bytes: 256
N,k = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
count = [0] * N
for i in range(N):
  count[a[i]-1] += 1
count.sort(reverse = True)
ans = N
for i in range(k):
  ans -= count[i]
print(ans)

Measured memory_bytes: 25772
#include<stdio.h>
int main(void){
	int n,a,b,c;
	scanf("%d",&n);
	while(scanf("%d %d %d",&a,&b,&c),n>0,n--){
		if(a*a==b*b+c*c || b*b==a*a+c*c || c*c==a*a+b*b)printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 580
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=2e5+5;
const int mod=998244353;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int j=1;
    while(a>0&&c>0)
    {
        if(j==1)
        {
            c-=b;
        }
        else
        {
            a-=d;
        }
        j++;
        j%=2;
    }
    if(a<=0)
    {
        cout<<"No"<<'\n';
    }
    else
    {
        cout<<"Yes"<<'\n';
    }



}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define REP1(i,n) for(int i=1; i<=(int)(n); i++)
#define SORT(v) sort(v.begin(), v.end())
#define REVERSE(v)  reverse(v.begin(), v.end())
using namespace std;

int main() {
  int N,K; cin>>N>>K;
  long long ans = 0;

  if(K % 2 == 1) {
    long long n = N / K;
    ans += n * n * n;
  }

  else {
    long long n = N / K;
    ans += n * n * n;

    long long m = (N + (K / 2)) / K;
    // while(((2 * m + 1) / 2) * K <= N) m++;
    ans += m * m * m;
    }

  cout << ans << endl;
}

Measured memory_bytes: 764
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

signed main(){
    ll X, Y;
    cin >> X >> Y;
    if(abs(X-Y) <= 1){
        cout << "Brown" << endl;
    }
    else{
        cout << "Alice" << endl;
    }
}

Measured memory_bytes: 3640
#include <stdio.h>
#include <math.h>

#define PI 3.141592653589

int main(void){
  int i, n;
  double x, y, rad;

  scanf("%d", &n);
  while(n != -1){
    x = 1;
    y = 0;
    for(i = 1; i < n; i++){
      rad = atan2(y, x) + PI/2;
      x += cos(rad);
      y += sin(rad);
    }
    printf("%f\n%f\n", x, y);
    scanf("%d", &n);
  }
  return 0;
}

Measured memory_bytes: 708
#pragma GCC optimize("O3")

#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define sz(x) (int)x.size()
#define f first
#define s second

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(15);

    int n;
    cin >> n;
    int oneCnt=0,twoCnt=0,threeCnt=0;
    int elem;
    F0R(i,n)
    {
        cin >> elem;
        switch(elem)
        {
            case 1:
                oneCnt++;
                break;
            case 2:
                twoCnt++;
                break;
            case 3:
                threeCnt++;
                break;
            default: break;
        }
    }
    vector<vector<vector<double>>> dp(n+1,vector<vector<double>>(n+1,vector<double>(n+1,0)));
    // dp[ones][twos][threes]
    F0R(k,n+1)
    {
        F0R(j,n+1)
        {
            if(k+j>n)
                continue;
            F0R(i,n+1)
            {
                if(k+j+i>n || i+j+k==0)
                    continue;
                double first,second,third;
                first=((double)i/(i+j+k));
                second=((double)j/(i+j+k));
                third=((double)k/(i+j+k));
                if(first!=0)
                    dp[i][j][k]+=dp[i-1][j][k]*first;
                if(second!=0)
                    dp[i][j][k]+=dp[i+1][j-1][k]*second;
                if(third!=0)
                    dp[i][j][k]+=dp[i][j+1][k-1]*third;
                dp[i][j][k]+=(double)n/(i+j+k); 
            }
        }
    }
    cout << dp[oneCnt][twoCnt][threeCnt];

    return 0;
}


Measured memory_bytes: 216832
#include<bits/stdc++.h>
#define ll long long
#define N 100005
#define M 1000000007
#define pii pair<ll,ll>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
main()
{
    vector<pii>v;
    int x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    for(int i=1;i<=a;i++)
    {
        int p;
        cin>>p;
        v.push_back({p,1});
    }
    for(int i=1;i<=b;i++)
    {
        int p;
        cin>>p;
        v.push_back({p,2});
    }
    for(int i=1;i<=c;i++)
    {
        int p;
        cin>>p;
        v.push_back({p,3});
    }
    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());
    int bakia=x,bakib=y,tot=0;
    ll ans=0;
    for(auto u:v)
    {
        if(u.second==3)
        {
            if(bakia+bakib-tot>=1)
            {
                ans+=u.first;
                tot++;
            }
        }
        else if(u.second==1&&bakia>=1&&bakia+bakib-tot>=1)
        {
            ans+=u.first;
            bakia--;
        }
        else if(u.second==2&&bakib>=1&&bakia+bakib-tot>=1)
        {
            ans+=u.first;
            bakib--;
        }

    }
    cout<<ans;

}


Measured memory_bytes: 10348
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using ll=long long;
using namespace std;

ll pow(ll a,ll b){
    if(b==0){
        return 1;
    }else{
        if(b%2==0){
            return pow(a*a,b/2);
        }else{
            return pow(a*a,b/2)*a;
        }
    }
}

int main(){
    ll H;
    cin>>H;
    
    int cnt=0;
    while(H>1){
        H/=2;
        cnt++;
    }

    cout<<pow(2,cnt+1)-1<<endl;

    return 0;
}

Measured memory_bytes: 3644
#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']

require 'prime'

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

def big(a,b) return (a>b)? a:b end

def small(a,b) return (a<b)? a:b end

n = inp[0]
p n*800 - n/15*200

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


int main() {
  string N;
  cin >> N;
  int n = 0;
  for(int i = 0; i < (int)N.size(); i++){
    n += N[i] - '0';
  }
  if(n%9  ==0 ) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3720
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
using namespace std;


int main() {
	map<int, int> mp;
	long long int a, b = 0, num[200005], bus = 0, sum[200005] = {}, n, cou = 0, res = 0, memo, min = 10000, c, k,time=0;
	string str,str2,str3;
	cin >>n>>c>>k;
	
	for (int i = 0; i < n; i++) {
		cin >> num[i];
	}
	sort(num, num + n);
	for (int i = 0; i < n; i++) {
		
		if (cou == 0) { cou++; time = num[i]; continue; }
		if (cou < c&&(num[i] - time) <= k) {
			cou++; continue;
		}
		if (cou == c || num[i] - time > k) {
			
			bus++; cou = 0;
			cou++; time = num[i];
		}
	}
	
	if (cou > 0) { bus++; }
	cout <<bus;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdbool.h>
#include <stdlib.h>

#define IO std::ios_base::sync_with_stdio(false); std::cin.tie(NULL); std::cout.tie(NULL);

#define MOD 1000000007
#define ll long long int
#define MAX 100005

using namespace std;

int main() {

    IO


    ll m, n, i, j, x;

    cin >> m >> n;

    ll a[n+1], b[n+1];

    for(i=0; i<n; i++)
        cin >> a[i];

    for(i=0; i<n-1; i++)
        b[i]=a[i+1]-a[i];
        
    b[n-1]=m-a[n-1]+a[0];
    ll maior=b[0];

    for(i=0; i<n; i++)
        maior=max(maior, b[i]);

    cout << m-maior << "\n";

    return 0;
}


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

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("6");
            WillReturn.Add("9 1 4 4 6 7");
            //2
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("8");
            WillReturn.Add("9 1 14 5 5 4 4 14");
            //0
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("14");
            WillReturn.Add("99592 10342 29105 78532 83018 11639 92015 77204 30914 21912 34519 80835 100000 1");
            //42685
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        int[] DArr = InputList[1].Split(' ').Select(X => int.Parse(X)).ToArray();

        Array.Sort(DArr);
        int UB = DArr.GetUpperBound(0);
        int MidLeft = UB / 2;
        int MidRight = MidLeft + 1;

        Console.WriteLine(DArr[MidRight] - DArr[MidLeft]);
    }
}


Measured memory_bytes: 20064
#include <iostream>
#include <string>

using namespace std;

unsigned int Check(const string& str, char start)
{
  	unsigned int change = 0;
	for(size_t i = 0; i < str.size(); ++i)
    {
      	if(!str[i])
      		break;
          
    	if(str[i] != start)
          ++change;
      
      	start = (start == '0')? '1' : '0';
    }
  
  	return change;
}

int main()
{
  	string Tiles;
	cin >> Tiles;
  
  	unsigned int nBlack = 0, nWhite = 0;
  	nBlack = Check(Tiles, '0');
  	nWhite = Check(Tiles, '1');
  
  	cout << ((nBlack < nWhite)? nBlack : nWhite) << endl;
  	
 	return 0; 
}

Measured memory_bytes: 512
unit = [""] + %w(Man Oku Cho Kei Gai Jo Jou Ko Kan Sei Sai Gok Ggs Asg Nyt Fks Mts)
loop do
    m, n = gets.split.map(&:to_i)
    break if m == 0
    x = m ** n
    s = ""
    unit.size.times do |i|
        y = x % 10000
        s = y.to_s + unit[i] + s if y > 0
        x /= 10000
    end
    puts s
end





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

long long INF = 1000000000000000000;

int main() {
	int N;
	cin >> N;
	N++;
	vector<long long> A(N);
	for (int i = 0; i < N; i++) cin >> A[i];
	vector<long long> L(N);
	vector<pair<long long, long long> > R(N);
	L[0] = 1;
	for (int i = 0; i < N - 1; i++) {
		L[i + 1] = min(INF, (L[i] - A[i]) * 2);
		if (L[i + 1] <= 0) {
			cout << -1 << endl;
			return 0;
		}
	}
	R[N - 1] = { A[N - 1], A[N - 1] };
	for (int i = N - 1; i > 0; i--) {
		R[i - 1].first = (R[i].first + 1) / 2 + A[i - 1];
		R[i - 1].second = R[i].second + A[i - 1];
	}
	for (int i = 0; i < N; i++) {
		if (L[i] < R[i].first) {
			cout << -1 << endl;
			return 0;
		}
	}
	long long ANS = 0;
	for (int i = 0; i < N; i++) {
		ANS += min(L[i], R[i].second);
	}
	cout << ANS << endl;
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    const int mxn = 1e5 + 5;
    long long sum = 0;
    set<long long> s;
    vector<long long> cnt(mxn, 0);
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        cnt[x]++;
        sum += x;
        s.insert(x);
    }
    int q;
    cin >> q;
    while (q--) {
        long long b, c;
        cin >> b >> c;
        long long Del = cnt[b] * b;
        long long Add = cnt[b] * c;
        s.insert(c);
        s.erase(b);
        cnt[c] += cnt[b];
        cnt[b] = 0;
        sum -= Del;
        sum += Add;
        cout << sum << '\n';
    }
    return 0;
}


Measured memory_bytes: 6812
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<algorithm>
#include<iostream>
using namespace std;
struct node
{
    string s;
    int x,num;
}a[105];
int cmp(node a,node b)
{
    if(a.s==b.s)
    {
        return a.x>b.x;
    }
    else
        return a.s<b.s;
}
int main()
{
    int n;
    scanf("%d",&n);
    int i;
    for(i=1; i<=n; i++)
    {
        cin>>a[i].s;
        scanf("%d",&a[i].x);
        a[i].num=i;
    }
    sort(a+1,a+n+1,cmp);
for(i=1; i<=n; i++)
    cout<<a[i].num<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>

 

using namespace std;

 

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


Measured memory_bytes: 3076
#include<stdio.h>

int main(){
    int a,b;

    scanf("%d %d",&a,&b);

    if(a==b){
        printf("Draw");
    }else if(a==1 || b==1){
        if(a<b){
            printf("Alice");
        }else{printf("Bob");}
    }else if(a<b){
        printf("Bob");
    }else if(a>b){
        printf("Alice");
    }
    return 0;
}

Measured memory_bytes: 128
#@inboundsなし
function main()
  V=zeros(Int,3010,3010)
  dp=zeros(Int,3010,3010,4)
  R,C,K=parse.(Int,split(readline()))
  for i=1:K
    r,c,v=parse.(Int,split(readline()))
    V[r,c]=v
  end
  for i=1:R
    for j=1:C
      for k=1:3
        dp[i+1,j+1,k+1]=max(max(dp[i,j+1,4],dp[i+1,j,k])+V[i,j],dp[i+1,j,k+1])
      end
    end
  end
  println(dp[R+1,C+1,4])
end
main()

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

using namespace std;

#define fcout(d) cout << fixed << setprecision(d)
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define repU(i,s,t) for(int i = (s); i <= (t); ++i)
#define repD(i,t,s) for(int i = (t); i >= (s); --i)
#define all(v)  begin(v),end(v)
#define clr(v) fill(all(v),0)
#define l_bnd lower_bound
#define u_bnd upper_bound
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define mkp make_pair
#define mkt make_tuple
#define fir first
#define sec second
#define rem(n,d) (((n % d) + d) % d)
#define q_ceil(n,d) ((n - 1)/(d) + 1)
#define parity(a,b) (((a)^(b)) & 1 ^ 1)

typedef long long ll;
typedef unsigned long long ull;
typedef double db;

const pair<int,int> DIR[] = { {1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1} };
const int INF_32 = -1 + (1 << 30);
const ll INF_64 = -1 + (1LL << 62);
const int MOD = 1e9 + 7;

int n;
vector<int> s = {2,3,4,9};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	cin>>n; 
	if(n == 3){ cout<<"2 5 63\n"; return 0; }
	n -= 4;
	rep1(i,5000){
		if(!n){
			for(int i : s) cout<<i<<' ';
			cout<<'\n';
			return 0;
		}
		s.pub(6 * i);
		--n;
	}
	if(n & 1){ s.pob(); ++n; }
	rep1(i,4999){
		if(!n){
			for(int i : s) cout<<i<<' ';
			cout<<'\n';
			return 0;
		}
		s.pub(6 * i + 2);
		s.pub(6 * i + 4);
		n -= 2;
	}
	rep1(i,2499){
		if(!n){
			for(int i : s) cout<<i<<' ';
			cout<<'\n';
			return 0;
		}
		s.pub(12 * i + 3);
		s.pub(12 * i + 9);
		n -= 2;
	}
	
	if(!n){
			for(int i : s) cout<<i<<' ';
			cout<<'\n';
			return 0;
		}
}


Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>
int main (void)
{
    int S,h,m,s;
    scanf("%d",&S);
    h = S/3600;
    m = (S%3600)/60;
    s = (S%3600)%60;
    printf("%d:%d:%d\n",h,m,s);
   
}


Measured memory_bytes: 2056
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define rep(i,k,n) for(int (i)=(k);(i)<(n);(i)++)
#define max(a,b) (a)>(b)?(a):(b)
#define min(a,b) (a)<(b)?(a):(b)
#define abs(a) (a)>0 ?(a):-(a)
#define llong long long

int main(){
	llong A; scanf("%lld",&A);
	char s[5]; scanf("%s",s);
	llong ans=0;
	ans += (s[0]-'0')*A*100;
	ans += (s[2]-'0')*A*10;
	ans += (s[3]-'0')*A;
	ans /= 100;
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 1736
#include<stdio.h>
int a[110];
int main(){
	int n,i,j,s;
	scanf("%d",&n);
	for(i=1;i<=n;i++)scanf("%d",a+i);
	s=0;
	for(i=1;i<=n;i=j+1){
		for(j=i;a[j]==a[j+1];j++);
		s+=(j-i+1)/2;
	}
	printf("%d",s);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep_lr(i,l,r) for(int i=(l);i<(r);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<int, int, int> T;
constexpr int INF = INT_MAX >> 1;
constexpr ll LINF = 5000000000000000LL;
constexpr int MOD = 1000000007;


int main() {

	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	ll ans = a * c;
	ans = max(ans, a * d);
	ans = max(ans, b * c);
	ans = max(ans, b * d);
	cout << ans << endl;
}

Measured memory_bytes: 3632
def main():
    import heapq
    w,h=map(int,input().split())
    p=[int(input()) for _ in [0]*w]
    q=[int(input()) for _ in [0]*h]
    
    cnt1=w+1
    cnt2=h+1

    h=[]
    heapq.heapify(h)
    for i in p:
        heapq.heappush(h,[i,0])
    for i in q:
        heapq.heappush(h,[i,1])

    ans=0
    while h:
        i,j=heapq.heappop(h)
        if j==0:
            ans+=cnt2*i
            cnt1-=1
        else:
            ans+=cnt1*i
            cnt2-=1
    print(ans)
main()

Measured memory_bytes: 31528
N=int(input())
T = list(map(int,input().split()))
M=int(input())
P=[]
X=[]
for i in range(M):
    x1,y1=[int(i) for i in input().split()]
    P.append(x1)
    X.append(y1)

output=[]
for j in range(M):
    tmp=T.copy()
    tmp[P[j]-1]=X[j]
    output.append(str(sum(tmp)))

print('\n'.join(output))


Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int cmp(const void*p,const void*q)
{
	return (*(int*)p-*(int*)q);
}
int a[300000],b[300000],c[300000],d[300000];
int main()
{
	int n,m,i,j,k,l,r,z;
	scanf("%d%d",&n,&m);
	for(k=j=i=0;i<m;i++)
	{
		scanf("%d%d",&a[i],&b[i]);
		if(a[i]==1)
			c[j++]=b[i];
		if(b[i]==n)
			d[k++]=a[i];
	}
	z=0;
	if(c[0]!=0&&d[0]!=0)
	{
	    qsort(c,j,sizeof(c[0]),cmp);
        qsort(d,k,sizeof(d[0]),cmp);
		for(z=i=0;i<j;i++)
		{
			l=0;r=k-1;
			while(l<=r)
			{
				int m=(l+r)/2;
				if(d[m]<c[i])
					l=m+1;
				else if(d[m]>c[i])
					r=m-1;
				else
				{
					z=1;
					break;
				}
			}
		}
	}
	if(z)
		printf("POSSIBLE\n");
	else
		printf("IMPOSSIBLE\n");
	return 0;
}


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

#define endl '\n'

using namespace std;

int main(){

  cin.tie(0);     // cout と cin の同期を切る
  ios::sync_with_stdio(false);  /* cの stdioストリーム (printfとか)と*/
  int d,c;

  cin>>d>>c;

  cout<<d*c<<endl;

  return 0;

}



Measured memory_bytes: 3164
A, B, C, D, E, F = map(int, input().split())
num = (0, 0)
rec = 0
for a in range(101):
    for b in range(101):
        if a * A * 100 + b * B * 100 > F:
            break
        for c in range(100):
            if a * A * 100 + b * B * 100 + c * C > F:
                break
            for d in range(100):
                q = a * A * 100 + b * B * 100
                p = C * c + D * d
                if p > E * (a * A + b * B):
                    continue
                if p + q == 0:
                    continue
                if p + q <= F:
                    if rec <= 100 * p / (p + q):
                        rec = 100 * p / (p + q)
                        num = (p + q, p)
                else:
                    break

print(num[0], num[1])

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

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    rep(i, n) cin >> p[i];
    sort(p.begin(), p.end());
    int sum = 0;
    rep(i, k) sum += p[i];
    cout << sum << endl;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();
        final int x = scanner.nextInt();
        final int y = scanner.nextInt();

        final int[][] table = new int[n + 1][n + 1];
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= n; j++) {
                table[i][j] = Math.abs(i - j);
            }
        }

        table[x][y] = 1;
        table[y][x] = 1;

        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= n; j++) {
                table[i][j] = Math.min(table[i][j], table[i][x] + table[x][j]);
            }
        }

        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= n; j++) {
                table[i][j] = Math.min(table[i][j], table[i][y] + table[y][j]);
            }
        }

        final int[] counter = new int[n];
        for (int i = 1; i <= n; i++) {
            for (int j = i + 1; j <= n; j++) {
                counter[table[i][j]]++;
            }
        }

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


Measured memory_bytes: 52820