akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;
using itn = int;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i >= (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define itn int
#define double ld
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl lcm(intl a,intl b){
    return a / gcd(a, b) * b;
}
intl digit10(intl a){
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl n,m;
    cin >> n;
    cout << n / 3 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>

#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <utility>
#include <array>

#include <boost/format.hpp>
#include <boost/range/irange.hpp>

int main() {
   std::string s;
   std::cin >> s;
   int result = 0;
   for (unsigned int i = 0; i < s.length() / 2; i++) {
      if (s[i] == s[s.length() - i - 1]) {
         continue;
      }
      result++;
   }
   std::cout << result << std::endl;
   return 0;
}


Measured memory_bytes: 760
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMaximum(Node x){
  while(x->right!=NIL)x=x->right;
  return x;
}

Node treeMinimum(Node x){
  while(x->left!=NIL)x=x->left;
  return x;

}

Node treeSuccessor(Node x){
  Node y;
  if(x->right!=NIL)return treeMinimum(x->right);

  y=x->parent;
  while(y!=NIL && x==y->right){
    x=y;
    y=y->parent;
  }
  return y;
}

void insert(int w){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = w;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y=x;
    if(z->key<x->key)
      x=x->left;
    else x=x->right;
  }
  z->parent=y;

  if(y==NIL)
    root=z;
  else if(z->key<y->key)
    y->left=z;
  else
    y->right=z;
    
}

void inParse(Node u){
  if(u==NIL){
      return;
  }
  printf(" %d",u->key);
  inParse(u->left);
  inParse(u->right);
}

void preParse(Node u){
  if(u==NIL){
      return;
  }
  preParse(u->left);
  printf(" %d",u->key);
  preParse(u->right);
}


int main(){
  int a,b,c,i;
  char d[20];
  scanf("%d", &a);

  for ( i = 0; i < a; i++ ){
    scanf("%s", d);
    
if ( d[0] == 'i' ){
      scanf("%d", &b);
      insert(b);
    } else if ( d[0] == 'p' ){
      preParse(root);
      printf("\n");
      inParse(root);
      printf("\n");
    } 
  }

  return 0;
}


Measured memory_bytes: 25152
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    ll n, x;
    cin >> n >> x;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    ll ans = 0;
    rep(i, n) {
        if (i==0) {
            ll z = a[i] - x;
            chmax(z, 0LL);
            a[i] -= z;
            ans += z;
            continue;
        }
        ll now = a[i] + a[i-1];
        ll z = now - x;
        chmax(z, 0LL);
        a[i] -= z;
        ans += z;
    }
    
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4028
#include <iostream>
#include <math.h>
#include <vector>
using namespace std;
#define endl '\n'


using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    long long int N,K;
    cin >> N >> K;
    long long int result=0,i=0;
    while((N-K+1-i)*(K+i)+1>0){
        result+=(N-K+1-i)*(K+i)+1;
        i++;
    }
    cout << result%(1000000000+7);
    return 0;
}

Measured memory_bytes: 3612
<?php
while ($line = fgets(STDIN)) {
   $array1[] = trim($line);
}
$array = explode(" ",$array1[0]);
$sum = 0;
function unchi ($z){
  $sum = 0;
  while($z>0){
    $sum = $sum + $z%10;
    $z= $z/10;
}
  return $sum;
}
$total = 0;
$aa = 0;
  for($i = 1; $i<=$array[0]; $i++){
    $aa = unchi($i);
    if($aa<=$array[2] && $aa>=$array[1]){
      $total = $i + $total;
    }
  }
  echo $total;
    
?>

Measured memory_bytes: 16256
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")

def main():
    n, x = map(int, input().split())
    while (n, x) != (0, 0):
        ans = 0
        for b in range(1, n + 1):
            for a in range(max(1, x - b - n), b):
                c = x - b - a
                if c <= b: break
                #if c > n: continue
                # print(a,b,c)
                ans += 1
        print(ans)
        n, x = map(int, input().split())

main()



Measured memory_bytes: 5608
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n;
  cin >> n;
  map<P,ll> m;
  REP(i,1,n+1) {
    string s;
    stringstream ss;
    ss << i;ss >> s;
    int x=s[0]-'0',y=s.back()-'0';
    m[P(x,y)]++;
  }
  ll ans=0;
  REP(i,1,n+1) {
    string s;
    stringstream ss;
    ss << i;ss >> s;
    int x=s[0]-'0',y=s.back()-'0';
    ans+=m[P(y,x)];
  }
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


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

lli n;

int main(void){
    cin >> n;
    vector<lli> a(n);
    rep(i, n) cin >> a[i];
    vector<lli> l(n), r(n);
    rep(i, n){
        l[i] = i+a[i];
        r[i] = i-a[i];
    }
    unordered_map<lli, lli> mpl, mpr;
    unordered_map<lli, bool> mpg;
    rep(i, n) mpl[l[i]]++, mpg[l[i]] = true;
    rep(i, n) mpr[r[i]]++, mpg[r[i]] = true;
    lli ans = 0;
    for(auto i : mpg){
        ans += mpl[i.first]*mpr[i.first];
    }
    cout << ans << endl;
    return 0;
}


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


