akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define __ ios_base::sync_with_stdio(0);cin.tie(0);
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(),x.end()
#define forn(i,a,n) for(int i=a; i < n; i++)
typedef long long int lli;
typedef long double Double;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
const int mod = 1e9+7;

int main(){__
	string s;
	int n;
	cin >> n;
	cin >> s;
	int cont =0;
	bool flag = false;
	int rojas =0;
	for(char c : s){
		if(c == 'W'){
			flag = true;
		}
		else{
			if(flag) cont++;
			rojas++;
		}
	}
	
	int res =0;
	for(int i=0; i < rojas; i++){
		if(s[i] == 'W') res++;
	}

	cout << min(cont,res) << endl;
	return 0;
}



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

int main () {
  double W, H, x, y;
  cin >> W >> H >> x >> y;

  if ((2*x) == W && (2*y) == H) {
    cout << fixed << setprecision(9) << W * H / 2.0  << " " << 1 << endl;
  } else {
    cout << fixed << setprecision(9) << W * H / 2.0 << " " << 0 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
inputs = input().split()
# print(inputs)
contA_amount = int(inputs[0]) - int(inputs[1])
contB_amount = int(inputs[2])

if contA_amount >= contB_amount:
    contB_left = 0

else:
    contB_left = contB_amount - contA_amount

print(contB_left)


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#define INF 10000000
#define REP(i, n) for(int i = 0;i < (n);i++)
#define all(n) n.begin(),n.end()

using namespace std;

typedef long long int ll;
typedef pair<int, int> PII;

const int MAX_N = 1005;

int w, h, n;
int X1[MAX_N], X2[MAX_N], Y1[MAX_N], Y2[MAX_N];
bool fld[6*MAX_N][6*MAX_N];

int compress(int *x1, int *x2, int W){
	vector<int> xs;
	
	REP(i, n){
		for(int d = -1;d <= 1;d++){
			int tx1 = x1[i]+d, tx2 = x2[i]+d;
			if(0 <= tx1 && tx1 <= W*2) xs.push_back(tx1);
			if(0 <= tx2 && tx2 <= W*2) xs.push_back(tx2);
		}
	}

	sort(all(xs));
	xs.erase(unique(all(xs)), xs.end());

	REP(i, n){
		x1[i] = find(all(xs), x1[i]) - xs.begin();
		x2[i] = find(all(xs), x2[i]) - xs.begin();
	}
	return xs.size();
}
int dx[4] = {-1, 1, 0, 0};
int dy[4] = {0, 0, -1, 1};

int main(void){
	while(cin >> w >> h && w && h){
		cin >> n;
		REP(i, n){
			cin >> X1[i] >> Y1[i] >> X2[i] >> Y2[i];
			X1[i] = X1[i] * 2;
			X2[i] = X2[i] * 2;
			Y1[i] = Y1[i] * 2;
			Y2[i] = Y2[i] * 2;
		}

		memset(fld, 0, sizeof(fld));

		w = compress(X1, X2, w);
		h = compress(Y1, Y2, h);

		REP(i, n){
			for(int y = Y1[i];y <= Y2[i];y++){
				for(int x = X1[i];x <= X2[i];x++){
					fld[y][x] = true;
				}
			}
		}

		int res = 0;
		REP(y, h) REP(x, w){
			if(fld[y][x]) continue;
			res++;

			queue<PII> que;
			que.push(PII(y, x));
			while(!que.empty()){
				PII p = que.front(); que.pop();
				REP(i, 4){
					int tx = p.second + dx[i], ty = p.first + dy[i];
					if(tx < 0 || w <= tx || ty < 0 || h <= ty || fld[ty][tx]) continue;

					fld[ty][tx] = true;
					que.push(PII(ty, tx));
				}
			}
		}

		cout << res << endl;
	}
}

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

int main(){
  int r,D,x;
  cin>>r>>D>>x;
  vector<int> ans(10);
  int tmp=x;
  rep(i,10){    
    ans[i]=r*tmp-D;    
    cout<<ans[i]<<endl;
    tmp=ans[i];
  }
  return 0;
}


Measured memory_bytes: 256
import queue
import math
import copy
"""
N = int(input())
#S = input()
# (N,M) = (int(i) for i in input().split(" "))
# A = [int(i) for i in input().split()]
A = []
for i in range(N):
	A.append(int(input()))

print(A)

"""
A = ["SUN","MON","TUE","WED","THU","FRI","SAT"]
s = input()
print(7-A.index(s))

Measured memory_bytes: 4336
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <fstream>
#include <queue>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <sstream>

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

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
#define SORT(c) sort((c).begin(),(c).end())
#define vi(m,a) vector<int> m(a)
#define vti(m,a,i) vector<vector<int>> m(a,vector<int>(i))
#define ALL(it,a) for(auto it = a.begin(); it!=a.end(); it++)
#define Fe(it,a) for(auto &it : a)
#define all(a) begin(a),end(a)

using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
#define WARU 1000000007;

int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
void printhoge(set<int> v) {
	ALL(it, v) {
		cout << *it << " ";
	}
	cout << endl;

}

int main() {
	int a, b;
	cin >> a>>b;
	cout << (a - 1) * (b - 1) << endl;

}



Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_variables)]

