akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

#define ff first
#define ss second
#define pb push_back
#define sz size()
#define mp make_pair
#ifndef ONLINE_JUDGE 
#include "/home/asif/Codes/Library/debug.h"
#endif
/*--------------------------------------------------------------------*/

const int N = 1e5 + 5;
const int MOD = 1e9 + 7;

int main() {

  string s;
  cin >> s;
  if(s.back() == '3') cout << "bon" << endl;
  else if(s.back() == '0' or s.back() == '1' or s.back() == '6' or s.back() == '8') cout << "pon" << endl;
  else cout << "hon" << endl;

  return 0;
}

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

int h, w;
char path[1001][1001];
long long  memo[1001][1001];
long long numberofpath(int i, int j)
{
	long long answer = 0; 
	if (i < 0 || j < 0 || i == h || j == w) return 0;
	else if (i == h-1 && j == w-1) return 1;
	else if (path[i][j] == '#') return 0; 
	else
	{
		if (memo[i][j] != -1) return memo[i][j];
		else
		{
			answer = (answer +  numberofpath(i + 1, j )) % (long long)(1e9+7);
			answer = (answer + numberofpath(i, j+1)) % (long long)(1e9 + 7);
		}
	}

	return memo[i][j] = answer;
}


int main()
{
	memset(memo,-1, sizeof memo);
	cin >> h >> w; 
	for (int i = 0; i < h; i += 1)
		for (int j = 0; j < w; j++)
			cin >> path[i][j];

	cout << numberofpath(0,0) << endl;
	cout << endl;

	system("pause");
}


Measured memory_bytes: 9336
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
if sum(A) < sum(B):
    print(-1)
    exit()
d = [A[i]-B[i] for i in range(N)]
d.sort()
neg = 0
count = 0
for e in d:
    if e < 0:
        neg += e
        count += 1
        continue
    break
for e in d[::-1]:
    if neg >= 0:
        break
    neg += e 
    count += 1
print(count)

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

using i64 = int64_t;

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> v;
    for(int i=0;i<m;++i){
        int x;
        cin >> x;
        v.push_back(x);
    }
    sort(v.begin(), v.end());
    vector<int> diffs;
    for(int i=0;i<m-1;++i){
        diffs.push_back(v[i+1]-v[i]);
    }
    sort(diffs.begin(), diffs.end());
    int ans = 0;
    for(int i=0;i<m-n;++i)ans += diffs[i];
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
using lint = long long;
template<typename T = lint>inline T in() { T x; cin >> x; return x; }
#define INF           1e9
#define INFL          static_cast<lint>(INF)
#define REP(i,n)      for(lint i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)     for(lint i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)     for(lint i=n-1;i>=0;--i)
#define REPR1(i,n)    for(lint i=n;i>0;--i)
#define REPI(i,ini,n) for(lint i=(ini),i##_len=(n);i<i##_len;++i)
#define REPC(i,obj)   for(auto i:obj)
#define R_UP(a,b)     (((a)+(b)-1)/(b))
#define ALL(obj)      (obj).begin(),(obj).end()

int main()
{
	int n = in();
	vector<int>a(n);
	REPC(&i, a)i = in();
	int q = in();
	REP(i, q)
	{
		int k = in();
		cout << (binary_search(a.begin(), a.end(), k) ? 1 : 0) << endl;
	}
}


Measured memory_bytes: 3096
package main

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

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	t, _ := strconv.Atoi(sc.Text())
	return t
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	H := nextInt(sc)
	N := nextInt(sc)
	M := make(map[int]int, 0)
	for i := 0; i < N; i++ {
		a := nextInt(sc)
		b := nextInt(sc)
		if M[a] == 0 {
			M[a] = b
		} else {
			M[a] = min(M[a], b)
		}
	}
	dp := make([]int, 2*int(1e4)+10)
	for i := 0; i < len(dp); i++ {
		dp[i] = int(1e9)
	}
	dp[0] = 0
	for i := 0; i < len(dp); i++ {
		for damage, cost := range M {
			if i-damage >= 0 {
				dp[i] = min(dp[i], dp[i-damage]+cost)
			}
		}
	}
	ans := int(1e9)
	for i := H; i < len(dp); i++ {
		ans = min(ans, dp[i])
	}
	fmt.Println(ans)
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}


Measured memory_bytes: 896
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(_i,_a,_n) for(int _i=_a;_i<=_n;++_i)
#define PER(_i,_a,_n) for(int _i=_n;_i>=_a;--_i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(_a) ({REP(_i,1,n) cout<<_a[_i]<<',';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head



#ifdef __APPLE__
const int N = 1e2+50;
#else
const int N = 1e6+50;
#endif


int n, a[N];
map<int,int> v;

int main() {
	scanf("%d", &n);
	REP(i,1,n) scanf("%d", a+i), ++v[a[i]];
	sort(a+1,a+1+n,greater<int>());
	int ans = 0;
	REP(i,1,n) if (v[a[i]]) {
		REP(j,0,30) { 
			int t = (1<<j)-a[i];
			if (!v.count(t)) continue;
			if (a[i]!=t&&v[t]||v[t]>=2) {
				++ans, --v[a[i]], --v[t];
				break;
			}
		}
	}
	printf("%d\n", ans);
}


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