int main(void)
{
    int n,t,a;
    int h[1100];
    cin >> n;
    cin >> t >> a;
    for(int i = 0;i < n;i++) cin >> h[i];
    
    int ans;
    double min = 100000;
    for(int i = 0;i < n;i++) {
        double th = abs(a - (t - h[i] * 0.006));
        if (min > th) {
            ans = i+1;
            min = th;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
#define M 1000000007
int main(){
  int n,m,k,a,c=0;
  cin>>n>>m;
  map<int,int> ma;
  for(int i=0;i<n;i++){
    cin>>k;
    for(int j=0;j<k;j++){
      cin>>a;
      ma[a]++;
    }
  }
  for(int i=1;i<=m;i++){
    if(ma[i]==n) c++;
  }
  cout<<c;
}

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

using namespace std;
using ll = long long;
constexpr int mo = 1e9+7;
constexpr int  mod = mo;
constexpr ll inf = 1ll<<50;
constexpr int infi= 1<<30;
int main(){
    int n,m;
    cin>>n>>m;
    vector<vector<int>> c(100050);
    for(int i=0;i<n;++i){
        int a,b;
        cin>>a>>b;
        c[a].push_back(b);
    }
    priority_queue<ll> q;
    ll ret = 0ll;
    for(int i=1;i<=m;++i){
        for(auto cur : c[i]){
            q.push(cur);
        }
        if(q.size()){
            ret += q.top();
            q.pop();
        }
    }
    cout << ret << endl;
    return 0;
}



Measured memory_bytes: 5632
#include "bits/stdc++.h"
#define INT long long
using namespace std;

int main()
{
    int n;
    cin >> n;
    long long f[n+1];
    for(int i=0;i<n+1;i++){
        if(i==0) f[i]=2;
        else if(i==1) f[i]=1;
        else f[i]=f[i-1]+f[i-2];
    }
    cout << f[n] << endl;
    return 0;
}


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

int main(void) {
	int a, b, c; cin >> a >> b >> c;
	if (a == b && a != c) {
		cout << "Yes" << endl;
	}
	else if (a == c && a != b) {
		cout << "Yes" << endl;
	}
	else if(b ==c && a != b ){
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;

const ll mod = 1000000007;

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

  int n, m;
  cin >> n >> m;
  vector<ll> d(n);
  for (auto &x: d) cin >> x;
  vector<vector<Pii> > edge(n);
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    edge[u-1].emplace_back(v-1, i);
    edge[v-1].emplace_back(u-1, i);
  }

  vector<bool> decided(m);
  vector<bool> isBlack(n);
  vector<ll> cost(m, 1000000000);
  priority_queue<Pii, vector<Pii>, greater<Pii> > que;
  for (int i = 0; i < n; i++) que.emplace(d[i], i);
  while (!que.empty()) {
    auto now = que.top();
    que.pop();
    if (decided[now.second]) continue;
    bool good = false;
    for (auto &x: edge[now.second]) {
      if (decided[x.first] && isBlack[x.first]) {
        cost[x.second] = d[now.second];
        decided[now.second] = true;
        good = true;
        break;
      }
    }
    if (good) continue;
    for (auto &x: edge[now.second]) {
      if (decided[x.first] && d[x.first] < d[now.second]) {
        cost[x.second] = d[now.second] - d[x.first];
        decided[now.second] = true;
        good = true;
        break;
      }
    }
    if (good) continue;
    for (auto &x: edge[now.second]) {
      if (!decided[x.first] && d[x.first] == d[now.second]) {
        cost[x.second] = d[now.second];
        isBlack[x.first] = true;
        decided[x.first] = true;
        decided[now.second] = true;
        good = true;
        break;
      }
    }
    if (good) continue;
    for (auto &x: edge[now.second]) {
      if (decided[x.first] && d[x.first] >= d[now.second]) {
        cost[x.second] = d[now.second];
        isBlack[now.second] = true;
        decided[x.first] = true;
        decided[now.second] = true;
        good = true;
        break;
      }
    }
    if (good) continue;
    cout << -1 << endl; // impossible
    return 0;
  }

  for (int i = 0; i < n; i++) {
    if (isBlack[i]) cout << "B";
    else cout << "W";
  }
  cout << endl;

  for (auto &x: cost) cout << x << endl;

  return 0;
}


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    int N,K; cin >> N >> K;
    map<int,int> A;
    REP(i,N){
        int a; cin >> a;
        A[a]++;
    }

    priority_queue<int, vector<int>, greater<int>> ball;
    for(auto i: A){
        ball.push(i.second);
    }

    int ans = 0;
    if(ball.size() <= K){
        cout << 0 << endl;
    }else{
        REP(i,K-ball.size()){
            ans += ball.top(); ball.pop();
        }
        cout << ans << endl;
    }

    return 0;
}

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

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

  int sum = 0;
  int l, r;

  for (int i = 0; i < N; i++) {
    cin >> l >> r;
    sum += r - l + 1;
  }

  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long M = sc.nextLong();
		long ans = M / N;
		while(true) {
			long res = M - N * ans;
			if(res % ans == 0) {
				break;
			}
			ans--;
		}
		System.out.println(ans);
	}

}


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

#define max 1299709
using namespace std;

