akhauriyash/Code-Regression huggingface dataset:
class PriorityQueue
  def initialize(array = [])
    @data = []
    array.each{|a| add(a)}
  end
  
  def add(element)
    @data.push(element)
    bottom_up
  end
  
  # @return Integer
  def peek
    @data[0]
  end

  # @return Integer
  def poll
    if size == 0
      return nil
    elsif size == 1
      return @data.pop
    else
      min = @data[0]
      @data[0] = @data.pop
      top_down
      return min
    end
  end
  
  # @return Integer
  def size
    @data.size
  end

  private

  def swap(i, j)
    @data[i], @data[j] = @data[j], @data[i]
  end

  
  def bottom_up
    idx = size - 1
    while(has_parent?(idx))
      parent_idx = parent_idx(idx)
      if @data[parent_idx] > @data[idx]
        swap(parent_idx, idx)
        idx = parent_idx
      else
        return
      end
    end
  end
  
  def top_down
    idx = 0
    while (has_child?(idx))
      a = left_child_idx(idx)
      b = right_child_idx(idx)
      if @data[b].nil?
        c = a
      else
        c = @data[a] <= @data[b] ? a : b
      end
      if @data[idx] > @data[c]
        swap(idx, c)
        idx = c
      else
        return
      end
    end
  end
  

  # @param Integer
  # @return Integer
  def parent_idx(idx)
    (idx - (idx.even? ? 2 : 1)) / 2
  end

  # @param Integer
  # @return Integer
  def left_child_idx(idx)
    (idx * 2) + 1
  end

  # @param Integer
  # @return Integer
  def right_child_idx(idx)
    (idx * 2) + 2
  end

  # @param Integer
  # @return Boolent
  def has_child?(idx)
    ((idx * 2) + 1) < @data.size
  end

  def has_parent?(idx)
    idx > 0
  end
end

s=gets.chomp
k=gets.to_i
require "set"
n=s.size
a=PriorityQueue.new
x=Set.new
1.upto(k){|i| 0.upto(n-i){|j|x.add(s[j,i])}; x.each{|m| a.add(m)};x=Set.new}
res=""
k.times{res=a.poll}
puts res

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

int main()
{
  double Load[102][102];
  int T,N,l,L,B;
  bool Lose[102],Back[102];

  while(1){
    cin>>N>>T>>L>>B;
    if(N+T+L+B==0)break;
    for(int i=0;i<N+1;i++){
      Lose[i]=false;
      Back[i]=false;
    }
    for(int i=0;i<T+1;i++){
      for(int j=0;j<N+1;j++)Load[i][j]=0;
    }
    for(int i=0;i<L;i++){
      cin>>l;
      Lose[l]=true;
    }
    for(int i=0;i<B;i++){
      cin>>l;
      Back[l]=true;
    }
    Load[0][0]=1;
    for(int i=1;i<T+1;i++){
      for(int j=0;j<N;j++){
	for(int k=1;k<=6;k++){
	  int dis=j+k;
	  if(dis>N)dis=N*2-dis;
	  if(Lose[dis]){
	    if(i<T)Load[i+1][dis]+=Load[i-1][j]/6;
	    else Load[i][dis]+=Load[i-1][j]/6;
	  }
	  else if(Back[dis])Load[i][0]+=Load[i-1][j]/6;
	  else {
	    Load[i][dis]+=Load[i-1][j]/6;
	  }
	}
      }
    }/*
    for(int i=0;i<T+1;i++){
      for(int j=0;j<N+1;j++)cout<<Load[i][j]<<" ";
      cout<<endl;
      }*/
    double ans=0;
    for(int i=0;i<T+1;i++)ans+=Load[i][N];
    printf("%.6f\n",ans);
  }
  return 0;
}

Measured memory_bytes: 1268
#include<cstdio>
typedef long long ll;
struct edge{
	ll to,next;
}e[10000000];
ll k=1,color[100010],head[100010];
ll bw[3];
inline void addedge(ll u,ll v){
	e[k]=(edge){v,head[u]};
	head[u]=k++;
}
inline void add(ll u,ll v){
	addedge(u,v); addedge(v,u);
}
bool tu(ll p){
	for(ll i=head[p];i!=0;i=e[i].next){
        ll v=e[i].to;
        if(color[v]==color[p]) return false;
        if(color[v]==0){
        	color[v]=3-color[p];
        	bw[color[v]]++;
        	if(!tu(v)) return false;
		}
    }
    return true;
}
int main(){
	ll n,m;
	scanf("%lld%lld",&n,&m);
	for(ll i=0;i<m;i++){
		ll a,b;
		scanf("%lld%lld",&a,&b);
		add(a,b);
	}
	color[1]=1;
	bw[1]++;
	if(tu(1)) printf("%lld",bw[1]*bw[2]-m);
	else printf("%lld",n*(n-1)/2-m);
}

Measured memory_bytes: 6528
#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>
#include<stdio.h>
#include <cstdint>
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)
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;



int a, b, total, tmp;

int main() {

	cin >> a >> b;

	tmp = b - a;

	rep(i, tmp) {
		total += i;
	}

	cout << total - a << endl;

	return 0;
}


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

int main()
{
  double r;
  cin >> r;

  cout << fixed << setprecision(6);
  cout << r * r * M_PI << " ";
  cout << 2 * r * M_PI << endl;

  return 0;
}

Measured memory_bytes: 3224
#include "bits/stdc++.h"
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef unsigned long long  ULL;

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

