akhauriyash/Code-Regression huggingface dataset:
#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <climits>
#include <utility>
using namespace std;
#define omajinai ios::sync_with_stdio(false);cin.tie(nullptr);

#pragma region typedef 
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> P;
#pragma endregion

#pragma region define
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)
#define pb push_back
#define pf push_front
#pragma endregion

#pragma region const
const ld PI = 3.141592653589793;
const ll INF18 = 1e18;
#pragma endregion

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

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

ll weight[110], value[110];
ll dp[110][100100];

int main(){
omajinai;
    int n;
    ll w;
    cin >> n >> w;
    rep(i, n) cin >> weight[i] >> value[i];

    rep(i, n)for(int sum_w = 0; sum_w <= w; sum_w++){
        if(sum_w - weight[i] >= 0)
            chmax(dp[i+1][sum_w],
                dp[i][sum_w - weight[i]] + value[i]);
    
        chmax(dp[i+1][sum_w], dp[i][sum_w]);
    }

    cout << dp[n][w] << endl;

return 0;
}

Measured memory_bytes: 81764
from collections import Counter
n = int(input())
*a, = map(int, input().split())

if sum(a) == 0:
    print("Yes")
elif n % 3 != 0:
    print("No")
else:
    can_put_on = False
    c = Counter(a)
    if c[0] == n//3 and len(c) == 2:
        can_put_on = True
    if len(c) == 3:
        s = 0
        for k in c.keys():
            s ^= k
        if s == 0 and all(v == n//3 for v in c.values()):
            can_put_on = True

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


Measured memory_bytes: 14468
// RainFlowsIntoDam.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <cmath>
using namespace std;
#define max_N 100000
int main(){
	int n;
	cin >> n;
	int arr[max_N];
	int printable[max_N];
	int a = 0;
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
		if (i % 2 == 0) {
			a += arr[i];
		}
		else {
			a -= arr[i] ;
		}
	}
	cout << a << " ";
	int prev = a;
	for (int i = 1; i < n; i++) {
		int k = 2*arr[i-1] - prev;
		cout << k << " ";
		prev = k;
	}
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file


Measured memory_bytes: 1664
#include <cstdio>

int main(){
    int n, k;
    scanf("%d %d", &n, &k);
    if(n % 2 == 1){
        if(n / 2 + 1 >= k){
            printf("YES\n");
        }else{
            printf("NO\n");
        }
    }else{
        if(n / 2 >= k){
            printf("YES\n");
        }else{
            printf("NO\n");
        }
    }

    return 0;
}

Measured memory_bytes: 128
from collections import deque
n = int(input())
a = deque(map(int, input().split()))
b = deque()

for i in range(n):
    res = a.popleft()
    if i % 2 == 0:
        b.append(res)
    else:
        b.appendleft(res)

if n % 2 == 0:
    print(' '.join(map(str, b)))
else:
    print(' '.join(map(str, reversed(b))))


Measured memory_bytes: 28988
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner scan = new Scanner(System.in);
        
        int x = scan.nextInt();
        int white = scan.nextInt();
        
        int all = x * x;
        
        int ans = all - white;
        
        System.out.println(ans);
        
    }
}

Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
void solve () {
    string s;
    cin >> s;
    int n = (int) s.size();
    long long ans = 0;
    for (int i = 0; i < (1 << n)/2; i++) {
        int x = 0;
        for (int j = n - 1; j >= 0; j--) {
            if (i & (1 << j)) {
                x = 0;
            }
            ans += (s[j] - '0') * pow (10, x);
            x++;
        }
    }
    cout << ans;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 4032
#include <iostream>
using namespace std;
typedef long long ll;
int main()
{
	ll n,m;
	cin>>n>>m;
	ll brojac=0;
	if(n*2<=m)
	{
		m-=(n*2);
		brojac+=n;
		brojac+=(m/((ll)4));
	}
	else
	{
		brojac+=(m/((ll)2));
	}
	cout<<brojac<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define itn int
#define nibu(K,x) binary_search(K.begin(),K.end(),x)
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define out(x) cout<<x<<endl
#define put(x) out(x)
#define in(x) cin>>x
#define maxx(a,b,c) max(a,max(b,c))
#define minn(a,b,c) min(a,min(b,c))
using ll = long long;
using vl = vector<ll>;
using vs = vector<string>;
const double pi = 3.14159265358979;

int main() {
  string O,E;
  in(O);
  in(E);
 int a = sz(O);
  int b= sz(E);
  if(a ==b) {
   rep(i,a) cout << O[i] <<E[i]; 
  }
  else{
   rep(i,b) cout <<O[i] <<E[i];
    out(O[a-1]);
  }
  cout <<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 10000000000000000
#define endl '\n'
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; }
using namespace std;

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

    int n,k; cin>>n>>k; k++;
    vector<P> ab(n);
    rep(i,n)cin>>ab.at(i).F>>ab.at(i).S;

    int ans=0;
    for(int i=30; i>=0; i--){
        int bit=1<<i;
        if(k&bit){
            int sum=0;
            rep(j,ab.size()){
                if(!(ab.at(j).F&bit))sum+=ab.at(j).S;
            }
            chmax(ans,sum);
        }else{
            vector<P> tmp;
            rep(j,ab.size()){
                if(!(ab.at(j).F&bit))tmp.push_back(ab.at(j));
            }
            ab=tmp;
        }
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 6100
#include <iostream>
#include <cmath>
using namespace std;
int main(){
  long long n;cin >> n;
  long long  a=1, b=n;
  for(int i = 1; i <= (long long)sqrt((long long)n); i++){
    if(n%i == 0)a=i;
  }
  b=n/a;
  cout << a+b-2 << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int[] a = new int[3];
		Scanner cin = new Scanner(System.in);
		for(int i=0;i<3;i++) {
			a[i] = cin.nextInt();
		}
		for(int i=0;i<3;i++) {
			for(int j=i+1;j<3;j++) {
				int temp = 0;
				if(a[i]>a[j]) {
					temp = a[i];
					a[i] = a[j];
					a[j] = temp;
				}
			}
		}
		System.out.println(a[0] + " " + a[1] + " " + a[2]);
	}
}


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

using namespace std;
 
#define MAX 55000
#define INF 1e9
typedef long long Int;
 
int main(){
    Int a,b,d;
    while(cin >> a >> b >> d, a){
	Int x,y;
	Int ansx,ansy,min1,min2;
	ansx = ansy = min1 = min2 = INF;
	for(x = 0 ; x < MAX ; x++){
	    Int ax = a*x;
	    y = (ax+d) % b;
	    if(ax+d >= b && y == 0){
		y = (ax+d)/b;
		if(x+y < min1){
		    min1 = x+y;
		    ansx = x;
		    ansy = y;
		}else if(x+y == min1 && ax+b*x < min2){
		    min2 = ax+b*x;
		    ansx = x;
		    ansy = y;
		}
	    }
	}
	for(y = 0 ; y < MAX ; y++){
	    Int by = b*y;
	    x = (by+d) % a;
	    if(by+d >= a && x == 0){
		x = (by+d)/a;
		if(x+y < min1){
		    min1 = x+y;
		    ansx = x;
		    ansy = y;
		}else if(x+y == min1 && a*x+by < min2){
		    min2 = a*x+by;
		    ansx = x;
		    ansy = y;
		}
	    }
	}
	for(y = 0 ; y < MAX ; y++){
	    Int by = b*y;
	    x = (d-by) % a;
	    if(d-by >= a && x == 0){
		x = (d-by)/a;
		if(x+y < min1){
		    min1 = x+y;
		    ansx = x;
		    ansy = y;
		}else if(x+y == min1 && a*x+by < min2){
		    min2 = a*x+by;
		    ansx = x;
		    ansy = y;
		}
	    }
	}
	cout << ansx << " " << ansy << endl;
    }
    return 0;
}

Measured memory_bytes: 3028
#include <bits/stdc++.h>
using namespace std;
int main(){
	
	int N;
	cin >>N;
	vector<int> X(N);
	for(int i=0; i<N; i++){
		cin >>X.at(i);
	}
	
	sort(X.begin(),X.end());
	
	vector<int> Y(N);
	for(int i = 0; i<N; i++){
		
		Y.at(i) = (X.at(i))*(X.at(i));
		
	}
	
	int sum1=0;
	for(int i = 0; i<N; i++){
		
		sum1+=Y.at(i);
		
	}
	int sum2 = 0;
	for(int i=0; i<N; i++){
		sum2+=X.at(i);
	}
	
	int p =  sum2 / N;
	
	int q = p +1;
	
	int ans1,ans2,ans;
	
	ans1 = sum1 - 2*p*sum2+p*p*N;
	ans2 = sum1 - 2*q*sum2+q*q*N;
	
	ans = min(ans1, ans2);
	cout <<ans <<endl;
	
	
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a,b,tmp1,tmp2,tmp3,kouyaku;
	int koubai;
	
	while(scanf("%d %d",&a,&b)!=EOF)
	{
		tmp1=a;
		tmp2=b;
		if(a==0 || b==0)
		{
			kouyaku=0;
			koubai=0;
		}
		else
		{
			while((tmp3=tmp1%tmp2)!=0)
			{
				tmp1=tmp2;
				tmp2=tmp3;
			}	//ループが終わればtmp2が最大公約数
			kouyaku=tmp2;
		
			koubai=a/kouyaku*b;	//a*b/最大公約数ではオーバーフローする
		}
		printf("%d %d\n",kouyaku,koubai);
	}
	return 0;
}

Measured memory_bytes: 592
program main
      integer a,b,c,d,s,e
      read(*,*) a,b,c,d
      if (a .gt. c) then
            s = a
      else
            s = c
      end if
      if (b .lt. d) then
            e = b
      else
            e = d
      end if
      if (s .lt. e) then
            write(*,*) e-s
      else
            write(*,*) 0
      end if
      end

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int cookie = 0, i, allGlam, glam, min;
  
  scanf("%d %d", &i, &allGlam);
  min = allGlam;
  
  for (cookie = 0; cookie < i; cookie++) {
    scanf("%d", &glam);
    allGlam -= glam;
    if (allGlam < 0) break;
    if (glam < min) min = glam;
  }
  
  if (allGlam > 0) cookie += allGlam / min;

  printf("%d", cookie);
}

Measured memory_bytes: 128
import Control.Applicative
import Control.Monad
import Data.List

-- Top, Front, Right. Back, Left, Bottom
-- X: Right-Left, Y: Front-Back, Z: Top-Bottom
type Dice a = (a,a,a,a,a,a)

rollPX :: Dice a -> Dice a
rollPX (tp,fr,rg,bk,lf,bt) = (fr,bt,rg,tp,lf,bk)

rollNX :: Dice a -> Dice a
rollNX (tp,fr,rg,bk,lf,bt) = (bk,tp,rg,bt,lf,fr)

rollPY :: Dice a -> Dice a
rollPY (tp,fr,rg,bk,lf,bt) = (lf,fr,tp,bk,bt,rg)

rollNY :: Dice a -> Dice a
rollNY (tp,fr,rg,bk,lf,bt) = (rg,fr,bt,bk,tp,lf)

rollPZ :: Dice a -> Dice a
rollPZ (tp,fr,rg,bk,lf,bt) = (tp,rg,bk,lf,fr,bt)

rollNZ :: Dice a -> Dice a
rollNZ (tp,fr,rg,bk,lf,bt) = (tp,lf,fr,rg,bk,bt)

rollX :: Int -> Dice a -> Dice a
rollX n = if n >= 0 then (foldl (.) id (replicate (n `mod` 4) rollPX)) else (foldl (.) id (replicate ((-n) `mod` 4) rollNX))

rollY :: Int -> Dice a -> Dice a
rollY n = if n >= 0 then (foldl (.) id (replicate (n `mod` 4) rollPY)) else (foldl (.) id (replicate ((-n) `mod` 4) rollNY))

rollZ :: Int -> Dice a -> Dice a
rollZ n = if n >= 0 then (foldl (.) id (replicate (n `mod` 4) rollPZ)) else (foldl (.) id (replicate ((-n) `mod` 4) rollNZ))

allRolls :: Dice a -> [Dice a]
allRolls dice = tail $ scanl (\d f -> f d) dice  (concatMap (\f -> (rollPZ . f) : replicate 3 rollPZ) (take 6 (cycle [rollPX, rollPY])))

dTop (tp,_,_,_,_,_) = tp
dBottom (_,_,_,_,_,bt) = bt
dRight (_,_,rg,_,_,_) = rg
dLeft (_,_,_,_,lf,_) =lf
dFront (_,fr,_,_,_,_) = fr
dBack (_,_,_,bk,_,_) = bk



sameDice :: Eq a => Dice a -> Dice a -> Bool
sameDice d1 d2 = any (==d1) (allRolls d2)

main = do
  [d1,d2,d3,d4,d5,d6] <- map read . words <$> getLine :: IO [Int]
  [e1,e2,e3,e4,e5,e6] <- map read . words <$> getLine :: IO [Int]
  
  let
    dice = (d1,d5,d3,d2,d4,d6)
    dice2 = (e1,e5,e3,e2,e4,e6)

  putStrLn $ if sameDice dice dice2 then "Yes" else "No"



Measured memory_bytes: 3748
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

vector<vector<ll> > table;
vector<P> roads;
vector<P> qs;

int main() {
  ll A, B, K;

  cin >> A >> B >> K;

  for (int i = A; i <= B; i++) {
    if (i - A < K || B - i < K) cout << i << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using ll = long long;
using P = pair<ll,ll>;
using vec = vector<ll>;
using vecp = vector<P>;
using mat = vector<vec>;
using matp = vector<vecp>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define all(v) v.begin(), v.end()

int main(){
  ll N,Q;
  cin >> N >> Q;
  dsu A(N);
  rep(i,Q){
    ll t,a,b;
    cin >> t >> a >> b;
    if(t==0){
      A.merge(a,b);
    }else{
      if(A.same(a,b)){
        cout << 1 << endl;
      }else{
        cout << 0 << endl;
      }
    }
  }
}

Measured memory_bytes: 3996
#include<stdio.h>
int main()
{
int n,temp,sum=0;
scanf("%d",&n);
int l[2*n];
for(int i=0;i<2*n;i++)
{ 
   scanf("%d",&l[i]);
} 
    for(int i=0;i<2*n;i++)
    {
     for(int j=0;j<(2*n-i-1);j++)
      {
       if(l[j]>l[j+1])
         {
          temp=l[j];
          l[j]=l[j+1];
          l[j+1]=temp;
          }
         }
     } 
for(int i=0;i<2*n;i=i+2)
{
 sum=sum+l[i];
} 
printf("%d",sum);
return 0;
}


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

int main() {
  int N,i,b=1,c=0; 
  cin >> N;
  vector<int> a(N);

  for(i=0; i<N; i++)
    cin >> a.at(i);
  
  for(i=0; i<N; i++) {
    c++;
    b = a.at(b-1);
    if(b == 2)
      break;
  }

  cout << ((i==N) ? -1 : c) << endl;
}

Measured memory_bytes: 640
mod=10**9+7
import math
import sys
from collections import deque
import heapq
import copy
import itertools
from itertools import permutations
from itertools import combinations
import bisect
def mi() : return map(int,sys.stdin.readline().split())
def ii() : return int(sys.stdin.readline().rstrip())
def i() : return sys.stdin.readline().rstrip()
a=ii()
l=list(mi())
c=0
ans=0
if a==1:
  print(0)
else:
  for i in range(1,a):
    if l[i]<=l[i-1]:
      c+=1
    else:
      if ans<c:
        ans=c
      c=0
  print(max(ans,c))

Measured memory_bytes: 88984
//	ZapZu's code hohoho
//	#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define dfs_black 1
#define dfs_white -1
#define pr pair
#define vt vector
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef double db;
typedef long long li;
typedef long double ld;

typedef pr<int, int> ii;
typedef pr<ld,ld> dd;

typedef vt<int> vi;
typedef vt<li> vli;
typedef vt<ld> vld;
typedef vt<ii> vii;

typedef map<int, int> mii;
typedef map<int, bool> mib;
typedef map<int, char> mic;

typedef set<int> s_i;
typedef set<char> s_c;

const int MOD = 998244353;
const li INF = 1e18;
const ld PI = 4*atan((ld)1);
bool vs[200005];
int dp[200005];
int en[200005];
vi G[200005];
struct it
{
	vector<int> arr;
	void build(int n)
	{
		arr.assign(4*n+5, INT_MIN);
	}
	void update(int id, int l, int r, int pos, int val)
	{
		if(pos<l or r<pos) return;
		if(l==r and l==pos) arr[id]=val;
		else if(l!=r)
		{
			update(2*id, l, (l+r)/2, pos, val);
			update(2*id+1, (l+r)/2+1, r, pos, val);
			arr[id]=max(arr[2*id], arr[2*id+1]);
		}
	}
	int get(int id, int l, int r, int L, int R)
	{
		if(R<l or r<L) return INT_MIN;
		if(L<=l and r<=R) return arr[id];
		return max(get(2*id, l, (l+r)/2, L, R), get(2*id+1, (l+r)/2+1, r, L, R));
	}
};
int dfs(int u)
{
	vs[u]=1;
	int ans=1;
	for(auto v: G[u])
	{
		ans=ans*dfs(v)%MOD;
	}
	ans=(ans+1)%MOD;
	return ans;
}
signed main()
{
//	freopen(".inp", "r", stdin);
//	freopen(".out", "w", stdout);
	int n;
	cin>>n;
	it IT;
	IT.build(n);
	vii v(1);
	for(int i=1; i<=n; i++)
	{
		int a, d;
		cin>>a>>d; d=d+a-1;
		v.eb(a, d);
	}
	sort(begin(v)+1, end(v));
	for(int i=n; i>=1; i--)
	{
		int l=i, r=n;
		while(l<r)
		{
			int mid=(l+r+1)/2;
			if(v[mid].fi<=v[i].se) l=mid;
			else r=mid-1;
		}
		dp[i]=max(i, IT.get(1, 1, n,  i, l));
		IT.update(1, 1, n, i, dp[i]);
		en[dp[i]]++;
	}
	stack<int> st;
	for(int i=1; i<=n; i++)
	{
		if(!st.empty()) G[st.top()].eb(i);
		st.push(i);
		while(en[i]--)
		{
			st.pop();
		}
	}
	int ans=1;
	for(int i=1; i<=n; i++)
	{
		if(!vs[i]) ans=ans*dfs(i)%MOD;
	}
	while(ans<0) ans+=MOD;
	cout<<ans;
}
/*
8
-59 27
34 20
69 4
-22 38
62 24
5 25
-19 27
61 11
*/



Measured memory_bytes: 37928
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<int>>;
using P=pair<int,int>;

int i,j;
vector<int> w,s;
vector<int> prime(100001,1),prime_2017(100001,0);//素数なら１　合成数なら０
vector<int> sum;

void isprime(int N){//エラトステネスの篩
    prime[0]=0;
    prime[1]=0;
    for(i=2;i*i<=N;i++){
        if(prime[i]==0){continue;}
        for(j=i*i;j<=N;j+=i){
            prime[j]=0;
        }
    }
    return;
}

void isprime_2017(int N){//2017数のtable
    for(i=0;i<N;i++){
        if(prime[i]==1 && prime[(i+1)/2]==1){
            prime_2017[i]=1;
        }
    }
}

void pre_process(vector<int> &a, vector<int> &S) {
    int n=(int)a.size();
    S.assign(n+1,0);
    for(i=0;i<n;i++){
        S[i+1]=S[i]+a[i];
    }
}
 
// [i,j) の区間和を求める
int query(int I,int J,vector<int> &S){
    return S[J]-S[I];
}

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

    isprime(100000);//prime table
    isprime_2017(100000);//2017number table
    pre_process(prime_2017,sum);//累積和を作る

    vector<int> ans(q);

    for(i=0;i<q;i++){
        int l,r;
        cin>>l>>r;
        r++;
        ans[i]=query(l,r,sum);//区間内の2017数を累積和で求める
    }
    for(i=0;i<q;i++){
        cout<<ans[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include<string>
#include <stdio.h>
#include <vector>
#define MP make_pair
using namespace std;

int main(void){
    // Your code here!
vector<pair<string, int> >name(6);
name[0] = MP("A", 10);  
name[1] = MP("B", 11);  
name[2] = MP("C", 12);  
name[3] = MP("D", 13);  
name[4] = MP("E", 14);  
name[5] = MP("F", 15);  

    string a,b;
    int a_sum,b_sum;
    cin>>a>>b;
    
    for(int i=0;i<6;i++){
   if(name[i].first ==a)      a_sum=name[i].second;
      if(name[i].first ==b)      b_sum=name[i].second;
    }

    if(a_sum==b_sum) cout<<"="<<endl;
    else if(a_sum>b_sum)cout<<">"<<endl;
    else cout<<"<"<<endl;
}


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

int N, M;
pair<int, unsigned int> keys[1000];
int dp[1001][5000] = {};

int main(){
  cin >> N >> M;
  for(int i = 0; i < M; i++){
    int a, b;
    cin >> a >> b;
    keys[i].first = a;
    for(int j = 0; j < b; j++){
      int c;
      cin >> c;
      keys[i].second += (1 << (c - 1));
    }
  }

  for(int i = 0; i <= M; i++){
    for(int j = 1; j < (1 << N); j++){
      dp[i][j] = 1e9;
    }
  }

  for(int i = 0; i < M; i++){
    for(int j = 0; j < (1 << N); j++){
      dp[i + 1][j] = min(
			 dp[i][j],
			 dp[i][j & (~(keys[i].second))] + keys[i].first
			 );
      /*
      dp[i + 1][j | keys[i].second] = min(dp[i + 1][j | keys[i].second], min(
					  dp[i][j | keys[i].second],
					  dp[i][j] + keys[i].first
									    ));
      */
      //cout << i << ' ' << j  << ' ' << dp[i + 1][j] << endl;
    }
  }
  if(dp[M][(1 << N) - 1] == 1e9){
    cout << -1 << endl;
    return 0;
  }
  cout << dp[M][(1 << N) - 1] << endl;
}


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

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int num; cin >> num;
    set<char> a;

    for(int i=0; i<num; i++){
        char cha;
        cin >> cha;
        a.insert(cha);
    }

    if(a.size()==4) cout << "Four" << endl;
    else cout << "Three" << endl;

    return 0;
}

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

// clang-format off
#define forn(i, N) for (int i = 0; i < N; i++)
// clang-format on

int main()
{
  int N;
  cin >> N;
  vector<int> A(N), B(N), C(N);
  forn(i, N) cin >> A[i] >> B[i] >> C[i];

  long long dA = A[0], dB = B[0], dC = C[0];

  for (int i = 1; i < N; i++)
  {
    long long a = dA, b = dB, c = dC;
    dA = A[i] + max(b, c);
    dB = B[i] + max(a, c);
    dC = C[i] + max(a, b);
  }

  cout << max(dA, max(dB, dC)) << endl;

  return 0;
}


Measured memory_bytes: 4576
import java.util.Scanner;


public class Main {

    public static void main(String[] args) {



        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int sum = 0;

        for(int i = 1; i <= n; i++) {
        	int judge = 0;
        	int now = i;
        	while(true) {
        		judge += now % 10;
        		if(now < 10) {
        			break;
        		}
        		now /= 10;
        	}
        	if(judge >= a && judge <= b) {
        		sum += i;
        	}
        }
        System.out.println(sum);
    }
}

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

int main()
{
  int n, b;
  cin >> n >> b;
  int c[n];
  rep(i, n){
    cin >> c[i];
  }
  int ans = 0;
  sort(c, c + n);
  reverse(c, c + n);
  rep(i, b){
    ans += c[i];
  }
    
  

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


Measured memory_bytes: 3640
#include <iostream>
#include <cstdio>

using namespace std;

typedef long long ll;

ll n, k;
ll a[100005];
ll b[100005];
ll c[100005];
ll ans;
ll mn = 4e18;

int main()
{
    scanf("%lld%lld", &n, &k);
    for(ll i = 0; i < n; i++)
    {
        scanf("%lld", &a[i]);
        if(a[i] > 0) ans += a[i];
    }
    for(ll i = 0; i < k; i++)
    {
        if(a[i] > 0) b[0] += a[i];
        else c[0] -= a[i];
    }
    mn = min(mn, min(b[0], c[0]));
    for(ll i = 1; i + k <= n; i++)
    {
        b[i] = b[i - 1];
        c[i] = c[i - 1];
        if(a[i - 1] > 0) b[i] -= a[i - 1];
        else c[i] += a[i - 1];
        if(a[i + k - 1] > 0) b[i] += a[i + k - 1];
        else c[i] -= a[i + k - 1];
        mn = min(mn, min(b[i], c[i]));
    }
    printf("%lld", -mn + ans);
    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF LLONG_MAX/5
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
int mypow(int a,int b,int c){
	if(b==0)return 1;
	if(b%2)return mypow(a,b-1,c)*a%c;
	int z=mypow(a,b/2,c);
	return z*z%c;
}
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
vector<P> v;
signed main(){
	int b=0,c=0,a=0;
	string s;
	cin>>s;
	f(i,s.size()){
		if(s[i]=='>')c++;
		else if(c){
			a+=((max(b,c)+1)*max(b,c)+min(b,c)*(min(b,c)-1))/2;
			b=1,c=0;
		}
		else b++;
	}
	a+=((max(b,c)+1)*max(b,c)+min(b,c)*(min(b,c)-1))/2;
	cout<<a<<endl;
}


Measured memory_bytes: 900
#include <bits/stdc++.h>
#include <boost/range/adaptor/reversed.hpp>
#include <boost/range/algorithm/sort.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using boost::irange;
using boost::sort;
using boost::adaptors::reversed;

int main() {
    int n;
    cin >> n;
    n = n % 10;
    switch (n) {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
        cout << "hon" << endl;
        break;

    case 0:
    case 1:
    case 6:
    case 8:
        cout << "pon" << endl;
        break;

    case 3:
        cout << "bon" << endl;

    default:
        break;
    }

}


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

#define pb push_back
#define mk make_pair
#define fi first
#define se second
#define eb emplace_back

typedef long long ll;
typedef pair<int,int> ii;
typedef vector< pair<int,int> > vii;
const ll INF = 0x3f3f3f3f3f3fef;

const int V = 1e5+2;
const int N = 102;

ll dp[V];
ll p[N];
ll v[N];
ll n,w;

int main() {
    ios_base::sync_with_stdio(false);
    for(int i = 0; i < V; i++) dp[i] = INF;

    cin >> n >> w;
    for(int i = 0; i < n; i++) cin >> p[i] >> v[i];

    dp[0] = 0;

    for(int i = 0; i < n; i++)
        for(ll j = V-1; j-v[i] >= 0; j--)
            dp[j] = min(dp[j], dp[j-v[i]]+p[i]);

    for(int i = V-1; i >= 0; i--)
        if(dp[i] <= w) { cout << i << endl; return 0; }


    return 0;
}



Measured memory_bytes: 1024
import scala.math.max

object Main extends App{
  val sc = new java.util.Scanner(System.in)
  val N, M, K = sc.nextInt
  val A = Array.fill(N)(sc.nextLong)
  val B = Array.fill(M)(sc.nextLong)
  var t: Long = A.sum
  var idx = N - 1
  var ans = 0
  var tmp = N
  for(i <- 0 to M){
    if(i != 0){
      t += B(i - 1)
      tmp += 1
    }
    while(t > K && idx >= 0){
      t -= A(idx)
      idx -= 1
      tmp -= 1
    }
    if(t <= K) ans = max(ans, tmp)
  }
  println(ans)
}

Measured memory_bytes: 62220
#include<bits/stdc++.h>
#define int long long
using namespace std;

int32_t main(){
	ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int h,n;
    cin>>h>>n;
    int a[n],b[n];
    for(int i=0;i<n;i++){
    	cin>>a[i]>>b[i];
    }
    int min_cost[h+1];
    for(int i=0;i<=h;i++)
    	min_cost[i]=1e9;

    min_cost[0]=0;
    for(int i=1;i<=h;i++){
    	for(int j=0;j<n;j++){
    		if(a[j]>i){
    			min_cost[i]=min(b[j],min_cost[i]);
    		}
    		else{
    			min_cost[i]=min(b[j]+min_cost[i-a[j]],min_cost[i]);
    		}
    	}
    }
    cout<<min_cost[h]<<endl;
    return 0;
}

Measured memory_bytes: 384
#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;
ll K;
pair<int,int> P[101010];
 
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>K;
	FOR(i,N) {
		cin>>P[i].first>>P[i].second;
	}
	sort(P,P+N);
	FOR(i,N) {
		if(K<=P[i].second) {
			cout<<P[i].first<<endl;
			break;
		}
		K-=P[i].second;
	}
}
 
 
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: 1024
#include <stdio.h>

int main(void){
    int n;
    int ac = 0, wa = 0, tle = 0, re = 0;
    scanf("%d", &n);
    for (int i = 0; i < n; i++){
        char str[4];
        scanf("%s", str);
        switch (str[0]){
            case ('A'): ac++; break;
            case ('W'): wa++; break;
            case ('T'): tle++; break;
            case ('R'): re++; break;
        }
    }
    printf("AC x %d\n", ac);
    printf("WA x %d\n", wa);
    printf("TLE x %d\n", tle);
    printf("RE x %d\n", re);
    return 0;
}

Measured memory_bytes: 1716
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <stack>

using namespace std;



int main() {
    int n, m;

    scanf("%d%d", &n, &m);

    vector< pair<int, int> > ap(n);

    for (int i = 0; i < n; ++i) {
        int a, b;
        scanf("%d%d", &a, &b);
        ap[i] = make_pair(b, a);
    }

    sort(ap.begin(), ap.end(), greater< pair<int, int> >());

    set<int> s;

    for (int i = 0; i < m; ++i) {
        s.insert(i + 1);
    }

    int res = 0;

    for (int i = 0; i < n; ++i) {
        if (s.empty()) break;

        auto it = s.lower_bound(ap[i].second);

        if (it != s.end()) {
            s.erase(it);
            res+=ap[i].first;
        }
    }

    printf("%d\n", res);

    return 0;
}

Measured memory_bytes: 5760
import java.util.Scanner;

public class Main {

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

		if (check(S)) {
			System.out.println("AC");
		} else {
			System.out.println("WA");
		}
	}

	private static boolean check(String S) {
		if (S.charAt(0) != 'A') return false;
		
		int C = 0;
		for (int i = 2; i < S.length() - 1; i++) {
			if (S.charAt(i) == 'C') {
				C++;
			}
		}
		if (C != 1) return false;

		int upper = 0;
		for (int i = 0; i < S.length(); i++) {
			if (S.charAt(i) >= 'A' && S.charAt(i) <= 'Z') {
				upper++;
			}
		}
		if (upper != 2) return false;

		return true;
	}
}

Measured memory_bytes: 23508
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i32 = int32_t;
using i64 = int64_t;
constexpr char newl = '\n';

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
//#define F first
//#define S second
#define debug(x) cout << #x << ": " << x << '\n';
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1

class UnionFind {
public:
  UnionFind(int size) : size(size) {

    par = vector<int>(size, -1);
  }

  int GetRoot(int v) {
    int root = v;
    while (par[root] >= 0) {
      root = par[root];
    }
    if (root != v) {
      par[v] = root;
    }
    return root;
  }
  
  bool IsUnion(int a, int b) {
    int ra = GetRoot(a), rb = GetRoot(b);

    return ra == rb && ra >= 0;
  }

  int GetUnionSize(int a) {
    return -par[GetRoot(a)];
  }

  void Unite(int a, int b) {
    int ra = GetRoot(a), rb = GetRoot(b);

    if (ra == rb) return;

    if (GetUnionSize(ra) > GetUnionSize(rb)) {
      par[ra] += par[rb];
      par[rb] = ra;
    }
    else {
      par[rb] += par[ra];
      par[ra] = rb;
    }
  }

protected:

  // 親がいれば、親のindexを入れる
  // 親がいなければ、グループのサイズを負にして入れておく（一人なら-1）
  vector<int> par;
  
  int size;
};

// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N, M, K;
  cin >> N >> M >> K;

  // 友達の繋がりでたどり着ける数(A) - 直接の友達の数(B) - その中でのブロックの数(C)
  // (C)が難しい。 (A) - (B) の中に (C) は全て含まれるわけではないから。

  // (A) ... Union Find
  // (B) ... 別途カウントしておく
  // (C) ... それぞれのブロック相手ごとに、Union Findで同じグループか判定し、同じだったら 1 とカウント

  UnionFind uf(N);

  vector<int> fcnt(N);
  vector<vector<int>> blocks(N);

  F0R(i, M) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    fcnt[a]++; fcnt[b]++;
    uf.Unite(a, b);
  }

  F0R(i, K) {
    int c, d;
    cin >> c >> d;
    c--; d--;
    blocks[c].push_back(d);
    blocks[d].push_back(c);
  }

  F0R(i, N) {
    int a = uf.GetUnionSize(i) - 1;
    int b = fcnt[i];
    int c = 0;
    for (auto b : blocks[i]) {
      if (uf.IsUnion(i, b)) {
        c++;
      }
    }
    cout << (a - b - c) << ' ';
  }
}
#endif


Measured memory_bytes: 6784
/******

AUTHOR : RUDRANSH TRIPATHI, IIIT NAGPUR, CCID(rt24) & CFID(rsgt24)

MOTTO : Use criticism as fuel and you will never run out of energy.
        AIM : TO BECOME A BETTER CODER
        INTROSPECT + COURSE CORRECTIONS = CATALYST FOR SUCCESS
        Every moment is an opportunity to better yourself

*******/

#include<bits/stdc++.h>
using namespace std;
const int M = 1e9 + 7;
const int MAX = 1e5 + 5;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define int long long int
#define pb push_back
#define d(x) cout<<x<<"\n"

//basic mathematics
int gcd(int a, int b)
{
	if (a == 0)
		return b;
	return gcd(b % a, a);
}
int lcm(int a, int b)
{
	return (a * b) / gcd(a, b);
}

//modular arithmetic
int powermod(int x, int y, int p)
{
	int res = 1;

	x = x % p;

	if (x == 0) return 0;

	while (y > 0)
	{
		if (y & 1)
			res = (res * x) % p;
		y = y >> 1;
		x = (x * x) % p;
	}
	return res;
}

//Prime numbers till n precomputation - range query
int prefix[MAX + 1];

void buildPrefix()
{
	bool prime[MAX + 1];
	memset(prime, true, sizeof(prime));

	for (int p = 2; p * p <= MAX; p++) {
		if (prime[p] == true) {
			for (int i = p * 2; i <= MAX; i += p)
				prime[i] = false;
		}
	}
	prefix[0] = prefix[1] = 0;
	for (int p = 2; p <= MAX; p++) {
		prefix[p] = prefix[p - 1];
		if (prime[p])
			prefix[p]++;
	}
}

int query(int L, int R)
{
	return prefix[R] - prefix[L - 1];
}

vector<int> graph[500000];
bool visited[500000];
int total=0;

int dfs(int v){
    
	visited[v] = 1;
	int z = 1;
	for(auto x: graph[v]){
	    
		if(visited[x] == 0)
		{
		    z += dfs(x);
		}
		
	}
	
	return z;
}

void solve()
{
    total = 0;
    
	int n, m, i, j, u, v;
	cin >> n >> m;
	
	int max_1 = INT_MIN;
	
    while(m--)
    {
        int u,v;
        cin>> u >> v;
        max_1 = max({max_1 , u});
        graph[u].push_back(v);
		graph[v].push_back(u);
    }
    
    int xx = INT_MIN;
    int ans;
     
    for(int i = 0; i < n ; i++)
    {
        if(!visited[i])
        {
            //cout<<i<<"\n";
            ans = dfs(i);
            xx = max(xx , ans);
        }
    }
    
	cout << xx << "\n";
	
	for(int i=0;i<500000;i++)
	graph[i].clear();
	
	for(int i=0;i<500000;i++)
	visited[i]=0;
    
}

int32_t main(void)
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fastio
	int t = 1;
	//cin >> t;
	while (t--)
	{
		solve();
	}
	return 0;
}


Measured memory_bytes: 31404
#include <iostream>

using namespace std;

static const int MAX = 100;
static const int INFTY = (1<<21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[MAX][MAX];

int prim(){
  int u, minv;
  int d[MAX], p[MAX], color[MAX];
	
  for(int i=0;i < n;++i){
    d[i] = INFTY;
    p[i] = -1;
    color[i] = WHITE;
  }
	
  d[0] = 0;
	
  while(1){
    minv = INFTY;
    u = -1;
    for(int i=0;i < n;++i){
      if(minv > d[i] && color[i] != BLACK){
	u = i;
	minv = d[i];
      }
    }
    if(u == -1) break;
    color[u] = BLACK;
    for(int v=0;v < n;++v){
      if(color[v] != BLACK && M[u][v] != INFTY){
	if(d[v] > M[u][v]){
	  d[v] = M[u][v];
	  p[v] = u;
	  color[v] = GRAY;
	}
      }
    }
  }
  int sum = 0;
  for(int i=0;i < n;++i){
    if(p[i] != -1) sum += M[i][p[i]];
  }
  return sum;
}

int main(){
  cin >> n;
	
  for(int i=0; i < n;++i){
    for(int j=0; j < n;++j){
      int e; cin >> e;
      M[i][j] = (e == -1) ? INFTY : e;
    }
  }
	
  cout << prim() << endl;
	
  return 0;
}



Measured memory_bytes: 3132
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        try{
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            
            String S = br.readLine();
            String T = br.readLine();
            char charS[] = S.toCharArray();
            char charT[] = T.toCharArray();
            
            int ans = 0;
            for(int i=0; i<S.length(); i++){
                if(charS[i] != charT[i]){
                    charS[i] = charT[i];
                    ans++;
                }
            }
            
            System.out.println(ans);
            
        }catch(Exception e){
            System.out.println(e);
        }
    }
}

