akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define int long long
typedef vector<int> vint;
typedef pair<int, int> pint;
const double PI = 3.141592653589793238462643383279;
const int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
template<typename T, typename U> inline bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> inline bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
struct Init {
    Init() {
        cout << fixed << setprecision(20);
    };
} init;

int A, B;
signed main() {
    cin >> A >> B;
    cout << max({2 * A - 1, A + B, 2 * B - 1}) << endl;
}


Measured memory_bytes: 256
import math
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

r,D,x = IL()

for i in range(10):
    x = r*x - D
    print(x)

Measured memory_bytes: 21724
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;

typedef istringstream ISS;
typedef ostringstream OSS;
typedef vector<string> VS;
typedef set<string> SS;
typedef vector<int> VI;
typedef vector<VI> VVI;
template<class T> T gcd( T a, T b ) {
	return !b ? a : gcd( b, a % b );
}
template<class T> T lcm( T a, T b ) {
	return a / gcd( a, b ) * b;
}
template<class T> string print_v( vector<T> v ) {
	OSS oss;
	for ( typename vector<T>::iterator it_i = v.begin(); it_i != v.end();
          ++it_i ) {
		oss << *it_i << ", ";
	}
	return oss.str();
}

typedef pair <int, string> IS;
typedef vector <IS> VIS;

int getN( string s ) {
    ISS iss( s );
    int res;
    iss >> res;
    return res;
}

int main() {
    string line;
    while ( getline( cin, line ) && line != "0" ) {
        int n = getN( line );
        string lines[n];
        for ( int i = 0; i < n; ++ i ) {
            getline( cin, lines[i] );
        }

        VS W;
        for ( int i = 0; i < n; ++ i ) {
            ISS iss( lines[i] );
            string w;
            while ( iss >> w ) W.push_back( w );
        }
        
        string h;
        getline( cin, h );
        char head = h[0];

        VS T;
        for ( VS::iterator it_i = W.begin(); it_i != W.end(); ++ it_i ) {
            string w = *it_i;
            if ( w[0] == head ) T.push_back( w );
        }
        int nt = T.size();

        SS S( T.begin(), T.end() );
        VIS U;
        for ( SS::iterator it_i = S.begin(); it_i != S.end(); ++ it_i ) {
            string w = *it_i;
            U.push_back( IS( nt - count( T.begin(), T.end(), w ), w ) );
        }

        if ( U.empty() ) {
            cout << "NA" << endl;
        } else {
            sort( U.begin(), U.end() );
            for ( VIS::iterator it_i = U.begin(); it_i != U.end(); ++ it_i ) {
                string w = (*it_i).second;
                cout << w;
                if ( it_i - U.begin() >= 4 ) break;
                if ( it_i + 1 != U.end() ) cout << " ";
            }
            cout << endl;
        }
    }
	return 0;
}

Measured memory_bytes: 976
(n, m) = [int(i) for i in input().split()]
A = []
b = []
for i in range(n):
    A.append([int(j) for j in input().split()])
  
for r in range(m):
    b.append(int(input()))
  
for i in range(n):
    s = 0
    for j in range(m):
        s += A[i][j] * b[j]
    print(s)

Measured memory_bytes: 7012
N=int(input())
alist=list(map(int,input().split()))

sum_a=0
slist=[]
for a in alist:
  sum_a+=a
  slist.append(sum_a)
#print(slist)

allsum=slist[-1]
answer=float("inf")
for i in range(N-1):
  score_a=slist[i]
  score_b=allsum-score_a
  
  cand=abs(score_a-score_b)
  #print(score_a,score_b,cand)
  answer=min(answer,cand)
  
print(answer)

Measured memory_bytes: 24812
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define N 55
int fun(char temp[N],char S[],char T[],int len_S,int len_T,int *pos)
{
    int i=0,flag=0,counter=0,j;
        while(i<=len_S-len_T)
        {
            strncpy(temp,S+len_S-len_T-i,len_T);
            *pos=len_S-len_T-i;
            for(j=0;j<len_T;j++)
            {
                if(temp[j]==T[j]||temp[j]=='?')
                        counter++;
            }
            if(counter==len_T)
                {
                    flag++;
                    break;
                }
            counter=0;
            i++;
        }
        if(flag)
            return 1;
        else
            return 0;

}

int main()
{
    char S[N],T[N];
    char temp[N];
    int pos=0,i;
    gets(S);
    gets(T);
    int len_S,len_T;
    len_S=strlen(S);
    len_T=strlen(T);
    if(len_S<len_T)
        printf("UNRESTORABLE");
    else
    {
            if(fun(temp,S,T,len_S,len_T,&pos))
            {
                strncpy(S+pos,T,len_T);
                for(i=0;i<len_S;i++)
                {
                    if(S[i]=='?')
                        S[i]='a';
                }
                printf("%s",S);
            }
            else
            {
 printf("UNRESTORABLE");
            }

    }


    return 0;
}



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

#define FASTIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using ll = long long;

const int MOD = 1e9+7;

int main() {
    FASTIO
    
    int x;
    cin >> x;
    cout << (!x) << "\n";
    
    return 0;
}

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

typedef long long ll;
typedef unsigned long long int ull;
#define endl "\n"
#define pb push_back
#define sq(a) (a)*(a)
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugv(v) cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;
#define MOD 1000000007
#define PI 3.141592653589793238
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);

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

ll exp(ll x,ll n,ll mod)
{
    ll result=1;
    while(n)
    {
        if(n & 1)
            result=(result * x)%mod;
        x=(x*x)%mod;
        n>>=1;
    }
    return result;
}



int32_t main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    IOS

    string s;
    cin>>s;
    int sum=0;
    for(auto c:s)
    	sum=(sum+(c-'0')%9)%9;

    if(!sum)
    	cout<<"Yes"<<endl;
    else
    	cout<<"No"<<endl;
    
    return 0;
}