fn main() {
    let (M, D): (i64, i64) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap()
        )
    };

    let ans = (1..(M + 1))
        .map(|m| (22..(D + 1)).filter(|&d| d % 10 >= 2 && (d % 10) * (d / 10) == m).count())
        .sum::<usize>();

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <valarray>
#include <cstdio>
using namespace std;
typedef valarray<int>V;
int n,m;
V z;
V &Me(const V &_x,const V &_y){
	int i=0,j;
	for(;i<n;i++)for(j=0;j<n;j++)z[i*n+j]=(_x[slice(i*n,n,1)]*_y[slice(j,n,n)]).sum()%m;
	return z;
}
V &Mx(const V &_x){
	int i=0,j;
	for(;i<n;i++)for(j=0;j<n;j++)z[i*n+j]=(_x[slice(i*n,n,1)]*_x[slice(j,n,n)]).sum()%m;
	return z;
}
void O(const V &r,const V &s){
	int i=0;
    for(;i<n-1;i++)printf("%d ",(r[slice(i*n,n,1)]*s).sum()%m);
    printf("%d\n",(r[slice(i*n,n,1)]*s).sum()%m);
}
main(){
	int i,a,b,c,t;
	for(;scanf("%d%d%d%d%d%d",&n,&m,&a,&b,&c,&t),n;){
		V s(n);
		for(i=0;i<n;i++)scanf("%d",&s[i]);
		V x(n*n);
		V e(n*n);
		//e.resize(0);
		//e.resize(n*n);
		z.resize(n*n);

		x[0]=b;
		x[1]=c;
		e[0]=1;
		for(i=1;i<n-1;i++){
			x[i*n+i-1]=a;
			x[i*n+i]=b;
			x[i*n+i+1]=c;
			e[i*n+i]=1;
		}
		x[i*n+i-1]=a;
		x[i*n+i]=b;
		e[i*n+i]=1;
		for(;t;t>>=1){
			if(t&1)e=Me(e,x);
			x=Mx(x);
		}
		O(e,s);
	}
}

Measured memory_bytes: 1080
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;++i)

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

int main(){
    int n;
    cin >> n;
    vector<vector<int>> MAPPING;
    vector<int> temp;
    temp.resize(n,0);
    MAPPING.resize(n,temp);
    
    REP(i,n){
        int index;cin >> index;
        int arr_size;cin >> arr_size;
        int number;
        REP(j,arr_size){
            cin>>number;
            MAPPING[index-1][number-1]=true;
        }
    }
    REP(i,n){
        REP(j,n){
            cout << (MAPPING[i][j] ? 1 : 0);
            if(j+1!=n)cout<<" ";
        }
        cout << endl;
    }        
}


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

using namespace std;


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

int H, W; 
vector<string> maze;

bool check () {
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (maze[i][j] == '.') return false;
        }
    }
    return true;
}


void solve() {
    cin >> H >> W;
    maze.resize(H);
    for (int i = 0; i < H; i++) cin >> maze[i];

    vector<queue<pair<int, int>>> v;

    queue<pair<int, int>> q0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (maze[i][j] == '#') q0.push(make_pair(i, j));
        }
    }

    v.push_back(q0);

    int count = 0;

    while (!check()) {
        queue<pair<int, int>> q;
        while (!v[count].empty()){
            pair<int, int> p = v[count].front();
            //cout << p.first << " " << p.second << endl;
            v[count].pop();
            for (int i = 0; i < 4; i++) {
                int nx = p.first + dx[i], ny = p.second + dy[i];
                if (0 <= nx && nx < H && 0 <= ny && ny < W) {
                    if (maze[nx][ny] == '.') {
                        q.push(make_pair(nx, ny));
                        //cout << nx << " " << ny << endl;
                        maze[nx][ny] = '#';
                    }
                }   
            }
        }
        // for (int i = 0; i < H; i++) {
        //     for (int j = 0; j < W; j++) {
        //         cout << maze[i][j];
        //     }
        //     cout << endl;
        // }
        //cout << endl;
        v.push_back(q);
        count++;
    }

    cout << count << endl;
}


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

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

int main(void) {
  string firstInput;
  string secondInput;

  int firstScore = 0;
  int secondScore = 0;

  int num;
  cin >> num;
  for(int i = 0; i < num; i++) {
    cin >> firstInput;
    cin >> secondInput;
    int cond = firstInput.compare(secondInput);
    if(cond == 0) {
      firstScore += 1;
      secondScore += 1;
    }
    else if(cond > 0) {
      firstScore += 3;
    }
    else {
      secondScore += 3;
    }
  }

  cout << firstScore << " " << secondScore << endl;
  return 0;
}

Measured memory_bytes: 1208
#pragma target("avx")
#pragma optimize("O3")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using PP = std::pair<ll,P>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define REP(i,b,e) for(ll i=b; i<e; i++)
#define ALL(vec) vec.begin(),vec.end()
#define PRINT(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define SCAN(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

const int MOD = 1e9+7;
const ll INF = 1e18;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

int main(){
	int n;
	scanf("%d", &n);
	std::vector<PP> ps(n*2);
	REP(i, 0, 2*n){
		int a, b;
		scanf("%d %d", &a, &b);
		if(i<n) ps[i] = PP(0, P(a, b));
		else ps[i] = PP(1, P(a, b));
	}
	std::sort(ALL(ps), [](PP x, PP y){
		return x.se.fi<y.se.fi;
	});

	int used[2*n] = {}, ans = 0;
	REP(i, 0, 2*n) if(ps[i].fi) {
		int idx = -1, maxse = -1;
		REP(j, 0, i) if(!ps[j].fi) {
			if(!used[j] and ps[j].se.se < ps[i].se.se){
				if(maxse<ps[j].se.se){
					idx = j;
					maxse = ps[j].se.se;
				}
			}
		}
		if(idx>=0){
			used[idx] = 1;
			ans++;
		}
	}
	printf("%d\n", ans);
	return 0;
}



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