int main(int argc, char const *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    string S;
    cin >> S;

    vector<int> childrens(S.size(), 0);
    bool flgR = false;
    bool flgL = false;
    int idxL = 0;
    int idxR = 0;
    int cntR = 0;
    int cntL = 0;

    for(int i=0; i<S.size(); i++) {
        if(S[i] == 'L') {
            cntL++;
            if(!flgL){
                flgL = true;
                idxR = i-1;
                idxL = i;
            }
        }

        if(S[i] == 'R' && flgL || (i == (S.size() - 1))){

            int cntLinR = (cntL)/2;
            int cntLinL = cntL - cntLinR;

            int cntRinL = (cntR)/2;
            int cntRinR = cntR - cntRinL;

            childrens[idxR] = cntLinR + cntRinR;
            childrens[idxL] = cntRinL + cntLinL;


            flgL = false;
            cntL = 0;
            cntR = 1;
        }
        else if(S[i] == 'R' && !flgL) {
            cntR++;
        }
    }



    for (int i = 0; i < childrens.size(); i++) {
        if(i==0) cout << childrens[i];
        else cout << ' ' << childrens[i];
    }
    
    cout << endl;
    return 0;
}


Measured memory_bytes: 1104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
string s,t;
int dp[3005][3005];
char prre[3005][3005];
P pre[3005][3005];
int main(){
	cin>>s>>t;
	for(int i=0;i<=s.size();i++){
		for(int j=0;j<=t.size();j++){
			if(i){
				if(dp[i][j] < dp[i-1][j]){
					dp[i][j] = max(dp[i][j],dp[i-1][j]);
					pre[i][j] = mp(i-1,j);
				}
			}
			if(j){
				if(dp[i][j] < dp[i][j-1]){
					dp[i][j] = max(dp[i][j],dp[i][j-1]);
					pre[i][j] = mp(i,j-1);
				}
			}
			if(i && j){
				if(dp[i][j] < dp[i-1][j-1]){
					dp[i][j] = max(dp[i][j],dp[i-1][j-1]);
					pre[i][j] = mp(i-1,j-1);
				}
			}
			if(i && j && s[i-1] == t[j-1]){
				if(dp[i][j] < dp[i-1][j-1]+1){
					dp[i][j] = max(dp[i][j],dp[i-1][j-1]+1);
					pre[i][j] = mp(i-1,j-1);
					prre[i][j] = s[i-1];
				}
			}
		}
	}
	int ans = -1;
	P cur;
	for(int i=0;i<=s.size();i++){
		for(int j=0;j<=t.size();j++){
			if(ans < dp[i][j]){
				ans = dp[i][j];
				cur = mp(i,j);
			}
		}
	}
	string ret = "";
	while(cur != mp(0,0)){
		int x = pre[cur.fi][cur.sc].fi;
		int y = pre[cur.fi][cur.sc].sc;
		if('a'<=prre[cur.fi][cur.sc] && prre[cur.fi][cur.sc]<='z'){
			ret.pb(prre[cur.fi][cur.sc]);
		}
		cur = mp(x,y);
	}
	reverse(ret.begin(),ret.end());
cout<<ret<<endl;}

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

int main() {
  int N,cnt1=0,ans;
  cin>>N;
  for(int i=1;i<=N;i++){
    int cnt2=0,k;
    k=i;
    while(k%2==0){
    cnt2++;
    k/=2;
    }
    if(cnt1<=cnt2){cnt1=cnt2;ans=i;}
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    char s[n];
    for(int i=1;i<=n;i++)
    {
        cin>>s[i];
    }
    for(int i=k;i<=n;i++)
    {
        s[i]=s[i]+32;
        break;
    }
    for(int i=1;i<=n;i++)
    {
        cout<<s[i];
    }
}


Measured memory_bytes: 3636
#include <iostream>

using namespace std;
typedef long long ll;
int n, k;
ll dp[200000];
ll a[200000];

int main()
{
	cin >> n >> k;
	for (int i = 0; i < n; i++)
        dp[i] = 1e9;
    dp[0] = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        for (int j = 1; j <= k && i - j >= 0; j++)
        {
            dp[i] = min(dp[i], dp[i - j] + abs(a[i - j] - a[i]));
        }
        //cout << dp[i] << " ";
    }
    cout << dp[n - 1];
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  int n;
  cin >> n;

  string s;
  cin >> s;

  int ans = 0;
  for (char i = '0'; i <= '9'; i++) {
    for (char j = '0'; j <= '9'; j++) {
      for (char k = '0'; k <= '9'; k++) {
        bool A = false;
        bool B = false;
        bool C = false;
        for (int x = 0; x < n; x++) {
          char c = s[x];
          if (A == false) {
            if (c == i) {
              A = true;
              continue;
            }
          } else if (B == false) {
            if (c == j) {
              B = true;
            }
          } else {
            if (c == k) {
              C = true;
              break;
            }
          }
        }

        if (A && B && C) {
          ans++;
        }
      }
    }
  }

  cout << ans << endl;

  return 0;
}

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


using namespace std;

int main() {
	//input
	int n; cin >> n;
	vector<int> H(n);

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

	//compute
	int ans = 0;
	int max = 0;
	for (int i = 0;i < n;i++) {
		if (max <= H[i]) {
			max = H[i];
			ans++;
		}
	}

	//output
	cout << ans << endl;


}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define mod 998244353

using namespace std;
typedef long long ll;
const int MAXN = 10000005;
int n;
ll fac[MAXN],inv[MAXN],fin[MAXN],pw[MAXN];
inline ll c(int a, int b)
    { return a<b?0:fac[a]*fin[b]%mod*fin[a-b]%mod; }
inline ll qpow(ll a, int b)
{
	ll res = 1;
	for(; b; a = a*a%mod, b >>= 1)
	    if(b&1)
	    	res = res*a%mod;
	return res;
}