Measured memory_bytes: 3712
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>
#define len length()
#define sz size()
#define rng(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) rng(i, 0, n)
#define srt(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define vi(a, n) vector<int> a(n)
#define vs(a, n) vector<string> a(n)
#define vc(a, n) vector<char> a(n)
#define psb(a) push_back(a)
#define ppb pop_back()
#define erc(S, i) S.erase(S.begin() + i)
#define ers(S, i, j) S.erase(S.begin() + i, S.begin() + j)
#define sp(n) cout << setprecision(n) << fixed
#define fst(s) s.at(0)
#define lst(s) s.at(s.len - 1)
typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(){
    int N;
    cin >> N;
    vi(H,N);
    rep(i,N){
        cin >> H[i];
    }
    int ans = 0, cnt = 0;
    rep(i,N-1){
        if(H[i] >= H[i+1]){
            cnt++;
        }
        else{
            cnt = 0;
        }
        ans = max(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
N = int(input())

nums = list(map(int,input().split(' ')))

count = 0
existOdd = True
while existOdd:
    for i in nums:
        if i%2!=0:
            existOdd = False
            break
    
    if existOdd:
        for i in range(N):
            nums[i] /= 2
        
        count+=1
    
print(count)


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

class Main {

	
	public static void main(String[] args) throws IOException {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		for (int i = 1; ; i++) {
			String s=br.readLine();
			if(s.equals("0"))
				break;
			System.out.println("Case "+i+": "+s);
		}

	}

}

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

int main() {
    long long L[90];
    L[0] = 2;
    L[1] = 1;
    int N;
    cin >> N;
    for (int i = 2; i <= N; i++) {
        L[i] = L[i - 1] + L[i - 2];
    }
    cout << L[N] << endl;
}

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

using namespace std;
long long syori[500000];
void init(long long a){
  long long nw = 1;
  long long hai = 2;
  for(int i = 0; a > i; i++){
    syori[i] = nw;
    nw += hai;
    hai++;
  }
}
int main(){
  string s;cin>>s;
  init(s.size());
  vector<long long> a;
  if(s[0] == '>')a.push_back(0);
  int nw = 1;
  for(int i = 1; s.size() > i; i++){
    if(s[i-1] != s[i]){
      a.push_back(nw);
      nw = 1;
    }else{
      nw++;
    }
  }
  a.push_back(nw);
  long long ans = 0;
  for(int i = 0; a.size() > i; i++){
    ans += syori[a[i]-1];
  }
  for(int i = 1; a.size() > i; i+=2){
    ans -= min(a[i-1],a[i]);
  }
  cout << ans << endl;
  

}

Measured memory_bytes: 6908
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
typedef long long ll;
int n,m,g[N],i,ans,nw;
ll a[N];
int rr[N];
struct edge{
	int x,y,z;
	bool operator<(const edge&rhs)const{
		return z<rhs.z;
	}
}e[N];
int gfa(int x){return g[x]==x?x:g[x]=gfa(g[x]);}
int main(){
	ios::sync_with_stdio(0);cin.tie(0);
	cin>>n>>m;for(i=1;i<=n;++i)g[i]=i,cin>>a[i];
	for(i=1;i<=m;++i){
		cin>>e[i].x>>e[i].y>>e[i].z;
	}
	sort(e+1,e+m+1);
	for(i=1;i<=m;++i){
		int x=gfa(e[i].x),y=gfa(e[i].y);
		if(x!=y){
			g[x]=y;a[y]+=a[x];
			if(a[y]>=e[i].z)nw+=rr[y]+rr[x]+1,rr[y]=0;else rr[y]+=rr[x]+1;
		}else{
			if(a[y]>=e[i].z)++nw;
				else ++rr[y];
		}
		ans=max(ans,nw);
	}
	cout<<m-ans<<endl;
	return 0;
}

Measured memory_bytes: 2944
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define per1(i,n) for(int i=n;i>0;i--)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    vec x(n),y(n);
    rep(i,n) cin>>x[i]>>y[i];
    vector<pair<P,ll>> A;
    vec B(n+1);
    rep(i,n) B[y[i]]=i;
    rep(i,n) A.push_back(make_pair(P(x[i],y[i]),i));
    vec D(n+1);
    sort(all(A));
    rep(i,n) D[A[i].first.second]=i;
    dsu d(n);
    int size=n;
    rep1(i,n){
        if(D[i]<size){
            vec C;
            for(int j=D[i];j<size&&A[j].first.second>=i;j++) C.push_back(A[j].first.second);
            int a=*max_element(all(C));
            //cout<<i<<" "<<D[i]<<" "<<C.size()<<"\n";
            rep(j,C.size()) d.merge(B[i],B[C[j]]);/*cout<<C[j]<<" ";cout<<i<<" "<<C[j]<<" ";*/
            //cout<<"\n";
            if(C.size()==1) size--;
            else size-=C.size()-1,A[size-1].first.second=a,D[a]=size-1;
            //cout<<"size"<<size<<"\n";
        }
    }
    rep(i,n){int a=d.size(i);cout<<a<<"\n";}
}

Measured memory_bytes: 18432
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
#define PIL pair<int,LL>
#define PLI pair<LL,int>
#define PIII pair<int,PII>
#define PLL pair<LL,LL>
#define PLII pair<LL,PII>
#define VI vector<int>
#define VVI vector<VI>
#define VL vector<LL>
#define VVL vector<VL>
#define VPII vector<PII>
#define FF first
#define SS second
#define MP make_pair
#define PB push_back
#define all(x) x.begin(),x.end()
#define watch(x) cout<<(#x)<<" = "<<(x)<<'\n'
#define mset(a,v) memset(a,v,sizeof(a))
#define setp(x) cout<<fixed<<setprecision(x)
#define EPS 0.00000000001
#define PI acos(-1)
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
using namespace std;

const int MOD = 1e9 + 7;
const LL MX = 1e9;
const LL INF = 1e9;

void print_a(VI v)
{
    if(v.size()) cout<<v[0];
    loop(i,1,v.size()) cout<<' '<<v[i];
    cout<<'\n';
}

VVI init_vvi(int n, int m, int val)
{
    return VVI(n,VI(m,val));
}

VVL init_vvl(int n, int m, LL val)
{
    return VVL(n,VL(m,val));
}

int main()
{
    //ofstream out("output.txt");
    //ifstream in("input.txt");
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    int n,a;
    cin>>n;
    map<LL,int> mp;
    loop(i,0,n)
    {
        cin>>a;
        ++mp[a];
    }

    LL s1 = -1, s2 = -1;
    for(auto it = mp.crbegin(); it != mp.crend(); ++it)
    {
        if(s1 == -1)
        {
            if(it -> SS >= 4) {s1 = s2 = it->FF;}
            else if(it -> SS >= 2) {s1 = it->FF;}
        }
        else if(s2 == -1)
        {
            if(it -> SS >= 2) {s2 = it->FF;}
        }
    }

    LL ans;
    if(s1 == -1 || s2 == -1) ans = 0;
    else ans = s1 * s2;

    cout<<ans<<'\n';

    /*
    int t,n;
    cin>>t;
    while(t--)
    {
        cin>>n;
        int a[n];
        loop(i,0,n) cin>>a[i];
    }
    */

    /*
    int n;
    cin>>n;
    int a[n];
    loop(i,0,n) cin>>a[i];
    */

    /*
    cout<<ans<<'\n';

    if(f) cout<<"YES\n";
    else cout<<"NO\n";

    if(f) cout<<"Yes\n";
    else cout<<"No\n";
    */

    return 0;
}


Measured memory_bytes: 9768
const config = {
    input: '/dev/stdin',
    newline: '\n'
};

const line = require('fs').readFileSync(config.input, 'utf-8').split(config.newline);

const list = line[1].split(' ').map(x => parseInt(x));

const partition = arr => {
    const x = arr[arr.length-1];
    const result = [...arr];
    let i = -1;
    for (let j = 0; j < arr.length - 1; j++) {
        if (result[j] <= x) {
            i++;
            const tmp = result[i];
            result[i] = result[j];
            result[j] = tmp;
        }
    }
    const tmp = result[i+1];
    result[i+1] = result[arr.length-1];
    result[arr.length-1] = tmp;

    return [i+1, result];
}

const res = partition(list);

console.log(res[1].map((x, i) => i === res[0] ? `[${x}]` : x.toString()).join(' '));



Measured memory_bytes: 38760
a = [1,3,5,7,8,10,12]
b = [4,6,9,11]
c = [2]

arr = gets.chomp.split(" ").map { |e| e.to_i }

if arr.all? {|i| a.include?(i)} then
  puts "Yes"
elsif arr.all? {|i| b.include?(i)} then
  puts "Yes"
elsif arr.all? {|i| c.include?(i)} then
  puts "Yes"
else
  puts "No"
end



Measured memory_bytes: 1788
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;



//bit全探索
vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}


int main(){
    int k, n;
    cin >> k >> n;
    vector<int>a;
    rep(i, n){
        int b;
        cin >> b;
        a.push_back(b);
        a.push_back(b + k);
    }
    sort(ALL(a));
    
    ll res = INF * INF;
    rep(i, n){
        ll sum = a[n + i - 1] - a[i];
        res = min(res, sum);
    }
    cout << res;
}



Measured memory_bytes: 2420
while True:
    x,y,s=map(int,input().split())
    if x==0 and y==0 and s==0:
        break
    ans=0
    for i in range(1,s):
        for j in range(1,i+1):
            p=i*(100+x)//100+j*(100+x)//100
            if p==s:
                now=i*(100+y)//100+j*(100+y)//100
                ans=max(ans,now)
    print(ans)


Measured memory_bytes: 5600
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <vector>

using namespace std;

#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)

typedef vector<int> vi;
typedef vector<vi> vvi;

const int INFTY=1<<29;

int dfs(vvi& a,int ci,int cj,int depth)
{
	if(depth==10)
		return INFTY;
	
	int h=a.size(),w=a[0].size();
	int di[]={-1,1,0,0},dj[]={0,0,-1,1};
	int res=INFTY;
	rep(k,4){
		for(int i=ci+di[k],j=cj+dj[k];;i+=di[k],j+=dj[k]){
			if(i<0 || h<=i || j<0 || w<=j)
				break;
			if(a[i][j]==1){
				if(abs(i-ci)+abs(j-cj)>1){
					a[i][j]=0;
					res=min(res,dfs(a,i-di[k],j-dj[k],depth+1));
					a[i][j]=1;
				}
				break;
			}
			if(a[i][j]==3)
				return depth+1;
		}
	}
	return res;
}

int main()
{
	for(int w,h;cin>>w>>h;){
		vvi a(h,vi(w));
		rep(i,h) rep(j,w)
			cin>>a[i][j];
		
		rep(i,h) rep(j,w)
			if(a[i][j]==2){
				a[i][j]=0;
				int res=dfs(a,i,j,0);
				cout<<(res==INFTY?-1:res)<<endl;
			}
	}
	
	return 0;
}

Measured memory_bytes: 912
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int count1 = x / 500;
        int count2 = x % 500;
        int count3 = count2 / 5;
        System.out.println(count1 * 1000 + count3 * 5);
    }
}


