akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long int
#define mod 1000000007
#define mx 1000006
using namespace std;	
int n,m;
int isvalid(int a,int b)
{
	//cout<<"a is "<<a<<" b is "<<b<<endl;
	if(a>=0 && b>=0 && a<n && b<m)
		return 1;
	//`cout<<"its invalid\n";
	return 0;
}
int r[]={0,0,1,-1},c[]={1,-1,0,0};
int main(){	
	int i,j,l,k,h;
	cin>>n>>m;
	string a[100];
	 for(i=0;i<n;i++)cin>>a[i];
	int ans=0;
	for(i=0;i<n;i++)
	for(j=0;j<m;j++)
	{
		if(a[i][j]=='#')
			continue;
		for(k=0;k<n;k++)
		{
			for(l=0;l<m;l++)
			{
				if(a[k][l]=='#')
					continue;
				queue<int > p,q;
				int vis[21][21]={0},dist[21][21]={0};
				vis[i][j]=1;
				p.push(i);
				q.push(j);
				while(!q.empty())
				{
					int x=p.front(),y=q.front();
					if(x==k && y==l)
					{	
			//printf("i %d j %d -> x %d y %d dist is %d \n",i,j,x,y,dist[x][y]);
						
						ans=max(ans,dist[x][y]);
						break;
					}
					q.pop();p.pop();
					for(h=0;h<4;h++)
					{
						int u=x+r[h],v=y+c[h];
						if(isvalid(u,v) && a[u][v]=='.' && vis[u][v]==0)
						{
							dist[u][v]=dist[x][y]+1;
							vis[u][v]=1;
							p.push(u);
							q.push(v);
						}
					}
				}
			}
			
		}
	}
	cout<<ans<<endl;
	
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int a, b;
  cin >> a >> b;
  int g = __gcd(a, b);
  ll l = (ll)a / g * b;
  cout << l << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
#define MOD 1000000007
using ll = long long;
using namespace std;
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 (a>b) { a=b; return 1; } return 0; }

ll gcd(ll a,ll b){
    if(a<b)return gcd(b,a);
    while(a%b!=0){
        ll c = a%b;
        a=b;
        b=c;
    }
    return b;
}
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
ll n,X;
cin>>n>>X;
ll x;
ll ans;
rep(i,n){
    cin>>x;
    if(i==0){
        ans=abs(x-X);
    }
    else{
        ans=gcd(ans,abs(x-X));
    }
}
cout<<ans<<endl;
system("pause");
return 0;
}

Measured memory_bytes: 504
// 2分探索
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<algorithm>
#include<iostream>

using namespace std;

const int MAX_N = 1000000;
//const int MAX_Q = 500;

bool Binary_Search(int A[], int n, int key);

int main(void)
{

    int n, q, key, count = 0;
    int ary_N[MAX_N + 1];

    scanf("%d", &n);

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

    scanf("%d", &q);

    for(int i = 0; i < q; i++)
    {
        scanf("%d", &key);

        if( Binary_Search(&ary_N[0], n, key) == true )
        {
            count++;
        }
    }

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

    return 0;
}

// 2分探索
bool Binary_Search(int A[], int n, int key)
{
    bool ret = false;

    int left, right, mid;

    left = 0;
    right = n;
    mid = ( left + right ) / 2;

    while( left < right )
    {
        if( A[mid] < key )
        {
        	// 後半を探索
            left = mid + 1;
        }
        else if( A[mid] > key )
        {
            // 前半を探索
            right = mid;
        }
        else
        {
            ret = true;
            // 値が見つかったので処理終了
            break;
        }

        mid = ( left + right ) / 2;
    }

    return ret;
}



Measured memory_bytes: 3500
'use strict'

function main(s) {

  const nums = s.split('\n')[1].split(' ').map(n => Number(n));
  const bucket = [...Array(100000)].fill(0);

  for (const n of nums) {
    bucket[n] += 1;
    if (n > 0) bucket[n - 1] += 1;
    if (n < 99999) bucket[n + 1] += 1;
  }

  const answer = Math.max(...bucket);
  console.log(answer);
}

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


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

using namespace std;

int gcd(int x, int y) {
	if (y == 0) return x;

	return gcd(y, x%y);
}

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

	if (a < b) {
		swap(a, b);
	}

	cout << gcd(a, b) << endl;
}


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

using namespace std;