int main()
{
	cin >> n;
	inv[1] = 1;
	for(int i = 2; i<=n; i++)
		inv[i] = inv[mod%i]*(mod-mod/i)%mod;
	fac[0] = fin[0] = 1;
	for(int i = 1; i<=n; i++)
		fac[i] = fac[i-1]*i%mod, fin[i] = fin[i-1]*inv[i]%mod;
	pw[0] = 1;
	for(int i = 1; i<=n; i++)
		pw[i] = pw[i-1]*2%mod;
	ll ans = qpow(3,n);
	for(int i = n/2+1; i<=n; i++)
		ans = (ans-2*c(n,i)*pw[n-i]%mod+mod)%mod;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 312704
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int m = sc.nextInt();
		int count = 0;
		boolean match = false;
				
		char [][] a = new char [n][];
		char [][] b = new char [m][];
		
		for(int x = 0; x < n; x++){a[x] = sc.next().toCharArray();}
		for(int x = 0; x < m; x++){b[x] = sc.next().toCharArray();}
		
		match : for(int sx = 0; sx < n - (m-1); sx++){
				for(int sy = 0; sy < n - (m-1); sy++){
					
					count = 0;
					int bx = 0;
					int by = 0;
		
				for(int x = sx; x < m + sx; x++){
				for(int y = sy; y < m + sy; y++){
					
					if(a[x][y] == b[bx][by]){count += 1; 
					if(count == m * m){match = true; break match;}
					}
					by++;
		}
					bx++; by = 0;
		}
		}}
		
		if(match){System.out.println("Yes");}
		else{System.out.println("No");}
	}
}

Measured memory_bytes: 9940
#include <iostream>
#include <iomanip>

using namespace std;

double dp [305] [305] [305];
int n, nma, nmb, nmc;

double rek (int a, int b, int c) {
	if (a < 0 || b < 0 || c < 0) return 0;
	if (a == 0 && b == 0 && c == 0) return 0;
	if (dp [a] [b] [c]) return dp [a] [b] [c]; 
	dp [a] [b] [c] = (a * rek (a-1, b, c) + b * rek (a+1, b-1, c) + c * rek (a, b+1, c-1) + n) / (a + b + c);
	//cout << a << " " << dp [a] [b] [c] << endl; 
	//cout << a << " " << dp [a] [b] [c] << endl;
	return dp [a] [b] [c];
}

int main () {
	cin >> n;
	int irr, i;
	for (i = 0; i < n; i++) {
		cin >> irr;
		if (irr == 1) nma++;
		if (irr == 2) nmb++;
		if (irr == 3) nmc++;
	}
	//cout << 1 / (1 + (1 + 0 + 0 - n) / n) << endl;
	cout << setprecision(12) << rek (nma, nmb, nmc); 
	return 0;
}


Measured memory_bytes: 219392
n,A,B,C,=map(int,input().split())
l=[int(input()) for i in range(n)]
INF=1e9
def dfs(i,a,b,c):
  if i==n:
    if min(a,b,c)>0:
      return abs(A-a)+abs(B-b)+abs(C-c)-30
    else:
      return INF
  ret0=dfs(i+1,a,b,c)
  ret1=dfs(i+1,a+l[i],b,c)+10
  ret2=dfs(i+1,a,b+l[i],c)+10
  ret3=dfs(i+1,a,b,c+l[i])+10
  return min(ret0,ret1,ret2,ret3)

print(dfs(0,0,0,0))



Measured memory_bytes: 3064
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import bisect

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

def LI(): return list(map(int, sys.stdin.readline().split()))

A,B = LI()
now = 1
ans = 0
while now < B:
    now += (A - 1)
    ans += 1

print(ans)


Measured memory_bytes: 6856
#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;
#define MAX 36
void bubblesort(struct CARD A[], int N);
void selectionsort(struct CARD A[],int N);
struct CARD{char c;int number;};
int main()
{
    struct CARD poker1[MAX];struct CARD poker2[MAX];

    int N,i;
  scanf("%d", &N);
      for (i = 0; i<N;i++)
       // cin >> poker1[i].c >> poker1[i].number;
       scanf(" %c%d", &poker1[i].c,&poker1[i].number);
        for(int f = 0;f<N;f++)
            poker2[f]=poker1[f];

bubblesort(poker1,N);

        for(int a = 0;a<N-1;a++)
            {printf("%c%d", poker1[a].c,poker1[a].number);
            printf(" ");}
        printf("%c%d\n", poker1[N-1].c,poker1[N-1].number);
        puts("Stable");

selectionsort(poker2,N);

         for(int a = 0;a<N-1;a++)
            {printf("%c%d", poker2[a].c,poker2[a].number);
            printf(" ");}
        printf("%c%d\n", poker2[N-1].c,poker2[N-1].number);

        bool stb = 1;
        for(int a = 0;a<N;a++)
            if(poker1[a].c != poker2[a].c)
                stb = 0;
        if(stb == 1)
            puts("Stable");
        else
            puts("Not stable");
  return 0;
}

void bubblesort(struct CARD A[], int N)
{
    for( int i = 0;i<N; i++){
        for(int j = N-1; j>= i+1;j--){
            if(A[j].number <A[j-1].number){
                struct CARD t = A[j];
                A[j] = A[j-1];
                A[j-1] = t;
            }
        }
    }

}

void selectionsort(struct CARD A[],int N)
{
     for(int i=0;i<N;i++)
 {
     int minj = i;
     for(int j = i;j<N;j++)
     {
         if(A[j].number < A[minj].number)
                minj = j;
     }
                if(A[i].number != A[minj].number)
                {
                    CARD t = A[i];
                    A[i] = A[minj];
                    A[minj] = t;
                }
 }
}



Measured memory_bytes: 3200
#include<cstdio>
#include<vector>


using namespace std;

using vi=vector<int>;


