akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

template <typename T>
void print_vec(const vector<T>& v, bool is_reverse=false, int num=0){
  if(num == 0) num = (int)v.size();
  if(is_reverse) for(int i=num-1; i>=0; i--){ cout<<v[i]; if(i!=0) cout<<" ";}
  else for(int i=0; i<num; i++){ cout<<v[i]; if(i!=num-1) cout<<" ";}
  cout << endl;
}

template <typename T>
void print_pairvec(const vector<T> &v, int num=0){
  if(num == 0) num = (int)v.size();
  cout << endl;
  for(int i=0; i<num; i++){ cout << v[i].first << " " << v[i].second << endl;}
}


template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
  cout << endl; cout << "       ";
  for(int i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(int j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}

int main(){
	int n;
	cin >> n;
	vector<ll> a(n);
	for(int i=0; i<n; i++) cin >> a[i];
	sort(a.begin(), a.end());

	ll Max = a.back();
	const int INF = 1e9+1;
	ll Mid = INF;
	// auto iter = lower_bound(a.begin(), a.end(), Max/2);
	// auto index = iter - a.begin();
	if(Max%2 == 0){
		int sub = INF;
		for(int i=0; i<n; i++){
			if(abs(Max/2 - a[i]) < sub){
				Mid = a[i];
				sub = Max/2 - a[i];
			}
		}
	}
	else if(Max % 2 == 1){
		int sub = INF;
		for(int i=0; i<n; i++){
			if(abs(Max/2 - a[i]) < sub){
				Mid = a[i];
				sub = Max/2 - a[i];
			}
			if(abs(Max/2 + 1  - a[i]) < sub){
				Mid = a[i];
				sub = Max/2 - a[i];
			}
		}
	}

	// ll nCk = 1;
	// for(int i=0; i<Mid; i++){
	// 	nCk *= Max - i;
	// 	nCk /= i+1;
	// }
	// cout << nCk << endl;

	cout << Max << " " << Mid << endl;

	return 0;
}



Measured memory_bytes: 4012
#!/usr/bin/env python

from sys import stdin, stderr

def solve(a, b):
   if a == 0 or b == 0: return 0
   if a < 0 and b > 0: return 0
   if a > 0: return 1
   L = b-a+1
   if (L % 2) == 0:
      return 1
   else:
      return -1

def main():
   a, b = map(int, stdin.readline().split())
   res = solve(a, b)
   if res < 0:
      print 'Negative'
   elif res > 0:
      print 'Positive'
   else:
      print 'Zero'
   return 0

if __name__ == '__main__': main()


Measured memory_bytes: 2692
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
#include <time.h>
#include <chrono>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,a,b) for(ll i=a;i>b;i--)
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
#define ct(a) cout<<a<<endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define repl(i,l,r) for(int i=(1);i<(r);i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
static const double pi = 3.141592653589793;
using namespace std;
typedef long long ll;
const ll MOD = 998244353;
const ll INF = 1e9 + 7;
const ll mod = 1e9 + 7;




int main() {


	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	
	int a; cin >> a;
	cout << a + a * a + a * a*a << endl;



	return 0;
}


Measured memory_bytes: 3604
import java.util.*;
import java.lang.*;
import java.io.*;
public class Main {

	public static void main(String[] args)throws java.lang.Exception
	{		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		long n = Long.parseLong(br.readLine()),p=0,total=0;
		List<Long> l=new ArrayList<>();
		StringTokenizer st = new StringTokenizer(br.readLine());
		for(int i=0; i<n; i++) l.add(Long.parseLong(st.nextToken()));
		Collections.sort(l, Collections.reverseOrder());
		for(int i=0; i<n-1; i++) {
			total+=l.get((int)p);
			if((i&1)==0) ++p;
		}
		System.out.println(total);
	}

}


Measured memory_bytes: 58848
import sys
a,b=map(int,input().split())
A=(a*100+8-1)//8
B=b*10
if a%2==0:
  for i in range(13):
    AA=A+i
    for j in range(10):
      BB=B+j
      if AA==BB:
        print(AA)
        sys.exit()
else:
  for i in range(12):
    AA=A+i
    for j in range(10):
      BB=B+j
      if AA==BB:
        print(AA)
        sys.exit()
print(-1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
string S, T;
cin >> S >> T;
  
int A, B;
cin >> A >> B;

  
string U;
cin >> U;
  
if ( U == S ) A--;
else B--;
  
    // 出力
    cout << A << " " << B << endl;
}

Measured memory_bytes: 256
s = input()

ans = 100000000000

for i in range(len(s)-2):
    tmp = 100 * int(s[i]) + 10 * int(s[i + 1]) + int(s[i+2])

    if abs(753 - int(tmp)) < ans:
        ans = abs(753 - int(tmp))


print(ans)



Measured memory_bytes: 2940
#define _USE_MATH_DEFINES

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <climits>
#include <cmath>
#include <utility>
#include <iomanip>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <boost/multiprecision/cpp_dec_float.hpp>

using namespace std;
using ll = long long int;
//// 任意長整数型
//namespace mp = boost::multiprecision;
//using Bint = mp::cpp_int;
//using Real1024 = mp::number<mp::cpp_dec_float<1024>>;



int rekkyo(string str, const int n)
{
	if (str.size() == n){
		cout << str << endl;
		return 0;
	}

	char max_char = 'a';
	for (size_t i = 0; i < str.size(); i++){
		max_char = max(max_char, str[i]);
	}

	for (char c = 'a'; c <= max_char + 1; c++){
		string next_str = str + c;
		rekkyo(next_str, n);
	}

	return 0;
}


int main(int argc, char *argv[])
{
	//input
	int n;
	cin >> n;


	//calc
	string ans = "a";
	rekkyo(ans, n);


	//ans


	return 0;
}


Measured memory_bytes: 1536
s=input()
for i in range(2**3):
    tmp=int(s[0])
    tmp+=int(s[1]) if i&1==1 else -1*int(s[1])
    tmp+=int(s[2]) if i&2==2 else -1*int(s[2])
    tmp+=int(s[3]) if i&4==4 else -1*int(s[3])
    if tmp==7:
        ans=s[0]
        ans+='+' if i&1==1 else '-'
        ans+=s[1]
        ans+='+' if i&2==2 else '-'
        ans+=s[2]
        ans+='+' if i&4==4 else '-'
        ans+=s[3]+'=7'
        print(ans)
        break

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

using namespace std;

int main(){
	#ifdef EVAL
		freopen("input.txt", "r", stdin);
		//freopen("output.txt", "w", stdout);
	#endif
	int N;
	cin >> N;
	vector <long double> v(N);
	for(int i = 0; i < N; i++){
		cin >> v[i];
	}
	sort(v.begin(),v.end());
	long double cur = (v[0] + v[1]) / 2;
	for(int i = 2; i < N; i++){
		cur = (cur + v[i]) / 2;
	}
	cout << cur;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
void solve(){
  int n,x,t;
  cin>>n>>x>>t;
  int z=ceil(n*1.0/x)*t;
  cout<<z<<endl;
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


Measured memory_bytes: 3652
from bisect import bisect_left

n = int(input())
s = input()

def calc(s):
    positions = {'R': [], 'G': [], 'B': []}
    positions_s = {'R': set(), 'G': set(), 'B': set()}
    for i, ch in enumerate(s):
        positions[ch].append(i)
        positions_s[ch].add(i)
    ans = 0

    for i in range(len(s)):
        for j in range(i + 1, len(s)):
            if s[i] != s[j]:
                for c3 in 'RGB':
                    if c3 not in (s[i], s[j]):
                        break
                k0 = bisect_left(positions[c3], j + 1)
                ans += len(positions[c3]) - k0
                if j + j - i in positions_s[c3]:
                    ans -= 1
    return ans


print(calc(s))


Measured memory_bytes: 70492
#include<iostream>
#include<string>
using namespace std;
int main(){
  int ans = 0;
  string s;
  cin >> s;
  if(s[0] == 'R'){
    if(s[1] == 'R'){
      if(s[2] == 'R'){
        cout << 3 << endl;
      }else{
        cout << 2 << endl;
      }
    }
    else{
      if(s[2] == 'R'){
        cout << 1 << endl;
      }
      else{
        cout << 1 << endl;
      }
    }
  }
  else{
    if(s[1] == 'R'){
      if(s[2] == 'R'){
        cout << 2 << endl;
      }
      else{
        cout << 1 << endl;
      }
    }
    else{
      if(s[2] == 'R'){
        cout << 1 << endl;
      }
      else{
        cout << 0 << endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int n,m;
vector<int> pred[100010];
int f[100010];
int lp(int x){
	if(f[x]!=-1)
	   return f[x];
	for(int i=0;i<pred[x].size();i++){
		f[x]=max(f[x],lp(pred[x][i])+1);
	}
	f[x]=max(f[x],0);
	return f[x];
}
int main()
{
	cin>>n>>m;
	int a,b;
	for(int i=1;i<=m;i++){
		cin>>a>>b;
		pred[b].push_back(a);
	}
	int maxx=0;
	memset(f,-1,sizeof(f));
	for(int i=1;i<=n;i++){
		if(f[i]==-1)
	      f[i]=lp(i);
	    maxx=max(maxx,f[i]);
	}
	cout<<maxx<<endl;
	return 0;
}


Measured memory_bytes: 10624
#include<stdio.h>
#include<algorithm>
#include<vector>
using namespace std;
int UF[1100];
int ret[10];
int FIND(int a){
	if(UF[a]<0)return a;
	return UF[a]=FIND(UF[a]);
}
void UNION(int a,int b){
	a=FIND(a);b=FIND(b);if(a==b)return;UF[a]+=UF[b];UF[b]=a;
}
vector<int>g[1100];
int v[1100];
int sc[1100];
int x1[1100];
int x2[1100];
int y1[1100];
int y2[1100];
int ten(int a,int b){
	if(x1[a]==x2[b]&&y1[a]==y2[b])return 1;
	if(x1[a]==x1[b]&&y1[a]==y1[b])return 1;
	if(x2[a]==x2[b]&&y2[a]==y2[b])return 1;
	if(x2[a]==x1[b]&&y2[a]==y1[b])return 1;
	return 0;
}
int hen(int a,int b){
	if(min(x1[a],x2[a])<=x1[b]&&x1[b]<=max(x1[a],x2[a])&&min(y1[a],y2[a])<=y1[b]&&y1[b]<=max(y1[a],y2[a])&&(y1[a]-y1[b])*(x2[a]-x1[b])==(y2[a]-y1[b])*(x1[a]-x1[b]))return 1;
	if(min(x1[a],x2[a])<=x2[b]&&x2[b]<=max(x1[a],x2[a])&&min(y1[a],y2[a])<=y2[b]&&y2[b]<=max(y1[a],y2[a])&&(y1[a]-y2[b])*(x2[a]-x2[b])==(y2[a]-y2[b])*(x1[a]-x2[b]))return 1;
	swap(a,b);
	if(min(x1[a],x2[a])<=x1[b]&&x1[b]<=max(x1[a],x2[a])&&min(y1[a],y2[a])<=y1[b]&&y1[b]<=max(y1[a],y2[a])&&(y1[a]-y1[b])*(x2[a]-x1[b])==(y2[a]-y1[b])*(x1[a]-x1[b]))return 1;
	if(min(x1[a],x2[a])<=x2[b]&&x2[b]<=max(x1[a],x2[a])&&min(y1[a],y2[a])<=y2[b]&&y2[b]<=max(y1[a],y2[a])&&(y1[a]-y2[b])*(x2[a]-x2[b])==(y2[a]-y2[b])*(x1[a]-x2[b]))return 1;
	return 0;
}
int sz[]={4,1,5,4,3,5,5,3,5,4};
int p[]={8,0,8,5,3,8,9,4,10,7};
int main(){
	int a;
	while(scanf("%d",&a),a){
		for(int i=0;i<a;i++)scanf("%d%d%d%d",x1+i,y1+i,x2+i,y2+i);
		for(int i=0;i<10;i++)ret[i]=0;
		for(int i=0;i<a;i++)UF[i]=-1;
		for(int i=0;i<a;i++)v[i]=sc[i]=0;
		for(int i=0;i<a;i++)g[i].clear();
		for(int i=0;i<a;i++){
			for(int j=i+1;j<a;j++){
				if(ten(i,j)){
					v[i]++;
				}
				if(hen(i,j)){
					UNION(i,j);
					v[i]++;
					g[i].push_back(j);
					g[j].push_back(i);
				}
			}
		}
		for(int i=0;i<a;i++)sc[FIND(i)]+=v[i];
		for(int i=0;i<a;i++){
			if(UF[i]<0){
				int s=-UF[i];
				if(s==5&&sc[i]==8){
					for(int j=0;j<a;j++)if(FIND(j)==i&&g[j].size()==1){
						int l=j;
						int r=g[j][0];
						int dx1,dy1,dx2,dy2;
						if(x1[l]==x1[r]&&y1[l]==y1[r]){dx1=x2[l]-x1[l];dy1=y2[l]-y1[l];dx2=x2[r]-x1[r];dy2=y2[r]-y1[r];}
						if(x1[l]==x2[r]&&y1[l]==y2[r]){dx1=x2[l]-x1[l];dy1=y2[l]-y1[l];dx2=x1[r]-x2[r];dy2=y1[r]-y2[r];}
						if(x2[l]==x1[r]&&y2[l]==y1[r]){dx1=x1[l]-x2[l];dy1=y1[l]-y2[l];dx2=x2[r]-x1[r];dy2=y2[r]-y1[r];}
						if(x2[l]==x2[r]&&y2[l]==y2[r]){dx1=x1[l]-x2[l];dy1=y1[l]-y2[l];dx2=x1[r]-x2[r];dy2=y1[r]-y2[r];}
						if(dx1*dy2-dx2*dy1>0)ret[2]++;
						else ret[5]++;
						break;
					}
				}else{
					for(int j=0;j<10;j++)if(sc[i]==p[j]&&s==sz[j])ret[j]++;
				}
			}
		}
		for(int i=0;i<10;i++){
			if(i)printf(" ");
			printf("%d",ret[i]);
		}
		printf("\n");
	}
}

Measured memory_bytes: 1140
#include<bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
#define DEKAI 1000000007
#define INF (1<<28)
#define int long long
/* ┗(^o^)┛ｗｗｗｗｗ┏(^o^)┓ﾄﾞｺﾄﾞｺﾄﾞｺﾄﾞｺｗｗｗｗｗ */

signed main(){
	int n,t;
	cin>>n>>t;
	int ans=INF;
	lp(i,n){
		int a,b;
		cin>>a>>b;
		if(b<=t){
			ans=min(ans,a);
		}

	}
	if(ans==INF) cout<<"TLE"<<endl;
	else cout<<ans<<endl;
	return 0;
}


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

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int k = sc.nextInt();
      int t = sc.nextInt();

      PriorityQueue<Integer> pq = new PriorityQueue((a, b) -> (int)b - (int)a);
      for(int i = 0; i < t; i++)
        pq.offer(sc.nextInt());
      while(pq.size() > 1) {
        int a = pq.poll();
        int b = pq.poll();
        a -= 1;
        b -= 1;
        if(a > 0) pq.offer(a);
        if(b > 0) pq.offer(b);
      }
      System.out.println(pq.size() == 0 ? 0 : pq.peek() - 1);
  }
}

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

#define MAXN (200010)
#define ll long long

int n;
ll a[MAXN];

int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; ++ i){
		scanf("%lld", a + i);
		a[i] += a[i - 1];
	}
	ll ans = LLONG_MAX;
	for(int i = 2; i <= n; ++ i){
		ans = std::min(ans, std::abs(a[n] - a[i - 1] - a[i - 1]));
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF 1<<30
#define LINF 1LL<<60

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_5_A&lang=jp
int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    ll N,T; cin >> N >> T;
    vector<ll> CumSum(T+1,0);
    for(int i = 0; i < N;i++){
        ll l,r; cin >> l >> r;
        CumSum[l]++;
        CumSum[r]--;
    }
    ll ans = CumSum[0];
    //cout << CumSum[0] << " ";
    for(int i = 1; i <= T;i++){
        CumSum[i] += CumSum[i-1];
        //cout << CumSum[i] << " ";
        ans = max(ans,CumSum[i]);
    }
    //cout << endl;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
    int n ;
    string s ;
    cin >> n >> s ;
    int x = 0 ;
    int max = 0 ;

    for(int i = 0 ; i < n ; i++ ){
        if(s[i] == 'I') x++ ;
        else x-- ;
        if(x > max) max = x ;
    }
    cout << max << endl;
    return 0;
}

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

using namespace std;

int main(){
    int n;
    while(true){
        cin>>n;
        if(n==0)break;
        vector<vector<int>> d;
        int ans=0;
        map<string,int> mp;
        mp["Red"]=0;
        mp["Yellow"]=1;
        mp["Blue"]=2;
        mp["Magenta"]=3;
        mp["Green"]=4;
        mp["Cyan"]=5;
        const int sa[6][4]={
                {4,2,1,3},
                {0,2,5,3},
                {4,5,1,0},
                {4,0,1,5},
                {5,2,0,3},
                {4,3,1,2}
        };
        for (int i = 0; i < n; ++i) {
            vector<string> s(6);
            int id;
            for (int j = 0; j < 6; ++j) {
                cin>>s[j];
                if(s[j]=="Red")id=j;
            }
            vector<int> tv;
            for (int j = 0; j < 4; ++j) {
                tv.emplace_back(mp[s[sa[id][j]]]);
            }
            for(auto item:d){
                for (int j = 0; j < 4; ++j) {
                    bool f=true;
                    for (int k = 0; k < 4; ++k) {
                        if(tv[k]!=item[(j+k)%4]){
                            f=false;
                            break;
                        }
                    }
                    if(f){
                        ++ans;
                        goto failed;
                    }
                }
            }
            d.emplace_back(tv);
            failed:;
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 3068
A = input()
B = input()
C = input()

# 文字列
S = {"a":A, "b":B, "c":C}
# 長さ
L = {"a":len(A), "b":len(B), "c":len(C)}
# 何文字目まで使ったか
C = {"a":0, "b":0, "c":0}

turn = "a"
# 文字を使い切る人が出るまで処理し続ける
while C[turn] < L[turn]:
    C[turn] += 1
    turn = S[turn][C[turn]-1]

print(turn.upper())



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

const int maxn = 1e2 + 10 , mod = 1e9 + 7;

int n, a[2][maxn], pu[maxn], pd[maxn], res;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 0; i < 2; i++)
		for (int j = 0; j < n; j++)
		{
			cin >> a[i][j];
			if (!i)
				pu[j+1] = pu[j] + a[i][j];
			else
				pd[j+1] = pd[j] + a[i][j];
		}
	for (int i = 1; i <= n; i++)
		res = max (res, pu[i] + (pd[n] - pd[i-1]));
	
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <deque>
#include <vector>
#include <algorithm>
 
using namespace std;
 
int main()
{
    int n,x;
    cin >> n >> x;
    int l[n], d[n];
    for(int i=0; i<n; i++){
        cin >> l[i];
        d[i] = 0;
    }
    int cnt = 1;
    for(int i=1; i<=n; i++){
        d[i] = d[i-1] + l[i-1]; 
        if(x < d[i]) break;
        cnt++;
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int N, B, A;
    int fara1, fara2;

    scanf("%d", &N);

    scanf("%d", &A);

    scanf("%d", &B);
    
    fara1 = N*A;
    fara2 = B;

     if (fara1 >= fara2) {
         printf("%d\n", fara2);
         } 
         else {
        printf("%d\n", fara1);
  }

}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
 
////////////// Prewritten code follows. Look down for solution. ////////////////

#define fs first
#define sc second
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define len(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
typedef pair<ll, ll> pll;

template<typename T>
const T INF = (is_same<T, int>::value ? 1e9 : 1e18);
template<typename T>
inline T mod(T n, T mod){ T res = n%mod; if(res < 0) res += mod; return res; }
 
////////////////////////// Solution starts below. //////////////////////////////

int main(){
  fastio;
  string s;
  cin >> s;
  if(s == "Sunny") cout << "Cloudy\n";
  if(s == "Cloudy") cout << "Rainy\n";
  if(s == "Rainy") cout << "Sunny\n";
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
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; }
// template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

int ans;
int n, m;
vector<vector<int> > v(10);

void dfs(int now, int bef, int reached) {
    if (reached & (1 << now)) return;
    reached |= 1 << now;
    if (reached == (1 << n) - 1) {
        ans++;
        return;
    }
    for (int nxt : v[now]) {
        if (nxt == bef) continue;
        dfs(nxt, now, reached);
    }
}

int main() {
    
    cin >> n >> m;
    
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        v[a].eb(b);
        v[b].eb(a);
    }
    
    dfs(0, -1, 0);
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int Parent(int);
int Left(int);
int Right(int);

int main(){
  int n,i,A[100001];

  scanf("%d",&n);

  for(i = 0 ; i < n ; i++){
    scanf("%d",&A[i+1]);
  }

  for(i = 0 ; i < n ; i++){
    printf("node %d: key = %d, ",i+1,A[i+1]);

    if(Parent(i+1) >= 1) printf("parent key = %d, ",A[Parent(i+1)]);
    if(Left(i+1) <= n) printf("left key = %d, ",A[Left(i+1)]);
    if(Right(i+1) <= n) printf("right key = %d, ",A[Right(i+1)]);

    printf("\n");
  }
    
  return 0;
}

int Parent(int x){
  return x / 2;
}

int Left(int x){
  return 2 * x;
}

int Right(int x){
  return 2 * x + 1;
}



Measured memory_bytes: 2108
n = gets.to_i
x = gets.chomp
c = x.count(?1)

pow2_mod_up1 = Array.new(n, 0)
if c > 0
    pow2_mod_up1[0] = 1
    (n-1).times{|i| pow2_mod_up1[i+1] = (pow2_mod_up1[i] << 1) % (c+1)}
end

pow2_mod_down1 = Array.new(n, 0)
if c > 2
    pow2_mod_down1[0] = 1
    (n-1).times {|i| pow2_mod_down1[i+1] = (pow2_mod_down1[i] << 1) % (c-1)}
end

x_mod_up1 = x_mod_down1 = 0
n.times do |i|
    x_mod_up1 += pow2_mod_up1[n-i-1] * x[i].to_i
    x_mod_down1 += pow2_mod_down1[n-i-1] * x[i].to_i
end
x_mod_up1 %= c + 1
x_mod_down1 %= c - 1 if c > 2

n.times do |i|
    if x[i] == ?0
        a = (x_mod_up1 + pow2_mod_up1[n-i-1]) % (c+1)
    else
        if c == 1
            puts 0
            next
        end
        a = (x_mod_down1 - pow2_mod_down1[n-i-1]) % (c-1)
    end

    ans = 1
    while a != 0
        a %= a.to_s(2).each_char.count(?1)
        ans += 1
    end
    p ans
end

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

int main(){
  int i,j,cnt=0;
  int n;
  cin>>n;
  int v[n];
  for(i=0;i<n;i++)cin>>v[i];
  int a[100001],b[100001];
  for(i=0;i<=100000;i++){
    a[i]=0;
    b[i]=0;
  }
  for(i=0;i<n;i++){
    if(i%2==0)a[v[i]]++;
    else b[v[i]]++;
  }
  int ma=0,cnt2=0;
  for(i=0;i<100001;i++){
    if(ma<a[i]){
      cnt=i;
      ma=a[i];
    }
  }
  ma=0;
  for(i=0;i<100001;i++){
    if(ma<b[i]){
      cnt2=i;
      ma=b[i];
    }
  }
  sort(a,a+100001,greater<int>());
  sort(b,b+100001,greater<int>());
  if(cnt!=cnt2)cout<<n-a[0]-b[0]<<endl;
  else{
    cout<<min(n-a[1]-b[0],n-a[0]-b[1])<<endl;
  }
}

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

int main(){
  int x,y,z,minm=100000000,e;
  while(true){
    minm=1000000;
    cin>>e;
    if(e==0)break;
    for(z=0; z*z*z<=e; z++){
      for(y=0; y*y+z*z*z<=e; y++){
	x = e-y*y-z*z*z;
	if(x>=0) minm = min(minm,x+y+z);
      }
    }
    cout<<minm<<endl;
  }
  return 0;
}



Measured memory_bytes: 3056
#include <bits/stdc++.h>
using namespace std;
int x,k;
int main()
{
    ios::sync_with_stdio(false);
    cin>>k>>x;
    for(int i=k-1;i>=1;--i) cout<<x-i<<' ';
    cout<<x<<' ';
    for(int i=1;i<k;++i) cout<<x+i<<' ';
    return 0;
}


Measured memory_bytes: 384
k = int(input())

if k % 2 == 0 or k % 5 ==0:
    print(-1)
else:
    ans = 1
    num = 7
    while True:
        if int(num) % k == 0:
            print(ans)
            break
        else:
            ans += 1
            num += 7 * pow(10, ans - 1, k)
            num %= k


Measured memory_bytes: 9132
'''
A - AtCoder Beginner Contest 999
https://atcoder.jp/contests/abc111/tasks/abc111_a

>>> main(119)
991
>>> main(999)
111
'''


def main(n):
    res = ''
    for _n in str(n):
        if _n == '1':
            res += '9'
        else:
            res += '1'

    print(res)


if __name__ == '__main__':
    main(int(input()))


Measured memory_bytes: 2940
*G=gets
$<.map{x=_1.split.map &:to_i;x.map{|a|G[a]||=[];G[a].push *x}}
puts G[1]&&(d,*v=->i{a=[[i,1]]
(i,l=a.pop
v[i]=l
G[i].map{v[_1]||a<<[_1,l+1]})while a[0]},0
d[1]
a=v.index v.max
*v=0
d[a]
v.max%3>1)?:Second: :First

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

//諸機能
#pragma region MACRO 
#define putans(x)  std::cerr << "[ answer ]: " ; cout << (x) << endl
#define dputans(x) std::cerr << "[ answer ]: "; cout << setprecision(27) << (double)(x) << endl
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define RREP(i,a,n) for(int i=(int)(n-1); i>= a; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) begin((a)),end((a))
#define mp make_pair
#define exist(container, n) ((container).find((n)) != (container).end())
#define equals(a,b) (fabs((a)-(b)) < EPS)
#ifdef _DEBUG //ファイルからテストデータを読み込む
std::ifstream ifs("data.txt");
#define put ifs >>
#else //ジャッジシステムでいい感じにやる
#define put cin >>
#endif
#pragma endregion
//デバッグなどの支援
#pragma region CODING_SUPPORT
#ifdef _DEBUG
#define dbg(var0) { std::cerr << ( #var0 ) << "=" << ( var0 ) << endl; }
#define dbg2(var0, var1) { std::cerr << ( #var0 ) << "=" << ( var0 ) << ", "; dbg(var1); }
#define dbg3(var0, var1, var2) { std::cerr << ( #var0 ) << "=" << ( var0 ) << ", "; dbg2(var1, var2); }
#define dbgArray(a,n) {std::cerr << (#a) << "=";  rep(i,n){std::cerr <<(a[i])<<",";} cerr<<endl;} 
#else
#define dbg(var0) {}
#define dbg2(var0, var1) {}
#define dbg3(var0, var1, var2) {}
#define dbgArray(a,n) {}
#endif 
#pragma endregion 
//typedef（書き換える、書き足す可能性ある）
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii; typedef pair<string, string> pss; typedef pair<int, string>pis;
typedef vector<string> vs; typedef vector<int> vi;
#pragma endregion
//諸々の定数(書き換える可能性ある)
#pragma region CONST_VAL
#define PI (2*acos(0.0))
#define EPS (1e-10)
#define MOD (ll)(1e9 + 7)
#define INF (ll)(2*1e9)
#pragma endregion



int main() {
	int n; put n;
	string s, t; put s >> t;
	int match = 0;
	rep(i, s.size()) {
		string sp = string(s, s.size() - 1 - i, i + 1);
		string tp = string(t, 0, i + 1);
		dbg2(sp, tp);
		if (sp == tp) match = i + 1;
	}
	putans(s.size() + t.size() - match);
END:
	return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var N, M int
	fmt.Scan(&N, &M)
	if N < M {
		N, M = M, N
	}
	var ans int
	if N-M >= 2 {
		ans = 0
	} else {
		ans = ModFactorial(N) * ModFactorial(M)
		if N == M {
			ans *= 2
		}
	}
	fmt.Println(ans % Mod)
}

const Mod = int(1e9) + 7

func ModFactorial(n int) int { return fac[n] }

var fac []int

func init() {
	const MAX = 1e5
	fac = make([]int, MAX+1)
	fac[0], fac[1] = 1, 1
	for i := 2; i <= MAX; i++ {
		fac[i] = fac[i-1] * i % Mod
	}
}


Measured memory_bytes: 2592
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		sc.close();
		int x = 1000;
		for(int i=0; i<S.length()-2; i++) {
			int a = Character.getNumericValue(S.charAt(i))*100 + Character.getNumericValue(S.charAt(i+1))*10 + Character.getNumericValue(S.charAt(i+2))*1;
			int b = Math.abs(753-a);
			if(b<x) {
				x = b;
			}
		}
		System.out.println(x);
	}

}

Measured memory_bytes: 35680
n, m, k = map(int, input().split(' '))
a_books = [0] + list(map(int, input().split(' ')))
b_books = [0] + list(map(int, input().split(' ')))
result = 0

for i in range(1, n+1):
    a_books[i] += a_books[i-1]
for j in range(1, m+1):
    b_books[j] += b_books[j-1]

b_cnt = m
for a_cnt in range(n+1):
    if a_books[a_cnt] > k:
        break
    while a_books[a_cnt] + b_books[b_cnt] > k:
        b_cnt -= 1
    result = max(result, a_cnt + b_cnt)
print(result)

Measured memory_bytes: 39828
use proconio::input;

fn main() {
    input! {
    n:usize,
    a:[i64;n],
    }

    let mut ans: i64 = a.iter().map(|&x| x.abs()).sum();
    let min = a.iter().map(|&x| x.abs()).min().unwrap();
    let cnt = a.into_iter().filter(|&x| x < 0).count();

    if cnt % 2 == 1 { ans -= 2 * min; }
    println!("{}", ans);
}

Measured memory_bytes: 3764
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


///////////////////////////




int main() {

	ll N, K;
	cin >> N >> K;
	if (K == 1) { cout << 0; }
	else { cout << N - K; }

	system("PAUSE");

}


Measured memory_bytes: 504
class uf_tree:
    def __init__(self, n):
        self._size = n
        self.sizes = [1] * n
        self.par = list(range(n))
 
    def find(self, x):
        if x == self.par[x]:
            return x
        self.par[x] = self.find(self.par[x])
        return self.par[x]
 
    def unite(self, x, y):
        self._size -= 1
        x, y = self.find(x), self.find(y)
        if x == y:
            return
        if self.sizes[x] < self.sizes[y]:
            x, y = y, x
        self.par[y] = x
        self.sizes[x] += self.sizes[y]
 
    def same(self, x, y):
        return self.find(x) == self.find(y)
 
    def size(self, x):
        return self.sizes[self.find(x)]


n, m = map(int, input().split())
p = [ int(x) for x in input().split() ]


uf = uf_tree(n+5)

for _ in range(m):
    x, y = map(int, input().split())
    uf.unite(x, y)    

ans = 0

for item_id, item in enumerate(p):
    if item == item_id + 1:
        ans += 1
    elif uf.same(item, item_id+1):
        ans += 1

print(ans)

Measured memory_bytes: 14320
N,M = map(int, input().split())

Ques = [0]*(N + 1)

correct = 0
incorrect = 0

for i in range(M):
    p,S = input().split()
    p = int(p)
    if Ques[p] == -1:
        continue
    
    if S == "AC":
        correct += 1
        incorrect += Ques[p]
        Ques[p] = -1
        
    else:
        Ques[p] += 1

print(correct, incorrect)

    

Measured memory_bytes: 3828
#include <iostream>
#include <cctype>
#include <string>

using namespace std;
string toUpper(string t) {
	string s = t;
	for (int i = 0; i < t.size(); i++) {
		s[i] = toupper(t[i]);
	}
	return s;
}
int main()
{
	string target, source;
	int count=0;
	cin >> target;
	target = toUpper(target);
	
	while (1) {
		cin >> source;
		if (source == "END_OF_TEXT") break;
		source = toUpper(source);
		if (target == source) count++;
	}
	cout << count << endl;
	
	return 0;
}

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

int H,W,N;
int a[201][201];
int A[201][201];


int calc(int h,int w,int H,int W){
  return A[H][W]-A[H][w]-A[h][W]+A[h][w];
}


bool solve(int h,int w,int H,int W,int N,int M){
  int res=0,total=calc(h,w,H,W);
  if(N==1)return (total>=M);
  
  for(int i=h+1;i<H;i++){
    if(calc(h,w,i,W)<M)continue;
    if(solve(i,w,H,W,N-1,M))return true;
    break;
  }
  
  for(int j=w+1;j<W;j++){
    if(calc(h,w,H,j)<M)continue;
    if(solve(h,j,H,W,N-1,M))return true;
    break;
  }

  for(int i=H-1;i>h;i--){
    if(calc(i,w,H,W)<M)continue;
    if(solve(h,w,i,W,N-1,M))return true;
    break;
  }

  for(int j=W-1;j>w;j--){
    if(calc(h,j,H,W)<M)continue;
    if(solve(h,w,H,j,N-1,M))return true;
    break;
  }
  return res;
}

bool check(int nv,int sv,int M){
  int ev=0,wv=0;
  while( calc(0,0,wv,nv) < M ){
    wv++;
    if(wv>=H)return false;
  }
  
  while( calc(0,nv,ev,W) < M ){
    ev++;
    if(ev>=H)return false;
  }

  if(sv<nv)ev=max(ev,wv);
  if(sv>nv)wv=max(ev,wv);
  
  if( calc(wv,0,H,sv) < M)return false;
  if( calc(ev,sv,H,W) < M)return false;

  return true;
}

bool check(int M){
  if(N==4){
    for(int nv=1;nv<W;nv++)
      for(int sv=1;sv<W;sv++)
        if(check(nv,sv,M))return true;
  }
  if( solve(0,0,H,W,N,M) )return true;
  return false;
}

int compute(){
  int L=0,R=2e8+1,M;
  while(R-L>1){
    M=(L+R)/2;
    if(check(M))L=M;
    else R=M;
  }
  return L;
}

int main(){
  scanf("%d %d %d",&H,&W,&N);
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      scanf("%d",&a[i][j]);
      A[i+1][j+1]=a[i][j]+A[i+1][j]+A[i][j+1]-A[i][j];
    }
  }

  int ans=compute();
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 3528
#include<bits/stdc++.h>
#define ll long long

const int N = 100010;

int a[N];
int n;

int main(){
	scanf("%d", &n);
	for (int i = 0; i < n; ++ i){
		scanf("%d", &a[i]);
	}
	ll sum = 0, ans = 0;
	for (int i = 0; i < n; ++ i){
		sum += a[i];
		if (i & 1){
			if (sum > 0){
				continue;
			}
			ans += 1 - sum;
			sum = 1;
		}
		else{
			if (sum < 0){
				continue;
			}
			ans += sum + 1;
			sum = -1;
		}
	}
	ll min = ans;
	sum = 0, ans = 0;
	for (int i = 0; i < n; ++ i){
		sum += a[i];
		if (!(i & 1)){
			if (sum > 0){
				continue;
			}
			ans += 1 - sum;
			sum = 1;
		}
		else{
			if (sum < 0){
				continue;
			}
			ans += sum + 1;
			sum = -1;
		}
	}
	min = std::min(ans, min);
	return printf("%lld\n", min), 0;
}

Measured memory_bytes: 640
//#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

#define rep(i,n) for(ll (i)=0;(i)<(ll)(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007LL
#define INF (1LL<<60LL)
#define int long long
typedef long long ll;

using namespace std;

#define MAXN 1000000

signed main() {
	int a, b, c;
	cin >> a >> b >> c;
	int ans = 0;
	if (abs(b - c) % 2 == 0) {
		ans = abs(b - c) / 2;
	}
	else {
		ans = min((b - 1 + c) / 2, (a - b + a - c + 1) / 2);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
parseInt(x) = parse(Int, x)

function main()
	n = parseInt(readline())
	x = [0 for i in 1:n]
	for i in 1:n
		x[i] = parseInt(readline())
	end
	x = sort(x)
	count = 1
	for i in 2:n
		if x[i] > x[i-1]
			count += 1
		end
	end
	print(count)
end

main()

Measured memory_bytes: 112904
list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(str(list[int(input())-1]))

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

using namespace std;

int n, m;
int a[100005];

int solve(double v) {
	int cnt = 0;
	
	for (int i = 0; i < n; i++) {
		int x = max(0, (int)(log2(a[i] * 1.0 / v)));
		cnt += x;
		//a[i] / 2^x >= v
		//a[i] >= v * 2^x
		//log(a[i]) >= log(v) + x
	}
	
	return cnt;
}

int main() {
	scanf("%d%d", &n, &m);
	
	for (int i = 0; i < n; i++) scanf("%d", &a[i]);
	
	double lb = 0;
	double ub = 1e9;
	
	for (int i = 0; i < 300; i++) {
		double mid = (lb + ub) / 2;
		if (solve(mid) <= m) ub = mid;
		else lb = mid;
	}
	
	if (fabs(ub) < 1e-9) return 0 * printf("0\n");
	
	long long res = 0;
	int cnt = 0;
	
	for (int i = 0; i < n; i++) {
		int x = max(0, (int)(log2(a[i] * 1.0 / ub)));
		a[i] /= (1 << x);
		cnt += x;
	}
	
	int mx = *max_element(a, a + n);
	
	for (int i = 0; i < n; i++) {
		if (cnt == m) break;
		
		if (a[i] == mx) {
			a[i] /= 2;
			cnt++;
		}
	}
	
	for (int i = 0; i < n; i++) res += a[i];
	
	printf("%lld\n", res);
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

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

    int a, b; cin >> a >> b;
    if(a == 1) a = 14;
    if(b == 1) b = 14;

    if(a == b) cout << "Draw";
    if(a <  b) cout << "Bob";
    if(a >  b) cout << "Alice";

    return 0;
}


Measured memory_bytes: 256
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/
 
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x
 
using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;
 
const ll MODBASE = 1000000007LL;
const int MAXN = 110;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    int a, b;
    cin >> a >> b;
    char A = char(a + '0');
    char B = char(b + '0');
    string s = "", t = "";
    FOR(i,1,b) s += A;
    FOR(i,1,a) t += B;
    if (s < t) cout << s;
    else cout << t;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<queue>
#include<algorithm>
using namespace std;
const int maxn=1e7;
const int mod=998244353;
long long ans=0;
int n;
int fir[maxn+5],inv[maxn+5],mu[maxn+5];
long long ksm(long long x,long long n)
{
	long long ans=1;
	while(n)
	{
		if(n&1) ans=ans*x%mod;
		x=x*x%mod;
		n>>=1;
	}
	return ans;
}
long long C(int n,int m)
{
	return 1ll*fir[n]*inv[m]%mod*inv[n-m]%mod;
}
int main()
{
	scanf("%d",&n);
	fir[0]=1;
	for(int i=1;i<=n;i++) fir[i]=1ll*fir[i-1]*i%mod;
	inv[n]=ksm(fir[n],mod-2);
	for(int i=n-1;i>=0;i--) inv[i]=1ll*inv[i+1]*(i+1)%mod;
	mu[0]=1;
	for(int i=1;i<=n;i++) mu[i]=mu[i-1]*2%mod;
	for(int i=n/2+1;i<=n;i++) ans=(ans+C(n,i)*mu[n-i]%mod)%mod;
	ans=(ksm(3,n)-ans*2%mod)%mod;
	ans=(ans%mod+mod)%mod;
	printf("%lld\n",ans);
}

Measured memory_bytes: 120908
#include <bits/stdc++.h>
#include <stdio.h>
# define M_PI  3.14159265358979323846
using namespace std;

typedef long long ll;
const int N = 1e3 + 9, M = 9e2 + 9, OO = 0x3f3f3f3f;
const double EPS = 0.00000000001;


int n, x, y;
ll l;
pair<int, int> town[10];
double dist[50000];

int fact(int n){
	int ans = 1;
	for(int i = 1 ; i <= n ; ++i) ans *= i;
	return ans;
}


double avg(){
	double sum = 0;
	for(int i = 0 ; i < l ; ++i) sum += dist[i];
	return (sum/(double)l);
}


double pairDist(pair<int, int> p1, pair<int, int> p2){
	return sqrt( ((p1.first-p2.first)*(p1.first-p2.first)) + ((p1.second-p2.second)*(p1.second-p2.second)));
}



double pathDistance(){
	double ans = 0;
	for(int i = 0 ; i < n-1 ; ++i) ans += pairDist(town[i], town[i+1]);
	return ans;
}

int main(){
	//freopen ("i.in","r",stdin);
	//freopen ("no.out","w",stdout);

	scanf("%d", &n);
	for(int i = 0 ; i < n ; ++i) scanf("%d%d", &x, &y), town[i] = {x, y};
	l = fact(n);
	dist[0] = pathDistance();
	for(int i = 1 ; i < l ; ++i){
		next_permutation(town, town+n);
		dist[i] = pathDistance();
	}

	printf("%.10lf\n", avg());

	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define M1 1000000007
#define M2 998244353
#define ll long long int
#define N (int)1e5+3
#define test(t) while(t--)
#define PI acos(-1.0)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mii map<int,int>
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repp(i,b,a) for(ll i=b-1;i>=a;i--)
#define clr(ar, val) memset(ar, val, sizeof(ar))
#define F first
#define S second
#define PB push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define V(a) vector<a>
#define M(a,b) map<a,b>
#define endl '\n'
#define all(x) begin(x),end(x)
#define allr(x) rbegin(x),rend(x)
#define pr(a) cout<<a<<endl;
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int dx[4] = { 0, -1, 0, 1 };
const int dy[4] = { -1, 0, 1, 0 };
using namespace std;

ll CalculateMex(set<ll> Set){
    ll Mex = 0;
    while(Set.find(Mex)!=Set.end()){
        Mex++;
    }
    return Mex;
}

inline void INP()
{
	#ifndef ONLINE_JUDGE
	    freopen("input.txt","r",stdin);   
	    freopen("output.txt","w",stdout);
	#endif 
}
ll floor_div(ll a, ll b) {
	return a / b - (((a ^ b) < 0) and a % b);
}
ll ceil_div(ll a, ll b){
    return a / b + (((a ^ b) >= 0) and a % b);
}
ll a[200004];
ll n,k;
bool check(ll prod){
    ll ct = 0;
    rep(i,0,n){
        if (a[i] == 0){
            if (prod >= 0) ct += (n-1);
            // if (prod == -6) cout << ct << endl;
        }
        else if (a[i] > 0){
            ll tmp = floor_div(prod,a[i]);
            ll b = ub(a,a+n,tmp) - a;
            if (i< b) ct += b-1;
            else ct += b;
            // if (prod == -6) cout <<  tmp << " " << ct << endl;
        }
        else{
            ll tmp = ceil_div(prod,a[i]);
            ll b = lb(a,a+n,tmp) - a;
            if (i >= b) ct += (n-b-1);
            else ct += n-b;
            // if (prod == -6) cout <<  tmp << " " << ct << endl;
        }
    }
    // cout << prod << " " <<  ct << "!" << endl;
    ct/=2;
    return (ct>=k);
}

void solve()
{
    
    cin>>n>>k;
    
    rep(i,0,n) cin >> a[i];
    sort(a,a+n);
    ll low = -1e18;
    ll high = 1e18;
    ll ans;
    while(low<=high){
        ll mid = (low+high)/2;
        // cout << mid << endl;
        if(check(mid)){
            ans = mid;
            high = mid-1;
        }
        else low = mid+1;
    }
    cout << ans << endl;
    
}

int32_t main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    // cin>>t;
    test(t){
        solve();
    }
    return 0;
}

Measured memory_bytes: 1920
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF (1e9+1)
//#define INF (1LL<<59)

#define int ll

signed main(){
	ll x;
	cin>>x;
	
	int ans = x/11;
	ans*=2;
	if(x%11==0){
		ans+=0;
	}else if(x%11<=6){
		ans+=1;
	}else{
		ans+=2;
	}
	
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
	int n;
	cin >> n;
	int bfrinfo[4][3][10];
	for (int i = 0; i < 4; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			for (int k = 0; k < 10; k++)
			{
				bfrinfo[i][j][k] = 0;
			}
		}
	}
	int b, f, r, v;
	for (int i = 0; i < n; i++)
	{
		cin >> b >> f >> r >> v;
		bfrinfo[b-1][f-1][r-1] += v;
	}
	for (int i = 0; i < 4; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			for (int k = 0; k < 10; k++)
			{
				cout << " " << bfrinfo[i][j][k];
			}
			cout << endl;
		}
		if (i != 3)
		{
			cout << "####################" << endl;
		}
	}

    return 0;
}


Measured memory_bytes: 3100
MINUS_INF = "-"
MATCHES = [-1, 2, 5, 5, 4, 5, 6, 3, 7, 6]

def char_max(a, b):
    if a == MINUS_INF:
        return b
    la, lb = len(a), len(b)
    if la < lb:
        return b
    elif la == lb and a < b:
        return b
    return a


N, M = map(int, input().split())
A = input().split()

dp = [MINUS_INF]*(10**4+10)
dp[0] = ""
for i in range(N+1):
    if dp[i] == MINUS_INF:
        continue
    for a in A:
        # 配るdp?
        dp[i+MATCHES[int(a)]] = char_max(
            dp[i+MATCHES[int(a)]],
            dp[i] + a
        )

print(dp[N])

Measured memory_bytes: 30196
// ALDS1_4_A.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include<vector>
using namespace std;
int main()
{
	int n;
	cin >> n;
	vector<int>S(n+1);// 探すkeyをS.at(n)に入れておく方法、番兵を使った線形探索
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &S.at(i));
		//scanf_s("%d", &S.at(i));
	}
	int q;
	cin >> q;
	vector<int>T(n);
	int ans = 0;
	for (int j = 0; j < q; j++)
	{
		scanf("%d", &T.at(j));
		//scanf_s("%d", &T.at(j));
	// LinearSearch
		S.at(n) = T.at(j);
		int i = 0;
		while (S.at(i) != S.at(n)) {
			i++;
		}
		if (i!=n)
		{
			ans++;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3152
def add(bit, a, w)
	x = a
	while x <= N do
			bit[x] += w.to_i
		x += x & -x
	end 
end

def sum(bit, a)
	ret = 0
	x = a;
	while x > 0 do
		ret += bit[x]
		x -= x & -x
	end
	return ret
end

N = gets.chomp.to_i
arys = gets.split(" ")
bit1 = Array.new(N*2+10, 0)
bit2 = Array.new(N*2+10, 0)
for i in 1..N do
	add(bit1, i, arys[i-1].to_i)
	add(bit2, i, arys[i-1].to_i)
end

ans1 = 0
op = 1
for i in 1..N do
	ss = sum(bit1,i)
	if op == 1 && ss <= 0
		d = 1 - ss
		add(bit1, i, d)
		ans1 += d
	end
	if op == -1 && ss >= 0
		d = ss + 1
		add(bit1, i, -d)
		ans1 += d
	end
	op *= -1
end
ans2 = 0
op = -1
for i in 1..N do
	ss = sum(bit2,i)
	if op == 1 && ss <= 0
		d = 1 - ss
		add(bit2, i, d)
		ans2 += d
	end
	if op == -1 && ss >= 0
		d = ss + 1
		add(bit2, i, -d)
		ans2 += d
	end
	op *= -1
end

print(ans1 < ans2 ? ans1 : ans2, "\n")


Measured memory_bytes: 10892
#include <bitset>
#include <cstddef>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

template <typename T> void print_vec(const vector<T> &v) {
  for (auto i : v)
    cout << i << " ";
  cout << endl;
}

int main() {
  string s;
  int tx, ty;
  cin >> s;
  cin >> tx >> ty;
  constexpr int cor = 10000;
  bitset<20000> x, y;
  x[cor] = 1;
  y[cor] = 1;
  int i = 0;
  int count = 0;
  int n = s.length();
  bool is_x = true;
  while (i < n && s[i] == 'F') {
    i++;
    count++;
  }
  x = x << count;
  while (i < n) {
    int count = 0;
    while (i < n && s[i] == 'F') {
      i++;
      count++;
    }
    if (is_x) {
      x = x << count | x >> count;
    } else {
      y = y << count | y >> count;
    }

    if (i < n && s[i] == 'T') {
      i++;
      is_x = !is_x;
    }
  }
  cout << (x[cor + tx] && y[cor + ty] ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			String str = scan.next();
			if(str.equals("#")){
				break;
			}
			char city = 'A';
			for(int i = 0;i < str.length() && city != 'M';i++){
				city = ans(city,str.charAt(i));
			}
			System.out.println((city == 'B')?"Yes":"No");
		}
	}
	
	public static char ans(char city,char road){
		switch(city){
		case 'A':
			return (road=='0')?'X':'Y';
		case 'X':
			return (road=='0')?'M':'Z';
		case 'Y':
			return (road=='0')?'X':'M';
		case 'W':
			return (road=='0')?'B':'Y';
		case 'Z':
			return (road=='0')?'W':'B';
		case 'B':
			return (road=='0')?'Y':'X';
		}
		return city;
	}
}

Measured memory_bytes: 17164