akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ls(x) (x)<<1
#define rs(x) (x)<<1|1
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define ll rt<<1
#define rr rt<<1|1
#define PI acos(-1)
#define MM int m=(l+r)>>1;
#define fu(i,r,t) for(int i=r;i<=t;i++)
#define fd(i,r,t) for(int i=r;i>=t;i--)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define endl '\n'
#define lcm(a,b) (a*b)/__gcd(a,b)
#define Case(i,ans) cout<<"Case "<<i<<": "<<ans<<endl;
#define cp(i,ans) printf("%.if",ans);
#define cpp(i,ans) cout<<setprecision(i)<<fixed<<ans<<endl;
#define ppb pop_back
#define ppf pop_front
#define pb push_back
#define pf push_front
#define pq priority_queue
#define lowbit(x) (x)&(-x)
#define all(V) V.begin(),V.end()
#define ms multiset
#define mod(x) (x+mo_num)%mo_num
#define vc vector
#define vct vector<int>
#define fa(i,V) for(auto i:V)
#define out(i) cout<<(i)<<endl;
#define fi first
#define se second
#define fun(i) fu(i,1,n)
#define fut(i) fu(i,1,t)
#define fum(i) fu(i,1,m)
#define ld long double
//#define P pair<int,int>
using namespace std;
const int INF=LLONG_MAX;
const int maxn=1e6+5;
const int mo_num=1e9+7;
int n,m,a[maxn],b[maxn],ans;
vct fu,zh;
bool cmp(int x,int y){return x>y;}
int32_t main()
{
    IOS
    cin>>n;
    int num=INF,it;
    fun(i)
    {
        int x;
        cin>>x;
        if(x>=0)zh.pb(x);
        else fu.pb(x);
        ans+=abs(x);
        if(abs(x)<num)
        {
            num=abs(x);
            it=x;
        }
    }
    int f=fu.size(),z=zh.size();
    if(f && z)
    {
        out(ans)
        int q=fu[f-1],w=zh[z-1];
        fu.ppb();
        zh.ppb();
        fa(i,zh)
        {
            cout<<q<<" "<<i<<endl;
            q-=i;
        }
        fu.pb(q);
        fa(i,fu)
        {
            cout<<w<<" "<<i<<endl;
            w-=i;
        }
    }else if(f && !z)
    {
        out(ans-2*num)
        sort(fu.begin(),fu.end());
        int q=fu[f-2],w=fu[f-1];
        fu.ppb();
        fu.ppb();
        fa(i,zh)
        {
            cout<<q<<" "<<i<<endl;
            q-=i;
        }
        fu.pb(q);
        fa(i,fu)
        {
            cout<<w<<" "<<i<<endl;
            w-=i;
        }
    }else{
        out(ans-2*num)
        sort(zh.begin(),zh.end(),cmp);
        int q=zh[z-1],w=zh[z-2];
        zh.ppb();
        zh.ppb();
        fa(i,zh)
        {
            cout<<q<<" "<<i<<endl;
            q-=i;
        }
        fu.pb(q);
        fa(i,fu)
        {
            cout<<w<<" "<<i<<endl;
            w-=i;
        }
    }

    return 0;
}

Measured memory_bytes: 2804
n, q = map(int, input().split())
s = input()
ac = [0]
prev = ''
for c in s:
    if prev + c == 'AC':
        ac.append(ac[-1]+1)
    else:
        ac.append(ac[-1])
    prev = c

queries = [tuple(map(int, input().split())) for _ in range(q)]
for query in queries:
    print(ac[query[1]] - ac[query[0]])


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