int main(void)
{
	int n;

	while(scanf("%d", &n)==1)
	{
		vi a(n);
		int four=0, two=0;

		for(int i=0;i<n;i++)
		{
			scanf("%d", &a[i]);
			if(a[i]%4==0) four++;
			else if(a[i]%2==0) two++;
		}

		if(two>=2)
		{
			n-=two;
			n-=four*2;
		}
		else
		{
			n-=four*2+1;
		}
		printf("%s\n", n<=0?"Yes":"No");
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll          long long
#define pb          push_back
#define eb 			emplace_back
#define mp 			make_pair
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define fi          first
#define si          second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define checkbit(n, b) ((n >> b) & 1)
#define mod        1000000007
#define inf        1000000000000000000
#define puts(n)		cout<<n;
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define setbits(x) __builtin_popcount(x)
#define mset(m,v) memset(m,v,sizeof(m))
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll h,n;
	cin>>h>>n;
	ll a[n],sum=0;
	for(ll i=0;i<n;i++){
		cin>>a[i];
		sum+=a[i];
	}
	if(h>sum) cout<<"No";
	else cout<<"Yes";
	return 0;
}

Measured memory_bytes: 1024
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
#include <numeric>
#include <random>
#include <climits>  // A/Bを計算するときA==LLONG_MIN && B==-1のみ(1ull<<63)で代用
using namespace std;

typedef long long LL;
typedef pair<LL, LL> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef vector<VL> VVL;				// VVL v(100,VL(100,0));
typedef vector<pair<LL, LL> > VP;
typedef vector<string> VS;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<LL, pair<P, P> > PP;

#define INF 999999999999999997		// 少し加算したらオーバーフローする
#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(LL i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
#define O(s) cout<<s<<endl;
#define SORTVL(v) sort(v.begin(), v.end());
#define SORTVL_GR(v) sort(v.begin(), v.end(), greater<LL>());

#define DUMP_VVI(b) if(dbgF){FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}

template<class T>T IN() { T d; cin >> d; return d; }

LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a % b) : a; } // 最大公約数（Greatest Common Divisor）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; } // 最小公倍数（Least Common Multiple）
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); } // うるう年判定
string Replace(string S, string from, string to) { auto p = S.find(from); while (p != string::npos) { S.replace(p, from.size(), to); p = S.find(from, p + to.size()); }return S; }
// 桁和
LL Ketawa_s(string s) { LL a = 0; FOR(i, 0, s.length())a += s[i] - '0'; return a; }
// 末尾数字で切り上げ
LL CeilLastNumber(LL n) { return ((n + (10 - 1)) / 10) * 10; }
//二項係数 nCk mod pを求める
const LL MAX = 510000, p = 998244353; LL fac[MAX], finv[MAX], inv[MAX];
/* 前処理 */void COM_init() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; FOR(i, 2, MAX) { fac[i] = fac[i - 1] * i % p; inv[i] = p - inv[p % i] * (p / i) % p; finv[i] = finv[i - 1] * inv[i] % p; } }
/* 主処理 */LL COM(int n, int k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % p) % p; }

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

// -------------------------------------------------------------------------------

int main() {
	FAST_IO;
	bool dbgF = true; // for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;

	string S, T;
	cin >> S >> T;
	cout << T << S << endl;

	return 0;
}

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

int main(){
       for(int x,y; ; ){
	      cin>>x>>y;

	      if(x==0 && y==0) break;

	      if(y<x){
		     cout<<y<<' '<<x<<endl;
	      }else{
		     cout<<x<<' '<<y<<endl;
	      }
       }

       return 0;
}

Measured memory_bytes: 3080
D=int(input())
c = list(map(int,input().split()))
s=[[0 for e in range(26)] for f in range(D)]
for i in range(D):
 s[i]=list(map(int,input().split()))
last=[0]*26
ans=0
point=[0]*D
for i in range(D):
 saidai=-(10**10)
 kouho=1
 for j in range(26):
  if s[i][j]+c[j]*((i+1)-last[j])>=saidai:
   kouho=j+1
   saidai=s[i][j]+c[j]*((i+1)-last[j])
 print(kouho)

Measured memory_bytes: 9528
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var s = input.ReadLine();
        var t = input.ReadLine();

        if (t.Length != s.Length + 1) return No;

        for(int i=0; i<s.Length; i++) {
            if (t[i] != s[i]) return No;
        }

        return Yes;
    }

    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


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