#include <iostream>
#define pb push_back
#define sort_incr(v) sort(v.begin(),v.end());
#define sort_decr(v) {sort(v.begin(),v.end()); reverse(v.begin(),v.end());}
#define take_input(v,n) for(ll i=0,temp;i<n;i++){cin>>temp;v.pb(temp);}
#define fastio {ios_base::sync_with_stdio(false);    cin.tie(NULL);}
#define ALL(v) v.begin(),v.end()

typedef long long ll;
using namespace std; 

int main() 
{
    fastio;
    ll n,temp,su=0;
    cin>>n;
    vector<ll> v;
    int co[100004]={0};
    // take_input(v,n);
    for(int i=0;i<n;i++)
    {
        cin>>temp;
        co[temp]++;
        su=su+temp;
    }
    ll q ;
    cin>>q;
    while(q--)
    {
        ll a,b;
        cin>>a>>b;
        su=su+(b-a)*co[a];
        co[b]+=co[a];
        co[a]=0;
        
        cout<<su<<"\n";
        
    }
    
    return 0; 
} 

Measured memory_bytes: 3964
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <climits>
#define endl '\n'
#define ll long long

using namespace std;


int main(void)
{
    cin.tie(NULL); ios_base::sync_with_stdio(false);
    ll a, b, c; cin >> a >> b >> c;
    ll possible = 1 + b + a;
    ll ret = b;
    ll poison = min(possible, c);
    cout << ret + poison << endl;
  
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <functional>
#include <queue>
#include <map>
#define REP(i,n) for(int i=0;i<n;i++)

using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
const int INF = 100000000;
const double PI = 3.141592653589793;

int main(){
    char grid[2050][2050];
    int R[2050][2050];
    int L[2050][2050];
    int U[2050][2050];
    int D[2050][2050];

    int h, w;
    cin >> h >> w;

    REP(i, h){
        REP(j, w){
            cin >> grid[i][j];
        }
    }

    REP(i, h){
        int num = 0;
        for(int j = w - 1; j >= 0; j--){
            num++;
            if(grid[i][j] == '#'){
                num = 0;
            }
            R[i][j] = num;
        }
    }

    REP(i, h){
        int num = 0;
        REP(j, w){
            num++;
            if(grid[i][j] == '#'){
                num = 0;
            }
            L[i][j] = num;
        }
    }

    REP(j, w){
        int num = 0;
        for(int i = h - 1; i >= 0; i--){
            num++;
            if(grid[i][j] == '#'){
                num = 0;
            }
            U[i][j] = num;
        }
    }

    REP(j, w){
        int num = 0;
        REP(i, h){
            num++;
            if(grid[i][j] == '#'){
                num = 0;
            }
            D[i][j] = num;
        }
    }

    int ans = 0;
    REP(i, h){
        REP(j, w){
            ans = max(ans, R[i][j] + L[i][j] + U[i][j] + D[i][j] - 3);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 69888
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int N = in.nextInt();
            int K = in.nextInt();
            int[] h = in.nextIntArray(N);

            long[] cost = new long[N];
            Arrays.fill(cost, Long.MAX_VALUE);
            cost[0] = 0;
            for (int i = 0; i < N - 1; i++) {
                for (int j = 1; j <= K; j++) {
                    if (i + j >= N) break;
                    cost[i + j] = Math.min(cost[i + j], cost[i] + Math.abs(h[i] - h[i + j]));
                }
            }
            out.println(cost[N - 1]);
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = nextInt();
            }
            return a;
        }

    }
}



Measured memory_bytes: 35212
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

const int N = (int)3e5;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  ret *= kaijo(n); ret %= MOD;
  ret *= gyaku_kaijo(r); ret %= MOD;
  ret *= gyaku_kaijo(n-r); ret %= MOD;
  return ret;
}


int main(void){
  int n,m;
  cin>>n>>m;
  vector<ll> A,B,C;
  rep(i,m){
    ll a,b;cin>>a>>b;
    A.push_back(a);
    ll c = 0;
    rep(j,b){
      ll inp;
      cin>>inp;
      inp--;
      c |= 1<<inp;
    }
    C.push_back(c);
  }
  vector<vector<ll>> dp;
  rep(i,m+2){
    dp.push_back(vector<ll>());
    rep(j,1<<12){
      dp[i].push_back(LINF);
    }
  }
  dp[0][0] = 0;
  rep(i,m){
    rep(j,1<<12){
      dp[i+1][j] = dp[i][j];
    }
    rep(j,1<<12){
      chmin(dp[i+1][j|C[i]], dp[i][j] + A[i]);
    }
  }
  if(dp[m][(1<<n)-1] == LINF){
    cout<<-1<<endl;
    return 0;
  }
  cout<<dp[m][(1<<n)-1]<<endl;
  return 0;
}


Measured memory_bytes: 32384
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;