int main()
{
	int n;
	cin >> n;
	int B[100] = {};
	for (int i = 0; i < n-1; ++i)
	{
		cin >> B[i];
	}
	int ans = B[0] + B[n-2];
	for (int i = 0; i < n-2; ++i)
	{
		ans += min(B[i], B[i+1]);
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
  string S;
  string T;
  int ans = 0;
  cin >> S >> T;
  for (int i = 0; i < S.size(); i++){
    if (S[i] != T[i]){
      ans += 1;
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  long n, a, b;
  cin >> n >> a >> b;
  if(a == 0 && b == 0){
    cout << 0 << endl;
  }
  else {
    long x, y, z;
    x = n / (a + b) * a;
    y = n % (a + b);
    if(y > a) {
      z = a;
    }
    else if(y <= a) {
      z = y;
    }
    cout << x + z << endl;
  }
}

Measured memory_bytes: 256
import java.io.*;import java.util.*;public class Main {    public static void main(String args[]) throws IOException {        BufferedReader r = new BufferedReader(new InputStreamReader(System.in));        int[] mountains = new int[10];        int i = 0;        while(true){            String s = r.readLine();            mountains[i++] = Integer.valueOf(s);            if(i >= 10) break;        }        Arrays.sort(mountains);        for(i = 9; i > 6; i--) {            System.out.println(mountains[i]);        }    }}

Measured memory_bytes: 16864
package main

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

func main() {
	r := bufio.NewReader(os.Stdin)
	var n, h int
	fmt.Fscan(r, &n)
	fmt.Fscan(r, &h)

	as := make([]int, n)
	bs := make([]int, n)
	maxA := 0
	for i := 0; i < n; i++ {
		fmt.Fscan(r, &as[i])
		fmt.Fscan(r, &bs[i])

		// 振って最も大きいダメージを与えられる刀を保持
		maxA = max(maxA, as[i])
	}
	sort.Sort(sort.IntSlice(as))
	sort.Sort(sort.IntSlice(bs))

	ans := 0

	// まずは投げてみる
	for i := n - 1; i >= 0; i-- {
		if bs[i] <= maxA {
			break
		}

		h -= bs[i]
		ans++
		if h <= 0 {
			break
		}
	}

	// 投げて不足する場合は、振って攻撃する
	if h > 0 {
		swingCount := (h + maxA - 1) / maxA
		ans += swingCount
	}

	fmt.Println(ans)
}

// Utility

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func primeFactor(x int) map[int]int {
	res := make(map[int]int)
	for i := 2; i*i <= x; i++ {
		for x%i == 0 {
			res[i]++
			x = x / i
		}
	}
	if x != 1 {
		res[x] = 1
	}
	return res
}

func divisor(x int) []int {
	res := make([]int, 0)
	for i := 1; i*i <= x; i++ {
		if x%i == 0 {
			res = append(res, i)
			if i != x/i {
				res = append(res, x/i)
			}
		}
	}
	return res
}

func gcd(x, y int) int {
	if y == 0 {
		return x
	}
	return gcd(y, x%y)
}

func lcm(x, y int) int {
	return x / gcd(x, y) * y
}

func reverseString(s string) string {
	r := []rune(s)
	for i, j := 0, len(r)-1; i < len(r)/2; i, j = i+1, j-1 {
		r[i], r[j] = r[j], r[i]
	}
	return string(r)
}


Measured memory_bytes: 5376
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
using namespace std;

#define mem(arr, i) fill(arr, arr + sizeof(arr), i)
#define MEM(arr, i) memset(arr, i, sizeof(arr))
#define Push push_back
#define Pair make_pair
#define ALL(x) x.begin(), x.end()
#define X first
#define Y second
#define ACCEL \
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL); \
	cout.tie(NULL)
typedef unsigned long long ull;
typedef long long lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef pair<pll,lli> p3l;
typedef vector<int> vcI;
typedef vector<lli> vcL;
typedef vector<pii> vPI;
typedef vector<pll> vPL;
typedef vector<p3l> v3L;
typedef vector<vcL> vvL;
const double PI = 3.141592653589793;
const lli I_MAX = 1LL << 60;
      lli   mod = 1000000007;

/// templates ///

const lli maxN = 2E5;

vcL inv(maxN+5, 1);

void ADD(lli &x, lli y) {
	x += y;
	if (x >= mod) x -= mod;
	if (x < 0) x += mod;
}

void MUL(lli &x, lli y) {
	x *= y;
	x = (x % mod + mod) % mod;
}

lli mypow(lli b, lli e) {
	if (b == 0) return 0;
	lli ans = 1;
	while (e) {
		if (e & 1) MUL(ans, b);
		MUL(b, b);
		e >>= 1;
	}
	return ans;
}

lli modinv(lli n) {
	return mypow(n, mod - 2);
}

void calcInv(lli n) {
	for (int i = 2; i <= n; ++i) {
		inv[i] = (mod - mod / i) * inv[mod % i] % mod;
	}
}

/// coding area ///

const lli maxn = 1E5;

void solve() {
	int cnt = 0;
	string s, t;
	cin >> s >> t;
	for (int i = 0; i < 3; ++i) {
		if (s[i] == t[i]) {
			++cnt;
		}
	}
	
	cout << cnt << '\n';
}

int main() {
//	precal();
	int t = 1;
	#ifdef LOCAL
		t = INT_MAX;
	#else
		ACCEL;
	#endif
//	cin >> t;
	for (int i = 1; i <= t; ++i) {
//		cout << "Case #" << i << ": ";
		solve();
	}
	return 0;
}



Measured memory_bytes: 1792
N = int(input())						# 5



from collections import defaultdict
d = defaultdict(int)

for i in range(N):
	s = input()
	k = s[0]
	d[k] += 1



r = [ d['M'], d['A'], d['R'], d['C'], d['H'] ]

#print(r)

# 3ペア抽出(組み合わせ)
from itertools import combinations
#l = list(combinations(r, 3))
#print( l )
ans=0
for l in list(combinations(r, 3)):
	ans += (l[0] * l[1] * l[2])

print(ans)

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

#define endl '\n'

using namespace std;

const int maxn = 1e5 + 3;

int x, y, a, b, c;
int p[maxn], q[maxn], r[maxn];
void read()
{
    cin >> x >> y >> a >> b >> c;
    for (int i = 1; i <= a; i++)
        cin >> p[i];

    for (int i = 1; i <= b; i++)
        cin >> q[i];

    for (int i = 1; i <= c; i++)
        cin >> r[i];
}

void solve()
{
    sort (p + 1, p + a + 1);
    sort (q + 1, q + b + 1);
    sort (r + 1, r + c + 1);

    multiset <long long> s;
    for (int i = a-x+1; i <= a; i++)
        s.insert(p[i]);

    for (int i = b-y+1; i <= b; i++)
        s.insert(q[i]);

    for (int i = c; i >= 1; i--)
    {
        auto it = s.begin();
        if (*it >= r[i])
            break;

        s.erase(it);
        s.insert(r[i]);
    }

    long long ans = 0;
    for (auto i: s)
        ans += i;

    cout << ans << endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    read();
    solve();
}


Measured memory_bytes: 9856
//list index out of rangeエラー表示用
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)


int main(){
  int n;
  cin >> n;
  int ans = 0;
  vector<int> yakusu(n);
  rep(i, 1, n){
    rep(j, 1, (n-1)/i+1){
      yakusu[i*j] += 1;
    }
  }
  rep(i, 0, n){
    ans += yakusu[i];
  }
  cout << ans;
}



Measured memory_bytes: 7152
#include <iostream>
#include <algorithm>
#include <climits>
#define leftnode (node<<1)
#define rightnode ((node<<1)|1)
#define getmid ((left+right)>>1)
using namespace std;
typedef pair<int, int> pii;
const int MAXN = 2e5 + 10;
int tree[MAXN<<2], info[MAXN<<2], n;
pii items[MAXN];
void build (int node, int left, int right, int m) {
    if (left == right) {
        tree[node] = left - m;
        return;
    }
    int mid = getmid;
    build (leftnode, left, mid, m);
    build (rightnode, mid+1, right, m);
    tree[node] = max(tree[leftnode], tree[rightnode]);
}
void push(int node, int left, int right) {
    if (info[node] == 0) return;
    int mid = getmid;
    tree[leftnode] += info[node];
    tree[rightnode] += info[node];
    info[leftnode] += info[node];
    info[rightnode] += info[node];
    info[node] = 0;
}
void update(int node, int left, int right, int i, int j) {
    if (right < i || j < left) return;
    if (i <= left && right <= j) {
        info[node]++;
        tree[node]++;
        return;
    }
    push(node, left, right);
    int mid = getmid;
    update(leftnode, left, mid, i, j);
    update(rightnode, mid+1, right, i, j);
    tree[node] = max(tree[leftnode], tree[rightnode]);
}
int query(int node, int left, int right, int i, int j) {
    if (right < i || j < left) return INT_MIN;
    if (i <= left && right <= j) {
        return tree[node];
    }
    push(node, left, right);
    int mid = getmid;
    return max(query(leftnode, left, mid, i, j), query(rightnode, mid+1, right, i, j));
}

bool cmp(pii a, pii b) {
    if (a.first != b.first) return a.first < b.first;
    return a.second > b.second;
}


int main() {
//    freopen("test.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int tot, m, a, b;
    cin >> tot >> m;
    n = m+1;
    for (int i = 0; i < tot; i++) {
        cin >> a >> b;
        items[i] = {a, b};
    }
    sort(items, items+tot, cmp);
    int ret = max(tot - m, 0);
    build (1, 1, m+1, m+1);
    for (int i = 0; i < tot; i++) {
        update(1, 1, m+1, items[i].first+1, items[i].second);
        int tmp = query(1, 1, m+1, items[i].first+1, m+1);
        ret = max(ret, tmp-items[i].first);
    }
    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 7040
#include <stdio.h>
int main(void){
	int i,r,d,x,ans;
	scanf("%d %d %d",&r,&d,&x);
	for(i=0;i<10;i++){
		x = x*r - d;
		ans = x;
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<algorithm>
using namespace std;

const int MAX = 100000;
int main() {
	int N, M, P, Y;
	scanf("%d%d", &N, &M);
	static pair<pair<int, int>, int> city[MAX]; // <<P, Y>, i>を記憶しているよ
	static pair<int, int> num[MAX]; // 求めた番号を記録するよ
	for (int i = 0;i < M;++ i) {
		scanf("%d%d", &P, &Y);
		city[i] = make_pair(make_pair(P, Y), i);
	}
	sort(city, city+M); // これでPの小さい順→同値ならYの小さい順にソートされるよ
	for (int i = 0, c = 1;i < M;++ i, c = i < M && city[i - 1].first.first == city[i].first.first ? c + 1 : 1) { // cは同じPにおける何番目かを表してるよ
		num[city[i].second] = make_pair(city[i].first.first, c);
	}
	for (int i = 0;i < M;++ i) printf("%06d%06d\n", num[i].first, num[i].second);
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

まず、P順→Y順にソートすると、それぞれについてxが一意に定まる
これを次にi順にソートすればxが分かっているので無事に求まる
*/

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

long long INF = 1000000000000000000LL;
long long N, A[1 << 18], E = 1;

int main() {
	cin >> N; long double P = 0;
	for (int i = 1; i <= N; i++) {
		cin >> A[i]; E *= A[i];
		if (A[i] == 0) {
			cout << "0" << endl;
			return 0;
		}
		P += log10(1.0L * A[i]);
	}
	if (P >= 18.5L || E > INF) cout << "-1" << endl;
	else cout << E << endl;
	return 0;
}

Measured memory_bytes: 4488
#include<stdio.h>
int main(void){
  char S[11]; scanf("%s",S);
  int min=1000;
  for(int i=0;S[i+2] != '\0';i++){
    int s=(S[i]-'0')*100+(S[i+1]-'0')*10+(S[i+2]-'0');
    int diff=(753>=s)?753-s:s-753;
    if(diff<min){
      min=diff;
    }
  }
  printf("%d\n",min);

  return 0;
}


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

class rest{
public:
	int id;
	string ct;
	int p;
	bool operator<(const rest& lhc){
		if(this->ct.compare(lhc.ct) < 0){
			return true;
		}else if(this->ct.compare(lhc.ct) > 0){
			return false;
		}
		return this->p > lhc.p;
	}
};

int main(){

	int N;
	cin >> N;
	vector<rest> rts(N);
	for(int i=0;i<N;i++){
		rts[i].id = i+1;
		cin >> rts[i].ct >> rts[i].p;
	}

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

	for(int i=0;i<N;i++){
		cout << rts[i].id << endl;
	}

}


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

using namespace std;

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


Measured memory_bytes: 3152
#include "stdio.h"

int main()
{
	int goodsCount;
	int price[10];
	int maxPrice = 0;
	int maxPriceIdx = 0;
	int total = 0;

	if (scanf("%d", &goodsCount) == EOF)
	{
		return 0;
	}

	for (int i = 0; i < goodsCount; i++)
	{
		if (scanf("%d", &price[i]) == EOF)
		{
			return 0;
		}

		if (maxPrice < price[i])
		{
			maxPrice = price[i];
			maxPriceIdx = i;
		}
	}

	for (int i = 0; i < goodsCount; i++)
	{
		if (i == maxPriceIdx)
		{
			total += (price[i] / 2);
		}
		else
		{
			total += price[i];
		}
	}

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

	return 0;
}

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

using namespace std;

#define rep(i, x)   for (__typeof(x) i = 0; i < x; i++)
#define mp             make_pair
#define pb             push_back
#define fi             first
#define se             second
#define sz(x)          (int)((x).size())
#define all(x)         (x).begin(), (x).end()
#define sci(x)         int x;       scanf("%d", &x);
#define scii(x, y)     int x, y;    scanf("%d %d", &x, &y);
#define sciii(x, y, z) int x, y, z; scanf("%d %d %d", &x, &y, &z);
#define TC(x)          sci(x); while(x --)
#define eprintf(...)   fprintf(stderr, __VA_ARGS__)
#define debug(x)       { cerr << #x << " = " << x << endl; }
#define repi(i, x)  for (__typeof(x) i = x-1; i >= 0; i --)
#define fore(itr, x)   for (__typeof(x.begin()) itr = x.begin(); itr != x.end(); itr ++)
#define forei(itr, x)  for (__typeof(x.end()) itr = x.end() - 1; itr != x.begin() - 1; itr --)
typedef long long      ll;
typedef pair<int, int> ii;
typedef pair<ii, int>  iii;
typedef vector<int>    vi;
typedef vector<ii>     vii;
typedef vector<iii>    viii;
typedef vector<vector<int> > vvi;
typedef pair<ll, ll>   pairl;
typedef vector<ll>     vl;
typedef vector<ll>     vll;
typedef vector<vector<ll> > vvl;
const   int            infi = numeric_limits<int>::max();
const   ll             infl = numeric_limits<ll>::max();
const   double         eps = 0;
const   int            ms  = 0;

const int MAX = 1000001;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main()
{
    ios::sync_with_stdio(false);//endl->"\n"
    cin.tie(0);
    COMinit();
    int X, Y;
    cin >> X >> Y;
    if((X+Y)%3 != 0){
        cout << 0 << endl;
        return 0;
    }
    int a = (X+Y)/3;
    if(!(a <= X && X <= 2*a && a<= Y && Y <= 2*a)){
        cout << 0 << endl;
        return 0;
    }
    cout << COM(a, 2*a-X) << endl;
    return 0;
}

Measured memory_bytes: 24320
#include <stdio.h>

int main(void){
 int a, b, c;

scanf("%d%d%d", &a, &b, &c);

int ispoor = 0;
if (a == b && b != c) ispoor = 1;
if (b == c && c != a) ispoor = 1;
 if (c == a && a != b) ispoor = 1;

if (ispoor) {
puts("Yes");
} else {
puts("No");
}

 return 0;
 }


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

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

using ll = long long int;
using P = pair<int, int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
using VB = vector<bool>;
using VVB = vector<VB>;




int main(){
  int fh, oh, ft, x;
  scanf("%d%d%d%d",&fh,&oh,&ft,&x);
  x /= 50;
  int ans = 0;
  REP(i,fh + 1) REP(j, oh + 1) REP(k, ft + 1){
    if(10 * i + 2 * j + k == x) ans++;
  }
  printf("%d\n",ans);
  return 0;
}

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

int main(){
  int n;
  cin >> n;
  int count=0;
  int detect=1;
  bool f = true;
  
  vector<int> vec(n);
  for(int i=0; i<n ; i++){
    cin >> vec.at(i);
  }
  
  for(int i=0; i<n ; i++){
    if(detect == 2){
      f = false;
      break;
    }
    detect = vec.at(detect-1);
    count ++;
  }
  
  if(f == true){
    cout << -1 << endl;
  }else{
    cout << count << endl;
  }
}

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

#define pb push_back
using namespace std;

vector<int> adj[100100];
int memo[100100];
int N, M, u, v;
int dp(int n) {
	int &ans = memo[n];
	if (ans != -1) return ans;

	ans = 0;
	for (int i = 0; i < (int)adj[n].size(); i++) {
		ans = max(ans, dp(adj[n][i]) + 1);
	}

	return ans;
}
int main() {
	memset(memo, -1, sizeof memo);
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		cin >> u >> v;
		adj[u].pb(v);
	}

	int ans = -1;
	for (int i = 1; i <= N; i++) {
		ans = max(ans, dp(i));
	}

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

Measured memory_bytes: 8192
#include<iostream>
#include<string>
using namespace std;
int main() {
	string a;
	cin >> a;

  
	for (int x = 0; x < 19; ++x) {
        
		if (a[x] == ','){
       
          a[x] = ' ';

        }
	}
  cout<<a<<endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n,a,b,max=0,tmp;
  int imos[100003]={};
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> a >> b;
    imos[a]++;
    imos[b+1]--;
  }
  for(int i=1;i<=n+1;i++){
    imos[i]=imos[i]+imos[i-1];
  }
  for(int i=0;i<=n;i++){
    if(imos[i+1]<i) continue;
    if(imos[i+1]>i)imos[i+1]=i;
    max=(imos[i+1]<max)?max:imos[i+1];
  }
  cout << max<<endl;
}



Measured memory_bytes: 3440
#include <bits/stdc++.h>
    using namespace std;
     
    int main() 
	
	{
      int n,m; cin>>n>>m;
      
      if( n==m) 
      {
      	for(int i=0;i<n;i++) cout<<n;
	  }
     
     else 
     {
     	 int mini=min(n,m);
     	 
     	 for( int i=0;i< max(n,m);i++)  cout<<mini;
	 }
        
     
    }

Measured memory_bytes: 3548
n,a,b=gets.chomp.split(' ').map(&:to_i)
ans = 0
if b == 0
    ans = n
elsif a != 0
    temp = (n/(a+b))*a
    remainder = n % (a+b)
    if remainder > a
        temp += a
    else
        temp += remainder
    end
    ans = temp
end
puts ans

Measured memory_bytes: 14372
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(); //ポイント
		int Q = sc.nextInt(); //クイズの回数
		int A[] =  new int[Q]; //正解者
		for(int i=0;i<Q;i++) {
			A[i] = sc.nextInt();
		}
		
		int points[] = new int[N];
		//初期化
		for (int point :points ) {
			point=0;
		}
		
		//自分以外に、K回正解されるとアウト。
		//したがって正解数Q回ならば、自分の正解数をAとすると、Q-A<Kならいい。つまり、A＞Q-Kなら良い。
		//開始０ポイントで、正解した人は１ポイントとし、
		//終了までにQ-Kポイントよりも獲得（Q-Kはだめ）すると突破に読み換える。
		for(int i=0;i<Q;i++) {
			points[A[i]-1]++;
		}
		
		StringBuilder sb = new StringBuilder();
		for (int point :points ) {
			if(point>Q-K) {
				sb.append("Yes");
				sb.append(System.getProperty("line.separator"));
			}else {
				sb.append("No");
				sb.append(System.getProperty("line.separator"));
			}
		}
		String ans = sb.toString();
		
		System.out.println(ans);
		

	}
}


Measured memory_bytes: 51104
#include <iostream>
#include <iomanip>

#define MAXN 3000

using namespace std;

string s1, s2;
int d[MAXN+1];
int t[MAXN+1][MAXN+1];

void lcs(int pa, int pb, string& ret)
{
    if(pa==0 || pb==0) return;

    switch(t[pb][pa])
    {
        case 0:
            lcs(pa-1, pb, ret);
            break;
        case 1:
            lcs(pa-1, pb-1, ret);
            ret += s1[pa-1];
            break;
        case 2:
            lcs(pa, pb-1, ret);
            break;
    }
}

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

    int temp, temp2;
    cin >> s1 >> s2;
    int l1 = s1.length();
    int l2 = s2.length();

    // make sure s1 shorter than s2
    if(l1 > l2)
    {
        swap(s1, s2);
        swap(l1, l2);
    }
    
    for(int i=1 ; i<=l2 ; i++)
    {
        temp = d[0];
        for(int j=1 ; j<=l1 ; j++)
        {
            if(s2[i-1] == s1[j-1])
            {
                temp2 = d[j];
                d[j] = temp + 1;
                temp = temp2;
                t[i][j] = 1;
            }
            else if(d[j-1] > d[j])
            {
                temp = d[j];
                d[j] = d[j-1];
                t[i][j] = 0;
            }
            else
            {
                temp = d[j];
                t[i][j] = 2;
            }
        }
    }

    string ans;
    lcs(l1, l2, ans);
    cout << ans;

    return 0;
}

Measured memory_bytes: 35584
#include <iostream>

using namespace std;

int main() {
	int A, B, K;
	cin >> A >> B >> K;
	int ans[200];
	// 配列を-1に初期化
	for (int i = 0; i < 200; i++) {
		ans[i] = -1;
	}

	// AからA+Kまでを配列に追加
	for (int i = 0; i < K; i++) {
		ans[i] = A + i;
		if(ans[i] == B) {
			for (int j = 0; j <= i; j++) cout << ans[j] << "\n";
			return 0;
		}
	}

	for (int i = 0; i < K; i++) {
		int tmp = B - K + 1 + i;
		if (tmp <= ans[K - 1]) {
			continue;
		}	
		else {
			ans[i + K] = tmp;	// そうでなければ配列に格納する
		}	
	}

	for (int i = 0; i < 2*K; i++) {
		if(ans[i] == -1) continue;
		cout << ans[i] << "\n";
	}
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<ll, ll, ll> T;

int A, B, C;

int main(void){
    
    scanf("%d %d %d", &A, &B, &C);
    if(A + B >= C) printf("Yes\n");
    else printf("No\n");
    
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
class Main{
public static void main(String[]args){
  Scanner sc=new Scanner(System.in);
  int n=sc.nextInt();
  int[]a=new int[n];
  for(int i=0;i<n;i++)a[i]=sc.nextInt();
  if(n<3){
  System.out.println(0);
  }else{int count=0;
  for(int i=0;i<n-2;i++){
  for(int j=i+1;j<n-1;j++){
  for(int k=j+1;k<n;k++){
  if(!(a[i]+a[j]<=a[k]||a[k]+a[j]<=a[i]||a[i]+a[k]<=a[j])&&(a[i]!=a[j]&&a[k]!=a[i]&&a[k]!=a[j]))count++;
  //else System.out.println(i+" "+j+" "+k);
  }
  }
  }System.out.println(count);
  
  }
}
}


Measured memory_bytes: 37212
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD = 1000000007;
#define INF (1e9)
#define print(x) cout << x << endl;

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; }
typedef pair <ll,ll> P;


int main()
{
    ll A, B, C,D;
    cin >> A >> B >> C >> D;
    print(min(A,B) + min(C,D));
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.PrintWriter;

public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		long[] divisors=new long[n+1];
		for(int i=1; i<=n; i++){
			int mul=1;
			while(mul*i<=n){
				divisors[mul*i]++;
				mul++;
			}
		}
		long ans=0;
		for(int i=1; i<=n; i++){
			ans+=i*divisors[i];
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 116196
#include<bits/stdc++.h>
using namespace std;
int main(){
  int t,n,k;
  cin>>t;
  for(int i=0;i<t;++i){
    int x[100000],sum=0,data[100000];
    cin>>n>>k;
    for(int j=0;j<n;++j)
      cin>>data[j];
    sort(data,data+n);
    for(int j=0;j<n-1;++j){
      sum+=(data[j+1]-data[j]);
      x[j]=data[j+1]-data[j];
    }
    if(n<=k) sum=0;
    else{
      sort(x,x+(n-1),greater<int>());
      for(int j=0;j<k-1;++j)
	sum-=x[j];
    }
    cout<<sum<<endl;
  }
    
  return 0;
}



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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define VIN(v) for(auto&elem_: (v) )cin>>elem_
#define VOUT(v, sep) for(_loop_int idx=0; idx<(_loop_int)v.size(); idx++) {cout<<v[idx]; if(idx<(_loop_int)v.size()-1) cout<<sep;} cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(debugidx,v.size())cout<<" "<<v[debugidx];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(debugidx,n)cout<<" "<<v[debugidx];cout<<endl

const ll MOD = 1000000007ll;
const int IINF = numeric_limits<int>::max()/2-1;
const ll LINF = numeric_limits<ll>::max()/2-1;

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


#define dame { puts("-1"); return 0;}
#define yn {puts("A");}else{puts("a");}

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    char a;
    cin>>a;
    if(a-'a' < 0) yn;
    return 0;
}

Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define RFOR(i,a,b) for(int i = (int)(b-1);i>=(int)(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

signed main(){
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout.precision(20);

  string c;
  cin >> c;
  c[0]++;

  cout << c << endl;

  return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
def main():
    N = int(input())
    A = list(map(int, input().split()))
    X = [0]*(N+1)

    for i in range(1,N+1):
        X[i] += A[i-1] + X[i-1]
    ans  = float('INF') 
    for i in range(1,N):
        ans = min(ans,abs(X[N] - 2*X[i]))
    print(ans)

if __name__ == '__main__':
    main()

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

using namespace std;

int main()
{
    int N, M, X, A, cost1 = 0, cost2 = 0, O[100], a;
    vector<int> v;

    cin >> N >> M >> X;

    while (cin >> A)
    {
        O[a] = A;
        v.push_back(O[a]);
        a++;
    }

    for (int i = X; i < N + 1; i++)
    {
        for (int a = 0; a < v.size(); a++)
        {
            if (i == v[a])
            {
                cost1++;
            }
        }
    }

    for (int i = X; i >= 0; i--)
    {
        for (int a = 0; a < v.size(); a++)
        {
            if (i == v[a])
            {
                cost2++;
            }
        }
    }

    cout << min(cost1,cost2);
}

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

int main () {
  vector<int> a(5);
  rep(i, 5) cin >> a.at(i);
  rep(i, 5) {
    if (a.at(i) == 0) cout << i + 1;
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3616
/*************************************************************************
  >         File: B.cc
  >       Author: lyyllyyl
  >         Mail: riho.yoshioka@yandex.com
  > Created Time: Sat 26 Nov 2016 11:50:36 PM JST
*************************************************************************/
#include <bits/stdc++.h>

int main() {
  std::ios::sync_with_stdio(0);
  int n;
  std::cin >> n;
  int sum = 0;
  for (int i = 1; i <= n; ++i) {
    sum += i;
    if (sum >= n) {
      for (int j = i; j >= 1; --j) {
        if (n >= j) {
          std::cout << j << std::endl;
          n -= j;
        }
      }
      break;
    }
  }

  return 0;
}


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

int main() {
int a,b,c,d,m=0;
cin>>a>>b>>c>>d;
int x=max(a,max(b,max(c,d)));
for(int i=0;i<=x;i++){
	if(i>=a&&i<=b&&i>=c&&i<=d)
	m++;
}
if(m!=0)
cout<<m-1<<endl;
else
cout<<m<<endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));

        }

        public void Solve(ConsoleInput cin)
        {
            var a = cin.ReadInt;
            var b = cin.ReadInt;
            int min = a;
            int max = b;
            if (max < min)
            {
                min = b;
                max = a;
            }
            for(int k=0 ; k < max; k++)
            {
                Console.Write(min);
            }
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

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

#define REP(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define ALL(c) c.begin(), c.end()
#define SZ(c) (int) c.size()
#define DBG1(x) cout<<#x<<" = "<<x<<"\n"
#if USE_CP_REDIR
#define CP \
    freopen("input.txt","r", stdin); \
    freopen("output.txt","w", stdout);
#endif

using ll = long long;
const ll MOD = 1'000'000'007;
const int MN = 1'000'000;

int main()
{
ios::sync_with_stdio(false);
#ifdef CP
    CP;
#endif
int n, x, t;
cin >> n >> x >> t;
cout << (n + x - 1)/x * t << endl;

}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define endl '\n'
#define PI 3.14159265358979323844
#define DECIMAL(n)  std::cout << std::fixed;std::cout << std::setprecision(n);
#define mp make_pair
#define pb push_back
#define int long long int 
#define forr(i,a,b) for (int i= a; i <b; ++i)
    using namespace std; 
   int weight[1000]; 
   int price[1000];
   int dp[100005][200];
    int knapsack(int W ,int n){
    if(W<=0 || n<0)return 0;
        if(dp[W][n]!=-1)return dp[W][n];
        if(W>=weight[n]){
        dp[W][n]=  max( knapsack(W-weight[n],n-1)+price[n] , knapsack(W,n-1)); }
     else    dp[W][n]=   knapsack(W,n-1);
        return dp[W][n];
    }
           
           
    signed main(){
     int n;cin>>n;
     memset(dp , -1 , sizeof dp);
     int W;cin>>W;
    forr(i,0,n){cin>>weight[i];cin>>price[i];}
    cout<<knapsack(W,n-1);}
        
        
        
       

Measured memory_bytes: 156544
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define mod 1000000007
typedef long long int ll;
int u(const void *a, const void *b){
    return *(ll*)a-*(ll*)b;
}
int d(const void *a, const void *b){
    return *(ll*)b-*(ll*)a;
}
int z(int a){
  if(a<1)a*=-1;
  return a;
}
int min(int a,int b){
  if(a>b)return b;
  return a;
}
int max(int a,int b){
  if(a>b)return a;
  return b;
}
int gcd(int a,int b){
  if(!b)return a;
  return gcd(b,a%b);
}
int kt(ll a){
  int sum=0;
  while(a){
    a/=10;
    sum++;
  }
  return sum;
}
int ks(ll a){
  int sum=0;
  while(a){
    sum+=a%10;
    a/=10;
  }
  return sum;
}
int x[100000];
int main(void){
  int n;
  ll k,q;
  scanf("%d %lld %lld",&n,&k,&q);
  int a;
  for(ll i=0;i<q;i++){
    scanf("%d",&a);
    x[a-1]++;
  }
  FOR(n){
    if(x[i]>q-k){
      PRS("Yes");
    }else{
      PRS("No");
    }
  }
  return 0;
}

Measured memory_bytes: 896
#include <iostream>
using namespace std;
int main () {
    string S, T;
    cin >> S >> T;
    int cnt=0;
    for (int i=0; i<S.size(); i++) {
        if (S[i]==T[i]) {
            cnt++;
        }
    }
    if (cnt==S.size()) {
        cout << "Yes" << endl;
    }
    else {
         cout << "No" << endl;
    }
}

Measured memory_bytes: 3652
import Foundation

extension String {
    func split(separator: String) -> [Int] {
        return self.componentsSeparatedByString(separator).map { Int($0)! }
    }
}

let input = readLine()!.split(" ")
let N = input[0]
let M = input[1]

var AB = [[Int]]()
for _ in 0..<N {
    let input = readLine()!.split(" ")
    AB.append([input[0], input[1]])
}
AB.sortInPlace{$0[0] < $1[0]}

var ans = 0
var i = 0
var j = 0
for _ in 0..<M {
    if i+1 > AB[j][1] {
        j += 1
      	i = 0
    }
    ans += AB[j][0]
  	i += 1
}

print(ans)

Measured memory_bytes: 10212
n = int(input())
a = list(map(int,input().split()))
sum = sum(a)
s = [0]
d = []
q = 0
for i in range(n-1):
    q = s[i]+a[i]
    s.append(q)
    d.append(abs(sum-2*q))

print(min(d))

Measured memory_bytes: 101072
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#define rep(i,a,b) for(int i=(a);i<(b);++i)
using namespace std;

int a[200005];
long long pre[200005];
int main ()
{
	int n;
	long long temp=0;
	scanf("%d",&n);
	rep(i,0,n) {
		scanf("%d",&a[i]);
		temp+=a[i];
		pre[i]=temp;
	}
	long long x,y,min=3000000000;
	rep(i,0,n-1) {
		x=pre[i];
		y=pre[n-1]-pre[i];
		if (fabs(x-y)<min) 
			min=fabs(x-y);
	}
	printf("%lld\n",min);

	return 0;
}

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

void solve()
{
    long long a,b,c,d;
    cin >> a >> b >> c >> d;
    long long ans = a*c;
    ans = max(ans, a*d);
    ans = max(ans, b*c);
    ans = max(ans, b*d);
    cout << ans << endl;
}

int main()
{
    cin.tie();
    ios::sync_with_stdio(false);
    // int ti = clock();
    // input();
    solve();
    // printf("Execution Time: %.4lf sec\n", 1.0 * (clock() - ti) / CLOCKS_PER_SEC);
    return 0;
}

Measured memory_bytes: 3648
from heapq import *
N,M = [int(x) for x in input().split()]

dic = {}
for m in range(1,M+1):
    dic.setdefault(m,[])
for _ in range(N):
    A,B = [int(x) for x in input().split()]
    if A <= M: dic.setdefault(A, []).append(B)

h = []
ans = 0
for m in dic.keys():
    for b in dic[m]:
        heappush(h, -b)
    if h:
        ans += -heappop(h)
print(ans)

Measured memory_bytes: 27108
#include <iostream>

using namespace std;

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

    int c = (b / n) * n;

    if (c >= a) {
        cout << "OK" << endl;
    } else {
        cout << "NG" << endl;
    }

    return 0;
}

Measured memory_bytes: 3636
from itertools import accumulate
n, k = map(int,input().split())
P = list(map(lambda x:(int(x)+1)/2,input().split()))
A = list(accumulate([0]+P))
B = []
for i in range(n-k+1):
    B.append(A[i+k]-A[i])

print(max(B))

Measured memory_bytes: 23896
#! usr/bin/env python
# -*- coding: utf-8 -*-

from collections import deque
import heapq
import math
import bisect


def main():
    N = int(input())
    ans = 0

    p = 1
    while p * p <= N:
        if N % p == 0:
            d = N // p
            if p + 1 < d:
                ans += d - 1
        p += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38768
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>       // for next_permutation
#include <vector>
#include <cstdlib>
#define INF 998244353

using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pi;

const ll MOD = 1e9+7;

static long gcd(long a, long b) {
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}
/*
long long int facctorialMethod(int k){//階乗
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}*/

long long int tousasum(long long int n){//等差数列
    return n*(n+1)/2;
}

unsigned GetDigit(unsigned num){//桁数
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}

bool is_prime(const unsigned n){
    switch(n){
        case 0: // fall-through
        case 1: return false;
        case 2: // fall-through
        case 3: return true;
    } // n > 3 が保証された

    if(n%2 == 0) return false;
    if(n%3 == 0) return false;
    // 2と3の倍数でないので6の倍数ではないことが保証された

    if(n%6 != 1 && n%6 != 5) return false;
    // 6の倍数前後の数(素数かもしれない数)であることが保証された

    // 6の倍数前後の数を使って試し割りをする
    for(unsigned i=5;i*i<=n;i+=6){
        if(n%i     == 0) return false; // 6n-1
        if(n%(i+2) == 0) return false; // 6n+1
    }

    return true;
}

map< ll, ll > prime_factor(ll n) {//素因数分解
    map< ll, ll > ret;
    for(ll i = 2; i * i <= n; i++) {
        while(n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if(n != 1) ret[n] = 1;
    return ret;
}

ll calcNumOfCombination(ll n, ll r){
    ll num = 1;
    for(ll i = 1; i <= r; i++){
        num = num * (n - i + 1) / i;
    }
    return num;
}

int bubblesort(vector<int> array,int size){//バブルソート　転倒数
    int kaisu = 0;
    for(int i = 0; i < size; i++){
        for(int j = i + 1; j < size; j++){
            if(array[i] > array[j]){
                int number = array[i];
                array[i] = array[j];
                array[j] = number;
                kaisu++;
            }
        }
    }
    return kaisu;
}

ll facctorialMethod(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum = (sum * i)%MOD;
    }
    return sum;
}

// nPnの順列に対して処理を実行する
void foreach_permutation(int n, std::function<void(int *)> f) {
    int indexes[n];
    for (int i = 0; i < n; i++) indexes[i] = i;
    do {
        f(indexes);
    } while (std::next_permutation(indexes, indexes + n));
}





int main() {
  int N,M;
  cin >> N >> M;
  string s = "";
  for(int i=0;i<max(N,M);i++){
      s+=to_string(min(N,M));
  }
  cout << s << endl;
}













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

using namespace std;
using ll = long long int;

int main() {
  ll a, b, k;
  cin >> a >> b >> k;
	cout << max(a - k, 0LL) << " " <<  max(b - max(k - a, 0LL), 0LL) << endl;
}


Measured memory_bytes: 256
const main = stdin => {
  const input = stdin.trim().split('\n')
  const N = parseInt(input[0])

  for (let i = 0; i <= 25; i++) {
    for (let j = 0; j <= 14; j++) {
      if (4 * i + 7 * j === N) {
        console.log('Yes');
        return
      }
    }
  }

  console.log('No')
}


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


Measured memory_bytes: 29536
#include <iostream>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
using namespace std;
int main(void){
    int n,i,j;
    string s;
    cin>>s;
    if(s[s.length()-1]=='s'){
        s+="es";
    }else{
        s+="s";
    }
    cout<<s;
}


Measured memory_bytes: 3620
#include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x);
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 1000000000;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={0, 1, 0, -1}, dy[4]={-1, 0, 1, 0};
using namespace std;
//typedef pair<int, int> P;
struct P {
	int x, y;
	P(int x, int y):x(x), y(y){}
	P(){}
};

/** Problem2584 : Broken Cipher Generator **/
string s;
int p;

string String();
char Letter();

string Cipher()
{
	string res;
	while (1) {
		if (p>=s.size()) {
			break;
		}
		
		res += String();
	}
	return res;
}

string String()
{
	if (s[p]=='[') {
		p++;
		
		string t;
		while (s[p]!=']')
			t+=String();
		
		string res;
		for (int i=(int)t.size()-1; i>=0; i--) {
			res += t[i];
		}
		
		p++;
		return res;
	} else {
		string res; res+=Letter();
		return res;
	}
}


char Letter()
{
	if (s[p]=='+') {
		p++;
		char c = Letter();
		if (c=='Z') return 'A';
		else		return (char)(c+1);
	} else if (s[p] == '-') {
		p++;
		char c = Letter();
		if (c=='A') return 'Z';
		else		return (char)(c-1);
	} else {
		return s[p++];
	}
}


int main()
{
	string t;
	while (cin>>t, t!=".") {
		p = 0;
		int tt=0;
		s="";
		
		rep(i, t.size()) {
			if (t[i]=='-' || t[i]=='+') {
				tt++;
			} else if (('A' <= t[i] && t[i] <= 'Z') || t[i]=='[' || t[i]==']') {
				for (int j=i-tt; j<=i; j++) {
					s+=t[j];
				}
				tt = 0;
			} else if (t[i]=='?') {
				s+='A';
				tt = 0;
			}
		}
		cout << Cipher() << endl;
	}
}

Measured memory_bytes: 1200
from collections import Counter
s = input()[::-1]
cnt = [0]
d = 0
mod = 2019

for i in s:
    tmp = int(i) * pow(10, d, mod) % mod
    tmp = cnt[-1] + tmp
    cnt.append(tmp % mod)
    d += 1

cnt = Counter(cnt)
ans = sum(j * (j - 1) // 2 for j in cnt.values())
print(ans)

Measured memory_bytes: 16620
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = a; i < b; ++i)

using namespace std;

int n, k, a[200005], b[200005], temp, cnt, nm, sum;

int main() {
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	temp = n;
	cnt = 0;
	while(1) {
		cnt++;
		temp /= 2;
		if (temp == 0) break;
	}
	nm = n - 1;
	if (k > 50) {
		for (int i = 0; i < n; i++) {
			cout << n << " \n"[i == n - 1];
		}
		return 0;
	}
	else {
		for (int i = 0; i < k; i++) {
			memset(b, 0, sizeof(b));
			for (int j = 0; j < n; j++) {
				b[max(0, j - a[j])]++;
				b[min(n, j + a[j] + 1)]--;
			}
			sum = 0;
			FOR(j,0,n) {
				sum += b[j];
				a[j] = sum;
			}
		}
	}
	for (int i = 0; i < n; i++) {
		cout << a[i] << " \n"[i == n - 1];
	}
}

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

using namespace std;

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

    vector<long long> sum(N + 1);
    for (int index = 0; index < N; index++) {
        long long input;
        cin >> input;

        sum[index + 1] = sum[index] + input;
    }

    vector<vector<long long>> partial_cost(N + 1, vector<long long> (N + 1));
    for (int row = N; row >= 1; row--)
        for (int col = row + 1; col <= N; col++) {
            long long cost = LLONG_MAX;
            for (int div = row; div < col; div++)
                cost = min(cost, partial_cost[row][div] + partial_cost[div + 1][col] + sum[col] - sum[row - 1]);
            partial_cost[row][col] = cost;
        }

    cout << partial_cost[1][N];
}


Measured memory_bytes: 1536
#include<iostream>
#include<cmath>
using namespace std;
long long n;
int main()
{
    cin>>n;
    for(int i=sqrt(n);i>=1;i--)
    {
        if(n%i==0)
        {
            int t=i,l=n/i;
            int s=1;
            while(l>=10){
                s++;
                l/=10;
        }
        cout<<s;
        return 0;
        }
    }
}

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

#define REPI(i, n) for(int i = 0; i < n; i++)
#define REPJ(j, n) for(int j = 0; j < n; j++)

using ll = long long;
using namespace std;

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

    ll a, b; char c; cin >> a >> c >> b;
    cout << (c == '+' ? a + b : a - b);
}


Measured memory_bytes: 256
n,w = map(int, input().split())
item = [list(map(int,input().split())) for i in range(n)]
dp = [0 for i in range(w+2)]
for i in range(w+1):
    for v in item:
        if i+v[1] <= w:
            dp[i+v[1]] = max(dp[i+v[1]], dp[i]+v[0])
print(dp[w])


Measured memory_bytes: 5924
import bisect
A, B, Q = map(int, input().split())
INF=10**18
s =[-INF] + [int(input()) for i in range(A)] + [INF]
t =[-INF] + [int(input()) for i in range(B)] + [INF]
for q in range(Q):
  x = int(input())
  b, d = bisect.bisect_right(s, x), bisect.bisect_right(t, x) 
  res = INF
  for S in [s[b - 1], s[b]]:
    for T in [t[d - 1], t[d]]:
      d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T) 
      res = min(res, d1, d2)
  print(res)

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

map<long, int> mp;
int main() {
	int N; long a; cin >> N;
	for(int i=0; i<N; ++i){
	    cin >> a;
	    ++mp[a];
	}
	int ans=0;
	auto itr=mp.end();
	while(itr!=mp.begin()){
	    --itr;
	    long sum=1;
	    while(sum<=itr->first) sum *= 2;
	    sum -= itr->first;
	    if(sum==itr->first){
	        ans += mp[sum]/2;
	    }
	    else{
	        ans += min(itr->second, mp[sum]);
	        mp[sum] -= min(itr->second, mp[sum]);
	    }
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 85504