int main()
{
    const int N = 100;
    const int M = 100;
    const int L = 100;

    int a[N][M];
    int b[M][L];
    long c[N][L];

    memset(a, 0, sizeof(a));
    memset(b, 0, sizeof(b));
    memset(c, 0, sizeof(c));

    int n, m, l;
    cin >> n >> m >> l;

    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < m; j++)
        {
            cin >> a[i][j];
        }
    }
    for(int i = 0; i < m; i++)
    {
        for(int j = 0; j < l; j++)
        {
            cin >> b[i][j];
        }
    }

    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < l; j++)
        {
            long s = 0;
            for(int k = 0; k < m; k++)
            {
                s += a[i][k]*b[k][j];
            }
            c[i][j] = s;
            if(j > 0)
                cout << ' ';
            cout << c[i][j];
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 3256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int n, m;
	cin >> n >> m;
	vector<int> item(n);
	int total = 0;
	for (int i = 0; i < n; i++) {
		cin >> item.at(i);
		total += item.at(i);
	}
 
	sort(item.begin(), item.end());
	reverse(item.begin(), item.end());
	for (int i = 0; i < m; i++) {
		if ((item.at(i) * 4 * m) < total) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using LL=long long;
int main(){
  LL N;cin>>N;
  vector<pair<LL,pair<LL,LL>>>AB(N);
  for(auto &ab:AB){
    LL A,B;cin>>A>>B;
    ab={A+B,{A,B}};
  }
  sort(AB.begin(),AB.end(),greater<>());
  LL ans=0;
  for(int i=0;i<N;i++){
    if(i%2==0)
      ans+=AB[i].second.first;
    else
      ans-=AB[i].second.second;
  }
  cout<<ans<<endl;
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
const ll mod = 1e9+7;

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

  int n; cin >> n;

  unordered_map<int, int> unmp;
  for(int i = 1; i <= n; i++) {
    int tmp = i;
    for(int j = 2; j <= i; j++) {
      while(tmp%j == 0) {
        tmp /= j;
        unmp[j]++;
      }
    }
  }

  ll ans = 1;
  for(auto elem : unmp) {
    ans *= (elem.second+1);
    ans %= mod;
  }

  cout << ans << '\n';
  return 0;
}


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

#define fi first
#define se second
#define FO(x, n) for (int x = 0; x < n; ++x)
#define FOR(x, a, b) for (int x = a; x < b; ++x)
#define RFO(x, n) for (int x = n - 1; x >= 0; --x)
#define RFOR(x, a, b) for (int x = b - 1; x >= a; --x)
#define FOR_ITER(x, a) for(auto x = a.begin(); x != a.end(); ++x)



using namespace std;
typedef unsigned char byte;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<string, string> pss;
typedef pair<ll, ll> pll;
inline bool feq(const double& a, const double& b) { return fabs(a - b) < 1e-10; }

using namespace std;


int main(){
//    int n, l;
//    cin >> n >> k;
//    vector<bool> dislike(10, false);
//
//    FOR(i, 0, k) {
//        int t;
//        cin >> t;
//        dislike[t] = true;
//    }

    ll a[3];
    FO(i, 3) {
        cin >> a[i];
    }
    sort(a, a+3);

    cout <<(a[0]+a[1]==a[2]?"Yes":"No")<< endl;


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <math.h>
using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;

    cout << ((a <= c && c <= b) ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
n,k,q=map(int,input().split())
a=[int(input()) for i in range(q)]
ct=[0 for i in range(n)]
for i in range(q):
  ct[a[i]-1]+=1
for i in range(n):
  if k-(q-ct[i])>0:
    print('Yes')
  else:
    print('No')

Measured memory_bytes: 8628
#include<bits/stdc++.h>
#define maxn 505
using namespace std;
typedef long long ll;
int a[maxn][maxn];
int main()
{
    ios::sync_with_stdio(0); cin.tie(0);
    int n, m, q;
    cin >> n >> m >> q;
    while (m--){
        int l, r;
        cin >> l >> r;
        ++a[l][r];
    }
    for (int i = n; i >= 1; --i){
        for (int j = 1; j <= n; ++j){
            a[i][j] += a[i + 1][j] + a[i][j - 1] - a[i + 1][j - 1];
        }
    }
    while (q--){
        int l, r;
        cin >> l >> r;
        cout << a[l][r] << endl;
    }
    return 0;
}


Measured memory_bytes: 1920
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list
#from itertools import combinations # (string,3) 3回

mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    import collections
    import bisect
    n,m = readInts()
    p = [[int(j) for j in input().split()] for i in range(m)]
    a = collections.defaultdict(list)
    for x,y in sorted(p):
        a[x] += [y]
    #print(a)
    for x,y in p:
        z = bisect.bisect_right(a[x],y)
        print("%06d%06d"%(x,z))



if __name__ == '__main__':
  main()


Measured memory_bytes: 41016
#include<bits/stdc++.h>
using namespace std;
#define int  long long 
#define speedrap ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
double be(double a,int b,int mod) {if(b == 0) return 1; if(b%2 == 1) return (a*be(a,b-1,mod)); else return (be(a,b/2,mod)*be(a,b/2,mod));}
const int mod = 1e9 + 7;
#define PI 3.14159265359
#define pf push_front
#define pb push_back
#define bitcount __builtin_popcount
#define sc(a) scanf("%d", &a);
#define sz(s) (int)s.size()
#define eb emplace_back
#define pf push_front
#define mkp(x,y) make_pair(x,y)
#define all(x) x.begin(),x.end()
#define INF 0x3f3f3f3f
const int siz = 2*(1e5 + 10);
const int logi = 21;
const double epsilon = 1e-6;
int prime[siz];
int has[siz];
bool cmp(const int &a,const int &b)
{
  return (abs(a-b)>1);
}

vector<int> vt[siz];


signed main()
{
	#ifndef ONLINE_JUDGE
 	freopen("in.txt", "r", stdin);
 	freopen("out.txt", "w", stdout);
 	#else
// // online submission
 	#endif 
	speedrap
	int t;
	t = 1;
	//cin>>t;
	while(t--)
	{	
		int n,m;
		cin>>n>>m;

		int a[n+1];

		for(int i = 1 ; i <= n ; i++)
		{
			cin>>a[i];
		}
		set<pair<int,int>> st;
		while(m--)
		{
			int u,v;
			cin>>u>>v;

			if(u > v)
			{
				swap(u,v);
			}

			if(st.find(make_pair(u,v)) != st.end())
			{
				continue;
			}
			st.insert(make_pair(u,v));
			vt[u].push_back(v);
			vt[v].push_back(u);
		}


		int cnt = 0;
		for(int i = 1 ; i <= n ; i++)
		{
			int go = a[i];
			int flag = 0;
			for(int j = 0 ; j < vt[i].size() ; j++)
			{
				if(a[vt[i][j]] >= go)
				{
					flag = 1;
				}
			}

			if(flag == 0)
			{
				cnt++;
			}

			//cout<<i<<" "<<flag<<"\n";
		}

		cout<<cnt;
	}
}

Measured memory_bytes: 18868
import java.io.*;

public class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder output = new StringBuilder();
		for(int i=0; i < 10001; i++){
			int data = Integer.parseInt(input.readLine());
			if( data == 0){
				break;
			}
			output.append("Case ").append(Integer.toString(i+1)).append(": ").append(Integer.toString(data)).append("\n");
		}
		System.out.print(output);
	}
}

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

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

    int W;   //考えやすいように重さとする
    cin >> W;

    vector<int> weight;
    weight.emplace_back(1);
    for(int i = 6; i <= W; i *= 6){
        weight.emplace_back(i);
    }
    for(int i = 9; i <= W; i *= 9){
        weight.emplace_back(i);
    }
    sort(weight.begin(), weight.end());

    int n = (int)weight.size();

    vector<int> dp(100010, 1e9);
    dp[0] = 0;

    for(int i = 0; i < n; i++){
        for(int w = weight[i]; w <= W; w++){
            dp[w] = min(dp[w], dp[w - weight[i]] + 1);
            /*
            -考えたこと
            w = 1 全てのdp配列は1になる
            w = 6 dp[6]から更新していく。dp[6]は1に更新される（6円の一回で下せるから）
            w = 36 （29行目から）min(dp[36], d[30] + 1) dp[30]は5になってるので5 + 1に更新
            …というのを6, 9の累乗と1で埋めていく
            */
            //cout << weight[i] << " " << w << " " << dp[w] << endl;
        }
    }
    cout << dp[W] << endl;

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<n;++i)

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 102;

struct edge{
	int to;
	int cost;
    int damage;
};

struct state{
    int pos;
    int damage;
    int rem;
    bool operator<(const state& another) const {
		return damage > another.damage;
	}
};

int a[MAX_N],d[MAX_N][MAX_N];
vector<edge> G[MAX_N];
int n,m,L;

void dijkstra(int s)
{
	priority_queue<state> que;
	d[s][L] = 0;
	que.push((state){s,0,L});
	while(!que.empty()){
		state S = que.top();
		que.pop();
		int v = S.pos;
        int c  = S.rem;
		if(d[v][c] < S.damage) continue;
		vector<edge>::iterator it = G[v].begin();
		rep(i,G[v].size()){
            if(c - G[v][i].cost >= 0){
                if(d[G[v][i].to][c - G[v][i].cost] > d[v][c]){
    				d[G[v][i].to][c - G[v][i].cost] = d[v][c];
    				que.push((state){G[v][i].to,d[G[v][i].to][c - G[v][i].cost],c - G[v][i].cost});
    			}
            }
            if(d[G[v][i].to][c] > d[v][c] + G[v][i].damage){
                d[G[v][i].to][c] = d[v][c] + G[v][i].damage;
                que.push((state){G[v][i].to,d[G[v][i].to][c],c});
            }
		}
	}
}

int main()
{
    while(1){
        scanf("%d%d%d",&n,&m,&L);
        if(n == 0 && m == 0 && L == 0){
            break;
        }
        rep(i,n){
            G[i].clear();
        }
        rep(i,m){
            int w,x,y,z;
            scanf("%d%d%d%d",&w,&x,&y,&z);
            G[w-1].push_back((edge){x-1,y,z});
            G[x-1].push_back((edge){w-1,y,z});
        }
        rep(i,n){
            fill(d[i],d[i]+L+1,INF);
        }
        dijkstra(0);
        int res = INF;
        rep(i,L+1){
            res = min(res,d[n-1][i]);
        }
        printf("%d\n",res);
    }
	return 0;
}

Measured memory_bytes: 3568
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i,e)for(int i=0;i<e;i++)
using namespace std;