int main(void){
    int n;
    string s;
    cin>>n;
    cin>>s;
    int ans=0;
    for(int i=0;i<n-2;){
        if(s[i]=='A'){
            if(s[i+1]=='B'){
                if(s[i+2]=='C'){
                    ans++;
                    i+=3;
                }
                else i++;
            }
            else i++;
        }
        else i++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;
using ll = long long;
using ii = pair<int, int>;
constexpr int MN = 2002;

int N, ans = 1e9;

void solve(string A, string B) {
	vector<int> v(1);
	for (int i = 0; i < N; ++i)
		if (B[i] == '1') v.push_back(i);
	v[0] = v.back()-N, v.push_back(v[1]+N);
	ii P[MN];
	for (int i = 0; i < N; ++i) {
		auto it = lower_bound(begin(v), end(v), i);
		P[i] = ii(*prev(it), *it);
	}

	for (int i = 0; i < N; ++i) {
		int cnt = 0;
		for (int j = 0; j < N; ++j)
			if (A[j] != B[j]) ++cnt;
		vector<ii> s;
		for (int j = 0; j < N; ++j)
			if (A[j] == '1' && B[j] == '0')
				s.emplace_back(j-P[j].f, P[j].s-j);
		sort(begin(s), end(s)),	reverse(begin(s), end(s));
		s.emplace_back(0, 0);

		if (s.size()) {
			int l = s[0].f, r = 0;
			for (int j = 0; j < s.size(); ++j) {
				ans = min(2*max(l-i, 0)+i+2*r+cnt, ans);
				if (j == s.size()-1) break;
				l = s[j+1].f;
				r = max(s[j].s, r);
			}
		}
		else {
			ans = min(cnt, ans);
		}
		rotate(begin(A), begin(A)+N-1, end(A));
	}
}

int main() {
	if (fopen("in", "r")) freopen("in", "r", stdin), freopen("out", "w", stdout);
	ios_base::sync_with_stdio(0), cin.tie(0);

	string A, B; cin >> A >> B;
	N = A.size();
	if (B == string(N, '0')) {
		cout << (A == string(N, '0') ? 0 : -1);
		return 0;
	}
	solve(A, B);
	reverse(begin(A), end(A)), reverse(begin(B), end(B));
	solve(A, B);
	cout << ans;
}


Measured memory_bytes: 3664
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using static System.Math;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var a = int.Parse(ReadLine());
        var count = 0;
        for (int i = 1; i <= a; i++)
        {
            for (int j = i + 1; j <= a; j += 2)
            {
                count++;
            }
        }
        WriteLine(count);
    }
}

Measured memory_bytes: 11092
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
	    String S = sc.next();
	    
	    String[] weathers = {"Sunny", "Cloudy", "Rainy"};
	    
	    for (int i = 0; i < weathers.length; i++) {
	    	if (S.equals("Rainy")) {
	    		System.out.println("Sunny");
	    		break;
	    	} else if (S.equals(weathers[i])) {
	    		System.out.println(weathers[i + 1]);
	    	}
	    }
	}	
}	

Measured memory_bytes: 22740
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    int n;
    cin>>n;
    vector<string> s;
    string cnt;
    for(int i=0;i<n;i++)
    {
        cin>>cnt;
        s.push_back(cnt);
    }
    sort(s.begin(),s.end());
    int kind=0;
    for(int k=0;k<n-1;k++){
        if(s[k]!=s[k+1]){kind++;}
    }
    cout<<kind+1;
}

Measured memory_bytes: 11656
def gcd(a,b):
    if b:
        return gcd(b,a%b)
    else:
        return a    

n,m=map(int,input().split())
s=input()
t=input()
c=0
g=gcd(n,m)
x=n*m//(gcd(n,m))
for k in range(g):
    if s[int(k*n/g)]==t[int(k*m/g)]:
        continue
    else:
        c=-1
        break
       
if c==-1:
    print(c)            
                        
else:
    print(x)
    

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
int main(){
  string a,b;
  cin>>a>>b;
  if(a.size()>b.size())
    cout<<"GREATER"<<endl;
  else if(a.size()<b.size())
    cout<<"LESS"<<endl;
  else if(a==b)
    cout<<"EQUAL"<<endl;
  else{
    for(int i=0;i<a.size();i++){
      if(a.at(i)>b.at(i)){
        cout<<"GREATER"<<endl;
        break;
      }
      else if(a.at(i)<b.at(i)){
        cout<<"LESS"<<endl;
        break;
      }
    }
  }
}

Measured memory_bytes: 3600
#include <stdio.h>
int main()
{
  int i=0, l,  p, q, j=0;
  int d[50];

  while(1)
    {
      for ( i = 0; i < 50; i++)
	{
	  d[i] = 0;
	}   
      scanf("%d %d", &l, &p);
      if( l == 0 && p == 0 ) break;
      q = p;
      while(1)
	{
     	  if ( i >= l ) i = 0;
	  if ( p > 0 )
	    {
	      d[i] += 1;
	      p--;
	      if ( d[i] == q && p == 0)
		{
		  break;
		}  
	    }
	  else if ( p == 0 )
	    {
	      p = d[i];
	      d[i] = 0;
	    }
	  i++;
	}
      printf("%d\n", i);
    }
  return 0;
}

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