int main(void){
	//FILE* fp_in = freopen("data.txt", "r", stdin);

	//■■■■素数テーブル作成(エラトステネスのふるい)■■■■
	vector<bool> pt;
	for(int i = 0; i <= max; i++)
		pt.push_back(true);

	pt.at(0) = false;
	pt.at(1) = false;

	for(int i = 2; i <= max; i++)
		for(int j = i * 2; j <= max; j += i)
			pt.at(j) = false;

	//■■■■素数リスト作成■■■■
	vector<int> plist;
	for(int i = 0; i <= max; i++)
		if( pt.at(i) == true ) plist.push_back( i );


	while(1) {
		int n;
		cin >> n;
		if( n == 0 ) break;


		//n以下で最大の素数を調べる
		int p;
		for(int i = 0; i < plist.size() && plist.at(i) <= n; i++)
			p = plist.at(i);

		if( pt.at(n) == true ) {
			cout << 0 << endl;
		} else {
			int ans = 1;
			for(int i = p + 1; pt.at(i) == false; i++) 
				ans ++;
			cout << ans << endl;
		}
	}

	//while(1){}

	return 0;
}

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

typedef long long int64;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;

int main() {
  int H, W, K;
  std::cin >> H >> W >> K;
  std::vector<string> c(H);
  REP(i, H) std::cin >> c[i];

  int answer = 0;
  REP(i, 1 << H) {
    REP(j, 1 << W) {
      int count = 0;
      REP(h, H) {
        REP(w, W) {
          if (i & (1 << h) || j & (1 << w))
            continue;
          if (c[h][w] == '#')
            count++;
        }
      }
      if (count == K)
        answer++;
    }
  }
  std::cout << answer << std::endl;
  return 0;
}


Measured memory_bytes: 3632
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []

    while True:
        d,e = LI()
        if d == 0:
            break
        r = inf
        for i in range(d//2+1):
            j = d - i
            tr = abs(e - (i**2+j**2)**0.5)
            if r > tr:
                r = tr
        rr.append(r)

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


print(main())




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

int main() {
  string s,t;
  cin >> s >> t;
  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  reverse(t.begin(),t.end());
  if(s<t) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
program Project1;
     
{$APPTYPE CONSOLE}
     
uses
  SysUtils;
var
  a,h,w,i,j,count,x,y,sw,m,n,b,c,soeji,sum,max,k,min:Integer;
  l:array of Integer;
  s,s123,s1,s2,s3:string;
  al:string = 'abcdefghijklmnopqrstuvwxyz';
  tf,tfl,tfr:Boolean;
begin
  try
    { TODO -oUser -cConsole メイン : ここにコードを記述してください }
    Readln(a);
    count:=0;
    max  :=0;
    min  :=100;

    if (a=1 )or
       (a=2 )or
       (a=3 )or
       (a=5 )or
       (a=6 )or
       (a=9 )or
       (a=10)or
       (a=13)or
       (a=17)  then
      Writeln('No')
    else
      Writeln('Yes');
    Readln;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBAG = false;

int main(){

    string s, t;
    cin >> s;
    cin >> t;

    vector<string> ans;
    for(int i = 0; i < s.size(); i++){        
        bool flag = true;
        int id = 0;
        if(i + t.size() > s.size() ) continue;
        for(int j = 0; j < t.size(); j++){
            if(t[j] != s[i + j] && s[i + j] != '?'){
                flag = false;
                break;
            }
        }
        if(flag){
            string u;
            for(int k = 0; k < s.size(); k++){
                if(i <= k && k < i + t.size()  ){
                    u.push_back( t[k-i] );
                }
                else{
                    if(s[k] == '?' ) u.push_back('a');
                    else u.push_back(s[k]);
                }
            }
            ans.push_back(u);
        }
    }

    if(ans.size() == 0 ) cout << "UNRESTORABLE" << endl;
    else {
        sort(all(ans));
        cout << ans[0] << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void) {
    int i,j;
    char t[25];
    scanf("%s",t);
    j=strlen(t)-1;
    for(j;j>=0;j--){
        printf("%c",t[j]);
    }
    printf("\n");
    return 0;
}

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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;

static constexpr ll LL_INF = 1LL << 60;
static constexpr int I_INF = 1 << 28;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);

int main(int argc, char* argv[]) {
  long long N;
  scanf("%lld", &N);
  long long A;
  scanf("%lld", &A);
  long long B;
  scanf("%lld", &B);

  cout << min(N * A, B) << endl;
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

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;
}

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define LL long long
template<class T> inline void chmax(T & a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> void print_vector(vector<T> vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << vec[i] << " ";
	}
	cout << "]" << endl;
}
template<class T> void print_pair_vector(vector<pair<T, T> > vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << "(" << vec[i].first << "," << vec[i].second << ") ";
	}
	cout << "]" << endl;
}

int main(void) {
	int K, S;
	cin >> K >> S;
	
	int count = 0;
	for (int i = 0; i <= K; i++){
		for (int j = 0; j <= K; j++){
			int k = S - i - j;
			if (0 <= k and k <= K) {
				count++;
			}
		}
	}

	cout << count << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  string S;
  cin>>N>>S;
  if(N%2==1)
    cout<<"No"<<endl;
  else{
    bool flag=true;
    for(int i=0;i<N/2;i++){
      if(S.at(i)!=S.at(i+N/2)){
        flag=false;
        break;
      }
    }
    if(flag==true)
      cout<<"Yes"<<endl;
    else
      cout<<"No"<<endl;
  }
}

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

#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define mod 1000000007
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
#define all(x) (x).begin(), (x).end()

typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> pi;

bool prime(ll n)
{
    if(n<=1)return false;
    if(n<=3)return true;
    if(n%2==0||n%3==0)return false;
    for(ll i=5;i*i<=n;i+=6)
    {
        if(n%i==0||n%(i+2)==0)return false;
    }
    return true;
}

ll modexp(ll a,ll b,ll m)
{
    ll r=1;
    a=a%m;
    while(b>0)
    {
        if(b&1)r=(r*a)%m;
        b = b>>1;
        a=(a*a)%m;
    }
    return r%m;
}
bool comp(pair<ll,ll>a,pair<ll,ll>b)
{
    return a.fi>b.fi;
}
ll a,b,c,d;
map<ll,ll>mmp;
ll solve(ll n)
{
    if(n==0)return 0;
    if(n==1)return d;
    if(mmp.count(n))return mmp[n];
    ll ans = 1e18;
    if(n<ans/d)ans=n*d;

    ll l2 = (n/2)*2,r2=((n+1)/2)*2;
    ll l3=(n/3)*3,r3=((n+2)/3)*3;
    ll l5=(n/5)*5,r5=((n+4)/5)*5;

    ans=min(ans,llabs(l2-n)*d+a+solve(l2/2));
    ans=min(ans,llabs(r2-n)*d+a+solve(r2/2));

    ans=min(ans,llabs(l3-n)*d+b+solve(l3/3));
    ans=min(ans,llabs(r3-n)*d+b+solve(r3/3));

    ans=min(ans,llabs(l5-n)*d+c+solve(l5/5));
    ans=min(ans,llabs(r5-n)*d+c+solve(r5/5));

    mmp[n] = ans;
    return ans;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
ll t; cin>>t;
while(t--)
{
    mmp.clear();
    ll n; cin>>n;
    cin>>a>>b>>c>>d;
    cout<<solve(n)<<endl;
}
return 0;

}
/*
1
4
4 2
10 3
3 4
9 2
*/


Measured memory_bytes: 4380
import java.util.*;

class Main {
    public static void main(String[] args) {
        new Main().main();
    }

    public void main() {
        Scanner scanner = new Scanner(System.in);
        int n = Integer.parseInt(scanner.nextLine());
        String[] line = scanner.nextLine().split(" ", n);

        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = Integer.parseInt(line[i]);
        }

        int index = this.partition(arr, 0, n-1);
        for (int i = 0; i < n; i++) {
            if (i == index) {
                System.out.printf("[%d]", arr[i]);
            } else {
                System.out.print(arr[i]);
            }

            if (i == n - 1) {
                System.out.print("\n");
            } else {
                System.out.print(" ");
            }
        }
    }

    private int partition(int[] arr, int p, int r) {
        int x = arr[r];
        int i = p - 1;

        for (int j = p; j < r; j++) {
            if (arr[j] <= x) {
                i++;
                int tmp = arr[i];
                arr[i] = arr[j];
                arr[j] = tmp;
            }
        }

        int tmp = arr[i+1];
        arr[i+1] = arr[r];
        arr[r] = tmp;
        return i + 1;
    }
}



