akhauriyash/Code-Regression huggingface dataset:
package main

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

const pi = math.Pi

var mod int = pow(10, 9) + 7
var Umod uint64 = 1000000007
var ans, cnt int

func main() {
	reader.Split(bufio.ScanWords)
	N, _ := strconv.Atoi(read())
	K, _ := strconv.Atoi(read())

	K_max := (N - 1) * (N - 2) / 2
	if K_max < K {
		fmt.Println(-1)
	} else {
		fmt.Println(N - 1 + K_max - K)
		for i := 2; i < N+1; i++ {
			fmt.Println(1, i)
		}

		for j := 2; j < N; j++ {
			for k := j + 1; k < N+1; k++ {
				if K_max <= K {
					return
				}
				fmt.Println(j, k)
				K_max--
			}
		}
	}
}

/*  ----------------------------------------  */

var reader = bufio.NewScanner(os.Stdin)

func read() string {
	reader.Scan()
	return reader.Text()
}

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

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

var fac [1000000]int
var finv [1000000]int
var inv [1000000]int

func combination_init() {
	fac[0], fac[1] = 1, 1
	finv[0], finv[1] = 1, 1
	inv[1] = 1

	// invは a^(-1) mod p
	// pをaで割ることを考える

	// p/a*(a) + p%a = p
	// p/a*(a) + p%a = 0          (mod p)
	// -p%a = p/a*(a)             (mod p)
	// -p%a *a^(-1)= p/a          (mod p)
	// a^(-1)= p/a * (-p%a)^(-1)  (mod p)
	// a^(-1) =

	for i := 2; i < 1000000; i++ {
		fac[i] = fac[i-1] * i % mod
		inv[i] = mod - inv[mod%i]*(mod/i)%mod
		finv[i] = finv[i-1] * inv[i] % mod
	}
}

func combination(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[y] * finv[x-y] % mod) % mod
	//return fac[x] / (fac[y] * fac[x-y])
}

func permutation(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[x-y] % mod) % mod
	//return fac[x] / fac[x-y]
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }
func ceil(x int) int   { return int(math.Ceil(float64(x))) }

type SortBy [][]int

func (a SortBy) Len() int      { return len(a) }
func (a SortBy) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool {
	return a[i][1] < a[j][1]
}

type PriorityQueue []int

func (h PriorityQueue) Len() int            { return len(h) }
func (h PriorityQueue) Less(i, j int) bool  { return h[i] < h[j] }
func (h PriorityQueue) Swap(i, j int)       { h[i], h[j] = h[j], h[i] }
func (h *PriorityQueue) Push(x interface{}) { *h = append(*h, x.(int)) }
func (h *PriorityQueue) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}