#define int long long
#define uint unsigned int
#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 REPR(i,n) FORR(i,n,0)
#define ALL(c) ((c).begin()), ((c).end())

#define PB(a) push_back(a)
#define EMPB(...) emplace_back(__VA_ARGS__)
#define EMP(...) emplace(__VA_ARGS__)
#define MP(a,b) make_pair(a,b)
#define MT(...) make_tuple(__VA_ARGS__)

#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))

#define PW(n) (1LL << (n))

using namespace std;

template <class T> inline bool CHMIN(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template <class T> inline bool CHMAX(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> inline void SORT(T &a) { sort(a.begin(), a.end()); }
template <class T> inline void REV(T &a) { reverse(a.begin(), a.end()); }
template <class T> inline void UNI(T &a) { sort(a.begin(), a.end()); a.erase(unique(a.begin(), a.end()), a.end()); }

template <class S, class T> ostream& operator << (ostream& os, const pair<S, T> v) {
  os << "(" << v.first << ", " << v.second << ")"; return os;
}

const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;

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

int N, Q;
string s;
int cum[100010];

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N >> Q >> s;
  for (int i = 1; i < s.size(); i++) {
    if (s[i-1] == 'A' && s[i] == 'C') cum[i+1]++;
  }
  REP(i, s.size()) cum[i+1] += cum[i];
  REP(i, Q) {
    int l, r;
    cin >> l >> r;
    cout << cum[r] - cum[l] << endl;
  }

  return 0;
}

Measured memory_bytes: 1872
import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
from math import *
from itertools import *
from copy import *

N = int(input())
dp1, dp2 = [0] * 3, [0] * 3
for i in range(1, N+1):
    p = list(map(int, input().split()))
    for j in range(3):
        for k in range(3):
            if j != k:
                dp2[j] = max(dp2[j], dp1[k]+p[j])
    dp1 = deepcopy(dp2)
print(max(dp1))


Measured memory_bytes: 50012
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<iomanip>
using namespace std;

int main(){
    int n;
    cin>>n;
    bool flag=true;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        if(a%2>0)continue;
        else {
            if(a%3>0&&a%5>0)flag=false;
        }
    }
    if(flag)cout<<"APPROVED"<<endl;
    else cout<<"DENIED"<<endl;
    return 0;
}

Measured memory_bytes: 3620
def gcd(c, d):
    if (d == 0): return c
    else: return gcd(d, c % d)

def f(n, c, d):
    return n - (n // c + n // d - n // (c * d // gcd(c, d)))

def main():
    a,b,c,d = map(int, input().split())
    print (f(b, c, d) - f(a - 1, c, d))

if __name__ == "__main__":
    main()


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

int main(){
  int N;
  cin >> N;
  int sum = 0;
  int l, r;
  
  for(int i = 0; i < N; i++){
    cin >> l >> r;
    sum += r - l + 1;
  }
  cout << sum << endl;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
typedef long long int ll;
using namespace std;
int n;
double v[50];

int main(){
  cin >> n;
  for(int i=0;i<n;i++) cin >> v[i];
  sort(v, &v[n]);
  for(int i=1;i<n;i++){
    v[i] = (v[i-1] + v[i]) / 2.0;
  }
  printf("%.8f\n", v[n-1]);
  return 0;
}
  

Measured memory_bytes: 256
import sys
N = int(input())
n_list = list(map(int,input().split()))

a = 1
b = 10**18

if 0 in n_list:
  print(0)
  sys.exit()

for i in range(0,N):
  
  a = n_list[i] * a
  #print(a)
 
  if a > b:
     print(-1)
     sys.exit()

print(a)

Measured memory_bytes: 87732
#include<cmath>
#include<bits/stdc++.h>
#define MAX(a,b) (a>b? a:b)
#define MIN(a,b) (a>b? b:a)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repr(i,n) for(lint i=(lint)(n);i>0;--i)
#define reps(i,a,b) for(lint i=a;i<=(lint)(b);i++)
typedef long long lint;
typedef long double ld;
using namespace std;
const ld PI = acos(-1.0);

int main(){
    lint s;
    cin >> s;
    vector<lint> a(1);
    a[0]=s;
    int cur = 0;
    bool flag = true;
    while(flag){
        a.push_back(a[cur]%2==0?a[cur]/2:3*a[cur]+1);
        rep(i,cur+1) if(a[cur+1]==a[i]) flag=false;
        cur++;
    }
    cout << cur+1 << endl;
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"unicode/utf8"
)

func main() {
	var S string

	var maxN int
	var head int
	flag := false

	//文字列を走査して
	//AGCTがあったらheadに位置を代入して数え始める
	//とまったら

	fmt.Scan(&S)

	if utf8.RuneCountInString(S) == 1 {
		switch S {
		case "A", "T", "C", "G":
			maxN = 1
		}
	} else {

		for pos, r := range S {
			if flag {
				switch r {
				default:
					if pos-head > maxN {
						maxN = pos - head
					}
					flag = false
				case 'A', 'T', 'C', 'G':
				}
			} else {
				switch r {
				case 'A', 'T', 'C', 'G':
					head = pos
					flag = true
				}
			}
		}
		if flag {
			if utf8.RuneCountInString(S)-head > maxN {
				maxN = utf8.RuneCountInString(S) - head
			}
		}
	}

	fmt.Println(maxN)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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;}
typedef long long ll;

int n,k;
string s,t;

int main() {
  cin >> n >> k;
  int a[n];
  rep(i,n) cin >> a[i];
  cout << (n-1+k-2)/(k-1) << endl;
}

Measured memory_bytes: 640
#X = int(input())
#S = str(input())
A, B, C = map(int, input().split())
#C = list(map(int, input().split()))
ans = 0
while A >= B:
  B *= 2
  ans += 1
#print(A, B, C, ans)  
while B >= C:
  C *= 2
  ans += 1
  
K = int(input())
#print(ans)
if ans <= K:
  print("Yes")
else:
  print("No")
  
  
  



Measured memory_bytes: 9164
while 1:
        i  =  raw_input().split()
        a = int(i[0])
        op = i[1]
        b = int(i[2])

        if op == "+":
                x = a+b
        elif op == "-":
                x = a-b
        elif op == "*":
                x = a*b
        elif op == "/":
                x = a/b
        elif op == "?":
                break
        print  x

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

using namespace std;
 
/// ----------------------------- (Debug) ------------------------------
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i));}
sim, class b dor(pair < b, c > d) {ris << "(" << d.first << ", " << d.second << ")";}
sim dor(rge<c> d) {*this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]";}
#else
sim dor(const c&) { ris; }
#endif
};
vector<char*> tokenizer(const char* args) {
	char *token = new char[111]; strcpy(token, args); token = strtok(token, ", ");
	vector<char*> v({token});
	while(token = strtok(NULL,", ")) v.push_back(token);
	return reverse(v.begin(), v.end()), v;
}
void debugg(vector<char*> args) { cerr << "\b\b "; }
template <typename Head, typename... Tail>
void debugg(vector<char*> args, Head H, Tail... T) {
	debug() << " [" << args.back() << ": " << H << "] ";
	args.pop_back(); debugg(args, T...);
}
#define harg(...) #__VA_ARGS__
#ifndef ONLINE_JUDGE
#define dbg(...) { debugg(tokenizer(harg(__VA_ARGS__, \b\t-->Line)), __VA_ARGS__, __LINE__); cerr << endl;}
#else
#define dbg(...) { }
#endif
/// -----------------------------------------------------------------------
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi; 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)    
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define print(x) cout << x << "\n";
#define REP(i,a,b) for(i=a;i<=b;i++)
#define RAP(i,a,b) for(i=a;i>=b;i--)
#define spa <<" "<<
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
ll mod=998244353;
const int MX=0x3f3f3f3f;

