akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

    int H;
    int P[10][5]; //パズル
    int score; //総得点
    int check; //連続した玉があるか

void renzoku_check() 
{
    for (int i = 0; i < H; i++) {
        if ((P[i][0] == P[i][1]) && (P[i][0] == P[i][2]) && (P[i][0] != P[i][3]) && (P[i][0] != 0)) {
            score += 3*P[i][0];
            P[i][0] = 0;
            P[i][1] = 0;
            P[i][2] = 0;
            check = 1;
        }
        if ((P[i][0] == P[i][1]) && (P[i][0] == P[i][2]) && (P[i][0] == P[i][3]) && (P[i][0] != P[i][4]) && (P[i][0] != 0)) {
            score += 4*P[i][0];
            P[i][0] = 0;
            P[i][1] = 0;
            P[i][2] = 0;
            P[i][3] = 0;
            check = 1;
        }
        if ((P[i][0] == P[i][1]) && (P[i][0] == P[i][2]) && (P[i][0] == P[i][3]) && (P[i][0] == P[i][4]) && (P[i][0] != 0)) {
            score += 5*P[i][0];
            P[i][0] = 0;
            P[i][1] = 0;
            P[i][2] = 0;
            P[i][3] = 0;
            P[i][4] = 0;
            check = 1;
        }
        if ((P[i][1] == P[i][2]) && (P[i][1] == P[i][3]) && (P[i][0] != P[i][2]) && (P[i][4] != P[i][2]) && (P[i][1] != 0)) {
            score += 3*P[i][1];
            P[i][1] = 0;
            P[i][2] = 0;
            P[i][3] = 0;
            check = 1;
        }
        if ((P[i][1] == P[i][2]) && (P[i][1] == P[i][3]) && (P[i][1]== P[i][4]) && (P[i][0] != P[i][1]) && (P[i][1] != 0)) {
            score += 4*P[i][1];
            P[i][1] = 0;
            P[i][2] = 0;
            P[i][3] = 0;
            P[i][4] = 0;
            check = 1;
        }
        if ((P[i][2] == P[i][3]) && (P[i][2] == P[i][4]) && (P[i][1] != P[i][2]) && (P[i][2] != 0)) {
            score += 3*P[i][2];
            P[i][2] = 0;
            P[i][3] = 0;
            P[i][4] = 0;
            check = 1;
        }
    }
}

void drow()
{
    for (int i = 1; i < H; i++) {
        for (int j = 0; j < 5; j++) {
            if (P[i][j] == 0) {
                for (int k = i; k > 0; k--) {
                    P[k][j] = P[k-1][j];
                }
                P[0][j] = 0;
            }
        }
    }
}

int main()
{
    while(1)
    {
        cin >> H;
        if (H == 0) {
            break;
        }
        for (int i = 0; i < H; i++) { //パズル初期化
            for (int j = 0; j < 5; j++) {
                cin >> P[i][j];
            }
        }
        score = 0;

        while(1)
        {
            check = 0;
            renzoku_check();
            if (check == 0) break;
            drow();
        }
        
        cout << score << endl;


    }
}


Measured memory_bytes: 3084
n,m=map(int,input().split())
key=[]
for _ in range(m):
  a,b=map(int,input().split())
  c=list(map(int,input().split()))
  bi=0
  for i in c:
    bi+=1<<(i-1)
  key.append([a,bi])
#print(key)

INF=2**24
dp=[INF]*(1<<n)
dp[0]=0
for k in key:
  for b in range(1<<n):
    dp[b|k[1]]=min(dp[b|k[1]],dp[b]+k[0])
    #print(b,k[1],b|k[1],dp)
    
print(-1 if dp[-1]==INF else dp[-1])

Measured memory_bytes: 9284
#include <bits/stdc++.h>
using namespace std;
int A[100000];
int partition(int p,int r){
	int x=A[r],i=p-1;
	for(int j=p;j<r;j++)
		if(A[j]<=x) swap(A[++i],A[j]);
	swap(A[i+1],A[r]);
	return i+1;
}
int main()
{
	int n; cin>>n;
	for(int i=0;i<n;i++)
		scanf("%d",&A[i]);
	int q = partition(0,n-1);
	for(int i=0;i<n;i++){		
		if(i==q) printf("[%d]",A[i]);
		else printf("%d",A[i]);
		printf("%c",(i==n-1)?'\n':' '); 
	}
}


Measured memory_bytes: 3572
from collections import deque

n = int(input())
q = deque()

q.append(1)
q.append(-1)  # increment event
cost = 1
costs = [-1] * n
while costs[0] == -1:
    head = q.popleft()
    if head == -1:
        cost += 1
        q.append(-1)
        continue
    elif costs[head] != -1:
        continue
    costs[head] = cost
    q.appendleft(head * 10 % n)
    q.append((head + 1) % n)
print(costs[0])

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