int main() {
    int n, x, p;
    cin >> x >> n;
    if (n == 0) {
        cout << x << endl;
        return 0;
    }
    vector<bool> contained(105, false);
    for (int i=0; i<n; i++) {
        cin >> p;
        contained[p] = true;
    }
    
  	if (contained[x] == false) {
      	cout << x << '\n'; 
      	return 0;
    }
    int i;
    for (i=x-1; i>=0 && contained[i]; i--);
    int ans = i;

    for (i=x+1; i<105 && contained[i]; i++);
    if (x-ans == i-x) {
        cout << ans << endl;
        return 0;
    }

    if (x-ans > i-x) {
        cout << i << endl;
        return 0;
    }

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


Measured memory_bytes: 3616
n = input()
while n:
    xa, ya, ra, xb, yb, rb = map(float, raw_input().split())
    r = ((xa-xb)**2 + (ya-yb)**2)**.5
    if ra+rb<r: x=0
    elif ra-rb>r: x=2
    elif rb-ra>r: x=-2
    else: x=1
    print x
    n-=1

Measured memory_bytes: 4292
#include <math.h>

#include <algorithm>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
const int INF = 100100100;

int main() {
  int n, x, y;
  cin >> n >> x >> y;
  --x;
  --y;
  vector<int> ans(n);
  rep(sv, n) {
    vector<int> dist(n, INF);  //毎回初期化
    queue<int> q;
    auto push = [&](int v, int d) {  //λ式
      if (dist[v] != INF) return;
      dist[v] = d;
      q.push(v);
    };
    push(sv, 0);  //始点
    while (!q.empty()) {
      int v = q.front();  //
      q.pop();
      int d = dist[v];
      if (v - 1 >= 0) push(v - 1, d + 1);
      if (v + 1 < n) push(v + 1, d + 1);
      if (v == x) push(y, d + 1);
      if (v == y) push(x, d + 1);
    }
    rep(i, n) ans[dist[i]]++;  //それぞれの距離についてｋ入れ込んでいく
  }
  rep(i, n) ans[i] /= 2;
  for (int i = 1; i < n; i++) {
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    ll n,k;cin>>n>>k;
    ll res=(n-2)/(k-1)+1;
    cout<<res<<endl;
}

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

const int INF = 1001001001;

int c[10][1005];

int main() {
  int h, w, k;
  cin >> h >> w >> k;
  vector<string> s(h);
  rep(i,h) cin >> s[i];
  int ans = INF;
  rep(div,1<<(h-1)) {
    int g = 0;
    vector<int> id(h);
    rep(i,h) {
      id[i] = g;
      if (div>>i&1) ++g;
    }
    ++g;
    rep(i,g)rep(j,w) c[i][j] = 0;
    rep(i,h)rep(j,w) c[id[i]][j] += (s[i][j]-'0');

    int num = g-1;
    vector<int> now(g);
    auto add = [&](int j) {
      rep(i,g) now[i] += c[i][j];
      rep(i,g) if (now[i] > k) return false;
      return true;
    };
    rep(j,w) {
      if (!add(j)) {
        num++;
        now = vector<int>(g);
        if (!add(j)) {
          num = INF;
          break;
        }
      }
    }
    ans = min(ans, num);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <stdio.h>
using namespace std;

int main(void)
{
    //string a,b;
    //int a,b,c,d;
    int i=0;
    char a,b='.';
    //cin>>a;
    while(1)
    {
        a=getchar();
        if(a=='\n'||a==EOF) break;
        if(a=='1') i++;
    }
    cout<<i;
    return 0;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main() {
	int W, H, N;
	cin >> W >> H >> N;
	vector<int>X(N), Y(N), A(N);
	int X_min = 0, X_max = W, Y_min = 0, Y_max = H;
	for (int i = 0; i < N; i++) {
		cin >> X.at(i) >> Y.at(i) >> A.at(i);
		if (A.at(i) == 1) {
			X_min = max(X_min, X.at(i));
		}
		else if (A.at(i) == 2) {
			X_max = min(X_max, X.at(i));
		}
		else if (A.at(i) == 3) {
			Y_min = max(Y_min, Y.at(i));
		}
		else {
			Y_max = min(Y_max, Y.at(i));
		}
	}
	cout << max((X_max - X_min), 0) * max((Y_max - Y_min), 0) << endl;
}


Measured memory_bytes: 256
s = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51".replace(" ", "").split(",")
input = raw_input 
k = int(input())
out = s[k-1]
print(out)

Measured memory_bytes: 27884
#pragma GCC optimize (2)
#pragma G++ optimize (2)
#include <bits/stdc++.h>
#define ll long long
#define lowbit(x) (x&-x)
using namespace std;
const int N = 2e5+7, p = 1e9+7;
ll tre[N];
int n, a[N], h[N];
void change(int p, ll v)
{
	for(int i = p; i <= n; i += lowbit(i))
	{
		tre[i] = max(tre[i], v);
	}
	return;
}
ll query(int p)
{
	ll res = 0;
	for(int i = p; i >= 1; i -= lowbit(i))
	{
		res = max(res, tre[i]);
	}
	return res;
}
int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n; i++)
	{
		scanf("%d", &h[i]);
	}
	for(int i = 1; i <= n; i++)
	{
		scanf("%d", &a[i]);
	}
	for(int i = 1; i <= n; i++)
	{
		change(h[i], query(h[i])+a[i]);
	}
	printf("%lld\n", query(n));
	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>									
using namespace std;
 
int main() {
  int D, T, S;
  cin >> D >> T >> S;
  if(D < (T * S)){cout << "Yes" << endl;}
  if(D == (T * S)){cout << "Yes" << endl;}
  if(D > (T * S)){cout << "No" << endl;}
}

Measured memory_bytes: 3612
#include <iostream>

using namespace std;

int main(void)
{
    char op;
    int a, b;

    while (op != '?')
    {
        cin >> a >> op >> b;
        switch (op)
        {
        case '+':
            cout << a + b << endl;
            break;
        case '-':
            cout << a - b << endl;
            break;
        case '*':
            cout << a * b << endl;
            break;
        case '/':
            cout << a / b << endl;
            break;
        default:
            break;
        }
    }
}


Measured memory_bytes: 3108
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int main() {
    int R[MAX], n;

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

    int maxv = -2000000000;
    int minv = R[0];

    for (int i = 1; i < n; i++) {
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }
    cout << maxv << endl;

    return 0;
}

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

struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
};
unordered_map<pair<int,int>,string,hash_pair>dp;
string helper(vector<int>&stones,int k,int chance){
	if(dp.find({k,chance}) != dp.end()){
		return dp[{k,chance}];
	}
	if(k < 0 && chance == 0){
		return "First";
	}
	else if(k < 0 && chance == 1){
		return "Second";
	}
	else if(k >= 0){
		string winner;
		for(int i=0;i<stones.size();i++){
			winner = helper(stones,k-stones[i],1-chance);
			//cout<<chance<<" "<<winner<<endl;
			if(chance == 0 && winner == "First"){
			dp[{k,chance}] = "First";
			return "First";
		}
			if(chance == 1 && winner == "Second"){
			dp[{k,chance}] = "Second";
			return "Second";
		}
		}
		dp[{k,chance}] = winner;
		return winner;
	}
}
int main(){
	int n,k;cin>>n>>k;
	vector<int>stones(n);
	for(int i=0;i<n;i++){
		cin>>stones[i];
	}
	cout<<helper(stones,k,0);
}


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

long long gcd(long long a, long long b) {return b ? gcd(b, a % b) : abs(a);}
long long lcm(long long a, long long b) {return abs(a / gcd(a, b) * b);}

long long a, b, c, d;

long long count(long long n) {
  return n - (n / c + n / d - n / lcm(c, d));
}

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

  cin >> a >> b >> c >> d;
  long long ans = count(b) - count(a-1);
  cout << ans << '\n';
  return 0;

}

Measured memory_bytes: 256
n, w = gets.strip.split.map(&:to_i)
wv = readlines.map {|line| line.strip.split.map(&:to_i) }
w1 = wv[0][0]

wv = wv.map {|ww, vv|  [ww-w1, vv]}
#p wv

width = n*3+3+1
dp = Array.new(n+1) { [-1]*(width) }
dp[0][0]=0

wv.each do |cw, cv|
  (0...n).to_a.reverse.each do |i|
    (width).times do |j|
      dp[i+1][j+cw] = dp[i][j] + cv if dp[i][j] != -1 && dp[i+1][j+cw] < dp[i][j] + cv
    end
  end
end

#dp.each {|l| p l }

result = [0,0]
dp.each_with_index do |line, i|
  line.each_with_index do|v, j|
    result = [j+w1*i, v] if v > result.last && j+w1*i <= w
  end
end

p result.last

Measured memory_bytes: 4220
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define inf (int)(100)

void next(vector<int> &x){
	for(int i = 0; i < x.size(); i++){
		if(x[i] < 0 || (x[i] < 9 && x[i + 1] < 0) || (x[i] < 9 && x[i] <= x[i + 1])){
			x[i] = max(0ll, x[i]) + 1;
			for(int j = i - 1; j >= 0; j--){
				x[j] = max(0ll, x[j + 1] - 1);
			}
			return;
		}
	}
}

signed main(){
	int K;
	scanf("%lld", &K);
	vector<int> ans(11, -inf);
	ans[0] = 0;
	while(K--){
		next(ans);
/*		for(int i = 0; i < 11; i++){
			printf("%lld ", ans[i]);
		}
		printf("\n");
*/	}
	int a = 0;
	for(int i = 10; i >= 0; i--){
		a = 10 * a + max(0ll, ans[i]);
	}
	printf("%lld\n", a);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <queue>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <complex>

using ll = long long int;
using namespace std;

int main(){
  
  string S;
  cin >> S;

  if(S.length()%2 == 1){
    cout << "No" << endl;
    return 0;
  }
  else{
    ll flag = 1;
    for(ll i = 0; i < S.length()/2; i++){
      if(S[2*i] != 'h'|| S[2*i+1]!= 'i'){
        flag = 0;
        break;
      }
    }
    if(flag){
      cout << "Yes" << endl;
    }
    else
    {
      cout << "No" << endl;
    }
    
  }

  return 0;
}


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

int main() {
  int n,m;
  cin >> n >> m;
  if(n == m){
    cout << 2*m;
  }
  else{
    cout << 2*max(m,n)-1;
  }
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
#define dummy 1e16
using namespace std;

long long n;
long long a[3005] = {0};
long long dp[3004][3005] = {0};

long long solve(long long l, long long r);

int main() {
  cin >> n;
  for(int i = 0; i < n; ++i) cin >> a[i];
  for(int i = 0; i < n; ++i)
    for(int j = 0; j < n; ++j) dp[i][j] = dummy;
  for(int i = 0; i < n; ++i) {
    if(n % 2)
      dp[i][i] = a[i];
    else
      dp[i][i] = -a[i];
  }
  cout << solve(0, n - 1) << endl;
  return 0;
}

long long solve(long long l, long long r) {
  if(dp[l][r] != dummy) return dp[l][r];
  long long ans = 0;
  if((r - l + 1) % 2 == n % 2)
    ans =
        max(a[l] + solve(l + 1, r), a[r] + solve(l, r - 1));
  else
    ans =
        min(solve(l + 1, r) - a[l], solve(l, r - 1) - a[r]);
  return dp[l][r] = ans;
}

Measured memory_bytes: 70784
l1=[1,3,5,7,8,10,12]
l2=[4,6,9,11]
l3=[2]
l=list(map(int,input().split()))
r1=[x for x in l if x in l1]
r2=[x for x in l if x in l2]
r3=[x for x in l if x in l3]
print("Yes" if max(len(r1),len(r2),len(r3))==2 else "No")

Measured memory_bytes: 9092
program main
    implicit none
    integer(4):: n,k,i
    integer(4),allocatable:: h(:)
    integer(4):: li, ri, cnt

    read*, n, k
    allocate(h(n))
    do i=1,n
        read*, h(i)
    end do
    call merge_sort(h,1,n)

    cnt=2000000001
    
    do i=1, n-k+1
        cnt = min(cnt, h(i+k-1) - h(i))
    end do
    print*, cnt

contains
recursive subroutine merge_sort(ar,f,l)
    integer(4):: ar(:), f,l,tmp,m

    if (l-f <= 1) then
        if (ar(l) < ar(f)) then
            tmp = ar(f)
            ar(f) = ar(l)
            ar(l) = tmp
        end if
        RETURN
    end if

    m = (f+l)/2
    call merge_sort(ar,f,m)
    call merge_sort(ar,m+1,l)
    call merge_(ar,f,m,l)
end subroutine

subroutine merge_(ar,f,m,l)
    integer(4)::ar(:),f,m,l
    integer(4):: li, fi, ti
    integer(4),allocatable:: tmp(:)
    allocate(tmp(l-f+1))
    li = m+1
    fi = f
    ti = 1

    do while(fi <= m .and. li <= l)
        if (ar(fi) <= ar(li)) then
            tmp(ti) = ar(fi)
            fi=fi+1
        else
            tmp(ti) = ar(li)
            li=li+1
        end if
        ti=ti+1
    end do


    if (fi > m) then
        tmp(ti:) = ar(li:l)
    else
        tmp(ti:) = ar(fi:m)
    end if



    ar(f:l) = tmp(:)
    deallocate(tmp)
end subroutine
end program main

Measured memory_bytes: 1212
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <cmath>
#include <iomanip>
#include <fstream>

using namespace std;

typedef long long ll;

const int MAXN = 250005;
const ll INF = (1ll << 60) - 1;

int n;

ll MIN[MAXN];

pair<ll,ll> a[MAXN];

bool cmp(const pair<ll,ll> &A,const pair<ll,ll> &B)
{
	return A.first + A.second < B.first + B.second;
}

int main()
{
	scanf("%d",&n);
	for (int i = 1;i <= n;i++)
		scanf("%d%d",&a[i].first,&a[i].second);
	sort(a + 1,a + n + 1,cmp);
	for (int i = 1;i <= n;i++)
		MIN[i] = INF;
	for (int i = 1;i <= n;i++)
	{
		int low = 0,high = i - 1;
		while (low < high)
		{
			int mid = (low + high + 1) >> 1;
			if (MIN[mid] <= a[i].first)
				low = mid;
			else
				high = mid - 1;
		}
		for (int j = low;j >= 0;j--)
			MIN[j + 1] = min(MIN[j + 1],MIN[j] + a[i].second);
	}
	for (int i = n;i >= 0;i--)
		if (MIN[i] != INF)
		{
			printf("%d\n",i);
			return 0;
		}
	return 0;
}

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

int main(){
  int N;
  int a[4];
  cin >> N;
  
  for(int i = 0; i < 4; i++){
    a[i] = N % 10;
    N = N / 10;
  }
  
  cout << ((a[1] == a[2]) && (a[0] == a[1] || a[2] == a[3]) ? "Yes" : "No");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 2147483647
#define lli long long int
#define MOD 1000000007
#define pb push_back

using namespace std;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;

bool isMS(int num) {
	if (num % 7 == 1 or num % 7 == 6) {
		return true;
	}
	return false;
}

bool isMSprime(int num, vi MS_list) {
	for (int i = 0; i < MS_list.size(); i++) {
		if (num % MS_list[i] == 0 and num != MS_list[i]) {
			return false;
		}
	}
	return true;
}

int main() {
	vi MS_list;

	for (int i = 2; i <= (300000); i++) {
		if (isMS(i)) {
			MS_list.pb(i);
		}
	}

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

		pair<int,vi> MS;
		MS.first = n;

		for (int j = 0; j < MS_list.size(); j++) {
			if (MS.first % MS_list[j] == 0 and isMSprime(MS_list[j],MS_list)) {
				MS.second.pb(MS_list[j]);
			}
		}
		
		cout << MS.first << ":";
		for (int k = 0; k < MS.second.size(); k++) {
			cout << " " <<  MS.second[k];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3580
import re

N = int(input())
S = input()
Answer = str()

for i in range(len(S)):
    Answer += chr(ord(S[i]) + N)
    if ord(Answer[i]) > ord("Z"):
        Answer = Answer[:-1] + chr(ord("A") + (ord(Answer[i]) - ord("Z")) - 1)
    
    
print(Answer)

Measured memory_bytes: 3188
//
// Created by yamunaku on 2019/08/19.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> mti;
typedef vector<ll> vl;
typedef vector<vector<ll>> mtl;

mti e;
vi ans;

void dfs(int x, int p){
    for(auto nx:e[x]){
        if(nx == p) continue;
        ans[nx] += ans[x];
        dfs(nx, x);
    }
}

int main(){
    int n, q;
    cin >> n >> q;
    e = mti(n);
    ans = vi(n, 0);
    rep(i, n - 1){
        int u, v;
        cin >> u >> v;
        e[u - 1].push_back(v - 1);
        e[v - 1].push_back(u - 1);
    }
    rep(i, q){
        int a, x;
        cin >> a >> x;
        ans[a - 1] += x;
    }
    dfs(0, -1);
    rep(i, n){
        cout << ans[i] << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 23552
#include <iostream>
#include <string>
#include <numeric>
using namespace std;

long gcd( long m, long n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	// ユークリッドの方法
	while( m != n )
	{
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}//gcd

int main(){
  long n, m;
  string s, t;
  cin >> n >> m >> s >> t;
  long g=gcd(n, m), l=n*m/g;
  bool trig=true;
  for(int i=0; i<m; i++){
    if((i*l/m)%(l/n)==0){
      int j=(i*l/m)/(l/n);
      if(s[j]!=t[i]){
        trig = false;
        break;
      }
    }
  }
  if(!trig)cout << -1;
  else cout << l;
  return 0;
}


Measured memory_bytes: 512
package main

import (
	"fmt"
	"math"
)

func main() {
	var a, b, c int64
	fmt.Scanf("%d %d %d", &a, &b, &c)

	maxInput := math.Max(math.Max(float64(a), float64(b)), float64(c))
	minInput := math.Min(math.Min(float64(a), float64(b)), float64(c))

	if maxInput == 7 && minInput == 5 && a+b+c-int64(maxInput)-int64(minInput) == 5 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 512
n = int(input())
l = list(map(int, input().split()))

ans = 0

for i in range(n):
    for j in range(i+1,n):
        for k in range(j+1,n):
            if l[i]==l[j] or l[j]==l[k] or l[k]==l[i]:
                ans+=0
            elif abs(l[i]-l[j])<l[k] and l[k]<l[i]+l[j]:
                ans+=1

print(ans)


Measured memory_bytes: 9052
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef uint64_t ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();


int main() {
    int n, val, k;
    cin >> n >> k;
    ll acc = 0;

    vector<ll> dp = {0};
    for(int i = 0; i < n; i++) {
        cin >> val;
        acc += val;
        dp.push_back(acc);
    }
    map<ll, int> cnt;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j <= i; j++) {
            cnt[dp[i+1]-dp[j]] += 1;
        }
    }


    ll mx = cnt.rbegin()->first;
    int nbit = 0;
    while ((1LL<<nbit) < mx) {
        nbit += 1;
    }
    // cout << mx << endl;
    // cout << nbit << endl;
    ll ans = 0;
    for(int b = nbit; b >= 0; b--) {
        auto it = cnt.rbegin();
        acc = 0;
        map<ll, int> cnt3;
        for(; it != cnt.rend(); ++it) {
            if ((it->first >> b)&1) {
                acc += it->second;
                cnt3[it->first&((1ll<<b)-1)] += it->second;
            } else {
                break;
            }
        }
        if (acc >= k) {
            ans += (1ll << b);
        } else {
            for(; it != cnt.rend(); ++it) {
                cnt3[it->first&((1ll<<b)-1)] += it->second;
            }
        }
        cnt.swap(cnt3);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 62848
//おまじない
#include <iostream>
#include<iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
#define P pair<int,int>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

int main(){
    
    ll x,y;
    cin >> x>>y;
    if(abs(x-y)<=1){
        cout <<"Brown"<<endl;
    }else{
        cout <<"Alice"<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[4][4];
void solve() {
	for (int i = 1; i <= 3; i++) {
		for (int j = 1; j <= 3; j++) {
			cin >> a[i][j];
		}
	}
	for (int i = 1; i <= 2; i++) {
		int s1 = a[i][1] - a[i + 1][1];
		int s2 = a[i][2] - a[i + 1][2];
		int s3 = a[i][3] - a[i + 1][3];
		if (s1 != s2 || s1 != s3) {
			cout << "No";
			return;
		}
	}
	cout << "Yes";
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t = 1;
	//cin >> t;
	for (int i = 1; i <= t; i++) {
		solve();
	}
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
string s1,s2;
int len;
int main()
{
	cin>>s1;
	s2=s1;
	len=s1.size();
	reverse(s1.begin(),s1.end());
	for(int i=0;i<len;i++){
		if(s1[i]=='b'){
			s1[i]='d';
		}
		else if(s1[i]=='d'){
			s1[i]='b';
		}
		else if(s1[i]=='p'){
			s1[i]='q';
		}
		else if(s1[i]=='q'){
			s1[i]='p';
		}
	}
	if(s1==s2) cout<<"Yes";
	else cout<<"No";
	return 0;
}

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

int main() {
  int n;
  long long v[100010];
  cin >> n;
  for(int i=0; i < n; i++) cin >> v[i];

  int result = 0;
  for(int i=0; i < n; i++) {
    int count =0;
    for(int j=i; j < n-1; j++) {
      if(v[j+1] <= v[j]) count++;
      else break;
    }
    result = max(result, count);
    i += count;
  }
  cout << result << endl;
}


Measured memory_bytes: 1024
S=list(input())
ans=0
for i in range(2**(len(S)-1)):
    kari=[""]*(len(S)-1)
    for j in range(len(S)-1):
        if ((i>>j)&1):
            kari[j]="+"
    hako=[]
    kasu=0
    gomi=0
    for j in range(len(kari)+len(S)):
        if j%2==0:
            hako.append(S[kasu])
            kasu+=1
        else:
            hako.append(kari[gomi])
            gomi+=1
    #print(hako)
    hako="".join(hako)
    #hako=hako.replace(",","")
    #print(hako)
    ans+=eval(hako)
print(ans)

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

using namespace std;

typedef long long ll;

int main() {
    ll N, A[51];

    cin >> N;
    ll maxAbs = 0;
    int maxAbsIdx = 0;

    for (int i = 1; i <= N; i++) {
        cin >> A[i];
        if (abs(A[i]) > maxAbs) {
            maxAbs = abs(A[i]);
            maxAbsIdx = i;
        }
    }

    if (maxAbs == 0) {
        cout << 0 << endl;
        return 0;
    }

    vector<string> ans;
    
    for (int i = 1; i <= N; i++) {
        if (i == maxAbsIdx) { continue; }
        A[i] += A[maxAbsIdx];
        char s[100];
        sprintf(s, "%d %d\n", maxAbsIdx, i);
        ans.push_back(s);
    }

    if (A[maxAbsIdx] > 0) {
        for (int i = 2; i <= N; i++) {
            A[i] += A[i-1];
            char s[100];
            sprintf(s, "%d %d\n", i-1, i);
            ans.push_back(s);
        }
    } else {
        for (int i = N - 1; i >= 1; i--) {
            A[i] += A[i+1];
            char s[100];
            sprintf(s, "%d %d\n", i+1, i);
            ans.push_back(s);
        }
    }

    cout << ans.size() << endl;
    for (const auto& e : ans) {
        std::cout << e;
    }
}

Measured memory_bytes: 3732
#include <bits/stdc++.h>
typedef long long ll;

using namespace std;

const ll inf=998244353;

inline int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9')
    {
        if(ch=='-')
            f=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9')
    {
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    return x*f;
}
ll num[105];
int main()
{
    ll x,k,d;
    cin >> x >> k>>d;
    x=abs(x);
    ll ct=x/d;
    if(abs(ct)>=abs(k))
    {
        cout << x-(k*d);
    }
    else
    {
        ll tx=x-(ct*d);
        k-=ct;
        if(k&1)
            cout << abs(tx-d);
        else
            cout << tx;
    }
    return 0;
}


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

int main(){
    int N,M;cin>>N>>M;
    vector<long long>A(N);
    for(int i=0;i<N;i++)cin>>A[i];
    map<long long,long long>nums;
    long long sum=0;
    nums[sum]++;
    for(int i=0;i<N;i++){
        sum+=A[i];
        nums[sum%M]++;
    }
    long long res=0;
    for(map<long long, long long>::iterator it=nums.begin();it!=nums.end();it++){
        res+=it->second*(it->second-1)/2;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    int n; cin >> n;
    string s; cin >> s;
    int k; cin >> k;
    char key = s[k-1];
    for(auto itr : s){
        cout << (key != itr ? '*':itr);
    }
    cout <<endl;
}




Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int cnt = 0;
		int k = sc.nextInt();
		int s = sc.nextInt();
		for(int x = 0; x <= k; x++) {
			for(int y = 0; y <= k; y++) {
				if(s - x - y >= 0 && s - x - y <= k) cnt++;
			}
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define MOD (19260817)
using namespace std;

long long n,ans;
char s[10001];

map<long long,map<long long,long long> >map1;
map<long long,map<long long,long long> >map2;

int main()
{
//	freopen("data.in","r",stdin);
//	freopen("datam.out","w",stdout);
	cin>>n; n*=2;
	cin>>s+1;
		
	for (int i=0; i<=(1<<(n/2))-1; ++i)
	{
		long long x=i,hash1=0,hash2=0,cnt1=0,cnt2=0;//cnt1 red
		for (int j=n; j>=n/2+1; --j)
		{
			if (x&1)
			{
				cnt1++;//red
				hash1=(hash1*10+s[j]-'a'+1)%MOD;
			}
			else
			{
				cnt2++;//blue
				hash2=(hash2*10+s[j]-'a'+1)%MOD;
			}
			x>>=1;
		}
		map1[cnt1][hash1]++;
		map2[hash1][hash2]++;
		
	}
	for (int i=0; i<=(1<<(n/2))-1; ++i)
	{
		long long x=i,hash1=0,hash2=0,cnt1=0,cnt2=0;//cnt1 red
		for (int j=1; j<=n/2; ++j)
		{
			if (x&1)
			{
				cnt1++;//blue
				hash1=(hash1*10+s[j]-'a'+1)%MOD;
			}
			else
			{
				cnt2++;//red
				hash2=(hash2*10+s[j]-'a'+1)%MOD;
			}
			x>>=1;
		}
		if (map1[cnt1][hash1])
			ans+=map2[hash1][hash2];
	}
	cout<<ans;
}

Measured memory_bytes: 66176
#include <stdio.h>

int main(void)
{
	int a, b, c;
	
	scanf("%d %d %d", &a, &b, &c);
	
	if (b - a == c - b){
		printf("YES\n");
	}
	else {
		printf("NO\n");
	}
	
	return (0);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
using ll = long long;
const int MOD = 1000000007;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define repp(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)


ll myPow(ll x, ll n, ll m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}

ll mmyPow(ll x, ll n, ll m){
  if (n == 0) return 1;
  ll y = 1;
  rep (i, n) {
    y = y * x % m;
  }

  return y;
}

int main() {
  ll n;  cin >> n;
  ll x, y, z;

  x = mmyPow (9, n, MOD);
  y = mmyPow (8, n, MOD);
  z = mmyPow (10, n, MOD);

  ll ans = (z - x - x + y) % MOD;
  ans = (ans + MOD) % MOD;
  cout << ans << endl;
}

Measured memory_bytes: 3588
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#include<stdlib.h>
#include<stdio.h>
#define test ll t; cin>>t; while(t--)
#define FOR(p,n) for(ll i=p;i<(ll)n;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}*/
using namespace std;
int solve()
{
	int a,b;
	cin>>a>>b;
	if(a<b)
	{
		string s;
		for(int i=0;i<b;i++)
			cout<<a;
	}
	
	else if(b<a)
	{
		
		string s;
		for(int i=0;i<a;i++)
			cout<<b;
	}
	else
	{
		string s;
		for(int i=0;i<min(a,b);i++)
			cout<<b;
	}




}
signed main()
{
	fastio;
	clock_t start, end;
//	test
	{
		start=clock();
		solve();
		end=clock();
		double time_taken=double(end-start)/double(CLOCKS_PER_SEC);
//		cout<<time_taken<<endl;
	}
}


Measured memory_bytes: 256
import java.util.*;

public 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();
		}
		for(int i=0;i<N;i++){
			if(i==N-1){
				System.out.println(A[i]);					
			}else{
			System.out.print(A[i]+" ");
			}
		}
		insertionSort(A,N);
	}
	static void insertionSort(int[] ar,int n){
		for(int i=1;i<ar.length;i++){
			int key=ar[i];
			int j=i-1;
			while(j>=0&&ar[j]>key){
				ar[j+1]=ar[j];
				j--;
			}
			ar[j+1]=key;
			for(int k=0;k<n;k++){
				if(k==n-1){
					System.out.println(ar[k]);					
				}else{
				System.out.print(ar[k]+" ");
				}
			}
		}
	}
}

Measured memory_bytes: 32696
#include<bits/stdc++.h>
            #define ll long long
            #define f   first
            #define s   second
            #define pb          push_back
            #define mod        1000000007
            #define mod1       1000000009
            #define hell        998244353
            #define inf         1000000000000000000LL
            #define pi          3.14159265358979323
            #define N           5000005
            using namespace std;
            ll n,k,sum,q,res,m,val;
            ll x,y;
            
            void solve()    
            {   

                char a;
                cin>>a;
                if(a>='a' and a<='z') cout<<"a";
                else cout<<"A";

            }
            int main()
            {   
                ios_base::sync_with_stdio(false);
                cin.tie(0);cout.tie(0);
                ll t=1;
                //cin>>t;
                
                for(int i=1;i<=t;i++)
                    solve();
            
            }            

Measured memory_bytes: 3608
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int res = 1;
        for (int i = 2; i * i <= x; i++) {
            int p = i * i;
            while (p <= x) {
                res = Math.max(res, p);
                p *= i;
            } 
        }
        System.out.println(res);
        sc.close();
    }
}

Measured memory_bytes: 35628
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;

int main()
{
    map<char, int> mp;
    mp['r'] = 0;
    mp['p'] = 1;
    mp['s'] = 2;
    int n, k, val[3], ans = 0;
    string s;
    cin >> n >> k >> val[2] >> val[1] >> val[0] >> s;

    vector<int> prev(n, 1);
    for (int i = 0; i < n; i++)
    {
        if (i - k >= 0 && s[i] == s[i - k] && !prev[i - k]) continue;
        ans += val[mp[s[i]]];
        prev[i] = 0;
    }

    cout << ans << "\n";
}

Measured memory_bytes: 3776
#include<stdio.h>
int main()
{
    long int a,b,t,x,gcd;

    scanf("%ld %ld",&a,&b);

    if(a==0)
    {
        gcd=b;
    }
    else if(b==0)
    {
        gcd=a;
    }
    else
    {
        while(b!=0)
        {
            t=b;
            b=a%b;
            a=t;
        }
        gcd=a;
    }
    printf("%ld\n",gcd);
}



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

void doRoutine() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    srand(322179);
#ifdef LOCAL
    freopen("/home/max/alg/clion_main/input.txt", "rt", stdin);
    freopen("/home/max/alg/clion_main/output.txt", "wt", stdout);
#endif
}

#define DBG(VAR) cerr << #VAR << ": " << VAR << endl

#define all(x) x.begin(), x.end()
#define vb vector<bool>
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define fi first
#define se second
#define pb push_back
#define vc vector
#define $ make_pair

#ifndef LOCAL
#define cerr if(0) cerr
#define DBG(...) (true)
#endif

#define D double
#define CD complex<D>
#define ll long long

// ----------------------------- CODE NOW ------------------------



signed main() {
    doRoutine();

    int a, b;
    cin >> a >> b;
    int cur = 1;
    int cnt = 0;
    while (cur < b) {
        cur += a - 1;
        ++cnt;
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ll long long
//priority_queue<int, vector<int>, greater<int> > pq;
#define _CRT_SECURE_NO_DEPRECATE
const int N = 300030;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =  1e9+7;

int main(){
 ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 
ll n,a,b;
cin>>n>>a>>b;
cout<<min(n*a,b);
  
 
 
 

}





Measured memory_bytes: 256
from collections import defaultdict
N = int(input())

def sieve_Eratosthenes(n):
    f = [True]*(n+1)
    f[0] = False
    f[1] = False
    m = int(n**0.5+1)
    for i in range(2,m):
        if f[i]:
            for j in range(i*i,n+1, i):
                f[j] = False
    return f

def getPrimeLists(n):
    table = sieve_Eratosthenes(n)
    return [x for x in range(2,n+1) if table[x]]

#N = 10**7
ps = getPrimeLists(N)

m = [1] * (N+1)

for p in ps:
    q = p
    i = 1
    while True:
        for n in range(q,N+1,q):
            m[n] *= p * (i+1)
            m[n] //= i
        q *= p
        i += 1
        if q > N:
            break

print(sum(m)-1)






Measured memory_bytes: 166164
import math
import fractions


def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


if __name__ == '__main__':
    a, b, c, d = map(int, input().split())
    warikireru_c = b // c - (- (-a // c)) + 1
    warikireru_d = b // d - (-(-a // d)) + 1
    lcm_1 = lcm(c, d)
    warikireru_lcm = b // lcm_1 - (- (-a // lcm_1)) + 1
    num = b - a + 1
    print(num - (warikireru_c + warikireru_d - warikireru_lcm))


Measured memory_bytes: 5048
def main():
    X, Y = (int(i) for i in input().split())
    fac = [0] * max(X, Y)
    finv = [0] * max(X, Y)
    inv = [0] * max(X, Y)
    MOD = (10**9) + 7

    def COMinit(m):
        fac[0] = 1
        finv[0] = 1
        if m > 1:
            fac[1] = 1
            finv[1] = 1
            inv[1] = 1
            for i in range(2, m):
                fac[i] = fac[i-1] * i % MOD
                inv[i] = MOD - inv[MOD % i] * (MOD // i) % MOD
                finv[i] = finv[i - 1] * inv[i] % MOD

    def COM(n, k):
        if n < k:
            return 0
        if n < 0 or k < 0:
            return 0
        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD

    COMinit(max(X, Y))
    if (X+Y) % 3 != 0:
        return print(0)
    n = (2*Y - X) // 3
    m = (2*X - Y) // 3
    print(COM(n+m, m))


if __name__ == '__main__':
    main()


Measured memory_bytes: 62064
#include <iostream>
using namespace std;
int main(){
    int n, a, b, cnt=0;
    cin >> n;
    bool flg = 0;
    for(int i=0; i<n; i++){
        cin >> a >> b;
        if(a==b){
            if(flg){
                cnt++;
                if(cnt==3){
                    puts("Yes");
                    return 0;
                }
            }else{
                cnt = 1;
                flg = 1;
            }
        }else{
            flg = 0;
        }
    }
    puts("No");
    return 0;
}

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

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

	int n, k, ans(0);
	cin >> n >> k;
	vector<int> v(n);

	for (int i = 0; i < n; i++)
	{
		cin >> v[i];
	}

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

	for (int i = 0; i < k; i++)
	{
		ans += v[i];
	}
	
	cout << ans;



	return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<double, double> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;


int main() {
    int k;
    cin >> k;
    string s;
    cin >> s;
    int n = s.size();
    if (n <= k) {
        cout << s << endl;
    } else {
        string t = s.substr(0, k);
        cout << t << "..." << endl;
    }

}


Measured memory_bytes: 3628
n, T = [int(x) for x in input().split()]
cost = 2000

for _ in range(n):
  c, t = [int(x) for x in input().split()]
  if t <= T:
  	cost = min(cost, c)

if cost == 2000:
  print("TLE")
else:
  print(cost)
  

Measured memory_bytes: 2940
#include <cmath>
#include <iostream>
#include <string>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <algorithm>

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

const int MIN = 200001;
const int MOD = 1000000007;

using namespace std;

int main() {
	int h, a, r;
	
	cin >> h >> a;
	
	r = (h % a > 0) ? (h / a + 1) : (h / a);
	
	cout << r << endl;
	
	return 0;
}

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

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

ll N;
ll K;
ll V[100];

ll sum(ll a, ll b, ll c) {
	if (a + b > N || a + b + c > K) { return -INF; }

	ll get[100];

	for (ll i = 1; i <= a; i++) {
		get[i] = V[i];
	}

	for (ll i = 1; i <= b; i++) {
		get[a + i] = V[N + 1 - i];
	}

	sort(get + 1, get + a + b + 1);

	ll sol = 0;
	for (ll i = c + 1; i <= a + b; i++) {
		sol += get[i];
	}

	return sol;

}

int main() {
	
	cin >> N >> K;
	for (ll i = 1; i <= N; i++) { cin >> V[i]; }

	ll ans = -INF;

	for (ll a = 0; a <= K; a++) {
		for (ll b = 0; b <= K; b++) {
			for (ll c = 0; c <= K; c++) {
				if (ans < sum(a, b, c)) { ans = sum(a, b, c); }
			}
		}
	}

	cout << ans;

	system("PAUSE");

}

Measured memory_bytes: 504
#include <iostream>
#include <vector>
#include<algorithm>
#include <string>
#include <cmath>
#include<queue>
#define PI 3.141592653589793238
using namespace std;

int main()
{
	string s1, s2;
	string ans;
	int n;

	cin >> n >> s1 >> s2;

	for (int i = 0; i < n; i++) {
		ans += s1[i];
		ans += s2[i];
	}

	cout << ans;

	return 0;
}

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

const ll INF = 1e17;
const ll MOD = 1e9+7;

ll gcd(ll a, ll b)
{
    if (a < b) {
        a ^= b;
        b ^= a;
        a ^= b;
    }
    
    return b ? gcd(b, a % b) : a;
}

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

int main() {
    // input, ready
    ll A,B;
    cin >> A >> B;

    //resolve


    // output
   cout << lcm(A,B) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
    vector<int> board(9);
    vector<int> map(101, 9);
    vector<int> haveIt(10);
    for (int i = 0; i < 9; i++) {
        cin >> board[i];
        map[board[i]] = i;
    }
    int n;
    cin >> n;
    while (n--) {
        int b;
        cin >> b;
        haveIt[map[b]]++;
    }
    if (haveIt[0] && haveIt[1] && haveIt[2] ||
            haveIt[3] && haveIt[4] && haveIt[5] ||
            haveIt[6] && haveIt[7] && haveIt[8] ||
            haveIt[0] && haveIt[3] && haveIt[6] ||
            haveIt[1] && haveIt[4] && haveIt[7] ||
            haveIt[2] && haveIt[5] && haveIt[8] ||
            haveIt[0] && haveIt[4] && haveIt[8] ||
            haveIt[2] && haveIt[4] && haveIt[6]) {
        cout << "Yes";
    } else {
        cout << "No";
    }
    return 0;
}

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


int main(){
  ll con = 1000000007;
  int n;
  cin>>n;
  vector <ll> a(n);
  ll cnt = 0;
  ll ans=0;
  rep(i,n) {
    cin>>a[i];
    cnt+=a[i];
  }


  rep(i,n-1){
    cnt-=a[i];
    ans+=(cnt%con)*a[i];
    ans%=con;
  }
  cout<<ans;

}

Measured memory_bytes: 4792