Measured memory_bytes: 22740
package main

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

func main() {
	sc := NewScanner()

	s := sc.ReadString()
	t := sc.ReadString()

	cnt := 0
	for i := 0; i < len(s); i++ {
		if s[i] != t[i] {
			cnt++
		}
	}

	fmt.Println(cnt)
}

// util
// *   math/simple

func Abs(x int) int {
	if x >= 0 {
		return x
	}
	return -x
}

func Min(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func Max(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func Pow(base int, exponent uint) int {
	answer := 1
	for i := uint(0); i < exponent; i++ {
		answer *= base
	}
	return answer
}

func Ceil(divident, dividor int) int {
	quo := divident / dividor
	rem := divident % dividor

	if rem != 0 {
		if (divident > 0 && dividor > 0) ||
			(divident < 0 && dividor < 0) {
			return quo + 1
		}
	}
	return quo
}

// *   sortutil

func ReverseInts(a []int) {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
}

func ReverseStrings(a []string) {
	sort.Sort(sort.Reverse(sort.StringSlice(a)))
}

// *   io

type Scanner struct {
	bufScanner *bufio.Scanner
}

func NewScanner() *Scanner {
	bufSc := bufio.NewScanner(os.Stdin)
	bufSc.Split(bufio.ScanWords)
	bufSc.Buffer(nil, 100000000)
	return &Scanner{bufSc}
}

func (sc *Scanner) ReadString() string {
	bufSc := sc.bufScanner
	bufSc.Scan()
	return bufSc.Text()
}

func (sc *Scanner) ReadInt() int {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.Atoi(text)
	if err != nil {
		panic(err)
	}
	return num
}


Measured memory_bytes: 2752
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**10
mod = 998244353

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():
    rr = []

    def f(k):
        p,a,b,c,d,e,f,s,m = map(int,k[1:])
        t = a + b + c + (d + e) * m
        u = f * s * m - p
        return (-u / t, k[0])

    while True:
        n = I()
        if n == 0:
            break

        a = [LS() for _ in range(n)]
        b = [f(c) for c in a]
        b.sort()
        for u,l in b:
            rr.append(l)
        rr.append('#')

    return '\n'.join(map(str, rr))


print(main())




Measured memory_bytes: 9148
#include <iostream>

using namespace std;

int main(void){
        int n;

        cin >> n;

        int ok = 0;

        for (int i = 0; i < 100; i++){
                if (n - i * 4 >= 0 && (n - i * 4) % 7 == 0)
                        ok = 1;
        }

        if (ok)
                cout << "Yes" << endl;
        else
                cout << "No" << endl;

}

Measured memory_bytes: 256
a , b = map(int,input().split())
count = 0

if a > b:
  count = a
  a = a - 1
  if a > b or a == b:
    count = count + a
elif b > a:
  count = b
  b = b - 1
  if b > a or a == b:
    count = count + b
else:
  count = a
  count = count + b

print(count)

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

string A,B,C;

int main(){
 
cin>>A>>B>>C;

int a=A.size()-1;
int b=B.size()-1;

if(A[a]==B[0]&&B[b]==C[0]) puts("YES");
else puts("NO");

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
bool isp[1000004];
void Eratosthenes(){
	isp[1]=1;
	for (int i=2;i*i<=n;i++)
		if (!isp[i])
			for (int j=i*i;j<=n;j+=i) isp[j]=1;
}
int main(){
	n=1e6;
	Eratosthenes();
	int x;cin>>x;
	while(1){
		if (!isp[x]){
			cout<<x;return 0;
		}
		x++;
	}
}

Measured memory_bytes: 1280
N,K,L=map(int,input().split())
def search(i,root):
    if root[i]>=0:
        root[i]=search(root[i],root)
        return root[i]
    return i
def UF(N,M):
    root=[-1]*N
    for i in range(M):
        u,v=map(int,input().split())
        u-=1
        v-=1
        ru=search(u,root)
        rv=search(v,root)
        if ru==rv:
            continue
        elif root[ru]<=root[rv]:
            root[rv]+=root[ru]
            root[ru]=rv
        else:
            root[ru]+=root[rv]
            root[rv]=ru
    return [search(i,root) for i in range(N)]
road=UF(N,K)
metro=UF(N,L)
from collections import defaultdict
cnt=defaultdict(int)
ROOT=[(i,j) for i,j in zip(road,metro)]
for r in ROOT:
    cnt[r]+=1
for i in range(N):
    print(cnt[ROOT[i]])

Measured memory_bytes: 52164
N = int(input())
A = [int(input()) for _ in range(N)]

maxleft = [0] * (N+2)
maxright = [0] * (N+2)

for i in range(N):
    maxleft[i+1] = max(maxleft[i],A[i])
    maxright[N-i] = max(maxright[N-i+1],A[N-i-1])

for i in range(N):
    print(max(maxleft[i], maxright[2+i]))


Measured memory_bytes: 15800
#include<iostream>
using namespace std;
int main(){
  int n;
  int i;
  int card[4][13]={{}};
  cin >> n;
  char a;
  int b;
  for(i=0;i<n;i++) {
    cin >> a >> b;
    switch(a){
    case 'S':
      card[0][b-1]=1;
      break;
    case 'H':
      card[1][b-1]=1;
      break;
    case 'C':
      card[2][b-1]=1;
      break;
    case 'D':
      card[3][b-1]=1;
      break;
    }
  }
  for(i=0;i<52;i++) {
    switch(i/13){
    case 0:
      if(card[0][i%13]==0) cout << "S " << i+1 << endl;
      break;
    case 1:
      if(card[1][i%13]==0) cout << "H " << i%13+1 << endl;
      break;
    case 2:
      if(card[2][i%13]==0) cout << "C " << i%13+1 << endl;
      break;
    case 3:
      if(card[3][i%13]==0) cout << "D " << i%13+1 << endl;
      break;
    }
  }
  
  return 0;
}


Measured memory_bytes: 3088
def main():
    n=int(input())
    A=list(map(lambda x: int(x)-1,list(input().strip())))
    ans=1
    if not 1 in A:
        ans*=2
        for i in range(n):
            A[i]>>=1
    parity=0
    for i in range(n):
        if (n-1)&i==i:
            parity^=A[i]&1
    ans*=parity
    print(ans)
    
if __name__=='__main__':
    main()

Measured memory_bytes: 144060
a, b, c, x, y = map(int, input().split())
key1 = min([x, y])
key2 = abs(x-y)
ans = min([a+b, 2*c]) * key1
if x > y:
    ans += min([a, 2*c]) * key2
else:
    ans += min([b, 2*c]) * key2
print(ans)

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

int main(){
  long long N, K;
  cin >> N >> K;
  vector<long long> P(N), C(N);
  for(int i = 0; i < N; ++i)
    cin >> P[i], --P[i];

  for(int i = 0; i < N; ++i)
    cin >> C[i];
  vector<bool> visited(N,false);
  vector<vector<int>> Cycle;
  for(int i = 0; i < N; ++i){
    if(visited[i]) continue;
    int v = i;
    vector<int> c;
    while(!visited[v]){
      c.push_back(v);
      visited[v] = true;
      v = P[v];
    }
    Cycle.push_back(c);
  }
  long long ans = -2e18;
  for(const auto& c : Cycle){
    long long m = c.size();
    long long s = 0;
    vector<long long> cc;
    for(auto v : c){
      s += C[v];
      cc.emplace_back(C[v]);
    }

    for(long long kk = 1; kk <= min(K,m); ++kk){
      long long t = 0;
      for(int i = 0; i < kk; ++i){
        t += cc[i];
      }
      for(int i = 0; i < m; ++i){
        t -= cc[i];
        t += cc[(i+kk)%m];
        ans = max(ans,t);
        long long u = (K-kk)/m*s;
        ans = max(ans,t+u);
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define ST first
#define ND second
 
ostream& operator<<(ostream &out, string str) {
	for(char c : str) out << c;
	return out;
}
 
template<class L, class R> ostream& operator<<(ostream &out, pair<L, R> p) {
	return out << "(" << p.ST << ", " << p.ND << ")";
}

template<class T> auto operator<<(ostream &out, T &&x) -> decltype(x.begin(), out) {
	out << '{';
	for(auto &e : x)
        	out << e << (&e == &*--x.end() ? "" : ", ");
	return out << '}';
}

template<class... Args> void dump(Args&&... args) {
	((cerr << args << ";  "), ...);
}
 
#ifdef DEBUG
#  define debug(x...) cerr << "[" #x "]: ", dump(x), cerr << "\n"
#else
#  define debug(...) false
#endif
 
template<class T> int size(T && a) { return (int) a.size(); }
 
using LL = long long;
using PII = pair<int, int>;

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

	LL a, b, v, w, t;
	cin >> a >> v >> b >> w >> t;
	if(a < b) {
		a += v * t;
		b += w * t;
		cout << (a >= b ? "YES" : "NO");
	}
	else if(a > b) {
		a -= v * t;
		b -= w * t;
		cout << (a <= b ? "YES" : "NO");
	}
	cout << "\n";
}


Measured memory_bytes: 3604
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    int n, m;
    int[] a, b;
    int i, j, maxdef, human, count;

    n = sc.nextInt();
    m = sc.nextInt();
    a = new int[m];
    b = new int[m];

    for(i = 0;i < m;i++){
      a[i] = sc.nextInt();
      b[i] = sc.nextInt();
    }

    count = 0;
    human = -1;

    for(i = 0;i < n;){
      maxdef = 0;
      human = -1;
      for(j = 0;j < m;j++){
        if(a[j] <= (i + 1) && (i + 1) <= b[j] && maxdef < b[j]){
          maxdef = b[j];
          human = j;
        }
      }

      if(human == -1){
        break;
      }else{
        i = b[human];
        count++;
      }
    }

    if(human == -1){
      System.out.println("Impossible");
    }else{
      System.out.println(count);
    }


/*end*/
    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 20424
#include <algorithm>
#include <string.h>
#include <iostream>
#include <stdio.h>
#include <string>

using namespace std;

typedef long long ll;
string s, s1;

int main() {
	cin >> s >> s1;

	for (ll i = 0; i < s.size(); i++) {
		if (s[i] != s1[i]) {
			puts("No");
			return 0;
		}
	}

	puts("Yes");

	return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#include<iomanip>
#define fast {ios_base::sync_with_stdio(false);cin.tie(NULL);}
#define mxn 1000005
#define mod 1000000007
#define ld long double
#define pb push_back
#define inf 1e18
#define fi first
#define se second
typedef long long int ll;
using  namespace std;
int main(void){
	fast;
	ll n,k,i,ma=-inf;
	cin>>n>>k;
	ll a[n];
	for(i=0;i<n;i++){
		cin>>a[i];
		ma=max(ma,a[i]);
	}
	ll lo=1,hi=ma;
	while(lo<hi){
		ll mid=(lo+hi)/2;
		ll c=0;
		for(i=0;i<n;i++)
			c+=(a[i]-1)/mid;
		if(c>k)
		lo=mid+1;
		else
		hi=mid;
	}
	cout<<max(lo,1LL);
}


Measured memory_bytes: 5164
// luogu-judger-enable-o2
// luogu-judger-enable-o2
#include<cstdio>
#include<iostream>
using namespace std;
int n;double d,x,ans;
int main()
{
    cin>>n>>d>>x;
    for(;n;--n)
    {
        ans+=d+(n-0.5)*x;
        d=((2*n+2)*d+5*x)/(2*n);
        x=(2*n+4)*x/(2*n);
    }
    printf("%.10lf\n",ans);
    return 0;
}

Measured memory_bytes: 256
//ltc.groverkss (Kunwar Shaanjeet Singh Grover)
//IIIT Hyderbad

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ll long long
#define ld long double
typedef pair<ll,ll> ii;
typedef vector<ll> vi;                  // Vector of long long
typedef vector<vi> vvi;                 // Vector of vi
typedef vector<ii> vii;                 // Vector of pairs
#define pq priority_queue               // Max heap (To convert to min heap, use negative sign before every value)
#define ff first                        // For pairs
#define ss second                       // For pairs
#define pb push_back                    // Pushback to vector
#define mp make_pair                    // Makes pairs to be stored as pair
#define all(c) (c).begin(), (c).end()   // Mainly used by me in sorting
// ordered_set adds two new functions to set - (set).find_by_order([kth element based on zero indexing]) and order_of_key()
// order_of_key returns number of elements less that parameter. If element exists, that order is its index
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>

int main(void)
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    char c;
    cin >> c;

    cout << (char)(c + 1) << "\n";
}

Measured memory_bytes: 256
import collections

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

N = int(input())
c = collections.Counter(prime_factorize(N))

def getCount(w):
    i = 1
    n = 1
    while n <= w:
        i+=1
        n+=i
    return i - 1

cnt = 0

for v in c.values():
    cnt += getCount(v)

print(cnt)

Measured memory_bytes: 9464
//Snack

#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <map>
#include <stdio.h>
#include <string.h>
#include <initializer_list>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <queue>
#include <set>

using namespace std;

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

long long lcm(long long a, long long b)
{
    return (a * b) / gcd(a, b);
}

int main ()
{
    long long A, B;
    cin >> A >> B;
    long long result = lcm(A, B);
    cout << result << endl;;

    return 0;
}

Measured memory_bytes: 256
N,M,C = map(int,input().split())
B = list(map(int,input().split()))

count = 0

for n in range(N):
  ans = 0
  A = list(map(int,input().split()))
  for m in range(M):
    ans += A[m]*B[m]
  if ans + C > 0:    
    count += 1
    
print(count)

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

template<typename ... Ts> void read(Ts& ...vs){(std::cin >> ... >> vs);}

struct Node
{
    std::vector<std::size_t> others;
};

int main()
{
    std::size_t N, M;
    read(N, M);

    std::vector<Node> nodes(N);
    std::vector<std::pair<std::size_t, std::size_t>> edges(M);
    for(auto& [A, B] : edges)
    {
        read(A, B);
        A -= 1; // 0-based index
        B -= 1;
        nodes.at(A).others.push_back(B);
        nodes.at(B).others.push_back(A);
    }

    std::vector<std::optional<std::size_t>> guide(N, std::nullopt);
    guide.front() = 1;

    std::queue<std::size_t> q;
    q.push(0);

    while(!q.empty())
    {
        const auto next = q.front();
        q.pop();

        for(const auto& connected : nodes.at(next).others)
        {
            if(guide.at(connected)) {continue;}

            guide.at(connected) = next+1; // 1 based index
            q.push(connected);
        }
    }

    const auto found = std::find_if(guide.begin()+1, guide.end(), [](const auto& g) {return !g;});
    if(found == guide.end())
    {
        std::cout << "Yes" << std::endl;
        for(auto iter = guide.begin() + 1; iter != guide.end(); ++iter)
        {
            std::cout << **iter << std::endl;
        }
    }
    else
    {
        std::cout << "No" << std::endl;
    }

    return 0;
}


Measured memory_bytes: 16696
#include<cstdio>
#include<algorithm> 
#include<map>
using namespace std;
typedef long long ll;
struct ob
{
	ll a,b;
	bool operator<(const ob&y)const
	{
		return a<y.a||(a==y.a&&b<y.b);
	}
}h;
ll n,i,j,x[55],y[55],ans;
map<ob,ll>mp;
map<ob,ll>::iterator it;
int main()
{
	scanf("%lld",&n);
	for(i=1;i<=n;i++)scanf("%lld%lld",&x[i],&y[i]);
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=n;j++)
		{
			if(i==j)continue;
			h=(ob){x[j]-x[i],y[j]-y[i]};
			mp[h]++;
		}
	}
	ans=n;
	for(it=mp.begin();it!=mp.end();++it)
	{
		ans=min(ans,n-(it->second));
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 384
s = input()
k = int(input())
k = k-1
def not1(t):
    for i in range(len(t)):
        if t[i] != '1':
            return (i, t[i])
    return (-1, '1')
(j, t) = not1(s)
if j == -1:
    print('1')
    exit()
if k < j:
    print('1')
    exit()
if k >= j:
    print(t)
    exit()


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <float.h>
#include <random>

#define repeat(i,n) for (int i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge] << '\n'
#define debugArrayP(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge].first<< " " << x[hoge].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = LLONG_MAX/10;
const ll MOD = 1e9+7;

ll mod_pow(ll x,int n){
  return n? n&1? x*mod_pow(x,n-1)%MOD:mod_pow(x*x%MOD,n/2):1;
}

int N;
ll dp[(1<<20)+10],dpsum[(1<<20)+10],dpsum2[(1<<20)+10];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>N;
  vint A(N);
  repeat(i,N)cin>>A[i];
  int c=0;
  int xorsum=0;
  repeat(i,N){
    c++;
    int j=i+1;
    xorsum=A[i];
    while(j<N&&xorsum!=0){
      dp[xorsum] = (1+dpsum[xorsum]*c-dpsum2[xorsum]+MOD)%MOD;
      dpsum[xorsum] = (dpsum[xorsum]+dp[xorsum])%MOD;
      dpsum2[xorsum] = (dpsum2[xorsum]+dp[xorsum]*c)%MOD;
      xorsum ^= A[j];
      j++;
    }
    i=j-1;
  }
  ll ans = 0;
  if(xorsum){
    ans = (1+dpsum[xorsum]*c-dpsum2[xorsum]+MOD)%MOD;
  }else{
    ans = mod_pow(2,c-1);
    repeat(i,1<<20){
      ans = (ans+dpsum[i])%MOD;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 26752
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#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++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

int main(){
    int d;cin>>d;
    vin c(26);rep(i,26)cin>>c[i];
    vvin s(d,vin(26));
    rep(i,d)rep(j,26)cin>>s[i][j];
    vvin last(d,vin(26,0));int sum,tmp;ll m;
    vin ans(d);
    rep(i,d){
        m=-INF;
        if(i>0)rep(j,26)last[i][j]=last[i-1][j];
        rep(j,26){
            sum=0;
            sum+=s[i][j];
            rep(k,26){
                if(k==j)continue;
                sum-=c[k]*(i+1-last[i][k]);
            }
            if((ll)sum>m){
                tmp=j;
                m=(ll)sum;
            }
        }
        ans[i]=tmp;
        last[i][tmp]=i+1;
    }
    int res,l;
    rep(i,225){
        rep(j,d){
            m=0;
            rep(k,26){
                sum=0;
                res=ans[j];
                rep2(l,j,d){
                    if(ans[l]=k){
                        sum+=c[k]*(j+1-last[j][k])*(l-j);
                        break;
                    }
                }
                rep2(l,j,d){
                    if(ans[l]=res){
                        sum-=c[res]*(j+1-last[j][res])*(l-j);
                    }
                }
                if(m<sum){
                    m=sum;
                    tmp=k;
                }
            }
            if(m==0)continue;
            ans[j]=tmp;
            l=last[j][tmp];
            rep2(k,j,d){
                if(last[k][tmp]!=l)break;
                last[k][tmp]=j+1;
            }
        }
    }
    rep(i,d)cout<<ans[i]+1<<endl;
}

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repp(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perr(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)

typedef long long LL;
typedef long double LD;

int main(){
  int n;
  cin >> n;
  vector<pair<int,int>> p(n),d(n);
  map<char,pair<int,int>> mp;
  mp['R']={1,0};
  mp['L']={-1,0};
  mp['U']={0,1};
  mp['D']={0,-1};
  char c;
  rep(i,n){
    cin >> p[i].first >> p[i].second;
    cin >> c;
    d[i]=mp[c];
  }
  double l=0,r=200000000,mid1,mid2;
  double ans=LINF;
  rep(i,100){
    mid1=l+(r-l)/3;
    mid2=l+2*(r-l)/3;
    double c1,c2;
    double lx=IINF,rx=-IINF,ly=IINF,ry=-IINF;
    rep(i,n){
      double x = p[i].first+d[i].first*mid1;
      double y = p[i].second+d[i].second*mid1;
      lx=min(lx,x);
      rx=max(rx,x);
      ly=min(ly,y);
      ry=max(ry,y);
    }
    c1=(rx-lx)*(ry-ly);
    lx=IINF,rx=-IINF,ly=IINF,ry=-IINF;
    rep(i,n){
      double x = p[i].first+d[i].first*mid2;
      double y = p[i].second+d[i].second*mid2;
      lx=min(lx,x);
      rx=max(rx,x);
      ly=min(ly,y);
      ry=max(ry,y);
    }
    c2=(rx-lx)*(ry-ly);
    if(c1<c2){
      ans=min(ans,c1);
      r=mid2;
    }else{
      ans=min(ans,c2);
      l=mid1;
    }
  }
  cout << fixed << setprecision(10) << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}


fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
	let v: Vec<i32> = read_vec();
    let result = v[0] * v[1];
    if result % 2 == 0 {
    	println!("Even");
    } else {
    	println!("Odd");
    }
}

Measured memory_bytes: 4352
s=input()
n=len(s)-1
a=0
for i in range(1<<n):
  l=[]
  for x,y in zip(s,[''for _ in[0]*10]):
    l.append(x)
    l.append(y)
  for j in range(n):
    if i>>j&1:
      l[j*2+1]='+'
  a+=eval(''.join(l))
print(a)

Measured memory_bytes: 40560
import java.util.*;

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 ans = N*A;
        
        if(ans <= B){
            System.out.println(ans);
        }else{
            System.out.println(B);
        }
        //System.out.println(ans);
    }
}

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

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

  if (a+b>c+d) {
    cout << "Left\n";
  }else if (a+b<c+d) {
    cout << "Right\n";
  }else {
    cout << "Balanced\n";
  }
}


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

#define int long long
#define inf 1000000007LL

#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define trep(i, n) for(int i = 0; i <= (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define mfor(i, s, t) for(int i = (s); i < (t); i++)
#define tfor(i, s, t) for(int i = (s); i <= (t); i++)

signed main() {
  int n;
  cin >> n;
  int ans[26];
  rep(i, 26) {
    ans[i] = inf;
  }
  rep(i, n) {
    int tmp[26];
    rep(j, 26) {
      tmp[j] = 0;
    }
    string s;
    cin >> s;
    for(auto j : s) {
      tmp[j - 'a']++;
    }
    rep(j, 26) {
      ans[j] = min(ans[j], tmp[j]);
    }
  }
  string ret;
  rep(i, 26) {
    rep(j, ans[i]) {
      ret += i + 'a';
    }
  }
  cout << ret << endl;
}


Measured memory_bytes: 256
using System;

namespace B___Hina_Arare
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var s = Console.ReadLine().Split(' ');
            var ans = "Three";
            for (var i = 0; i < n; i++)
            {
                if(s[i]=="Y")
                {
                    ans="Four";
                    break;
                }
            }
            Console.WriteLine(ans);
        }
    }
}

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

int main()
{
	int n,f=0,f2=0,f1=0,f3=0;
	cin >> n;
	for(int i = 1;i <= n;i++)
	{
		if(i <= 9)
			f++;
		else if(i>=100&& i <=999)
			f1++;
		else if(i >=10000 && i < 100000)
			f2++;
		else if(i > 100000 && i <= 1000000)
			f3++;
	}
	cout << f+f1+f2+f3;
	
}

Measured memory_bytes: 256
from collections import defaultdict

n, m = map(int, input().split())
needs = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
usable = defaultdict(lambda: 0)
for a in map(int, input().split()):
    na = needs[a]
    usable[na] = max(usable[na], a)
use_keys = sorted(usable.keys())

dp = [-1] * (n + 8)
dp[0] = 0
for a in sorted(usable.values(), reverse=True):
    na = needs[a]
    for i in range(n + 1):
        if dp[i] == -1:
            continue
        dp[i + na] = max(dp[i + na], dp[i] * 10 + a)

print(dp[n])


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

#define REP( i, n )     for( int (i) = 0; (i) < (n); (i)++ )
#define ALL( a )        (a).begin(), (a).end()

using namespace std;
using ll = long long;
using P = pair<int, int>;

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

const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9 + 7;

int main(){
    int a, b; cin >> a >> b;
    if( a * b % 2 == 1 ) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define ll long long 
#define pb push_back
#define mk make_pair
#define mod 1e9+7
using namespace std;

ll gcd(ll a, ll b){
    return __gcd(a,b);
}

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

bool isPrime(ll n){
    for(ll i=2; i<=sqrt(n); i++){
        if(n%i == 0){
            return false;
        }
    }
    return true;
}


void solve(){
    ll a[5];
    for(ll i=0; i<5; i++) cin >> a[i];
    for(ll i=0; i<5; i++) {
        if(a[i]==0){
            cout << i+1 ;
            return;
        }
    }
}

int main() {
    fast;
    solve();
	//ll t; cin >> t; while(t--){ solve(); }
	return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
const int mo = 1e9 + 7;
#define fi first
#define sd second
#define mp make_pair
template <class T>
inline void _read(T &x)
{
	x = 0;
	char t = getchar();
	while(!isdigit(t) && t != '-') t = getchar();
	if(t == '-')
	{
		_read(x);
		x *= -1;
		return ;
	}
	while(isdigit(t))
	{
		x = x * 10 + t - '0';
		t = getchar();
	}
}
const int MAXN = 100;
ll fib[MAXN];
vector< pii > base[MAXN];
inline int cgcd(ll a, ll b)
{
	if(b == 0) return 0;
	return cgcd(b, a % b) + 1;
}
inline int gcdnum(ll a, ll b)
{
	if(a < b) return cgcd(b, a);
	else return cgcd(a, b);
}
ll A, B;
int T;
inline void pre()
{
	fib[0] = fib[1] = 1;
	for(int i = 2; i <= 90; ++i) fib[i] = fib[i - 1] + fib[i - 2];
}
int main()
{
//	freopen("gcd.in", "r", stdin);
//	freopen("gcd.out", "w", stdout);
	pre();
	base[1].push_back({1, 2}), base[1].push_back({1, 3});
	for(int i = 2; i <= 88; ++i)
	{
		base[i].clear();
		for(auto p : base[i - 1])
		{
			ll tmp = p.sd;
			swap(p.fi, p.sd);
			p.sd += tmp;
			for(; p.sd <= fib[i + 2]; p.sd += tmp)
				if(gcdnum(p.fi, p.sd) == i) base[i].push_back(p);
//			cout << "**" << endl;
		}
		sort(base[i].begin(), base[i].end());
		base[i].erase(unique(base[i].begin(), base[i].end()), base[i].end());
//		cout << base[i].size() << endl;
//		cout << "i : " << i << endl;
	}
//	cout << "@#&*(&#" << endl;
//	for(int i = 1; i <= 10; ++i)
//	{
//		for(auto j : base[i])
//		{
//			cout << "(" << j.a << ", " << j.b << ") ";
//		}
//		cout << endl;
//	}
	_read(T);
	while(T--)
	{
		ll ans = 0, cnt = 0;
		_read(A), _read(B);
		if(A > B) swap(A, B);
		ans = 1;
		for(int i = 1; i < 90; ++i)
			if(fib[i] <= A && fib[i + 1] <= B) ans = i;
		if(ans == 1)
		{
			printf("1 %d\n", A % mo * (B % mo) % mo);
			continue;
		}
		else
		{
			for(auto p : base[ans - 1])
			{
				if(p.sd <= A) cnt = (cnt + (B - p.fi) / p.sd) % mo;
				if(p.sd <= B) cnt = (cnt + (A - p.fi) / p.sd) % mo;
			}
		}
		printf("%lld %lld\n", ans, cnt);
	}
	return 0;
}

Measured memory_bytes: 4096
'''
Created on 24-08-2019

@author: martins
'''

def check(m, i):
    a = i % 10
    b = i // 10
    if((a < 2) | (b < 2)):
        return 0
    elif(a*b <= m):
        return 1
    else:
        return 0

m, d = map(int, input().split())

res = 0
for i in range(22, d+1):
    res += check(m, i)

print(res)
    


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		//数取得
		int A = sc.nextInt();
		int B = sc.nextInt();
		int H = sc.nextInt();
		int M = sc.nextInt();
		sc.close();

		double answer = 0.00;

		double omega = 6*M - 30*H - 0.5*M ;
//		System.out.println(omega);

		if(omega >= 0) {
			//長針の方が進むとき
			if(omega >= 180) {
				omega = 360 - omega;
			}else {
				//そのまま使えるオメガ
			}
		}else {
			//短針の方が進むとき
			if(omega <= -180) {
				omega = 360 + omega;
			}else {

			}
		}

		double radian = Math.toRadians(omega);
		answer = A*A + B*B -2*A*B*Math.cos(radian);
		answer = Math.sqrt(answer);
		System.out.println(answer);
	}

}


Measured memory_bytes: 35992