int main(){
	IOS;
	int n,i,q;
	cin>>n;
	int a[n];
	map<int,int> mp;
	ll sum=0;
	REP(i,0,n-1) cin>>a[i],mp[a[i]]++,sum+=a[i];
	cin>>q;
	int b[q],c[q];
	REP(i,0,q-1) cin>>b[i]>>c[i];
	ll  temp;
	REP(i,0,q-1){
		dbg(sum);
		temp=mp[b[i]];
		mp[b[i]]=0;
		mp[c[i]]+=temp;
		sum+=temp*(c[i]-b[i]);
		cout<<sum<<"\n";
		dbg(sum,temp);
		dbg(mp);
	}
	return 0;
}

Measured memory_bytes: 9108
s = list(str(input()))
ans = 0
if len(s) == 1:
  print(int(s[0]))
else:
  for i in range(2**(len(s)-1)):
    a = 0
    bin_str = format(i, 'b').zfill(len(s)-1)
    for num,j in enumerate(bin_str):
      if j == "1":
        ans += sum([int(k)*10**(num-a-l) for l,k in enumerate(s[a:num+1])]) 
        a = num+1
      if num == len(bin_str)-1:
        ans += sum([int(k)*10**(num-a+1-l) for l,k in enumerate(s[a:num+2])])
  print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n) / gcd(n, m)*abs(m);//gl=xy
}
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;


void solve(){
  int n,m;
  cin>>n>>m;
  vector<int>x(n);
  map<int,int>mp,mp2;
  map<int,int>s,t;
  vector<int>v(1e5+10);
  rep(i,n)cin>>x[i],mp[x[i]%m]++,v[x[i]]++;
  rep(i,1e5+5){
    mp2[i%m]+=v[i]/2;
  }
  int ans=0;
  for(auto x: mp){
    if((x.first==0)||(2*x.first==m))continue;
    if(s.count(x.first)||t.count(x.first))continue;
    if(mp[x.first]>=mp[(m-x.first)%m]){
      s[x.first]=mp[x.first];
      t[(m-x.first)%m]=mp[(m-x.first)%m];
    }
    else{
      t[x.first]=mp[x.first];
      s[(m-x.first)%m]=mp[(m-x.first)%m];
    }
  }
  for(auto x:s){
    ans+=t[(m-x.first)%m];
    ans+=min((s[x.first]-t[(m-x.first)%m])/2,mp2[x.first]);
  }
  ans+=mp[0]/2;
  if(m%2==0){
    ans+=mp[m/2]/2;
  }
  cout<<ans;
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  solve();
	return 0;
}


Measured memory_bytes: 15104
#include <stdio.h>
int main(void){
        char str[1001],word[1001];;
        char end[] = {"END_OF_TEXT"};
        int i,count = 0;

        scanf("%s",word);
        for(i=0;word[i] != 0;i++)
                word[i] = tolower(word[i]);
        while(1){
                scanf("%s",str);
                if(strcmp(str,end) == 0)
                        break;
                for(i=0;str[i] != 0;i++)
                        str[i] = tolower(str[i]);
                if(strcmp(str,word) == 0)
                        count++;
        }
        printf("%d\n",count);
        return 0;
}