int main()
{
	int n;
	while(cin >> n)
	{
		int maxn = 0;
		for(int i = 1;i<=sqrt(n);i++)
		{
			if(i * i >= maxn)
				maxn = i * i;
			else
			{
				break;
			}
		}
		cout<<maxn<<endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<complex>
#include<vector>
#include<algorithm>
#include<functional>
#include<array>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;


int main() {
	int x, a=0,b;
	cin >> x;
	for (int i = 32;i > 0;i--)
		for (int j = 2;j < 10;j++) {
			b = pow(i, j);
			if (b <= x && b > a) a = b;
		}

	cout << a << endl;

	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
    int w[] = {1, 5, 10, 50, 100, 500};
    int sum = 0;
 
    for (int i = 0; i < 6; i++){
        int x;
        scanf("%d", &x);
        sum += x * w[i];
    }
 
    printf("%d\n", sum >= 1000);
 
    return (0);
}

Measured memory_bytes: 1188
n=int(input())
a=list(map(int,input().split()))
m=max(a)
l=[0for i in range(m+1)]
for i in range(n):
 for j in range(a[i], m + 1, a[i]):l[j] += 1
c=0
for i in range(n):
 if l[a[i]] == 1:c += 1
print(c)

Measured memory_bytes: 32352
if __name__ == '__main__':
    n = int(input())
    k = [int(i) for i in input().split()]
    a = 0
    b = 0
    k.sort(reverse=True)
    flag = True
    for i in k:
        if flag == True:
            a+=i
            flag=False
        else:
            b+=i
            flag=True
    print(a-b)


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
using namespace std;

int main()
{
    vector<long long> move(5);
    long long n, mic = 1000000000000000000, cnt = 0;
    cin >> n;
    for(int i = 0;i < 5;i++){
        cin >> move[i];
        mic = min(move[i], mic);
    }

    cnt = n / mic;
    if(n % mic == 0) cnt--;
    

    cout << cnt + 5;

    return 0;
}

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

int main() {
    int x, y, z;
    cin >> x >> y >> z;
    swap(x, y);
    swap(x, z);
    cout << x << " "<< y << " "<< z;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
struct Point {
	long long a, b;
	bool operator<(const Point &x) const {
		return x.a * (b + 1) < a * (x.b + 1);
	}
};
vector<Point> A;
vector<long long> B;
long long Dp[111], T;
int N;
int main() {
	int i, j, k;
	scanf("%d%lld", &N, &T);
	for (i = 1; i <= N; ++i) {
		int a, b;
		scanf("%d%d", &a, &b);
		if (!a) B.push_back(b + 1);
		else A.push_back({a, b});
	}
	N = min( (int) A.size(), 40);
	if (A.size()) sort(A.begin(), A.end());
	for (i = 0; i <= 100; ++i) Dp[i] = T + 1;
	Dp[0] = 0;
	for (Point u : A) {
		for (i = 40; i >= 0; --i) {
			Dp[i + 1] = min(Dp[i + 1], Dp[i] + (Dp[i] + 1) * u.a + u.b + 1);
		}
	}
	B.push_back((long long) 1e15);
	sort(B.begin(), B.end());
	for (i = 1; i < (int) B.size(); ++i) B[i] += B[i - 1];
	int Res = 0;
	for (i = 0; i <= 40; ++i) if (Dp[i] <= T) {
		int it = lower_bound(B.begin(), B.end(), T - Dp[i] + 1) - B.begin();
		Res = max(Res, it + i);
	}
	printf("%d\n", Res);
}


Measured memory_bytes: 6384
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rep1(i,n) for(int i=1;i<=int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define foreach(i,n) for(auto &&i:n)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define GSORT(x) sort(all(x), greater<int>())
#define REV(x) reverse(all(x))
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
#define LOWitr(x, n) lower_bound(all(x), n)
#define UPRitr(x, n) upper_bound(all(x), n)
#define cii(x) int x;cin >> x
#define cill(x) LL x;cin >> x
#define cis(x) string x;cin >> x
#define co(x) cout << x << endl
#define dump(x)  cout << #x << " = " << (x) << endl
#define truecheck assert
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef long long int64;
template<class T,class U>bool chmax(T &a, const U &b) { if (a<b) { a=b; return true; } return false; }
template<class T,class U>bool chmin(T &a, const U &b) { if (b<a) { a=b; return true; } return false; }
const int INF = 1e9, MOD = 1e9 + 7;
const LL LLINF = 1e16;

int main() {
    fastcin();
    cout << fixed << setprecision(10);
    cii(n);
    cii(m);
    VI vi(n, -1);
    auto ans = 0;
    rep(i, m){
        cii(s);
        cii(c);
        if (vi[s-1]==-1){
            vi[s-1] = c;
        }else{
            if (vi[s-1]!=c)
                ans = -1;
        }
    }
    if (ans!=-1){
        string str;
        rep(i, n){
            if(vi[i]==-1){
                str+="x";
            }else{
                str+=to_string(vi[i]);
            }
        }
        bool numbered=false;
        rep(i, n){
            if (str[i] == '0' && !(numbered)){
                if (n == 1){
                    str[i] = '0';
                }else{
                    str="-1";
                    break;
                }
            }else if (str[i] == 'x' && !(numbered)){
                if (n == 1){
                    str[i] = '0';
                }else{
                    str[i] = '1';
                }
                numbered = true;
            }else if (str[i] == 'x' && numbered){
                str[i] = '0';
            }else{
                numbered = true;
            }
        }
        ans = stoi(str);
    }
    co(ans);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int s,w;
  cin>>s>>w;
  if(w>=s)
  {
    cout<<"unsafe"<<endl;
  }
  else
  {
    cout<<"safe"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3624
macro_rules! get {
      ($t:ty) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.trim().parse::<$t>().unwrap()
          }
      };
      ($($t:ty),*) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              let mut iter = line.split_whitespace();
              (
                  $(iter.next().unwrap().parse::<$t>().unwrap(),)*
              )
          }
      };
      ($t:ty; $n:expr) => {
          (0..$n).map(|_|
              get!($t)
          ).collect::<Vec<_>>()
      };
      ($($t:ty),*; $n:expr) => {
          (0..$n).map(|_|
              get!($($t),*)
          ).collect::<Vec<_>>()
      };
      ($t:ty ;;) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.split_whitespace()
                  .map(|t| t.parse::<$t>().unwrap())
                  .collect::<Vec<_>>()
          }
      };
      ($t:ty ;; $n:expr) => {
          (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
      };
}

use std::cmp;

fn main() {
    // 入力
    let (A, B, C) = get!(usize, usize, usize);

    let ans = cmp::min(B / A, C);

    // 出力
    println!("{}", ans);
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for (int i = a; i < (int)b; ++i)
#define rrep(i, n) for (int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	string s, t;
	cin >> s >> t;
	int res = Inf;
	rep (i, s.size() - t.size() + 1) {
	  int tmp = 0;
	  rep (j, t.size()) if (s[i + j] != t[j]) tmp++;
	  res = min(res, tmp);
	}
	cout << res << endl;

	return 0;
}


Measured memory_bytes: 3668
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, K = il()

    ret = 1
    for n in range(N):
        ret *= K
        if n == 0:
            K -= 1

    print(ret)



if __name__ == '__main__':
    main()


Measured memory_bytes: 10184
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n;
	cin >> n;
	int a[n];
	for(int i=0;i<n;i++) cin >> a[i];
	int mina=1001,maxa=-1;
	for(int i=0;i<n;i++){
		mina=min(mina,a[i]);
		maxa=max(maxa,a[i]);
	}
	cout << maxa-mina << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define brep(i,n) for(int i=n-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<n;i++)
#define cY cout<<"Yes"<<endl
#define cN cout<<"No"<<endl

int main(void){
    string a;
    string b;
    cin >> a >>b;
    int n = a.size();
    int check[26];
    rep(i,26)check[i] = -1;
    rep(i,n){
        if(check[b[i]-'a'] >= 0){
            if(a[check[b[i]-'a']] != a[i]){
                cN; 
                return 0;
            }
        }
        else check[b[i]-'a'] = i;
    }
    rep(i,26)check[i] = -1;
    rep(i,n){
        if(check[a[i]-'a'] >= 0){
            if(b[check[a[i]-'a']] != b[i]){
                cN; 
                return 0;
            }
        }
        else check[a[i]-'a'] = i;
    }
    cY;
    return 0;
}


Measured memory_bytes: 776
import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Clock{
	int h,m,s;
	void doit(int t){
		int tmp = t;
		s = tmp % 60;
		tmp /= 60;
		m = tmp % 60;
		tmp /= 60;
		h = tmp;
		System.out.println(h + ":" + m + ":" + s);
	}
}

class Main{
	public static void main (String[] args) throws java.lang.Exception{
		Scanner scan = new Scanner(System.in);
		int t = Integer.parseInt(scan.next());
		Clock c = new Clock();
		c.doit(t);
	}
}

Measured memory_bytes: 17320
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <fstream>
#include <set>
#include <utility>
#include <algorithm>

#define rep(i,p,n) for(int i=p;i<n;i++)
#define lli long long int
#define vi vector<int> 

using namespace std;

void p(int x) {
	cout << x << endl;
}

void pp(string s) {
	cout << s << endl;
}

int main() {
	int n, m;
	cin >> n >> m;
	vector<string> v(n);
	rep(i, 0, n) cin >> v[i];

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

	rep(i, 0, n)cout << v[i];
	cout << endl;

	return 0;
}

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

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

    int cnt = 1;
    int tmp;
    while(n >= k){
        tmp = n%k;
        cnt ++;
        n /= k;
    }
cout << cnt << endl;
}

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