Measured memory_bytes: 63848
N = int(input())
pl = []
mi = []

for i in range(N):
    _m = 0
    _t = 0
    s = input()
    for c in s:
        if c == ")":
            _t -= 1
            _m = min(_m, _t)
        else:
            _t += 1
    if _t > 0:
        pl.append([-_m, -_t]) # sortの調整のために負にしている
    else:
        mi.append([- _t + _m,  _m, _t])
pl = sorted(pl)
mi = sorted(mi)

#import IPython;IPython.embed()


if len(pl) == 0:
    if mi[0][0] == 0:
        print("Yes")
    else:
        print("No")
    exit()
if len(mi) == 0:
    print("No")
    exit()

tot = 0
for m, nt in pl:
    if tot - m < 0: # これはひくではないのでは?
        print("No")
        exit()
    else:
        tot -= nt
for d, m, nt in mi:
    if tot + m <0:
        print("No")
        exit()
    else:
        tot += nt
if tot != 0:
    print("No")
else:
    print("Yes")
        



# どういう時できるか
# で並べ方
# tot, minの情報が必要
# totが+のものはminとtotを気をつける必要がある
# minがsum以上であればどんどん足していけばいい.
# なのでminが大きい順にsortし,totの大きい順にsort
# その次はtotがminusの中ではminが小さい順に加える
# 合計が0になる時Yes,それ意外No.

Measured memory_bytes: 187360
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <list>
#include <queue>
#include <cmath>
#include <numeric>
using namespace std;

int inf = (1 << 30);
int mod = 1e9 + 7;
int64_t inf64 = (1LL << 60);

template <typename T>
T gcd(T a, T b) {
    if(b == 0) return a;
    else return gcd(b, a % b);
}

template <typename T>
T lcm(T a, T b) {
    T g = gcd(a, b);
    return a / g * b;
}

bool check(vector<int> a, int index, int key){
    if(a[index] >= key) return true;
    else return false;
}

