akhauriyash/Code-Regression huggingface dataset:
program ccc
implicit none

integer(8) :: n, m, i, j, res
integer(8),allocatable,dimension(:) :: a, b

read*, n, m
allocate(a(n),b(n))

do i=1,n
read*, a(i), b(i)
end do

call heapsortkai(n,a,b)

j=0
res=0
do while(m>0)
j=j+1
m=m-b(j)
res=res+a(j)*b(j)
end do

res=res-abs(m)*a(j)

write(*,'(i0)') res

end program

subroutine heapsortkai(n,array1,array2)
  implicit none
  integer(8),intent(in) :: n
  integer(8),intent(inout) :: array1(1:n), array2(1:n)
 
  integer(8) ::i,k,j,l
  integer(8) :: t1, t2
 
  if(n.le.0)then
     write(6,*)"Error, at heapsort"; stop
  endif
  if(n.eq.1)return

  l=n/2+1
  k=n
  do while(k.ne.1)
     if(l.gt.1)then
        l=l-1
        t1=array1(l)
        t2=array2(l)
     else
        t1=array1(k)
        t2=array2(k)
        array1(k)=array1(1)
        array2(k)=array2(1)
        k=k-1
        if(k.eq.1) then
           array1(1)=t1
           array2(1)=t2
           exit
        endif
     endif
     i=l
     j=l+l
     do while(j.le.k)
        if(j.lt.k)then
           if(array1(j).lt.array1(j+1))j=j+1
        endif
        if (t1.lt.array1(j))then
           array1(i)=array1(j)
           array2(i)=array2(j)
           i=j
           j=j+j
        else
           j=k+1
        endif
     enddo
     array1(i)=t1
     array2(i)=t2
  enddo

  return
end subroutine heapsortkai

Measured memory_bytes: 1792
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"

using namespace std;

char letter[1000];
char ans[1000];
int r;

int main() {
	cin >> letter;
	r = -1;
	for (int i = 0; letter[i] != NULL; i++) {
		if (letter[i] == '0') {
			ans[r + 1] = '0';
			r++;
		}
		else if (letter[i] == '1') {
			ans[r + 1] = '1';
			r++;
		}
		else {
			if (r >= 0) {
				ans[r] = NULL;
				r--;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
    long long int a, b, v, w, distance1 = 0, distance2 = 0, t, i;

    cin >> a >> v >> b >> w >> t;

    distance1 = a;
    distance2 = b;

    for(i = 1; i <= t; i++){
        if(a > b){
            distance1 -= v;
        }
        else{
            distance1 += v;
        }
    }

    for(i = 1; i <= t; i++){
        if(a > b){
            distance2 -= w;
        }
        else{
            distance2 += w;
        }
    }

    // cout << "distance 1 = " << distance1 << " distance 2 = " << distance2 << "\n";

    if((distance1 <= distance2 && a > b) || (distance1 >= distance2 && a < b)){
        cout << "YES\n";
    }
    else{
        cout << "NO\n";
    }
    return 0;
}

Measured memory_bytes: 3636
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Queue;
import java.util.Random;
import java.util.Scanner;
 


public class Main {
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static long mod =1000000007;
	//static 	ArrayList<Integer> cc = new ArrayList<>(100);
	
	
	public static void main(String[] args) {
		//int N=sc.nextInt();for(int i=0;i<N;i++) {}
		//int a[]=new int[N];
		//Ae2+Be2=Ce2
	
		//for(int i=0;i<N;i++) {}
		
		long N=sc.nextLong();
		long ans=(long) Math.pow(10, 13);
		for(long i=1;i*i<=N;i++) {
			if(N%i==0) {
				long A=i;
				long B=N/i;
				ans=Math.min(A+B-2, ans);
				
			}
			
			
		}
		
		p(ans);
		
		
	}
		
		
		
		static long Nb(long t) {
			long r=1;
			for(long i=t;i>0;i--) {
				r*=i;
				r%=mod;
				
			}
			return (int)r;
			
		}
		
	
	
	
	public static long lcm(long a, long b) {
        return a / gcd(a, b) * b;
	}
	
	public static long gcd(long a, long b) {
        return b == 0 ? a: gcd(b, a % b);
	}

	


	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	
}
	


Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

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

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

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(12);
    ll N;
    cin >> N;
    vector<ll> A(N);
    REP(i,N)cin >> A[i];
    if(N == 1){
        cout << A[0] << "\n";
    }else{
        ll num = 0;
        REPS(i,N-1){
            num ^= A[i];
        }
        cout << num << "\n";
        REPS(i,N-1){
            cout << ((num ^ A[0]) ^ A[i]) << "\n";;
        }
    }
}

Measured memory_bytes: 4764
#include <stdio.h>
typedef long long ll;

ll n;
ll s[100005];
ll cnt;

int main()
{
    scanf("%lld", &n);
    for (int i = 0; i < n; i++) {
        ll d;

        scanf("%lld", &d);

        s[d]++;
    }

    for (int i = 1; i < 100005; i++) {
        s[i] = s[i - 1] + s[i];
    }

    for (int k = 1; k <= 100000; k++) {
        if (s[k] - s[0] == s[100000] - s[k]) {
            cnt++;
        }
    }

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


Measured memory_bytes: 896
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	if(a+b==15)cout<<'+'<<endl;
	else if(a*b==15)cout<<'*'<<endl;
	else cout<<'x'<<endl;
	//cout<<<<endl;
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    int cnt = 0;
    ll N; cin >> N;
    while (N > 0) {
        N /= 2; cnt++;
    }

    cout << (1ll << cnt) - 1 << endl;
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



Measured memory_bytes: 256
import java.util.InputMismatchException;
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
	try {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		if (a < b) {
			System.out.println("a < b");
		}
		if (b < a) {
			System.out.println("a > b");
		}
		if (a == b) {
			System.out.println("a == b");
		}
		scan.close();
	} catch (InputMismatchException e) {
		System.out.println("??????????????????????????????");
	}
    }
}

Measured memory_bytes: 17164
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

    int h, w, n;
    cin >> h >> w >> n;
    int x, y;
    cin >> x >> y;
    string s, t;
    cin >> s >> t;

    vector<int> a(4), b(4);
    string d = "LURD";
    rep(i, n){
        rep(k, 4){
            if(d[k] == s[i]){
                a[k]++;
            }
        }

        if(y - max(a[0] - b[2], 0LL) <= 0){
            cout << "NO" << endl;
            return 0;
        }
        if(y + max(a[2] - b[0], 0LL) > w){
            cout << "NO" << endl;
            return 0;
        }
        if(x - max(a[1] - b[3], 0LL) <= 0){
            cout << "NO" << endl;
            return 0;
        }
        if(x + max(a[3] - b[1], 0LL) > h){
            cout << "NO" << endl;
            return 0;
        }

        rep(k, 4){
            if(d[k] == t[i]){
                b[k]++;
            }
        }
        if(y - (b[0] - a[2]) <= 0){
            b[0]--;
        }
        if(y + (b[2] - a[0]) > w){
            b[2]--;
        }
        if(x - (b[1] - a[3]) <= 0){
            b[1]--;
        }
        if(x + (b[3] - a[1]) > h){
            b[3]--;
        }
    }

    cout << "YES" << endl;

    return 0;
}