int main() {
	int height[10];
	for (int i = 0; i < 10; i++)
		cin >> height[i];
	sort(height, height + 10);
	for (int i = 0; i < 3; i++)
		cout << height[9 - i] << endl;
}


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

int main(void) {
  int N, M, X;
  cin >> N >> M >> X;
  vector<int> C(N);
  vector<vector<int>> A(N, vector<int>(M));
  for (int i = 0; i < N; i++) {
    cin >> C[i];
    for (int j = 0; j < M; j++) {
      cin >> A[i][j];
    }
  }
  int ans = 10000000;
  for (int i = 0; i < (1 << N); i++) {
    vector<int> understanding(M, 0);
    int value = 0;
    for (int j = 0; j < N; j++) {
      if (i & (1 << j)) {
        value += C[j];
        for (int k = 0; k < M; k++) {
          understanding[k] += A[j][k];
        }
      }
    }

    bool ok = true;
    for (int j = 0; j < M; j++) {
      if (understanding[j] < X) {
        ok = false;
        break;
      }
    }
    if (ok) {
      ans = min(value, ans);
    }
  }
  cout << (ans == 10000000 ? -1 : ans) << endl;
  return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define f(a, b) for (ll i = a; i <= b; i++)
#define pb push_back
#define pf push_front
#define mp make_pair
using namespace std;
#define N 200005
const ll INF = 1000000000000000001;
const ll MOD = 1000000007;

//vector< vector<ll> > g(N);
//vector< pair<ll, pair< ll, ll > > > g(N);
//ll vis[N] = {0}, par[N] = {0}, child[N] = {0},cnt = 0;


void solve(){
    ll n; cin >> n;
    cout << (n^(ll)1) << "\n";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("out.txt","w",stdout);
    #endif
   //ll t;cin >> t;for(ll index=1; index<=t; index++){
        //cout << "Case #" << index << ": " ;
        solve();
   // }
    return 0;
}

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

int main() {
 int N,M,S;
 cin >> N >> M ;
 S=0;
 vector <int> vec(M*2) ;
  for (int k=0; k<M*2; k++) {
       cin >> vec.at(k) ;
      // cout <<vec.at(k) ;
  }
  //cout <<endl;
   for (int j=0;j<N;j++){
   for (int i=0 ; i<M*2 ; i++){
     if(vec.at(i)==j+1)
       S+=1 ;
   }
   cout << S << endl;
   S=0;
  }
 
}
  
      
  
  
 

Measured memory_bytes: 256
use std::vec::Vec;

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 (n, k): (i64, i64) = {
      let v: Vec<i64> = read_vec();
      (v[0], v[1])
    };

    println!("{}", n - k + 1);
}


