akhauriyash/Code-Regression huggingface dataset:
# coding: utf-8

import sys
import math
from collections import Counter
import itertools
import fractions
from decimal import *
#import numpy as np
#from functools import reduce

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")

# ###########################################
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


N=II()
if N == 1:
    print(0)
    exit()

ans = factorization(N)

cnt = 0

for an in ans:
    p = an[0]
    e = an[1]
    num = 1
    while e >= num:
        e -= num
        cnt += 1
        num += 1
        


print(cnt)


Measured memory_bytes: 10732
S = input()
N = int(input())

for i in range(N):
    run_list = list(input().split())
    if run_list[0] == "print":
        a = int(run_list[1])
        b = int(run_list[2])
        print(S[a:b+1])
    elif run_list[0] == "reverse":
        a = int(run_list[1])
        b = int(run_list[2])
        S = S[:a] + S[a:b+1][::-1] + S[b+1:]

    else:
        a = int(run_list[1])
        b = int(run_list[2])
        p = run_list[3]
        S = S[:a] + p + S[b+1:]



Measured memory_bytes: 5612
/*------------------------- Bism Allah Alruhmin Alrahim -------------------------------*/
#include <bits/stdc++.h>
#define forn(i, n) for (int i = 0; i < n; i++)
#define ford(i, n) for (int i = n - 1; i > -1; i--)
#define forl(i, l, r) for (int i = l; i <= r; i++)
#define vc vector
#define f first
#define s second
#define pb(i) push_back(i)
#define mx(ar, n) (*max_element(ar, ar + n))
#define mn(ar, n) (*min_element(ar, ar + n))

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;


int main()
{

    int s; 
    cin >> s ; 
    vc<int>v; 
    v.push_back(s);
    for (int i = 1; i <= 100000; i++)
    {
        if(v[i-1]%2 == 0){
            v.push_back(v[i-1]/2);
        }
        else{
            v.push_back(3*v[i-1]+1);

        }
    }
    for (int i = 0; i < 100000-1; i++)
    {
        for (int j = i+1; j < 100000; j++)
        {
            if(v[i] == v[j]){
                cout << j+1 << endl ;
                i = 100000-1;
                break ;
            }
        }
        
    }
    
    

    return 0 ;
}



Measured memory_bytes: 892
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;cin>>N;
  set<string> S;
  bool isok=true;
  char prev='0';
  repeat(i,N){
    string W;cin>>W;
    if(S.find(W)!=S.end()){
      isok = false;
    }
    S.insert(W);
    if(i>0){
      isok &= prev==W[0];
    }
    prev=W.back();
  }
  cout<<(isok? "Yes":"No")<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define int long long int
using namespace std;
signed main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    
    int a,b,c,k,t; cin>>a>>b>>c>>k; t=k;
    k -=a;
    //cout<<k<<endl;
    if(k <= 0) cout<<t<<endl;
    else{
        k -=b;
        if(k <=0) cout<<a<<endl;
        else{
            cout<<a-k<<endl;
        }
    }
}

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

typedef struct{
	int w = 0;
	int b = 0;
} Grid;

int main(){
	int w, h;
	int dw[] = {1,0,-1,0};
	int dh[] = {0,1,0,-1};
	while(cin >> w >> h, w+h){
		vector<string> x(h+2);
		for(int i = 1; i <= h; ++i){
			cin >> x[i];
			x[i] = "#" + x[i] + "#";
		}
		for(int i = 0; i < w+2; ++i){
			x[0] += '#';
			x[h+1] += '#';
		}
		Grid a[h+2][w+2];
		for(int i = 0; i < h+2; ++i){
			for(int j = 0; j < w+2; ++j){
				if(x[i][j]=='#' || x[i][j]=='.') continue;
				if(x[i][j]=='W'){
					queue<pair<int,int> > q;
					q.push(make_pair(i,j));
					while(!q.empty()){
						int bh = q.front().first;
						int bw = q.front().second;
						q.pop();
						for(int dir = 0; dir < 4; ++dir){
							int nh = bh + dh[dir];
							int nw = bw + dw[dir];
							if(x[nh][nw]=='#' || x[nh][nw]=='B' || x[nh][nw]=='W') continue;
							if(a[nh][nw].w==1) continue;
							q.push(make_pair(nh,nw));
							a[nh][nw].w = 1;
						}
					}
				}else{
					queue<pair<int,int> > q;
					q.push(make_pair(i,j));
					while(!q.empty()){
						int bh = q.front().first;
						int bw = q.front().second;
						q.pop();
						for(int dir = 0; dir < 4; ++dir){
							int nh = bh + dh[dir];
							int nw = bw + dw[dir];
							if(x[nh][nw]=='#' || x[nh][nw]=='B' || x[nh][nw]=='W') continue;
							if(a[nh][nw].b==1) continue;
							q.push(make_pair(nh,nw));
							a[nh][nw].b = 1;
						}
					}
				}
			}
		}
		int ans_w = 0, ans_b = 0;
		for(int i = 1; i < h+1; ++i){
			for(int j = 1; j < w+1; ++j){
				if(a[i][j].w == 1 && a[i][j].b != 1){
					ans_w++;
				}
				if(a[i][j].w != 1 && a[i][j].b == 1){
					ans_b++;
				}
			}
		}
		// for(int i = 0; i < h+2; ++i){
		// 	for(int j = 0; j < w+2; ++j){
		// 		cout << a[i][j].b;
		// 	}
		// 	cout << endl;
		// }
		cout << ans_b << " " << ans_w << endl;

	}
	return 0;
}


Measured memory_bytes: 3172
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//#define int long long