int main() {
  int n,k;
  cin>>n>>k;
  double sum = max(0,n-k+1);
  for (size_t i = 17; i >=1; i--) {
    sum += max(min(n+1,(int)ceil(k/pow(2,i-1)))-(int)ceil(k/pow(2,i)),0)/pow(2,i);
  }
  cout<<setprecision(12)<<sum/n;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
const lli INF = 1e9 + 100;
const lli INF64 = (1LL << 61) + 100;
const lli MOD = 1e9 + 7;
const lli MH1 = 1599614977, MH2 = 2034417103, MH3 = 1090250123, MH4 = 2024491871;
lli bpow(lli baseee, lli exponenttt) {
	if(exponenttt < 0) return 0;
	lli res = 1;
	baseee %= MOD;
	while (exponenttt > 0) {
		if ((exponenttt & 1) == 1) res = (res*baseee) % MOD;
		baseee = (baseee*baseee) % MOD;
		exponenttt >>= 1;
	}
	return res;
}
lli multInverse(lli a) {//if_mod_is_prime
	return bpow(a, MOD - 2);
}
lli divm(lli a, lli b) {//if_mod_is_prime
	return (a * multInverse(b)) % MOD;
}
lli multm(lli a, lli b) {
	return (a * b) % MOD;
}
lli subm(lli a, lli b) {
	a += MOD;
	lli r = a - b;
	if(r >= MOD) return r - MOD;
	return r;
}
lli addm(lli a, lli b) {
	lli r = a + b;
	if(r >= MOD) return r - MOD;
	return r;
}
signed main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//	freopen("input.txt", "r", stdin);
	//	freopen("output.txt", "w", stdout);
    int n;
    cin >> n;
    map<string, int> dict;
    for(int i = 1; i <= n; i++) {
        string ss;
        cin >> ss;
        dict[ss]++;
    }
    cout << "AC x " << dict["AC"] << "\n";
    cout << "WA x " << dict["WA"] << "\n";
    cout << "TLE x " << dict["TLE"] << "\n";
    cout << "RE x " << dict["RE"] << "\n";

	return 0;
}


Measured memory_bytes: 3668
#include <iostream>

int main() {
    int A, B, K;
    std::cin >> A >> B >> K;

    if (K * 2 <= B - A + 1) {
        for (int n = A; n < A + K; n ++) {
            std::cout << n << std::endl;
        }
        for (int n = B - K + 1; n <= B; n ++) {
            std::cout << n << std::endl;
        }
    } else {
        for (int n = A; n <= B; n ++) {
            std::cout << n << std::endl;
        }
    }
}


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

using namespace std;

int main() {
	int N, M;
	cin >> N >> M;
	if (M == 1) {
		cout << 0 << endl;
		return 0;
	}
	vector<int> points(M);
	for (int i = 0; i < M; ++i) {
		cin >> points[i];
	}
	sort(points.begin(), points.end());
	vector<int> diffs(M - 1);
	for (int i = 0; i < M - 1; ++i) {
		diffs[i] = points[i + 1] - points[i];
	}
	sort(diffs.begin(), diffs.end());
	long long ans = 0;
	for (int i = 0; i < max(M - N, 0); ++i) {
		ans += diffs[i];
	}
	cout << ans << endl;
	return 0;
}

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