Measured memory_bytes: 4352
//
/*==========================================================*/
/*    Template ver 2017-0720    |    Created by JollyBee    */
/* DOMINUS pascit me, et nihil mihi deerit (Psalmorum 23:1) */
/*==========================================================*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
const double EPS=(double)1e-9;
const double PI=(double)acos(-1.0);
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define FOR(i,n) for(int i=0;i<n;i++)
#define REPP(i,l,r,c) for(int i=l;i<=r;i+=c)
#define REP(i,l,r) REPP(i,l,r,1)
#define FORD(i,n) for(int i=n-1;i>=0;i--)
#define REVV(i,l,r,c) for(int i=l;i>=r;i-=c)
#define REV(i,l,r) REVV(i,l,r,1)
//random
int irand(int lo, int hi){
    return (((double)rand())/(RAND_MAX+1.0)) * (hi-lo+1) + lo;
}
//ll to string
string toString(ll x) {
    stringstream ss;
    ss << x;
    return ss.str();
}
//string to ll
ll toNumber(string S) {
    ll ret;
    sscanf(S.c_str(),"%lld",&ret);
    return ret;
}
// std::fill(start, end, value);
// for(auto it: DS){}

const int INF=(int)2e9;
const ll MOD=(ll)1e9+7;
/*==========================================================*/
/*                     END OF TEMPLATE                      */
/* DOMINUS pascit me, et nihil mihi deerit (Psalmorum 23:1) */
/*==========================================================*/

set<string> dat;

int main(){
    int n; cin >> n;
    string s_prev="", s_now;
    int res = 1;
    REP(i,1,n){
    	cin >> s_now;
    	if(s_prev != ""){
    		res &= (s_prev.back() == s_now.front());
    	}
    	dat.insert(s_prev = s_now);
    }
    res &= ((int)dat.size() == n);
    //print
    puts(res ? "Yes" : "No");
    return 0;
}

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

using ll=long long; 

bool hantei(vector<int> a, vector<int> b){
	int norm=0;
	for(int i=0; i<a.size(); i++){
		norm+=(a[i]-b[i])*(a[i]-b[i]);
	}
	double sq=sqrt(norm);
	if(sq-int(sq)>0.0){
		return false;
	}
	return true;
}


void solve(){
	int n,d;
	cin>>n>>d;
	vector<vector<int>> a(n, vector<int>(d));
	for(int i=0; i<n; i++){
		for(int j=0; j<d; j++){
			cin>>a[i][j];
		}
	}
	int cnt=0;
	for(int i=0; i<n-1; i++){
		for(int j=i+1; j<n; j++){
			if(hantei(a[i], a[j])){
				cnt++;
			}
		}
	}
	cout<<cnt<<endl;
}

signed main(){
	//while(1)
	solve();
}

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

int main(void){
  int n, m;
  cin >> n >> m;
  bool f[n + 1], g[n + 1];
  for(int i = 0; i <= n; i++){
      f[i] = false;
      g[i] = false;
  }
  for(int i = 0; i < m; i++){
    int a, b;
    cin >> a >> b;
    if(a == 1) f[b] = true;
    if(b == n) g[a] = true;
  }
  bool flag = false;
  for(int i = 2; i < n; i++){
    if(f[i]) if(g[i]) flag = true;
  }
  if(flag) cout << "POSSIBLE" << endl;
  else cout << "IMPOSSIBLE" << endl;
  return 0;
}


Measured memory_bytes: 640
const main = stdin => {
  const input = stdin.trim().split('\n')

  const S = input[0]

  if (S[0] === S[1] || S[1] === S[2] || S[2] === S[3]) {
    console.log('Bad')
  } else {
    console.log('Good');
  }

}
// 標準入力
main(require("fs").readFileSync("/dev/stdin", "utf8"))


Measured memory_bytes: 30588
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace atcorder_BeginnerContest_119
{
    class Program
    {
        static void Main(string[] args)
        {
            DateTime dt = DateTime.Parse(Console.ReadLine());
            string ret = "TBD";
            if(dt <= DateTime.Parse("2019/04/30"))ret = "Heisei";
            Console.WriteLine(ret);

        }
    }
}