Measured memory_bytes: 37656
def gcd(a, b):
    if a == 0: return b
    else : return gcd(b % a, a)

def solve():
    a, b, c, d = map(int, input().split())
    if d < b:return "No"
    if a < b:return "No"
    if c >= b:return "Yes"
    g = gcd(d, b)
    a %= b
    if((c-a) // g != (b-a-1) // g):return "No"
    else: return "Yes"


for _ in range(int(input())):
    print (solve())

Measured memory_bytes: 3064
sx, sy, tx, ty = map(int, input().split())
 
right1 = ["R" for _ in range(tx-sx)]
up1 = ["U" for _ in range(ty-sy)]
left1 = ["L" for _ in range(tx-sx)]
down1 = ["D" for _ in range(ty-sy)]
hoge = ["D"]
right2 = ["R" for _ in range(tx-sx+1)]
up2 = ["U" for _ in range(ty-sy+1)]
hoge2 = ["LU"]
left2 = ["L" for _ in range(tx-sx+1)]
down2 = ["D" for _ in range(ty-sy+1)]
hoge3 = ["R"]
print("".join(right1+up1+left1+down1+hoge+right2+up2+hoge2+left2+down2+hoge3))

Measured memory_bytes: 3432
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n,k,q = LI()
    a = LI() + [-1]
    sa = sorted(a)
    r = sa[-1] - sa[0]
    # print(sorted([[a[i],i] for i in range(n)]))
    for i in range(1,n+1):
        if sa[i] == sa[i-1]:
            continue
        mi = sa[i]
        b = []
        c = 0
        for j in range(n+1):
            if a[j] < mi:
                if j - c >= k:
                    b += sorted(a[c:j])[:j-c-k+1]
                c = j + 1
        if len(b) < q:
            continue
        b.sort()
        t = b[q-1] - mi
        if r > t:
            r = t


    return r




print(main())



Measured memory_bytes: 6096
/**********************************************************************
   File hoge.cpp
   Author  harunaya
   Date   2020-03-04(Wed)
   note
**********************************************************************/

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
//#define PI(acos(-1))
using namespace std;
typedef long long ll;

int main() {
  int n, k;
  cin >> n >> k;
  double ans = 0;
  for (int i = 1; i <= n; i++ ) { //総計算量はO(NlogK)
    double p = 1;
    int x = i;
    while (x < k) { //whileループの回る回数(計算量)はO(log i)
      p *= 0.5;
      x *= 2;
    }
    ans += p / n;
  }
  printf("%.16f\n", ans); //%.10f で小数点以下10桁出力可
}


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

using namespace std;

int main(){
    int n,k;
    cin >> n >> k;

    if(n < 10){
        cout << (100*(10 - n)) + k << endl;
    } else {
  
    cout << k << 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 N;
    cin >> N;
    vector<int> A(N);
    rep(i,N) cin >> A[i]; 

    bool Unsorted = true;
    int SortedNum = 0; //Aの最初からSortedNum個目まではソート済
    int SwapNum = 0; //交換数

    while(Unsorted){
        Unsorted = false;
        for(int CurPos = N-1; CurPos >= SortedNum + 1; --CurPos){
            if(A[CurPos] < A[CurPos-1]){
                swap(A[CurPos], A[CurPos-1]);
                ++SwapNum;
                Unsorted = true;
            }
        }
        ++SortedNum;
    }

    rep(i,N-1) cout << A[i] << " ";
    cout << A[N-1] << endl;
    cout << SwapNum << endl;
    
    return 0;
}


Measured memory_bytes: 3096
#include<stdio.h>
#define N 100
int main(){
  int i,j,k[N],temp,l,flag=0;
  scanf("%d",&j);
  for(i=0;i<j;i++)
    scanf("%d",&k[i]);
  
  for(i=0;i<j;i++){
    for(l=j-1;l>i;--l){
      if(k[l-1]>k[l]){
	temp = k[l-1];
	k[l-1] = k[l];
	k[l] = temp;
	flag++;
      }
    }
  }
  for(i=0;i<j;++i){
    if(i>0)printf(" ");
    printf("%d",k[i]);
  }
      
  printf("\n");
  printf("%d\n",flag);
  return 0;
}
	  


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

int main() {
    string X;
    cin >> X;

    int ans = 0, S_over = 0;
    for (int i = 0; i < X.size(); i++) {
        if (X[i] == 'T' and S_over == 0) {
            ans++;
        } else if (X[i] == 'T' and S_over > 0) {
            S_over--;
        } else if (X[i] == 'S') {
            S_over++;
        }
    }

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

Measured memory_bytes: 640
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func next() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func main() {
	scanner.Split(bufio.ScanWords)

	n := nextInt()
	a := nextInt()
	b := nextInt()

	train := n * a
	taxi := b

	if train >= taxi {
		fmt.Println(taxi)
	} else {
		fmt.Println(train)
	}
}


Measured memory_bytes: 640
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <string.h>
#include <string>
#include <vector>
#include <sstream>
using namespace std;
const int maxn = 100010;
vector <int> vt[maxn];
vector <int> ans,tt;
int temp,lt;
bool nr[maxn],vis[maxn],vis2[maxn];
int dfs(int st){
    ans.push_back(st);
    vis2[st] = 1;
    if(st == temp)
        return 1;
    for(int i = 0;i < vt[st].size(); i++){
        if(vis2[vt[st][i]]){
            continue;
        }
        if(dfs(vt[st][i])){
            return 1;
        }
    }
    ans.pop_back();
    return 0;
}
int  dfs2(int st){
    if(nr[st]){
        lt--;
    }
    int flag=1;
    vis[st] = 1;
    vis2[st] = 1;
    ans.push_back(st);
    for(int i = 0;i < vt[st].size();i++){
        if(vis[vt[st][i]] == 0){
            flag = 0;
            if(vis2[vt[st][i]] == 0 && dfs2(vt[st][i])){
                return 1;
            }
        }
    }
    if(flag == 1 && lt == 0){
        return 1;
    }
    if (nr[st])
        lt ++;
    vis[st] = 0;
    ans.pop_back();
    return 0;
}
 
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,m,x,y;
    cin >> n >> m;
    for(int i = 0; i < m; i++){
        cin >> x >> y;
        vt[x].push_back(y);
        vt[y].push_back(x);
    }
    for(int i = 0;i <= n; i++)
        if (vt[i].size() == 1){
            tt.push_back(i);
        }
    if(tt.size() >= 2){
        temp = tt[1];
        dfs(tt[0]);
    }else{
        for(int i = 1; i <= n; i++){
            memset(nr,0,sizeof(nr));
            memset(vis2,0,sizeof (vis2));
            for(int j = 0; j < vt[i].size(); j++)
                nr[vt[i][j]] = 1;
            lt = vt[i].size();
            if(dfs2(i)){
                break;
            }
        }
    }
    cout << ans.size() << endl;
    for(int i = 0;i < ans.size();i++)
        cout << ans[i] << " ";
    return 0;
}

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

int main(){
	int n,x;	cin >> n >> x;
	int l[n]; int d[n+1];	d[0]=0;
	for(int i=0; i<n; i++)	cin >> l[i];
	for(int i=1; i<=n; i++	)	d[i] = d[i-1]+l[i-1];
	
	int ans=0;
	for(int i=0; i<=n;i++){
		if(d[i] > x)	break;
		else	ans++;
	}
	cout << ans;
}

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

int main(){
    int n,k;
    cin>>n>>k;
    bool num[n];
    for(int i=0;i<n;i++){
        num[i]=true;
    }
    for(int i=0;i<k;i++){
        int d;
        cin>>d;
        for(int j=0;j<d;j++){
            int a;
            cin>>a;
            num[a-1]=false;
        }
    }
    int ans=0;
    for(int i=0;i<n;i++){
        if(num[i])
        ans++;
    }
    cout<<ans<<endl;
    return 0;

}

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

struct UnionFind {
  vector<int> parent;
  vector<int> height;
  
  UnionFind(int n) {
    for (int i = 0; i < n; i++) {
      parent.push_back(i);
      height.push_back(0);
    }
  }
  
  int find (int x) {
    if (parent.at(x) == x) {
      return x;
    } else {
      parent.at(x) = find(parent.at(x));
      return parent.at(x);
    }
  }
  
  void unite(int x, int y) {
    int p = find(x);
    int q = find(y);
    if (p == q) return;
    
    if (height.at(p) < height.at(q)) {
      parent.at(p) = q;
    } else {
      parent.at(q) = p;
      if (height.at(p) == height.at(q)) height.at(p)++;
    }
  }
  
  bool same(int x, int y) {
    return find(x) == find(y);
  }
};

int main() {
  int N, M;
  cin >> N >> M;
  
  vector<int> p(N);
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    p.at(i) = a - 1;
  }
  
  UnionFind u(N);
  for (int i = 0; i < M; i++) {
    int x, y;
    cin >> x >> y;
    
    u.unite(x - 1, y - 1);
  }
  
  int cnt = 0;
  for (int i = 0; i < N; i++) {
    if (u.find(i) == u.find(p.at(i))) cnt++;
  }
  
  cout << cnt << endl;
  
  return 0;
}

Measured memory_bytes: 1660
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    if(S[0] == S[1] && S[1] == S[2]) {
        cout << "Yes" << endl;
    } else if(S[1] == S[2] && S[2] == S[3]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }


    return 0;
}