void solve() {
	int a, b; cin >> a >> b;
    if(a > b) swap(a, b);
    if(a == 1 && b == 2) {
        cout << 3 << endl;
    } else if(a == 1 && b == 3) {
        cout << 2 << endl;
    } else {
        cout << 1 << endl;
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <memory.h>
using namespace std;

int main(){
	int n;
	string s1,s2;
	cin>>n>>s1>>s2;
	string fig;
	for(int i=0;i<n;){
		if(s1[i]==s2[i]) fig+='1',i++;
		else fig+='2',i+=2;
	}
	long long ans;
	if(fig[0]=='1') ans=3;
	else ans=6;
	for(int i=1;i<fig.length();i++){
		if(fig[i-1]=='1'){
			ans*=2;
			ans%=1000000007;
		}
		else{
			if(fig[i]=='2'){
				ans*=3;
				ans%=1000000007;
			}
		}
	}
	cout<<ans<<endl;
return 0;
}

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

int main() {
	int k;
	cin >> k;
	if (k % 2 == 0) {
		cout << (k / 2) * (k / 2) << endl;
	} else {
		cout << (k / 2) * (k / 2 + 1) << endl;
	}
}


Measured memory_bytes: 256
let rec solve acc = function
  | 0 -> acc
  | n -> solve (abs n mod 2 :: acc) (~- (n - abs n mod 2) / 2)
let solve = solve []

let () = Scanf.scanf "%d" @@ function
  | 0 -> print_endline "0"
  | n ->
      List.iter (Printf.printf "%d") (solve n);
      print_newline ()


Measured memory_bytes: 4480
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <bitset>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007; //998244353;

template<class _T> static void get(_T& a) {
	std::cin >> a;
}
template<class _T> static void get(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void get(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}
template <class _T> static _T tp_abs(_T a) {
	if (a < (_T)0) {
		a *= (_T)-1;
	}
	return a;
}

static void A();

int main()
{
	A();
	fflush(stdout);
	return 0;
}

static void A()
{
	std::string str;
	get(str);

	int ans = 0;
	char bfr = 0;
	for (int i = 0; i < 3; i++) {
		if ((str[i] == 'R') && (bfr == 'R')) {
			ans++;
		}
		else if (str[i] == 'R') {
			ans = 1;
		}
		bfr = str[i];
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 3684
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush, heapify
import math
import itertools
import random
 
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
INF = float('inf')
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N,K = inputMap()
    D = inputList()
    
    base = list(range(10))
    for vol in D:
        base.remove(vol)
        
    ans = ""
    NN = str(N)
    flg = False
    for i,val in enumerate(NN):
        isInp = False
        for j,vol in enumerate(base):
            if flg == True:
                ans += str(vol)
                isInp = True
                break
            tmp = int(val)
            if tmp == vol:
                ans += val
                isInp = True
                break
            elif tmp < vol:
                flg = True
                ans += str(vol)
                isInp = True
                break
            else:
                continue
        
        if isInp == False:
            ans += "*"
    
    if "*" not in ans:
        print(ans)
        sys.exit()
    
    ans = list(ans)
    ans_T = ""
    if ans[0] == "*" or 1 == 1:
        if base[0] != 0:
            ans_T += str(base[0])
        else:
            ans_T += str(base[1])
        for i in range(len(str(N))):
            ans_T += str(base[0])
        print(ans_T)
        sys.exit()
    
if __name__ == "__main__":
	main()


Measured memory_bytes: 38512
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
using namespace std;
inline int D()
{
    int t;
    scanf("%d",&t);
    return t;
}
inline ll llD()
{
    ll t;
    scanf("%lld",&t);
    return t;
}

const int Max=1e6+9;
const int OO=-1e6;
int st[4]= {1,0,0,-1};
int nt[4]= {0,1,-1,0};
int n,m;
bool valid(int x,int y)
{
    return x>-1 && y>-1 && x<n && y<m;
}
ll mem[Max];
void init()
{
    memset(mem,-1,sizeof mem);
}
//////////////////////////////////////////////////////////

ll a[Max];

ll solve (int i )
{
    if(i==n-1)return 0;
    if(i>=n)
        return Max;

    ll &ret=mem[i];
    if(~ret)return ret;

    ll take1 =solve(i+1)+abs(a[i]-a[i+1]);
    ll take2 =solve(i+2)+abs(a[i]-a[i+2]);

     return mem[i]=min(take2,take1);
}

void Fast()
{
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cerr.tie(0);
}
int main()
{
   init();
   n =D();
   for(int i=0; i<n;i++)
   {
       a[i]=llD();
   }
   printf("%lld",solve(0));

}


Measured memory_bytes: 18640
//dlang template---{{{
import std.stdio;
import std.conv;
import std.string;
import std.array;
import std.algorithm;
import std.typecons;
import std.math;
import std.range;

// MIT-License https://github.com/kurokoji/nephele
class Scanner
{
  import std.stdio : File, stdin;
  import std.conv : to;
  import std.array : split;
  import std.string;
  import std.traits : isSomeString;

  private File file;
  private char[][] str;
  private size_t idx;

  this(File file = stdin)
  {
    this.file = file;
    this.idx = 0;
  }

  this(StrType)(StrType s, File file = stdin) if (isSomeString!(StrType))
  {
    this.file = file;
    this.idx = 0;
    fromString(s);
  }

  private char[] next()
  {
    if (idx < str.length)
    {
      return str[idx++];
    }

    char[] s;
    while (s.length == 0)
    {
      s = file.readln.strip.to!(char[]);
    }

    str = s.split;
    idx = 0;

    return str[idx++];
  }

  T next(T)()
  {
    return next.to!(T);
  }

  T[] nextArray(T)(size_t len)
  {
    T[] ret = new T[len];

    foreach (ref c; ret)
    {
      c = next!(T);
    }

    return ret;
  }

  void scan()()
  {
  }

  void scan(T, S...)(ref T x, ref S args)
  {
    x = next!(T);
    scan(args);
  }

  void fromString(StrType)(StrType s) if (isSomeString!(StrType))
  {
    str ~= s.to!(char[]).strip.split;
  }
}
//}}}

void main() {
  Scanner sc = new Scanner;

  int S, W;

  sc.scan(S, W);

  if (S <= W) writeln("unsafe");
  else writeln("safe");
}


Measured memory_bytes: 2760
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <numeric>
#include <vector>
using namespace std;
#define MAXSIZE 200
#define MAXL 100
#define NUM 1000000007
typedef long long int lli;

int main(){
    string s;
    cin >> s;
    for(int i = 0; i < s.length(); i += 2){
        cout << s[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 512
import java.util.*;


public class Main {
     public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
//        String s = sc.nextLine();
//        int k = sc.nextInt();
//        int a = sc.nextInt();
//        int b = sc.nextInt();        
//        int r = sc.nextInt();
        String n = sc.nextLine();
        sc.close();
        if(n.contains("7")){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
//        System.out.println(n);
//        if(s <= w){
//            System.out.println(Math.PI);
//        }else{
//            System.out.println("safe");
//        }
//        System.out.println(s);
//        if(s.contains("RRR")){
//            System.out.println(3);
//        }else if(s.contains("RR")){
//            System.out.println(2); 
//        }else if(s.contains("R")){
//            System.out.println(1);
//        }else{
//             System.out.println(0);
//        }
//        String s = sc.nextLine();
//        String t = sc.next();
//        String[] arr =  s.split("　");
//        sc.close();
//        System.out.println("input: "+ s);
//        System.out.println("k:" + k);
//        System.out.println("a:" + a);
//        System.out.println("b:" + b);
//        String ans = "NG";
//        for(int x = a; x<=b; x++){
//            if(x%k == 0){
//                ans = "OK";
//            }
//        }
//        System.out.println(ans);
//        \
//        System.out.println("arr[1]:" + arr[1]);
//
//        if(s.equals("ABC")){
//            System.out.println("ARC");
//        }else{
//            System.out.println("ABC");
//        }
//        String[] arr1 =  s.split("");
//        String[] arr2 =  t.split("");
////        List<String> list1 = Arrays.asList(s.split(""));
//        List list1 = new LinkedList(Arrays.asList(s.split("")));
////        List<String> list2 = Arrays.asList(t.split(""));
//        List list2 = new LinkedList(Arrays.asList(t.split("")));
////        int num = Integer.parseInt(arr[arr.length - 1]);
//        list2.remove(arr2.length - 1);
////        System.out.println(list1);
////        System.out.println(list2);
//         if(list1.toString().contentEquals(list2.toString())){
//             System.out.println("Yes");
//         }else{
//             System.out.println("No");
//         }
//        switch(num){
//            case 3:
//                System.out.println("bon");
//                break;
//            case 0:
//            case 1:
//            case 6:
//            case 8:
//                System.out.println("pon");
//                break;
//            default:
//                System.out.println("hon");
//                break;
//        }
//        String[] array = str.split(" ");
//        int sum = 0;
//        for(int i=0; i<array.length; i++) {
//            int num = Integer.parseInt(array[i]);
//            sum += num;
//        }
//        System.out.println(15-sum);
    }
}

Measured memory_bytes: 35564
#include <bits/stdc++.h>
#define ll long long int
#define ul unsigned long long int
#define ld long double
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define pll pair<long long int, long long int>
#define pii pair<int, int>
#define vii vector<int>
#define vll vector<long long int>
#define sii set<int>
#define sll set<long long int>
#define usi unordered_set<int, custom_hash>
#define usl unordered_set<long long int, custom_hash>
#define mii map<int, int>
#define mll map<long long int, long long int>
#define umi unordered_map<int, int, custom_hash>
#define uml unordered_map<long long int, long long int, custom_hash>
#define ski stack<int>
#define skl stack<long long int>
#define all(v) v.begin(),v.end()
using namespace std;
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c`
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};


const int N=3e3+1;
const int mod=998244353;
ld a[N], b[N], c[N];

ld dp[N][N];

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
#endif

    
    int n;
    cin>>n;
    for(int i=1;i<=n;++i){
        cin>>a[i];
    }

    dp[0][0]=1;

    for(int i=1;i<=n;++i){
        for(int j=0;j<=i;++j){
            if(j==0){
                dp[i][j]=dp[i-1][j]*(1-a[i]);
                continue;
            }

            dp[i][j]=dp[i-1][j]*(1-a[i])+dp[i-1][j-1]*a[i];

        }
    }
    ld ans=0.0;
    for(int i=(n+1)/2;i<=n;++i){
        ans+=dp[n][i];
    }

    cout<<setprecision(15);
    cout<<ans<<endl;
}

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

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

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


// Driver code 
int main() 
{ 
	

	int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
};

int n;
cin>>n;
cout<<a[n-1];
}

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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

vl fact, rfact;
ll p(ll a, ll n) {
	if (n == 0)return 1;
	ll d = p(a, n / 2);
	if (n & 1)return a * d%MOD*d%MOD;
	return d * d%MOD;
}

ll h(int n, int r) {
	return fact[n + r - 1] * rfact[r - 1] % MOD*rfact[n] % MOD;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	map<int, int> mp;
	for (int i = 2; i*i <= m; ++i) {
		while (m%i == 0) {
			m /= i;
			mp[i]++;
		}
	}
	if (m != 1)mp[m]++;
	fact.resize(n + 100, 1);
	rfact.resize(n + 100);
	REP(i, n + 99)fact[i + 1] = fact[i] * (i + 1) % MOD;
	REP(i, n + 100)rfact[i] = p(fact[i], MOD - 2);

	ll ans = 1;
	for (auto a : mp) {
		ans *= h(a.second, n);
		ans %= MOD;
	}
	cout << ans << endl;
}

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

int main(){
    ll x,y;
    cin >> x >> y;
    int ans=0;
    while(1){
        if(x<=y) ans++;
        else break;
        x*=2;
    }
    cout << ans << endl;
}

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

typedef long long LL;

using namespace std;

int N,S[100010],A[100010];
int L = 0, R = 0;

int main()
{
	scanf("%d",&N);
	int ans = 0;
	for (int i=1;i<=N;i++)
	{
		scanf("%d",&A[i]);
		if (!S[A[i]]) ans++;
		S[A[i]]++;
	}
	if ((N-ans)&1) ans--;
	printf("%d\n",ans);
}

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

using namespace std;

int main() {
  int mx = 0;
  int k, n;
  cin >> k >> n;
  vector<int> a(n);
  for (int &p : a) cin >> p;
  mx = k - a[n - 1] + a[0];
  for (int i = 1; i < n; ++i) mx = max(mx, a[i] - a[i - 1]);
  cout << k - mx << '\n';
  return 0;
}

Measured memory_bytes: 1024
N = int(input())

AB = []
for i in range(N):
    a, b = map(int, input().split())
    AB.append([b, a])   # b順にsortするので
AB.sort()

ans = "Yes"
time = 0
for b, a in AB:
    time += a
    if time > b:
        ans = "No"
        break

print(ans)


Measured memory_bytes: 35616
import java.util.Scanner;

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

        int n = sc.nextInt();
        int x = sc.nextInt();

        int l[] = new int[n];

        for (int i = 0; i < n; i++) {
            l[i] = sc.nextInt();
        }

        int bound = 1;
        int coordinate = 0;

        for (int i = 0; i < n; i++) {
            coordinate += l[i];
            if (coordinate <= x){
                bound++;
            }
        }
        System.out.println(bound);

        sc.close();
    }
}

Measured memory_bytes: 23764
parseInt(x) = parse(Int,x)
parsemap(x::Array{SubString{String}, 1}) = map(parseInt, x)

function is_valid(v::Int)
    while(v > 0)
        if ((v&3) == 3) return false; end
        v ÷= 2;
    end
    return true
end
function amida(v::Int, pos::Vector{Int})
    for i = 0:length(pos)-2
        if( (v & (1 << i)) > 0)
            pos[i+1], pos[i+2] = pos[i+2], pos[i+1]
        end
    end
    return pos
end
const M = 10^9+7
g(n,A,R=A^0)=n>0 ? g(n÷2,A*A.%M,R*A^(n%2).%M) : R
function main()
    h,w,k = readline() |> split |> parsemap
    A = zeros(Int,w,w)
    for i = 0:(1 << (w-1))-1
        if (!is_valid(i)) continue end
        v = amida(i, Vector(1:w))
        for j=1:w
            @inbounds A[j,v[j]]  += 1
        end
    end
    r = g(h,A)
    println(r[1,k])
end

main()

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

#include <bits/stdc++.h>
using namespace std;

constexpr ll INF = 1e15;

constexpr ll mod = 1e9 + 7;

template<typename T>
void cmpmax(T& reference, T value) {
	reference = max(reference, value);
}

template<typename T>
void cmpmin(T& reference, T value) {
	reference = min(reference, value);
}

int main() {
	ll n, m;
	cin >> n >> m;
	vector<vector<int>> graph(n);
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}
	vector<ll> minCost(n, INF);
	vector<int> parents(n);
	queue<t3> q;
	q.emplace(0, 0, -1);
	while (!q.empty()) {
		auto t = q.front(); q.pop();
		int current, cost, from;
		tie(current, cost, from) = t;
		if (minCost[current] <= cost) {
			continue;
		}
		minCost[current] = cost;
		parents[current] = from;
		auto ncost = cost + 1;
		for (auto p : graph[current]) {
			if (minCost[p] <= ncost) {
				continue;
			}
			q.emplace(p, ncost, current);
		}
	}
	cout << "Yes" << endl;
	for (int i = 1; i < n; i++) {
		cout << parents[i] + 1 << endl;
	}
	return 0;
}



Measured memory_bytes: 13476
#include <iostream>

inline unsigned insertion_sort(unsigned a[], unsigned n, unsigned gap){
  unsigned count = 0;
  for(unsigned i = gap; i < n; i++){
    unsigned v = a[i];
    int j = i - gap;
    while(j >= 0 && a[j] > v){
      a[j+gap] = a[j];
      j -= gap;
      count++;
    }
    a[j+gap] = v;
  }
  return count;
}

inline void shell_sort(unsigned a[], unsigned n){
  const unsigned gaps[] = {1,8,23,77,281,1073,4193,16577,65921,262913,1050113};
  // generated from pow(4,i)+3*pow(2,i-1)+1 (prefixed with 1)

  unsigned gap_num = 0, count = 0;
  while(gaps[gap_num+1] < n) gap_num++;

  for(int i = gap_num; i >= 0; i--) count += insertion_sort(a,n,gaps[i]);

  std::cout << (gap_num+1) << '\n';

  for(int i = gap_num; i; i--) std::cout << gaps[i] << ' ';
  std::cout << gaps[0] << '\n';

  std::cout << count << '\n';
}

int main(){
  std::ios::sync_with_stdio(false);
  unsigned n;
  unsigned a[1000000];
  std::cin >> n;
  for(unsigned i = 0; i < n; i++) std::cin >> a[i];
  shell_sort(a,n);
  for(unsigned i = 0; i < n; i++) std::cout << a[i] << '\n';
}

Measured memory_bytes: 5100
from collections import defaultdict

N = int(input())
A = list(map(int, input().split()))

# j-i == A[i]+A[j] (i < j)                                                                                                                                                                                                                    
# A[i]+i == j-A[j]                                                                                                                                                                                                                            

memo = defaultdict(int)

ans = 0
for i in range(N):
    target = i - A[i]
    ans += memo[target]
    memo[A[i]+i] += 1
print(ans)

Measured memory_bytes: 150840
fun main(args: Array<String>) {
    Program().solve()
}

class Program {
    fun solve() {
        val sc = MyScanner()
        val s = sc.nextLong()

        // s = |x1*y2 - x2*y1|

        val x1 = 1000000000L
        val y2 = (s + x1 - 1) / x1

        val diff = x1 * y2 - s
        // diff = x2 * y1
        val x2 = 1L
        val y1 = diff

        println("0 0 $x1 $y1 $x2 $y2")
    }
}


class MyScanner() {
    private var index = 0
    private var line = listOf<String>()

    fun next(): String {
        while (line.size <= index) {
            line = readLine()!!.split(' ')
            index = 0
        }
        return line[index++]
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextDouble() = next().toDouble()
    fun nextCharArray() = next().toCharArray()
    fun nextChar() = next()[0]

    fun strList(): List<String> {
        index = line.size
        return readLine()!!.split(' ')
    }

    fun intList() = strList().map { it.toInt() }
    fun longList() = strList().map { it.toLong() }
    fun doubleList() = strList().map { it.toDouble() }
}

Measured memory_bytes: 38084
N = int(input())
K = int(input())

X = str(N+1)

dp = [[[0] * (K+1) for _ in range(2)] for _ in range(len(X)+1)]
#dp[i桁目][未満フラグ、0ならばそこまでの桁はNと同じ。1ならばすでにN以下が確定][k個の非ゼロを使う]
dp[0][0][0] = 1

for i in range(len(X)):
    D = int(X[i])
    for j in range(2):
        for k in range(K+1):
            for d in range(10 if j == 1 else D+1):
                if k + (d != 0) <= K:
                    dp[i+1][j | (d<D)][k+(d != 0)] += dp[i][j][k]


print(dp[-1][-1][-1])

Measured memory_bytes: 40304
// 22
#include <bits/stdc++.h>
using namespace std;
#define coutc "\033[48;5;196m\033[38;5;15m"
#define endc "\033[0m"
#define endl '\n'
#define M(_1, _2, _3, _4, NAME, ...) NAME
#define rep(...) M(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rep4(_, x, n, s) for (int _ = x; (s < 0) ? _ > n : _ < n; _ += s)
#define rep3(_, x, n) rep4(_, x, n, (x < n ? 1 : -1))
#define rep2(_, n) rep3(_, 0, n)
#define rep1(n) rep2(i, n)
#define fi first
#define se second
#define pb push_back
#define pairii pair<int, int>
#define all(x) x.begin(), x.end()
#define len(x) int(x.size())
#define lli __int128_t
#define li long long int
#define ld long double
// 4
template <class A, class B>
ostream &operator<<(ostream &o, const pair<A, B> &p) {
  return o << "(" << p.fi << ", " << p.se << ")";
}
// 5
template <class T>
ostream &operator<<(ostream &o, const vector<T> &v) {
  rep(i, len(v)) o << setw(7) << left << v[i];
  return o << endc << endl << coutc;
}
// 5
template <class A, class B>
ostream &operator<<(ostream &o, const map<A, B> &m) {
  for (auto &kv : m) o << kv;
  return o;
}
// 7
template <class T, class... Ts>
void debug(const T &e, const Ts &... r) {
#ifdef DEBUG
  cerr << coutc << e;
  ((cerr << " " << r), ..., (cerr << endc << endl));
#endif
}

// notes:
// https://lh4.googleusercontent.com/CNQ1gy-Zf7LuK-FCsBAy_keJTMoaeasIkW79rAedjMeUhX8LlF-UjkVaB6HJgDS4DxGvzzE=w16383

void _main(int tc) {
  int n;
  cin >> n;
  vector<vector<int>> adj(n);
  auto addEdge = [&](int u, int v) { adj[u].pb(v); };
  rep(n - 1) {
    int u, v;
    cin >> u >> v;
    u--, v--;
    addEdge(u, v);
    addEdge(v, u);
  }
  const int mod = 1e9 + 7;
  function<pairii(int, int)> f = [&](int u, int p) -> pairii {
    int ifwhitecnt = 1, ifblackcnt = 1;
    for (int v : adj[u]) {
      if (v == p) continue;
      auto ans = f(v, u);
      ifwhitecnt = ((li)ifwhitecnt * ((ans.fi + ans.se) % mod)) % mod;
      ifblackcnt = ((li)ifblackcnt * ans.fi) % mod;
    }
    return {ifwhitecnt, ifblackcnt};
  };
  auto ans = f(0, 0);
  cout << ((ans.fi + ans.se) % mod) << endl;
}
// 7
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  _main(0), exit(0);
  int tc;
  cin >> tc;
  rep(i, tc) _main(i + 1);
}

Measured memory_bytes: 14080
R,G,B,N=list(map(int,input().split()))
ans=0
for r in range(0,N//R+1):
    for g in range(0,N//G+1):
        if 0<= (N-(R*r+G*g))//B<=N/B and (N-(R*r+G*g))%B==0 :
            ans+=1
print(ans)

Measured memory_bytes: 40684
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int main() {
	int k;
	cin >> k;
	int a, b;
	cin >> a >> b;
	int p = 1010;
	int t = 0;
	rep(i, p) {
		if (k * i <= b && k * i >= a)t++;
	}
	if (t == 0)cout << "NG" << endl;
	else cout << "OK" << endl;
	return 0;
}


Measured memory_bytes: 3636
# coding: utf-8
# Your code here!

# W = 0
# E = 1
N = int(input())
S = input()

X = []
count = 0
for s in S:
    if s == 'W':
        X.append(count)
    else:
        count += 1
        X.append(count)
     
min_person = int(1e10) 
for i, x in enumerate(X):
    num_person = 0
    if i > 0:
        num_person += i - X[i - 1]
    if i < N:
        num_person += X[-1] - X[i]
        
    min_person = min(min_person, num_person)
    
print(min_person)

Measured memory_bytes: 15520
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABCProblems
{
    class Program
    {
        static void Main(string[] args)
        {
            //空白ずつ取得
            string[] input = Console.ReadLine().Split(' ');
            //int number = int.Parse(Console.ReadLine());

            int n = int.Parse(input[0]);
            int r = int.Parse(input[1]);

            if(n < 10)
            {
                r = r + (100 * (10 - n));
            }

            Console.WriteLine(r);

        }
    }
}


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


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

    for(long long i=0;i<K;i++){
        if(S.at(i)!='1'){
            cout<<S.at(i)<<endl;
            break;
        }
        if(i==(K-1)){
            cout<<1<<endl;
        }
    }


    return 0;



}


Measured memory_bytes: 256
//By Vlgd
#include<bits/stdc++.h>
using namespace std;
const int N=100;
int pre[N],in[N],post[N],n,cnt=0,pos=0;
int chl[N][2];
//no tree:
void rec(int x,int y){
	if (x>=y) return;
	int root=pre[cnt++],cur;
	for (cur=x;cur<y;cur++) if (in[cur]==root) break;
	rec(x,cur);
	rec(cur+1,y);
	post[pos++]=root;
}
//tree:
//int rec(int x,int y){
//	if (x>=y) return -1;
//	int root=pre[cnt++],cur;
//	for (cur=x;cur<y;cur++) if (in[cur]==root) break;
//	chl[root][0]=rec(x,cur);
//	chl[root][1]=rec(cur+1,y);
//	return root;
//}
//void posto(int v){
//	if (v==-1) return;
//	posto(chl[v][0]);
//	posto(chl[v][1]);
//	if(cnt++)printf(" ");
//	printf("%d",v);
//}
main(){
	scanf("%d",&n);
	memset(chl,-1,sizeof(chl));
	for (int i=0;i<n;i++) scanf("%d",&pre[i]);
	for (int i=0;i<n;i++) scanf("%d",&in[i]);
	
	rec(0,n);
//	cnt=0;posto(pre[0]);
//	printf("\n");
	for (int i=0;i<n;i++){
		printf("%d",post[i]);
		if (i!=n-1) printf(" ");
		else printf("\n");
	}
}
//5
//1 2 3 4 5
//3 2 4 1 5


Measured memory_bytes: 3212
using System;
using System.Linq;
using System.Collections.Generic;

namespace ABC
{
    class ProgramB
    {
        static void Main(string[] args)
        {
            var inputs = Console.ReadLine().Split(" ");
            var a = long.Parse(inputs[0]);
            var b = long.Parse(inputs[1]);
            var x = long.Parse(inputs[2]);

            var count = (b / x) - ((a - 1) / x);
            if (a == 0 && x > 1)
                count++;

            Console.WriteLine(count);
        }
    }
}


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

#define int long long

signed main() {
    string s;
    cin >> s;
    int ans = 0;
    for (int i = 0; i < s.size(); ++i)
        if (i < s.size() - 1 - i)
            ans += s[i] != s[s.size() - 1 - i];
        else
            break;
    cout << ans;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int A, B, C, D, N, ans=0;
    vector<int> V(3);
    char tmp, tmp2;
    string S, S2;
    bool flag=true;
    
    cin >> S;
    
    // ans = A+2*(B-A);
    // cout << ans << endl;

    if(S[1]==S[2] &&(S[0]==S[1] | S[2]==S[3]))
    	cout << "Yes" <<endl;
    else
    	cout << "No" <<endl;

    // string S;
    // cin >>S;
    // cout << S + "pp"<<endl;
    // if(A+B==C || B+C==A || C+A==B)
    // 	puts("Yes");
    // else
    // 	puts("No");
}


Measured memory_bytes: 256
N, M = map(int, input().split())
C = [-1] * 3


for i in range(M):
    s, c = map(int, input().split())
    if C[s - 1] == -1:
        C[s - 1] = c
    else:
        if C[s - 1] != c:
            print(-1)
            exit()

if N == 1 and (M == 0 or (M == 1 and C[0] == 0)):
    print(0)
    exit()

for i in range(10 ** (N - 1), 10 ** N):
    si = str(i)
    flg = True
    for j in range(N):
        if C[j] != -1 and si[j] != str(C[j]):
            flg = False
            break
    if flg:
        print(i)
        exit()
print(-1)


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

int main(){
  int N,L;
  cin >> N >> L;
  
  int ans = 0;
  for(int i=0;i<N;i++){
    ans = ans + L + i;
  }
  
  if(L >= 0){
    ans = ans - L;
  }
  else if(L+N-1 <= 0){
    ans = ans - L - N + 1;
  }
  
  cout << ans << endl;
  
}

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

const uint64_t M = 1'000'000'007;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout.precision(12);
    cout.setf(ios_base::fixed, ios_base::floatfield);
    
    string s;
    int d;
    cin >> s;
    cin >> d;

    static uint64_t dp[10001][100][2];
    dp[0][0][1] = 1;

    for(size_t i=0;i<s.size();i++){
        for(int j=0;j<d;j++){
            for(int k=0;k<=9;k++){
                if(k < s[i]-'0'){
                    dp[i+1][(j+k)%d][0] += dp[i][j][0] + dp[i][j][1];
                    dp[i+1][(j+k)%d][0] %= M;
                }else if(k == s[i]-'0'){
                    dp[i+1][(j+k)%d][0] += dp[i][j][0];
                    dp[i+1][(j+k)%d][0] %= M;
                    dp[i+1][(j+k)%d][1] += dp[i][j][1];
                    dp[i+1][(j+k)%d][1] %= M;
                }else{
                    dp[i+1][(j+k)%d][0] += dp[i][j][0];
                    dp[i+1][(j+k)%d][0] %= M;
                }
            }
        }
    }
    
    cout << (dp[s.size()][0][0] + dp[s.size()][0][1] - 1 + M) % M << endl;
    return 0;
}

Measured memory_bytes: 15872
import sys
input = sys.stdin.readline

x,y = list(map(int,input().split()))
nl = [[1,3,5,7,8,10,12],[4,6,9,11],[2]]
nd = {1:0,1:0,3:0,5:0,7:0,8:0,10:0,12:0,4:1,6:1,9:1,11:1,2:2}
print('Yes' if y in nl[nd[x]] else 'No')


Measured memory_bytes: 9188
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
#include<stdio.h>
using namespace std;
int main(){
    int n,m,l;
    cin >>n >>m >>l;
    long long a[n][m];
    long long b[m][l];
    long long c[n][l];

    int i,j,k;

    for(int i = 0; i <n; i++){
        for(int j = 0; j < l; j ++){
            c[i][j] = 0;
        }
    }

    for(int i = 0; i <n; i++){
        for(int j = 0; j < m; j ++){
            cin >> a[i][j];
        }
    }
    for(int j= 0; j <m; j++){
        for(int k = 0; k < l; k ++){
            cin >> b[j][k];
        }
    }
    for(int i= 0; i<n;  i++){
        for(int j=0; j<l; j++){
            for(int k = 0; k < m; k++){
                c[i][j] += a[i][k] * b[k][j];
            }
        }
    }


    for(int i = 0; i <n; i++){
        for(int j = 0; j < l; j ++){
            if(j!=l-1){
                cout << c[i][j] << " " ;
            }else{
                cout << c[i][j] << endl;
            }
        }
    }

}


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007

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

ll H,W,N;
ll c[15];

int main()
{
	cin >> H >> W >> N;
	ll a,b;
	map<P,int> M;
	rep(i,0,N){
		cin >> a >> b;
		a--;b--;
		rep(i,0,3) rep(j,0,3) {
			if(a-(ll)i>=0 and a-(ll)i+2<H and b-(ll)j>=0 and b-(ll)j+2<W){
				M[P(a-(ll)i,b-(ll)j)]++;
			}
		}
	}
	for(auto it=M.begin();it!=M.end();++it){
		c[(*it).second]++;
	}
	c[0] = (H-2LL)*(W-2LL);
	rep(i,1,10)c[0] -= c[i];
	rep(i,0,10){
		cout << c[i] << endl;
	}


	return 0;
}


Measured memory_bytes: 56448
function Main(input) {
  input = input.split("\n");

  var A = ~~input[0];
  var B = ~~input[1];
  var C = ~~input[2];
  var X = ~~input[3];

var You = function(){
  this.match = 0;
};

You.prototype = {
  procedure: function(){
    this.match = 0;
    for(var a=0; a<=A; a++){
      for(var b=0; b<=B; b++){
        for(var c=0; c<=C; c++){
          if(a*500+b*100+c*50 == X){
            this.match++;
          }
        }
      }
    }
    return this.match;
  }
}

var you = new You();

console.log(you.procedure());

  // console.log('%d %d',N,Q);
}


Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

int main() {
	double n;
	cin >> n;
	double pos = floor(n / 1.08);
	if (floor(pos * 1.08) == n) {
		cout << pos << endl;
		return 0;
	}
	if (floor((pos + 1) * 1.08) == n) {
		cout << pos + 1 << endl;
		return 0;
	}
	cout << ":(" << endl;
	return 0;
}

Measured memory_bytes: 3708
#include<bits/stdc++.h>
#define m 1000000007
#define r(i,n) for(l i=0;i<n;i++)
#define B push_back
using namespace std;
typedef long l;
typedef vector<l> L;
vector<L> p;
l P(l i, l b) {l a=1;r(n,62){if((b>>n)%2){a*=p[i][n];a%=m;}}return a;}
main(){deque<l>q;l N,X,Y;cin>>N;l M=N-1;L V,A(N,0),a(N,-1),D(N,1),J(N,0),n(N,1),w(70);vector<L>T(N);
	r(i,N*2){w[0]=i;r(j,62)w[j+1]=(w[j]*w[j])%m;p.B(w);}
	r(i,M){cin>>X>>Y;X--;Y--;T[X].B(Y);T[Y].B(X);A[X]++;A[Y]++;	}q.B(0);J[0]=1;V.B(0);
	r(k,N){l x=q.front();q.pop_front();r(i,A[x]){l E=T[x][i];if(!J[E]){J[E]=1;	q.B(E);a[E]=x;V.B(E);}}}
	r(j,N){l i=N-1-j,x=V[i];r(j,A[x]){l E=T[x][j];if(E==a[x])continue;D[x]+=D[E];}}
	r(i,N)n[0]=((n[0]*(i+1)%m)*P(D[i],m-2))%m;
	r(j,N-1){l x=V[j+1];n[x]=(((n[a[x]]*D[x])%m)*P(N-D[x],m-2))%m;}
	r(i,N)cout<<n[i]<<"\n";}

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

int main (void) {
  int N;
  cin >> N;
  int ans=0;
  int t=0;
  int b=0;
  int c=0;
  int a[N];
  for (int i=0; i<N;i++){
    cin >> a[i];
  }
  sort(a,a+N);
  while (t<N) {
    c=a[t];
    int f=0;
    while (t<N && a[t]==c) {
      f=f+1;
      t=t+1;
    }
    ans=ans+(f%2);
  }
  cout << ans;
}

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

using namespace std;

int main(void)
{
    int A, B, C, K;
    cin >> A >> B >> C >> K;

    vector<int> v = {A, B, C};
    sort(v.begin(), v.end());
    cout << (v[0] + v[1] + v[2] * (1 << K)) << endl;
    return 0;
}

Measured memory_bytes: 384
lines = readlines.map{|line| line.split(' ').map(&:to_i)}
s=lines[0][1]
a=0
e=lines[1].sort.reverse
for i in 1..s
  e.shift(1)
end
if e.length>0 then
  puts e.inject(:+)
else
  puts "0"
end

Measured memory_bytes: 23012
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    K, S = list(map(int,_in[0].split(' ')))  # type:list(int)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    cnt = 0
    for X in range(K+1):
        for Y in range(K+1):
            if 0<=S-X-Y<=K:
                cnt += 1
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)


Measured memory_bytes: 41452
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int i,j,n,o,po,s;
    int shuzu[100860];
    while(~scanf("%d",&n))
    {
        for(i=1; i<=n; i*=2)
        {
            if(i*2>n)
            {
                break;
            }

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

Measured memory_bytes: 128
N=int(input())

A=list(map(int, input().split()))

#重複した値だけを集めて消す

sets={}
for i in A:
    if i in sets:
        sets[i]+=1
    else:
        sets[i]=1

duplicate=0
for k,v in sets.items():
    if v>1:
        duplicate+=(v-1)

duplicate %=2

print(len(set(A))-duplicate)

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

lli N, X;
vector<lli> A(100005);

int main() {
  cin >> N >> X;
  for (lli i = 0; i < N; ++i) {
    cin >> A[i];
  }
  lli res = 0;
  for (lli i = 0; i + 1 < N; ++i) {
    lli diff = max(0LL, A[i] + A[i+1] - X);
    res += diff;
    A[i+1] = max(0LL, A[i+1] - diff);
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 1024
N = int(input())*2
N -= 1
inp = input()
skewers=[]
for num in inp.split():
    skewers.append(int(num))
skewers = sorted(skewers)
total = 0
for i in range(0,N,2):
  num = int(skewers[i])
  total+=num
print(total)


Measured memory_bytes: 3060
#include <stdio.h>
   
#define min(a,b) ((a) < (b) ? (a) : (b))
#define MAX 100
#define INF 1000000000
   
int V;
int cost[MAX][MAX];
int mincost[MAX];
int used[MAX];
   
int prim() {
  int i,res,v,u;
   
  for (i = 0 ; i < V ; i++) {
    mincost[i] = INF;
    used[i] = 0;
  }
   
  mincost[0] = 0;
  res = 0;
   
  while (1) {
    v = -1;
   
    for (u = 0 ; u < V ; u++) {
      if (!used[u] && (v == -1 || mincost[u] < mincost[v])) {
    v = u;
      }
    }
   
    if (v == -1) {
      break;
    }
    used[v] = 1;
    res += mincost[v];
   
    for (u = 0 ; u < V ; u++) {
      if (cost[v][u] != -1) {
    mincost[u] = min(mincost[u],cost[v][u]);
      }
    }
   
  }
   
  return res;
}
   
int main() {
  int i,j;
     
  scanf("%d" ,&V);
  for (i = 0 ; i < V ; i++) {
    for (j = 0 ; j < V ; j++) {
      scanf("%d" ,&cost[i][j]);
    }
  }
   
  printf("%d\n" ,prim());
   
  return 0;
}

Measured memory_bytes: 640
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ENDL '\n'
#define print(i) std::cout << (i) << '\n'

#define int long long // at least int64 > 9*10^18
#define all(v) (v).begin(), (v).end()
/* libraries */

#define dump1(v) for(auto i:v) std::cout << i << ' '; std::cout << "\n";
#define dump2(v) for(auto i:v) { for(auto j:i) std::cout << j << ' '; std::cout << "\n"; }


const int MOD = 1e9+7;
signed main() {
	int n;
	std::cin >> n;
	std::vector<int> c;
	rep(i,n) {
		int a;
		std::cin >> a;
		if(i==0) c.emplace_back(a);
		else if(c.back()!=a) c.emplace_back(a);
	}
	n = c.size();
	std::vector<int> dp(n,0);
	std::map<int,std::vector<int> > map;
	dp[0] = 1;
	map[c[0]].emplace_back(0);
	for(int i=1;i<n;i++) {
		int sum = dp[i-1];
		if(!map[c[i]].empty()) {
			int x = map[c[i]].back();
			sum+=dp[x];
			sum%=MOD;
		}
		dp[i] = sum;
		map[c[i]].emplace_back(i);
	}
	print(dp[n-1]);
	return 0;
}


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

int main(void) {
	int a, b;
	char symbol;
	while(cin >> a >> symbol >> b)
	{
		if(symbol == '?') {
			break;
		}
		else if(symbol == '+') {
			cout << a + b << endl;
		}
		else if(symbol == '-') {
			cout << a - b << endl;
		}
		else if(symbol == '*') {
			cout << a * b << endl;
		}
		else if(symbol == '/') {
			cout << a / b << endl;
		}
	}
    return 0;
}



Measured memory_bytes: 3120