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

using namespace std;
typedef long long ll;

ll gcd(ll c, ll d){
	return d ? gcd(d, c % d) : c;
}

ll lcm(ll c, ll d){
	return c / gcd(c, d) * d;
}

int main() {
    int n; cin >> n;
    vector <ll> t(n);
    for(int i = 0; i < n; i++){
        cin >> t[i];
    }
    ll ans = t[0];
    if(n != 1){
        ans = lcm(t[0], t[1]);
        for(int i = 2; i < n; i++){
            ans = lcm(ans, t[i]);
        }
        cout << ans << endl;
    }else{
        cout << t[0] << endl;
    }

}

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

int n;
string s;
vector<long long> hash1,power1,hash2,power2;

int base1 = 1007, mod1 = 1000000007;
int base2 = 2007, mod2 = 1000000009;

pair<long long, long long> get(int l, int r) {
  long long res1 = (hash1[r] - hash1[l]*power1[r-l]%mod1 + mod1) % mod1;
  long long res2 = (hash2[r] - hash2[l]*power2[r-l]%mod2 + mod2) % mod2;
  return {res1, res2};
}

bool check(int len) {
  map<pair<long long, long long>, int> d;
  for(int i=0;i+len<=n;i++) {
    auto h = get(i,i+len);
    if(d.count(h)>0){
      if(i-d[h]>=len) {
        return true;
      }
    } else {
      d[h] = i;
    }
  }
  return false;
}

int main() {
  cin>>n>>s;
  hash1.assign(n+1,0);
  hash2.assign(n+1,0);
  power1.assign(n+1,1);
  power2.assign(n+1,1);

  for(int i=0;i<n;i++) {
    hash1[i+1] = (hash1[i]*base1 + s[i])%mod1;
    power1[i+1] = (power1[i]*base1)%mod1;

    hash2[i+1] = (hash2[i]*base2 + s[i])%mod2;
    power2[i+1] = (power2[i]*base2)%mod2;
  }

  int ok = 0;
  int ng = n/2+1;
  while(ng-ok > 1) {
    int d = (ok+ng)>>1;
    if(check(d)){
      ok = d;
    } else {
      ng = d;
    }
  }

  cout<<ok<<endl;
}


Measured memory_bytes: 768
#include <stdio.h>