int lower_bound(vector<int> a, int key){
    int left = -1, right = a.size();
    while(right - left > 1){
        int mid = left + (left + right) / 2;
        if(check(a, mid, key)) right = mid;
        else left = mid;
    }
    return right;
}

int main(){

    int N, M;
    cin >> N >> M;
    vector<int> L(M), R(M);
    for(int i = 0; i < M; i++) cin >> L[i] >> R[i];

    int Rmin = *min_element(R.begin(), R.end()), Lmax = *max_element(L.begin(), L.end());

    if(Rmin - Lmax + 1 < 0) cout << 0 << endl;
    else cout << Rmin - Lmax + 1 << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <iomanip>

using namespace std;
typedef long long ll;
using Pll = pair<ll,ll>;

const ll INF = 1LL<<60;
const ll MOD = 1000000007;

//cout << fixed << setprecision(10);

int main() {
    ll N,x;
    cin >> N >> x;
    if(x==2*N-1 || x==1){
        cout << "No" << endl;
        return 0;
    }
    else cout << "Yes" << endl;

    deque<ll> ans;
    set<ll> se;
    if(x!=2){
        ans.push_back(x-1); se.insert(x-1);
        ans.push_back(x+1); se.insert(x+1);
        ans.push_back(x);   se.insert(x);
        ans.push_back(x-2); se.insert(x-2);
        for(int i=1;i<=2*N;i++){
            if(se.count(i)==1) continue;
            if(ans.size()<N+2){
                ans.push_front(i);
            }
            else ans.push_back(i);
        }
    }
    else{
        ans.push_back(x+1); se.insert(x+1);
        ans.push_back(x-1); se.insert(x-1);
        ans.push_back(x);   se.insert(x);
        ans.push_back(x+2); se.insert(x+2);
        for(int i=1;i<=2*N;i++){
            if(se.count(i)==1) continue;
            if(ans.size()<N+2){
                ans.push_front(i);
            }
            else ans.push_back(i);
        }
    }

    for(int i=0;i<2*N-1;i++){
        cout << ans[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 3200
#include <cstdio>
#include <cstring>

typedef long long ll;

inline ll abs(ll x){ return x>0?x:-x; }

ll x[1010],y[1010],len[33];

int main() {
    int n; scanf("%d", &n);
    for(int i = 1; i <= n; i++) {
    	scanf("%lld%lld", &x[i], &y[i]);
    }
    int tmp = abs(x[1] + y[1]) & 1;
    for(int i = 1; i <= n; i++)
        if((abs(x[i] + y[i]) & 1) != tmp)
            return puts("-1"), 0;
    printf("%d\n1", 32 - tmp);
    len[1] = 1; int N = 1;
    if(tmp) {
        for(int i = 1; i <= 30; i++) printf(" %d", len[++N] = 1 << i);
        puts("");
    } else {
        for(int i = 0; i <= 30; i++) printf(" %d", len[++N] = 1 << i);
        puts("");
    } char s[40];
    memset(s, 0, sizeof(s));
    for(int i = 1; i <= n; i++) {
        ll nx = 0, ny = 0;
        for(int j = N; j; --j) {
            ll dx = x[i] - nx, dy = y[i] - ny;
            if(abs(dx) > abs(dy)) {
                if(dx > 0) nx += len[j], s[j] = 'R';
                else nx -= len[j], s[j] = 'L';
            } else {
                if(dy > 0) ny += len[j], s[j] = 'U';
                else ny -= len[j], s[j] = 'D';
            }
        } printf("%s\n", s + 1);
    }
    return 0;
}

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

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

using namespace std;
using lint=long long;

vector<vector<lint>> nCr;
void binom(int n){
	nCr.assign(n+1,vector<lint>(n+1));
	rep(i,n+1) nCr[i][0]=1;
	rep(i,n) rep(j,i+1) nCr[i+1][j+1]=nCr[i][j+1]+nCr[i][j];
}

int main(){
	binom(50);

	int n,a,b; cin>>n>>a>>b;
	lint v[50];
	rep(i,n) cin>>v[i];

	sort(v,v+n);

	lint ans1=0,ans2=1;
	for(int m=a;m<=b;m++){
		lint sum=accumulate(v+n-m,v+n,0LL);
		if(sum*ans2>m*ans1){
			ans1=sum;
			ans2=m;
		}
	}

	lint cnt=0;
	for(int m=a;m<=b;m++){
		lint sum=accumulate(v+n-m,v+n,0LL);
		if(sum*ans2==m*ans1){
			cnt+=nCr[count(v,v+n,v[n-m])][count(v+n-m,v+n,v[n-m])];
		}
	}
	cout<<setprecision(9)<<1.0*ans1/ans2<<'\n'<<cnt<<'\n';

	return 0;
}


Measured memory_bytes: 256
<?php
  fscanf(STDIN,"%d %d %d",$n,$m,$x);
  $a = explode(" ",trim(fgets(STDIN)));
  $i = $x;
  $cost_i = 0;
  while($i<$n){
    if(in_array($i,$a)){
      $cost_i++;
    }
    $i++;
  }
  $j = $x;
  $cost_j = 0;
  while($j>0){
    if(in_array($j,$a)){
      $cost_j++;
    }
    $j--;
  }
  echo min($cost_i,$cost_j)."\n";

Measured memory_bytes: 4604
#include <stdio.h>
#define leap(x, y, z) ((x)% 400 == 0 || ((x) % 100 && (x) % 4 == 0) ? (y) : (z))

int x[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},a,b,c,d,e,f,i,r;

int main(){
   for(;scanf("%d%d%d%d%d%d", &a, &b, &c, &d, &e, &f), a != -1;){
    r = -c;
    i = a % 4;
    x[2] = leap(a, 29, 28);
    for(i = b; i <=(a==d?e-1:12); i++) r += x[i];
    for(i = a + 1;i < d;i++) r += leap(i, 366, 365);
    x[2] = leap(d, 29, 28);
    for(i = (a==d?13:1);i < e;i++) r += x[i];
    printf("%d\n", r + f);
  }
  return 0;
}

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

ll n;
std::vector<ll> ara(100010);
ll dp[100010];
ll k;

ll fnc(ll i){
  if(i+1 == n)return 0;
  if(i >= n)return 1<<30;
  if(dp[i] != -1)return dp[i];
  ll res1 = 1<<30;
  for(int j = 1;j<=k;j++){
    res1 = min(res1, abs(ara[i]-ara[i+j]) + fnc(i+j));
  }
  dp[i] = res1;
  return dp[i];
}

int main(int argc, char const *argv[]) {
  memset(dp,-1,sizeof(dp));
  cin >> n >> k;
  for(ll i = 0;i<n;i++){
    cin >> ara[i];
  }
  cout << fnc(0) << endl;

  return 0;
}


Measured memory_bytes: 8064
n=input()
m=n[0]
for i in range(len(n)-1):
  m+=n[0]
if int(n)>int(m):
  if n[0]!=str(9):
    a=str(int(n[0])+1)
    for j in range(len(n)-1):
      a+=str(int(n[0])+1)
    print(a)
  else:
    b=str(1)
    for k in range(len(n)):
      b+=str(1)
    print(b)
else:
  print(m)
      
      
              


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

int main()
{
   int x,a,b;
   cin>>x>>a>>b;
   if(abs(x-a)>abs(x-b))
    cout<<'B'<<endl;
   else
    cout<<'A'<<endl;


   return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int h = sc.nextInt();
			int w = sc.nextInt();
			String s = sc.nextLine();

			for (int i = 0; i < w + 2; i++) {
				System.out.print("#");
			}
			System.out.println();
			while(sc.hasNext()) {
				System.out.print("#");
				System.out.print(sc.nextLine());
				System.out.println("#");
			}
			for (int i = 0; i < w + 2; i++) {
				System.out.print("#");
			}
			System.out.println();
		}
	}

}

Measured memory_bytes: 21460
n=int(input())
h=list(map(int,input().split()))
ans=0
hi=0
count=0
for i,num in enumerate(h):
	if i>0:
		if hi>=num:
			count+=1
		else:
			ans=max(ans,count)
			count=0
	hi=num
ans=max(ans,count)
print(ans)

Measured memory_bytes: 14252
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

//
// # Examples
//
// # integers
// input! { n: usize, m: usize, ... }
//
// # array
// input! { n: usize, v: [i32; n], }
//
// # matrix
// input! { n: usize, m: usize, mat: [[]] }
//
// # string
// input! { s: chars }
//
// 3 4
// ####
// #..#
// .#.#
//
// input!{
//     h: usize,
//     w: usize,
//     board: [chars; h],
// }

// https://practice.contest.atcoder.jp/tasks/practice_1
//fn main() {
//    input!{
//        a: usize, b: usize, c: usize,
//        foo: chars,
//    }
//    let s: String = foo.into_iter().collect();
//    println!("{} {}", a+b+c, s);
//}
fn main() {
    input!{
        n: usize
    }
    if n <= 999 {
        println!("{}", "ABC");
    } else {
        println!("{}", "ABD");
    }
}

Measured memory_bytes: 4352
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())



int n;
vector<int> edge[200000];
int p[200000];
bool vis[200000];
int si[200000];

vector<int> vers[2];

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

	cin >> n;
	rep(i, n-1) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		edge[a].push_back(b);
		edge[b].push_back(a);
	}

	queue<pair<int, int>> q;
	q.emplace(0, 0);
	vis[0] = true;


	bool ok = true;

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

		int u = pa.first;
		vers[pa.second % 2].push_back(u);	
		for (int v: edge[u]) {
			if (vis[v])continue;
			vis[v] = true;
			q.emplace(v, pa.second + 1);
		}
	}


	int n1 = (n + 2) / 3;
	int n2 = (n + 1) / 3;
	int n0 = n / 3;

	vector<int> mv[3];
	for (int i = 1; i <= n; i++)mv[i % 3].push_back(i);

	if (vers[0].size() <= n1 + n0 && vers[1].size() <= n2 + n0) {
		for (int u : vers[0]) {
			if (!mv[1].empty()) {
				p[u] = mv[1].back();
				mv[1].pop_back();
			}
			else {
				p[u] = mv[0].back();
				mv[0].pop_back();
			}
		}
		for (int u : vers[1]) {
			if (!mv[2].empty()) {
				p[u] = mv[2].back();
				mv[2].pop_back();
			}
			else {
				p[u] = mv[0].back();
				mv[0].pop_back();
			}
		}
		rep(i, n) {
			if (i)cout << ' ';
			cout << p[i];
		}
		cout << endl;
	}else if (vers[0].size() <= n2 + n0 && vers[1].size() <= n1 + n0) {
		for (int u : vers[1]) {
			if (!mv[1].empty()) {
				p[u] = mv[1].back();
				mv[1].pop_back();
			}
			else {
				p[u] = mv[0].back();
				mv[0].pop_back();
			}
		}
		for (int u : vers[0]) {
			if (!mv[2].empty()) {
				p[u] = mv[2].back();
				mv[2].pop_back();
			}
			else {
				p[u] = mv[0].back();
				mv[0].pop_back();
			}
		}
		rep(i, n) {
			if (i)cout << ' ';
			cout << p[i];
		}
		cout << endl;
	}
	else if (vers[0].size() <= n0){
		for (int u : vers[0]) {
			p[u] = mv[0].back();
			mv[0].pop_back();
		}
		for (int u : vers[1]) {
			rep(i, 3) {
				if (!mv[i].empty()) {
					p[u] = mv[i].back();
					mv[i].pop_back();
					break;
				}
			}
		}
		rep(i, n) {
			if (i)cout << ' ';
			cout << p[i];
		}
		cout << endl;
	}
	else if (vers[1].size() <= n0) {
		for (int u : vers[1]) {
			p[u] = mv[0].back();
			mv[0].pop_back();
		}
		for (int u : vers[0]) {
			rep(i, 3) {
				if (!mv[i].empty()) {
					p[u] = mv[i].back();
					mv[i].pop_back();
					break;
				}
			}
		}
		rep(i, n) {
			if (i)cout << ' ';
			cout << p[i];
		}
		cout << endl;
	}
	else {
		cout << -1 << endl;
	}

	return 0;
}