Measured memory_bytes: 13536
#include <bits/stdc++.h>
using namespace std;
int n, da, dq;
char st[10000]; //瀹氫箟
int main()
{
    cin >> n; //璇诲叆鏈夊灏戜釜浣嶇疆
    for (int i = 1; i <= n; i++)
    {
        cin >> st[i];
        if (st[i] == 'I')
            dq++; //濡傛灉寰€涓婄埇锛屽綋鍓嶆捣鎷?1
        else
            dq--; //濡傛灉寰€涓嬭蛋锛屽綋鍓嶆捣鎷?1
        if (dq > da)
            da = dq; //姣忎釜浣嶇疆姣忎釜浣嶇疆閮戒笌鏈€澶у€兼瘮杈?
    }
    cout << da << endl; //杈撳嚭鏈€澶у€煎苟鎹㈣
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; inline void fileio(const char* in, const char* out) { freopen(in, "r", stdin); freopen(out, "w", stdout); } 
#define TD typedef
#define forx(i,n) for(int i = 0; i < (n); ++i)
#define forxr(i,n) for(int i = (n)-1; i >= 0; --i)
TD long long ll; TD long double ld; TD pair<int,int> pii; TD pair<ll,ll> pll; TD vector<int> VI; TD vector<bool> VB; TD vector<ll> VL;
const char nl = '\n'; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3fll; const ld EPS = 1e-9, PI = acos(-1);
#define ff first
#define ss second
#define all(c) c.begin(),c.end()

static const int N = 1e5;
static int par[N];
vector<int> group[N];
vector<int> adj[N];
bitset<N> usr;
bitset<N> grp;

int ans[N];

int find(int i) {
  if (par[i] == -1) {
    return i;
  }
  return par[i] = find(par[i]);
}
void join(int i, int j) {
  i = find(i), j = find(j);
  if (i == j) return;
  par[i] = j;
}

int main() {
  atexit([](){ cerr << "Time: " << (ld)clock() / CLOCKS_PER_SEC << nl; });
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cout << fixed << setprecision(12);
  // Emily <3
  memset(par, -1, sizeof par);
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 0; i < n; ++i) {
    adj[i].push_back(i);
  }
  while(m--) {
    int a, b; cin >> a >> b;
    a--, b--;
    join(a,b);
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  while (k--) {
    int a,b; cin >> a >> b; a--, b--;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  for (int i = 0; i < n; ++i) {
    int p = find(i);
    group[p].push_back(i);
  }
  for (int p = 0; p < n; ++p) {
    if (group[p].empty()) continue;
    grp.reset();
    for (int i : group[p]) grp[i] = 1;
    for (int i : group[p]) {
      usr.set();
      for (int v : adj[i]) usr[v] = 0;
      ans[i] = (usr & grp).count();
    }
  }
  for (int i = 0; i < n; ++i) {
    cout << ans[i] << " ";
  } cout << nl;
  return 0;
}



Measured memory_bytes: 14848
N = int(input())
a = list(map(int,(input().split())))
r = []
c = 0
for i in range(N):
    if a[i] >= 3200:
        c += 1
    else:
        r.append(a[i]//400)

nim = len(set(r))
ansm = max(1,nim)
ansM = nim + c
print(ansm,ansM)

Measured memory_bytes: 38256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int a = scan.nextInt();
		int b = scan.nextInt();
		int price = n * a;
		if(price > b) {
			price = b;
		}
		System.out.println(price);
	}
}

Measured memory_bytes: 23764
function Main(input) {
	input = input.trim().split("\n").map((a)=>Number(a));
  var A = input[0];
  var B = input[1];
  var H = input[2];
  console.log(H * (A + B) / 2);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#B

n = int(input())
S=[]

for i in range(n):
    s,p = (x for x in input().split())
    p = int(p)
    S.append((s,p, i+1))

S = sorted(S, key=lambda x: x[1], reverse=True)
S = sorted(S, key=lambda x: x[0])

for i in S:
    print(i[2])

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

int main() {
	ll a,b;
	ll num_a = 0;
	ll num_b = 0;
	cin >> a >> b;
	rep(i,b) {
		num_a *= 10;
		num_a += a;
	}
	rep(i,a) {
		num_b *= 10;
		num_b += b;
	}
	cout << max(num_a, num_b) << endl;
	return 0;
}


Measured memory_bytes: 256
import sys

def main():
    input = sys.stdin.readline
    N, Q = map(int, input().split())
    S = input()
    t = [0] * (N + 1)
    
    for i in range(N):
        t[i + 1] = t[i] + (1 if S[i:i+2] == 'AC' else 0)
    
    for i in range(Q):
        start, end = map(int, input().split())
        print(t[end - 1] - t[start - 1])
    
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 7916
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        solve();
    }

    private static void solve() {
        Scanner input = new Scanner(System.in);

        long a = Long.parseLong(input.next());
        long b = Long.parseLong(input.next());
        long c = Long.parseLong(input.next());
        long d = Long.parseLong(input.next());

        long ansA1 = (a - 1) / c;
        long ansA2 = (a - 1) / d;
        long ansA3 = (a - 1) / lcm(c, d);

        long ansB1 = b / c;
        long ansB2 = b / d;
        long ansB3 = b / lcm(c, d);

        long ansB = ansB1 + ansB2 - ansB3;
        long ansA = ansA1 + ansA2 - ansA3;

        long ans = ansB - ansA;
        long result = b - (a - 1) - ans;

        System.out.println(result);

    }

    static long lcm (long a, long b) {
    	long temp;
    	long c = a;
    	c *= b;
    	while((temp = a%b)!=0) {
    		a = b;
    		b = temp;
    	}
    	return (c/b);
    }

}