int main(void){
    string s;
    cin >> s;
    long long n;
    cin >> n;
    rep(i,n){
        if(s[i] != '1'){
            cout << s[i] << endl;
            return 0;
        }
    }
    cout << s[n-1] <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const  ll INF = 1e18;
const  ll MOD = 1e9 + 7;
#define all(v) v.begin(), v.end()
#define repi(i,n,init) for(ll i=init;i*i<=(n);i++)
#define repd(i,n,init) for(ll i=(n);i>=init;i--)
#define repm(i,m) for(auto i=m.begin();i!=m.end();i++)
int main()
{
    ll N;
    cin >> N;
    ll ans = INF;
    repi(i,N,1){
        if(N%i != 0){
            continue;
        }
        ll j = N/i;
        ans = min(ans,i+j-2);
    }
    cout << ans << endl;
    return 0;
}

/*memo*/
// 数学的考察をしましょう
// 表を使うときは対称性に気をつける。
// 2次元にとらわれすぎない
// 整数の性質を使う
// sqrt(N)よりかはi*i < Nのほうがよき

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()
template<class T>
using reverse_priority_queue = priority_queue<T, vector<T>, greater<T>>;

ll solve_sub(const vector<pair<ll, ll>>& ks){
    map<ll, vector<ll>> x;
    for(const auto& p : ks){
        x[p.first].push_back(p.second);
    }
    reverse_priority_queue<ll> que;
    for(auto it = x.begin(); it != x.end(); ++it){
        const ll ki = it->first;
        for(ll s : it->second){
            que.push(s);
        }
        while(que.size() > ki + 1){
            que.pop();
        }
    }
    ll ret = 0;
    while(!que.empty()){
        ret += que.top();
        que.pop();
    }
    return ret;
}

void solve(){
    ll n;
    cin >> n;
    vector<pair<ll, ll>> l, r;
    ll ans = 0;
    REP(i, n){
        ll ki, li, ri;
        cin >> ki >> li >> ri;
        ki--;
        if(li == ri || ki == n - 1){
            ans += li;
        }else if(li > ri){
            ans += ri;
            l.emplace_back(ki, li - ri);
        }else{
            assert(li < ri);
            assert(ki < n - 1);
            ans += li;
            r.emplace_back(n - 1 - ki - 1, ri - li);
        }
    }
    ans += solve_sub(l) + solve_sub(r);
    cout << ans << endl;
}

int main(){
    ll t;
    cin >> t;
    REP(i, t){
        solve();
    }
    return 0;
}


Measured memory_bytes: 16180
#include <bits/stdc++.h>
 
using namespace std;
 
int n, k, ta, tb, ma;
 
int gcd(int a, int b) {
	if (b == 0)
		return a;
	return gcd(b, a % b);
}
 
int main() {
	scanf("%d%d", &n, &k);
	scanf("%d", &ta);
	ma = ta;
	n--;
	while (n--) {
		scanf("%d", &tb);
		ma = max(ma, tb);
		ta = gcd(ta, tb);
	}
	if (ma >= k && (ma - k) % ta == 0)
		printf("POSSIBLE\n");
	else
		printf("IMPOSSIBLE\n");
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define FOR(i, m, n) for (ll i = m; i < (n); i++)
#define RFOR(i, m, n) for (ll i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define print(ele) cout << (ele) << "\n"
#define print10(ele) cout << fixed << setprecision(10) << (ele) << "\n"

using namespace std;
typedef long long ll;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

int main() {
  int n, p;
  cin >> n >> p;
  ivec a(n);
  bool isAllEven = true;
  REP(i, n) {
    ll tmp;
    cin >> tmp;
    if (tmp % 2) {
      isAllEven = false;
    }
  }

  ll ans;
  if (isAllEven) {
    ans = p ? 0 : pow(2, n);
  } else {
    ans = pow(2, n - 1);
  }
  print(ans);
  return 0;
}

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

int b143(void);
int c143(void);

int main(void) {
	c143();
	return 0;
}

int b143(void) {
	int n;
	std::cin >> n;
	std::vector<int> k;
	int temp;
	for (int i = 0; i < n; i++) {
		std::cin >> temp;
		k.push_back(temp);
	}
	int sum = 0;
	for (int i = 0; i+1 < n;  i++) {
		for (int j = i+1; j < n; j++) {
			sum += k[i] * k[j];
		}
	}
	std::cout << sum;
	return 0;
}

int c143(void) {
	int l;
	std::cin >> l;
	std::string colors;
	std::cin >> colors;
	std::string result;
	char holder='0';

	for (int i = 0; i < l; i++) {
		if (holder != colors[i]) {
			result.push_back(colors[i]);
			holder = colors[i];
		}
	}
	std::cout << result.size();
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
    for(auto &e:t) fill_v(e,v);
}

int main() {
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;

  function<string(int, int)> calc = [](int dx, int dy){
    string ret = "";
    if(dx > 0 && dy > 0){
      REP(i, dy) ret += "U";
      REP(i, dx) ret += "R";
    } else {
      REP(i, -dy) ret += "D";
      REP(i, -dx) ret += "L";
    }
    
    return ret;
  };

  string ans = "";
  ans += calc(tx - sx, ty - sy);
  ans += calc(sx - tx, sy - ty);
  ans += "LU" + calc(tx - sx, ty - sy) + "RD";
  ans += "RD" + calc(sx - tx, sy - ty) + "LU";

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
/*"You can do anything you set your mind to,man" - Eminem*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define llpow(a,b) (ll)(pow(a,b)+0.5)
#define l_b(a,val) min((int)a.size()-1, (int)(lower_bound(a.begin(),a.end(),val)-a.begin()))
#define f first
#define up(a,b) max(a,b)
#define s second
#define INF 9223372036854775807
const  int mod = 1000000007;
void add(ll& a, ll b){a+=b;while(a>=mod)a-=mod;while(a<0)a+=mod;}
void mul(ll& a, ll b){a*=b;while(a>=mod)a-=mod;while(a<0)a+=mod;}
void up_self(ll& a, ll b){a = up(a,b);}
void min_self(ll& a, ll b){a = min(a,b);}
ll binexpomodulo(ll x, ll y){ll res =1;x%=mod;if(!x)return 0;while(y){if(y&1){mul(res, x);}mul(x,x);y>>=1;}return res;}
ll nCrInOr(ll n, ll r){ll res = 1;if(r>n-r)r = n-r;ll rin = 1;for(ll i = 1; i <=r ; i++)rin = (rin*i)%mod;rin = binexpomodulo(rin,mod-2);for(ll i = 1; i <= r; i++)res = (res*(n-i+1))%mod;res = (res*rin)%mod;return res;}
int msb(ll n){int ans;for(int i = 0 ; i < 64;  i++)if(n&(1LL<<i))ans = i+1;return ans;}
void strrev(string& s){int n = (s.size());for(int i = 0 ; i < n/2; i++)swap(s[i],s[n-1-i]);}
int main()
{
	ll n,w; cin>>n>>w;
	vector<ll> dp(w+1);
	for(int i = 0 ; i < n; i++){
		ll weight, value;
		cin>>weight>>value;
		for(int prev_weight = w- weight; prev_weight>=0; prev_weight--){
			up_self(dp[prev_weight+weight],dp[prev_weight]+(ll)value);
		}
	
	}
	ll ans = -1;
	for(ll c : dp){
		up_self(ans,c);
	}
	cout<<ans<<endl;
  	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iomanip>
#include <vector>
#include <cstdio>
#include <float.h>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <stack>
#include <functional>
 
using namespace std;
 
#define endl '\n'
#define MOD 1000000007
#define INF 1ll<<30
#define MAX 100010
#define eps 1e-11
#define bit_max 1ll<<32
#define _USE_MATH_DEFINES
 
 
 
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
  //  freopen("./input.txt","r",stdin);
 //   freopen("./output.txt","w",stdout);
    long long int n;
    cin>>n;
    int b[n];
    for(int i=0;i<n-1;i++)
        cin>>b[i];
    int a[n]={0};
    for(int i=0;i<n;i++)
    {
        if(i==0)
        {
            a[i] = b[i];
        }
        else if(i==n-1)
        {
            a[i]= b[i-1];
        }
        else
        {
            a[i]=min(b[i],b[i-1]);
        }
    }
    long long int ans =0;
    for(int i=0;i<n;i++)
    {
        ans+=a[i];
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
    int n,l,i,j;
    scanf("%d %d",&n,&l);
    l=l+1;
    char s[n][l],p[l];
    for(i=0;i<n;i++)
    {
        scanf("%s", s[i]);
    }
    for(i=0;i<n;i++)
    {
        for(j=i+1;j<n;j++)
        {
            if(strcmp(s[i],s[j])>0)
            {
                strcpy(p,s[i]);
                strcpy(s[i],s[j]);
                strcpy(s[j],p);
            }
        }
    }
    for(i=0;i<n;i++)
    {
        printf("%s",s[i]);
    }
    return 0;
}


Measured memory_bytes: 1736
#include <stdio.h>
#include <math.h>
#define N 10000
int prime(double x);
int main(){
  int i,n,a[N],count=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){ 
    if(scanf("%d",&a[i])==EOF) break;
    count+=prime((double)a[i]);
  }
  printf("%d\n",count);
  return 0;
}

int prime(double a){
  int i; 
  if(a==2)
    return 1;
  if(a<2 || ((int)a%2)==0)
    return 0;

  i=3;
  while((double)i<=sqrt(a)){
    if ((int)a%i==0) return 0;
    i=i+2;
  }
  return 1;

}

Measured memory_bytes: 628
N,M=map(int,input().split())
H=list(map(int,input().split()))
n=[1 for i in range(N)]
for i in range(M):
    A,B=map(int,input().split())
    if H[A-1]>H[B-1]:
        n[B-1]=0
    elif H[A-1]<H[B-1]:
        n[A-1]=0
    else:
        n[A-1]=0
        n[B-1]=0
print(sum(n))

Measured memory_bytes: 20032
import collections,copy,sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N,M = LI()
AB = [LI() for _ in range(M)]
graph = {i:collections.deque() for i in range(1,N+1)} #1_indexed
for a,b in AB:
    graph[a].append(b)
    graph[b].append(a)
for i in range(1,N+1):
    if not graph[i]:
        print('No')
        exit()
else:
    print('Yes')
seen = [0]*(N+1) #1_indexed
min_dist = [-1]*(N+1) #1_indexed
queue = collections.deque() #頂点NOを入れておく
def bfs():
    c_graph = copy.deepcopy(graph)
    seen[1] = 1
    queue.append(1)
    min_dist[1] = 0
    while queue:
        q_NO = queue.popleft()
        q_dist = min_dist[q_NO]
        if not c_graph[q_NO]:
            continue
        g = c_graph[q_NO]
        for _ in range(len(g)):
            g_NO = g.popleft()
            if seen[g_NO]:
                continue
            seen[g_NO] = 1
            queue.append(g_NO)
            min_dist[g_NO] = q_dist+1
bfs()
for j in range(2,N+1):
    ans,dist = 0,float('INF')
    for x in graph[j]:
        if dist>=min_dist[x]:
            ans = x
            dist = min_dist[x]
    print(ans)


Measured memory_bytes: 196344
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    long long N, A, B;
    cin >> N >> A >> B;
    long long MIN = A * (N - 1) + B;
    long long MAX = A + B * (N - 1);
    cout << max(0LL, MAX - MIN + 1) << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

typedef unsigned long ul;
typedef long long ll;
typedef pair<ul, ul> P;
map<int, int> dp;
#define REP(i, n) for (int i = 0; i < n; i++)

bool in(int target, int max) { return 0 <= target && target < max - 1; }
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, K;
  cin >> N >> K;
  cout << N -K + 1 <<endl;
  

  return 0;
}


Measured memory_bytes: 888
#include <stdio.h>
#include<math.h>
#include <iostream>
#include<string.h>
#include<map>
#include<vector>
#include<algorithm>
using namespace std;
#define mod 1000000007
int h[100005],a[100005],b[100005];
vector<int>q[100005];
int check(int pos)
{
    int flag=0;
    for(int i=0; i<q[pos].size(); i++)
    {
        int t=q[pos][i];
        if(h[t]>=h[pos])
        {
            flag=1;
            break;
        }
    }
    return flag;
}
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=1; i<=n; i++)
    {
        scanf("%d",&h[i]);
    }
    memset(q,0,sizeof(q));
    for(int i=0; i<m; i++)
    {
        scanf("%d%d",&a[i],&b[i]);
        q[a[i]].push_back(b[i]);
        q[b[i]].push_back(a[i]);
    }
    int cnt=0;
    for(int i=1; i<=n; i++)
    {
        if(check(i)==0||q[i].size()==0)
        {
            //printf("%d\n",i);
            cnt++;
        }

    }
    printf("%d\n",cnt);
    return 0;
}


Measured memory_bytes: 10104
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
use std::vec::Vec;
use std::{vec, cmp, num};


struct Scanner<'a> {
    cin: StdinLock<'a>,
}

impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner {cin: cin}
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
                    .skip_while(|c| c.is_whitespace())
                    .take_while(|c| !c.is_whitespace())
                    .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

// create Vec<char> from String
#[allow(dead_code)]
fn to_chars(s: String) -> vec::Vec<char> {
    let mut cs = s.chars();
    let mut res = vec::Vec::new();
    while let Some(c) = cs.next() {
        res.push(c);
    }
    res
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);
    let a: i32 = sc.read();
    let b: i32 = sc.read();
    if a * b % 2 == 0 {
        println!("Even");
    } else {
        println!("Odd");
    }
}

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

int main()
{
    string s;
    cin >> s;
    int count = 0;
  
for(int i= 0; i < s.size();i++){
if( (i+1) % 2 == 0){
        if (s.at(i) == 'L'|| s.at(i) == 'U' || s.at(i) == 'D')
            {
                count++;
            }
   }else if((i+1) % 2 == 1){
       if (s.at(i) == 'R' || s.at(i) == 'U' || s.at(i) == 'D')
       {
           count++;
       }
   }

}


    if(count == s.size()){
        cout << "Yes" <<endl;
    }else{
        cout <<"No"<<endl;
    }


return 0;
}


Measured memory_bytes: 384
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//{akari : 1D, yukari : 2D, maki : 3D} vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//{akane : ascending order, aoi : decending order} priority queue
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Libraries ---------------------------------//

//------------------------------- Dubug Functions ---------------------------//

inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}

//------------------------------- Solver ------------------------------------//

void solve()
{
    int n;
    seika s, t;
    cin >> n >> s >> t;
    for (int i = 0; i < n; i++)
    {
        cout << s[i] << t[i];
    }
    cout << endl;
}

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


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    long int N,Y;
    cin>>N;
    cin>>Y;
    
    for(int i=N;i>=0;i--){
        for(int j=N-i;j>=0;j--){
            if(10000*i+5000*j+1000*(N-i-j)==Y){
                cout<<i<<" "<<j<<" "<<(N-i-j)<<endl;
                return 0;
            }
        }
    }
    cout<<-1<<" "<<-1<<" "<<-1<<endl;
}


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

ans = sum(b)

for i in range(n-1):
    if a[i]+1==a[i+1]:
        ans += c[a[i]-1]
print(ans)


Measured memory_bytes: 38384
INF = 10 ** 20
while True:
  n = int(input())
  if n == 0:
    break
  names = []
  weights = []
  safes = []
  for _ in range(n):
    f, w, s = input().split()
    names.append(f)
    weights.append(int(w))
    safes.append(int(s))
  all_weight = sum(weights)
  dic = [None] * (2 ** n)
  
  def score(rest, total_weight, count):
    if dic[rest] != None:
      return dic[rest]
    if rest == 0:
      return (0, [])

    ret = (INF, [])
    mask = 1
    for i in range(n):
      if rest & mask:
        if safes[i] >= all_weight - total_weight - weights[i]:
          temp = score(rest & ~mask, total_weight + weights[i], count + 1) 
          ret = min(ret, (temp[0] + weights[i] * (count + 1), [names[i]] + temp[1]))
      mask <<= 1
    dic[rest] = ret
    return ret

  print(*score(2 ** n - 1, 0, 0)[1], sep="\n")


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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
using Graph = vector<vector<int>>;

//BIT,O(log(N)) 
int N;
int bit[500010];
// v[a] += w
void add(int a, int w){
    for(int x = a; x <= N; x += x & -x) bit[x] += w;
}
// v[1] + ... + v[a]
int sum(int a){
    int res = 0;
    for(int x = a; x > 0; x -= x & -x) res += bit[x];
    return res;
}
// v[l] + ... + v[r]
int range_sum(int l, int r){
    return sum(r) - sum(l-1);
}


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

    vector<int> res(Q+1,0);
    vector<int> A(N+1,0); //A[i] 種類iの玉の最も右側のインデックス。
    vector<int> C(N+1,0); //C[i] i番目の玉
    vector<vector<int>> q_l(N+1),q_ind(N+1);
    
    rep1(i,N)cin>>C[i];//1-ind
    rep(i,Q){
        int l,r; cin>>l>>r;
        q_l[r].push_back(l);
        q_ind[r].push_back(i);
    }
    rep(i,5e5+10)bit[i] = 0;
    rep1(i,N)A[i] = 0;
    rep1(i,N){
        //左端から順に玉を見ていく。
        if(A[C[i]]>0)add(A[C[i]],-1);
        add(i,1);
        A[C[i]]=i;//C[i]の最も右側のindはiである。
        rep(j,q_l[i].size()){
            res[q_ind[i][j]] = range_sum(q_l[i][j],i);
        }
    }
    rep(i,Q)cout<<res[i]<<endl;
}



Measured memory_bytes: 52980
type t = { v : int; w : int }

let solve n w a =
  let s = Array.make (w + 1) 0 in
  let t = Array.copy s in
  for i = 0 to n - 1 do
    for j = a.(i).w to w do
      if s.(j - a.(i).w) + a.(i).v > s.(j) then
        t.(j) <- s.(j - a.(i).w) + a.(i).v;
    done;
    Array.iteri (fun i e -> s.(i) <- e) t;
  done;
  t.(w)

let () =
  let (n, w) = Scanf.scanf "%d %d " (fun n w -> n, w) in
  Array.init n (fun _ -> Scanf.scanf "%d %d " (fun v w -> { v; w }))
  |> solve n w |> Printf.printf "%d\n"

Measured memory_bytes: 2544
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define f(i,j,n) for(int i=j;i<=n;i++)
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,t=0;
    cin>>n;
    ll a[n];
    f(i,1,n){
        cin>>a[i];
        if(i%2!=0&&a[i]%2!=0)
          t++;
    }
    cout<<t;
}   
   

Measured memory_bytes: 3572
x = input().split()
a = int(x[0])
b = int(x[1])
c = int(x[2])
 
if a <= b <= c:
    print(a,b,c)
elif a <= c <= b:
    print(a,c,b)
elif b <= a <= c:
    print(b,a,c)
elif b <= c <= a:
    print(b,c,a)
elif c <= a <= b:
    print( c,a,b)
else:
    print(c,b,a)

Measured memory_bytes: 6724
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

int main() {
	while (true){
		if (cin.eof())
			break;
		bool cell[8][8] = { false };
		int ans = 0;
		string s;
		getline(cin, s);
		if (s.empty())
			continue;
		REP(j, 8){
			if (s[j] == '1')
				cell[0][j] = true;
		}
		REP(i, 7){
			getline(cin, s);
			REP(j, 8){
				if (s[j] == '1')
					cell[i+1][j] = true;
			}
		}
		REP(i, 8){
			REP(j, 8){
				if (cell[i][j]){
					REP(k, 3)
						REP(l, 3)
						if (i + (k - 1) >= 0 && i + (k - 1) < 8 && j + (l - 1) >= 0 && j + (l - 1) < 8 && cell[i + (k - 1)][j + (l - 1)])
							ans += 1 << (8 - (k * 3 + l));
					i = 8;
					j = 8;
				}
			}
		}
		switch (ans){
		case 27:
			cout << 'A' << endl;
			break;
		case 18:
			cout << 'B' << endl;
			break;
		case 24:
			cout << 'C' << endl;
			break;
		case 22:
			cout << 'D' << endl;
			break;
		case 25:
			cout << 'E' << endl;
			break;
		case 19:
			cout << 'F' << endl;
			break;
		case 30:
			cout << 'G' << endl;
			break;
		}
	}
}

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


/*
int main(){


 long long h,w;
cin>>h>>w;

 string board[50];

 for(int i=0;i<h;i++) cin>>board[i];

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

 for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){

     if(board[i][j] == '#') continue;

      int num=0;

      for(int d=0;d<8;d++){
        const int a1 = i+dy[d];
        const int b1 = j+dx[d];

        if(a1 < 0 || a1>=h) continue;
        if(b1 < 0 || b1>= w) continue;

        if(board[a1][b1] == '#') num++;
      }

      board[i][j] = char(num+'0');

    }
 }


 for(int i=0;i<h;i++)
    cout<<board[i]<<endl;


return 0;
}

*/


int main(){

 int a,b,c;
 cin>>a>>b>>c;

 if(a == b)
    cout<<c<<endl;
 else if(b == c)
    cout<<a<<endl;
 else if(a == c)
    cout<<b<<endl;



 return 0;
}














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

using namespace std;

int main()
{
	vector<int>vec;
	int n,val,k,sum=0;
	cin >> n>>k;
	for (int i = 0;i < n;i++) 
	{
		cin >> val;
		vec.push_back(val);
	}
	sort(vec.begin(), vec.end());
	for (int i = 0;i < k;i++) {
		sum += vec[i];
	}
	cout << sum;
}



Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long int N = 0, K = 0, a = 0;
	cin >> N >> K;
	if(K == 0){
		a = 0;
    } else {
		a = N % K;
    }
	if(a <= K - a){
		cout << a;
	} else {
		cout << K - a;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
vector<ll> layerNum;
vector<ll> pattiNum;
//------------------------------------------------------------------------------
ll Solve(int N, ll X)
{
    if (N == 0)
    {
        return X <= 0 ? 0 : 1;
    }
    else if (X <= 1 + layerNum[N - 1])
    {
        return Solve(N - 1, X - 1);
    }
    else
    {
        return pattiNum[N - 1] + 1 + Solve(N - 1, X - 2 - layerNum[N - 1]);
    }
}

void _main()
{
    int N;
    ll X;
    cin >> N >> X;

    layerNum.resize(N + 1);
    pattiNum.resize(N + 1);
    layerNum[0] = 1;
    pattiNum[0] = 1;
    rep(i, 0, N)
    {
        layerNum[i + 1] = layerNum[i] * 2 + 3;
        pattiNum[i + 1] = pattiNum[i] * 2 + 1;
    }

    cout << Solve(N, X) << endl;
}


Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    a, b, c = map(int, readline().split())

    ans = a + b + c - max(a, b, c)

    print(ans)

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 61924
program problemC
  implicit none

  integer, parameter    :: i8 = selected_int_kind  ( 18 )
  integer ( kind = i8 ) :: N, i, ans, tmp

  read *, N

  ans = N

  do i = 1, int ( sqrt ( real ( N ) ) )
!     print *, i
     if ( mod ( N, i ) == 0 ) then
        tmp = N / i + i - 2
        if ( tmp < ans ) then
           ans = tmp
        end if
     end if
  end do

  print *, ans
  
end program problemC

     


Measured memory_bytes: 384
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


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


	int N;
	string S;
	cin >> N >> S;

	int kotae = 0;
	rep(i, N - 2) {
		if (S.substr(i, 3) == "ABC") kotae++;
	}
	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 384
s=int(input())
mod=10**9+7
if s<=2:
  print(0)
  exit()
if s==3:
  print(1)
  exit()
dp=[0]*(s+1)
for i in range(3,s+1):
  dp[i]+=1
  for j in range(3,s+1):
    if i+j>s:
      continue
    dp[i+j]+=dp[i]
    dp[i+j]%=mod
  dp[i]%=mod
print(dp[-1]%mod)

Measured memory_bytes: 9200
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <cctype>
#include <algorithm>
#include <functional>
#include <utility>
#include <vector>
const int maxn = 200005;
using ll = long long;
int A[maxn], B[maxn];
int SA[maxn], SB[maxn];
int n;
inline void resort(int p, int *A, int *SA) {
  std::vector<int> V1, V2;
  for(int i = 1; i <= n; i ++) {
    int th = SA[i];
    if((1 << p) & A[th]) V2.push_back(th);
    else V1.push_back(th);
  }
  int cnt = 0;
  for(int th : V1) {
    SA[++ cnt] = th;
  }
  for(int th : V2) {
    SA[++ cnt] = th;
  }
#ifdef LOCAL
  printf("SA(%d) :", p);
  for(int i = 1; i <= n; i ++) {
    printf(" %d", SA[i]);
  }
  puts("");
#endif
}
inline ll calc(int bt, int p) {
  int pt = n; ll ans = 0;
  int vp = (1 << (bt + 1)) - 1;
  for(int i = 1; i <= n; i ++) {
    int th = SA[i];
    while(pt > 0 && (A[th] & vp) + (B[SB[pt]] & vp) > p) {
      pt --;
    }
    ans += pt;
  }
  return ans;
}

int main() {
  scanf("%d", &n);
  for(int i = 1; i <= n; i ++) {
    scanf("%d", &A[i]); SA[i] = i;
  }
  for(int i = 1; i <= n; i ++) {
    scanf("%d", &B[i]); SB[i] = i;
  }
  int ans = 0;
  for(int i = 0; i <= 28; i ++) {
    resort(i, A, SA); resort(i, B, SB);
    ll val = calc(i, (1 << (i + 1)) - 1) - calc(i, (1 << i) - 1);
    val += calc(i, (1 << (i + 2)) - 1) - calc(i, (3 << i) - 1);
    if(1LL & val) ans |= (1 << i);
#ifdef LOCAL
    printf("Sol(%d) : %lld\n", i, val);
#endif
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 5212
import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        String s = fs.next();

        int ans = Integer.MAX_VALUE;
        for (int i = 0; i <= s.length()-3; ++i) {
            int tmp = Integer.parseInt(s.substring(i, i+3));
            ans = Math.min(ans, Math.abs(753 - tmp));
        }

        System.out.println(ans);
    }
}

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: 32440
#include<bits/stdc++.h>
using namespace std;
int main(){
  string str;
  int q;
  string m,p;
  int a,b,j,k;
  cin>>str;
  cin>>q;
  for(int i=0;i<q;i++){
    cin>>m>>a>>b;
    if(m=="replace"){
      cin>>p;
      for(int j=a;j<=b;j++){
	str[j]=p[j-a];
      }
    }
    else if(m=="reverse"){
      j=a;
      k=b;
      while(j<k){
	swap(str[j],str[k]);
	j++;
	k--;
      }
    }
    else if(m=="print"){
      for(int j=a;j<=b;j++){
	cout<<str[j];
      }
      cout<<endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a, b, c, k, s=0;
    scanf("%d%d%d%d",&a,&b,&c,&k);
        if(a < k)
        {
            s+=a;
            k-=a;

            if(b < k){
                k-=b;
                s-=k;
            }
        }
        else s = k;
    printf("%d\n",s);
}

Measured memory_bytes: 3824
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <stack>
#include <queue>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (int i=0;i<N;i++)

namespace mod {

	ll MOD = 1000000007;

	ll add(ll x, ll y) {
		return (x + y) % MOD;
	}

	ll sub(ll x, ll y) {
		return (x + MOD - (y % MOD)) % MOD;
	}

	ll mul(ll x, ll y) {
		return ((x % MOD) * (y % MOD)) % MOD;
	}

	ll power(ll x, ll y) {
		if (y == 0) {
			return 1;
		}
		else if (y == 1) {
			return x % MOD;
		}
		else if (y % 2 == 0) {
			ll pow = power(x, y / 2);
			return (pow * pow) % MOD;
		}
		else {
			ll pow = power(x, y / 2);
			return (((pow * pow) % MOD) * x) % MOD;
		}
	}

	ll div(ll x, ll y) {
		return mul(x, power(y, MOD - 2));
	}

	//階乗x~y
	ll fact(ll x, ll y) {
		if (x == y) {
			return x;
		}
		else {
			return mul(x, fact(x - 1, y));
		}
	}

	//組み合わせ nCr
	ll conbi(ll n, ll r) {
		return div(fact(n, n - r + 1), fact(r, 1));
	}

	//順列 nPr
	ll perm(ll n, ll r) {
		return fact(n, n - r + 1);
	}

	//重複組合せ nHr
	ll homo(ll n, ll r) {
		return conbi((n + r - 1), r);
	}
}


//変数
ll N, M;

//解法
void solve() {

	vector<pair<ull, ull>> vec;

	//素因数分解
	while (M!=1) {

		int ii = 0;

		//素因数を見つける
		for (int i = 2; i <= M;i++) {
			if (M%i == 0) {
				ii = i;
				M /= i;
				break;
			}
		}
		//vectorに格納
		bool flag=false;
		rep(i, vec.size()) {
			if (vec[i].first == ii) {
				vec[i].second++;
				flag = true;
				break;
			}
		}
		if (flag == false) {
			vec.emplace_back(make_pair(ii, 1));
		}

	}

	ll ans = 1;

	rep(i, vec.size()) {
		ans = mod::mul(ans, mod::homo(N, vec[i].second));
	}

	cout << ans << endl;

	return;
}

int main() {
	//入力
	cin >> N >> M;
	solve();
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define int long long
#define lint long long
#define pii pair<int, int>
#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 REP(i, n) FOR(i, 0, n)
#define SZ(v) ((int)v.size())
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define FILLINF(a) memset(a, 0x3f, sizeof(a))
#define POW(n) (1LL << (n))
#define POPCNT(n) (__builtin_popcount(n))
#define IN(i, a, b) ((a) <= (i) && (i) <= (b))
using namespace std;
template <typename T> inline bool CHMIN(T& a, T b) { if(a > b) { a = b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a, T b) { if(a < b) { a = b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(begin(a), end(a)); }
template <typename T> inline void REV(T& a) { reverse(begin(a), end(a)); }
template <typename T> inline void UNI(T& a) { sort(a.begin(), a.end()); a.erase(unique(a.begin(), a.end()), a.end()); }
template <typename S, typename T> inline T LB(S& v, T a) { return *lower_bound(begin(v), end(v), a); }
template <typename S, typename T> inline int LBP(S& v, T a) { return lower_bound(begin(v), end(v), a) - begin(v); }
template <typename S, typename T> inline T UB(S& v, T a) { return *upper_bound(begin(v), end(v), a); }
template <typename S, typename T> inline int UBP(S& v, T a) { return upper_bound(begin(v), end(v), a) - begin(v); }
template <typename S, typename T> ostream& operator << (ostream& os, const pair<S, T>& p) { os << p.first << " " << p.second; return os; }
template <typename S, typename T> istream& operator >> (istream& is, pair<S, T>& p) { is >> p.first >> p.second; return is; }
template <typename T> ostream& operator << (ostream& os, const vector<T>& v) { for (int i = 0; i < v.size(); ++i) { if (i) os << " "; os << v[i]; } return os; }
template <typename T> istream& operator >> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template <typename T, typename V> typename enable_if<is_class<T>::value == 0>::type fill_v(T& t, const V& v) { t = v; }
template <typename T, typename V> typename enable_if<is_class<T>::value != 0>::type fill_v(T& t, const V& v) { for(auto &e : t) fill_v(e, v); }
const double PI = 3.14159265358979323846;
const double EPS = 1e-10;
const lint INF = 0x3f3f3f3f3f3f3f3f;
const lint MOD = 1000000007;

void _main() {
    int N, A, B;
    cin >> N >> A >> B;
    int ans = (N / (A + B)) * A;
    N %= (A + B);
    ans += min(A, N);
    cout << ans << endl;
}

signed main(signed argc, char **argv) {
    if (argc > 1) {
        if (strchr(argv[1], 'i')) freopen("input.txt", "r", stdin);
        if (strchr(argv[1], 'o')) freopen("output.txt", "w", stdout);
    }
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
bool p[5001][5001];
int main(){
  while(cin>>n&&n){
    int px[5000],py[5001],an=0;
    for(int i=0;i<n;i++)cin>>px[i]>>py[i],p[px[i]][py[i]]=1;
    for(int i=0;i<n;i++)
      for(int j=i;j<n;j++){
	int dx=px[i]-px[j],dy=py[i]-py[j];
	int x1=px[i]-dy,y1=py[i]+dx,x2=px[j]-dy,y2=py[j]+dx;
	int x3=px[i]-dy,y3=py[i]+dx,x4=px[j]+dy,y4=py[j]-dx;

	if(0<=x1&&x1<=5000&&0<=y1&&y1<=5000&&p[x1][y1]&&0<=x2&&x2<=5000&&0<=y2&&y2<=5000&&p[x2][y2])an=max(an,dx*dx+dy*dy);

	if(0<=x3&&x3<=5000&&0<=y3&&y3<=5000&&p[x3][y3]&&0<=x4&&x4<=5000&&0<=y4&&y4<=5000&&p[x4]&&p[x4][y4])an=max(an,dx*dx+dy*dy);

      }
    cout<<an<<endl;
  }
  return 0;
}

Measured memory_bytes: 25000
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, a, b, c, d, e, f;
  cin >> N;
  a = N % 10;
  b = (N - a) / 10;
  c = N / 1000;
  d = N - 1000 * c;
  e = b % 111;
  f = d % 111;
  if (e == 0 || f == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int h, w, k;
LL dp[1010][101];
const LL mod = 1e9 + 7;

LL calc1(int cur){
    LL ret = 0;
    REP(i, (1 << (w - 1))){
        bool isok = true;
        if((1 << cur) & i)isok = false;
        if(cur >= 1)if((1 << (cur - 1)) & i)isok = false;
        REP(j, w - 1){
            if(((1 << j)&i) && ((1 << (j + 1))&i))isok = false;
        }
        if(isok)ret++;
    }
    return ret;
}

LL calc2(int cur){
    LL ret = 0;
    REP(i, (1 << (w - 1))){
        bool isok = true;
        if(!((1 << (cur - 1)) & i))isok = false;
        REP(j, w - 1){
            if(((1 << j)&i) && ((1 << (j + 1))&i))isok = false;
        }
        if(isok)ret++;
    }
    return ret;
}

LL calc3(int cur){
    LL ret = 0;
    REP(i, (1 << (w - 1))){
        bool isok = true;
        if(!((1 << cur) & i))isok = false;
        REP(j, w - 1){
            if(((1 << j)&i) && ((1 << (j + 1))&i))isok = false;
        }
        if(isok)ret++;
    }
    return ret;
}

int main(){
    INIT;
    cin >> h >> w >> k;
    dp[0][0] = 1;
    for(int i = 1;i <= h;i++){
        for(int j = 0;j < w;j++){
            //動かない場合
            (dp[i][j] += dp[i - 1][j]*calc1(j)) %= mod;
            //j - 1からきた場合
            if(j >= 1){
                (dp[i][j] += dp[i - 1][j - 1]*calc2(j)) %= mod;
            }
            //j + 1から来た場合
            if(j < w - 1){
                (dp[i][j] += dp[i - 1][j + 1]*calc3(j)) %= mod;
            }
        }
    }
    cout << dp[h][k - 1] << endl;
}

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

int main(){
    priority_queue<int> pq;
    string order;
    while(true){
        cin >> order;
        if(order == "insert"){
            int key;
            cin >> key;
            pq.push(key);
        }
        else if(order == "extract"){
            cout<<pq.top()<<endl;
            pq.pop();
        }
        else if(order == "end"){
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 6504