Measured memory_bytes: 17008
#include<cstdio>
#include<map>
#include<algorithm>
using namespace std;
typedef long long LL;
const int maxn=1e5+2;
int n;
map<LL,int> mp;
LL dis[maxn];
int id[maxn],fa[maxn],siz[maxn];
bool cmp(int x,int y){
	return dis[x]>dis[y];
}
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++){
		scanf("%lld",&dis[i]);
		siz[i]=1;
		id[i]=mp[dis[i]]=i;
	}
	sort(id+1,id+n+1,cmp);
	for (int i=1;i<n;i++){
		fa[id[i]]=mp[dis[id[i]]-n+2*siz[id[i]]];
		if (!fa[id[i]]){
			puts("-1");
			return 0;
		}
		siz[fa[id[i]]]+=siz[id[i]];
	}
	for (int i=1;i<n;i++) dis[id[n]]-=siz[id[i]];
	if (dis[id[n]]){
		puts("-1");
		return 0;
	}
	for (int i=1;i<n;i++) printf("%d %d\n",fa[id[i]],id[i]);
	return 0;
}

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

int main()
{
    long long int na, nb, nc, k, sum;
    long long int ta, tb, tc;

    cin >> na >> nb >> nc >> k;
    ///a
    if(k<=na)
    {
        ta=k;
    }
    else
    {
        ta=na;
    }
    k=k-ta;


    ///b
    if(k<=nb)
    {
        tb=k;
    }
    else
    {
        tb=nb;
    }
    k=k-tb;


    ///c
    if(k<=nc)
    {
        tc=k;
    }
    else
    {
        tc=nc;
    }
    k=k-tc;

    sum=ta-tc;
    cout << sum ;


    return 0;
}