Measured memory_bytes: 3644
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<ll, ll>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (ll i = begin; i < n; i++)
#define repe(i, begin, n) for (ll i = begin; i <= n; i++)
#define repr(i, begin, n) for (ll i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (ll i = begin; i >= end; i--)

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

const ll inf = 1000000007;
const ll MOD = 1000000007;
const long long INF = 1000000000000000007;

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

int N, K;

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

  int ma = (N - 1) * (N - 2) / 2;
  if (K > ma) {
    cout << -1;
    return 0;
  }

  int diff = ma - K;

  int M = N - 1 + diff;

  cout << M << "\n";
  rep(i, 0, N - 1) { cout << 1 << " " << i + 2 << "\n"; }

  if (diff == 0) return 0;

  int cnt = 0;
  repe(i, 2, N - 1) {
    repe(j, i + 1, N) {
      cout << i << " " << j << "\n";
      ++cnt;
      if (cnt == diff) break;
    }
    if (cnt == diff) break;
  }
}


Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
long long num[88]={0};
long long a[88];
int main()
{
    int n;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    num[0]=1000;
    for(int i=0;i<n;i++){
        if(i)
        num[i]=num[i-1];
        for(int j=0;j<i;j++){
            num[i] = max(num[j]%a[j]+num[j]/a[j]*a[i],num[i]);
        }
    }
    cout << num[n-1] << endl;
    return 0;
}


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

public class Main{
  public static void main(String[] args){
     Scanner scanner = new Scanner(System.in);
     int n = scanner.nextInt();
     int a = scanner.nextInt();
     int b = scanner.nextInt();
     int c = scanner.nextInt();
     int d = scanner.nextInt();

     int x = 0;
     int y = 0;
     int i = 0;
     int j = 0;


     while(true){
       i = i + a;
       x = x + b;
       if(i>=n)break;
     }

     while(true){
       j = j + c;
       y = y + d;
       if(j>=n)break;
     }

     if(x<y){
       System.out.println(x);
     }else{
       System.out.println(y);
     }


  }
}


Measured memory_bytes: 26460