Measured memory_bytes: 23764
require 'pp'

a, b = gets.chomp!.split(" ").map(&:to_i)
ans = { 0 => 0 }
sub = []
1.upto(999).with_index(1) do |i, index|
    ans[index] = ans[index - 1] + i
    sub << ans[index] - ans[index -1]
end

puts ans[b - a] - b


Measured memory_bytes: 4092
#include<stdio.h>
#include<time.h>

unsigned long long a ,b ,c ,cnt ;


int main()
{
	scanf( "%lld %lld %lld" ,&a ,&b ,&c ) ;

	while( clock() < 1990 )
	{
		cnt++ ;
		int m = b * cnt + c ;

		if( m % a == 0 )
		{
			printf( "YES\n" ) ;
			return 0 ;
		}
	}

	printf( "NO\n" ) ;

	return 0 ;
}

Measured memory_bytes: 384
//Iron Bar Cutting

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define irep(i,a) for(auto i = a.begin(); i != a.end(); ++i)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define nxvarep(n,x,a) ll n,x;cin>>n>>x;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
#define cout15(a) printf("%.15f\n",a)
template<class T>inline bool chmin(T& a,T b,bool f){
if(f==1){if(a>b){a=b;return true;}return false;}
else if(f==0){if(a<b){a=b;return true;}return false;}return false;}
typedef pair<ll,string> p;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

int main (){
    nvarep(n,a);
    ll sum = accumulate(range(a),0LL);
    ll c=0,ans=inf;
    rep(i,0,n){
        c+=a[i];
        ans=min(ans,abs((sum-c)-c));
    }
    cout<<ans<<nnn;
    return 0;
}

Measured memory_bytes: 1792
class Main{
    public static void main(String[] a){
    	for(int i = 1 ; i <= 9 ; i++){
    		for(int j = 1 ; j <=9 ; j++){
    			System.out.println(i + "x" +j + "=" +i*j);
    		}
    	}
    }
}

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

using namespace std;

#define REP(i, n)   for(int i = 0; i < (n); i++)
#define REPS(i, n)  for(int i = 1; i <= (n); i++)
#define RREP(i, n)  for(int i = (n)-1; i >= 0; i--)
#define RREPS(i, n) for(int i = (n); i > 0; i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

using ll  = long long;
using pi  = pair<int, int>;
using pl  = pair<ll, ll>;
using vi  = vector<int>;
using vl  = vector<ll>;
using vs  = vector<string>;
using vb  = vector<bool>;
using vvi = vector<vi>;
using vvl = vector<vl>;

const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e9 + 7;
const ll  INFL = 1e18;
const double PI = 3.141592653589793;
const double EPS = 1e-9;

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

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    string s; cin >> s;
    int ans = 0;
    REP(i, (int)s.length() / 2)
    {
        string x = s.substr(0, i);
        string y = s.substr(i, i);
        if(x == y) chmax(ans, i*2);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3612
def MI():
    return map(int, input().split())

def LI():
    return list(map(int, input().split()))

ABC = LI()
ABC.sort()
ans = 0

if (ABC[1] - ABC[0]) % 2 == 0:
    ans = (ABC[1] - ABC[0]) // 2 + ABC[2] - ABC[1]
    print(ans)

else:
    ABC[0] += 1
    ABC[2] += 1
    ans = ans = (ABC[1] - ABC[0]) // 2 + ABC[2] - ABC[1] + 1
    print(ans)

Measured memory_bytes: 61988
local str = io.read()
local n = #str
local startx = 0
local curlen = 0
local curIsY = false
local xlist = {}
local ylist = {}
local isfirst = true
for i = 1, n do
  if str:sub(i, i) == "F" then
    curlen = curlen + 1
  else
    if curIsY then
      table.insert(ylist, curlen)
    else
      if isfirst then
        startx = curlen
        isfirst = false
      else
        table.insert(xlist, curlen)
      end
    end
    curIsY = not curIsY
    curlen = 0
  end
end
if isfirst then
  startx = startx + curlen
else
  if curIsY then table.insert(ylist, curlen)
  else table.insert(xlist, curlen)
  end
end
local xdst, ydst = io.read("*n", "*n")
xdst = xdst - startx
local xsum, ysum = 0, 0
for i = 1, #xlist do xdst = xdst + xlist[i] end
for i = 1, #ylist do ydst = ydst + ylist[i] end

local function check(list, dst)
  if dst == 0 then return true end
  local t = {}
  local ln = #list
  for i = 1, dst do t[i] = false end
  local curmax = 0
  for i = 1, ln do
    for j = curmax, 1, -1 do
      if t[j] then
        if (j + list[i] * 2) == dst then
          return true
        elseif (j + list[i] * 2) < dst then
          t[j + list[i] * 2] = true
        end
      end
    end
    curmax = curmax + list[i] * 2
    t[list[i] * 2] = true
    if (list[i] * 2) == dst then return true end
  end
  return false
end
print(check(xlist, xdst) and check(ylist, ydst) and "Yes" or "No")


Measured memory_bytes: 512