akhauriyash/Code-Regression huggingface dataset:
n, m, Q = map(int, input().split())
data = [[0]*(n+2) for i in range(n+2)]
for i in range(m):
    l, r = map(int, input().split())
    data[l][r] += 1

for i in range(n+2):
    for j in range(n+1):
        data[i][j+1] += data[i][j]

for i in range(n+1, -1, -1):
    for j in range(n+2):
        data[i-1][j] += data[i][j]

for i in range(Q):
    p, q = map(int, input().split())
    print(data[p][q])


Measured memory_bytes: 9460
/*IT'S A VERY LONG ROAD BUT IT WILL BE WORTH IT*/
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back 
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define ld long double
#define int long long int
const int N = 1e6;
bool prime[N+1];
vector<int> ans;
void seive()
{
    memset(prime,true,sizeof(prime));
    prime[1] = 0;
    for(int i=4;i<=N;i+=2)
        prime[i] = 0;
    for(int i=3;i*i<=N;i++)
    {
        if(prime[i])
        {
            for(int j = i*i;j<=N;j+=i)
            {
                prime[j] = 0;
            }
        }
    }
    for(int i=2;i<=N;i++)
    {
        if(prime[i])
            ans.pb(i);
    }
}
signed main() 
{ 
    fast;
    seive();
    int x;
    cin>>x;
    auto ff = lb(all(ans),x);
    cout<<(*ff);
} 

Measured memory_bytes: 2424
N,A,B,C,D=map(int,input().split())
S=input()

ans='Yes'
if '##'in S[A-1:C]:
    ans='No'
elif '##'in S[B-1:D]:
    ans='No'
elif C>D and ('...'not in S[B-2:D]):
    ans='No'
    if S[D-2]=='.' and S[D]=='.':
        ans='Yes'

print(ans)

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

using namespace std;

typedef long long int64;

int main()
{
  int N, K, A[100000];
  cin >> N >> K;
  for(int i = 0; i < N; i++) cin >> A[i];
  int gcd = A[0];
  for(int i = 1; i < N; i++) gcd = __gcd(gcd, A[i]);
  if(K % gcd == 0 && K <= *max_element(A, A + N)) puts("POSSIBLE");
  else puts("IMPOSSIBLE");
}

Measured memory_bytes: 640
#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};

ll ans[200002]	= {};
bool used[200002] = {};
vector<ll> g[200002];

void rec(int v, ll sum) {
	used[v] = true;
	ans[v] += sum;
	for (int i = 0; i < g[v].size(); i++) {
		if (!used[g[v][i]]) {
			rec(g[v][i], ans[v]);
		}
	}
}

int main() {
	IOS();
	ll n, q;
	cin >> n >> q;
	for (int i = 0; i < n - 1; i++) {
		ll a, b;
		cin >> a >> b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	for (int i = 0; i < q; i++) {
		ll p, x;
		cin >> p >> x;
		ans[p] += x;
	}
	rec(1, 0);
	for (int i = 1; i <= n; i++) {
		cout << ans[i] << (i == n ? "\n" : " ");
	}
	return 0;
}

Measured memory_bytes: 24448
# loop number
N = STDIN.gets.to_i

# this number will be used when decided to plus
K = STDIN.gets.to_i

# target number is 1 at first
displayed_number = 1

N.times do |_n|
  if displayed_number <= K
    displayed_number *= 2
  else
    displayed_number += K
  end
end

puts displayed_number

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
using ll = long long; 
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
template<class T> using pq = priority_queue<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
int main() { // 問題文はしっかり読め!!!
	int n;
	cin >> n;
	V a(n);
	rep(i, n) {
		cin >> a[i];
	}
	int s = a[0];
	rep1(i, n - 1) {
		s = gcd(s, a[i]);
	}
	cout << s << endl;
	return 0;
}

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

N = int(input())
L = [int(v) for v in input().split()]

ans = 0
for i in range(1, N - 1):
    p = L[i-1:i+2]
    p.sort()
    
    if p[1] == L[i]:
        ans += 1
    
print(ans)

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

#define NREP() for(ll i = 0; i < n; i++)
#define MREP() for(ll j = 0; j < m; j++)
#define REP(i, x, y) for(ll i = x; i < y; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define MSGF(x, n) MSG(fixed << setprecision(n) << x)
#define END(x) cout << x << endl; exit(0);
#define IPT(v, n) REP(i, 0, n){ cin >> v[i]; }
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<ull> vul;
typedef vector<vector<ull>> vvul;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
const static ll INF = 1LL << 30;

ll a, b, c, d, k, l, m, n, h, w, q, x, y;
string s, t;

ll ans = 0;
ll sum = 0;
ll cnt = 0;
ll cur = 0;
ll tmp = 0;
ll mini = INF;
ll maxi = 0;

double ave = 0.0;

ll mod_pow(ll base, ll power) {
    if (power == 0) return 1;
    if (power == 1) return base % MOD;
    if (power % 2 == 0) return ((mod_pow(base % MOD, (power / 2)) % MOD) * (mod_pow(base, (power / 2)) % MOD)) % MOD;
    return (base % MOD * (mod_pow(base % MOD, power - 1) % MOD)) % MOD;
}

ll mod_fact(ll number) {
    ll ret = 1;
    ll count = 1;
    while (count <= number) {
        ret *= (count % MOD);
        ret %= MOD;
        count++;
    }
    return ret % MOD;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    cin >> s;
    char t = s.at(s.length() - 1);
    if (t == '2' || t == '4' || t == '5' || t == '7' || t == '9') {
        cout << "hon" << endl;
    } else if (t == '0' || t == '1' || t == '6' || t == '8') {
        cout << "pon" << endl;
    } else {
        cout << "bon" << endl;
    }
}


Measured memory_bytes: 3616
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		int[][]A = new int[N][];
		for(var i=0;i<N;i++){
			string[] str = Console.ReadLine().Split();
			A[i] = new int[2]{int.Parse(str[0]),int.Parse(str[1])};
		}
		Array.Sort(A,(x,y)=>x[0]-y[0]);
		int ans = 0;
		for(var i=0;i<N;i++){
			for(var j=0;j<N;j++){
				if(i==j){
					continue;
				}
				int p = A[j][0]-A[i][0];
				int q = A[j][1]-A[i][1];
				int ct = 0;
				for(var i2=0;i2<N;i2++){
					for(var j2=0;j2<N;j2++){
                      	if(i2==j2){
                          continue;
                        }
						if(A[j2][0]-A[i2][0]==p && A[j2][1]-A[i2][1]==q){
							ct++;
						}
					}
				}
				ans = Math.Max(ans,ct);
			}
		}
		Console.WriteLine(N-ans);
	}
}

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