Measured memory_bytes: 3636
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

int main() {
  ll H;
  cin >> H;

  ll pos = 0;  //最高のBit位置

  while (H > 0) {
    H >>= 1;
    pos++;
  }

  ll ans = 1;
  for (ll i = 0; i < pos; i++) {
    ans *= 2;
  }
  ans--;

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


Measured memory_bytes: 256
//include,namespace
 #include<bits/stdc++.h>
 #include<iostream> 
 #include <queue>
 #include <vector>
 #include <string>
 using namespace std;
//REPmacro
 #define all(x) (x).begin(),(x).end()             //ソート
 #define FOR(i,x,n)for(int i=(x);i<(n);i++)
 #define FOR_R(i,x,n) for(int i=(n-1);i>=(x);i--)
 #define REP(i, n) FOR(i, 0, n)
 #define REP_R(i, n) FOR_R(i, 0, n)
//long long(define)
 using ll = long long;
 typedef long long ll;
 typedef long long int64;
 typedef long long lint;
 typedef long long lli;

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};
////////////////いろいろあるよ//////////////////////////////////
int main(){
    long long a,b,c;
  	cin >> a >> b >> c;
  	if(c-a-b>0&&4*a*b<(c-a-b)*(c-a-b))cout << "Yes" << endl;
  	else cout << "No" << endl;
    
	return 0; 
}


Measured memory_bytes: 256
s=['7 ','17 ','37 ','47 ','67 ','97 ','107 ','127 ','137 ','157 ','167 ','197 ','227 ','257 ','277 ','307 ','317 ','337 ','347 ','367 ','397 ','457 ','467 ','487 ','547 ','557 ','577 ','587 ','607 ','617 ','647 ','677 ','727 ','757 ','787 ','797 ','827 ','857 ','877 ','887 ','907 ','937 ','947 ','967 ','977 ','997 ','1087 ','1097 ','1117 ','1187 ','1217 ','1237 ','1277 ','1297 ','1307 ']
for i in range(int(input())):
    print(s[i],end="")