int main (void){
  int H,W,h,w;

  while(1){
    scanf("%d %d",&H,&W);
    if(H == 0 && W == 0){
      break;
    }

    for(h=0; h<H; h++){
      for(w=0; w<W; w++){
        printf("#");
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}


Measured memory_bytes: 2064
N = int(input())
 
testimony = [[] for _ in range(N)]
 
for i in range(N):
    num = int(input())
    for j in range(num):
        person, state = map(int, input().split())
        testimony[i].append([person-1, state])
        
honest = 0
for i in range(2**N):
    flag = 0
    for j in range(N):
        if (i>>j)&1 == 1: # j番目は正直と仮定
            for x,y in testimony[j]:
                if (i>>x)&1 != y: # j番目は正直だが矛盾を発見
                    flag = 1
                    break
    if flag == 0:  # 矛盾がある場合はflag == 1になる
        honest = max(honest, bin(i)[2:].count('1'))  # 1の数をカウントし最大となるものを選択
print(honest)

Measured memory_bytes: 9148
#include <stdio.h>
#include <math.h>

int main(void){
	int t,i,n,p,q,a,j,l;
	
	scanf("%d",&n);
	for(t=0;t<n;t++){
		p=0;
		q=0;
		j=0;
		for(i=0;i<10;i++){
			scanf("%d",&a);
			if(p<a){
				p=a;
			}
			else if(q<a){
				q=a;
			}
			else{
				j=1;
			}
			if(p<q){
				l=p;p=q;q=l;
			}
		}
		if(j==0){
			printf("YES\n");
		}
		if(j==1){
			printf("NO\n");
		}
			
			
		}
	
	return 0;

}

Measured memory_bytes: 580
N = int(input())
lp = []

for i in range(N):
    p = list(map(int,input().split()))
    lp.append(p)

lp.sort(key=lambda x : x[2], reverse=True)


def check(cx,cy, lp):
    is_center = True
    ch = lp[0][2] + abs(cx - lp[0][0]) + abs(cy - lp[0][1])
    for p in lp[1:]:
        x,y,h = p
        if h:
            chp = h + abs(cx - x) + abs(cy - y)
            if ch != chp:
                is_center = False
                break
        else:
            if (ch-abs(cx - x) - abs(cy-y)) > 0:
                is_center = False
                break

    return is_center, ch


if N == 1:
    print(p)
else:
    for i in range(101):
        for j in range(101):
            is_center, h = check(i,j, lp)
            if is_center:
                print(i,j,h)


Measured memory_bytes: 3064
#include <stdio.h>

int main(void){
    int a,b;
    char op;
    while(1){
    scanf("%d %c %d",&a, &op, &b);
    if(op=='?')
    break;
    if(op=='+'){
         printf("%d\n",a + b);
    }else if(op=='-'){
         printf("%d\n",a - b);
    }else if(op=='*'){
         printf("%d\n",a * b);
    }else if(op=='/'){
         printf("%d\n",a / b);
    }
    }
    return 0;
}


Measured memory_bytes: 2104
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <functional>
#define inf 10000000
using namespace std;
typedef long long ll;
const int MAXN=5e6+10;
const int MAX=1e6+10;
const double eps=1e-6;

ll n,k;
ll s[MAX];

int main(){
    #ifdef ONLINE_JUDGE
    #else
    //freopen("in.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    #endif

    ll n,a,b;
    cin>>n>>a>>b;
    cout<<min(n*a,b)<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>

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

using namespace std;

const int INF=1<<29;

int main(){
	for(int n,m;scanf("%d%d",&n,&m),n;){
		int t=INF,pre,ans,cnt=0;
		rep(i,n){
			int a; scanf("%d",&a);

			int j;
			for(j=m;j%a;j--);

			if(j<t || (j==t && a<=pre)){
				cnt=(j==t&&a==pre?cnt+1:1);
				t=j;
				pre=a;
				ans=i;
			}
		}

		printf("%d\n",cnt<2?ans+1:n);
	}

	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std ;

const long long int mod = 1e9+7 ;

int a[200001] , b[200001] ={} , c[200001] ;

long long int dp[200000] ;

int main()
{
	int n , i ;
	cin >> n ;
	
	for ( i=1 ; i<=n ; i++)
		cin >> a[i] ;
	
	c[1] = a[1] ;
	int total = 1 ;
	
	for( i=2 ; i<=n ; i++){
		if ( a[i] != c[total] ) 
			c[++total] = a[i] ;
	}
	
	for ( i=1 ; i<= total ; i++ ){
		if ( i==1 ) {
			b[c[i]] = i ;
			dp[1] = 1 ;
			continue ;
		}
		if (b[c[i]])
			dp[i] = (dp[i-1] + dp[b[c[i]]]) % mod ;
		else
			dp[i] = dp[i-1] ;
		b[c[i]] = i ;
		
	}
	
	cout << dp[total] ;
		
	
	return 0 ;
}

Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n;
cin>>n;
int h[n];
for(int i=0;i<n;i++)
{
cin>>h[i];
}
int dp[n];
dp[0]=0;
dp[1]=abs(h[1]-h[0]);
for(int i=2;i<n;i++)
{
dp[i]=min(dp[i-1]+abs(h[i]-h[i-1])  , dp[i-2]+abs(h[i]-h[i-2]));
//cout<<dp[i]<<"\n";
}
cout<<dp[n-1]<<"\n";
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>

int W, H;
char map[128][128];
char vis[128][128];

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

void searchLake(int nowy, int nowx)
{
	//int dy, dx;
	int newy, newx;
	int i;
	
	vis[nowy][nowx] = 1;
	
	//for (dy = -1; dy <= 1; dy++){
		for (i = 0; i < 4; i++){
			newy = nowy + dy[i];
			newx = nowx + dx[i];
			if (0 <= newy && newy < H && //newyが範囲内
				0 <= newx && newx < W && //newxが範囲内
				vis[newy][newx] != 1  && //すでに訪れていない
				map[newy][newx] == '1'   //新しい場所が池か？
			   ){
			   	searchLake(newy, newx);
			}
		}
	//}
}

int main(void)
{
	int i, j;
	int count;
	char str[32];
	
	while (1){
		//縦横の大きさの入力
		//scanf("%d %d", &W, &H);
		//実際の盤面の入力
		W = H = 12;

		for (i = 0; i < 12; i++){
            if (scanf("%s", map[i]) == EOF){
                return (0);
            }
        }
		
		count = 0;
		memset(vis, 0, sizeof(vis));
		for (i = 0; i < H; i++){
			for (j = 0; j < W; j++){
				if (map[i][j] == '1' && vis[i][j] != 1){
					searchLake(i, j);
					count++;
				}
			}
		}
		
		printf("%d\n", count);
	}
}

Measured memory_bytes: 576
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w, d; cin >> h >> w >> d;
    int table[h][w];
    vector<pair<int, int>> pos((h + 1) * (w + 1));
    for(int i = 0; i < h; i++)
    {
        for(int j = 0; j < w; j++)
        {
            int x; cin >> x;
            table[i][j] = x;
            pos[x] = make_pair(i + 1, j + 1);
        }
    }
    vector<int> sum((h + 1) * (w + 1), -1);
    for(int l = 1; l <= h * w; l++)
    {
        if(sum[l] >= 0) continue;
        sum[l] = 0;
        int y = pos[l].first, x = pos[l].second;
        for(int r = l + d; r <= h * w; r += d)
        {
            sum[r] = sum[r - d] + abs(pos[r].first - y) + abs(pos[r].second - x);
            y = pos[r].first, x = pos[r].second;
        }
    }
    int q; cin >> q;
    for(int i = 0; i < q; i++)
    {
        int l, r; cin >> l >> r;
        cout << sum[r] - sum[l] << endl;
    }
    return 0;
}



Measured memory_bytes: 2560
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let a: Vec<char> = itr.next().unwrap().chars().collect();

    let mut sum: Vec<usize> = vec![0; n + 1];
    let mut ans = 500000;
    for i in 0..n {
        sum[i + 1] = sum[i] + (a[i] == 'W') as usize;
    }

    for i in 0..n {
        ans = std::cmp::min(ans, sum[i] + n - (i + 1) - (sum[n] - sum[i + 1]));
    }
    println!("{}", ans);
}


Measured memory_bytes: 10492
#include<stdio.h>

int main(void){
	int a,b,k,i,t;

	scanf("%d %d %d",&a,&b,&k);
	t=a+k;
	for(i=a;i<(t<b+1?t:b+1);i++){
		printf("%d\n",i);
	}
	t=b-k+1;
	for(i=(i>t?i:t);i<=b;i++){
		printf("%d\n",i);
	}

	return 0;
}


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

int main() {
  int N, A, odd=0, even=0;
  cin >> N;
  for(int i=0;i<N;++i){
    cin >> A;
    if(A%2) odd++; else even++;
  }
  if(odd%2){
    cout << "NO" << endl; return 0;
  }
  cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>

using namespace std;
typedef long long ll;

#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())

int main(void){
	int N;
	ll x=1;
	cin >> N;
	rep(i, N){
		ll a;
		cin >> a;
		ll b = __gcd(x, a);
		x = (x/b)*a;
	}

	cout << x << endl;

	return 0;
}

Measured memory_bytes: 256
listA=[]
listOP=[]
listB=[]
count=0
while True:
    a,op,b=input().split()
    listA.append(int(a))
    listOP.append(op)
    listB.append(int(b))
    if op=="?":
        del listA[len(listA)-1]
        del listOP[len(listOP)-1]
        del listB[len(listB)-1]
        break
#入力パートここまで。計算出力パートここから
while count<=len(listA)-1:
    if listOP[count]=="+":
        print(listA[count]+listB[count])
    elif listOP[count]=="-":
        print(listA[count]-listB[count])
    elif listOP[count]=="*":
        print(listA[count]*listB[count])
    elif listOP[count]=="/":
        print(listA[count]//listB[count])
    else:
        print("ERROR")
    count+=1


Measured memory_bytes: 5596
n, *a = map(int, open(0).read().split())
ans = 0
mod = 10 **9 + 7
for k in range(61):
	m = 1 << k
	c = 0
	for x in a:
		if m & x:
			c += 1
	ans +=c * (n - c) * m
	ans %= mod
print(ans)

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

using namespace std;

using ll = long long;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    set<string> memo;

    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        memo.insert(s);
    }

    cout << memo.size() << endl;
    return 0;
}

Measured memory_bytes: 19268
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) (x).begin(),(x).end()
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



int main() {
	
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	
	int n, k; cin >> n >> k;
	
	vector<int> a(n); rep(i,n) cin >> a[i];
	
	
	sort(all(a));
	
	int ans = 0;
	
	rep(i, k) ans += a[i];
	
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 3616
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>

using namespace std;

#define MAX(a, b)  a>b?a:b
#define MIN(a, b)  a<b?a:b

int createValue(int a, int b)
{
	int value = a;
	for(int i=1 ; i<b ; i++) {
		value=value*10+a;
	}
	return value;
}

int main()
{
	int a, b;
	int value;

	cin>>a>>b;

	if(a<b) {
		cout<<createValue(a,b)<<endl;
	} else {
		cout<<createValue(b,a)<<endl;
	}

	return 0;
}


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

def main():
    a, b, c, d = map(int, input().split())

    flg = False

    while a > 0 and b > 0:
        c -= b

        if c > 0:
            a -= d
        else:
            flg = True
            break

    if flg == False:
        print('No')
    else:
        print('Yes')



if __name__ == '__main__':
    main()


Measured memory_bytes: 9176
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<pair<ll, ll>> pll;
 
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define popcount(x) __builtin_popcountll(x)
 
const long double PI = acos(-1);
 
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  ll a, b, x;
  cin >> a >> b >> x;
  if(x >= a && x <= a + b) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;



int main(){
  ll D, G;
  cin>>D>>G;
  vector<ll> P(D), C(D);
  rep(i, D){
    cin>>P[i]>>C[i];
  }
  ll Ans=INF;
  for(ll i=0; i<(1<<D); i++){
    ll Point=0;
    ll Cou=0;
    rep(j, D){
      if(i&(1<<j)){
        Point+=C[j];
        Point+=(100*(j+1))*P[j];
        Cou+=P[j];
      }
    }
    //cout<<Point;
    if(Point>=G){
      Ans=min(Ans,Cou);
      continue;
    }
    //cout<<'&';
    for(ll j=D-1; j>=0; j--){
      //cout<<Point<<" "<<Cou<<endl;
      if(i&(1<<j))continue;
      ll K=(G-Point)/((j+1)*100);
      if((G-Point)%((j+1)*100)>0)K++;
      //cout<<K<<" "<<endl;
      if(K<=P[j]-1){
        Cou+=K;
        Point=INF;
        break;
      }else{
        Cou+=P[j]-1;
        Point+=((j+1)*100)*(P[j]-1);
      }
    }
    if(Point<G)Cou=INF;
	Ans=min(Ans, Cou);

  }
  cout<<Ans<<endl;
} 



Measured memory_bytes: 3596
#include<iostream>
#include <string>
#include <stdio.h>
#include <math.h>
#include <iomanip>

using namespace std;

int main()
{
    double A; //時針 　こちらは１２時間つまり720分で360度回転するので、0.5度/min
    double B; //分針   こちらは１時間つまり60分で360度回転するので、6度/min
    double H; // H時
    double M; // M分

    cin >> A;
    cin >> B;
    cin >> H;
    cin >> M;

    double min = H * 60.0 + M;

    double A_angle = (min * 0.5) ;
    double B_angle = min * 6.0 ;

    while(A_angle - 360.0 >= 0){
        A_angle = A_angle - 360.0;
    }
    while(B_angle - 360.0 >= 0){
        B_angle = B_angle - 360.0;
    }

    // cout << A_angle << endl;
    // cout << B_angle << endl;

    double angle = abs(A_angle - B_angle);
    if(angle > 180){
        angle = 360 - angle;
    }
    // cout << angle << endl;

    double c = cos(angle*M_PI/180.0);
    double ans = sqrt(A*A + B*B -2*A*B*c);

    cout << fixed << setprecision(15) <<ans << endl;

    
    return 0;
}

Measured memory_bytes: 3604
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int m1 = sc.nextInt();
		int d1 = sc.nextInt();
		int m2 = sc.nextInt();
		int d2 = sc.nextInt();
		if( m1 == 1 && d1 == 31 ){
			System.out.println(1);
		} else if( m1 == 2 && d1 == 28 ){
			System.out.println(1);
		} else if( m1 == 3 && d1 == 31 ){
			System.out.println(1);
		} else if( m1 == 4 && d1 == 30 ){
			System.out.println(1);
		} else if( m1 == 5 && d1 == 31 ){
			System.out.println(1);
		} else if( m1 == 6 && d1 == 30 ){
			System.out.println(1);
		} else if( m1 == 7 && d1 == 31 ){
			System.out.println(1);
		} else if( m1 == 8 && d1 == 31 ){
			System.out.println(1);
		} else if( m1 == 9 && d1 == 30 ){
			System.out.println(1);
		} else if( m1 == 10 && d1 == 31 ){
			System.out.println(1);
		} else if( m1 == 11 && d1 == 30 ){
			System.out.println(1);
		} else if( m1 == 12 && d1 == 31 ){
			System.out.println(1);
		} else{
			System.out.println(0);
		}
	}
}

Measured memory_bytes: 22612
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    int a, b; cin >> a >> b;
    string s = to_string(b);
    int num = 0, d = 1;
    REP(i, s.size()) d *= 10;
    num = a * d + b;
    int sq = sqrt(num);
    cout << (sq * sq == num ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner scanner=new Scanner(System.in);
    int number=scanner.nextInt();
    int hundreds=number/100;
    int tens=number/10-hundreds*10;
    int ones=number-hundreds*100-tens*10;
    if(hundreds==7||tens==7||ones==7){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 35772
n = int(input())
a = list(input())
b = list(input())
c = list(input())
count = 0

for i in range(n):
	if a[i] != b[i] and b[i] != c[i] and a[i] != c[i]:
		count += 2
	elif a[i] != b[i] and b[i] == c[i] and a[i] != c[i]:
		count += 1
	elif a[i] != b[i] and b[i] != c[i] and a[i] == c[i]:
		count += 1
	elif a[i] == b[i] and b[i] != c[i] and a[i] != c[i]:
		count += 1
	else:
		continue

print(count)


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;
#define mp  std::make_pair
#define ll long long int
#define abs(n) ((n>0)?(n):((n)*(-1)))
#define CEIL(a,b) (((a) + ((b)-1)) / (b))
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
#define VREP_ll(v) for(std::vector<ll>::iterator itr = (v).begin(); itr != (v).end();itr++)
#define VREP_int(v) for(std::vector<int>::iterator itr = (v).begin(); itr != (v).end();itr++)
#define VALL(v) ((v).begin(),(v).end())
#define errln(v) cerr << (v) << endl;
#define println(v) cout << (v) << endl;

int main(int argc, const char * argv[]) {
	double denom=0;
	int n,a;
	cin >> n;
	REP(i,n){
		cin >> a;
		denom += 1.0 / a;
	}
	printf("%6f\n",1.0/denom);
	return 0;
}


Measured memory_bytes: 256
# https://atcoder.jp/contests/abc129/tasks/abc129_a

import itertools
from collections import Counter
from collections import defaultdict
import bisect
from heapq import heappush, heappop

def main():
    P, Q, R = map(int, input().split())
    print(min(P + Q, Q + R, R + P))

if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include <iostream>
using namespace std;
const int MAX = 500000;
const int SENTINEL = 2000000000;
int A[MAX/2 + 2],B[MAX/2 + 2];
int cnt;

void merge(int P[],int n,int alpha,int gamma,int beta){
    int n1 = gamma - alpha;
    int n2 = beta - gamma;
    for (int i = 0; i < n1 ; ++i)A[i] = P[alpha + i];
    for (int i = 0; i < n2 ; ++i)B[i] = P[gamma + i];
    A[n1] = SENTINEL;
    B[n2] = SENTINEL;
    int i=0; int j=0;
    for (int k = alpha; k < beta ; ++k) {
        cnt ++;
        if(A[i] <= B[j]){
            P[k] = A[i];
            i++;
        }else{
            P[k] = B[j];
            j++;
        }
    }
}

void mergesort(int P[],int n,int alpha,int beta){
    if(alpha + 1 < beta){
        int gamma = (alpha + beta)/2;
        mergesort(P,n,alpha,gamma);
        mergesort(P,n,gamma,beta);
        merge(P,n,alpha,gamma,beta);
    }
}

int main (){
    int P[MAX] ,n,i;
    cnt = 0;
    cin >> n;

    for (int i = 0; i < n; ++i)cin >> P[i];

    mergesort(P,n,0,n);

    for (int i = 0; i < n ; ++i) {
        if (i) cout << " ";
        cout << P[i];
    }
    cout << endl;
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 5064
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
typedef long long ll;
const int mod=998244353;
inline int addmod(int x)
{
	return x>=mod?x-mod:x;
}
inline int submod(int x)
{
	return x<0?x+mod:x;
}
int fpow(int x,int y)
{
	int ans=1;
	while(y)
	{
		if(y&1) ans=1ll*ans*x%mod;
		x=1ll*x*x%mod;
		y/=2;
	}
	return ans;
}
struct pt
{
	int a,b;
	pt(int a=0,int b=0):a(a),b(b){}
};
pt operator+(const pt x,const pt y)
{
	return pt(addmod(x.a+y.a),addmod(x.b+y.b));
}
pt operator-(const pt x,const pt y)
{
	return pt(submod(x.a-y.a),submod(x.b-y.b));
}
pt operator*(const pt x,const pt y)
{
	return pt(addmod(1ll*x.a*y.a%mod+5ll*x.b*y.b%mod),addmod(1ll*x.a*y.b%mod+1ll*x.b*y.a%mod));
}
pt getinv(pt x)
{
	int nw=submod(1ll*x.a*x.a%mod-5ll*x.b*x.b%mod);
	nw=fpow(nw,mod-2);
//	printf("nw=%d\n",nw);
	return pt(1ll*x.a*nw%mod,addmod(mod-1ll*x.b*nw%mod));
}
pt pfpow(pt x,ll y)
{
	pt ans=pt(1);
	while(y)
	{
		if(y&1) ans=ans*x;
		x=x*x;
		y/=2;
	}
	return ans;
}
int n,inv2,c[1000005],pn=2e5;
ll m;
pt p,q,invp,invq,dp[200005],ans;
void print(pt x)
{
	printf("(%d,%d) ",x.a,x.b);
}
int main()
{
	inv2=fpow(2,mod-2);
	scanf("%d%lld",&n,&m);
	c[0]=1;
	for(int i=1;i<=pn;i++)
		c[i]=1ll*c[i-1]*((m+i)%mod)%mod*fpow(i,mod-2)%mod;
	p=pt(inv2,inv2);
	q=pt(inv2,mod-inv2);
	invp=getinv(p-pt(1));
	invq=getinv(q-pt(1));
//	print(p),print(q),print(invp),print(invq);
//	printf("\n");
	//print((p-pt(1)));
//	print((p-pt(1))*invp),print((q-pt(1))*invq);
	dp[1]=pfpow(p,m);
	for(int i=2;i<=n;i++)
		dp[i]=(dp[i-1]*p-pt(c[i-2]))*invp;
	ans=dp[n];
	dp[1]=pfpow(q,m);
	for(int i=2;i<=n;i++)
		dp[i]=(dp[i-1]*q-pt(c[i-2]))*invq;
	ans=ans-dp[n];
	ans=ans*getinv(pt(0,1));
	//print(ans);
	printf("%d\n",ans.a);
	return 0;
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  string s;
  in(s);
  ll n;
  in(n);
  rep(i, n){
    if(s[i] != '1'){
      out(s[i]);
      memi;
      return 0;
    }
  }
  out(1);
  memi;
}

Measured memory_bytes: 256
"use strict"
function main(arg) {
    var no1 = arg.trim().split(" ")[0];
    var no2 = arg.trim().split(" ")[1];
    var sa = 0;

    if(no2 - no1 > 0){
        sa = no2 - no1;
        if(sa % 2 == 0){
            console.log(no2 - sa / 2);
        }else{
            console.log('IMPOSSIBLE')
        }
    }else{
        sa = no1 - no2;
        if(sa % 2 == 0){
            console.log(no1 - sa / 2);
        }else{
            console.log('IMPOSSIBLE')
        }
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
/******************************************
* AUTHOR : RAJAGOPALAN *
* NICK : ARNO *
* INSTITUTION : VIT *
******************************************/
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define alli(a, n, k) (a+k),(a+n+k)
#define FP(i, a, b, k) for(__typeof(a) i = a;i < b;i += k)
#define FS(i, a, b, k) for(__typeof(a) i = a;i > b;i -= k)
#define IT(it, a) for(__typeof(a.begin()) it = a.begin();it != a.end(); ++it)
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define eps 1e-6
#define pi 3.141592653589793
using namespace std;
using namespace __gnu_pbds;

template<class T> inline T gcd(T x, T y) { if (!y) return x; return gcd(y, x%y);}
typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef vector< pair<int, int> > VPII;
typedef vector< pair<int, PII > > VPPI;
const int MOD = 1e9 + 7;
const int INF = 1e9;

inline ll modulo(ll a, ll m)
{
	return (a % m + m) % m;
}

inline ll modInverse(ll a, ll m)
{
	assert(__gcd(a, m) == 1);
	ll m0 = m;
	ll y = 0, x = 1;

	if (m == 1)
		return 0;

	while (a > 1)
	{
		ll q = a / m;
		ll t = m;

		m = a % m, a = t;
		t = y;

		y = x - q * y;
		x = t;
	}

	if (x < 0)
		x += m0;

	return x;
}

inline ll modPow(ll x, ll y, ll m)
{ //x^y % m
	if (y == 0)
		return 1LL;
	else if (y == 1)
		return x;
	else
	{
		ll ans = modPow(x, y / 2, m) % m;
		if (y & 1)
		{
			return (((ans * ans) % m) * x) % m;
		}
		else
		{
			return (ans * ans) % m;
		}
	}
}

int main(int argc, char* argv[])
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	map<int,PII> mhh;
	bool gd[3][3];
	int mat[3][3];
	memset(gd,false,sizeof(gd));
	for(int i=0;i<3;++i)
	{
		for(int j=0;j<3;++j)
		{
			cin>>mat[i][j];
			mhh[mat[i][j]]={i,j};
		}
	}
	int n;
	cin>>n;
	while(n--)
	{
		int x;
		cin>>x;
		if(mhh.find(x)!=mhh.end())
		{
			PII xx=mhh[x];
			gd[xx.first][xx.second]=true;
		}
	}
	int cnt=0;
	bool win=false;
	for(int i=0;i<3;++i)
	{
		cnt=0;
		for(int j=0;j<3;++j)
		cnt+=(gd[i][j]);

		if(cnt==3)win=true;
		cnt=0;
		for(int j=0;j<3;++j)
		cnt+=(gd[j][i]);

		if(cnt==3)win=true;

	}

	if(gd[0][0]==gd[1][1] && gd[1][1]==gd[2][2] && gd[0][0])
	win=true;

	if (gd[0][2] == gd[1][1] && gd[1][1] == gd[2][0] && gd[0][2])
		win = true;

	if(win)cout<<"Yes";
	else cout<<"No";
	return 0;
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

struct edge{
  int from;
  int to;
  ll cost;
};

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

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

  vector<edge> E(M);
  vector<vector<int>> G(N);
  vector<vector<int>> Gb(N);

  ll a, b, c;
  for(int i = 0; i < M; i++){
    cin >> a >> b >> c;
    a--;
    b--;
    E[i].from = a;
    E[i].to   = b;
    E[i].cost = -c;
    G[a].push_back(b);
    Gb[b].push_back(a);
  }

  vector<ll> visitG(N);
  vector<ll> visitS(N);
  for(int i = 0; i < N; i++){
    visitG[i] = -1;
    visitS[i] = -1;
  }
  queue<int> q;
  q.push(0);

  visitG[N-1] = 1;
  visitS[0]   = 1;

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

    for(auto nv : G[next]){
      if(visitS[nv] >= 0) continue;
      
      q.push(nv);
      visitS[nv] = 1;
    }
  }

  q.push(N-1);
  while(!q.empty()){
    int next = q.front();
    q.pop();

    for(auto nv : Gb[next]){
      if(visitG[nv] >= 0) continue;
      
      q.push(nv);
      visitG[nv] = 1;
    }
  }

  vector<int> valid(N);
  for(int i = 0; i < N; i++){
    if(visitS[i] >= 0 && visitG[i] >= 0){
      valid[i] = 1;
    }else{
      valid[i] = 0;
    }
  }

  vector<ll> d(N);
  for(int i = 0; i < N; i++){
    d[i] = INF;
  }

  d[0] = 0LL;
  bool is_negative = false;
  for(int i = 0; i < N; i++){
    for(int j = 0; j < M; j++){

      edge e = E[j];

      if (d[e.to] > d[e.from] + e.cost) {  //移動した後のコストが小さいと、頂点のコストを更新
        d[e.to] = d[e.from] + e.cost; 
      }
    }
  }



  for(int i = 0; i < M; i++){
    edge e = E[i];
    if(d[e.from] + e.cost < d[e.to] && valid[e.from]){
      is_negative = true;
    }
  }

  if(is_negative){
    cout << "inf" << endl;
  }else{
    ll ans = -1 * d[N-1];
    cout << ans << endl;
  }

  return 0;
}


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

int main(){
    int N, K;  cin >> N >> K;
    vector<int> h(N);
    for(int i=0; i<N; i++)
        cin >> h[i];
    
    sort(h.begin(), h.end());
    
    int ans = 1e9;
    for(int i=K-1; i<N; i++){
        ans = min(ans, h[i] - h[i-K+1]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define rep(i,l,r) for(int i=l;i<r;i++)
#define rep2(i,r,l) for(int i=r;i>=l;i--)
#define sz(a) (ll)a.size()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define nl "\n"
#define pii pair<ll,ll>
#define F first
#define S second
#define iterate(c,x) for(auto &x:c)
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
	template <typename Arg1>
	void __f(const char* name, Arg1&& arg1){
		cerr << name << " : " << arg1 << std::endl;
	}
	template <typename Arg1, typename... Args>
	void __f(const char* names, Arg1&& arg1, Args&&... args){
		const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
	}
#else
#define trace(...)
#endif
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
// less_equal
// ordered_set X;
//K-th smallest
//*X.find_by_order(k-1)
//NO OF ELEMENTS < A
//X.order_of_key(A)
const int C = 1e5+5;
int n;
ll w[105], val[105], dp[C][105];
ll func(int W, int idx){
	if(W < 0)
		return -1e18;
	if(idx == n-1){
		if(W >= w[idx])
			return val[idx];
		else 
			return 0;
	}
	if(dp[W][idx] != -1)
		return dp[W][idx];
	dp[W][idx] = max(func(W, idx+1), val[idx]+func(W-w[idx], idx+1));
	return dp[W][idx];
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL),cout.tie(NULL);
	int W;
	cin>>n>>W;
	for(int i = 0; i <= W; i++)
		for(int j = 0; j <= n; j++)
			dp[i][j] = -1;
	for(int i = 0; i < n; i++)
		cin>>w[i]>>val[i];
	cout<<func(W, 0)<<endl;
	return 0;
}

Measured memory_bytes: 82304
import sys

input = sys.stdin.buffer.readline


class StronglyConnectedComponets:
    def __init__(self, n: int) -> None:
        self.n = n
        self.edges = [[] for _ in range(n)]
        self.rev_edeges = [[] for _ in range(n)]
        self.vs = []
        self.order = [0] * n
        self.used = [False] * n

    def add_edge(self, from_v: int, to_v: int) -> None:
        self.edges[from_v].append(to_v)
        self.rev_edeges[to_v].append(from_v)

    def dfs(self, v: int) -> None:
        self.used[v] = True
        for child in self.edges[v]:
            if not self.used[child]:
                self.dfs(child)
        self.vs.append(v)

    def rdfs(self, v: int, k: int) -> None:
        self.used[v] = True
        self.order[v] = k
        for child in self.rev_edeges[v]:
            if not self.used[child]:
                self.rdfs(child, k)

    def run(self) -> int:
        self.used = [False] * self.n
        self.vs.clear()
        for v in range(self.n):
            if not self.used[v]:
                self.dfs(v)
        self.used = [False] * self.n
        k = 0
        for v in reversed(self.vs):
            if not self.used[v]:
                self.rdfs(v, k)
                k += 1
        return k


class TwoSat(StronglyConnectedComponets):
    def __init__(self, num_var: int) -> None:
        super().__init__(2 * num_var + 1)
        self.num_var = num_var
        self.ans = []

    def add_constraint(self, a: int, b: int) -> None:
        super().add_edge(self._neg(a), self._pos(b))
        super().add_edge(self._neg(b), self._pos(a))

    def _pos(self, v: int) -> int:
        return v if v > 0 else self.num_var - v

    def _neg(self, v: int) -> int:
        return self.num_var + v if v > 0 else -v

    def run(self) -> bool:
        super().run()
        self.ans.clear()
        for i in range(self.num_var):
            if self.order[i + 1] == self.order[i + self.num_var + 1]:
                return False
            self.ans.append(self.order[i + 1] > self.order[i + self.num_var + 1])
        return True


def main() -> None:
    N, D = map(int, input().split())

    flags = [tuple(int(x) for x in input().split()) for _ in range(N)]

    # (X_i, Y_i) -> (i, -i) (i=1, ..., N) と考える
    sat = TwoSat(N)

    # 節 a, b の距離が D 以下の場合，
    # a -> -b つまり -a or -b が成立しなければならない
    for i, (x_i, y_i) in enumerate(flags, 1):
        for j, (x_j, y_j) in enumerate(flags[i:], i+1):
            if abs(x_i - x_j) < D:
                sat.add_constraint(-i, -j)
            if abs(y_i - x_j) < D:
                sat.add_constraint(i, -j)
            if abs(x_i - y_j) < D:
                sat.add_constraint(-i, j)
            if abs(y_i - y_j) < D:
                sat.add_constraint(i, j)
    if sat.run():
        print("Yes")
        print(*[x_i if sat.ans[i] else y_i for i, (x_i, y_i) in enumerate(flags)], sep="\n")
    else:
        print("No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 9940
#include<bits/stdc++.h>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define put(x) cout<<#x<<" = "<<x<<endl;
#define X first
#define Y second
#define pb push_back
#define pp pop_back
#pragma GCC optimize("O2")
using namespace std;
typedef long long num;
typedef pair<int,int> point;
const int maxn=2e6,lg=20;

int n,m,ans[maxn],A[maxn];
point dp[maxn][lg]; // = -inf

void smax(point &a,int b){
    if(b>a.X){
	a.Y=a.X;
	a.X=b;
    }else if(b>a.Y){
	a.Y=b;
    }
}

int32_t main(){
    scanf("%d",&n);
    m=1<<n;
    rep(i,0,m){
	scanf("%d",A+i);
	smax(dp[i][lg-1],A[i]);
    }
    rep(mask,0,m){
	for(int i=lg-2;i>=0;i--){
	    if((mask>>i)&1){
		smax(dp[mask][i],dp[mask^(1<<i)][i+1].X);
		smax(dp[mask][i],dp[mask^(1<<i)][i+1].Y);
	    }
	    smax(dp[mask][i],dp[mask][i+1].X);
	    smax(dp[mask][i],dp[mask][i+1].Y);
	}
    }
    
    rep(i,1,m){
	ans[i]=ans[i-1];
	if(dp[i][0].Y>0){
	    ans[i]=max(ans[i],dp[i][0].X+dp[i][0].Y);
	}
	printf("%d\n",ans[i]);
    }
}


Measured memory_bytes: 52224
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
using namespace std;
#define FOR(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define rep(i,n) FOR(i,0,n-1)
#define int long long
#define MOD 998244353
#define MAXN  100005
#define P pair<int,int>

int gcd(int a, int b) {return b?gcd(b,a%b):a;}
int lcm(int a,int b) {return a/gcd(a,b)*b;}
 
signed main(){
	
	int n;cin>>n;
	
	int ans = 1;
	rep(i,n)
	{
		int t;cin>>t;
		ans = lcm(ans,t);
	}
	cout << ans << endl;
	
}
 

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        long res = -(long)Math.pow(10, 18);
        int[] p = new int[n];
        for (int i = 0; i < p.length; i++) {
            p[i] = sc.nextInt() - 1;
        }
        int[] c = new int[n];
        for (int i = 0; i < c.length; i++) {
            c[i] = sc.nextInt();
        }

        for (int i = 0; i < n; i++) {
            int x = i;
            long tot = 0;
            List<Integer> list = new ArrayList<>();
            while (true) {
                x = p[x];
                list.add(c[x]);
                tot += c[x];
                if (x == i) {
                    break;
                }
            }
            int l = list.size();
            long t = 0;
            for (int j = 0; j < l; j++) {
                t += list.get(j);
                long now = t;
                if (j + 1 > k) {
                    break;
                }
                if (tot > 0) {
                    int e = (k - (j + 1)) / l;
                    now += tot * e;
                }
                res = Math.max(res, now);
            }
        }
        System.out.println(res);
        sc.close();
    }
}

Measured memory_bytes: 57416
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <set>
#define MX 400005

using namespace std;

int fst[MX], nxt[MX], u[MX], v[MX], lnum;
int id[MX], con[MX][2];
int n, m;

void addeg(int nu, int nv)
{
	nxt[++lnum] = fst[nu];
	fst[nu] = lnum;
	v[lnum] = nv;
	u[lnum] = nu;
}

void input()
{
	scanf("%d%d", &n, &m);
	for(int i=1; i<=n; i++)
	{
		char ch = getchar();
		while(ch != 'A' && ch != 'B') ch = getchar();
		if(ch == 'A') id[i] = 1;
		else id[i] = 0;
	}
	for(int i=1; i<=m; i++)
	{
		int a, b;
		scanf("%d%d", &a, &b);
		addeg(a, b);
		addeg(b ,a);
		con[a][id[b]] ++;
		con[b][id[a]] ++;
	}
}

void work()
{
	static int stk[MX], vis[MX];
	int top = 0, cnt = 0;
	for(int i=1; i<=n; i++)
		if(!con[i][0] || !con[i][1])
			stk[++top] = i, vis[i] = 1;
	while(top)
	{
		int x = stk[top--];
		cnt ++;
		for(int i=fst[x]; i; i=nxt[i])
		{
			con[v[i]][id[x]]--;
			if(!con[v[i]][id[x]] && !vis[v[i]]) stk[++top] = v[i], vis[v[i]] = 1;
		}
	}
	if(cnt == n) printf("No\n");
	else printf("Yes\n");
}

int main()
{
	input();
	work();
	return 0;
}

Measured memory_bytes: 12416
#!/usr/bin/env python3
N,M,C = map(int,input().split())
B = list(map(int,input().split()))
res = 0

for i in range(N):
    A = list(map(int,input().split()))
    tmp = C
    for i,j in zip(A,B): # longer is cut
        tmp += i * j
    if tmp > 0:
        res += 1

print(res)


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

int main(void)
{
  std::string s;
  std::vector<char> ans;

  std::cin >> s;
  for(int ii=0;ii<s.size();ii++){
    if(s[ii]=='1'){
      ans.push_back('1');
    }else if(s[ii]=='0'){
      ans.push_back('0');
    }else if(s[ii]=='B'){
      if(ans.size()){
        ans.erase(ans.begin()+ans.size()-1);
      }
    }
  }

  for(int ii=0;ii<ans.size();ii++){
    std::cout << ans[ii];
  }
  std::cout << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, m;
    string s, t;
    cin >> n >> m;
    for (int i = 0; i < n; i++) s += (char)(m + '0');
    for (int i = 0; i < m; i++) t += (char)(n + '0');
    cout << min(s, t);
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
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>
struct SegmentTree{
  using F = function<T(T,T)>;
  Int n;
  F f;
  T ti;
  vector<T> dat;
  SegmentTree(){};
  SegmentTree(F f,T ti):f(f),ti(ti){}
  void init(Int n_){    
    n=1;
    while(n<n_) n<<=1;
    dat.assign(n<<1,ti);
  }
  void build(const vector<T> &v){
    Int n_=v.size();
    init(n_);
    for(Int i=0;i<n_;i++) dat[n+i]=v[i];
    for(Int i=n-1;i;i--)
      dat[i]=f(dat[(i<<1)|0],dat[(i<<1)|1]);
  }
  void set_val(Int k,T x){
    dat[k+=n]=x;
    while(k>>=1)
      dat[k]=f(dat[(k<<1)|0],dat[(k<<1)|1]);    
  }
  T query(Int a,Int b){
    T vl=ti,vr=ti;
    for(Int l=a+n,r=b+n;l<r;l>>=1,r>>=1) {
      if(l&1) vl=f(vl,dat[l++]);
      if(r&1) vr=f(dat[--r],vr);
    }
    return f(vl,vr);
  }
  template<typename C>
  Int find(Int a,Int b,C &check,Int k,Int l,Int r){
    if(!check(dat[k])||r<=a||b<=l) return -1;
    if(k>=n) return k-n;
    Int m=(l+r)>>1;
    Int vl=find(a,b,check,(k<<1)|0,l,m);
    if(~vl) return vl;
    return find(a,b,check,(k<<1)|1,m,r);
  }
  template<typename C>
  Int find(Int a,Int b,C &check){
    return find(a,b,check,1,0,n);
  }
};

//INSERT ABOVE HERE
signed main(){
  Int n,m;
  cin>>n>>m;
  vector<Int> v(n);
  for(Int i=0;i<n;i++) cin>>v[i];
  Int ans=0;
  for(Int i=0;i<n;i++) ans+=abs(v[i]-i);
  
  using P = pair<Int, Int>;
  struct T{
    P a,b,c;
    T(){}
    T(P a,P b,P c):a(a),b(b),c(c){}
  };
  auto f=[&](T x,T y){
           return T(max(x.a,y.a),min(x.b,y.b),x.c);
         };

  vector<T> vt(n);
  for(Int i=0;i<n;i++){
    vt[i]=T(P(min(v[i],i),i),P(max(v[i],i),i),P(i,i));    
  }

  const Int INF = 1e9;
  T ti(P(-INF,-INF),P(INF,INF),P(0,0));
  SegmentTree<T> seg(f,ti);
  seg.build(vt);

  for(Int i=0;i<m;i++){
    T res=seg.query(0,n);
    Int x=res.b.second;
    Int y=res.a.second;
    if(x==y) break;
    if(min(v[y],y)<=max(v[x],x)) break;
    //cout<<x<<" "<<y<<endl;
    ans+=(min(v[y],y)-max(v[x],x))*2;
    swap(v[x],v[y]);
    vt[x]=T(P(min(v[x],x),x),P(max(v[x],x),x),P(x,x));
    vt[y]=T(P(min(v[y],y),y),P(max(v[y],y),y),P(y,y));
    seg.set_val(x,vt[x]);
    seg.set_val(y,vt[y]);
  }
  Int res=0;
  for(Int i=0;i<n;i++) res+=abs(v[i]-i);
  assert(ans==res);  
  //cout<<ans<<endl;
  cout<<res<<endl;
  
  return 0;
}



Measured memory_bytes: 20492
class Main{
        public static void main(String[] args){
                java.util.Scanner sc = new java.util.Scanner(System.in);
                int n = sc.nextInt();
                while(n > 0){ 
                        int[][] matrix = new int[n+1][n+1];
                        for(int i = 0 ; i < n ; i++){
                                for(int j = 0 ; j < n ; j++){
                                        matrix[i][j] = sc.nextInt();
                                        matrix[i][n] += matrix[i][j];
                                        matrix[n][j] += matrix[i][j];
                                        matrix[n][n] += matrix[i][j];
                                }   
                        }   
                        for(int i = 0 ; i < n+1 ; i++){
                                for(int j = 0 ; j < n+1 ; j++){
                                        System.out.print(String.format("%5d",matrix[i][j]));
                                }   
                                System.out.println();
                        }   
                        n = sc.nextInt();
                }   
        }   
}

Measured memory_bytes: 13000
#include<iostream>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  int A, P; std::cin >> A >> P;
  P += A*3;
  fin(P/2);
  return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
#N = int(input())
S, T = map(str, input().split())
print (T+S)

Measured memory_bytes: 38256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
#include <vector>
#include <cstdlib>
#include <utility>
#include <map>
#include <set>
#include <ios>
#include <iomanip>
#include <functional>

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<vector<int>> v(2);
    for(int i = 0; i < 2; i++){
        for(int j = 0; j < n; j++){
            int x;
            cin >> x;
            v[i].push_back(x);
        }
    }
    vector<int> ans;

    
    for(int i = 0; i < n; i++){
        int sum1 = 0;
        int sum2 = 0;
        for(int j = 0; j <= i; j++){
            sum1 += v[0][j];
        }
        for(int j = i; j <= n - 1; j++){
            sum2 += v[1][j];
        }
        ans.push_back(sum1 + sum2);
    }
    sort(ans.begin(), ans.end());
    reverse(ans.begin(), ans.end());
    cout << ans[0];
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		//input
		//	N枚のモチ(i番目のモチはdiセンチメートル)
		//	◆条件
		//		1<= N <= 100
		//		1<= di <= 100
		//


		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();

		if(N<1 || N>100) {
			System.out.println("N is illegal");
			System.exit(1);
		}

		int d[] = new int[N];


		for(int i =0 ;i<N;i++) {
			int d_i = scan.nextInt();
			if(d_i < 1 || d_i > 100 ) {
				System.out.println("d[i] is illegal");
				System.exit(1);
			}
			d[i] = d_i;

		}

		//logic(組み合わせ問題)
		//①重複なしで、モチの直径をソートして、現時点で積み上げたモチの直径より小さいモチがあれば積み上げる
		//②

		int num_stage = 0;


		Arrays.sort(d);//昇順にソート
		int diameter = d[N-1];//直径が一番大きいモチの積み上げ
		num_stage = num_stage + 1;

		for(int i = 2;i < N +1 ;i++) {

			if(d[N-i] < diameter) {//一段積み上げ
				diameter = d[N-i];
				num_stage = num_stage + 1;

			}

		}


		//output
		//	最大で何段重ねのモチを作れるか
		System.out.println(num_stage);
	}

}


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

/*
int main(){
    int n,a,b;
    cin >> n >> a >> b;
    int tmp,tmp1,tmp2,tmp3,tmp4,tmp5=0;
    int sum=0;
    for(int i=1;i<=n;i++){
        if(i<10){
            if(i>=a && i<=b){
                sum+=i;
            }
        }else if(10<=i && i<100){
            tmp1=i%10;
            tmp2=(i/10)%10;
            tmp=tmp1+tmp2;
            if(tmp>=a && tmp<=b){
                sum+=i;
            }
        }else if(100<=i && i<1000){
            tmp1=i%10;
            tmp2=(i/10)%10;
            tmp3=(i/100)%10;
            tmp=tmp1+tmp2+tmp3;
             if(tmp>=a && tmp<=b){
                sum+=i;
            }
        }else if(1000<=i && i<10000){
            tmp1=i%10;
            tmp2=(i/10)%10;
            tmp3=(i/100)%10;
            tmp4=(i/1000)%10;
            tmp=tmp1+tmp2+tmp3+tmp4;
             if(tmp>=a && tmp<=b){
                sum+=i;
            }
        }else if(10000<=i && i<100000){
            tmp1=i%10;
            tmp2=(i/10)%10;
            tmp3=(i/100)%10;
            tmp4=(i/1000)%10;
            tmp5=(i/10000)%10;
            tmp=tmp1+tmp2+tmp3+tmp4+tmp5;
             if(tmp>=a && tmp<=b){
                sum+=i;
            }
        }
        //cout << "sum:" << sum <<endl;
    }

    cout << sum << endl;
    return 0;
}*/

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

    int sum=0;
    int total=0;
    int tmp=0;
    repeq(i,1,n){
        sum=0;
        tmp=i;
        while(tmp>0){
            sum+=tmp%10;
            tmp/=10;
        }
        if(a<=sum && sum<=b){
            total+=i;
        }
    }

    cout << total << endl;
    return 0;
}

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

int main(){
  int i;
  string s;
  bool flag = false;
  
  cin >> i;
  for(int j=0;j<i;j++){
    cin >> s;
 	
    if(s=="Y"){
      flag = true;
  	  break;
  }
  }
    if(flag)
      cout << "Four" << endl;
    else
      cout << "Three" << endl;
    
    
    
}

Measured memory_bytes: 256