Measured memory_bytes: 1020
n, k = map(int, input().split())
A = list(map(int, input().split()))

def is_ok(x):
    if x == 0:
        return False
    cnt = 0
    for a in A:
        q, r = divmod(a, x)
        if r == 0:
            cnt += q-1
        else:
            cnt += q
    if cnt <= k:
        return True
    else:
        return False

l = 0
r = 10**18
while l+1 < r:
    c = (l+r)//2
    if is_ok(c):
        r = c
    else:
        l = c
print(r)


Measured memory_bytes: 94056
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<string>
#include<sstream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cctype>
#include<climits>
using namespace std;
#define REP(i, j) for(int i = 0; i < j; i++)
#define FOR(i, j, k) for(int i = j; i < k; i++)
#define P pair<int, int>
const int INF = INT_MAX / 2;
const int N = 500000;

int prime[N];

void makePrime(){
    REP(i, N) prime[i] = true;
    prime[0] = false;
    prime[1] = false;
    for(int i = 2; i < N; i++){
        if(i % 7 != 1 && i % 7 != 6) prime[i] = false;
        if(!prime[i]) continue;
        for(int j = i + i; j < N; j += i) prime[j] = false;
    }
}

int main(){
    makePrime();
    int n;
    while(cin >>n && n != 1){
        cout <<n <<":";
        REP(i, n + 1) if(prime[i] && n % i == 0) cout <<" " <<i;
        cout <<endl;
    }
    return 0;
}

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

using namespace std;

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

    cin>>n;
    vector<int>a(n);
    for(int i=0; i<n; i++)
    {
        cin>>a[i];
        if(i!=0 &&a[i]>a[i-1])
            a[i]--;

    }
    int m=a[0];
    int k=1;
    for(int i=0; i<n-1; i++)
    {
        if(a[i]>a[i+1])
        {
            k=0;
            break;
        }
        if(a[i]>m) m=a[i];
    }
    if(k) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


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