Measured memory_bytes: 768
#include <iostream>
using namespace std;
int main(){
	int a,b,c,d;
	int c1,c2;
	cin >> a >> b >> c >> d;
	if(b < c || a > d){
		cout << "0" << endl;
		return 0;
	}
	c1 = (a > c) ? a : c;
	c2 = (b < d) ? b : d;
	cout << c2 - c1 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll al[200010],mod=1e9+7,sum[200010],anss=0,n;
int main(){
	scanf("%lld",&n);
	memset(sum,0,sizeof(sum));
	for(int i=1;i<=n;++i){
		scanf("%lld",&al[i]);
		sum[i]=(sum[i-1]+al[i])%mod;
	}
	for(int i=1;i<=n-1;++i)
		anss=(anss+al[i]*(sum[n]-sum[i]+mod))%mod;
	printf("%lld\n",anss);
	return 0;
	
}

Measured memory_bytes: 6928
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class C
{
	public static void Main()
	{
		long L = GetLong();
		long R = GetLong();
		if(R - L + 1 >= 2019)
		{
			Console.WriteLine(0);
			return;
		}

		long min = long.MaxValue;
		for(long i = L; i <= R; i++)
		{
			for(long j = i + 1; j <= R; j++)
				min = Math.Min(min, (i * j) % 2019);
		}
		Console.WriteLine(min);
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}


Measured memory_bytes: 13140
x = sorted(list(map(int,input().split())),reverse=True)

count = 0
if (x[1]-x[2])%2 == 1:
    count += 1
    x[0] += 1
    x[2] += 1
count = count + (x[1]-x[2])/2 + (x[0]-x[1])

print(int(count))

Measured memory_bytes: 3060
n = int(input())
a = list(map(int, input().split()))

result = 0
counter = 1
temp = 0
for i in range(n):
    counter -= 1
    start = i + counter
    for j in range(start, n):
        if a[j] ^ temp != a[j] + temp:
            temp -= a[i]
            break
        else:
            temp += a[j]
            counter += 1
    result += counter


print(result)

Measured memory_bytes: 25684
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define foi(i,a,n) for(ll i=a;i<n;i++)
#define el "\n"
#define ll long long int
const int INF = 2e9+5;
void solve(){
	ll n,W;cin>>n>>W;
  	vector<ll> w(n),v(n),mx(W+1,0);
  	rep(i,n)cin>>w[i]>>v[i];
  	rep(i,n){
    	for(ll j=W-w[i];j>=0;j--){
        	mx[w[i]+j]=max(mx[w[i]+j], mx[j]+v[i]);
        }

    }
  	cout<<*max_element(mx.begin(),mx.end())<<el;
}

int main(){
  solve();
  return 0;
}

Measured memory_bytes: 4040
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>

#define INF 1000000000
#define MOD 1000000007
#define ll long long
#define rep(i,a,b) for(int32 i = (a); i < (b); ++i)
#define rrep(i,a,b) for(int32 i = (b) - 1; i >= (a); --i)
#define bitget(a,b) (((a) >> (b)) & 1)
#define vint vector<int>
#define ALL(x) (x).begin(),(x).end()
#define C(x) cout << #x << " : " << x << endl
#define scanf scanf_s

using uint16 = uint_fast32_t;
using int32 = int_fast32_t;
using int64 = int_fast64_t;
using uint32 = uint_fast32_t;
using uint64 = uint_fast64_t;

using namespace std;




int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	uint32 n;
	cin >> n;
	uint16 f[100] = {};
	int32 p[100][11] = {};
	int32 a;
	rep(i, 0, n) {
		rep(j, 0, 10) {
			cin >> a;
			if (a) f[i] |= 1 << j;
		}
	}
	rep(i, 0, n) {
		rep(j, 0, 11)
			cin >> p[i][j];
	}
	int32 ans = -INF;
	for (uint16 i=1023;i;--i) {
		a = 0;
		rep(j, 0, n) {
			a += p[j][__builtin_popcount(i&f[j])];
		}
		ans = max(ans, a);
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <queue>
#include <set>

using namespace std;

typedef unsigned long long int ULL;
typedef long long LL;
typedef long double LD;

const LL inf = 1000000000000000;
const LL mod = 1000000007;

int main()
{
	LL a, b;
	cin >> a >> b;
	cout << max(a-2*b, 0LL) << endl;
	
	 
}

Measured memory_bytes: 764
#include <iostream>
#include <string>
#include <cstdlib>

using namespace std;

int main()
{
	string str;

	while (cin >> str)
	{
		for(int i=0; str[i] != '\0'; i++)
		{
			if(str[i] != '@'){
				cout << str[i];
			}else{
				/*char c = str[i+1];*/
				for(int j=0; j<str[i+1]-48 /*j<atoi(&c)*/; j++){
					cout << str[i+2];
				}
				i+=2;
			}
		}

		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 1172
#include<iostream>
using namespace std;
int N;
int main(){
    cin>>N;
    bool can=false;
    for(int i=0;i<=N/4;i++){
        for(int j=0;j<=N/7;j++){
            if(i*4+j*7==N){
                can=true;
            }
        }
    }
    if(can)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


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

int main(int argc, const char * argv[]) {
    int a, b, c;
    
    cin >> a >> b >> c;
    
    if(c >= a && c<=b){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    
    
    return 0;
}

Measured memory_bytes: 256
def solve():
    X,K,D = map(int, input().split())
    X = abs(X)
    pos = abs(X % D)
    neg = abs(pos - D)
    if X // D >= K:
        print(abs(X - D*K))
        return
    elif (X // D) % 2 == K %2:
        print(pos)
    else:
        print(neg)


solve()

Measured memory_bytes: 61904
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;
typedef string::const_iterator State;
class ParseError {};

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll INM = 114514;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll powm(ll a, ll b, ll c) {
	if (b == 0)
		return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	} else
		return (a * powm(a, b - 1, c)) % c;
}
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; }
ll dx[4] = {1, 0, -1, 0};
ll dy[4] = {0, 1, 0, -1};

int main() {
	IOS();
	ll n, a, b, c;
	cin >> n >> a >> b >> c;
	ll M = 364364;
	vector<ll> fact(M), facti(M);
	fact[0] = facti[0] = 1;
	for (int i = 1; i < M; i++) {
		fact[i]  = (fact[i - 1] * i) % MOD;
		facti[i] = powm(fact[i], MOD - 2, MOD);
	}
	ll ans = 0;
	//dump(powm(100ll - c, MOD - 2, MOD));
	for (ll m = n; m < 2 * n; m++) {
		ll c2   = (((fact[m - 1] * facti[n - 1]) % MOD) * facti[m - n]) % MOD;
		ll unko = powm(a + b, m, MOD);
		ll x	= (((powm(a, n, MOD) * powm(b, m - n, MOD) + powm(b, n, MOD) * powm(a, m - n, MOD)) % MOD) * powm(unko, MOD - 2, MOD)) % MOD;
		ll y	= (100 * m * powm(100 - c, MOD - 2, MOD)) % MOD;
		ans += ((((c2 * x) % MOD) * y) % MOD);
		ans %= MOD;
	}
	dump(ans);
	return 0;
}


Measured memory_bytes: 6016
/*
      author  : nishi5451
      created : 14.08.2020 22:59:03
*/

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

const int INF = 2e9;

int main(){
    string s;
    cin >> s;
    int ans = INF;
    for(int i=0; i<int(s.size())-2; i++){
        string t = s.substr(i,3);
        int dif = abs(atoi(t.c_str()) -753);
        ans = min(ans,dif);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3616
#include<iostream>
using namespace std;
int main(){
    int m,f,r;
    for(int i=0; i<50; i++){
        cin>>m>>f>>r;
        if(m==-1&&f==-1&&r==-1) break;
        if(m==-1||f==-1)cout<<'F'<<endl;
        else if(m+f<30)cout<<'F'<<endl;
        else if(30<=m+f&&m+f<50){
            if(50<=r)cout<<'C'<<endl;
            else cout<<'D'<<endl;
        }
        else if(50<=m+f&&m+f<65)cout<<'C'<<endl;
        else if(65<=m+f&&m+f<80)cout<<'B'<<endl;
        else if(80<=m+f)cout<<'A'<<endl;
        }
}


Measured memory_bytes: 3072
#include <stdio.h>
int main(void){
    // Your code here!
    int N;
    scanf ("%d",&N);
    int i;
    for ( i = 0 ; i <= N / 7 ; i ++ )
    {
        if (( N - 7 * i ) % 4 == 0)
        {
            printf("Yes\n");
            return 0;
        }
    }
    
    printf("No\n");
    return 0;
    
}


Measured memory_bytes: 128
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

pos = [A, B, C, D, E]
wait_time = [10 - x % 10 if x % 10 != 0 else 0 for x in pos]
wait_time.sort()
print(sum(pos) + sum(wait_time[0:4]))


Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main ()
{
  int N,K,i=0;
  char s[50],ch;
  cin>>N>>K;
  cin>>s;
  while(i<N)
  {

      if(i==K-1)
      {
          ch=s[i];
          ch=tolower(ch);
          s[i]=ch;
      }
      i++;

  }
  cout<<s;
 cout<<endl;
}


Measured memory_bytes: 256
#ABC124C/Coloring_Colorfully_別解
def main():
    s = [int(x) for x in input()]
    odd = s[::2]
    even = s[1::2]
    cnt = 0

    if odd[0]:
        cnt = odd.count(0) + even.count(1)    
    else:
        cnt = odd.count(1) + even.count(0)
    print(cnt)
main()

Measured memory_bytes: 4636
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;

typedef long long ll;
typedef long double ld;

#define REP(i,a,n) for(int (i)=(a); (i)<(int)(n); (i)++)
#define rep(i,n) REP(i,0,n)
#define vec vector 

const int INF = 2e9;
const ll large_P = 1e9 + 7;


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

	vector<int> a(M), b(M);
	rep(i, M) cin >> a.at(i) >> b.at(i);
	rep(i, M) a.at(i)--;
	rep(i, M) b.at(i)--;

	Graph g(N);
	rep(i, M) g.at(a.at(i)).push_back(b.at(i));
	rep(i, M) g.at(b.at(i)).push_back(a.at(i));
    
    rep(i, N) sort(g.at(i).begin(), g.at(i).end());


	vector<int> c(N);
	rep(i, N) c.at(i) = i;

	int res = 0;
	//if (M >= 2){
		do {
			bool ok = false;
			for(int i = 0; i < N-1; i++){
              ok = false;
              if(!g.at(c.at(i)).empty()){
                if(binary_search (g.at(c.at(i)).begin(), g.at(c.at(i)).end(), c.at(i + 1))) ok =true;
              }
		      if (!ok) break;
			}
			if(ok) res++;

		} while(next_permutation(c.begin() + 1, c.end()));
	//}
	//else if (M == 1 && N == 2) res = 1;
	//else res = 0;

	
	cout << res << endl;


 }

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

typedef long long int ll;
typedef long double ld;

//****************************************************                
#define lp(var,start,end) for (ll var = start; var <end ; ++var)
#define rlp(var,start,end) for(ll var = start; var>=end ; var--)
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define pll pair<ll,ll> 
#define vpll vector<pll>
#define all(X) X.begin(),X.end()
#define endl "\n" //comment it for interactive questions
#define trace1(a) cerr << #a << ": " << a << endl;
#define trace2(a,b) cerr << #a << ": " << a << " " << #b << ": " << b << endl;
#define trace3(a,b,c) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << endl;
#define trace4(a,b,c,d) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << #d << ": " << d << endl;
#define OC   
#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
        //*******************************************************
//Some Functions

const ll MOD = (ll)1e9+7; //change it for other mods

ll powmod(ll a,ll b)
{
   ll res = 1;
   while(b > 0) {
      if(b & 1) res = (res * a) % MOD;
      a = (a*a)%MOD;
      b = b >> 1; 
  }
  return res % MOD;
}

void solve(ll testnum)
{
    ll x;
    cin >> x;
    if(x >= 30) {
    	cout << "Yes\n";
    } else {
    	cout << "No\n";
    }
}

int main()
{
    FAST_IO;
    #ifdef STIO 
      freopen("input.txt" , "r", stdin);
      freopen("output.txt" , "w", stdout);
    #endif
    ll t = 1;
    // cin >> t;
    for (ll i = 1; i <= t; i++) {
        solve(i);
    }
}

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

int main() {
  int N;
  cin >> N;
  vector<int> x(N + 1);
  cin >> x.at(N);
  for (int i = 0; i < N; i++) {
    cin >> x.at(i);
  }
  sort (x.begin(), x.end());
  int ans = x.at(1) - x.at(0);
  for (int i = 1; i < N; i++) { 
    int memo = x.at(i + 1) - x.at(i);
    ans = gcd(ans, memo);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3588
N = int(input())
H = list(map(int, input().split()))

A = [0 for _ in range(N)]
A[0] = 0
A[1] = abs(H[1]-H[0])

for i in range(N):
    if i > 1:
        A[i] = min(A[i-1] + abs(H[i]-H[i-1]), A[i-2] + abs(H[i]-H[i-2]))

print(A[-1])    


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

const int MAX_V = 100010;
vector<int> G[MAX_V];

int main()
{
    int N, M;
    cin >> N >> M;
    for (int i = 0; i < M; i++)
    {
        int A, B;
        cin >> A >> B;
        --A;
        --B;
        G[A].push_back(B);
        G[B].push_back(A);
    }

    bool seen[N];
    int ans[N];
    fill_n(seen, N, false);
    fill_n(ans, N, -1);
    queue<int> que;
    que.push(0);
    seen[0] = true;
    while (!que.empty())
    {
        int from = que.front();
        que.pop();
        for (int to : G[from])
        {
            if (!seen[to])
            {
                seen[to] = true;
                ans[to] = from;
                que.push(to);
            }
        }
    }

    // 更新できていないものがないかチェック
    for (int i = 1; i < N; i++)
    {
        if (ans[i] == -1)
        {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    for (int i = 1; i < N; i++)
    {
        cout << ans[i] + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 10508
// Date: 2020-05-04

#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef long double LD;
typedef vector<int> VI;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
#define IO freopen("in.txt", "r", stdin);freopen("out.txt", "w", stdout)
#define FIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define rep(i, a, b) for(int i = int(a); i <= int(b); ++i)
#define per(i, b, a) for(int i = int(b); i >= int(a); --i)
#define D(x) cout << #x << " = " << x << endl;
#define mem(x, y) memset(x, y, sizeof(x))
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)x.size())
#define mk make_pair
#define pb push_back
#define fi first
#define se second
const LL INF = 1e18;
const LL mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int N = 2e5 + 10;
template <typename T> void chkmax(T &x, T y) { x = max(x, y); }
template <typename T> void chkmin(T &x, T y) { x = min(x, y); }
LL qpow(LL x, LL y, LL MOD) {LL a=1; while(y){ if(y&1) a=a*x%MOD; x=x*x%MOD; y>>=1; } return a;}

pii op[N];
string s;
int n, m;

int cal(int x) {
    rep(i, 1, m) {
        if(0 <= x && x < n && op[i].fi + 'A' == s[x]) x += op[i].se;
    }
    return x;
}

int main() {
    FIO;
    cin >> n >> m >> s;
    rep(i, 1, m) {
        char t, d;
        cin >> t >> d;
        op[i] = mk(t-'A', d == 'L' ? -1 : 1);
    }
    int l = 0, r = n-1, ansl = -1;
    while(l <= r) {
        int mid = (l + r) >> 1;
        if(cal(mid) <= -1) {
            ansl = mid;
            l = mid + 1;
        } else r = mid - 1;
    }
    l = 0, r = n-1;
    int ansr = n;
    while(l <= r) {
        int mid = (l + r) >> 1;
        if(cal(mid) >= n) {
            ansr = mid;
            r = mid - 1;
        } else l = mid + 1;
    }
    cout << ansr-ansl-1;

    return 0;
}

Measured memory_bytes: 2196
using System;

namespace ITP1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);
           
            Console.WriteLine(a/b+" "+a%b+" " + ((double)a / b).ToString("f5"));

        }
    }
}

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

int main() {
  int N , A;
  cin >> N >> A;
  
  if (N <= A) {
    cout << "Yes" << endl;
    return 0;
  }
  for (int i = 0; i <= A ; i++) {
   	if ((N-i) % 500 == 0) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  
  cout << "No" << endl;
  
}

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

using namespace std;

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

    int k, ans = 0;
    cin >> k;

    for (int i = 1; i <= k; i++)
        for (int j = 1; j <= k; j++)
            for (int l = 1; l <= k; l++)
                ans += __gcd(__gcd(i, j), l);
    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 3612
import java.io.*;
import java.util.*;
class Main{
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int a= 0;
		int five = 0;
		int seven = 0;
		for(int i = 0;i < 3;i++){
			a = saori.saori_hayami();
			if(a == 5){
				five++;
			}
			if(a == 7){
				seven++;
			}
		}
		if(five == 2 && seven == 1){
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 22228
#include<iostream>
#include<vector>
using namespace std;
void solve(vector<vector<int>>* adj,vector<int>* q,int r,vector<int>* p,vector<int>* ans);


void solve();

int main(){
  int n,q; cin >> n >> q;
  vector<vector<int>> adj(n);
  for(int i=0;i<n-1;i++){
    int a,b; cin >> a >> b;
    a--;b--;
    adj.at(a).push_back(b);
    adj.at(b).push_back(a);
  }
  vector<int> query(n,0);
  for(int i=0;i<q;i++){
    int p,x; cin >> p >> x;
    query.at(p-1)+=x;
  }
  vector<int> parent(n,-1);
  vector<int> ans(n,0);
  solve(&adj,&query,0,&parent,&ans);
  for(int i=0;i<n;i++){
    cout << ans.at(i) << " ";
  }
}

long int temp=0;
void solve(vector<vector<int>>* adj,vector<int>* q,int r,vector<int>* p,vector<int>* ans){
  temp+=(*q).at(r);
  (*ans).at(r)=temp;
  for(const auto& v: (*adj).at(r)){
    if((*p).at(r)==v)continue;
    (*p).at(v)=r;
    solve(adj,q,v,p,ans);
  }
  temp-=(*q).at(r);
}


Measured memory_bytes: 34432
import sys
a,b = map(int, input().split())
s = input()
count = 0
if(s[a]!="-"):
    print("No")
    sys.exit()
else:
    for i in range (len(s)):
        if(s[i]=="-"):
            count += 1
if (count == 1):
    print("Yes")
else: 
    print("No")

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

int main(){
  int N,M,C;
  cin >> N >> M >> C;
  vector<int> B(M);
  vector<vector<int>> A(N,vector<int>(M));
  for(int i=0;i<M;i++){
    cin >> B.at(i);
  }
  for(int i=0;i<N;i++){
    for(int j=0;j<M;j++){
      cin >> A.at(i).at(j);
    }
  }
  int counter=0;
  for(int i=0;i<N;i++){
    int sum=0;
    for(int j=0;j<M;j++){
      sum += A.at(i).at(j)*B.at(j);
    }
    sum += C;
    if(sum > 0){
      counter++;
    }
  }
  cout << counter << endl;
}

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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  int X, Y;
  cin >> X >> Y;

  cout << X + Y / 2 << endl;

  return 0;
}


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

#define rep3(i, s, n ,a) for (int i = (s); i < (int)(n); i+=a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

int main(){
    double r;
    cin >> r;
    cout << 2 * r * M_PI << endl;
    return 0;
}

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


int main(void){
    int K;
    cin >> K;
    
    queue<long long int> queue;
    for(int i=1; i<=9; i++) queue.push(i);
    long long int x;
    for(int k=0; k<K; k++) {
        x = queue.front();
        queue.pop();
        if(x%10 != 0) queue.push(x*10 + x%10 - 1);
        queue.push(x*10 + x%10);
        if(x%10 != 9) queue.push(x*10 + x%10 + 1);
    }
    cout << x << endl;
    return 0;
}


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

int main() {
  int N, A;
  cin >> N >> A;
  int num;
  num = N % 500;
  if (A >= num) {
    cout << "Yes" << endl;
  }
  if (A < num) {
    cout << "No" << endl;
  }
}

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

int main(){
  ll n;
  cin>>n;
  vector<ll>v;
  ll x;
  ll psum[n];
  for(ll i=0; i<n; i++){
    cin>>x;
    v.push_back(x);
  }
  psum[0]=v[0];
  for(ll i=1; i<n; i++){
    psum[i]= psum[i-1]+v[i];
  }
  ll dp[n][n];
  memset(dp,0,sizeof(dp));
  for(ll i=0; i<n; i++){
    dp[i][i] =0;
  }
  ll j;
  ll mval;
  for(ll ln=2; ln<=n; ln++){
    for(ll i=0; i<n+1-ln; i++){
      j = i+ln-1;
      dp[i][j] = 1e18;
      for(ll k=i; k<j; k++){
        mval = i==0?dp[i][k] + dp[k+1][j] + psum[j] : dp[i][k] + dp[k+1][j] + psum[j]-psum[i-1];
        if(mval<dp[i][j]){
          dp[i][j] = mval;
        }
      }
      
    }
  }
  cout<<dp[0][n-1]<<"\n";
  return 0;
}


Measured memory_bytes: 4792
#include <stdio.h>
#include <string.h>
 
int main(){
    char a[26] ,b[26], c[26];
    scanf("%s %s %s", &a, &b, &c);
 
    int x = strlen(a), y = strlen(b);
    if(a[x-1] == b[0] && b[y-1] == c[0]){
        printf("YES \n");
    }else {
        printf("NO \n");
    }
    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    ll n, t; cin >> n >> t;
    vector<pair<ll, ll>> ab(n);
    rep(i, n) cin >> ab[i].first >> ab[i].second;
    sort(all(ab));

    // dp[i][j]; i番目の料理まででj分までに完食できる美味しさの最大値（i番目の料理はt-1時点で注文する）
    vvi dp(n+1, vi(t+1, 0));

    rep(i, n){
        rep(j, t){
            chmax(dp[i+1][j], dp[i][j]);
            if(ab[i].first <= j){
                chmax(dp[i+1][j], dp[i][j-ab[i].first]+ab[i].second);
            }
            if(j == t-1) dp[i][j] += ab[i].second;
        }
    }
    ll ans = 0;
    rep(i, n) chmax(ans, dp[i][t-1]);
    cout << ans << endl;
}

Measured memory_bytes: 73632
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
   for(int i=1;i<=9;++i)
   {
	   for(int k=1;k<=9;++k)
	   {
		   cout<<i<<"x"<<k<<"="<<i*k<<endl;
	   }
   }
   return 0;
}

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

int main(){
    int a,b,t; cin >> a >> b >> t;
    int s = 0;
    int k = a;
    while(k < t + 0.5){
        s += b;
        k += a;
    }
    cout << s;
}

Measured memory_bytes: 256
(unless (member :child-sbcl *features*)
  (quit
   :unix-status
   (process-exit-code
    (run-program *runtime-pathname*
                 `("--control-stack-size" "128MB"
                   "--noinform" "--disable-ldb" "--lose-on-corruption" "--end-runtime-options"
                   "--eval" "(push :child-sbcl *features*)"
                   "--script" ,(namestring *load-pathname*))
                 :output t :error t :input t))))

(let* ((n (read))
       (q (read))
       (graph (make-array n :element-type 'list :initial-element nil))
       (qval (make-array n :initial-element 0))
       (ans (make-array n :initial-element 0)))
  (dotimes (i (1- n))
    (let ((a (1- (read)))
          (b (1- (read))))
      (push b (aref graph a))
      (push a (aref graph b))))
  (dotimes (i q)
    (let ((p (1- (read)))
          (x (read)))
      (incf (aref qval p) x)))
  (labels
    ((dfs (x val parent)
       (setf (aref ans x) (+ (aref qval x) val))
       (dolist (child (aref graph x))
         (unless (= child parent)
           (dfs child (aref ans x) x)))))
    (dfs 0 0 -1))
  (dotimes (i n)
    (format t "~A " (aref ans i)))
  (fresh-line))

Measured memory_bytes: 91160
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <random>
#include <utility>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <stdlib.h>
#include <algorithm>
#include <vector>
 
using namespace std;
typedef long long ll;
 
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<int> G[100005];
std::vector<P> tree[100010];
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
 
ll i,j,k;
ll n,m;
ll a[100005],b[100005];
ll ans=0;

int main(){
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a[i]>>b[i];
	}
	for(i=n-1;i>=0;i--){
		if((a[i]+ans)%b[i]!=0)
		ans += (b[i]-(a[i]+ans)%b[i]);
	}
	cout<<ans<<endl;
	return 0;
}

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


signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
    
    ll n,k;
    cin>>n>>k;
    ll a[n],f[n];
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<n;i++) cin>>f[i];
    sort(a,a+n);
    sort(f,f+n,greater<ll>());
    ll low=-1,up=1e18,mid;
    while(up-low>1){
        mid = (up+low)/2;
        ll rem=k;
        for(int i=0;i<n;i++){
            if(a[i]*f[i]>mid){
                rem -= a[i] - mid/f[i];
            }
        }
        if(rem<0) low = mid;
        else up = mid;
    }
    cout << up << endl;
}

Measured memory_bytes: 3328
#include <iostream>
using namespace std;
const int m=510;
char a[m][m];
bool b[m][m],c[m][m];
int main()
{
	int h,w;
	cin>>h>>w;
	for(int i=1; i<=h; i++) {
		for(int j=1; j<=w; ++j) {
			cin>>a[i][j];
			if (a[i][j]=='#') b[i][j]=c[i][j]=true;
		}
	}
	for(int i=1; i<=w; ++i) {
		b[1][i]=true;
		c[h][i]=true;
	}
	for(int i=2; i<h; i++) {
		for(int j=1; j<=w; ++j) {
			if(j%2==0)
			b[i][j]=true;
			else
			c[i][j]=true;
		}
	}
		for(int i=1; i<=h; i++) {
		for(int j=1; j<=w; ++j) {
			cout<<(b[i][j]?'#':'.');
		}
		puts("");
	}
			puts("");
		for(int i=1; i<=h; i++) {
		for(int j=1; j<=w; ++j) {
			cout<<(c[i][j]?'#':'.');
		}
		puts("");
	}
			puts("");
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
 
int cnt_digits(ll N){
  int digits = 0;
  while(N > 0){
    digits++;
    N /= 10;
  }
  
  return digits;
}

int main() {
 
  ll N; cin >> N;
  
  int ans = cnt_digits(N);
  
  for(ll A = 1; A * A <= N; A++){
    if(N % A != 0) continue; //Aが約数でないなら次へ
    
    ll B = N / A;
    
    int temp = max(cnt_digits(A), cnt_digits(B));
    
    if(ans > temp) ans = temp;
    
  }
  
  cout << ans << endl;
  
}

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

#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x, n)                                                       \
    for(long long hoge = 0; (hoge) < (n); ++(hoge))                            \
    cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

using ll = long long;
using ull = unsigned long long;
const ll INF = LLONG_MAX / 2;
const ll MOD = 1e9 + 7;

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    ll N;
    cin >> N;
    ll A[5];
    for(int i = 0; i < 5; i++) {
        cin >> A[i];
        if(i)
            A[i] = min(A[i], A[i - 1]);
    }
    ll ans = 0;
    for(int i = 0; i < 5; i++) {
        ll T = (N - 1) / A[i];
        if(i + 1 < 5)
            N = (ans + T - i) * (A[i] - A[i + 1]) + (N - T * A[i]);
        ans += T + 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int S,h,m,s;
  scanf("%d", &S);
  h = S/3600;
  m = (S-3600*h)/60;
  s = S-3600*h-60*m;
  printf("%d:%d:%d\n",h,m,s);
  return 0;
}

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

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

    vector<int> s;
    for (int i=0; i<S.size(); ++i) {
        s.push_back(S[i]-'0');
    }

    int n = s.size() - 1;
    ll sum = 0;  // 総和
    for (int bit=0; bit < (1<<n); ++bit) {
        ll psum = 0;
        for (int i=0; i<n; ++i) {
            if (bit & (1<<i)) {
                sum += 10 * psum + s[i];  // psumを加える
                psum = 0;  // 初期化
            } else {
                psum = 10 * psum + s[i];
            }
        }
        sum += 10 * psum + s[n];
    }

    cout << sum << endl;
}

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

int main(){
    int d;
    cin >>d;
    switch(d){
        case 25:
            cout<<"Christmas"<<endl;
            break;
        case 24:
            cout<<"Christmas Eve"<<endl;
            break;
        case 23:
            cout<<"Christmas Eve Eve"<<endl;
            break;
        case 22:
            cout<<"Christmas Eve Eve Eve"<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
def main():

    N = int(input())
    X = list(map(int, input().split()))
    X.sort()
    ans = float('inf')
    for y in range(min(X), max(X)+1):
        p = 0
        for i in range(N):
            p += pow(y - X[i], 2)
        ans = min(ans, p)
    return ans

if __name__ == '__main__':
    print(main())


Measured memory_bytes: 39280
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
#include <numeric>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<ll, ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<P> vp;
typedef vector<bool> vb;
#define rep(i, a, n) for (ll i = (a); i < (n); ++i)
#define rrep(i, a, n) for (ll i = (a); i > (n); --i)
#define erep(i, a, n) for (ll i = (a); i <= (n); ++i)
#define rerep(i, a, n) for (ll i = (a); i >= (n); --i)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
#define vec_max(V) *max_element(all(V))
#define vec_min(V) *min_element(all(V))
#define vec_sum(V) accumulate(all(V), 0LL)
#define print(X) cout << (X) << "\n"
#define _ << " " <<
#define Yes print("Yes")
#define No print("No")
static const int INF = 1e+9+7;

int main(){
  ll N,M;
  cin >> N >> M;
  vll X(M);
  rep(i,0,M) cin >> X[i];

  if(N >= M) print(0);
  else {
    sort(all(X));

    vll sa(M-1);
    rep(i,0,M-1){
      sa[i] = abs(X[i+1] - X[i]);
    }
    sort(all(sa));
    ll sum_sa = vec_sum(sa);

    rep(i,0,N-1) sum_sa -= sa[M-2-i];

    print(sum_sa);
  }

  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef pair<int,int> pii;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
template<class Type> void line(const Type &a){int cnt=0;for(auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	int x;
	cin>>x;
	
	int jud=0;
	int cnt=x/100;
	int rest=x-100*cnt;
	while(cnt>0){
		int tmp=rest/5;
		int tmpp=rest%5;
		if((tmpp==0 and tmp<=cnt)or tmp<cnt){
			jud=1;
			break;
		}
		
		cnt--;
		rest+=100;
	}
	
	cout<<jud<<endl;
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <cstdint>
#include <tuple>
#include <numeric>
#define M_PI       3.14159265358979323846


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FILL(a, x) memset(a, x, sizeof(a))

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)

int main() {
	int n, l;
	scanf("%d%d", &n, &l);
	int s = 0;
	int x = l;
	REP(i, n) {
		s += l + i;
		if (abs(x) > abs(l + i))x = l + i;
	}
	s -= x;
	printf("%d\n", s);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using ll = long long;
using namespace std;
const long long INF = 1LL << 60;
const int inf = 1e9;
ll mod = 1e9 + 7;

int main()
{
    int r;
    cin >> r;
    cout << 3 * r * r << endl;
    return 0;
}

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

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

const ll MOD = 1e9+7;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    std::cout << min(n*a, b) << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stack>
using namespace std;
int main(){
  stack<int>st[2];
  int n,f;
  cin >> n;
  while(n--){
    f = 1;
    st[0].push(0);st[1].push(0);
    int i;
    for(i = 0 ; i < 10 ; i++ ){
      int a;
      cin >> a;
      if(a-st[0].top() > 0 && a-st[1].top() <= 0){
	st[0].push(a);
      } else if(a-st[1].top() > 0 && a-st[1].top() <= 0){
	st[1].push(a);
      } else if(a-st[1].top() > 0 && a-st[1].top() > 0){
	if(st[1].top() < st[0].top())st[0].push(a);
	else st[1].push(a);
      }else{f=0;}
    }
    if(f)cout << "YES" << endl;
    else cout << "NO" << endl;
  }
}

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

using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;

ll power(ll a, ll b) {
  if(b==0) return 1;
  ll res = power(a, b/2);
  res *= res;
  res %= mod;
  if(b&1) {
    res *= a;
    res %= mod;
  }
  return res;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  cin >> n;
  if(n==1) {
    cout << "0\n";
    return 0;
  }
  ll ans = power(10LL, n);
  ans -= 2*power(9LL, n);
  ans = (ans+mod*mod)%mod;
  ans += power(8LL, n);
  ans %= mod;
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <cmath>

using namespace std;

int main() {
	int N;
	while (cin >> N) {
		if (N == 0) {
			break;
		}
		int n, d;
		int x[300] = {0};
		int y[300] = {0};
		int vx[] = {-1, 0, 1, 0};
		int vy[] = {0, -1, 0, 1};
		int maxx, maxy, minx, miny;
		maxx = maxy = 0;
		minx = miny = 0;
		for (int i = 1; i < N; i++) {
			cin >> n >> d;
			x[i] = x[n]+vx[d];
			y[i] = y[n]+vy[d];
			maxx = max(maxx, x[i]);
			maxy = max(maxy, y[i]);
			minx = min(minx, x[i]);
			miny = min(miny, y[i]);
			//cout << endl << x[i] << " " << y[i] << endl;
		}
		cout << maxx-minx+1 << " " << maxy-miny+1 << endl;
	}
	return 0;
}

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

using ipair = pair<int, int>; 

int main() {
    int n;
    cin >> n;
    priority_queue<ipair, vector<ipair>, greater<ipair>> que;
    for (int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        que.push(make_pair(b, a));
    }
    int current = 0;
    while (que.size()) {
        int limit = que.top().first;
        int required = que.top().second;
        que.pop();
        current += required;
        if (current <= limit) continue;
        else {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
} 


Measured memory_bytes: 2420
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;

int main(){
  string s, t;
  cin >> s >> t;
  vector<vector<int>> dp(3010, vector<int>(3010));
  rep(i, s.length()) {
    rep(j, t.length()) {
      if (s[i] == t[j]) {
        dp[i + 1][j + 1] = dp[i][j] + 1;
      }
      dp[i + 1][j + 1] = max(dp[i + 1][j], max(dp[i + 1][j + 1], dp[i][j + 1]));
    }
  }
  string ans = "";
  int i = s.length();
  int j = t.length();
  while(i > 0 && j > 0) {
    if (dp[i][j] == dp[i][j - 1]) {
      --j;
    } else if (dp[i][j] == dp[i - 1][j]) {
      --i;
    } else {
      ans = s[i - 1] + ans;
      --i; --j;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 35840
#include <iostream>
#include <string>

using namespace std;

int main() {
	int n; cin >> n;
	string s; cin >> s;
	int ans = 0;
	for (int i = 0; i < n - 2; ++i)
		if (s.substr(i, 3) == "ABC") ++ans;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<utility>
#include<math.h>

using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pair<int, int> > vp;

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define For(i, a, n) for(int i = a; i < (n); i++)
#define out(n) cout << (n) << endl;
#define vut(v) rep(i, v.size()) out(v[i]);

int main(){
  int a, ans = 1;
  cin >> a;
  vi b(a);
  int f = -1;
  rep(i, a) cin >> b[i];

  For(i, 1, a) {
    if(b[i - 1] == b[i]) continue;

    f = b[i - 1] < b[i] ? false : true;
    break;
  }

  if(f == -1) {
    out(1)
    return 0;
  }
  For(i, 1, a) {
    if(f ? b[i - 1] < b[i] : b[i - 1] > b[i]) {
      ans++;
      if(b[i + 1]) {
        f = -1;
        For(j, i, a) {
          if(b[j] == b[j + 1]) continue;

          f = b[j] < b[j + 1] ? false : true;
          break;
        }
        if(f == -1) {
          out(ans)
          return 0;
        }
      }
    }
  }

  out(ans);
}


Measured memory_bytes: 1024
n, q = gets.split.map(&:to_i)
a = n.times.map{[]}

q.times do
  command, num1, num2 = gets.split.map(&:to_i)
  case command
  when 0
    a[num1].push num2
  when 1
    puts a[num1][-1] if !a[num1].empty?
  else
    a[num1].pop if !a[num1].empty?
  end
end


Measured memory_bytes: 8568
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {

        Scanner stdId = new Scanner(System.in);
        int a;
        int cnt = 0;

        while (true) {
            a = stdId.nextInt();
            if (a == 0) {
                break;
            } else {
                cnt++;
                System.out.println("Case " + cnt + ": " + a);
                //Case 1: 3
            }
        }
    }
}

Measured memory_bytes: 40356
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>
#include <iomanip>

using namespace std;
bool changed[100];
int main(){ 
    string S;
    cin >> S;
    long long K;
    cin >> K;

    if(S.size() == 1){
        cout << K / 2 << endl;
        return 0;
    }
    long long tmp_ans = 0;
    for(int i = 0; i < S.size(); i++){
        if(S[i] == S[(i + 1) % S.size()] && !changed[i]){
            tmp_ans ++;
            changed[(i + 1) % S.size()] = true;
        }
    }

    if(!changed[0]){
        cout << tmp_ans * K << endl;
    } else {
        long long changed_front_ans = 0;
        for(int i = 0; i < S.size(); i++){
            changed[i] = false;
        }
        for(int i = 1; i < S.size(); i++){
            if(S[i] == S[(i + 1) % S.size()] && !changed[i]){
                //cout << i << " " << changed_front_ans << endl;
                changed_front_ans ++;
                changed[(i + 1) % S.size()] = true;
            }
        }
        if(changed[0]){
            cout << tmp_ans + (K - 1) * changed_front_ans - 1 << endl;;
        } else {
            if(K % 2 == 0){
                cout << tmp_ans * (K / 2) + changed_front_ans * (K / 2) << endl;;
            } else {
                cout << tmp_ans * (K / 2 + 1) - 1 + changed_front_ans * (K / 2) << endl;; 
            }
        }
            //cout << tmp_ans << " " << changed_front_ans << endl;

    }
    return 0;
}

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

int main(){
  long long int N;
  cin >> N;
  long long int ans;
  for(long long int i=1; i<=sqrt(N); i++){
    if(N%i==0){
      ans = N/i+i-2;
    }
  }
  
  cout << ans;
  return 0;
}

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

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

	ll ans = 0, i = x;
	while(i <= y) {
		ans++;
		i *= 2;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 384