Measured memory_bytes: 2128
def power(n, r, mod):
    if r == 0: return 1
    if r%2 == 0:
        return power(n*n % mod, r//2, mod) % mod
    if r%2 == 1:
        return n * power(n, r-1, mod) % mod

def comb(n,k,mod):
    if n<k:
        return 0
    if n<0 or k<0:
        return 0
    k=min(n-k,k)
    ans=1
    inv=[1]*(k+1)
    if k>=1:
        ans*=(n-k+1)%mod
    for i in range(2,k+1):
        inv[i]=mod-inv[mod%i]*(mod//i)%mod
        ans=ans*(n-k+i)*inv[i]%mod
    return ans

n, a, b = map(int, input().split())
MOD = 10 ** 9 + 7

ans = power(2, n, MOD) - 1 - comb(n, a, MOD) - comb(n, b, MOD)

print(ans % MOD)

Measured memory_bytes: 10932
n = int(input())
a = list(map(int,input().split()))
flag = 1
cnt = 0
while flag:
    flag = 0
    i = -1
    for j in range(n-1, i+1, -1):
        if a[j] < a[j-1]:
            a[j], a[j-1] = a[j-1], a[j]
            cnt += 1
            flag = 1
    i += 1
print(' '.join(map(str, a)))
print(cnt)


Measured memory_bytes: 5600
n = gets.to_i
until n == 0
    ohaziki = 32
    arry = gets.split(" ").map{|k| k.to_i }
    i = 1
    bro = 0
    until ohaziki == 0
        if i % 2 == 1
            if ohaziki <= 5
                ohaziki = 1
                puts ohaziki
            else
                ohaziki -= (ohaziki - 1) % 5
                puts ohaziki
            end
        elsif i % 2 == 0
            if arry[bro] >= ohaziki
               ohaziki = 0
               puts ohaziki
            else
               ohaziki -= arry[bro]
               puts ohaziki
               if bro == n-1
                   bro = 0
               else
                   bro += 1
               end
            end
        end
        i += 1
    end
    n = gets.to_i
end


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

using namespace std;
vector<long long> factors;
#define ll long long

#define pii pair<int,int>
#define pll pair<ll,ll>
#define _ <<'\n'
#define __ << ' '
#define all(x) (x).begin(), (x).end()
#define gcd __gcd
int IT_MAX = 1 << 17;
int MOD = 1000'000'007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x0f3f3f3f3f3f3f3f;
const double PI = acos(-1);
const double ERR = 1e-10;
#define szz(x) (int)(x).size()
#define IOS ios_base::sync_with_stdio(false); cout.tie(0);cin.tie(0);
#define flush fflush(stdout)

ll mod(ll a, ll m)
{ return (a + (abs(a) / m) * m + m) % m; }

//****************************don't use int!!!!!!!****************************//
//***************************code starts here!!!!!****************************//

int main()
{

	ll n;
	cin >> n;
	ll ans = 0;
	ll s = sqrt(n) + 10;
	for (int i = 1; i < s; ++i)
	{
		if ((n - i) % i == 0 && (n - i) / i > i)
		{
			ans += (n - i) / i;
		}
	}
	cout << ans;

	return 0;
}

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

int main(){
  int64_t X;
  cin >> X;
  int64_t sum = 100;
  int n;
  for(int i=1; i<10000; i++){
    sum = sum + sum/100;
    n++;
    if(sum >= X){
      break;
    }
  }
  cout << n << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cmath>
using namespace std;
 
int main() {
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int b[n];
	for(int i=0;i<n;i++){
		if(i==0)
			b[i]=0;
 
		else if(i==1)
			b[i]=abs(a[i]-a[0]);
 
		else {
 
			b[i]=min((b[i-1]+abs(a[i-1]-a[i])),(b[i-2]+abs(a[i-2]-a[i])));
		}
		//cout<<b[i]<<"  ";
	}
	cout<<b[n-1];
	return 0;
}

Measured memory_bytes: 1024
f::Integer->[(Integer,Integer)]
f 0=[(1,0)]
f n=let es=f (n-1)
        (p,b)=head es
    in (p*2+1,b*2+2):es

f2::Integer->[(Integer,Integer)]->Integer
f2 x _
    |x<=0=0
f2 _ ((1,0):[])=1
f2 x ((p,b):(p2,b2):xs)
      |x>=p+b=p
      |x>p2+b2+2=(p2+1) + (f2 (x-2-b2-p2) ((p2,b2):xs))
      |x==p2+b2+2=p2+1
      |otherwise=f2 (x-1) ((p2,b2):xs)

main = do
       e<-getLine
       let (n:k:[])=map read (words e)::[Integer]
           xs=f n
       putStrLn $ show $ f2 k xs

Measured memory_bytes: 508
import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int x=Integer.parseInt(sc.next());
double temp=0;
for(int i=1;i<32;i++){
for(int j=2;j<10;j++){
    if(Math.pow(i,j)<=x){
        
temp=Math.max(temp,Math.pow(i,j));
        }
        }
}
int ans=(int)temp;
System.out.println(ans);
}
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define ms(a,b) memset(a,b,sizeof(a))
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
const int maxn=1e6+10;
const int mod=1e9+7;
const int maxm=1e3+10;
using namespace std;
struct wzy
{
    int day,money;
}p[maxn];
bool cmp(wzy u,wzy v)
{
    return u.day<v.day;
}
int main(int argc, char const *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m;
    cin>>n>>m;
    for(int i=0;i<n;i++)
        cin>>p[i].day>>p[i].money;
    sort(p,p+n,cmp);
    priority_queue<int>que;
    int ans=0;
    int pos=0;
    for(int i=1;i<=m;i++)
    {
        while(p[pos].day<=i&&pos<n)
            que.push(p[pos++].money);
        if(!que.empty())
            ans+=que.top(),que.pop();
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1660
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

const string color = "RYGB";

int main()
{
    int h, w, d;
    cin >> h >> w >> d;

    vector<string> s(h, string(w, ' '));
    for(int y=0; y<h; ++y){
        for(int x=0; x<w; ++x){
            int y2 = y + x;
            int x2 = y + (w - x);
            int i = y2 / d % 2;
            int j = x2 / d % 2;
            s[y][x] = color[i*2+j];
        }
    }
    for(int i=0; i<h; ++i)
        cout << s[i] << endl;

    return 0;
}


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

int main(void){
    long long int a,b,c,day=0,cur=0;
    cin >> a>>b>>c;
    while(cur<c){
        day++;
        cur+=a;
        if(day%7==0&&day!=0) cur+=b;
    }
    cout << day << endl;
}



Measured memory_bytes: 3120
#H = int(input())
H,N = list(map(int,input().split()))
#H = sorted(list(map(int,input().split())))
AB = sorted([list(map(int,input().split())) for i in range(N)])
dp = [float('inf') for i in range(H)]
dp[0] = 0
for j in range(H):
    for i in range(N):
        if j-AB[i][0] >= 0:
            dp[j] = min(dp[j],dp[j-AB[i][0]]+AB[i][1])
ans = float('inf')
for i in range(N):
    for j in range(max(0,H-AB[i][0]),H):
        if dp[j] != float('inf') and j+AB[i][0] >= H:
            ans = min(ans,dp[j]+AB[i][1])
print(ans)

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

int main(){
    string S; cin >> S;
    int flag = 0;
    if(S.at(0)=='A'){
        flag = 1;
    }else{
        flag = 0;
    }

    int flag2 = 0;
    int cnt = 0;
    int x = 0;
    for(int i=2;i<(int)S.size()-1;i++){
        if(S.at(i)=='C'){
            cnt++;
            x = i;
        }
    }
    if(cnt == 1){
        flag2 = 1;
    }else{
        flag2 = 0;
    }

    bool flag3 = 0;
    for(int i=0;i<S.size();i++){
        if((i != 0 && S.at(i) >= 'a' && S.at(i) <= 'z') || (i != x && S.at(i) >= 'a' && S.at(i) <= 'z')){
            flag3 = 1;
        }else if((i == 0 && S.at(i) == 'A') || (i == x && S.at(i) == 'C')){
            flag3 = 1;
        }else{
            flag3 = 0;
            break;
        }
    }

    if(flag + flag2 + flag3 == 3){
        cout << "AC" << endl;
    }else{
        cout << "WA" << endl;
    }
}


Measured memory_bytes: 256
n=int(input())
s=[list(input()) for _ in range(n)]
for i in range(n):
    s[i].sort()
s.sort()
c=0
x=1
for i in range(1,n):
    if s[i]==s[i-1]:
        x+=1
    else:
        c+=(x*(x-1)//2)
        x=1
c+=(x*(x-1)//2)
print(c)


Measured memory_bytes: 100184
/**
 *    Author:   Jay Sabale
 *	       
**/

#include<bits/stdc++.h>

using namespace std;
 
// Competetive Template:
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;
typedef vector <lli> vl;
typedef vector <string> vs;
typedef vector < pair <long, long> > vll;

// Debugging :
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define ba  back
#define si size()
#define be begin()
#define en end()
#define le length()
#define mp make_pair 
#define mt make_tuple
#define fi first
#define se second
#define gcd __gcd
#define maxe *max_element
#define mine *min_element
#define deb debug
 
#define forz(i,n) for(lli i=0; i<n; i++)
#define rep(i,k,n) for (lli i = k; i < n; i++)
#define deci(n)  fixed<<setprecision(n)
#define high(n) __builtin_popcount(n)
#define parity(n) __builtin_parity(n)
#define ctz(n)  __builtin_ctz(n)
#define mod 1000000007
#define mod2 998244353
#define kira ios::sync_with_stdio(0), cin.tie(0),cout.tie(0)

// Printing Data :
#define pvec(v) forz(i,v.si) cout<<v[i]<<" "; cout<<endl;
#define parr(arr, n) forz(i,n) cout<<arr[i]<<" "; cout<<endl;
#define p1(i) cout<<i<<endl;
#define p2(i, j) cout<<i<<" "<<j<<endl;
#define p3(i, j, k) cout<<i<<" "<<j<<" "<<k<<endl;
#define p4(i, j, k, l) cout<<i<<" "<<j<<" "<<k<<" "<<l<<endl;

typedef pair <lli,lli> pll;
 
// CODE BEGINS :

int main()
{
    kira;

    lli n, m; cin>>m>>n;

    lli sum=0;
    forz(i, n)
    {
        lli t; cin>>t;
        sum+=t;
    }

    if(m>=sum) cout<<m-sum<<endl;
    else cout<<-1<<endl;

    return 0;
}




















































Measured memory_bytes: 3660
import std;

void main() {
    int s, w; scan(s, w);
    writeln(s <= w ? "unsafe" : "safe");
}

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;


Measured memory_bytes: 3608
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

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

        int K = sc.nextInt();

        System.out.println(solve(K));

        sc.close();
    }

    static String solve(int K) {
        List<Long> candidates = new ArrayList<>();
        for (int prefix = 0; prefix <= 999; ++prefix) {
            long candidate = prefix;
            for (int suffixLength = 0; suffixLength <= 15; ++suffixLength) {
                candidates.add(candidate);
                candidate = candidate * 10 + 9;
            }
        }
        candidates = candidates.stream().distinct().sorted().collect(Collectors.toList());

        List<Long> solutions = new ArrayList<>();
        double minFactor = Double.MAX_VALUE;
        for (int i = candidates.size() - 1; i >= 0; --i) {
            double factor = computeFactor(candidates.get(i));
            if (factor <= minFactor) {
                solutions.add(candidates.get(i));
                minFactor = factor;
            }
        }
        Collections.reverse(solutions);

        return solutions.stream().limit(K).map(String::valueOf).collect(Collectors.joining("\n"));
    }

    static double computeFactor(long x) {
        return (double) x / String.valueOf(x).chars().map(ch -> ch - '0').sum();
    }
}

Measured memory_bytes: 32984
N = int(input())
a = [int(x) for x in input().split()]

a.sort(reverse=True)                # カードを降順ソートして
alice = sum([i for i in a[0::2]])   # aliceは偶数番目を
bob = sum([i for i in a[1::2]])     # bobは奇数番目の総和を取得
print(alice - bob)

Measured memory_bytes: 3064
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <iomanip>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;++i)
#define repi(i,n) for(ll i=n-1;i>=0;--i)
#define sll(n) scanf("%lld", &n);
#define slf(n) scanf("%lf", &n);
typedef long long ll;
typedef double lf;
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
typedef long long ll;
const int max_n = 200010;
// const int mod = 1000000007;
const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
// vector<string> Qs(max_n);
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    // assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

combination comb(max_n);


void Main(){
    // bool is_ok = true;
    // printf("------------- V=%lld---------\n", V);
    ll N, M , K;
    string s;
    cin >> N >> M >> K;
    mint total = 0;
    rep(i,K+1){
        mint this_ = M;
        this_ = this_ * (this_-1).pow(N-i-1);
        this_ *= comb(N-1, i);
        total += this_;
        // cout << "i="<<i<<" " << total << endl;
    }

    cout << total << endl;
    // M * (M-1)^(N-k-1) * nCk

}

int main(){
    Main();

    return 0;

}

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

#define sswap(x, y) { x+=y; y=x-y; x-=y; }
#define LSOne(S) ((S) & (-S))

#define EPS 1e-6
#define MOD 1000000007

#define fi first
#define se second
#define pb push_back
#define ende '\n'

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define mset(x, y) memset(&x, (y), sizeof(x))

using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
	int n;
	cin >> n;
	set<string> s;
	string e;
	int k = 0;
	while (cin >> e)
		if (!s.count(e)) {
			k++;
			s.insert(e);
		}

	cout << k << ende;
  return 0;
}


Measured memory_bytes: 19132
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
const ll mo=1000000007;
ll ans=1;
ll dp[0][0];


const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

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


bool prime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
int main()
{
ll n,m;
if(m==1){cout << '1' << endl;return 0;}
cin >> n>>m;
int tempsoin=m;
vector<int> soin;
for(ll j = 2; j <= tempsoin; j++){
    if(tempsoin%j==0){
        tempsoin=tempsoin/j;
        soin.push_back(j);
        j--;
    }
if(prime(tempsoin)){
    soin.push_back(tempsoin);
    break;
    }
}
soin.push_back(0);
ll coun[100000]={};
ll syu=0;
rep(i,soin.size()-1){
    coun[syu]++;
    if(soin[i]!=soin[i+1])syu++;
}
vector<ll> kaij;
kaij.push_back(1);
for(ll i = 1; i < 100100; i++){
    kaij.push_back((kaij[i-1]*i)%1000000007);
}
COMinit();

rep(i,syu){
    ans=ans*COM(coun[i]+n-1,coun[i])%mo;
}

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





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

int main(int argc, char const *argv[])
{
	int n; cin >> n;
	vector<int> l(n); rep(i, n) cin >> l[i];
	sort(l.begin(), l.end());
	int sum = accumulate(l.begin(), l.end() - 1, 0);
	int ma = l.back();
	if (sum > ma) printf("Yes\n");
	else printf("No\n");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LL long long
int n;
int a, b;
int data[100010];
int vis[100010];
struct node {int id, a, b;} seg[100010], tag[100010];
//int vis[100010];
bool cmp1(node x, node y)
{
	return x.a + x.b > y.a + y.b;
}
bool cmp2(node x, node y)
{
	return (x.b - y.a) == (y.b - x.a) ? x.b > y.b : (x.b - y.a) < (y.b - x.a);
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	cin >> n;
	for (int i = 1; i <= n; ++i)
	{
		cin >> a >> b;
		seg[i] = tag[i] = (node){i, a, b};
	}
	sort(seg + 1, seg + n + 1, cmp1);
	sort(tag + 1, tag + n + 1, cmp2);
	int l1 = 1, l2 = 1;
	long long sum1 = 0, sum2 = 0;
	for (int i = 1;  i <= n; ++i)
	{
		if (i & 1)
		{
			sum1 += seg[i].a;
		}
		else
		{
			sum2 += seg[i].b;
		}
	}
	cout << sum1 - sum2;
	return 0;
}


Measured memory_bytes: 2560
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K = MAP()
h = [INT() for _ in range(N)]
h.sort()

a = h[K-1] - h[0]
for i in range(1, N-K+1):
	a = min(a, h[i+K-1] - h[i])

print(a)

Measured memory_bytes: 9648
N = int(input())
s = []
for i in range(N):
    s.append(input())
M = int(input())
t = []
for i in range(M):
    t.append(input())
s_set = list(set(s))
max_s = 0
for i in range(len(s_set)):
    sum_s = 0
    for j in range(N):
        if s_set[i] == s[j]:
            sum_s += 1
    for j in range(M):
        if s_set[i] == t[j]:
            sum_s -= 1
    max_s = max(max_s, sum_s)

print(max_s)

Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>

template <typename C>
void print_container(const C &c, const std::string &name)
{
  std::cout << name << ": ";
  std::for_each(c.cbegin(), c.cend(),
                [](auto &x) { std::cout << x << ", "; });
  std::cout << std::endl;
}

template <typename Map>
void print_map(const Map &c, const std::string &name)
{
  std::cout << name << ": ";
  std::for_each(c.begin(), c.end(),
                [](auto &x) { std::cout << x.first << "->" << x.second << ", "; });
  std::cout << std::endl;
}

int main()
{
  uint64_t N, M;
  std::cin >> N >> M;
  std::vector<uint64_t> A(N);
  std::vector<uint64_t> integrate(N);
  std::map<int, int> mod_num;

  std::cin >> A[0];
  integrate[0] = A[0] % M;
  mod_num[integrate[0]]++;

  for(uint64_t i=1; i<N; i++) {
    std::cin >> A[i];
    integrate[i] = (integrate[i-1] + A[i]) % M;
    mod_num[integrate[i]]++;
  }
  // print_container(integrate, "integrate");
  // print_map(mod_num, "mod_num");

  uint64_t minus = 0;
  uint64_t ret = mod_num[0];
  for(uint64_t l=1; l<N; l++) {
    minus = (minus + A[l-1]) % M;
    mod_num[minus]--;

    // std::cout << "l: " << l << "minus: " << minus << std::endl;
    // print_map(mod_num, "mod_num");

    ret += mod_num[minus];
  }

  std::cout << ret << std::endl;

  return 0;
}


Measured memory_bytes: 7568
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        for(int i =0;i < s.length() ;i++){
            if(i % 2 != 0){
                if(!s.substring(i,i+1).equals("L") && !s.substring(i,i+1).equals("U") && !s.substring(i,i+1).equals("D")){
                    System.out.println("No");
                    return;
                }
            }else{
                if(!s.substring(i,i+1).equals("R") && !s.substring(i,i+1).equals("U") && !s.substring(i,i+1).equals("D")){
                    System.out.println("No");
                    return;
                }
            }
        }
        System.out.println("Yes");
        return;
    }
}

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

class Main{
    public static void main(String[] a) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		// ????§???¢??????????????°
		int x;
		int y;
		int z;

		// ????????\??????????????????????????§2????????????????????????
		String line = br.readLine();
		line = br.readLine();
		while (line != null) {
			String strArray[] = line.split(" ");
			x = Integer.valueOf(strArray[0]);
			y = Integer.valueOf(strArray[1]);
			z = Integer.valueOf(strArray[2]);

			// ?????????????????????????????´????????°????????´?§?????§???¢?????????
			String Anser = "NO";
			if (x * x == (y * y + z * z)
					|| (y * y == (x * x + z * z))
					|| (z * z == (y * y + x * x))) {
				Anser = "YES";
			}
			System.out.println(Anser);
			line = br.readLine();
		}

    }
}

Measured memory_bytes: 25772
import functools as ft
import heapq
import itertools as it
import logging
import unittest
from collections import (
    OrderedDict,
    defaultdict,
    namedtuple,
    Counter,
)

import numpy as np

_ = [ft, it, np, heapq, namedtuple, Counter, defaultdict, OrderedDict]

debug = logging.getLogger(__name__).debug


def input_ints():
    return list(map(int, input().strip().split()))


def _main():
    n, a, b = input_ints()
    train_rate = a
    taxi_rate = b / n
    if train_rate < taxi_rate:
        print(a * n)
    else:
        print(b)


class Test(unittest.TestCase):
    def setUp(self):
        import run
        self._test = run

    def test_main(self):
        self._test.test_files(self, _main)


if __name__ == '__main__':
    _main()


Measured memory_bytes: 21344
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
  int n,i,a[100010]={},sum=0;
  cin >> n;
  for (i=1;i<=n;i++) cin >> a[i];
  for (i=0;i<=n;i++) sum+=abs(a[i]-a[i+1]);
  for (i=1;i<=n;i++) cout << sum-(abs(a[i-1]-a[i])+abs(a[i]-a[i+1]))+abs(a[i-1]-a[i+1]) << endl;
  return 0;
}

Measured memory_bytes: 1664
#include<cstdio>
#include<iostream>
#include<string>
using namespace std;

int main(){
  int a, b;
  int r;
  cin >> a >> b;
  long fa = a;
  long fb = b;

  if(a < b){
    r = a;
    a = b;
    b = r;
  }
  do{
    r = a%b;
    a = b;
    b = r;

  }while(r>0);
  
  long lcm = fa*fb/(long)a;
  cout << lcm << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

        while(true) {
            int n = scanner.nextInt();
            if (n == 0) break;

            int s[] = new int[n];
            for (int i = 0; i < n; i++) {
                s[i] = scanner.nextInt();
            }
            double sum = 0;
            for (int i = 0; i < n; i++) {
                sum += s[i];
            }
            double mean = sum / n;
            double var = 0;
            for (int i = 0; i < n; i++) {
                var += Math.pow((s[i] - mean), 2);
            }
            var = var / n;
            double stddev = Math.sqrt(var);
            System.out.printf("%.8f\n", stddev);
        }
        scanner.close();
    }
}



Measured memory_bytes: 31552