//define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define fi first
#define se second

//template
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << p.first << " " << p.second;return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if (it != v.begin())os << " ";os << *it;
  }return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void print(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void print(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}

//typedef
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;

int a[10], b[10];
signed main(){
	while(1){
		int x, y;
		scanf("%lld%lld", &x, &y);
		if(x == 0 and y == 0)break;
		a[0] = x;b[0] = y;
		rep(i,4)scanf("%lld%lld", &a[i+1], &b[i+1]);
		rep(i,5)a[i] += b[i];
		int mx = *max_element(a, a+5);
		rep(i,5)if(a[i] == mx)printf("%c %lld\n", "ABCDE"[i], a[i]);
	}
	return 0;
}







Measured memory_bytes: 3148
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		int[] L = new int[N];
		for (int i = 0; i < N ; i++) {
			L[i] = sc.nextInt();
		}
		Arrays.sort(L);
		int ans = 0;
		for (int i = 0; i < N-2; i++) {
			for (int j = i+1; j < N -1; j++) {
				for (int k = N-1; k > j; k--) {
					if (L[i] + L[j] > L[k]) {
						ans += k - j;
						break;
					}
				}
			}
		}
		System.out.println(ans);
	}
	
	public static long gcd(long a, long b) {
		long remainder = a % b;
		if (remainder == 0) {
			return b;
		} else {
			return gcd(b, remainder);
		}
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


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

signed main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    
    //int t=1 ; cin>>t ; while(t--)
    {
        int n, m;
        cin >> n >> m;
        int h[100] = {}, ans = 0;
        for(int i=0;i<n;i++)
        {
            int k;
            cin >> k;
            while(k--)
            {
                int x;
                cin >> x;
                h[x]++;
                if(h[x] == n)
                    ans++;
            }
        } 

        cout << ans << '\n';
    }
    
    cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
    return 0;
}



Measured memory_bytes: 256
a, b, c = map(int, input().split())

if b < a:
    t = b
    b = a
    a = t

if c < a:
    t = c
    c = a
    a = t

if c < b:
    t = c
    c = b
    b = t

print("{} {} {}".format(a, b, c))


Measured memory_bytes: 5596
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a[51],b[51];
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i],b[i]=a[i];
	sort(b+1,b+n+1);
	for(int i=0;i<=n;i++){
		for(int j=i;j<=n;j++){
			swap(a[i],a[j]);
			int f=1;
			for(int k=1;k<=n;k++)if(a[k]!=b[k]){f=0;break;}
			if(f){
				cout<<"YES";return 0;
			}
			swap(a[i],a[j]);
		}
	}
	cout<<"NO";
	return 0;
}

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

