akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
    int n, m, ans = 0;
    cin >> n >> m;
    int A[n][m];
    int b[m];
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            cin >> A[i][j];
        }
    }
    for(int i = 0; i < m; i++){
        cin >> b[i];
    }
    for(int i  = 0; i < n; i++) {
        for(int j = 0; j < m; j++){
            ans += A[i][j] * b[j];
        }
        cout << ans << endl;
        ans = 0;
    }
    return 0;
}



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

using pii = pair<int, int>;
using ll  = long long;
#define rep(i, j) for (int i = 0; i < (int)(j); i++)
#define repeat(i, j, k) for (int i = (j); i < (int)(k); i++)
#define all(v) v.begin(), v.end()
#define debug(x) cerr << #x << " : " << x << endl

template <class T>
bool set_min(T &a, const T &b) {
    return a > b ? a = b, true : false;
}
template <class T>
bool set_max(T &a, const T &b) {
    return a < b ? a = b, true : false;
}
// vector
template <class T>
istream &operator>>(istream &is, vector<T> &v) {
    for (T &a : v) is >> a;
    return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    for (const T &t : v) os << "\t" << t;
    return os << endl;
}
// pair
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &v) {
    return os << "<" << v.first << ", " << v.second << ">";
}

const int INF = 1 << 30;
const ll INFL = 1LL << 60;



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

    ll X, Y, A, B, C; cin >> X >> Y >> A >> B >> C;
    vector<ll> P(A), Q(B), R(C); cin >> P >> Q >> R;
    sort(all(P)); reverse(all(P));
    sort(all(Q)); reverse(all(Q));
    sort(all(R)); reverse(all(R));

    ll ans = 0;
    vector<ll> p, q;
    p.push_back(INFL);
    q.push_back(INFL);
    rep(i, X) {
      p.push_back(P[i]);
      ans += P[i];
    }
    rep(i, Y) {
      q.push_back(Q[i]);
      ans += Q[i];
    }
    for(ll r : R) {
      if(p.back() < q.back()) {
	if(r > p.back()) {
	  ans -= p.back();
	  ans += r;
	  p.pop_back();
	}
      } else {
	if(r > q.back()) {
	  ans -= q.back();
	  ans += r;
	  q.pop_back();
	}
      }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4852
#include<bits/stdc++.h>
using namespace std;
long long h,n,minv=2138475647;
long long f[2000005],a[1005],b[1005];
int main(){
	for(int i=1;i<=2000000;i++)  
	    f[i]=2138475647;
	cin>>h>>n;
	for(int i=1;i<=n;i++)  
	    cin>>a[i]>>b[i];
	for(int j=1;j<=n;j++)
		for(int i=a[j];i<=20000;i++)  
		    f[i]=min(f[i-a[j]]+b[j],f[i]);
	for(int i=h;i<=20000;i++)
		if(f[i]<minv)  minv=f[i];
	cout<<minv<<endl;
	return 0;
}

Measured memory_bytes: 15872
#include<iostream>
#include<cstdlib>
#include<sstream>

using namespace std;

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

int main() {
  while (true){
    int n;
    cin >> n;
    if (n == 0) break;
    string str[n];
    rep (i, n) cin >> str[i];
    rep (i, n) if (str[i] == "-") str[i] = "";
    bool re[n];
    rep (i, n) {
      if (str[i][str[i].size() - 1] == 'v') {
	re[i] = true;
	str[i] = str[i].substr(0, str[i].size() - 1);
      } else {
	re[i] = false;
      }
    }
    int num[n];
    rep (i, n) num[i] = 0;
    rep (i, n) if (str[i].size()) {
      int k = 0;
      while (isalpha(str[i][k])) ++k;
      stringstream ss;
      ss << str[i].substr(k);
      ss >> num[i];
      str[i] = str[i].substr(0, k);
    }
    bool used[n];
    rep (i, n) used[i] = false;
    //rep (i, n) cerr << str[i] << " " << num[i] << " " << re[i] << endl;
    int pos = -1;
    while (true) {
      ++pos;
      if (pos == n) break;
      if (used[pos]) continue;
      if (re[pos]) continue;
      if (num[pos] > 1) continue;
      cout << pos + 1 << endl;
      used[pos] = true;
      int nn = num[pos];
      if (nn == 1) {
	int p = pos;
	nn = 2;
	while (p > 0) {
	  --p;
	  if (used[p]) continue;
	  if (str[pos] != str[p]) continue;
	  if (nn != num[p]) break;
	  ++nn;
	  pos = p;
	  used[pos] = true;
	  cout << p + 1 << endl;
	}
      }
      if (pos != 0 && re[pos - 1]) {
	pos -= 2;
	re[pos + 1] = false;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 2164
N, A, B = map(int, input().split())
ans = 0

for i in range(1,N+1): # 実はrange(a,b)は、aからb-1まで　の数字を格納したリスト
    # 整数の各桁の和を計算するポイント
    a = str(i)          # 整数を文字列に変換する
    array = map(int, a) # 文字列の要素をすべて数値に変換してリスト化
    sum_ = sum(array)   # リストの要素の和を計算する（おわり）
    if A <= sum_ <= B:
        ans += i
        
print(ans)

Measured memory_bytes: 3060
import itertools
import os
import sys

from scipy.misc import comb

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")

N, K = list(map(int, sys.stdin.readline().split()))

max_k = comb(N - 1, 2, exact=True)
if K > max_k:
    print(-1)
    exit()
graph = []
for i in range(2, N + 1):
    graph.append((1, i))
count = max_k
for v in itertools.combinations(range(2, N + 1), r=2):
    if count <= K:
        break
    graph.append(v)
    count -= 1
print(len(graph))
for v, u in graph:
    print(v, u)


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

// a,bの大小関係

int main() {
  int a, b;
  cin >> a >> b;
  if (a > b) {
    cout << "a > b" << endl;
  }

  if (a < b) {
    cout << "a < b" << endl;
  }

  if (a == b) {
    cout << "a == b" << endl;
  }
}


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

typedef long long int ll;
typedef vector<long long>lve;
typedef vector<pair<ll,ll> > lvp;
typedef vector<pair<string,ll> > svp;

#define sp         ' '
#define endl       '\n'
#define F          first
#define S          second
#define pp         pop_back`
#define pb         push_back
#define mp         make_pair 
#define GCD(x,y)   __gcd(x,y)
#define PI         2*acos(0.0);
#define lb         lower_bound
#define bs         binary_search
#define all(x)     x.begin(),x.end()
#define LCM(x,y)   ((x*y)/__gcd(x,y))
#define btpc       __builtin_popcountll
#define spc(x)     cout<<fixed<<setprecision(x)

const   long long  cs=2e5+5;
const   long long  inf=1e18;
const   long long  mod=1e9+7;
void solve()
{
    int64_t t,n,m,a,b,d,e,i,j,k,cnt=1,cnt1=0;
    bool flag = false;

    cin>>n>>a;
    n--;
    for(i=n;i>=0;i--) cout<<a-i<<sp;
    for(i=1;i<=n;i++) cout<<a+i<<sp;
    cout<<endl;
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);    cout.tie(NULL);

    // freopen ("input.txt","r",stdin);
    // freopen ("output.txt","w",stdout);

    // ll tc;
    // cin>>tc;
    // while(tc--)
    solve();

    return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define ff              first
#define ss              second
#define int             long long int
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define vv(type)		vector<vector<type>>
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define db(x) 			cout<<x<<" "
#define db1(x) 			cout<<x<<'\n'
#define db2(x,y) 		cout<<x<<" "<<y<<'\n'
#define db3(x,y,z) 		cout<<x<<" "<<y<<" "<<z<<'\n'
#define rep(i,n) 		for(int i=0;i<(n);++i)
#define repA(i,a,n) 	for(int i=a;i<=(n);++i)
#define repD(i,a,n) 	for(int i=a;i>=(n);--i)
#define so(a) 			sort(a.begin(),a.end())
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
// to find all local maximaa and minima in O(n)
//	 for (int i=1;i<=n;i++)
//        {
//            if (i==1 || i==n || (p[i-1]<p[i])!=(p[i]<p[i+1]))
//           ans.push_back(p[i]);
//        }
int dx[] = { -1, 1, -1, 0, 0, -1, 1, 1 };
int dy[] = { -1, -1, 1, -1, 1, 0, 0, 1 };
int gcd(int a, int b)
{
	if (!b)
		return a;
	return gcd(b, a % b);
}
int modular_expo(int x, int y, int m)
{
	int ans = 1;
	while (y)
	{
		if (y & 1)
			ans = (ans % m * x % m) % m;
		x = (x % m * x % m) % m;
		y /= 2;
	}
	return ans % m ;
}
int power(int x, int y)
{
	int ans = 1;
	while (y)
	{
		if (y & 1)
			ans = (ans * x);
		x *= x;
		y /= 2;
	}
	return ans;
}
int dp[3001][3001][2];

int winner(vi &a, int i, int j, int turn)
{
	if (i > j)	return 0;
	if (dp[i][j][turn] != -1)
		return dp[i][j][turn];
	if (turn)
		return dp[i][j][1] = max(a[i] + winner(a, i + 1, j, 0), a[j] + winner(a, i, j - 1, 0));
	else
		return dp[i][j][0] = min(winner(a, i + 1, j, 1), winner(a, i, j - 1, 1));
}

void solve()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	vi a(n);
	int sum = 0;
	rep(i, n)
	{
		cin >> a[i];
		sum += a[i];
	}
	memset(dp, -1, sizeof(dp));
	int x = winner(a, 0, n - 1, 1);
	cout << 2 * x - sum;
}
int32_t main()
{
	solve();
	return 0;
}


Measured memory_bytes: 144632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
    ll n, m;
    cin>>n>>m;
    string s, t;
    cin>>s>>t;
    if(s[0]!= t[0]){
        cout<<"-1\n";
        return 0;
    }
    if(n==m){
        if(s==t){
            cout<<n<<'\n';
        }else{
            cout<<"-1\n";
        }
        return 0;
    }
    ll val = (n*m)/__gcd(n,m);
    ll indx = 0;
    while(indx < n){
        ll indx1 = indx*(val/n);
        if((indx*m)%n==0){
            ll indx2 = (indx*m)/n;
            if(s[indx]!=t[indx2]){
                cout<<"-1\n";
                return 0;
            }
        }
        indx++;
    }
    // indx=0;
    // while(indx < m){
    //     ll indx1 = indx*(val/m);
    //     if((indx*n)%m==0){
    //         ll indx2 = (indx*n)/m;
    //         if(t[indx1]!=s[indx2]){
    //             cout<<"-1\n";
    //             return 0;
    //         }
    //     }
    //     indx++;
    // }
    cout<<val<<endl;
}

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


int main(){
    int x,a,b;
    cin>>x>>a>>b;
    if(b<=a) cout<<"delicious"<<endl;
    else if(b<=x+a) cout<<"safe"<<endl;
    else cout<<"dangerous"<<endl;
}

Measured memory_bytes: 3636
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  auto abc = readln.chomp.split.map!(to!int).array.sort();
  writeln(abc[0]+abc[1]);
}


Measured memory_bytes: 256
from functools import lru_cache

@lru_cache(maxsize = None)
def rec(digit, flag, k):
    limit = int(N[digit])
    if k > K:
        return 0
    if digit == len(N) - 1:
        if k == K:
            return 1
        elif k == K - 1:
            return limit if flag else 9
        else:
            return 0
    if flag:
        if limit == 0:
            return rec(digit + 1, 1, k)
        else:
            return rec(digit + 1, 0, k + 1) * (limit - 1) + rec(digit + 1, 1, k + 1) + rec(digit + 1, 0, k)
    else:
        return rec(digit + 1, 0, k + 1) * 9 + rec(digit + 1, 0, k)

N = input()
K = int(input())
print(rec(0, 1, 0))

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

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


int main(){

    string s;
    cin >> s;

    vector<ll> v;
    v.push_back(0);
    vector<char> marks;
    ll tmp = 1;
    for(int i = 0; i < s.size() - 1; i++){
        if(s[i] != s[i + 1]){
            v.push_back(tmp);
            marks.push_back(s[i] );
            tmp = 1;
        }
        else{
            tmp ++;
        }
    }
    marks.push_back(s[s.size() - 1] );
    v.push_back(tmp);
    v.push_back(0);
    ll sum = 0;
    ll maxi = 0;
    for(int i = 1; i < v.size() - 1; i++ ){
        sum += v[i] * (v[i] + 1) / 2;
    }

    for(int i = 1; i < v.size() - 1; i++ ){
        if(marks[i - 1] == '>' ){
            if(v[i - 1] >= v[i]){
                sum -= v[i];
            }
        }
        else if(marks[i - 1] == '<'){
            if(v[i+1] > v[i]){
                sum -= v[i];
            }
        }
    }



    cout << sum << endl;
}

Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ld double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
typedef long long ll;
typedef unsigned long long ull;
typedef pair <ll, ll> pll;
typedef vector<pll> vplll;
ll mod = 1e9+7;
ll m[100005][4], cnt = 0;
ll cost(ll ar[][3], ll n, ll k, ll ans,ll flag)
{
	if(m[k][flag]!=-1)
		return m[k][flag];
	if(k==n)
		return 0;
	ll tmp = ans;
	ans = 1e10;
	pll val[3];
	for(int i=0;i<3;i++)
	{
		if(i==flag)
			val[i].ff = -1e10;
		else 
			val[i].ff = ar[k][i]+cost(ar,n,k+1,tmp,i);
		// val[i].ss = i;
	}
	sort(val,val+3);
	// if(val[2].ss==flag)
	// {
	// 	ans = val[1].ff;
	// 	flag = val[1].ss;
	// }
	// else 
	// {
		ans = val[2].ff;
		// flag = val[2].ss;
	// }
	// cout<<flag<<endl;
	ans += tmp;
	m[k][flag] = ans;
	return ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long int a,b,c,x,n,t;
    for(int i=0;i<100005;i++)
    	for(int j=0;j<4;j++)
    	m[i][j] = -1;
    cin>>n;
    ll ar[n][3];
    for(int i=0;i<n;i++)
    	cin>>ar[i][0]>>ar[i][1]>>ar[i][2];
    ll ans;
    ans = cost(ar,n,0,0,3);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 19840
#  LLLLRRRLLR  => LRLR
def run_length(s)
  ret = [s[0]]
  1.upto(s.size - 1) do |i|
    ret << s[i] if ret[-1] != s[i]
  end
  ret.join
end

def face_produces_unhappiness(n, s, k)
  n - [1, run_length(s).size - 2 * k].max
end

n, k = gets.split.map(&:to_i)
s = gets.chomp

puts face_produces_unhappiness(n, s, k)


Measured memory_bytes: 7932
#include <stdio.h>

int main(void){
    int P,Q,R;
    scanf("%d %d %d",&P,&Q,&R);
    if(P<=Q){
        if(Q>=R) printf("%d\n",P+R);
        else printf("%d\n",P+Q);
    }
    else if(P>=R) printf("%d\n",Q+R);
    else printf("%d\n",P+Q);
    return 0;
}

Measured memory_bytes: 128
X = int(input())
A=[]

for i in range(-200, 200):
    A.append(i**5)
t=False

for i in range(len(A)):
    for j in range(len(A)):
        if A[i]-A[j]==X:
            print(i-200,j-200)
            t=True
            break
    if t:
        break



Measured memory_bytes: 64436
package main

import (
	"fmt"
	"regexp"
)

func main() {

	var A string
	fmt.Scan(&A)

	r := regexp.MustCompile(A)

	if r.MatchString("abcdefghijklmnopqrstuvwxyz") {
		fmt.Println("a")
	} else {
		fmt.Println("A")
	}

}


Measured memory_bytes: 1996
'use strict';
function main(input) {
  const args = input.split('\n'),
        N = parseInt(args[0]),
        A = args.slice(1, N+1);
  let array = new Array();
  for (let a of A) {
    array.push(parseInt(a));
  }
  let max = 0;
  let maxIndex = 0;
  let maxNext = 0;
  for (let i = 0; i < N; ++i) {
    if (array[i] > max) {
      maxNext = max;
      max = array[i];
      maxIndex = i;
    } else if (array[i] > maxNext) {
      maxNext = array[i];
    }
  }
  for (let i = 0; i < N; ++i) {
    if (i === maxIndex) {
      console.log(maxNext);
    } else {
      console.log(max);
    }
  }
}

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

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

typedef long long ll;
using namespace std;

int main() {
    int n, m;
    ll l;
    cin >> n >> m >> l;
    vector<vector<int>> towns(n+1);
    vector<vector<ll>> dis(n+1, vector<ll>(n+1, -1));
    for (int i=0; i<m; i++) {
        int a, b;
        ll c;
        cin >> a >> b >> c;
        towns[a].push_back(b);
        towns[b].push_back(a);
        dis[a][b] = c;
        dis[b][a] = c;
    }
    for (int i = 1; i < n; i++) {
        dis[i][i] = 0;
    }
    // warshal floyd
    for (int i=1; i<=n; i++) {
        for (int from=1; from<=n; from++) {
            for (int to=1; to<=n; to++) {
                if (dis[from][i] < 0 || dis[i][to] < 0)
                    continue;
                if (dis[from][to] < 0) {
                    dis[from][to] = dis[from][i] + dis[i][to];
                } else {
                    dis[from][to] = min(dis[from][i] + dis[i][to], dis[from][to]);
                }
            }
        }
    }
    vector<vector<int>> min_counts(n+1, vector<int>(n+1, -1));
    for (int i = 1; i <= n; i++) {
        for (int k = 1; k <= n; k++) {
            if (dis[i][k] <= l && dis[i][k] >= 0) {
                min_counts[i][k] = 1;
            }
        }
    }
    for (int i = 1; i <= n; i++) {
        for (int from = 1; from <= n; from++) {
            for (int to = 1; to <= n; to++) {
                if (min_counts[from][i] >= 0 && min_counts[i][to] >= 0) {
                    if (min_counts[from][to] < 0)
                        min_counts[from][to] = min_counts[from][i] + min_counts[i][to];
                    else
                        min_counts[from][to] = min(min_counts[from][to], min_counts[from][i] + min_counts[i][to]);
                }
            }
        }
    }
    int q;
    cin >> q;
    for (int i=0; i<q; i++) {
        int s, t;
        cin >> s >> t;
        if (min_counts[s][t] < 0) {
            cout << -1 << endl;
        } else {
            cout << min_counts[s][t] - 1 << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 2176
n,m = map(int, input().split())
SNS = {i:[] for i in range(n)}
for i in range(m):
 s,t = map(int, input().split())
 SNS[s].append(t)
 SNS[t].append(s)

color = [None] * n
S = []
def dfs(r, c):
 S.append(r)
 color[r] = c
 while len(S) != 0:
  u = S.pop()
  for i in SNS[u]:
   if color[i] == None:
    color[i] = c
    S.append(i)
id = 0
for i in range(n):
 if color[i] == None:
  id += 1
  dfs(i, id)

q = int(input())
for i in range(q):
 s,t = map(int, input().split())
 if color[s] == color[t]:
  print("yes")
 else:
  print("no")

Measured memory_bytes: 35220
n = int(input())
lst_a = input().split()
lst_b = input().split()
lst_c = input().split()
for i in range(n):
    lst_a[i]=int(lst_a[i])
    lst_b[i]=int(lst_b[i])
for i in range(n-1):
    lst_c[i]=int(lst_c[i])

ans = sum(lst_b)
for i in range(n-1):
    if lst_a[i]+1==lst_a[i+1]:
        ans+=lst_c[lst_a[i]-1]

print(ans)


Measured memory_bytes: 3064
#[allow(unused_imports)]
use proconio::{fastout, input};

#[fastout]
fn main() {
    input!(x: isize, mut k: isize, d: isize);

    let xd = x / d;

    if xd.abs() > k {
        println!("{}", (x.abs() - (k * d).abs()).abs());
    } else {
        let aaa = x.abs() % d;

        let ax = (k - xd.abs()) % 2;
        if ax == 0 {
            println!("{}", aaa.abs());
        } else {
            println!("{}", (aaa - d).abs());
        }
    }
}


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

#define for0(i, n) for (ll i = 0; i < (ll)(n); ++i) // 0 based indexing
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i) // 1 based indexing
#define forc(i, l, r) for (ll i = (ll)(l); i <= (ll)(r); ++i) // closed interver from l to r r inclusive
#define forr0(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i) // reverse 0 based.
#define forr1(i, n) for (ll i = (ll)(n); i >= 1; --i) // reverse 1 based

#define ff first
#define ss second
#define pb push_back

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	string s,t;
	cin >> s;
	cin >> t;
	// getline(s,cin);
	// getline(t,cin);
	if(t.length() == s.length() +1){
		for0(i,s.length()){
			if(s[i] != t[i]){
				cout << "No"<<endl;
				return 0;
			}
		}
		cout << "Yes"<<endl;
		return 0;
	}
	else{
		cout << "No" << endl;
	}
	return 0;
}


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


int main(){
  long long N, M;
  cin >> N >> M;
  long long number = 1;
  for (int i = M / N + 1; i >= 1; i--){
    if (M % i == 0){
      if  (M >= i * N){
        number = i;
        break;
      }
      else if (i >= N)
        number = M / i;
    }
  }
  cout << number << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

#define N_MAX 100

int count = 0;

void
selection_sort(int *a, int n)
{
  int i, j, minj, v;

  for (i = 0; i < n; i++) {
    minj = i;
    for (j = i + 1; j < n; j++)
      if (a[j] < a[minj])
        minj = j;
    if (i != minj) {
      count++;
      v = a[i];
      a[i] = a[minj];
      a[minj] = v;
    }
  }
}

int
main(void)
{
  int i, n;
  int a[N_MAX];

  scanf("%d", &n);
  for (i = 0; i < n; i++)
    scanf("%d", a + i);

  selection_sort(a, n);
  for (i = 0; i < n; i++)
    printf("%s%d", i ? " " : "", a[i]);
  printf("\n%d\n", count);

  return 0;
}




Measured memory_bytes: 2100
#pragma once
#include <stdio.h>
#include <sstream>
#include <string>
#include <string.h>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <limits>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define bit(x,v) ((ll)x << v)

const ll INF = 1000000007;
const int MAX = 210000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

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

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int pr[100010];
void uini(int n) {
	for (size_t i = 0; i <= n; i++)
	{
		pr[i] = i;
	}
}

int parent(int x) {
	if (x == pr[x]) return x;
	return pr[x] = parent(pr[x]);
}

bool unit(int x, int y) {
	int px = parent(x);
	int py = parent(y);

	if (px == py) return false;
	if (px < py) {
		pr[py] = px;
	}
	else {
		pr[px] = py;
	}
	return true;
}

// res[i][c] := i 文字目以降で最初に文字 c が登場する index (存在しないときは n)
vector<vector<int> > calcNext(const string& S) {
	int n = (int)S.size();
	vector<vector<int> > res(n + 1, vector<int>(26, n));
	for (int i = n - 1; i >= 0; --i) {
		for (int j = 0; j < 26; ++j) res[i][j] = res[i + 1][j];
		res[i][S[i] - 'a'] = i;
	}
	return res;
}

void solv() {
	
	int n,a,b;
	cin >> n >> a >> b;
	cout << min(n * a, b) << endl;

}

int main() {
	COMinit();
	solv();

	return 0;
}
 

Measured memory_bytes: 5120
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <cstdlib>

#define ll long long
#define pb push_back
#define for(i,a,b) for(ll i=a;i<b;i++)

using namespace std;


int main(void)
{
    ll n,x,y;
    scanf("%lld %lld %lld",&n,&x,&y);
    if(x>y) swap(x,y);
    ll a[n]={0};
    for(i,1,n)
    {
        for(j,i+1,n+1)
        {
            a[min((j-i),(abs(x-i)+1+abs(j-y)))]++;
        }
    }
    for(i,1,n) printf("%lld\n",a[i]);
}


Measured memory_bytes: 256
def main():
    N = int(input())

    aord = ord('a')
    ans = ''
    
    while N:
        N, Nmod = divmod(N, 26)
        if Nmod:
            ans = chr(aord + Nmod - 1) + ans
        else:
            ans = chr(aord + 25) + ans
            N -= 1

    print(ans)


if __name__ == '__main__':
	main()

exit()


Measured memory_bytes: 9180
// Code for A - Calc
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define FOR(i,x,y) for(ll i=x;i<(ll)(y);i++)

#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

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

  cout << a + a * a + a * a * a << endl;
  return 0;
}


Measured memory_bytes: 3632
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using static System.Console;

namespace ConsoleApp2
{
    class Program
    {
        static public int[] Sarray() { return ReadLine().Split().Select(int.Parse).ToArray(); }
        static public List<int> Slist() { return new List<int>(ReadLine().Split().Select(int.Parse)); }
        static void Main(string[] args)
        {
            var N = Sarray()[0];
            var S = ReadLine().GroupBy(c=>c).ToArray();
            long ans = 1;
            foreach(var g in S)
            {
                ans *= g.Count() + 1;
                ans %= 1000000007;
            }
            WriteLine(ans - 1);
        }

    }
}


Measured memory_bytes: 14304
#include <iostream>

using namespace std;

int main(){

    int N;
    int d[101];

    cin >> N;

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

    int ret = 0;

    for (int i = 0; i < N-1; i++){
        for(int j = i+1; j < N; j++){
            ret += d[i] * d[j];
        }
    }
    cout << ret;

    return 0;
}

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

using namespace std;

int inf = 2147483647;

int solve(vector<int> v, int sz, int jmp){
    vector<int> dp(sz) ;
    dp[0] = 0;
    for (int i= 1 ; i< sz ; i++){
        dp[i] = inf;
        for (int j = i - 1 ; j >= 0 && (i-j) <= jmp ; j-- ){
            
            dp[i] = min(dp[i], abs(v[i]-v[j]) + dp[j]);
        }
        
    }
    return dp[sz-1];
}

int main(){
    
   
    int N,k;
    cin>>N>>k;
    vector<int> v(N);
    for( int i = 0 ; i < N ; i++ ){
        cin>>v[i];
       
    }

    
    cout<<solve(v,N,k)<<endl;
}

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

int main(){
int A,B,C;
  cin>>A>>B>>C;
  
  vector<int> P={A,B,C};
  
  int K;
  cin>>K;
  
  sort(P.begin(),P.end());
  
  cout<<P.at(2)*pow(2,K)+P.at(1)+P.at(0)<<endl;
}

 

Measured memory_bytes: 384
#include<iostream>
using namespace std;
#define test(a) cout << "*" << a << endl;
int main(){
  string s; 
  int a,b,c,d;  
  bool diffFrag = false;

  cin >> s;
  
  a = 0;
  b = (s.size()-1)/2-1;
  c = (s.size()+3)/2-1;
  d = s.size()-1;
  
  while(a<b){
    if(s[a]!=s[b]){
      diffFrag = true;
      break;     
    }
    a++;
    b--;   
  }
  while(c<d){
    if(s[c]!=s[d]){
      diffFrag = true;
      break;     
    }
    c++;
    d--;   
  }
   while(a<d){
    if(s[a]!=s[d]){
      diffFrag = true;
      break;     
    }
    a++;
    d--;   
  }
  
  if(diffFrag == true)
    cout << "No";
  else
    cout << "Yes";
 
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException,
			IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));

		StringBuilder builder = new StringBuilder();
		for(int i=1;i<10;i++){
			for(int j=1;j<10;j++){
				builder.append(i).append('x').append(j).append('=').append(i*j).append('\n');
			}
		}
		System.out.print(builder);
	}
}

Measured memory_bytes: 17048
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll mod = 100000007;
int main() {
    int K,A,B;cin >> K >> A >> B;
    for (int i = A;i < B+1;i++){
        if (i % K == 0){
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
const long long INF = 1LL << 60;
// const int INF=1010101010;
using Graph = vector<vector<int>>;

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> a(h);
  rep(i, h) cin >> a[i];

  using pint = pair<int, int>;
  queue<pint> que;

  int dx[4] = {1, 0, -1, 0};
  int dy[4] = {0, 1, 0, -1};

  vector<vector<int>> dist(h, vector<int>(w, -1));

  rep(i, h) {
    rep(j, w) {
      if (a[i][j] == '#') {
        dist[i][j] = 0;
        que.push(pint(i, j));
      }
    }
  }

  while (!que.empty()) {
    auto now = que.front();
    que.pop();
    for (int dir = 0; dir < 4; ++dir) {
      int nx = now.first + dx[dir];
      int ny = now.second + dy[dir];
      if (nx < 0 || nx >= h || ny < 0 || ny >= w) continue;
      if (dist[nx][ny] == -1) {
        dist[nx][ny] = dist[now.first][now.second] + 1;
        que.push(pint(nx, ny));
      }
    }
  }
  int res = 0;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      res = max(res, dist[i][j]);
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 13456
#include <stdio.h>
#include <stdlib.h>
//#include <string.h>
//#include <stdbool.h>
//#include <limits.h>
//#include <math.h>

//降順
int des(const void *a, const void *b)
{
  return *(int *)b - *(int *)a;
}

int main() {
  int n, h;
  scanf("%d%d", &n, &h);
  int a[n], b[n];
  for (int i=0; i<n; i++)
    scanf("%d %d", a+i, b+i);
  int ans = 0, amax;
  qsort(a, n, sizeof(int), des);
  qsort(b, n, sizeof(int), des);
  amax = a[0];
  for (int i=0; i<n; i++) {
    if (h <= 0) break;
    if (b[i] < amax) break;
    h -= b[i];
    ans++;
  }
  if (h > 0) {
    ans += (h-1)/amax+1;
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 1400
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <list>
#include <set>
using namespace std;
typedef long long ll;


int main(int argc, char *args[]) {
	int a[3];
	for (int i = 0; i < 3; i++) {
		cin >> a[i];
	}
	int max = 0;
	int min = 1000;
	for (int i = 0; i < 3; i++) {
		if (a[i] > max)max = a[i];
		if (a[i] < min)min = a[i];
	}
	cout << max - min << endl;

}


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

c = 0
s = 0
ans = 0
k = 0

for i in range(1,n+1):
    s = 0
    k += 1
    while i != 0:
        s += i % 10
        i = i // 10
    if a <= s <= b:
        ans += k
        
print(ans)

Measured memory_bytes: 3060
#include <cstdio>
#include <vector>
#include <algorithm>
#include <array>
#include <set>
#include <map>
#include <queue>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#include <cassert>
#define repeat(i, n) for (int i = 0; (i) < int(n); ++(i))
#define repeat_from(i, m, n) for (int i = (m); (i) < int(n); ++(i))
#define repeat_reverse(i, n) for (int i = (n)-1; (i) >= 0; --(i))
#define repeat_from_reverse(i, m, n) for (int i = (n)-1; (i) >= int(m); --(i))
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define unittest_name_helper(counter) unittest_ ## counter
#define unittest_name(counter) unittest_name_helper(counter)
#define unittest __attribute__((constructor)) void unittest_name(__COUNTER__) ()
using ll = long long;
using namespace std;
template <class T> inline void setmax(T & a, T const & b) { a = max(a, b); }
template <class T> inline void setmin(T & a, T const & b) { a = min(a, b); }
template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

int main() {
    int n; scanf("%d", &n);
    vector<ll> a(n); repeat (i, n) scanf("%lld", &a[i]);
    ll result = 0;
    while (true) {
        whole(sort, a);
        if (a[n - 1] < n) break;
        ll k = a[n - 1] / n;
        a[n - 1] %= n;
        repeat (i, n - 1) a[i] += k;
        result += k;
    }
    printf("%lld\n", result);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r(i,n) for(int i = 0; i<n; i++)
using namespace std;
 
int main() {
  char a[5],b[7],c[5],d;
  r(i,5) {
    cin >> a[i];
    cout << a[i];
  }
  cout << " ";
  cin >> d;
  r(i,7) {
    cin >> b[i];
    cout << b[i];
  }
  cin >> d;
  cout << " ";
  r(i,5) {
    cin >> c[i];
    cout << c[i];
  }
  cout << endl;
}

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


int main(){
	int n;
	while(cin>>n,~n){
		string s;
		do{
			int a=n&3;
			s+=+a+'0';
			n>>=2;
		}while(n);
		reverse(s.begin(),s.end());
		cout<<s<<endl;
	}
	return 0;
}

Measured memory_bytes: 1192
#include<bits/stdc++.h>
#include<iomanip>
#define C char
#define D double
#define F float
#define LL long long
#define ULLI unsigned long long int
#define LLI long long int
#define LLD long long double
#define LD long double
#define S string
#define PI (2.0*acos(0.0))
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define READ 		freopen("input.txt","r",stdin)
#define WRITE  		freopen("output.txt","w",stdout)
using namespace std;

int main()

{
    IOS;

    LL x;
    cin>>x;
    LL z = x*x;
    cout<<z<<endl;

    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include  "bits/stdc++.h"
using namespace std;
#define I_AM_SPEED  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#define printclock  cerr <<"Time : "<<(double)clock()/(double)CLOCKS_PER_SEC<<" sec\n";
#define mp(a , b)   make_pair(a , b)
#define eb(a)       emplace_back(a)
#define SZ(n)      ((int)(n).size())
#define all(n)     (n).begin(), (n).end()
#define anal         '\n'
#define mod 1000000007
#define fst first
#define sec second
//const double PI = acos(-1.0);
typedef long long ll;
typedef unsigned long long ull;

//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
     

    
//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
      
int main(){
I_AM_SPEED;
#ifndef ONLINE_JUDGE  
        freopen("input.in", "r", stdin);
        freopen("output.in", "w", stdout);
#endif 

//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
          
        int n;
        cin >> n;
        int ans = 0;
        for(int i = 1; i <= n; i++){
             int x; cin >> x;
             if((i&1) && (x&1)) ans++;
        }
        cout << ans;

//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
//printclock; 
return  0 ;      
}        



     

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

const long long MOD = 1000000007;

vector<vector<long long>> G;
vector<bool> seen;
long long res;
long long k;
void dfs2(int v){
    seen[v] = true;
    long long s=2;
    for(int i=0;i<G[v].size();++i){
        if(seen[G[v][i]])continue;
        long long tmp = 0;
        if(k-s > 0)tmp = k-s;
        res *= tmp;
        res %= MOD;
        s++;
        dfs2(G[v][i]);
    }
}
void dfs(int v){
    seen[v] = true;
    long long s=1;
    for(int i=0;i<G[v].size();++i){
        if(seen[G[v][i]])continue;
        long long tmp = 0;
        if(k-s > 0)tmp = k-s;
        res *= tmp;
        res %= MOD;
        s++;
        dfs2(G[v][i]);
    }
}
void solve(long long N, long long K, std::vector<long long> a, std::vector<long long> b){
    G = vector<vector<long long>>(N, vector<long long>(0));
    seen = vector<bool>(N);
    for(int i=0;i<N-1;++i){
        G[a[i]-1].push_back(b[i]-1);
        G[b[i]-1].push_back(a[i]-1);
    }
    res = K;
    k = K;
    dfs(0);
    cout<<res<<endl;
}

// 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)
int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> a(N-1);
    std::vector<long long> b(N-1);
    for(int i = 0 ; i < N-1 ; i++){
        scanf("%lld",&a[i]);
        scanf("%lld",&b[i]);
    }
    solve(N, K, std::move(a), std::move(b));
    return 0;
}


Measured memory_bytes: 10752
#include <iostream>

using namespace std;

int main() {
    int N;
    cin >> N;
    int ans = 0;
    for (int i = 1; i <= N; ++i) {
        if (i % 2 == 0) continue;
        int cnt = 0;
        for (int j = 1; j <= i; ++j) {
            if (i % j == 0) cnt++;
        }
        if (cnt == 8) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3168
#include<bits/stdc++.h>
#define LL long long 
using namespace std;
const int N=1e5+50;
int T,n,k;LL a[N],b[100];char s[N];
bool insert(LL x){
	for(int i=60;~i;i--)if(x>>i&1){
		if(!b[i]){b[i]=x;return 1;}
		x^=b[i];
	}
	return 0;
}
void solve(){
	memset(b,0,sizeof(b));
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%lld",&a[i]);
	scanf("%s",s+1);
	for(int i=n;i;i--)
		if(insert(a[i])&&s[i]=='1'){puts("1");return;}
	puts("0");
}
int main(){
	scanf("%d",&T);
	while(T--)solve();
	return 0;
}

Measured memory_bytes: 3660
fun main(args: Array<String>) {
    val line = readLine()!!.trim()
    val amount: Long = line.toLong()

    val count500: Long = amount / 500L
    val amari500: Long = amount % 500L
    val count5: Long = amari500 / 5L

    val uresisa: Long = count500 * 1000L + count5 * 5L

    println(uresisa)
}

Measured memory_bytes: 33720
#include <iostream>
#include <algorithm>
using namespace std;
static const int Max = 10000;
int s;

int main(){
    int n,A[1000],B[1000],T[10001],ans=0;
    bool flag[1000];
    s=Max;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>A[i];
        B[i]=A[i];
        s=min(s,A[i]);
        flag[i]=false;
    }
    //cout<<s<<endl;
    sort(B,B+n);
    for(int i=0;i<n;i++)
        T[B[i]]=i;
    for(int i=0;i<n;i++)
    {
        if(flag[i])continue;
        int x=i,m=Max,sum=0,cnt=0;
        while(1){
            flag[x]=true;
            sum+=A[x];
            m=min(m,A[x]);
            x=T[A[x]];
            cnt++;
            if(flag[x])
                break;
        }
        ans += min(sum + m * (cnt - 2), sum + m + (cnt + 1) * s);


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


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

typedef long long ll;
const ll MOD = 1000003;

#define MAX 2000015
#define forl(i, start, stop, step) for (int i = start; i < stop; i += step)
#define rforl(i, start, stop, step) for (int i = start; i > stop; i += step)
#define pii pair<int, int>
#define F first
#define S second
#define vi vector<int>
#define vpii vector< pii >
#define vll vector<ll>
#define pb push_back

// define MOD before using this function
void mult(ll &a, ll b) {
    a *= b;
    if (a >= MOD) a %= MOD;
}

//Fast Exponentiation
ll fexp(ll base, ll exp, ll mod) {
    ll result = 1;
    while (exp > 0) {
        if (exp % 2 == 1)
            result = (result * base) % mod;
        exp >>= 1;
        base = (base * base) % mod;
    }
    return result;
}

ll fact[MAX], invfact[MAX];

void pre() {
    fact[0] = 1;
    forl(i, 1, MAX, 1) {
        ll j = i * 1ll;
        while (j % MOD == 0) j /= MOD;
        fact[i] = fact[i - 1] * j;
        if (fact[i] >= MOD) fact[i] %= MOD;
    }
    invfact[MOD - 1] = fexp(fact[MOD - 1], MOD - 2, MOD);
    rforl(i, MOD - 2, -1, -1) {
        invfact[i] = invfact[i + 1] * (i + 1);
        if (invfact[i] >= MOD) invfact[i] %= MOD;
    }
}

int main() {
    pre();

	int Q; scanf("%d", &Q);
    while (Q--) {
        ll x, d, n; scanf("%lld%lld%lld", &x, &d, &n);
        if (d == 0) {
            ll ans = fexp(x, n, MOD);
            printf("%lld\n", ans);
            continue;
        }
        ll q = x * fexp(d, MOD - 2, MOD);
        if (q >= MOD) q %= MOD;

        ll ans = 1;
        ans = ans * fexp(d, n, MOD);
        if (ans >= MOD) ans %= MOD;

        if (q + n - 1 >= MOD) ans = 0;
        else {
            mult(ans, fact[q + n - 1]);
            mult(ans, invfact[q - 1]);
        }

        printf("%lld\n", ans);
    }

	return 0;
}

Measured memory_bytes: 25984
#include<stdio.h>

/* ???????????????(0????????????) */
int selectionSort(int A[], int N) {
  int i, j, t, sw = 0, minj;
  for ( i = 0; i < N - 1; i++ ) {
    minj = i;
    for ( j = i; j < N; j++ ) {
      if ( A[j] < A[minj] ) minj = j;
    }
    t = A[i], A[i] = A[minj], A[minj] = t;
    if ( i != minj ) sw++;
  }
  return sw;
}

int main() {
  int A[100], N, i, sw;

  scanf("%d", &N);
  for ( i = 0; i < N; i++ ) scanf("%d", &A[i]);

  sw = selectionSort(A, N);

  for ( i = 0; i < N; i++ ) {
    if (i > 0) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
  printf("%d\n", sw);

  return 0;
}

Measured memory_bytes: 1032
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long Long;

int N, M;
vector<int> H, W;
bool input() {
    scanf("%d %d\n", &N, &M);
    if (N == 0 && M == 0) return false;
    H.clear(); H.resize(N);
    W.clear(); W.resize(M);
    for (int i = 0; i < N; i++) {
        scanf("%d\n", &H[i]);
    }
    for (int i = 0; i < M; i++) {
        scanf("%d\n", &W[i]);
    }
    return true;
}

void solve() {
    vector<int> sH(N + 1, 0);
    for (int i = 0; i < N; i++) {
        sH[i + 1] = sH[i] + H[i];
    }
    vector<int> sW(M + 1, 0);
    for (int i = 0; i < M; i++) {
        sW[i + 1] = sW[i] + W[i];
    }

    vector<int> hh;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j <= N; j++) {
            hh.push_back(sH[j] - sH[i]);
        }
    }
    sort(hh.begin(), hh.end());
    Long ans = 0;
    for (int i = 0; i < M; i++) {
        for (int j = i + 1; j <= M; j++) {
            int w = sW[j] - sW[i];
            ans += Long(upper_bound(hh.begin(), hh.end(), w) - lower_bound(hh.begin(), hh.end(), w));
        }
    }
    printf("%lld\n", ans);
}

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

Measured memory_bytes: 17524
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    VI a(3);
    REP(i,2) a[in()-1] = 1;
    REP(i,3){
        if (!a[i]) cout << i + 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y);
#define chmin(x,y) x = min(x,y);
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
const int INF = 1001001001;



int main() {
    string s;
    cin >> s;
    int n = s.size();
    string ans;
    if (s[n-1] == 's') {
        ans = s + "es";
    }
    else {
        ans = s + "s";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}

int euq(int a, int b) {return b ? euq(b, a%b) : a;}

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

    int res = 0;
    FOR(a, 1, K+1) {
        FOR(b, 1, K+1) {
            int t = euq(a, b);
            FOR(c, 1, K+1) {
                res += euq(t, c);
            }
        }
    }

    cout << res << endl;


    return 0;
}

Measured memory_bytes: 3624
lst = [int(input()) for _ in range(5)]

for k, i in enumerate(lst):
    if i % 10 == 0:
        index = k

rest = 9
for k, i in enumerate(lst):
    if 0 < i % 10 <= rest:
        rest = i % 10
        index = k

ans = 0
for k, i in enumerate(lst):
    if k == index:
        ans += i
    else:
        if i % 10 == 0:
            ans += i
        else:
            ans += i + (10 - (i % 10))
print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
int main(void)
{
    int N,k=0;
    scanf("%d",&N);
    for(int i=1;i<10;i++ )
    {
        if((N%i)==0&&(N/i)<10)
        {
            k=k+1;
        }

    }
    if(k==0)
    {
         printf("%s\n","No");
    }
    else
    {
        printf("%s\n","Yes");
    }

    return 0;
}

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

int main(){
	
while(1){
	int x,y;
	cin>>x>>y;
	if(x<y){
		cout<<x<<" "<<y<<endl;
	}
	if(x>y){
		cout<<y<<" "<<x<<endl;
	}
	if(x==0&&y==0){
		break;
	}
	else if(x==y){
	cout<<x<<" "<<y<<endl;
}
}
	
}



Measured memory_bytes: 3040
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<functional>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;

ll K;
string s;
int main(){
    cin>>s>>K;
    K--;
    for(ll i=0;i<s.length();i++){
        if(s[i]!='1' && K>=i){
            cout<<s[i]<<endl;
            return 0;
        }
    }
    cout<<"1"<<endl;
    
    return 0;
}

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

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

	int n; cin >> n;
	vector<int> dp(n + 1);
	dp[0] = 0;
	for(int i = 1; i <= n; i++) {
		dp[i] = dp[i - 1] + 1;
		for(int j = 6; j <= i; j *= 6) {
			dp[i] = min(dp[i], dp[i - j] + 1);
		}
		for(int j = 9; j <= i; j *= 9) {
			dp[i] = min(dp[i], dp[i - j] + 1);
		}
	}
	cout << dp[n] << endl;
	return 0;
}	


Measured memory_bytes: 640
#include <bits/stdc++.h>
const int INF = 1e9+7;
using namespace std;

int main(){
    int n;
    string s;
    cin>>n>>s;
    vector<int> west(n,0);
    vector<int> east(n,0);

    if(s[0] == 'W') west[0]++;
    else if(s[0] == 'E') east[0]++;

    for(int i=1; i<n; i++){
        west[i] = west[i-1];
        east[i] = east[i-1];
        if(s[i] == 'W') west[i]++;
        else if(s[i] == 'E') east[i]++;
    }

    int ans = INF;

    for(int i=0; i<n; i++){
        int cnt = 0;
        cnt += east[n-1]-east[i];
        cnt += west[i];
        if(s[i] == 'W')cnt--;
        ans = min(ans,cnt);
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
signed main()
{
int x=0,y=0,z=0,w=0;
std::cin >> x>>y;
if(x*500>=y)std::cout << "Yes" << '\n';
else std::cout << "No" << '\n';
}


Measured memory_bytes: 256