int main(){
    int n, i, j;
    double x1, y1 , x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    double D = pow(x1-x2,2)+pow(y1-y2,2);
    printf("%.8f\n", sqrt(D));
    return 0;
}


Measured memory_bytes: 3284
#include<map>
#include<cstdio>
#include<algorithm>
using namespace std;
#define N 100005
#define LL long long
#define rep(i,j,k) for(i=j;i<=k;++i)
const int X[11]={2,3,5,7,11,13,17,19,23,29,31};
map<LL,int> mp;
int n,m,i,top,j,k,bit,ans,temp;
LL s,rem,ms[N],bs[N],fact[100];
void read(int &p){
	p=0; char x=getchar();
	while(x<'0' || x>'9') x=getchar();
	while(x>='0'&&x<='9'){p=p*10+x-'0'; x=getchar();}
}
void read(LL &p){
	p=0; char x=getchar();
	while(x<'0' || x>'9') x=getchar();
	while(x>='0'&&x<='9'){p=p*10+x-'0'; x=getchar();}
}
LL mul(LL a,LL b,LL mod){
	a%=mod; b%=mod;
	LL ans=a*b-(LL)((long double)a*b/mod+1e-8)*mod;
	while(ans<0) ans+=mod; while(ans>=mod) ans-=mod;
	return ans;
}
LL quick_mi(LL a,LL b,LL mod){
	LL sum=1;
	for(;b;b>>=1,a=mul(a,a,mod))
	if(b&1) sum=mul(sum,a,mod);
	return sum;
}
bool check(LL p,LL x){
	if(p==x) return true;
	int i; x=quick_mi(x,rem,p);
	if(x==1) return true;
	rep(i,1,bit){
		if(x==p-1) return true;
		x=mul(x,x,p);
		if(x==1) return false; 
	}
	return false;
}
bool isprime(LL p){
	if(p==1) return false;
	if(p==2) return true;
	if(!(p&1)) return false;
	bit=0; rem=p-1; int i;
	while(!(rem&1)) rem>>=1,bit++;
	rep(i,0,10)
	if(!check(p,X[i])) return false;
	return true;
}
LL gcd(LL a,LL b){ return b==0?a:gcd(b,a%b); }
LL pho(LL n,int a){
	int cnt=0,std=1; LL x=2,y=2,d;
	while(1){
		cnt++; x=(mul(x,x,n)+a)%n;
		d=gcd(n,x>y?x-y:y-x);
		if(d>1) return d;
		if(cnt==std) std<<=1,y=x;
	}
}
void find(LL n){//1Ò»¶¨ÒªÌØ±ðÅÐ¶Ï 
	if(isprime(n)){
		top++; fact[top]=n;
		return ;
	}
	LL d,a=1;
	while((d=pho(n,a))==n) a++;
	find(d); find(n/d);
}
int main(){
//	freopen("in.txt","r",stdin);
	read(n);
	rep(i,1,n){
		read(s); top=0;
		if(s==1){
			if(!ans) ans=1;
			continue ;
		}
		find(s);
		sort(fact+1,fact+1+top); 
		temp=fact[top+1]=0; ms[i]=bs[i]=1;
		rep(j,1,top){
			temp++;
			if(fact[j]!=fact[j+1]){
				temp%=3;
				if(temp==1) ms[i]=ms[i]*fact[j],bs[i]=bs[i]*fact[j]*fact[j];
				if(temp==2) bs[i]=bs[i]*fact[j],ms[i]=ms[i]*fact[j]*fact[j];
				temp=0;
			}
		}
		if(ms[i]==1){
			if(!ans) ans++;
			continue ;
		}
		mp[ms[i]]++;
	}
	rep(i,1,n)
	if(ms[i]){
		ans+=max(mp[ms[i]],mp[bs[i]]);
		mp[ms[i]]=mp[bs[i]]=0;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 14336
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007

int main(){
    int n,m,c;
    cin>>n>>m>>c;
    int a[n][m],b[m];
    rep(i,m){
        cin >> b[i];
    }
    rep(i,n){
        rep(j,m){
            cin >> a[i][j];
        }
    }
    int sum,ans=0;;
    rep(i,n){
        sum = 0;
        rep(j,m){
            sum += a[i][j]*b[j];
        }
        if(sum+c>0){
            ans++;
            //cout<<"sum="<<sum<<endl;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<map>
#include<array>

using lr = std::pair<int, int>;
using lr_map = std::map<lr, int>;

int rc(int mat[], lr_map &dp, int n, int rest_n, int limit);

int main()
{
	int n, mat[101]{}, count{};
	lr_map dp;

	scanf("%d%d%d", &n, mat, mat + 1);
	for (int i = 1; i < n; ++i)
		scanf("%d%d", mat + i, mat + i + 1);

	printf("%d\n", rc(mat, dp, 0, n, 2000000000));

	return 0;
}

int rc(int mat[], lr_map &dp, int left, int right, int min)
{
	if (left + 1 == right) return 0;
	if (dp.find(lr{ left, right }) != dp.end()) return dp[lr{ left, right }];

	for (int mid = left + 1; mid < right; ++mid)
	{
		int tmp = mat[left] * mat[mid] * mat[right];
		tmp += rc(mat, dp, left, mid, min);
		if (tmp > min) continue;

		tmp += rc(mat, dp, mid, right, min);
		if (tmp > min) continue;

		min = tmp;
	}
	dp[lr{ left, right }] = min;
	return min;
}


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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{

int X;
	cin >> X;
	fz(X+1) {

		bool flag = false;
		for (int x = 0; x * 102 <= z; x++) {
			for (int y = 0; y * 101 + x*102 <= z; y++) {
				if ((z-x*102-y*101)%100==0) {
					flag = true;
					x = z, y = z;
				}
			}
		}

		if (flag) {
			for (int x = 0; x * 105 <=X- z; x++) {
				for (int y = 0; y * 104 + x*105 <=X- z; y++) {
					if ((X-z - x * 105 - y * 104) % 103 == 0) {
						ce(1)
						return 0;
					}
				}
			}
		}

	}
	ce(0)


    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef dbg
#include "./printer.hpp"
#else
#define dump(x) void(0)
#endif

using namespace std;
#define ll long long
inline long  toInt(string s) {long  v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
#define INF 100000

int main(){
  ios_base::sync_with_stdio(0);

  vector<ll> a;
  ll e;
  while(scanf(" %d", &e) != EOF){
    a.push_back(e);
  }
  sort(a.begin(),a.end(),[] (ll a, ll b) {return a > b;});
  cout << a[0] << '\n' << a[1] << '\n' << a[2] << '\n';
  
  return 0;

}

Measured memory_bytes: 3276
#include<bits/stdc++.h>
using namespace std;
int f[100005][3];
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
	    cin>>f[i][0]>>f[i][1]>>f[i][2];
	}
	for(int i=2;i<=n;i++){
	    f[i][0]+=max(f[i-1][1],f[i-1][2]);
	    f[i][1]+=max(f[i-1][2],f[i-1][0]);
	    f[i][2]+=max(f[i-1][1],f[i-1][0]);
	}
	cout<<max({f[n][0],f[n][1],f[n][2]});
}


Measured memory_bytes: 4736
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**8) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

INF = pow(10,15)
SIZE = pow(10,5)+1

n,w = li()
wv = [tuple(li()) for _ in range(n)]

dp = [[INF]*(SIZE + 10) for _ in range(n+1)]
for i in range(n+1):
    dp[i][0] = 0

for idx in range(n):
    wi, vi = wv[idx]
    for val in range(SIZE):
        if val - vi < 0:
            dp[idx+1][val] = min(dp[idx+1][val],
                                 dp[idx][val])
            
        else:
            dp[idx+1][val] = min(dp[idx+1][val],
                                 dp[idx][val-vi]+wi,
                                 dp[idx][val])
        

ans = 0     
for val in range(SIZE):
    if dp[n][val] <= w:
        ans = val
        
print(ans)
    

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
    int n;cin>>n;
    vii a;
    if(n%2==0){
        for(int i=1;i<=n;++i){
            for(int j=i+1;j<=n;++j){
                if(i+j!=n+1){
                    a.PB(MP(i,j));
                }
            }
        }
    }
    else{
        for(int i=1;i<=n;++i){
            for(int j=i+1;j<=n;++j){
                if(i+j!=n){
                    a.PB(MP(i,j));
                }
            }
        }
    }
    cout<<a.size()<<endl;
    rep(i,a.size()){
        cout<<a[i].F<<" "<<a[i].S<<endl;
    }
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cstdio>

using namespace std;

template<class T>
struct SkewHeap {

private:

  struct node{
    node *lch,*rch;
    T val;
    node(T val):val(val){ lch=rch=NULL; }
  } *root;


public:

  SkewHeap(){root=NULL;}

  node *meld(node *a,node *b){
    if(!a || !b)return a?a:b;
    if(a->val < b->val)swap(a,b);
    a->rch=meld(a->rch,b);
    swap(a->lch,a->rch);
    return a;
  }

  void push(T x){ root=meld(root,new node(x)); }
  
  void pop(){
    //node *tmp=root;
    root=meld(root->rch,root->lch);
    //delete tmp;
  }

  T top(){ return root->val; }
  bool empty(){ return !root; }
  void clear(){ while(!empty())pop(); }
};

int main(void){

  SkewHeap<int> que;
  char ch[10];
  int k;

  while(true){
    scanf(" %s",ch);
    if(ch[2]=='d')break;
    if(ch[0]=='i'){
      scanf("%d",&k);
      que.push(k);
    } else {
      printf("%d\n",que.top());
      que.pop();
    }
  }

  return 0;
}

Measured memory_bytes: 48056
N, C = map(int, input().split())
sushi = [(0, 0)]
for _ in range(N):
    x, v = map(int, input().split())
    sushi.append((x, v))
# preprocess
cumsum = [(0, 0)]
cumsum_max = [(0, 0)]
prev = 0
for x, v in sushi[1:]:
    cumsum.append((x, cumsum[-1][1] + prev + v - x))
    cumsum_max.append(cumsum_max[-1] if cumsum_max[-1][1] > cumsum[-1][1] else cumsum[-1])
    prev = x
cumsum_rev = [(0, 0)]
cumsum_rev_max = [(0, 0)]
prev = 0
for x, v in reversed(sushi[1:]):
    cumsum_rev.append((C - x, cumsum_rev[-1][1] + prev + v - (C - x)))
    cumsum_rev_max.append(cumsum_rev_max[-1] if cumsum_rev_max[-1][1] > cumsum_rev[-1][1] else cumsum_rev[-1])
    prev = C - x
ans = 0
for i in range(N+1):
    temp1 = cumsum_max[N-i][1] + cumsum_rev[i][1] - cumsum_rev[i][0]
    temp2 = cumsum_rev_max[N-i][1] + cumsum[i][1] - cumsum[i][0]
    ans = max(ans, temp1, temp2)
print(ans)

Measured memory_bytes: 44712
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
  int n;
  while(1){
    cin>>n;
    if(n==0) return 0;
    int r[1001], w[1001];
    int s=0, sw=0;
    for(int i=0; i<n; i++){
      cin>>r[i]>>w[i];
      s+=r[i];
      sw+=w[i];
    }
    if(n==1){
      cout<<2*r[0]+w[0]<<endl;
      continue;
    }
    int i0=max_element(r, r+n)-r;
    if(2*r[i0]<=s){
      cout<<s+sw<<endl;
      continue;
    }
    bool dp[1010]={};
    dp[0]=1;
    for(int i=0; i<n; i++){
      if(i==i0) continue;
      for(int j=2*r[i0]-s; j>=w[i]; j--){
        if(dp[j-w[i]]) dp[j]=1;
      }
    }
    int d=0;
    for(int j=2*r[i0]-s; j>=0; j--){
      if(dp[j]){
        d=j;
        break;
      }
    }
    cout<<2*r[i0]+sw-d<<endl;
  }
	return 0;
}


Measured memory_bytes: 3084
import java.util.*;
class Main{

  public static void main(String args[]){
    Scanner sc=new Scanner(System.in);
   int n=sc.nextInt();
    long a=0;
    long arr[]=new long[n];
    for(int i=0;i<n;i++){
      arr[i]=sc.nextInt();
    }
    for(int i=1;i<n;i++){
     if(arr[i]<arr[i-1]){
       long k=arr[i-1]-arr[i];
       a=a+k;
       arr[i]=arr[i]+k;
     }
    }
    System.out.println(a);
  }}
  


Measured memory_bytes: 61376
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <queue>
#include <utility>
#include <climits>
#include <bitset>
#include <cmath>

#define MOD 1000000007

using namespace std;

typedef long long ll;

typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<vl> vvl;
typedef vector<vi> vvi;

typedef pair<ll, ll> pll;
typedef pair<int, int> pi;

typedef vector<pll> vpl;
typedef vector<pi> vpi;

typedef queue<ll> ql;
typedef queue<int> qi;

template <class T>
void printv(vector<T> vc) {
    for (auto e: vc) cout << e << " ";
    cout << endl;
}

template <class T>
void printvv(vector<T> vvc) { 
    for (auto vc: vvc) {
        for (auto e: vc) cout << e << " ";
        cout << endl;
    }
}

template <class T>
void printvp(vector<pair<T, T> > vp) {
    for (auto pT: vp) cout << pT.first << " " << pT.second << endl;
}

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << min(b/ a, c) << endl;
    return 0;
}

Measured memory_bytes: 256
import sys 
import fractions
input = sys.stdin.readline

N, X = map(int,input().split())
x = list(map(int,input().split()))
xX = []

for i in x:
  xX.append(abs(i - X))

ans = xX[0]

for i in range(N):
  ans = fractions.gcd(xX[i],ans)

print(ans)

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

int main(){
    string s; cin >> s;
    string a = "CODEFESTIVAL2016";
    int cnt = 0;
    for(int i = 0; i < s.size(); i++) {
        if(s[i] != a[i]) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
n,a=map(int,input().split())
lst=list(map(int,input().split()))

z=len(lst)
dp=[[[0]*2501 for i in range(51)] for j in range(z+1)]
dp[0][0][0]=1

for i in range(z):
  x=lst[i]
  for j in range(z):
    for k in range(2451):
      dp[i+1][j][k]+=dp[i][j][k]
      dp[i+1][j+1][k+x]+=dp[i][j][k]

ans=0

for i in range(z+1):
  ans+=dp[-1][i][i*a]

print(ans-1)

Measured memory_bytes: 118656
import math
N, M = map(int, input().split())
if abs(N - M) >= 2:
    print(0)
elif abs(N - M) == 1:
    print(math.factorial(N) * math.factorial(M) % (10 ** 9 + 7))
elif abs(N - M) == 0:
    print(2 * math.factorial(N) * math.factorial(M) % (10 ** 9 + 7))

Measured memory_bytes: 5192