print("\n")

Measured memory_bytes: 3064
// Bubble Sort
#include <stdio.h>

int BubbleSort(int*, int);

int main(){
  int i, n, A[100], count;
  scanf("%d", &n);
  for(i=0; i < n; i++){
    scanf("%d", &A[i]);
  }
  count = BubbleSort(A, n); // BubbleSortを実行
  // 配列の内容とカウント回数を表示 //
  for(i=0; i < n; i++){
    if(i != 0)printf(" ");
    printf("%d", A[i]);
  }
  printf("\n%d\n",count);
  return 0;
}

int BubbleSort(int *A, int n){
  int i, str, flag, count=0;
  flag = 1; // 逆の隣接要素が存在する
  while(flag){
    flag = 0;
    for(i=n-1; i > 0; i--){
      if(A[i] < A[i-1]){ // A[i]とA[i-1]を交換する
	str = A[i];
	A[i] = A[i-1];
	A[i-1] = str;
	count++; // 交換回数を記録
	flag = 1;
      }
    }
  }
  return count; // カウント回数を返す
}



Measured memory_bytes: 2120
#include<iostream>
#include<cstdio>
#include<set>
#include<map>
#include<stack>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;
int n,m;
stack<char >a;
char ch[100005];
int getsum(){
    int sum=0;
    int t=strlen(ch);
    int p=0,q=t-1;
    while(p<q)
    {
        if(ch[p]==ch[q])
        {
            p++;q--;
        }
        else
        {
            if(ch[p]=='x')
            {
                p++;
                sum++;
            }
            else if(ch[q]=='x')
            {
                q--;
                sum++;
            }
        }
    }
    return sum;
}
int main()
{
    cin>>ch;
    int t=strlen(ch);
    int flag=1;
    for(int i=0;i<t;i++)
    {
        if(ch[i]!='x')
            a.push(ch[i]);
    }
    for(int i=0;i<t;i++){
        if(ch[i]=='x') continue;
        char c=a.top();
        a.pop();
        if(ch[i]!=c)
        {
            flag=0;
            break;
        }
    }
    if(flag){
       for(int i=0;i<t;i++)
            a.push(ch[i]);
       cout<<getsum()<<endl;
    }
    else
        cout<<"-1"<<endl;
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<algorithm>
#include<iomanip>
#include<vector>
#include<cmath>

using std::cin;
using std::cout; using std::endl;

#define rep(X,Y) for(int (X)=0;(X)<(Y);++(X))
#define rept(X,Y,Z) for(int (X)=(Y);(X)<(Z);++(X))
#define repr(X,Y) for(int (X)=(Y);(X)>=0;--(X))
const double pi=3.141592653589793283462;

int main(){
	int n, m;
	int a;
	while(cin>>n>>m){
		for(int i=1;i<=n;i++){
			       if(n%i==0  && m%i==0)
					   a=i;
			}
		cout<<a<<endl;
	}
	return 0;
	}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
const double PI = 3.14159265358979323846;

int main() {
  int n;
  cin >> n;
  int maxm = -1;
  int sum = 0;
  rep(i, n) {
    int l;
    cin >> l;
    sum += l;
    maxm = max(maxm, l);
  }
  int ans = sum - maxm;
  if(maxm < ans) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3648
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main(void) {

	int n, minn, tmpa, tmpb;

	string a, b;

	cin >> n;
	
	minn = 18 * to_string(n).size();

	for (int i = 1; i < n; i++)
	{
		tmpa = 0;
		tmpb = 0;
		a = to_string(i);
		b = to_string(n - i);
		for (int ka = 0; ka < a.size(); ka++)
		{
			tmpa += a[ka] - '0';
		}

		for (int kb = 0; kb < b.size(); kb++)
		{
			tmpb += b[kb] - '0';
		}

		minn = min(minn, tmpa + tmpb);
	}

	cout << minn << "\n";

	return 0;
}

Measured memory_bytes: 256
# from math import factorial,sqrt
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque,Counter
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import scipy as scp

# 入力の受け取り
n = int(input())

ans = 0
for i in range(1,n+1):
    if len(str(i)) % 2 == 1:
        ans += 1

print(ans)
# print("{:.10f}".format(ans))
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する



Measured memory_bytes: 2940
s = input()
k = int(input())
n = len(s)

a = 1
data = []
for i in range(n-1):
    if s[i] == s[i+1]:
        a += 1
    else:
        data.append(a)
        a = 1
data.append(a)

ans = 0

if s[0] != s[-1]:
    for d in data:
        ans += d//2
    ans *= k
elif len(data) == 1:
    ans = n*k//2
else:
    for i in range(1,len(data)-1):
        ans += data[i]//2
    ans *= k
    ans += data[0]//2 + data[-1]//2 + (data[0] + data[-1])//2 * (k-1)

print(ans)

Measured memory_bytes: 38256
import java.util.Scanner;

public class Main {

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


	    //?????£????????????(int)
	    System.out.println( (int)Math.pow(x, 3) );
	    
	   

	}

}

Measured memory_bytes: 26020