int main()
{
	int n,l;
  	cin>>n>>l;
  	vector<int> flavor(n);
  	flavor[0]=l;
  	int sum=l;
  	for(int i=1 ; i<n ; ++i)
    {
    	flavor[i]=i+l;
    	sum+=flavor[i];
    }
    int ans=abs(sum-(sum-flavor[0]));
    int diff=sum-(sum-flavor[0]);
    for(int i=1 ; i<n ; ++i)
    {
        int curr_diff=sum-(sum-flavor[i]);
        if(ans>abs(curr_diff))
        {
            ans=abs(curr_diff);
            diff=curr_diff;
        }
    }
    cout<<sum-diff<<endl;
	return 0;
}


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

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

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    int res = 0;
    rep(i, n){
        if((i+1)%2 == 1){
            if(a[i]%2 == 1) ++res;
        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3648
def all_divisor(n):
  small = [1]
  large = [n]
  for i in range(2, int(n ** 0.5)+1):
    if n % i == 0:
      small.append(i)
      large.append(n//i)
  large.reverse()
  divisor = small + large
  return divisor


n = int(input())
n_divisor = all_divisor(n)
ans = 0
for i in n_divisor:
  mini_ans = (n - i) // i
  if i >= mini_ans:
    break
  ans += mini_ans 
print(ans)


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

int main() {
  int n, u, v, m;
  cin >> n >> u >> v >> m;
  if (n == 1) {
    u *= 4;
    v *= 4;
  }
  map<int, P> mpu, mpv;
  REP(i, n) REP(j, n) {
    int k;
    cin >> k;
    mpu[k] = {i, j};
  }
  REP(i, n) REP(j, n) {
    int k;
    cin >> k;
    mpv[k] = {i, j};
  }
  int ans = 0;
  vector<int> cu(2 * n + 2, 0), cv(2 * n + 2, 0);
  REP(i, m) {
    int q;
    cin >> q;
    if (mpu.find(q) != end(mpu)) {
      P p = mpu[q];
      cu[p.first]++;
      cu[n + p.second]++;
      if (p.first == p.second) cu[2 * n]++;
      if (p.first == n - 1 - p.second) cu[2 * n + 1]++;
    }
    if (mpv.find(q) != end(mpv)) {
      P p = mpv[q];
      cv[p.first]++;
      cv[n + p.second]++;
      if (p.first == p.second) cv[2 * n]++;
      if (p.first == n - 1 - p.second) cv[2 * n + 1]++;
    }
    int nu = 0, nv = 0;
    REP(j, 2 * n + 2) {
      if (cu[j] == n) nu++;
      if (cv[j] == n) nv++;
    }
    if (nu >= u) ans += 1;
    if (nv >= v) ans += 2;
    if (ans == 0) continue;
    if (ans == 1) {
      cout << "USAGI" << endl;
      return 0;
    }
    if (ans == 2) {
      cout << "NEKO" << endl;
      return 0;
    }
    if (ans == 3) {
      cout << "DRAW" << endl;
      return 0;
    }
  }
  cout << "DRAW" << endl;
  return 0;
}



Measured memory_bytes: 20968
#include<iostream>
#include<queue>
#include<vector>
using namespace std;
int main () {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> game(H, vector<char>(W));
  vector<vector<int>> step(H, vector<int>(W, -1));
  int ans = 0;
  for (int i = 0; i < H; i ++) {
    for (int j = 0; j < W; j ++) {
      cin >> game[i][j];
      if (game[i][j] == '.') ans ++;
    }
  }
  step[0][0] = 0;
  queue<int> qx;
  queue<int> qy;
  qx.push(0);
  qy.push(0);
  while(!qx.empty()) {
    int x[] = {0, 1, 0, -1};
    int y[] = {1, 0, -1, 0};
    int ux = qx.front();
    int uy = qy.front();
    qx.pop();
    qy.pop();
    for (int i = 0; i < 4; i ++) {
      int px = ux + x[i];
      int py = uy + y[i];
      if (px >= H || py >= W || px < 0 || py < 0 || game[px][py] == '#') continue;
      if (step[px][py] == -1) {
        step[px][py] = step[ux][uy] + 1;
        qx.push(px);
        qy.push(py);
      }
    }
  }
  if (step[H - 1][W - 1] == -1) {
    cout << -1 << endl;
    return 0;
  }
  ans -= step[H - 1][W - 1] + 1;
  cout << ans << endl;
}
    
  



Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
using namespace std;
typedef long long ll;
const ll N=1000005;
const ll mod=924844033;
const ll g=5;
ll ksm(ll x,ll y){
    ll res=1;
    while(y){
        if(y&1)
            res=(res*x)%mod;
        x=(x*x)%mod;
        y>>=1;
    }
    return res;
}
ll fact[N+2],inv[N+2];
void Init(){
    fact[0]=inv[1]=1;
    for(ll i=1;i<=N;i++)
        fact[i]=fact[i-1]*i%mod;
    for(ll i=2;i<=N;i++)
        inv[i]=((mod-mod/i)*inv[mod%i])%mod;
    inv[0]=1;
    for(ll i=1;i<=N;i++)
        inv[i]=inv[i-1]*inv[i]%mod;
}
struct node{
    ll u,v,nxt;
}edge[N*2];
ll head[N],mcnt;
void add_edge(ll u,ll v){
    mcnt++;
    edge[mcnt].u=u;
    edge[mcnt].v=v;
    edge[mcnt].nxt=head[u];
    head[u]=mcnt;
}
ll sz[N];
ll cnt[N];
ll n;
void dfs(ll u,ll fa){
    sz[u]=1;
    for(ll i=head[u];i;i=edge[i].nxt){
        ll v=edge[i].v;
        if(v==fa)
            continue;
        dfs(v,u);
        sz[u]+=sz[v];
    }
    cnt[sz[u]]--;
    cnt[n-sz[u]]--;
}
void NTT(ll a[],ll n,ll mode){
	for(ll i=0,j=0;i<n;i++)
	{
		if(i<j) swap(a[i],a[j]);
		ll k=(n>>1);
		while(k&&(k&j)){ j^=k; k>>=1; }
		j^=k;
	}
	for(ll i=1;i<n;i<<=1)
	{
		ll w1=ksm(g,(mod-1)/(i<<1)),w=1;
		if(mode==-1) w1=ksm(w1,mod-2);
		for(ll j=0;j<i;j++,w=1ll*w*w1%mod)
			for(ll l=j,r=l+i;l<n;l+=(i<<1),r=l+i)
			{
				ll temp=1ll*w*a[r]%mod;
				a[r]=(a[l]-temp+mod)%mod;
				a[l]=(a[l]+temp)%mod;
			}
	}
	if(mode==-1)
	{
		ll inv=ksm(n,mod-2);
		for(ll i=0;i<n;i++) a[i]=1ll*a[i]*inv%mod;
	}
}
ll a[N];
ll b[N];
int main()
{
    Init();
    scanf("%lld",&n);
    for(ll i=1;i<n;i++){
        ll u,v;
        scanf("%lld%lld",&u,&v);
        add_edge(u,v);
        add_edge(v,u);
    }
    dfs(1,0);
    ll len=1;
    cnt[n]=n;
    for(;len<=n*2;len<<=1) ;
    for(ll i=0;i<=n;i++){
        a[i]=cnt[i]*fact[i]%mod;
        b[i]=inv[n-i];
    }
    NTT(a,len,1);
    NTT(b,len,1);
    for(ll i=0;i<=len;i++)
        a[i]=a[i]*b[i]%mod;
    NTT(a,len,-1);
    for(ll i=1;i<=n;i++){
        ll ans=a[n+i]*inv[i]%mod;
        ans=(ans%mod+mod)%mod;
        printf("%lld\n",ans);
    }
    return 0;
}


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

vector<pair<long long, long long>> prime_factorize(long long n) {
  vector<pair<long long, long long>> res;
  for (long long p = 2; p*p <= n; p++) {
    if (n % p != 0) continue;
    int num = 0;
    while (n % p == 0) { num++; n /= p; }
    res.push_back(make_pair(p, num));
  }
  if (n != 1) res.push_back(make_pair(n, 1));
  return res;
}

int MAX = 510000;
int MOD = 1000000007;
vector<long long> fac(MAX), finv(MAX), inv(MAX);
void COMinit() {
  fac.at(0) = fac.at(1) = 1;
  finv.at(0) = finv.at(1) = 1;
  inv.at(1) = 1;
  for (int i = 2; i < MAX; i++) {
    fac.at(i) = fac.at(i-1) * i % MOD;
    inv.at(i) = MOD - inv.at(MOD % i) * (MOD / i) % MOD;
    finv.at(i) = finv.at(i-1) * inv.at(i) % MOD;
  }
}

long long COM(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac.at(n) * (finv.at(k) * finv.at(n-k) % MOD) % MOD;
}

int main() {
  int N, M;
  cin >> N >> M;
  vector<pair<long long, long long>> pf = prime_factorize(M);
  long long ans = 1;
  COMinit();
  for (auto p : pf) {
    ans = ans * COM(p.second+N-1, N-1) % MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 12288
import java.util.*;
public class Main {
	static int r;
	static int c;
    public static void main(String[] args) throws java.io.IOException{
        Scanner scan = new Scanner(System.in);

        while(true){
        	 r = scan.nextInt();
        	 c = scan.nextInt();
        	if((r|c)==0)break;
        	boolean [][] os=new boolean[r][c];

        	for(int i=0;i<r;i++)
        		for(int j=0;j<c;j++){
        			if(scan.nextInt()==1)os[i][j]=true;
        			else os[i][j] = false;
        		}
        	int max=0;
        	for(int i=0;i<Math.pow(2,r);i++){
        		boolean [] flip =new boolean[10];
        		for(int j=0;j<r;j++)
        			if((i>>j&1)==1)flip[j]=true;
        		int ans=0;
        		for(int j=0;j<c;j++){
        			int surf=0;
        			for(int k=0;k<r;k++)
        				if(os[k][j] ^ flip[k])surf++;
        				if(surf<r - surf)
        					ans+=r - surf;
        				else ans+=surf;

        		max = Math.max(ans,max);
        		}
        	}
        	System.out.println(max);
        }
    }
}

Measured memory_bytes: 13000
#include "bits/stdc++.h"

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), (c)
const int INF =
sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
	is >> p.first >> p.second;
	return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
	os << p.first << " " << p.second;
	return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}
/*
typedef __int128_t Int;
std::ostream &operator<<(std::ostream &dest, __int128_t value) {
std::ostream::sentry s(dest);
  if (s) {
	__uint128_t tmp = value < 0 ? -value : value;
	char buffer[128];
	char *d = std::(buffer);
	do {
	  --d;
	  *d = "0123456789"[tmp % 10];
	  tmp /= 10;
	} while (tmp != 0);
	if (value < 0) {
	  --d;
	  *d = '-';
	}
	int len = std::(buffer) - d;
	if (dest.rdbuf()->sputn(d, len) != len) {
	  dest.setstate(std::ios_base::badbit);
	}
  }
  return dest;
}

__int128 parse(string &s) {
  __int128 ret = 0;
  for (int i = 0; i < s.length(); i++)
	if ('0' <= s[i] && s[i] <= '9')
	  ret = 10 * ret + s[i] - '0';
  return ret;
}
*/

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
template <class T> bool chmin(T &a, const T &b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	string s; cin >> s;
	string k = "keyence";
	if (s == k) {
		YES(s == k);
		return 0;
	}
	bool f=false;
	rep(i, 0, s.size()+1) {
		rep(j, i, s.size()+1) {
			dump(i,j,s.substr(0, i), s.substr(j));
			string t=s.substr(0, i) + s.substr(j);
			dump(t);
			if (t == k) {
				f = true;
			}
		}
	}
	YES(f);

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int N, L;
  int sum(0);
  int minimum(10000);
  int exv(0);
  cin >> N >> L;
  vector<int> value(N);
  for (auto idx(1); idx <= N; ++idx) {
    if (abs(idx + L - 1) < minimum) {
      minimum = abs(idx + L - 1);
      exv = idx + L - 1;
    }
    value.push_back(idx + L - 1);
  }
  for (auto v : value) {
    if (v == exv) {
      continue;
    }
    sum += v;
  }
  cout << sum << endl;
}


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

struct UnionFind{
    vector<int> parent;
    vector<int> rank;
    UnionFind(int n):rank(n+1,0),parent(n+1){
        rep(i,n+1) parent[i]=i;
    }

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

    void unite(int x, int y){
        x = find(x);
        y = find(y);
        if (x==y) return;
        else if(rank[x]<rank[y]) parent[x]=y;
        else{
            parent[y]=x;
            if (rank[x]==rank[y]){
                rank[x]+=1;
            }
        }
    }
};

/*abc157-d*/
int main(){
    int n,m,k;
    cin >> n >> m >> k;
    UnionFind uf(n);
    vector<int> friends(n+1);
    vector<int> bad(n+1);
    rep(i,n+1){
        friends[i]=0;
        bad[i]=0;
    }
    rep(i,m){
        int a,b;
        cin >> a >> b;
        friends[a]++;
        friends[b]++;
        uf.unite(a,b);
    }
    rep(i,k){
        int c,d;
        cin >> c >> d;
        if (uf.find(c)==uf.find(d)){
            bad[c]++;
            bad[d]++;
        }
    }
    vector<int> group(n+1);
    rep(i,n)group[i]=0;
    rep(i,n){
        int par;
        par = uf.find(i+1);
        group[par]++;
    }
    rep(i,n){
        int par;
        par = uf.find(i+1);
        cout << group[par] - friends[i+1]-bad[i+1]-1;
        cout << " ";
    }
    //cout << "\b";
    cout << endl;
}

Measured memory_bytes: 2816
N,M = map(int,input().split())

C = []
for i in range(N):
    C.append(tuple(map(int,input().split())))

C.sort()

tmp = M
ans = 0
for cost,num in C:
    if tmp - num >= 0:##全部買う
        tmp -= num
        ans += num*cost
    else:
        ans += cost*tmp
        break

print(ans)

Measured memory_bytes: 84152
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 100005

struct Info{
	Info(int arg_value,int arg_loc){
		value = arg_value;
		loc = arg_loc;
	}
	bool operator<(const struct Info &arg) const{

		return value < arg.value;
	}
	int value,loc;
};

int N;
int BIT[NUM];
vector<Info> V;

void add(int loc,int value){

	BIT[loc] += value;

	loc += loc & -loc;

	while(loc <= N){
		BIT[loc] += value;
		loc += loc & -loc;
	}
}

int getSum(int loc){

	int sum = BIT[loc];

	loc -= loc & -loc;

	while(loc > 0){
		sum += BIT[loc];
		loc -= loc & -loc;
	}
	return sum;
}

int calc(int left,int right){
	return getSum(right)-getSum(left-1);
}

int main(){

	scanf("%d",&N);

	for(int i = 0; i <= N; i++)BIT[i] = 0;

	for(int i = 1; i <= N; i++){

		add(i,1); //BITは1オリジン
	}

	int tmp;
	for(int loc = 1; loc <= N; loc++){

		scanf("%d",&tmp);
		V.push_back(Info(tmp,loc));
	}
	sort(V.begin(),V.end());

	ll ans = 0;
	int tmp_value = V[0].value,start = 0,end;

	while(true){

		for(end = start; end < N && tmp_value == V[end].value; end++);

		//先に、今回の数を論理削除しておく
		for(int i = start; i < end; i++){

			add(V[i].loc,-1);
		}
		for(int i = start; i < end; i++){

			ans += min(calc(1,V[i].loc),calc(V[i].loc,N)); //近い方に寄せる
		}

		if(end == N)break;

		start = end;
		tmp_value = V[start].value;
	}

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

	return 0;
}



Measured memory_bytes: 4276
#include<stdio.h>
#include<string.h>
int main(void)
{
	int a,i;
	char S[5];
	a=0;
	scanf("%s",S);
		for(i=0;i<strlen(S);i++){
			if(S[i]=='+') a++;
			else a--;
		}
		printf("%d\n",a);
	return 0;
}


Measured memory_bytes: 1696
from collections import Counter
N=int(input())
B=[tuple(map(int, input().split())) for _ in range(N)]
R=[(x[0]-y[0],x[1]-y[1]) for x in B for y in B if x!=y]
C=Counter(R).most_common(1)
print(N-C[0][1] if C else N)


Measured memory_bytes: 3828
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

constexpr int MOD_TYPE = 2;
constexpr ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
constexpr int INF = (int)1e9;
constexpr ll LINF = (ll)4e18;
constexpr ld PI = acos(-1.0);
constexpr ld EPS = 1e-11;
constexpr int Dx[] = {0, 0, -1, 1, -1, 1, -1, 1, 0};
constexpr int Dy[] = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

#pragma endregion

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);

  int h, w;
  cin >> h >> w;
  string s[51];
  rep(i, h)
  {
    cin >> s[i];
  }
  char ans[51][51];
  rep(i, h) rep(j, w)
  {
    if (s[i][j] == '#')
    {
      ans[i][j] = '#';
      continue;
    }
    int cnt = 0;
    rep(di, 8)
    {
      int ii = i + Dx[di];
      int jj = j + Dy[di];
      if (ii < 0 || ii >= h || jj < 0 || jj >= w)
        continue;
      if (s[ii][jj] == '#')
        cnt++;
    }
    ans[i][j] = cnt + '0';
  }
  rep(i, h)
  {
    rep(j, w)
    {
      cout << ans[i][j];
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 256
K, S = gets.split.map(&:to_i)
 
sum = 0
(0..K).each do |x|
    s = S - x
    break if s < 0
    if s <= K
        sum += s + 1
    elsif s <= 2*K
        sum += 2 * K - s + 1
    end
end
 
puts sum

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long
#define mod 1000000007
#define IINF INT_MAX
#define INF 1LL << 30


int main() {
    int a, b; cin >> a >> b;
    if(a <= 5){
        cout << 0 << endl;
    }else if(6 <= a && a <= 12){
        cout << b / 2 << endl;
    }else{
        cout << b << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define ss(x) scanf("%s",x)
#define mod 1000000007
#define bitcount __builtin_popcountll
#define ll long long
#define pb push_back
#define pi pair<int,int>
#define pii pair<pi,int>
#define mp make_pair
int arr[]={399,799,1199,1599,1999,2399,2799,3199,1000000000};
int a[10];
int main()
{
	int i,j,k;
	int n;
	sd(n);
	for(i=0;i<n;i++)
	{
		sd(j);
		for(k=0;k<=9;k++)
		{
			if(j<=arr[k])
			{
				a[k]++;
				break;
			}
		}
	}
	int ans=0;
	for(i=0;i<=7;i++)
	{
		if(a[i])
			ans++;
	}
	printf("%d %d\n",ans == 0 ? 1 : ans,ans+a[8] );
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
using namespace std;
 
int main(){
    
    int A,B,C,X,Y,x,y,ans,tmp;

    cin >> A>>B>>C>>X>>Y;

    x=X%2;
    y=y%2;

    if((A+B)>C*2){
        //Cがお得
        ans = min(X,Y)*C*2;

        if(X>Y){
            ans+=min((X-Y)*A,(X-Y)*2*C);
        }else if(Y>X){
            ans+=min((Y-X)*B,(Y-X)*2*C);
        }

    }else{

        ans=X*A+B*Y;

    }

    cout << ans <<endl;

    return 0;
}


Measured memory_bytes: 256
using System;

public class Hello
{
    public static void Main()
    {
        var L = new int[4]; var r = new int[4];
        string line;
        for (; (line = Console.ReadLine()) != null;)
        {
            var a = Array.ConvertAll(line.Trim().Split(' '), decimal.Parse);
            L[goEyeTest(a[0])]++;
            r[goEyeTest(a[1])]++;
        }
        for (int i = 0; i < 4; i++)
            Console.WriteLine("{0} {1}", L[i], r[i]);
    }
    public static int goEyeTest(decimal a)
    {
        if (a >= 1.1m) return 0;
        if (a >= 0.6m) return 1;
        if (a >= 0.2m) return 2;
        else return 3;
    }
}

Measured memory_bytes: 9156
#include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long

using namespace std;

typedef pair<ll, ll> pll;

const ll inf = 2e18;
const int maxN = 2e5 + 30;
const int maxX = 1e6 + 30;

ll f(pll &a, ll b) { return a.fi * b + a.se; }

ll  n, c, h[maxN], dp[maxN];
pll line[4 * maxX];

void add_line(pll nw, int v = 1, int l = 0, int r = maxX)
{
    int m = (l + r) / 2;
    bool lef = f(nw, l) < f(line[v], l);
    bool mid = f(nw, m) < f(line[v], m);
    if (mid)
        swap(line[v], nw);
    if (r - l == 1)
        return;
    else if (lef != mid)

        add_line(nw, 2 * v, l, m);
    else
        add_line(nw, 2 * v + 1, m, r);
}

ll get(int x, int v = 1, int l = 0, int r = maxX)
{
    int m = (l + r) / 2;
    if (r - l == 1)
        return f(line[v], x);
    else if (x < m)
        return min(f(line[v], x), get(x, 2 * v, l, m));
    else
        return min(f(line[v], x), get(x, 2 * v + 1, m, r));
}

void add(int a)
{
    pll l = {-2 * h[a], h[a] * h[a] + dp[a]};
    add_line(l);
}

int main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n >> c;
    fill(line, line + 4 * maxX, pll(0, inf));
    for (int i = 0; i < n; i++)
        cin >> h[i];
    dp[n - 1] = 0;
    add(n - 1);
    for (int i = n - 2; i >= 0; i--)
    {
        dp[i] = get(h[i]) + h[i] * h[i] + c;
        add(i);
    }
    cout << dp[0];
}


Measured memory_bytes: 69244
n = gets.split("").map(&:to_i).reverse

n.push(0)
len = n.length
ans = 0
i = 0

while i <= len - 1
    if n[i] <= 4
        ans += n[i]
    elsif n[i] > 5 
        ans += 10 - n[i]
        n[i + 1] += 1
    elsif n[i] == 5
        if n[i + 1] < 5
            ans += n[i]
        else
            ans += n[i]
            ans += 9 - n[i + 1]
            n[i + 2] += 1
            i += 1
        end
    else
        n[i + 1] += 1
    end
    i += 1
end

puts ans


Measured memory_bytes: 74244
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;

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

	cout << S.at(0) << S.at(1) << S.at(2);
}

Measured memory_bytes: 3624
#include<iostream>
#include<cmath>
#include<iomanip>


int main(void) {
	int n;
	std::cin >> n;
	int x[n], y[n];
	for (int i = 0; i < n; i++) std::cin >> x[i];
	for (int i = 0; i < n; i++) std::cin >> y[i];

	auto calc_d_1 = [&]() {
		double res = 0;
		for (int i = 0; i < n; i++) res += abs(x[i] - y[i]);
		return res;
	};
	auto calc_d_2 = [&]() {
		double res = 0;
		for (int i = 0; i < n; i++) res += pow(abs(x[i] - y[i]), 2);
		return pow(res, 0.5);
	};
	auto calc_d_3 = [&]() {
		double res = 0;
		for (int i = 0; i < n; i++) res += pow(abs(x[i] - y[i]), 3);
		return pow(res, (double)1 / 3);
	};
	auto calc_d_inf = [&]() {
		double res = 0;
		for (int i = 0; i < n; i++) if (abs(x[i] - y[i]) > res) res = abs(x[i] - y[i]);
		return res;
	};

	double d_1 = calc_d_1();
	double d_2 = calc_d_2();
	double d_3 = calc_d_3();
	double d_inf = calc_d_inf();

	std::cout << std::fixed << std::setprecision(15) << '\n';
	std::cout << d_1 << '\n';
	std::cout << d_2 << '\n';
	std::cout << d_3 << '\n';
	std::cout << d_inf << '\n';

	return 0;
}



Measured memory_bytes: 3484
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include <cmath>
#include <cstdlib>
#include <cassert>
#include <algorithm>

#include <set>
#include <utility>
using namespace std;

int main(){
    int a, p;
    cin >> a >> p;
    p += a*3;
    cout << p/2;

}
    // for (int i = 0; i < ; i++){
        
        //         if(!(i+offset < n)) break;
        // int c = i + offset;
        // if(n/c == n%c){
        //     res += i;
        //     offset += 
        // }
    // }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int p[100005];
int n,m;
int num[100005], low[100005];
int ct=  1;
int ans = 0;
vector<int> adjlist[100005];
int dfs(int u){
    num[u] = low[u] = ct++;
    for (auto v : adjlist[u]){
        if (p[u] == v) continue;
        if (num[v] == 0){
            p[v] = u;
            dfs(v);
            if (low[v] >= num[u]){
                ans++;
                //printf("%d is arcpoint",u);
            }
            low[u] = min(low[u],low[v]);
        }
        else{
            low[u] = min(low[u],num[v]);
        }
    }
    //printf("%d %d %d\n",low[u],num[u],u);
}
int main(){
    scanf("%d%d",&n,&m);
    for (int i =0;  i<m; i++){
        int a,b;
        scanf("%d%d",&a,&b);
        adjlist[a].push_back(b);
        adjlist[b].push_back(a);
    }
    for (int i = 0; i < n; i++){
        if (adjlist[i].size() % 2 == 1){
            printf("No");
            return 0;
        }
    }
    p[1] = 1;
    dfs(1);
    if (m-n == 2){
        printf("%s\n",ans>=2?"Yes":"No");
    }
    else printf("%s\n",m-n>=2?"Yes":"No");

}


Measured memory_bytes: 10112
#include <stdio.h>
#define MAX_ITEM 100

int n, w;
int dp[101][10001];
int value[MAX_ITEM], weight[MAX_ITEM];

void solve(void);
int Max(int a, int b);

int main(void)
{
    int i, j, max = 0;

    scanf("%d %d",&n, &w);

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

    solve();

    /*    for (i = 0; i <= n; i++) {
          for (j = 0; j <= w; j++) {
          printf("%d ",dp[i][j]);
          }
          puts("");
          }*/

    for (i = 0; i <= w; i++) {
        if (max < dp[n][i]) {
            max = dp[n][i];
        }
    }
    printf("%d\n",max);

    return 0;
}

void solve(void)
{
    int i, j;

    for (i = 0; i < n; i++) {

        if (weight[i] <= w) {
            dp[i+1][weight[i]] = Max(dp[i][weight[i]], value[i]);
        } else {
            continue;
        }
        for (j = 1; j <= w; j++) {
            if (dp[i][j] || dp[i+1][j]) {
                dp[i+1][j] = Max(dp[i][j], dp[i+1][j]);
                if (j + weight[i] <= w) {
                    dp[i+1][j+weight[i]] = Max(dp[i][j+weight[i]], 
                        Max(dp[i+1][j+weight[i]], dp[i+1][j] + value[i]));
                }
            }
        }

    }

}

int Max(int a, int b)
{
    if (a < b) {
        return b;
    } else {
        return a;
    }
}

Measured memory_bytes: 4504
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define N 1010

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

	ll l, r;
	cin >> l >> r;

	ll k1 = l / 2019;
	ll k2 = r / 2019;
	ll ans = 2019;
	if(k1 == k2)
	{
		for(ll i = l; i <= r; ++i)
		{
			for(ll j = i + 1; j <= r; ++j)
				ans = min(ans, i * j % 2019);
		}
	}
	else
		ans = 0;
	cout << ans;
	return 0;
} 





// void phi()
// {
// 	p[1] = 1;
// 	for(int i = 2; i < N; ++i)
// 		p[i] = i;
// 	for(int i = 2; i < N; ++i)
// 	{
// 		if(p[i] == i)
// 		{
// 			p[i] = i - 1;
// 			for(int j = 2 * i; j < N; j += i)
// 				p[j] = p[j] * (i - 1) / i;
// 		}
// 	}
// }

// void dpf()
// {
// 	for(int i = 1; i < N; ++i)
// 	{
// 		for(int j = i; j < N; j += i)
// 		{
// 			dp[j] += (i * p[i]);
// 		}		
// 	}
// 	for(int i = 2; i < N; ++i)
// 	{
// 		dp[i] = ((dp[i] + 1) * i) / 2;
// 	}
// }



Measured memory_bytes: 256
module Int = struct
  type t = int
  let compare = compare
end
module Ints = Set.Make(Int)

let id x = x
let n = Scanf.scanf "%d\n" id
let ar = Array.init n (fun _ -> Scanf.scanf "%d " id)

let rec f i ans s =
  let a = ar.(i-1) in
  if Ints.mem a s then -1
  else if a = 2 then succ ans
  else f a (succ ans) (Ints.add a s)

let () =
  f 1 0 Ints.empty |> Printf.printf "%d\n"

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

int main() {
  string A ;
    cin >> A ;
  int count=0 ;
  for (int i=0 ; i<3 ; i++){
   if (A.at(i)=='1'){
     count++;
   }
  }
  cout << count << endl;  
    
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(x) (x).begin(), (x).end()

int main() {
    int n,q,l=100010;
    cin>>n;
    vector<int>a(n),cnt(l);
    rep(i,n)cin>>a[i];
    cin>>q;
    vector<pair<int,int>>m(q);
    rep(i,q)cin>>m[i].first>>m[i].second;
    long long sum=0;
    rep(i,n){
        sum+=a[i];
        cnt[a[i]]++;
    }
    int b,c;
    rep(i,q){
        b=m[i].first;c=m[i].second;
        sum+=cnt[b]*(c-b);
        cout<<sum<<endl;
        cnt[c]+=cnt[b];cnt[b]=0;
    }
	return 0;
}


Measured memory_bytes: 4824
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int[][][] officialHouses = new int[4][3][10];

        int n = sc.nextInt();
 
        while (n-- > 0) {
            int b = sc.nextInt();
            int f = sc.nextInt();
            int r = sc.nextInt();
            int v = sc.nextInt();

            officialHouses[b-1][f-1][r-1] += v;
        }

        for (int b = 0; b < 4; b++) {
            for (int f = 0; f < 3; f++) {
                for (int r = 0; r < 10; r++) {
                    System.out.print(' ');
                    System.out.print(officialHouses[b][f][r]);
                }
                System.out.println();
            }
            if (b < 4-1)
                System.out.println("####################");
        }
    }
}



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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

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

  CIN(N, L);
  vector< string > S(N);
  REP(i, N)
    cin >> S[i];
  sort(ALL(S));
  string ans = "";
  REP(i, N) {
    ans += S[i];
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
	using namespace std;
	map<int,pair<int,int> > arr;
	int dp[900011];
	map<int,int> mins;
	map<int,int> maxs;
	map<int,int>::iterator it;
	int main(){
		ios_base::sync_with_stdio(false);
		cin.tie(0);	
		int h,w,d;
		cin>>h>>w>>d;
		int hold;
		for(int i=0;i<h;i++){
			for(int ii=0;ii<w;ii++){
				cin>>hold;
				if (mins[hold%d]==0){
					mins[hold%d]=hold;
				}
				else {
					mins[hold%d]=min(mins[hold%d],hold);
				}
				if (maxs[hold%d]==0){
					maxs[hold%d]=hold;
				}
				else{
					maxs[hold%d]=max(maxs[hold%d],hold);
				}
				arr[hold]=make_pair(i+1,ii+1);
			}
		}
		for(it=mins.begin();it!=mins.end();it++){
			hold=it->second;
			dp[hold]=0;
			while(hold<=maxs[it->first]){
				dp[hold+d]=dp[hold]+abs(arr[hold+d].first-arr[hold].first)+abs(arr[hold+d].second-arr[hold].second);
				hold+=d;
			}
			
			// teleport a piece placed on Square (i,j) to Square (x,y) by consuming |x−i|+|y−j| magic points.
		}
		int q;
		cin>>q;
		int l,r;
		while(q--){
			cin>>l>>r;
			int mpcon=dp[r]-dp[l];
			cout<<mpcon<<"\n";
		}
		
		return 0;
	}
	

Measured memory_bytes: 20864
import copy
n = int(input())
t = list(map(int,input().split()))
m = int(input())
tmp = list(t)
for i in range(m):
  p,x = map(int,input().split())
  p = p-1
  tmp[p] = x
  print(sum(tmp))
  tmp[p] = t[p]

Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
int a[200005];//1为左括号，2为右括号
char s[200005];
int main()
{
    int n;
    scanf("%d",&n);
    scanf("%s",s+1);
    int t=0;
    if(s[1]=='W'||s[2*n]=='W')
    {
        printf("0\n");
        return 0;
    }
    for(int i=1;i<=2*n;i++)
    {
        if(s[i]=='B')
        {
            if(t%2==0)
            {
                a[i]=1;
                t++;
            }
            else
            {
                a[i]=0;
                t--;
            }
        }
        else if(s[i]=='W')
        {
            if(t%2==0)
            {
                a[i]=0;
                t--;
            }
            else a[i]=1,t++;
        }
    }
    if(t!=0)
    {
        printf("0\n");
        return 0;
    }
    t=0;
    ll ans=1;
    for(int i=1;i<=2*n;i++)
    {
        if(a[i]==1)
        {
            t++;
        }
        else
        {
            ans=(ans*t)%mod;
            t--;
        }
    }
    if(t!=0)
    {
        printf("0\n");
        return 0;
    }
    for(int i=1;i<=n;i++)
    {
        ans=ans*i%mod;
    }
    printf("%lld\n",ans);
}

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

                     //
         \\         //
          \\       //
    ##DDDDDDDDDDDDDDDDDDDDDD##
    ## DDDDDDDDDDDDDDDDDDDD ##   ________   ___   ___        ___   ________   ___   ___        ___
    ## hh                hh ##   |\   __  \ |\  \ |\  \      |\  \ |\   __  \ |\  \ |\  \      |\  \
    ## hh    //    \\    hh ##   \ \  \|\ /_\ \  \\ \  \     \ \  \\ \  \|\ /_\ \  \\ \  \     \ \  \
    ## hh   //      \\   hh ##    \ \   __  \\ \  \\ \  \     \ \  \\ \   __  \\ \  \\ \  \     \ \  \
    ## hh                hh ##     \ \  \|\  \\ \  \\ \  \____ \ \  \\ \  \|\  \\ \  \\ \  \____ \ \  \
    ## hh      wwww      hh ##      \ \_______\\ \__\\ \_______\\ \__\\ \_______\\ \__\\ \_______\\ \__\
    ## hh                hh ##       \|_______| \|__| \|_______| \|__| \|_______| \|__| \|_______| \|__|
    ## MMMMMMMMMMMMMMMMMMMM ##
    ##MMMMMMMMMMMMMMMMMMMMMM##                             Release 2.6.1. Powered by jinkela-core 2.4.12.
         \/            \/
*/


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define fore(i,a,b) for(int i=a;i<b;i++)
#define maxe(a,b,c) max(a,max(b,c))
#define pb push_back
#define eb emplace_back
#define em emplace
#define print(x) cout<<x<<endl;
typedef long long int ll;
const ll mod=1e9+7;
inline ll add(ll a, ll b){ ll c = a + b; if(c > mod) c -= mod; return c; }
int main()
{
    fastio;
    int h,w;
    cin>>h>>w;
    ll d[h][w];
    fore(i,0,h)
    {
        fore(j,0,w)
        {
            d[i][j]=0;
        }
    }
    char c[h][w];
    fore(i,0,h)
    {
        fore(j,0,w)
        cin>>c[i][j];
    }
    fore(i,0,h)
    {
        if(c[i][0]=='#')
        break;
        d[i][0]=1;
    }
    fore(i,0,w)
    {
        if(c[0][i]=='#')
        break;
        d[0][i]=1;
    }
    fore(i,1,h)
    {
        fore(j,1,w)
        {
            if(c[i][j]=='#')
            continue;
            else
            d[i][j]=(d[i-1][j]+d[i][j-1])%mod;
        }
    }
    cout<<d[h-1][w-1];
  return 0;
}

Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef vector<int> vec1;
typedef vector<string> vec2;
typedef vector<double> vec3;

int main() {

  string s, t;
  cin >> s >> t;

  for(int i = 0; i < s.size()+2; i++) {
    if(s == t) {
      cout << "Yes" << endl;
      return 0;
    } else {
      char c = s.at(s.size()-1);
      s.erase(s.begin() + s.size()-1);
      s.insert(s.begin() + 0, c);
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void) {
	long long a, b, c;

	cin >> a >> b >> c;
	int i;

	for (i = 0; i < 100; i++) {
		if ((a * i) % b == c) {
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256