int main (void)
{
	int input1,input2;
	int i,j;
	do
	{
		scanf("%d %d",&input1,&input2);
		if(input1 == 0 && input2 == 0)
		{
			break;
		}
		for(i = 0 ; i < input1 ; i++)
		{
			for(j = 0 ; j < input2 ; j++)
			{
				if(j % 2 == i % 2 )
				{
					printf("#");
				}
				else
				{
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	}while(1);
	return 0;
}


Measured memory_bytes: 2028
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 100005;
char en = '\n';
ll inf = 1e16;
ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n;
  cin >> n;
  ll arr[n + 5];
  ll pos[n + 5];
  for (ll i = 1; i <= n; i++) {
    cin >> arr[i];
    pos[arr[i]] = i;
  }

  map<ll, ll> par;

  par[pos[n]];

  ll res = 0;
  for (ll i = n - 1; i >= 1; i--) {

    ll indx = pos[i];
    auto it = par.lower_bound(indx);

    ll l1 = 0, l2 = 0;

    if (it != par.begin()) {
      it--;

      l1 = it->first;
      if (it != par.begin()) {
        it--;
        l2 = it->first;
      }
    }

    it = par.lower_bound(indx);

    ll r1 = n + 1, r2 = n + 1;
    if (it != par.end()) {

      r1 = it->first;
      it++;
      if (it != par.end()) {
        r2 = it->first;
      }
    }

    res += i * ((l1 - l2) * (r1 - indx) + (r2 - r1) * (indx - l1));

    par[pos[i]];
  }

  cout << res << en;

  return 0;
}


Measured memory_bytes: 8064
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
using namespace std;
typedef long long ll;
int main(){
  int n,l;
  cin>>n>>l;
  int d=0;
  int ans=1;
  for(int i=1;i<=n;i++){
    int k;
    cin>>k;
    d+=k;
    if(d<=l) ans++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define for(i, m, n) for(int i = m; i < n; i++)
#define all(v) v.begin(), v.end()

typedef long long lint;
int main(){
    lint h,w;
    cin >> h;
    cin >> w;
    if((h == 1) || (w == 1))
        cout << 1 << endl;
    else
        cout << lint(((h * w) + 1) / 2) << endl;
}

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

const int MAX_N = 1120;

vector<int> sieve(int n) {
	vector<int> res(1, 2);
	vector<bool> prime(n, true);
	for(int i = 3; i < n; i += 2) {
		if(prime[i]) {
			res.push_back(i);
			for(long long j = static_cast<long long>(i) * i; j < n; j += i * 2)
				prime[j] = false;
		}
	}

	return res;
}

int main() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	const auto primes = sieve(MAX_N + 1);
	const int num = primes.size();

	for(int n, k; cin >> n >> k && n;) {
		vector<vector<int>> dp(n + 1, vector<int>(k + 1, 0));
		dp[0][0] = 1;

		for(int i = 0; i < num; ++i) {
			if(primes[i] > n) break;

			for(int j = n - primes[i]; j >= 0; --j) {
				for(int l = k - 1; l >= 0; --l) {
					dp[j + primes[i]][l + 1] += dp[j][l];
				}
			}
		}

		cout << dp[n][k] << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1336
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


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

  int now = 0;
  int cnt = 0;
  while(now < N) now += cnt++;

  if(N != now){
    cout << "No" << endl;
    return 0;
  }

  cnt--;
  cout << "Yes" << endl << cnt+1 << endl;

  now = 1;
  vector<vector<int>> v(cnt+5, vector<int>(cnt+5, 0));
  REP(i, cnt) REP(j, i+1){
    v[i][j] = now++;
  }

  vector<vector<int>> ans(cnt+1);
  REP(i, cnt) ans[0].emplace_back(v[i][i]);
  REP(i, cnt) ans[cnt].emplace_back(v[i][0]);

  FOR(i, 1, cnt){
    int x = i, y = 0;
    while(v[x][y] != 0) ans[i].emplace_back(v[x][y++]);
    y--; x++;
    while(v[x][y] != 0) ans[i].emplace_back(v[x++][y]);
  }

  REP(i, cnt+1){
    cout << ans[i].size() << " ";
    REP(j, ans[i].size()){
      cout << ans[i][j]; SPBR(j, ans[i].size());
    }
  }

  return 0;
}

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

using namespace std;

const int N = 1000017;
const int MOD = 1000 * 1000 * 1000 + 7;

int n, a, b;

bool read() {
    if (!(cin >> n >> a >> b))
        return false;

    return true;
}

void solve() {
    cout << min(a * n, b) << endl;
}

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

    while (read())
        solve();

    return 0;
}



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

typedef long long ll;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)

#define ALL(obj) (obj).begin(),(obj).end()

#define pii pair<int,int>

#define pb(a) push_back(a)
#define mp make_pair

int main()
{
	ll n;
	cin >> n;
/*	if(n == 0){
		ANS(0);
		return 0;
	}*/
	vector<int> ans;
	for(int k = 0;k < 50; k++){
		if(n % (ll)pow(-2,k+1) == 0){
			ans.pb(0);
		}else{
			ans.pb(1);
			n -= (ll)pow(-2,k);
		}
		//cout << s << "\n";
		if(n == 0)break;
	}
	FORR(i,(int)ans.size()-1,0)
		cout << ans[i];
	cout << "\n";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;


int main()
{
    int n,m,x;
    int str;
    int zuo=0,you=0;
    cin>>n>>m>>x;
    for(int i=1;i<=m;i++)
    {
        cin>>str;
        if(str>x)you++;
        else zuo++;
    }
    cout<<min(zuo,you)<<endl;

    return 0;
}


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

int main(){

    size_t n;
    std::cin >> n;
    
    std::vector<size_t> cnt(5, 0);

    for(size_t i = 0; i < n; i++){
        std::string in;
        std::cin >> in;

        if(in[0] == 'M'){
            cnt[0]++;
        }else if(in[0] == 'A'){
            cnt[1]++;
        }else if(in[0] == 'R'){
            cnt[2]++;
        }else if(in[0] == 'C'){
            cnt[3]++;
        }else if(in[0] == 'H'){
            cnt[4]++;
        }
    }

    std::vector<size_t> index = {0, 1, 2, 3, 4};
    size_t ans = 0;

    for(size_t i = 0; i < index.size() - 2; i++){
        for(size_t j = i + 1; j < index.size() - 1; j++){
            for(size_t k = j + 1; k < index.size(); k++){
                ans += cnt[index[i]] * cnt[index[j]] * cnt[index[k]];
            }
        }
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int a[13][4],i,j,b,c;
	char d;
	for(i=0;i<13;i++){
		for(j=0;j<4;j++){
			a[i][j]=0;
		}
	}
	scanf("%d",&b);
	while(b!=0){
		scanf("%s %d",&d,&c);
		if(d=='S'){
			a[c-1][0]=1;
		}
		else if(d=='H'){
		        a[c-1][1]=1;
		}
		else if(d=='C'){
		        a[c-1][2]=1;
		}
		else{
		        a[c-1][3]=1;
		}
		b--;
	}
	for(j=0;j<4;j++){
		for(i=0;i<13;i++){
			if(a[i][j]==0){
				if(j==0){
					printf("S %d\n",i+1);
				}
				else if(j==1){
					printf("H %d\n",i+1);
				}
				else if(j==2){
					printf("C %d\n",i+1);
				}
				else{
					printf("D %d\n",i+1);
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 596
#include <stdio.h>

int main(void) {
   int siz,i;
   int total = 0;
   scanf("%d",&siz);
   int a[siz];
   for (i = 0; i < siz; i++) {
        scanf("%d",&a[i]);
        total += a[i];
   }
   if (total % 10 != 0) { printf("%d",total);  return 0 ;}
   else {
      int min= 100;
      for (i = 0; i< siz; i++ ) {
       if (a[i] % 10 != 0 &&  a[i] < min) min = a[i];
      } 
      if (min == 100) {
        printf("0");
        return 0;
      } else  { 
          printf("%d", total-min);
          return 0;
        }
   }
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 30;
 
int main() {
  ll n,m;
  string s,t;
  cin >>n>>m>>s>>t;
  ll k = __gcd(n,m);
 
  ll x = n / k, y = m / k;
  for (int i = 0; i < k; i++)
  {
    if (s[i*x] != t[i*y]) {
      cout << -1 << endl;
      return 0;
    } 
  }
  cout << n/k*m << endl;
  return 0;
}

Measured memory_bytes: 3732
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var xy = Console.ReadLine().Split(' ').Select(num => int.Parse(num)).ToArray();
            var x = xy[0];
            var y = xy[1];
            var result = x * 4;
            if (result == y)
            {
                Console.WriteLine("Yes");
                return;
            }
            for (var i = 0; i < x; i++)
            {
                result -= 2;
                if (result == y)
                {
                    Console.WriteLine("Yes");
                    return;
                }
            }

            Console.WriteLine("No");
        }
    }
}

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

int main(){
    int N;
    cin >> N;
    int num[10];
    int count = 0;
    for (int i = 0; i < 4; i++){
        num[i] = N % 10;
        if (num[i] == 2) count++;
        N = N / 10;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <string> 
using namespace std;
#include <string> 
#define fast ios_base::sync_with_stdio(false);	cin.tie(NULL);
typedef long long ll;
#define MAX 1000000000
const int maxn=1000010;
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
ll dp[maxn];
ll n,W;
ll v[maxn];
ll w[maxn];

int main()
{
	fast;
	  memset(dp,0x3f,sizeof(dp));
    cin>>n>>W;
    repd(i,1,n)
    {
        cin>>w[i]>>v[i];
    }
    ll ans=0ll;
    dp[0]=0;
    repd(i,1,n)
    {
        for(int j=1e5;j>=v[i];--j)
        {
            {
                dp[j]=min(dp[j],dp[j-v[i]]+w[i]);
                if(dp[j]<=W)
                    ans=max(ans,(ll)(j));
            }
        }
    }
    cout<<ans;
	return 0;
}


Measured memory_bytes: 11392
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.NoSuchElementException;
import java.util.Scanner;
import java.util.Set;

class Main {

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

		InputStreamReader is = null;
		Scanner sc = null;
		Set<String> integers = new HashSet<String>();

		try {
			sc = new Scanner(is = new InputStreamReader(System.in));
			Integer value = null;

			while ((value = Integer.parseInt(sc.next())) != null) {
				for (int a = 0; a <= 9; a++) {
					for (int b = 0; b <= 9; b++) {
						for (int c = 0; c <= 9; c++) {
							for (int d = 0; d <= 9; d++) {

								if (value == a + b + c + d) {

									integers.add(String.valueOf(a)
											+ String.valueOf(b)
											+ String.valueOf(c)
											+ String.valueOf(d));

								}

							}

						}
					}

				}

				System.out.println(integers.size());
				integers.removeAll(integers);
			}

		}catch(NoSuchElementException e){


		}

		finally {
			is.close();
			sc.close();

		}

	}

}

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

int main(){
  int n, a;
  cin >> n;
  vector<int> c(n);
  for(int i = 0; i < n; i++){
    cin >> a;
    a--;
    c[a] = i + 1;
  }
  for(int i = 0; i < n; i++){
    cout << c[i];
    cout << ' ';
  }
  cout << endl;
}

Measured memory_bytes: 1152
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll INF=(1LL<<60);
const ld pi=acosl((ld)1);
const ll mod = 1000000007;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};

template< typename T >
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;

template< typename G >
G convert_rooted_tree(const G &g, int r = 0) {
  int N = (int) g.size();
  G rg(N);
  vector< int > v(N);
  v[r] = 1;
  queue< int > que;
  que.emplace(r);
  while(!que.empty()) {
    auto p = que.front();
    que.pop();
    for(auto &to : g[p]) {
      if(v[to] == 0) {
        v[to] = 1;
        que.emplace(to);
        rg[p].emplace_back(to);
      }
    }
  }
  return rg;
}

bool solve(){
  string s;cin>>s;
  rep(i,s.size()-8)cout<<s[i];
  cout<<endl;
  return false;
}


signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout<<fixed;
	cout<<setprecision(30);
	return solve();
}


Measured memory_bytes: 256
n = gets.to_i
x = []
y = []
for i in 0...n do
  x[i], y[i] = gets.split.map(&:to_i)
end
perm = (0...n).to_a.permutation.to_a
sum = 0.0
perm.each do |a|
  for i in 0...(a.length - 1) do
    d = Math.sqrt((x[a[i]] - x[a[i + 1]]) ** 2 + (y[a[i]] - y[a[i + 1]]) ** 2)
    sum += d
  end
end
puts sum / perm.length


Measured memory_bytes: 8188
package main

import (
	"fmt"
)

func main() {
	var a, b, k int
	fmt.Scan(&a, &b, &k)

	max := a
	for i := a; i < a+k; i++ {
		if i <= b {
			fmt.Println(i)
			max = i
		}
	}

	for i := max + 1; i <= b; i++ {
		if i >= b-k+1 {
			fmt.Println(i)
		}
	}

}


Measured memory_bytes: 512
use std::io::{self, Read, Write};

#[rustfmt::skip] #[macro_use] #[allow(unused_macros)]
mod rwc {
    macro_rules! rd { ($buf:ident, $t:ty)       => { $buf.next().unwrap().parse::<$t>().ok().unwrap() }; }
    macro_rules! wt { ($out:ident, $($arg:tt)*) => { write!($out, $($arg)*).ok()                      }; }
    macro_rules! cv { ($n:expr, $fn:expr)       => { (0..$n).map($fn).collect::<Vec<_>>()             }; }
}

fn main() {
    let (mut _buf, mut _out) = (String::new(), io::stdout());
    let (mut _buf, mut _out) = {
        io::stdin().read_to_string(&mut _buf).ok();
        (_buf.split_whitespace(), io::BufWriter::new(_out.lock()))
    };

    let n = rd!(_buf, usize);
    let mut v = vec![0i32; n];

    for _ in 0..(n - 1) {
        let a = rd!(_buf, usize);
        v[a - 1] += 1;
    }

    for i in 0..n {
        wt!(_out, "{}\n", &v[i]);
    }
}


Measured memory_bytes: 3948
// 1_5_D
#include<stdio.h>

int main(void)
{
	int n, i, x;
	scanf("%d", &n);

	for(i = 1; i <= n; i++){
		if(i%3 == 0){
			printf(" %d", i);
		}else{
			x = i;
			while(x){
				if(x%10 == 3){
					printf(" %d", i);
					break;
				}else{
					x /= 10;
				}
			}
		}
	}
	printf("\n");

	return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
vector<pair<int,pair<int,int>>> E;

template<int um> class UF {
	public:
	vector<int> par,rank;
	UF() {rank=vector<int>(um,0); for(int i=0;i<um;i++) par.push_back(i);}
	int operator[](int x) {return (par[x]==x)?(x):(par[x] = operator[](par[x]));}
	int operator()(int x,int y) {
		if((x=operator[](x))==(y=operator[](y))) return x;
		if(rank[x]>rank[y]) return par[x]=y;
		rank[x]+=rank[x]==rank[y]; return par[y]=x;
	}
};
UF<500000> uf;

vector<ll> node[202020]; // num, leftid,leftcost,rightid,rightcose
int id[202020];
ll ret[101010];

void dfs(int cur,ll sum) {
	if(cur<N) {
		ret[cur]=sum;
	}
	else {
		dfs(node[cur][1],sum+node[cur][2]);
		dfs(node[cur][3],sum+node[cur][4]);
	}
	
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N-1) {
		cin>>x>>y>>j;
		E.push_back({j,{x-1,y-1}});
	}
	FOR(i,N) {
		id[i]=i;
		node[i]={1,-1,0,-1,0};
	}
	sort(ALL(E));
	reverse(ALL(E));
	int nex=N;
	FORR(e,E) {
		x=id[uf[e.second.first]];
		y=id[uf[e.second.second]];
		node[nex]={node[x][0]+node[y][0],x,node[y][0]*e.first,y,node[x][0]*e.first};
		uf(e.second.first,e.second.second);
		id[uf[e.second.first]]=nex++;
	}
	dfs(nex-1,0);
	FOR(i,N) cout<<ret[i]<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 23792
#include <stdio.h>

#define SWAP(x, y) ((x) += (y), (y) = (x) - (y), (x) -= (y))
#define LEFT(x) (2 * x)
#define RIGHT(x) (2 * x + 1)

int heap_size;

void maxHeapify(int *a, int i){
  int l = LEFT(i), r = RIGHT(i), largest;
  if(l <= heap_size && a[l] > a[i]) largest = l;
  else largest = i;
  if(r <= heap_size && a[r] > a[largest]) largest = r;
  if(largest != i){
    SWAP(a[i], a[largest]);
    maxHeapify(a, largest);
  }
  return;
}

int main(){
  int a[500005], i;

  scanf("%d", &heap_size);
  for(i = 1; i <= heap_size; ++i) scanf("%d", a + i);

  for(i = heap_size / 2; i > 0; --i) maxHeapify(a, i);

  for(i = 1; i <= heap_size; ++i) printf(" %d", *(a + i));
  puts("");
  return 0;
}


Measured memory_bytes: 3648
#include <stdio.h>

int main(void) {
  int a, b, c, n,i;
  scanf("%d", &n);
  for(i = 0; i < n; ++i) {
    scanf("%d%d%d", &a, &b, &c);
    a *= a, b *= b, c *= c;
    if(a + b == c || b + c == a || c + a == b) printf("YES\n");
    else printf("NO\n");
  }
  return 0;
}


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

struct coin{lint a, b, c;};

const int MAX_N = (int)1e5 + 5;
lint S[MAX_N];
coin D[MAX_N];

int main(){
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int X, Y, Z, N;
    cin>>X>>Y>>Z;
    N = X + Y + Z;
    for(int i=0;i<N;i++){
        cin>>D[i].a>>D[i].b>>D[i].c;
    }
    sort(D, D+N, [](coin c1, coin c2){ return c1.a-c1.b < c2.a-c2.b;});

    auto f1 = [](coin c1, coin c2){return c1.b-c1.c > c2.b-c2.c;};
    auto f2 = [](coin c1, coin c2){return c1.a-c1.c > c2.a-c2.c;};
    priority_queue<coin, vector<coin>, decltype(f1)> pq1(f1);
    priority_queue<coin, vector<coin>, decltype(f2)> pq2(f2);

    lint cur_a = 0, cur_b = 0, cur_c = 0;
    for(int i=0;i<Y;i++) pq1.push(D[i]), cur_b += D[i].b;
    S[Y-1] = cur_b;
    for(int i=Y;i<N-X;i++){
        pq1.push(D[i]); cur_b += D[i].b;
        coin cc = pq1.top(); pq1.pop();
        cur_b -= cc.b; cur_c += cc.c;
        S[i] = cur_b + cur_c;
    }

    for(int i=N-1;N-X-1<i;i--) pq2.push(D[i]), cur_a += D[i].a;
    S[N-X-1] += cur_a; cur_c = 0;
    for(int i=N-X-1;Y<=i;i--){
        pq2.push(D[i]); cur_a += D[i].a;
        coin cc = pq2.top(); pq2.pop();
        cur_a -= cc.a; cur_c += cc.c;
        S[i-1] += cur_a + cur_c;
    }

    cout<<*max_element(S+Y-1, S+N-X)<<endl;
    return 0;
}

Measured memory_bytes: 7412
N=input()
K=int(input())

def f(N,K):
    if K==0: return 1
    if N=="": return 0
    N=str(int(N))
    if N==0 : return 0
    l = len(N)
    n0 = int(N[0])
    return f(N[1:],K-1) + f("9"*(l-1),K-1)*(n0-1) + f("9"*(l-1),K)

print(f(N,K))

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

public class Main{
	/*
	 * 問題文 いろはちゃんは 長さ L の文字列を N 個持っており、それぞれ S1,S2,…,SN です。
	 *
	 * それらの文字列を好きな順番で全て結合してできる文字列のうち、もっとも辞書順で小さいものを求めてください。
	 *
	 * なお、ある文字列 s=s1s2s3...sn と t=t1t2t3...tm について、以下のどちらかを満たすとき、
	 * 辞書順比較で s<t
	 * であるといいます。
	 *
	 * ある整数 i(1≦i≦min(n,m)) に関して、 1≦j<i を満たす任意の整数 j において sj=tj が成立し、
	 * かつ si<ti
	 * が成立する。 任意の整数 i(1≦i≦min(n,m)) に関して si=ti が成立し、かつ n<m が成立する
	 */
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int l = sc.nextInt();
		String[] str = new String[n];
		for (int i = 0; i < n; i++) {
			str[i] = sc.next();

		}
		Arrays.sort(str);//昇順でならびかえる
		for (int i = 0; i < str.length; i++) {
			System.out.print(str[i]);
		}
	}

}

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

int main(){
  string s;
  cin >> s;
  int cnt = 0;
  for(int i = 0; i < s.size(); i++){
    if(s[i] == '1'){
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 3596
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<cmath>
#include<limits>
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define pint_INF 2000000000
#define ll_INF 	9223372036854775807
#define MOD 1000000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvll vector<vector<long long>>
#define vvc vector<vector<char>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
#define sysp system("PAUSE")
#define pno cout << "no" << endl
#define pyes cout << "yes" << endl
#define pYes cout << "Yes" << endl
#define pNo cout << "No" << endl
using namespace std;
ll N;
ll for_each_k(ll K) {
	ll res = K * (N - K + 1) + 1;
	res% MOD;
	return res;
}

int main() {
	cin >> N;
	ll K; cin >> K;
	ll ans = 0;
	for (int k = K; k <= N+1; k++) {
		ans += for_each_k(k);
		ans %= MOD;
	}

	cout << ans << endl;
}

Measured memory_bytes: 3524
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        sc.close();
        int[] P = new int[48];
        int over74 = 0;
        int over24 = 0;
        int over14 = 0;
        int over4 = 0;
        int over2 = 0;
        for(int i = 2; i <= N; i++){
            int x = i;
            for(int j = 2; j < Math.min(N, 48); j++){
                while(x % j == 0){
                    x /= j;
                    P[j]++;
                }
            }
        }
        for(int p: P){
            if(p >1) over2++;
            if(p >3) over4++;
            if(p >13) over14++;
            if(p >23) over24++;
            if(p >73) over74++;
        }
        int ans = 0;
        ans += over74;
        if(over14 > 0 && over4 > 1) ans += over14 * (over4-1);
        if(over24 > 0 && over2 > 1) ans += over24 * (over2-1);
        if(over4 > 1 && over2 > 2) ans += (over4 * (over4-1) / 2) * (over2 - 2);

        System.out.println(ans);
    }

}


Measured memory_bytes: 21716
#include<stdio.h>
#include<stack>

int main(){
	int data[100],i=0,n=0;
	std::stack<int> train;
	while(scanf("%d",&data[i])!= EOF){
		i++;n++;
	}
	i=0;
	train.push(data[i]);
	for(i=1;i<n;i++){
		if(data[i]==0){
			printf("%d\n",train.top());
			train.pop();
		}else{
			train.push(data[i]);
		}
	}
	return 0;
}

Measured memory_bytes: 1036
#!/usr/bin/env python3
import sys
import itertools


def solve(N: int, M: int, x: "List[int]", y: "List[int]", z: "List[int]"):

    res = 0
    for mp in itertools.product([-1,1],repeat=3):
        xyz = [x*mp[0] + y*mp[1] + z*mp[2] for x,y,z in zip(x,y,z)]
        xyz.sort(reverse=True)
        res = max(res, sum(xyz[0:M]))

    print(res)


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    x = [int()] * (N)  # type: "List[int]" 
    y = [int()] * (N)  # type: "List[int]" 
    z = [int()] * (N)  # type: "List[int]" 
    for i in range(N):
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
        z[i] = int(next(tokens))
    solve(N, M, x, y, z)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
# coding: utf-8
# Your code here!
def main():
    n = int(input())
    c_array = list(input())
    
    w = 0
    r = c_array.count("R")
    ans = r
    
    for i in range(0, n):
        if c_array[i] == "W":
            w += 1
        else:
            r -= 1
        # print(w, r)
        tmp = max(w, r)
        # print(tmp)
        if tmp <= ans:
            ans = tmp
    
    print(ans)
    
main()

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

int main() {
	// your code goes here
	int n;
	cin>>n;
	int arr[n];
	for(int i=0;i<n;i++){
	    cin>>arr[i];
	}
	int dp[n];
	dp[0]=0;dp[1]=dp[0]+abs(arr[1]-arr[0]);
	for(int i=2;i<n;i++){
	    dp[i]=min((dp[i-1]+abs(arr[i]-arr[i-1])),(dp[i-2]+abs(arr[i]-arr[i-2])));
	}
	cout<<dp[n-1];
	return 0;
}


Measured memory_bytes: 4344
from sys import stdin
# stdin = open('sample.txt')


def main():
    S = stdin.readline().rstrip()
    K = int(stdin.readline().rstrip())
    tmp = 0
    # spam = 5000 * 1000000000000
    for c in S:
        if c == '1':
            tmp += 1
            if K == tmp:
                print(1)
                break
        else:
            print(c)
            break


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#define _USE_MATH_DEFINES
#include<iostream>
#include<fstream>
#include<vector>
#include<string>
#include<algorithm>
#include<climits>
#include<numeric>
#include<cmath>
#include<cstring>
#include<deque>
#include<map>
#include<iomanip>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define VSORT(v) sort(v.begin(), v.end());
#define VE vector<int>
#define VEP vector<pair<int,int>>
#define ll long long
#define pb(a) push_back(a)
using namespace std;
const vector<VE> DIR{ {-1,0},{1,0},{0,-1},{0,1} };
const ll MOD = 1000000007;
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
int main() {
	int n, m;
	int sum = 0;
	cin >> n >> m;
	VE vec(n);
	REP(i, n) {
		cin >> vec[i];
		sum += vec[i];
	}
	sort(vec.begin(), vec.end(), greater<int>());
	if (vec[m - 1] >= 1.0 / (4 * m) * sum) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}


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

typedef long long ll;

set<string> ans;
string str;

void dfs (string &S, int C, int B) {
    if (C == str.size()) {
        ans.insert(S);
        return ;
    }

    if (~B & (1 << ('z' - 'a')) && str[C] == 'z') return ;
    if (str[C] == 'a') {
        if (~B & (1 << 1) ) {
            S[C] = 'b';
            dfs (S, C + 1, B | (1 << 1));
        }
        S[C] = 'a';
        dfs (S, C + 1, B | (1 << 0));

    } else if (B & (1 << (str[C] - 'a')) ) {
        if ('z' >= (str[C] + 1) && ~B & (1 << (str[C] - 'a' + 1)) ) {
            S[C] = (char)(str[C] + 1);
            dfs (S, C + 1, B | (1 << (str[C] + 1 - 'a')) );
        }
        S[C] = str[C];
        dfs (S, C + 1, B);

    } else {
        if ('z' >= (str[C] + 1) && ~B & (1 << (str[C] - 'a' + 1)) ) {
            S[C] = (char)(str[C] + 1);
            dfs (S, C + 1, B | (1 << (str[C] + 1 - 'a')) );

        } else
            return ;
    }
}

int main ()
{
    while (cin >> str, str != "#") {
        ans.clear();
        string tmp = str;
        dfs(tmp, 0, 0);
        int s = ans.size();
        cout << s << endl;

        int k = 0;
        if (0 < s && s <= 10) {
            for (auto i : ans) {
                cout << i << endl;
            }
        } else if (s > 10) {
            int k = 0;
            for (auto i : ans) {
                if (k == 5) break;
                cout << i << endl;
                k++;
            }
            auto ite = ans.end(); ite--; ite--; ite--; ite--; ite--;
            k = 0;
            while (k++ < 5) {
                cout << *ite << endl;
                ite++;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 3144
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<deque>
#define rep(i,n) for(int i = 0;i<n;i++)
#define _GLIBCXX_DEBUG
using ll = long long; 
using namespace std;

int main() {
    long long a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;
    long long total = 1000000000LL;
    for(int i = 0; i < max(2*x,2*y); i++) {
    total = min(total, 2*c*i+max(0LL,(x-i)*a)+max(0LL,(y-i)*b));
    }
    cout << total << endl;
}

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

using namespace std;

int digts_sum(int n)
{
    int sum = 0;

    while (n)
    {
        int current = n % 10;
        sum++;
        n /= 10;
    }
    return sum;
}

int main()
{
    int n;
    cin >> n;
    int ans = 0;

    for (int i = 0; i <= n; i++)
    {
        if (digts_sum(i) % 2 != 0)
        {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
x,y,a,b,c = map(int,input().split())
p = [int(i) for i in input().split()]
q = [int(i) for i in input().split()]
r = [int(i) for i in input().split()]
p.sort(reverse=True)
q.sort(reverse=True)
for i in range(x): r.append(p[i])
for i in range(y): r.append(q[i])
r.sort(reverse=True)
print(sum(r[:x+y]))

Measured memory_bytes: 23644
#include <stdio.h>

int main() {
	int N;
	scanf("%d",&N);
	int d[N];
	for (int i = 0; i < N; i++) {
		scanf("%d",&d[i]);
	}
	int ans = 0;
	for (int i = 0; i < N; i++) {
		for (int j = i+1; j < N; j++) {
			ans += d[i]*d[j];
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<string>
#include<stack>

using namespace std;

int main(){
	string s,t;
 	cin>>s>>t;
	vector<vector<int> >dp(s.length()+1,vector<int>(t.length()+1,0));
	for(int i=1; i<=s.length(); i++){
		for(int j=1; j<=t.length(); j++){
			if(s[i-1]==t[j-1])
				dp[i][j]=dp[i-1][j-1]+1;
			else{
				if(dp[i-1][j]>dp[i][j-1])
					dp[i][j]=dp[i-1][j];
				else
					dp[i][j]=dp[i][j-1];	
			}
		}
	}
	int i=s.length(), j=t.length(), index=dp[s.length()][t.length()];
	char ans[index+1];
	ans[index]='\0';
	while(i>0&&j>0){
		if(dp[i][j]==dp[i-1][j-1]+1 && dp[i-1][j] + 1 == dp[i][j] && dp[i][j-1] + 1 == dp[i][j]){
			ans[index-1]=s[i-1];
			i--;
			j--;
			index--;
		}else if(dp[i][j]==dp[i-1][j]){
			i--;
		}else{
			j--;	
		}
	}
	cout<<ans<<"\n";
}


Measured memory_bytes: 35584