akhauriyash/Code-Regression huggingface dataset:
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)
import copy

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

def neighbors4(x, y):
  dxy = (0, 1, 0, -1, 0 )
  for i in range(4):
    yield(x + dxy[i], y + dxy[i+1])

h,w = get_nums_l()

grid_s = [ input() for _ in range(h) ]
grid = [ [-1] * (w+2) for _ in range(h+2) ]

log(grid_s)

def init_grid():
    for y in range(1,h+1):
        for x in range(1, w+1):
            if grid_s[y-1][x-1] == ".":
                grid[y][x] = 999999999999999999

ans = 0
for y in range(1,h+1):
    for x in range(1, w+1):
        if grid_s[y-1][x-1] == ".":
            init_grid()
            grid[y][x] = 0

            que = deque()
            que.append((x, y, 1))

            max_ = 0
            while que:
                x,y,score = que.popleft()

                for nx,ny in neighbors4(x,y):
                    if grid[ny][nx] != -1 and grid[ny][nx] > score:
                        grid[ny][nx] = score
                        max_ = max(max_, score)
                        que.append((nx, ny, score+1))
            ans = max(ans, max_)

print(ans)

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

public class Main {
	static public int calc(ArrayList<Integer> arr) {
		int ret = 0;
		for(int i = 1; i < arr.size(); i++) {
			ret = ret + arr.get(0) * arr.get(i);
		}
		return ret;
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		ArrayList <Integer> array = new ArrayList<Integer>();
		for(int i = 0; i < N; i++) {
			array.add(sc.nextInt());
		}
		int ans = 0;
		while(true) {
			ans = ans + calc(array);
			array.remove(0);
			if(array.size()==1) {
				break;
			}
		}
		System.out.println(ans);
	}

}



Measured memory_bytes: 22608
#include <stdio.h>
#define MAX 500000
#define SENTINEL 2000000000

int L[MAX/2+2],R[MAX/2+2];
int cnt;

void merge(int A[], int n, int left, int mid, int right){
	int n1 = mid - left;
	int n2 = right - mid;
	int i;
	for(i=0; i<n1; i++)L[i]=A[left+i];
	for(i=0; i<n2; i++)R[i]=A[mid+i];
		L[n1]=R[n2]=SENTINEL;
	int j=0;
	i = 0;
	int k;
	for(k=left; k<right; k++){
		cnt++;
		if(L[i]<=R[j]){
			A[k]=L[i++];
		}else{
			A[k]=R[j++];
		}
	}
}

void mergeSort(int A[], int n, int left, int right){
	if(left+1<right){
		int mid=(left+right)/2;
		mergeSort(A,n,left,mid);
		mergeSort(A,n,mid,right);
		merge(A,n,left,mid,right);
	}
}

int main(){
	int A[MAX],n,i;
	cnt=0;

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

	mergeSort(A,n,0,n);

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

    return 0;
}

Measured memory_bytes: 4508
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }

const ll INF=(1LL<<60);

int main(void){
    int n; cin >> n;
    ll h[100100];
    ll dp[100100];
    for(int i=1; i<=n; i++) cin >> h[i];

    for(int i=0; i<100100; i++) dp[i]=INF;
    dp[1]=0;

    for(int i=1; i<=n; i++){
        chmin(dp[i+1], dp[i]+abs(h[i]-h[i+1]));
        chmin(dp[i+2], dp[i]+abs(h[i]-h[i+2]));
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<stdlib.h>
#include<string>
#include<numeric>
#include<algorithm>
using namespace std;

int main(){
  int n;
  long long int x;
  scanf("%d %lld",&n,&x);
  long long int a[n];
  for (int i = 0; i<n; i++){
    scanf("%lld",&a[i]);
  }sort(a,a+n);
  for (int i = 0; i<n; i++){
    if (x<a[i]){
      printf("%d\n",i);
      return 0;
    }else if(x == a[i]){
      printf("%d\n",i+1);
      return 0;
    }x -= a[i];
  }printf("%d\n",n-1);
  return 0;
}


Measured memory_bytes: 256
N = int(input())
t = list()
l= list()
for i in range(N):
  tmp = input().split(" ")
  t.append(tmp[0])
  l.append(int(tmp[1]))
d = input()
rec = 0
ans = 0
for i in range(N):
  if rec==1:
    ans += l[i]
  if t[i] == d:
    rec=1
print(ans)

Measured memory_bytes: 3064
function main(input) {
  const formatted_input = input.split('\n').map(x => parseInt(x));

  if(formatted_input[4] - formatted_input[0] > formatted_input[5]){
    console.log(':(')
  }else{
    console.log('Yay!')
  }
}

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



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

int decompositPrime(int num) {
  int a   = 2;
  int res = 0;
  int cnt = 0;
  while (num >= a * a) {
    if (num % a == 0) {
      num /= a;
      if ((res != 0 && a != res) || cnt == 2) return 0;
      res = a;
      cnt++;
    } else {
      a++;
    }
  }
  return res;
}

int main() {
  int n;
  cin >> n;
  int res = 0;
  for (int i = n; i >= 1; i--) {
    int j = 1;
    while (j * j <= i) {
      if (j * j == i) {
        res = i;
        break;
      }
      j++;
    }
    if (res != 0) break;
  }
  cout << res << endl;
}

Measured memory_bytes: 256
#include<map>
#include<set>
#include<list>
#include<ctime>
#include<cmath>
#include<deque>
#include<queue>
#include<stack>
#include<string>
#include<vector>
#include<bitset>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<complex>
#include<iostream>
#include<algorithm>
#define rep(i,s,t) for(register int i=s;i<=t;++i)
#define _rep(i,s,t) for(register int i=s;i>=t;--i)
#define Rep(i,s,t) for(register int i=s;i<t;++i)
#define go(x) for(register int e=las[x];e;e=nxt[e])
#define re register
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define insert is
#define erase es
#define pii pair<int,int>
#define ms(f,x) memset(f,x,sizeof f)
#define mc(f,x) memcpy(f,x,sizeof f)
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
#define gi(x) read(x)
#define gii(x,y) read(x),read(y)
#define giii(x,y,z) read(x),read(y),read(z)
namespace IO{
    #define gc getchar()
    #define pc(x) putchar(x)
    template<typename T>inline void read(T &x){
        x=0;int f=1;char ch=gc;while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=gc;}
        while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+ch-'0',ch=gc;x*=f;return;
    }
    template<typename T>inline void write(T x=0){
        T wr[51];wr[0]=0;if(x<0)pc('-'),x=-x;if(!x)pc(48);
        while(x)wr[++wr[0]]=x%10,x/=10;while(wr[0])pc(48+wr[wr[0]--]);return;
    }
}
using IO::read;
using IO::write;
typedef long long ll;
typedef double db;
typedef long double ld;
typedef unsigned long long ull;
using namespace std;
const int N=1e6+11;
int n,k,mn,ans;
int a[N],b[N];
int main(){
	gii(n,k);
	mn=(1<<30);
	rep(i,1,n)
		gi(a[i]),mn=min(mn,a[i]);
	int i=1;
	for(;i<=n;++i){
		int j=i,f=0;
		for(;a[i]==mn&&i<=n;)
			++i;
		if(i>n)break;
		if(a[i-1]==mn)
			--i;
		j=i;
		//printf("%d ",i);
		for(;i<=j+k-1&&i<=n;++i)
			if(a[i]==mn)
				f|=1;
		if(f)i=j+k-1;
		else i=j+k-2;
		++ans;
		//printf("%d\n",i);
		if(i>n)break;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 4352
#include <stdio.h>
#include <string.h>

int main(void)
{
	int i, n, m, t = 0, h = 0;
	char T[101], H[101];
	
	scanf("%d", &n);
	for(i = 0; i < n; i++){
		scanf("%s%s", T, H);
		m = strcmp(T, H);
		if(m > 0){
			t += 3;
		}else if(m < 0){
			h += 3;
		}else{
			t++;
			h++;
		}
	}
	printf("%d %d\n", t, h);
	
	return(0);
}



Measured memory_bytes: 1728
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) > (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

int gcd(int a, int b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

int main(){

    int n, x;
    scanf("%d %d", &n, &x);
    vector<int> v(n);
    
    REP(i,n){
        scanf("%d", &v[i]);
        v[i] -= x;
    }
    

   
    int result = gcd(v[0],v[1]);
    FOR(i,2,n){
        result = gcd(result, v[i]);
    }
    cout << abs(result) << endl;

    return 0;
}

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

using namespace std;
typedef long long ll;

int main(){
  ll N, K;
  cin >> N >> K;
  
  if (N % K == 0){
    cout << 0;
    return 0;
  }
  
  N = (N > K) ? N % K : N;
  ll ret = (K-N > N) ? N : K-N;
  cout << ret;
  
  return 0;
}

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

int main(){
  int count=0;
  string S,T;
  cin >> S >> T;
  for(int i=0;i<S.size();i++){
    if(S.at(i)!=T.at(i)){
      count++;
    }
  }
  cout << count << endl;
}
  

Measured memory_bytes: 3912
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

ll dp[1000005][2];

int main(){
  string N;
  cin >> N;
  reverse(ALLOF(N));
  N += "000";
  
  rep(i,1000005){
    dp[i][0] = dp[i][1] = (ll)1e17;
  }
  
  dp[0][0] = 0;
  rep(i,N.size()){
    int n = N[i]-'0';
    dp[i+1][0] = min(dp[i+1][0], dp[i][0] + n);
    dp[i+1][1] = min(dp[i+1][1], dp[i][0] + (10-n));
    dp[i+1][0] = min(dp[i+1][0], dp[i][1] + (n+1));
    dp[i+1][1] = min(dp[i+1][1], dp[i][1] + (10-(n+1)));
  }

  cout << dp[N.size()][0] << endl;

  return 0;
}



Measured memory_bytes: 17028
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(void)
{
	int i,j,n,m,x;
	int a[5100],b[5100];
	while(1)
	{
		scanf("%d", &n);
		if (n == 0)
			break;
		memset(b, 0, sizeof(b));
		m = 0;
		for (i = 1; i <= n / 2; i++)
		{
			x = (i * i) % n;
			for (j = 0; j < m; j++)
				if(a[j] == x)
					break;
			if(j == m)
				a[m++] = x;
		}
		for (i = 0; i < m; i++)
		{
			for (j = 0; j < m; j++)
			{
				if (i != j)
				{
					x = a[i] - a[j];
					if (x < 0)
						x += n;
					if (x > (n - 1) / 2)
						x = n - x;
					b[x]++;
				}
			}
		}
		for (i = 1; i <= n / 2; i++)
			printf("%d\n", b[i]);
	}
	return 0;
}

Measured memory_bytes: 648
import sys
from math import ceil


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    n = ni()
    A, B = [], []
    for i in range(n):
        a, b = nm()
        if a % b != 0:
            A.append(b - a % b)
        else:
            A.append(0)
        B.append(b)
    for i in range(n - 2, -1, -1):
        if A[i + 1] > A[i]:
            A[i] += B[i] * ceil((A[i + 1] - A[i]) / B[i])
    print(A[0])


if __name__ == '__main__':
    main()


Measured memory_bytes: 21740
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

#################

from bisect import bisect_left

N = I()
A = III()
B = III()
C = III()

A.sort()
B.sort()
C.sort()

memo = [0]*N
for i in range(N):
    x = bisect_left(A,B[i])
    if i==0:
        memo[i] = x
    else:
        memo[i] = memo[i-1]+x

ans = 0
for i in range(N):
    y = bisect_left(B,C[i])
    if y==0:
        continue
    else:
        ans += memo[y-1]

print(ans)

Measured memory_bytes: 92968
import math

def is_integer_num(n):
    if isinstance(n, int):
        return True
    if isinstance(n, float):
        return n.is_integer()
    return False

N=int(input())
answer=1

for i in reversed(range(N+1)):
    if is_integer_num(math.sqrt(i)):
        answer=i
        break

print(answer)
        


Measured memory_bytes: 2940
q = int(input())
is_prime = [1] * (10**5 + 1)
is_prime[0] = 0
is_prime[1] = 0
for i in range(2, 10**5+1):
    if is_prime[i] == 1:
        for j in range(i+i, 10**5+1, i):
            is_prime[j] = 0
ls = [0]
for i in range(1, 10**5+1):
    if is_prime[i] == 1 and is_prime[(i+1)//2] == 1:
        ls.append(ls[i-1]+1)
    else:
        ls.append(ls[i-1])
for i in range(q):
    l, r = map(int, input().split())
    print(ls[r] - ls[l-1])


Measured memory_bytes: 80432
#include<cstdio>
int ans;
int main() {
	long long int x, y;
	scanf("%lld%lld", &x, &y);
	long long int i=x;
	while(i<=y) {
		ans++;
		i*=2;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


using namespace std;
using ll = long long;
using ull = unsigned long long;

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

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


















int main(){
    constexpr const int MAX_N = 300000;
    int n;
    scanf("%d", &n);
    int a[MAX_N], c[MAX_N + 1] = {};
    for(int i = 0; i < n; i++){
        scanf("%d", &a[i]);
        c[a[i]]++;
    }
    int d[MAX_N + 1] = {};
    for(int i = 0; i <= n; i++){
        d[c[i]]++;
    }
    ll r1[MAX_N + 1] = {};
    int r2[MAX_N + 1] = {};
    for(ll i = 1; i <= n; i++){
        r1[i] += r1[i - 1];
        r1[i] += i * d[i];
        r2[i] += r2[i - 1];
        r2[i] += d[i];
    }
    auto f = [&](ll x) -> int {
        return (r1[x] + x * (r2[n] - r2[x])) / x;
    };
    int ans = n;
    for(int i = 0; i < n; i++){
        while(ans > 0 && i + 1 > f(ans)) ans--;
        printf("%d\n", ans);
    }
}


Measured memory_bytes: 7936
#include <math.h>
#include <ctype.h>
#include <limits.h>
#include <string.h>
#include <assert.h>

#include <vector>
#include <numeric>
#include <iostream>
#include <algorithm>

#define nl                std::cout << "\n"
#define in(x)             std::cin  >> (x)
#define out(x)            std::cout << (x) << " "
#define err(x)            std::cerr << "DBG: " << #x << " " << (x) << "\n"

#define inn(x)            int x; in(x);
#define rep(i, n)         for (int i =  0 ; i < (n); ++i)
#define repr(i, l, r)     for (int i = (l); i < (r); ++i)
#define rrep(i, n)        for (int i = (n) - 1; i > -1; --i)

#define no                puts("NO")
#define yes               puts("YES")

using ll  = long long int;
using vi  = std::vector<int>;
using ii  = std::pair<int, int>;
using iii = std::pair<ii, int>;
using vii = std::vector<ii>;

const int N = 1010101;
const int MD = 1e9 + 7;

void solve() {
    int n; in(n);
    int m; in(m);

    int a[m]; rep(i, m) in(a[i]);

    const int M = 1000000007;

    int dp[n + 2]; dp[n] = 1; dp[n + 1] = 0;

    int j = m - 1;
    rrep(i, n)
        if (j > -1 && a[j] == i) --j, dp[i] = 0;
        else dp[i] = (dp[i + 1] + dp[i + 2])%M;
    out(dp[0]);
}

int main() {
    std::ios_base::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0);

    //int t; in(t); repr(tc, 1, t + 1)
    solve();

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h> // imports every library in c++
using namespace std; // ; is essential | says that you are USING the libraries

//  COMMAND TO USE WHEN RUNNING CODE: g++ day6.cpp -o day6 -std=c++11 -O2  | to run: ./(name of file)  //

string S;

int main() {
    cin >> S;
    if ( S == "Sunny" ) {
        cout << "Cloudy";
    } else if ( S == "Cloudy" ) {
        cout << "Rainy";
    } else if ( S == "Rainy" ) {
        cout << "Sunny";
    }
    return 0;
}

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

#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define inter ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)

// policy-based
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;	


using namespace std;
using namespace atcoder;

typedef long long ll; // int or long long
typedef long double ld;
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;

/*
typedef tree<
ll,
null_type,
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
*/
 
const ll MAX = 5e6 + 100;
const ll inf = 1e9;

int main(){
	fastio;	
	ll n,q,t,u,v,m,a,b;
	cin >> q;	
	while(q--){
		cin >> n >> m >> a >> b;
		cout << floor_sum(n,m,a,b) << endl;
	}
}

Measured memory_bytes: 3652
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")

#include<bits/stdc++.h>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;


#define ll          long long
#define pb          push_back
#define pii         pair<int ,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define FF           first
#define SS           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell          1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
// mp::cpp_in
long long f(long long a) {
     long long res[] = {a,1,a+1,0};
     return res[a%4];
}

long long getXor(long long a, long long b) {
     return f(b)^f(a-1);
}


int solve( ){
 

ll a,b;
cin>>a>>b;
if(a==0){cout<<f(b);return 0;}
cout<<getXor(a,b);

return 0;
}
int main()
{  int t=1;
 ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
  
  
  
  clock_t time_req;

    // Without using pow function
    time_req = clock();
    
//cin>>t;
   while(t--)
     {solve();
     }

         time_req = clock() - time_req;
   // cout << "Processor time taken is "
     //  << (double)time_req/CLOCKS_PER_SEC << " seconds" << endl;


    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll A, B;
    cin >> A >> B;
    bool ok[3];
    fill(ok, ok + 3, false);
    ok[A - 1] = true;
    ok[B - 1] = true;
    REP(i, 0, 3) {
        if (!ok[i]) {
            cout << i + 1 << endl;
            break;
        }
    }
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
    int n;
    cin >> n;
    int T;
    cin >> T;
    int a[T];
    for (int i = 0; i < T; i++) cin >> a[i];
    for (long long i = 0; i < (1 << n); i++) {
        bool f = true;
        for (int k = 0; k < T; k++) {
            if (!(i & (1 << a[k]))) f = false;
        }
        if (f) {
            cout << i << ":";
            for (long long j = 0; j < n; j++) {
                if (i & (1 << j)) { cout << " " << j; }
            }
            cout << endl;
        }
    }
}


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

using namespace std;
inline int read()
{
	int ck=0;
	char fu=1;
	char c;
	for(;!isdigit(c);c=getchar())
		if(c=='-')
			fu=-1;
	for(;isdigit(c);c=getchar())
		ck=ck*10+c-'0';
	return fu*ck;
}
int main()
{
	int ans=0;
	int a=read();
	int b=read();
	int c=read();
	int x=read();
	for(int i=0;i<=a;i++)
		for(int j=0;j<=b;j++)
			if((x-(i*500+j*100)>=0)&&(x-(i*500+j*100)<=c*50)) ans++;
	cout<<ans<<endl;
	return 0;
}



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

int main() {

	ll a, b; cin >> a >> b;
	if (b < a) swap(a, b);
	if ((b - a) % 2 != 0) {
		cout << "IMPOSSIBLE" << endl;
		return 0;
	}
	cout << (a + b) / 2 << endl;
	return 0;
}

Measured memory_bytes: 3524
import sys
from math import ceil, floor, sqrt, sin, cos, pi
from itertools import accumulate, permutations, combinations
from fractions import gcd # 最大公約数
from collections import deque, Counter
from operator import itemgetter
from heapq import heappop,heappush
sys.setrecursionlimit(10**7)
def lcm(x, y): return ((x * y) // gcd(x, y)) # 最小公倍数
# list(map(int, input().split()))

N = int(input())
x = 0
ans = [0 for _ in range(N)]
maxv = ceil(sqrt(N)) + 1
for x in range(1, maxv):
    for y in range(1, maxv):
        for z in range(1, maxv):
            f = x*x + y*y + z*z + x*y + y*z + z*x - 1
            if f > N-1: continue
            ans[f] += 1
for i in range(N):
    print(ans[i])

Measured memory_bytes: 10440
#include<iostream>

int main(){
	
	for(int i=0;i<3;i++){
		int a=0;	

		int p,q,r;
		std::cin>>p>>q>>r;
	
		a-=(p*3600+q*60+r);

		std::cin>>p>>q>>r;
		
		a+=(p*3600+q*60+r);
				
		std::cout<<a/3600;
		a%=3600;
		std::cout<<" "<<a/60;
		a%=60;
		std::cout<<" "<<a<<std::endl;
	}
	
	return 0;
}

Measured memory_bytes: 1160
#ika　tako
def prepare(n, MOD):
    f = 1
    for m in range(1, n + 1):
        f = f * m % MOD
        #print(f)
    fn = f#n!を求める
    #print(fn)
 
    #print(f)
    inv = pow(f, MOD - 2, MOD)
    #print(inv)
    invs = [1] * (n + 1)#[1, 1, 1]のイメージ、逆元？格納テーブル
    #print(invs)　　⇒　[1, 1, 1]のイメージ、逆元格納テーブル
    invs[n] = inv
    for m in range(n, 1, -1):#n*(n-1)*(n-2)*...と上から掛けている
        inv = inv * m % MOD#なぜ、下から掛けない？
        invs[m - 1] = inv
 
    return fn, invs
 
def solve(x, y):
    d, m = divmod(x + y, 3)#商と余り
    if m != 0 or x < d or y < d:
    #Xとyの合計は3の倍数、x、yがd移動回数以下はあり得ない（1回1個は進む）
        return 0
    #c = d - x　　これだと範囲外参照でエラー
    c = abs(d - x)
 
    MOD = 10 ** 9 + 7
    f, invs = prepare(d, MOD)
    return f * invs[c] * invs[d - c] % MOD
  #fはn!、invs[c],invs[d - c] はc!,(d-c)!の逆元？
  #nCr=n!/(r!*(n-r)!)
  
x, y = map(int, input().split())
print(solve(x, y))

Measured memory_bytes: 29300
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  int N, M;
  cin >> N >> M;
  vector<ll> H(N);
  set<int> se;
  rep(i, N) {
    cin >> H[i];
    se.insert(i);
  }
  vector<int> A(M), B(M);
  rep(i, M) {
    cin >> A[i] >> B[i];
    --A[i], --B[i];
    if(H[A[i]] <= H[B[i]]) se.erase(A[i]);
    if(H[A[i]] >= H[B[i]]) se.erase(B[i]);
  }
  cout << se.size() << endl;
  return 0;
}


Measured memory_bytes: 9596
#include <iostream>

using namespace std;

int main(){
	int m[2];
	cin >> m[0] >> m[1];
	while(m[0]){
		char c[100];
		int dx[][2] = {{0,1},{1,0},{0,-1},{-1,0}};
		int x[2] = {1,1};
		int a;
		int d = 0;
		bool f = 1;
		while(f){
			cin >> c;
			switch(c[0]){
				case 'B':
				case 'F':
					cin >> a;
					if(c[0] == 'B') a = -a;
					for(int i = 0; i < 2; i++){
						x[i] += dx[d][i]*a;
						if(x[i] < 1) x[i] = 1;
						if(m[i] < x[i]) x[i] = m[i];
					}
					break;
				case 'R':
					d = (d+1)%4;
					break;
				case 'L':
					d = (d+3)%4;
					break;
				case 'S':
					f = 0;
			}
		}
		cout << x[0] << " " << x[1] << endl;
		cin >> m[0] >> m[1];
	}

}

Measured memory_bytes: 0
#include<iostream>
#include<iomanip>
#include<cassert>
#include<math.h>
#include<complex>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll N,M;
multiset<ll> stA,stB;
int main(){
    cin>>N>>M;
    for(ll i=0;i<N;i++){
        ll a;
        cin>>a;
        stA.insert(a);
    }
    for(ll i=0;i<M;i++){
        ll b;
        cin>>b;
        stB.insert(b);
    }
    ll overCntInA=0,overCntInB=0;
    ll ans=1;
    for(ll i=N*M;i>=1;i--){
        if(stA.count(i)==1 && stB.count(i)==1){
            overCntInA++;
            overCntInB++;
        }
        else if(stA.count(i)==1 && stB.count(i)==0){
            ans=ans*overCntInB%MOD;
            overCntInA++;
        }else if(stA.count(i)==0 && stB.count(i)==1){
            ans=ans*overCntInA%MOD;
            overCntInB++;
        }
        else if(stA.count(i)==0 && stB.count(i)==0){
            ans=ans*max(0ll,overCntInA*overCntInB-(N*M-i))%MOD;
        }else if(stA.count(i)>1 || stB.count(i)>1){
            cout<<0;
            return 0;
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
constexpr double pi=3.14159265358979;

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(){
  vector<int>n(4);
  rep(i,4)cin>>n[i];
  sort(begin(n),end(n));
  if(n.front()==1&&n[1]==4&&n[2]==7&&n.back()==9)cout<<"YES\n";
  else cout<<"NO\n";
  return;
}

signed main(){
	std::ios::sync_with_stdio(false);
    std::cin.tie(0);
	solve();
	return 0;
}


Measured memory_bytes: 256
n = int(input())
p = list(map(float,input().split()))
dp = [0]*(n+1)
dp[0] = 1
for i in range(1,n+1):
  for j in range(n,0,-1):
    dp[j] += dp[j-1]*p[i-1]
    dp[j-1] -= dp[j-1]*p[i-1]
ans = 0
for i in range(n//2+1,n+1):
  ans += dp[i]
print(ans)

Measured memory_bytes: 48604
#include <iostream>
#include <algorithm>

#define rep(i,n) for (int i=0; i < (n); ++i)
using ll = long long ;
using namespace std;
const int INF = 1001001001;

int main() {

    int n,x,t ;
    cin >> n >> x >> t ;

    int ans = n/x ;
    if(n%x>0) ans++ ;

    cout << ans*t << endl ;

    return 0 ;
}

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

int  main()
{
	int x,y,z; cin >> x >> y >> z;

	if (x % (y+z) >= z)
		cout << x / (y+z);
	else
		cout << x / (y+z) - 1;
	return (0);
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
 int main(){
     int D;
    cin >> D;
    string ans;
    if(D == 25) ans = "Christmas";
    else if(D == 24) ans = "Christmas Eve";
    else if(D == 23) ans = "Christmas Eve Eve";
    else ans = "Christmas Eve Eve Eve";
    cout << ans << endl;
}


Measured memory_bytes: 256
str = gets.chomp
gets.to_i.times do
	line = gets.chomp.split
	if (start_pos = line[1].to_i) == 0 then
		head = ""
	else
		head = str[0..start_pos - 1]
	end
	if (end_pos = line[2].to_i) == str.length - 1 then
		foot = ""
	else
		foot = str[(end_pos + 1)..(str.length - 1)]
	end
	body = str[start_pos..end_pos]
	if line[0] == "print" then
		puts body
		elsif line[0] == "reverse" then
		str = head + body.reverse + foot
	else
		str = head + line[3] + foot
	end
end

Measured memory_bytes: 8876
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,D,X;
  cin >> A >> B >> C >> D;
 
  X = A+B-(C+D);
  
  if (X==0) cout << "Balanced" << endl;
  else if (X>0) cout << "Left" << endl;
  else cout << "Right" << endl;
  
}

Measured memory_bytes: 256
fn main(){
  loop {
    let n: usize = read();
    if n == 0 { break; }

    let mut fd: Vec<(String, usize, usize)> = Vec::new();

    for _ in 0 .. n {
      let buf: Vec<String> = read_vec();
      fd.push((buf[0].parse().unwrap(), buf[1].parse().unwrap(), buf[2].parse().unwrap()));
    }

    let mut iv: Vec<usize> = (0..n).collect();

    let mut miv: Vec<usize> = vec![0;n];
    let mut mcg: usize = 100000;

    if let Some(cg) = calc_cg(&fd, &iv) {
      if mcg > cg {
        mcg = cg;
        miv = iv.clone();
      }
    }
    
    while next_permutation(&mut iv) {
      if let Some(cg) = calc_cg(&fd, &iv) {
        if mcg > cg {
          mcg = cg;
          miv = iv.clone();
        }
      }
    }

    for i in miv {
      println!("{}", fd[i].0);
    }
  }
}

fn read<T>() -> T
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.trim().parse().unwrap()
}

fn read_vec<T>() -> Vec<T>
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.split_whitespace().map(|e| e.parse().unwrap()).collect()
}

fn next_permutation(v: &mut Vec<usize>) -> bool {
  let ln = v.len();
  let mut u: usize = ln;
  for i in (0 .. ln-1).rev() {
    if v[i] < v[i+1] { u = i; break;}
  }
  if u == ln { false }
  else {
    let mut w: usize = u + 1;
    for i in (u+1 .. ln).rev() {
      if v[i] > v[u] { w = i; break; }
    }
    v.swap(u, w);
    u += 1;
    w = ln - 1;
    while u < w {
      v.swap(u, w);
      u += 1;
      w -= 1;
    }
    true
  }
}

fn calc_cg(fd: &Vec<(String, usize, usize)>, iv: &Vec<usize>) -> Option<usize> {
  let mut cg: Option<usize> = Some(0);
  let mut aw: usize = 0;
  
  for (i, &j) in iv.iter().enumerate().rev() {
    if fd[j].2 >= aw {
      aw += fd[j].1;
      cg = Some (cg.unwrap() + (i + 1) * fd[j].1);
    } else {
      cg = None;
      break;
    }
  }
  
  cg
}



Measured memory_bytes: 5028
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}
string YN(bool v) { return v ? "Yes":"No"; }
void uniq(VI& es) { sort(ALL(es)); es.erase(unique(ALL(es)), es.end()); }

#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N;
	while(cin>>N) {
		VI A(N);
		REP(i, N) {cin>>A[i];A[i]--;}
		ll ans=0;
		REP(i, N) if(A[A[i]]==i) ans++;
		ans/=2;
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>


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



Measured memory_bytes: 2044
#include <stdlib.h>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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;   
}

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




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

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define VSORT(v) sort(v.begin(), v.end());
#define VE vector<int>
#define VEP vector<pair<int,int>>
#define llong long long
#define pb(a) push_back(a)
using namespace std;
const vector<VE> DIR{ {-1,0},{1,0},{0,-1},{0,1} };
const int MOD = 1000000007;
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
template<class T>
int dp2csv(const vector<vector<T>>& dp, const string fname);

int main() {
	int x[2];
	cin >> x[0] >> x[1];
	int ans = 0;
	REP(i, 2) {
		switch (x[i]) {
		case 1:
			ans += 300000;
			break;
		case 2:
			ans += 200000;
			break;
		case 3:
			ans += 100000;
			break;
		default:
			break;
		}
	}
	if (x[0] == 1 && x[1] == 1) {
		ans += 400000;
	}
	cout << ans << endl;
	return 0;
}
template<class T>
int dp2csv(const vector<vector<T>>& dp, const string fname) {
	ofstream ofs(fname);
	if (ofs.fail()) { cerr << "cannot open file. :" + fname << endl; return -1; }
	for (auto dp_row : dp) {
		for (auto dp_cell : dp_row) {
			ofs << dp_cell << ",";
		}
		ofs << endl;
	}
	ofs.close();
	return 0;
}


Measured memory_bytes: 256
import math

def n_divisors(n):
    counter = 0
    for i in range(1, int(math.sqrt(n) + 1e-9) + 1):
        if n % i == 0:
            counter += 1
            if n != i**2:
                counter += 1

    return counter

N = int(input())

counter = 0

for n in range(1, N+1):
    if n_divisors(n) == 8 and n%2 == 1:
        counter += 1

print(counter)


Measured memory_bytes: 3060
import sys
n,yen=map(int,input().split())

for x in range(n+1):
    for y in range(n+1):
        z=int((yen-(x*10000+y*5000))/1000)
        if z>=0 and x+y+z==n:
            print('{} {} {}'.format(x,y,z))
            sys.exit()

print('-1 -1 -1')


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

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;

    while(true){
        c = c-b;
        if(c <= 0){
            cout << "Yes" << endl;
            return 0;
        }

        a = a-d;
        if(a <= 0){
            cout << "No" << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3636
import sys
import numpy as np

stdin = sys.stdin
 
ni = lambda:int(ns())
na = lambda:list(map(int,stdin.readline().split()))
ns = lambda:stdin.readline().rstrip()  # ignore trailing spaces

M = ni()
D = [] ; C = []

for i in range(M):
    d, c = na()
    D.append(d)
    C.append(c)

D = np.array(D) ; C = np.array(C)
#桁数の9倍とそれぞれの数字の総和をx
x = C.sum() * 9 + (C * D).sum()
# 18以下で終了
answer = (x + 8) // 9 - 2
print(answer)

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

using namespace std;

#define REP(i,n)	for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,s,n)	for(int i=(s), i##_len=(n); i<i##_len; ++i)

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

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;

typedef pair<int,int>			P;
typedef vector<int>				V;
typedef vector<V>				VV;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define LINF		((ll)1 << 63 -1)
#define INF 		(1<<29)
#define MINF		-2000000007
#define MAX 		100050

const int MOD = 1e9+7;
// テンプレ終了
//====================================================================//

vector<ll> fac(MAX); //n!(mod M)
vector<ll> ifac(MAX); //k!^{M-2} (mod M)  逆元(割り算)
//a,bの範囲的にこれだけ配列を用意していけば十分

ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % MOD;
        x = x*x % MOD;
        n = n >> 1;
    }
    return ans;
}

ll comb(ll a, ll b){ //aCbをmod計算
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % MOD;
    return tmp * fac[a] % MOD;
}


void init(){
	fac[0] = 1;
    ifac[0] = 1;
    for(ll i = 0; i<MAX; i++){
        fac[i+1] = fac[i]*(i+1) % MOD; // n!(mod M)
        ifac[i+1] = ifac[i]*mpow(i+1, MOD-2) % MOD; // k!^{M-2} (mod M) ←累乗にmpowを採用
    }
}

vector<P> func(int m){
	vector<P> t;
	int cnt=0;
	while(m%2==0){++cnt;m/=2;}
	if(cnt>0)t.push_back(P(2,cnt));
	for(ll i=3; m!=1 ;i+=2){
		if(m%i==0){
			cnt = 0;
			while(m%i==0){
				++cnt;
				m /= i;
			}
			t.push_back(P(i,cnt));
		}
	}
	return t;
}

//
int main(){
	int N,M;cin>>N>>M;

	init();
	auto res = func(M);

	ll ans = 1;
	for(auto itr : res){
		ans = (ll)comb(itr.second+N-1,itr.second)*ans % MOD;
	}

	cout << ans << endl;

	return 0;
}




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

using namespace std;

int main() {
    int N;
    long long int W;
    cin >> N >> W;
    
    vector<long long int> w(N+1, 0), v(N+1, 0);
    long long int V=0;
    for(int i=1; i<=N; i++) {
        cin >> w[i] >> v[i];
        V+=v[i];
    }
    
    vector<vector<long long int> > dp(N+1, vector<long long int>(V+1, 0));
    long long int ans;
    for(int cur_v=1; cur_v<=V; cur_v++) {
        // cout << "cur_v=" << cur_v << endl;
        for(int i=1; i<=N; i++) {
            if(cur_v-v[i]>0) {
                if(dp[i-1][cur_v-v[i]]!=0) {
                    if(dp[i-1][cur_v]!=0) {
                        dp[i][cur_v] = min(dp[i-1][cur_v], dp[i-1][cur_v-v[i]]+w[i]);
                    } else {
                        dp[i][cur_v] = dp[i-1][cur_v-v[i]]+w[i];
                    }
                } else {
                    dp[i][cur_v] = dp[i-1][cur_v];
                }
            } else if(cur_v-v[i]==0) {
                if(dp[i-1][cur_v]==0){
                    dp[i][cur_v] = w[i];
                } else {
                    dp[i][cur_v] = min(dp[i-1][cur_v], w[i]);
                }
            } else {
                dp[i][cur_v] = dp[i-1][cur_v];
            }
            // cout << "i=" << i << ", dp=" << dp[i][cur_v] << endl;
        }
        if(dp[N][cur_v]!=0 && dp[N][cur_v]<=W) {
            ans = cur_v;
        }
    }

    cout << ans << endl;

    return 0;
    
}

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

int main()
{
    int n, l;
    cin >> n >> l;
    vector<string> s(n);
    for (int i = 0; i < n; i++)
        cin >> s[i];
    sort(s.begin(), s.end());
    for (int i = 0; i < n; i++)
        cout << s[i];
    cout << endl;
}

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

using namespace std;
using ll = long long;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

const string YES = "Yes";
const string NO = "No";

void solve(long long N, long long M, std::vector<std::string> A, std::vector<std::string> B){
  bool f = false;
  for(int i=0; i<=N-M; i++){
    for(int j=0; j<=N-M; j++) {
      bool ff = true;
      for(int k=0; k<M; k++) {
	for(int l=0; l<M; l++) {
	  if(B[k][l] != A[k+i][l+j]) 
	    ff = false;
	}
      }
      f = f or ff;
    }
  }
  if(f)
    std::cout << YES << std::endl;
  else
    std::cout << NO << std::endl;
}

int main(){
  long long N;
  scanf("%lld",&N);
  long long M;
  scanf("%lld",&M);
  std::vector<std::string> A(N);
  for(int i = 0 ; i < N ; i++){
    std::cin >> A[i];
  }
  std::vector<std::string> B(M);
  for(int i = 0 ; i < M ; i++){
    std::cin >> B[i];
  }
  solve(N, M, std::move(A), std::move(B));
  return 0;
}


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

int main() {
	char x, y;
	cin >> x >> y;
	int a = x - y;
	if (a < 0)cout << "<" << endl;
	else if (a > 0)cout << ">" << endl;
	else cout << "=" << endl;
}

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

int main()
{
  string s;
  cin >> s;
  string ans;
  ans += s[0];
  ans += to_string(s.size() - 2);
  ans += s.back();
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
/*
 * author: calgagi
 *         Calvin Gagliano 
 */
#include <bits/stdc++.h>

using namespace std;

#define long long long
#define double double double
#define ulong unsigned long long
#define ii pair<int, int>
#define ll pair<long long, long long>
#define ar array
#define f first
#define s second

void solve() {
    int k, x;
    cin >> k >> x;
    cout << (k*500 >= x ? "Yes" : "No") << endl;

    return;
}

int main() {
    ios_base::sync_with_stdio(false);  
    cin.tie(NULL);
    srand(chrono::steady_clock::now().time_since_epoch().count()); 
    
    int t = 1;
    /* cin >> t; */
    while (t--) {
        solve();
    }

    return 0;
}


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

int main(){
    int K;
    cin >> K;
    ll lun = 1;
    queue<ll> q;
    rep(i,9) q.push(i+1);
    rep(i,K){
        lun = q.front();
        q.pop();
        if(lun % 10 != 0) q.push(lun*10 + (lun%10) - 1);
        q.push(10*lun + (lun % 10));
        if(lun % 10 != 9) q.push(10*lun + (lun % 10) + 1);
    }
    cout << lun << endl;
}

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

using namespace std;

typedef long long ll;

int max(int a, int b) { return (a > b) ? a : b; }

const int MAXN = 31;


const int INF = 1e9;

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

    int n;
    int k;
    int a;
    int b;
    cin >> n >> a >> b;
    cout <<  (((a - b) % 2 == 0) ? "Alice" : "Borys");
    return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
//*find_by_order
//order_of_key

const int maxn = 1e6 + 5;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
  cout << fixed << setprecision(12);

  string s; cin>>s;
  int ans = 700;
  for (char c:s) {
    ans += (c=='o')*100;
  }

  out(ans);

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<cstdint>
#include<bits/stdc++.h>
#include<queue>
#include<set>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for(int i = n-1; i >= 0; i--)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define INF bit(60)
#define pb push_back
#define mod 1000000007

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using namespace std;
using uif=uint_fast64_t;
using ll=long long int;

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mod;a=1ll*a*a%mod;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(void){

  double ans=0.0;

  ll n,k;
  cin>>n>>k;
  
  std::cout << std::setprecision(12);

  if(n<k){
    rep1(i,n){

      ll num= (ll) ceil( ( log2( (double)k / i ) ) );
      //cout << num << endl;
      double one=1.0;

      double pl= one / ( (double)pow((double)2.0,(double)num) );

      //cout << pl << endl;

      ans += pl;

    }

    ans /= (double)n;

    cout << ans << endl;
  }
  else{

    ans += ((double)n-(double)k+1.0L);

    rep1(i,k-1){

      ll num= (ll) ceil(( log2( (double)(k) / i ) ) );
      
      double one=1.0;

      double pl= one / ( (double)pow((double)2.0,(double)num) );

      //cout << pl << endl;

      ans += pl;
    }

    ans /= (double)n;

    cout << ans << endl;
  }



  return 0;

}


Measured memory_bytes: 256