akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = 1e9 + 7;

// gcd: 最大公約数, lcm: 最小公倍数
template<typename T>
T euclidean(T a, T b){
    if(a < b) swap(a, b);
    T r = a % b;
    while(r != 0){
        a = b; b = r; r = a % b;
    }
    return b;
}
template<typename T>
T gcd(T a, T b){
    return euclidean(a, b);
}
template<typename T>
T lcm(T a, T b){
    T g = gcd(a, b);
    return a / g * b;
}

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

    int n, x;
    cin >> n >> x;
    int y;
    cin >> y;
    int ans = abs(y - x);
    REP(i, n-1){
        cin >> y;
        ans = gcd(ans, abs(y-x));
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
a = list(map(int, input().split()))
l = []
prev = None
for i in range(n):
    if prev!=a[i]:
        l.append(a[i])
    prev = a[i]
        
if len(l)==1:
    ans = 1
else:
    m = len(l)
    prev = None
    ans = 0
    for i in range(m-1):
        s = l[i]<l[i+1]
        if prev is None:
            prev = s
        elif prev!=s:
            ans += 1
            prev = None
    ans += 1
print(ans)

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

int main() {
	int i, len[3];
	char next, S[3][110];
	scanf("%s%s%s", &S[0], &S[1], &S[2]);
	for (i=0;i<3;i++) len[i] = strlen(S[i]);

	i = 0;
	while (1) {
		if (len[i] == 0) {
			break;
		} else {
			next = S[i][0];
			memmove(S[i], S[i]+1, len[i]-1);
			S[i][len[i]-1] = '\0';
			len[i]--;
			i = next-97;
		}
	}

	next -= 32;
	printf("%c\n", next);

	return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<vector>
#include<algorithm>

int main(){
    int n;
    scanf("%d",&n);
    int a[3*n];
    int i;
    for(i=0;i<=3*n-1;i++)scanf("%d",&a[i]);
    std::sort(a,a+3*n);
    long long int ans=0;
    for(i=n;i<=3*n-1;i=i+2){
        ans+=a[i];
    }
    printf("%lld",ans);
    return 0;
    
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007 
#define all(n)      (n).begin(), (n).end()
#define ll long long 
#define PI 3.14159265358979323846

void solve(){
	int r; cin >> r; 
	long double ans;
	ans = (2 * PI * (long double)r);
	cout << setprecision(30) << ans << endl;
	

}


int main (){
	#ifndef ONLINE_JUDGE
		freopen ("input.txt","r",stdin);
		freopen ("output.txt", "w", stdout);
	#endif
	ios::sync_with_stdio(0);
	cin.tie(0);
	//Write from here.
	
		solve();
	
	return 0;
}

Measured memory_bytes: 3820
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
const int N=2010,M=4000010;
const ll mod=1e9+7;
ll dp[N][N],d1[M],d2[M];
int n,k,max1;
inline ll f(ll y,ll x){
	ll t=y,s=1;if(x%2)s=y;x>>=1;
	while(x){t=(t*t)%mod;if(x%2)s=(s*t)%mod;x>>=1;}
	return s;
}
inline ll c(int m,int n){
	//printf("c%d %d %lld\n",m,n,((d1[n]*d2[m])%mod*d2[n-m])%mod);
	return ((d1[n]*d2[m])%mod*d2[n-m])%mod;
}
int main(){
	scanf("%d%d",&n,&k);max1=n*k;
	if(k==1){printf("1");return 0;}
	d1[0]=1;d2[0]=1;
	for(int i=1;i<=max1;i++)d1[i]=(d1[i-1]*i)%mod;
	d2[max1]=f(d1[max1],mod-2);//printf("%lld ",d2[max1]);
	for(int i=max1-1;i>=1;i--)d2[i]=(d2[i+1]*(i+1))%mod;
	dp[1][0]=1;dp[1][1]=(c(k-2,max1-2)*n)%mod;//printf("1 1 %lld\n",dp[1][1]);
	for(int i=2;i<=n;i++){
		dp[i][0]=1;
		for(int j=1;j<=i;j++){
			dp[i][j]=(dp[i-1][j]+((dp[i][j-1]*c(k-2,max1-i-1-(j-1)*(k-1)))%mod*(n-j+1))%mod)%mod;
			//printf("%d %d %lld\n",i,j,dp[i][j]);
		}
	}
	printf("%lld",dp[n][n]);
	return 0;
} 

Measured memory_bytes: 94080
#include<iostream>
using namespace std;
int main() {
	int N;
	long long A[100006];
	cin >> N;

	int odd = 0;

	for (int i = 0; i < N; i++) {
		cin >> A[i];
		if (A[i] % 2 == 1) odd++;
	}
	if (odd % 2 == 0) cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 1024
#include <iostream>

int x, n, arr[100], cnt;


bool findoccur(int tg, int arr[], int l) {
    for (int i=0; i<l; ++i)
        if (arr[i] == tg) return true;
    return false;
}

void solve() {
    std::cin >> x >> n;
    cnt = 0;
    for (int i=0; i<100; ++i)
        arr[i] = x;
    for (int i=0; i<n; ++i) 
        std::cin >> arr[i];

    while(true) {
        if (!findoccur(x-cnt, arr, n)) {
            std::cout << x - cnt << std::endl;
            return;
        }
        else if (!findoccur(x + cnt, arr, n)) {
            std::cout << x + cnt << std::endl;
            return;
        }
        else
            ++cnt;
    }
    
}

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

Measured memory_bytes: 3636
# -*- coding: utf-8 -*-


def bubble_sort(cards, num):
    flag = True
    while flag:
        flag = False
        for left in range(num-1, 0, -1):
            right = left - 1
            if cards[left][1] < cards[right][1]:
                cards[right], cards[left] = cards[left], cards[right]
                flag = True

    print(list_to_str(cards))


def selection_sort(cards, num):
    for head in range(num):
        min_i = head

        for target in range(head+1, num):
            if cards[target][1] < cards[min_i][1]:
                min_i = target
        cards[head], cards[min_i] = cards[min_i], cards[head]

    print(list_to_str(cards))


def is_stable(before, after, num):
    for i in range(num):
        for j in range(i+1, num):
            for a in range(num):
                for b in range(a+1, num):
                    if before[i][1] == before[j][1]\
                    and before[i] == after[b]\
                    and before[j] == after[a]:
                        return 'Not stable'
    return 'Stable'


def list_to_str(l, delimiter=' '):
    # The default delimiter is one space.
    return delimiter.join([str(v) for v in l])


if __name__ == '__main__':
    num = int(input())
    cards = input().split()
    cards_for_bubble = cards.copy()
    cards_for_selection = cards.copy()

    bubble_sort(cards_for_bubble, num)
    print(is_stable(cards, cards_for_bubble, num))

    selection_sort(cards_for_selection, num)
    print(is_stable(cards, cards_for_selection, num))

Measured memory_bytes: 7860
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
#include <functional>
#include <numeric>
#include <limits>
#include <iomanip>
#include <queue>
#include <cmath>
#include <math.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const long long INF = 1LL << 60;
using pll = pair<long long, long long>;
#define min(a, b) ((a) < (b) ? (a) : (b))



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

long long lcm(long long a, long long b)
{
	return a * b / gcd(a, b);
}

double calculateDegree(double side, double B) {
	double radian = atan2(side, B);
	double degree = radian * (180.0 / 3.141592653589793238463);
	return degree;
}

int main() {
	int N;
	cin >> N;
	vector<long long> A(N);
	bool flag = false;
	long long tmp = 0;
	long long minusCount = 0;
	for (int i = 0; i < N; i++) {
		cin >> tmp;
		if (tmp < 0) {
			++minusCount;
		}
		A.at(i) = abs(tmp);
	}

	if (minusCount % 2 != 0) flag = true;
	long long res = 0;
	for (int i = 0; i < N; i++) {
		res += abs(A.at(i));
	}
	if (flag) {
		sort(A.begin(), A.end());
		res -= A.at(0) * 2;
	}

	cout << res << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
	int n,m,i,j,a[110],b[110],x,y;
	cin>>n>>m>>x>>y;
	for(i=0;i<n;i++){
		cin>>a[i];
	}
	for(i=0;i<m;i++){
		cin>>b[i];
	}
	int flag=0;
	for(i=x+1;i<=y;i++){
		int flag1=0,flag2=0;
		for(j=0;j<n;j++){
			if(a[j]>=i){
				flag1=1;
				break;
			}
		}
		for(j=0;j<m;j++){
			if(b[j]<i){
				flag2=1;
				break;
			}
		}
		if(flag1==0&&flag2==0){
			flag=1;
			break;
		}
	}
	if(flag==1){
		cout<<"No War"<<endl;
	}else{
		cout<<"War"<<endl;
	} 
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int long long N;
	int long long i=1;
	scanf("%d",&N);
	int A=N ;
	while (i<A) {
	N=N*i%1000000007;
	i++; }
	printf("%lld\n",N%1000000007);
	
    return 0;
	} 
 

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

const int N = 1e5 + 7;

vector <int> ad[N];
long long n, m;
int mrk[N];

bool dfs(int v) {
	bool ok = 0;
	for (auto u: ad[v]) {
		if (mrk[v] == mrk[u])
			ok = 1;
		if (!mrk[u]) { 
			mrk[u] = 3 - mrk[v];
			ok |= dfs(u);
		}
	}
	return ok;
}

int main() {
	cin >> n >> m;
	while (m--) {
		int x, y;
		cin >> x >> y;
		ad[x].push_back(y);
		ad[y].push_back(x);
	}
	long long k = 0, g = 0, one = 0;
	for (int i = 1; i <= n; i++)
		if (!mrk[i]) {
			mrk[i] = 1;
			if (dfs(i))
				g++;
			else
				k++;
			if (ad[i].size() == 0)
				one++, k--;
		}
	cout << 2 * k * k + 2 * k * g + g * g + 2 * one * (n) - one * one;
	return 0;
}



























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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int left = a + b;
  int right = c + d;

  if (left > right) {
    cout << "Left" << endl;
  } else if (left == right) {
    cout << "Balanced" << endl;
  } else {
    cout << "Right" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <unordered_map>
#include <iterator>
#include <algorithm>
#include <queue>

typedef std::pair<int, int> P;

const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
std::string move[] = {"R", "U", "L", "D"};

inline P key(int i, int j) {return std::make_pair(i, j);}
inline int getx(P pair) {return pair.first;}
inline int gety(P pair) {return pair.second;}

struct pair_hash
{
	template <class T1, class T2>
	std::size_t operator() (const std::pair<T1, T2> &pair) const
	{
		return std::hash<T1>()(pair.first) ^ std::hash<T2>()(pair.second);
	}
};

std::unordered_map<P, P, pair_hash> d;
std::unordered_map<P, bool, pair_hash> visits;

std::string bfs(int sx, int sy, int tx, int ty);
void solve();
/*
void solve(int sx, int sy, int tx, int ty)
{
  std::string ans;
  ans += bfs(sx, sy, tx, ty);
  ans += bfs(tx, ty, sx, sy);
  ans += bfs(sx, sy, tx, ty);
  ans += bfs(tx, ty, sx, sy);
  std::cout << ans << std::endl;
}
*/

void solve(int sx, int sy, int tx, int ty)
{
  std::string ans;

  for (int i=0; i< tx-sx; i++) ans += "R";
  for (int i=0; i< ty-sy; i++) ans += "U";

  for (int i=0; i< tx-sx; i++) ans += "L";
  for (int i=0; i< ty-sy; i++) ans += "D";

  ans += "L";
  for (int i=0; i<= ty-sy; i++) ans += "U";
  for (int i=0; i<= tx-sx; i++) ans += "R";
  ans += "D";

  ans += "R";
  for (int i=0; i<= ty-sy; i++) ans += "D";
  for (int i=0; i<= tx-sx; i++) ans += "L";
  ans += "U";

  std::cout << ans << std::endl;
}

int main()
{
  int sx, sy, tx, ty;
  std::cin >> sx >> sy >> tx >> ty;
  solve(sx, sy, tx, ty);
  return 0;
}

std::string bfs(int sx, int sy, int tx, int ty)
{
  std::string ret;
  std::queue<P> que;

  // init
  que.push(key(sx, sy));
  d.insert({key(sx, sy), key(0, -1)});

  while (!que.empty()) {
    P p = que.front(); que.pop();
    int x = getx(p), y = gety(p);
    //std::cout << x << ", " << y << '\n';
    if (x==tx && y==ty) break;
    for (int i=0; i<4; i++) {
      int nx = x + dx[i], ny = y + dy[i];
      auto search = d.find(key(nx, ny));
      auto visited = visits.find(key(nx, ny));
      if (search == d.end() && visited == visits.end()) {
        // if not found and not visited before, then push it to queue
        que.push(key(nx, ny));
        int dist = (d.find(key(x, y))->second).first + 1;
        d.insert({key(nx, ny), key(dist, i)});
      }
      //else std::cout << "Already visited: " << nx << ", " << ny << '\n';
    }
  }

  // back trace
  P p = key(tx, ty);
  while (1) {
    P srch = d.find(p)->second;
    int m = srch.second;
    if (m==-1) break;
    ret += move[m];
    visits.insert({p, true});
    p = key(getx(p) - dx[m], gety(p) - dy[m]);
  }
  visits.erase(visits.find(key(tx, ty)));
  std::reverse(ret.begin(), ret.end());

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

  d.clear();

  return ret;
}

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>
#define _USE_MATH_DEFINES
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775808;

int fld[41][401][401];

int main() {
    int N, ma, mb;
    cin >> N >> ma >> mb;
    int a[N], b[N], c[N];
    for (int i = 0; i < N; i++) {
        cin >> a[i] >> b[i] >> c[i];
    }
    for (int i = 0; i < 41; i++) {
        for (int j = 0; j < 401; j++) {
            fill(fld[i][j], fld[i][j] + 401, 1000000);
        }
    }
    fld[0][0][0] = 0;
    for (int i = 1; i < N + 1; i++) {
        for (int j = 0; j < 401; j++) {
            for (int k = 0; k < 401; k++) {
                if(j - a[i - 1] >= 0 && k - b[i - 1] >= 0) {
                    fld[i][j][k] = min(fld[i - 1][j][k], fld[i - 1][j - a[i - 1]][k - b[i - 1]] + c[i - 1]);
                } else {
                    fld[i][j][k] = fld[i - 1][j][k];
                }
            }
        }
    }
    int ans = 1000000;
    int num = 1;
    while (ma * num <= 400 && mb * num <= 400) {
        ans = min(ans, fld[N][ma * num][mb * num]);
        num++;
    }
    if (ans == 1000000) {
        ans = -1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 25984
# https://atcoder.jp/contests/abc050/tasks/arc066_a
# 並び方がありうるかの判別は簡単で、Nが偶数なら、Aがすべて奇数かつすべての数が2回ずつ出現する
# 奇数なら、Aが全て偶数で、0だけ1回出現しほかは2回ずつ出現する。

# ありえるならば、N&1→ 2**(N//2)が答え
# N&1 =0→ 2**(N//2)が答え
# どちらも同じ式でOK
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


N = read_a_int()
A = read_ints()

from collections import Counter
A_cnt = Counter(A)


def end():
    print(0)
    exit()


if N & 1:
    if A_cnt[0] != 1:
        end()
    for i in range(2, N, 2):
        if A_cnt[i] != 2:
            end()
else:
    for i in range(1, N, 2):
        if A_cnt[i] != 2:
            end()

print(pow(2, N // 2, 10**9 + 7))


Measured memory_bytes: 55516
#include<stdio.h>
#include<string.h>
using namespace std; 
#define L 14
#define M 1456527
char H[M][14]; 
int getchar(char ch){
    if (ch == 'A') return 1;
    else if (ch == 'C') return 2;
    else if (ch == 'G') return 3;
    else if (ch == 'T') return 4;
}
long long getKey(char str[]) {
    long long sum = 0, p = 1, i;
    for (i = 0; i < strlen(str); i++) {
        sum += p * (getchar(str[i]));
        p *= 5;
    }
    return sum;
}
int h1(int key) { return key % 10456527; }
int h2(int key) { return 1 + (key % 10456526); }
int find(char s[]) {
    long long key, i, h;
    key = getKey(s);
    for (i = 0;; i++) {
        h = (h1(key) + i * h2(key)) % M;
        if (strcmp(H[h], s) == 0) return 1;
        else if (strlen(H[h]) == 0) return 0;
    }
    return 0;
}
int insert(char s[]) {
    long long key, i, h;
    key = getKey(s);
    for (i = 0;; i++) {
        h = (h1(key) + i * h2(key)) % M;
        if (strcmp(H[h], s) == 0)return 1;
        else if (strlen(H[h]) == 0) {
            strcpy(H[h], s);
            return 0;
        }
    }
}
int main()
{
    int i, n, h;
    char str[L], com[9];
    for (i = 0; i < M; i++) H[i][0] = '\0';
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%s %s", com, str);
        if (com[0] == 'i') {
            insert(str);
        }
        else {
            if (find(str))
                printf("yes\n");
            else 
                printf("no\n");
        }
    }
}


Measured memory_bytes: 22576
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    if(S == "Sunny") cout << "Cloudy" << endl;
    else if (S == "Cloudy") cout << "Rainy" << endl;
    else cout << "Sunny" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

int main() {
  
  lint a, b, c; cin >> a >> b >> c;
  lint k; cin >> k;
  int cnt = 0;
  while (b <= a) {
    b *= 2;
    cnt++;
  }
  while (c <= b) {
    c *= 2;
    cnt++;
  }

  if (cnt <= k) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <map>
#define N 100005
using namespace std;
typedef long long ll;
ll x;
int n, m;
vector<string> a, b;
bool check(int x, int y) {
	for (int i = 0; i < m; ++i) {
    	for (int j = 0; j < m; ++j) {
          if (x + i >= n || y + j >= n) return false;
          if (a[x+i][y+j] != b[i][j]) return false;
        }
    }
  return true;
}
int main() {
  cin>>n>>m;
  a.clear();
  b.clear();
  for (int i = 0; i < n; ++i) {
  	string s;
    cin>>s;
    a.push_back(s);
  }
  for (int i = 0; i < m; ++i) {
  	string s;
    cin>>s;
    b.push_back(s);
  }
  bool ok = false;
  for (int i = 0; i < n; ++i) {
  	for (int j = 0; j < n; ++j) {
    	if (check(i, j)) ok = true;
    }
  }
  if (ok) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
while 1:
    n=int(input())
    if n==0:break
    ans=[0]*(n+1)**2
    for i in range(0,n):
        keep=list(map(int,input().split()))
        s_keep=0
        for j in range(n):
            ans[i*(n+1)+j]=keep[j]
            s_keep+=keep[j]
        ans[(i+1)*(n+1)-1]=s_keep
    for i in range(n+1):
        s_keep=0
        for j in range(n+1):
            s_keep+=ans[i+j*(n+1)]
        ans[i+n*(n+1)]=s_keep
    for i in range(n+1):
        for j in range(n+1):
            print(f"{ans[i*(n+1)+j]:>5}",end="")
        print()


Measured memory_bytes: 5632
#include <cstdio>
#include <cctype>

int main(){
	int i=0, a[26]={0};
	char ch;
	
	while( scanf("%c", &ch) != EOF ){
		if( isupper(ch) ) 
			ch = tolower(ch);
	
		if('a'<=ch && ch<='z') 
			++a[ ch-'a' ];
	
		++i;
	}

	for(int x=0; x<26; ++x)
		printf("%c : %d\n", 'a'+x, a[x]);

	return 0;
}

Measured memory_bytes: 976
#include<bits/stdc++.h>
 
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
 
using namespace std;
 
typedef pair<int,int> ii;
const int IINF = INT_MAX;
 
vector<ii> G[100010];
int mincost[100010];
int V,E,r;
 
int main(){
  scanf("%d %d %d",&V,&E,&r);
 
  int s,t,d;
  rep(i,E){
    scanf("%d %d %d",&s,&t,&d);
    G[s].push_back(ii(t,d));
  }
 
  rep(i,V) mincost[i] = IINF;
  mincost[r] = 0;
  deque<int> deq; deq.push_back(r);
  vector<int> in_queue(V,0); in_queue[r] = 1;
 
  while(!deq.empty()){
    int u = deq.front(); deq.pop_front(); in_queue[u] = 0;
    rep(i,(int)G[u].size()){
      int v = G[u][i].first, c = G[u][i].second;
      if( mincost[v] > mincost[u] + c ) {
        mincost[v] = mincost[u] + c;
        if( !in_queue[v] ) {
          deq.push_back(v);
          in_queue[v] = 1;
        }
      }
    }
  }
 
  rep(i,V) {
    if( mincost[i] == IINF ) puts("INF");
    else printf("%d\n",mincost[i]);
  }
 
  return 0;
}

Measured memory_bytes: 12732
import java.util.Scanner;

public class Main {

	static Scanner scan = new Scanner(System.in);

	public static void main(String args[]) {
		
		int n = scan.nextInt();
		boolean[] flag = new boolean[64];
		
		for(int i=0; i<n; i++) {
			
			int query = scan.nextInt();
			
			switch(query) {
			
			case 0:	//test
				int cmd0 = scan.nextInt();
				System.out.println(flag[cmd0] ? 1 : 0);
				break;
				
			case 1: //set
				int cmd1 = scan.nextInt();
				flag[cmd1] = true;
				break;
				
			case 2: //clear
				int cmd2 = scan.nextInt();
				flag[cmd2] = false;
				break;
				
			case 3: //flip
				int cmd3 = scan.nextInt();
				if(flag[cmd3]) {flag[cmd3] = false; 
				}else { flag[cmd3] = true;	//WARNING
				}
				break;
				
			case 4: //all
				int count = 0;
				for(int j=0; j<64; j++) {
					if(flag[j]) count++;
				}
				if(count == 64)	System.out.println(1);
				else System.out.println(0);		
				break;
				
			case 5: //any
				int count2 = 0;
				for(int j=0; j<64; j++) {
					if(flag[j]) count2++;
				}
				if(count2 > 0)	System.out.println(1);
				else System.out.println(0);
				break;
				
			case 6:	//none
				int count3 = 0;
				for(int j=0; j<64; j++) {
					if(flag[j]) count3++;
				}
				if(count3 == 0)	System.out.println(1);
				else System.out.println(0);
				break;
				
			case 7:	//count
				int sum = 0;
				for(int j=0; j<64; j++) {
					if(flag[j]) sum++;
				}
				System.out.println(sum);	
				break;
				
			case 8:	//var
				long sum2 = 0;
				for(int j=0; j<64; j++) {
					long pow = 1;

					if(flag[j]) {
						for(int k=0; k<j; k++) pow *= 2;
						sum2 += pow;
					}
				}
				System.out.println(Long.toUnsignedString(sum2));	
				break;
			}
		}
	}
}


Measured memory_bytes: 78596
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

vector<int> as;

vector<int> bs;
map<ll, int> cs;

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

    as.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> as[i];
    }

    bs.resize(N);
    for (int i = 0; i < N; i++) {
        bs[i] = i + 1 -  as[i];
    }

    for (int i = 0; i < N; i++) {
        cs[as[i] + i + 1]++;
    }

    ll cnt = 0;
    for (int i = 0; i < N; i++) {
        cnt += cs[bs[i]];
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 27488
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(void) {
    int N;cin>>N;
    vector<int> X(N),sort_X(N);
    for (int i = 0; i < N; i++) {
        int x;cin>>x;
        X[i] = x;
        sort_X[i] = x;
    }
    sort(sort_X.begin(), sort_X.end());
    int median = sort_X[N / 2];
    int median_before = sort_X[N / 2 - 1];
    for (int i = 0; i < N; i++) {
        if (X[i] >= median) cout << median_before << endl;
        else cout << median << endl;
    }
    return 0;
}

Measured memory_bytes: 3712
n=int(input())
g=[[]for i in range(n)]
for i in range(n-1):
    a,b=map(int,input().split())
    g[a-1].append((b-1,i))
    g[b-1].append((a-1,i))

def path(i,goal,mam=-1):
    if len(g[i][0])==1 and g[0]==mam:
        return 0
    else:
        for j,idx in g[i]:
            if j==mam:
                continue
            if j==goal:
                return 1<<idx
            p=path(j,goal,i)
            if p>0:
                return p | (1<<idx)
        return 0

m=int(input())
ps=[]
for _ in range(m):
    a,b=map(int,input().split())
    ps.append(path(a-1,b-1))

dp=[0]*(1<<m)
dp[0]=1
for i in range(n-1):
    newdp=[0]*(1<<m)
    hit=0
    for j,p in enumerate(ps):
        a=p & (1<<i)
        if p & (1<<i):
            hit+=1<<j
    for j in range(1<<m):
        newdp[j|hit]+=dp[j]
    for j in range(1<<m):
        dp[j]+=newdp[j]
print(dp[-1])

Measured memory_bytes: 133492
def main():

    num = int(input())
    boss = input().split()

    ans_list = [0] * num
    
    for i_boss in boss:
        #print(f'start for {i_boss}')
        ans_list[int(i_boss)-1] += 1
    a = list(map(lambda  x: str(x), ans_list))
    print('\n'.join(a))


if __name__ == '__main__':
    main()

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

int main()
{
ll n , k ;
cin >> n >> k ;
vector<ll> p(n);
rep(i, n){
  cin >> p[i];
}
vector<ll> pp(n);
ll a=0;
ll rr=0;
rep(i,n-1){
  if(p[i]<p[i+1])a++;
  else a=0;
  if(a>=k-1){
    pp[i-k+2]=1;
    rr++;
  }
}
set<ll> s;
rep(i,k){
  s.insert(p[i]);
}
rep(i,n-k){
  if(pp[i]==0){auto itrmi=s.begin();
  auto itrmx=s.end();itrmx--;
  if(*itrmi==p[i] && *itrmx<p[i+k])ans++;}
  s.erase(p[i]);
  s.insert(p[i+k]);
}
ll an=n-k+1-ans;
if(rr!=0){
  an-=rr-1;
}
cout << an << endl;
return 0;
}

Measured memory_bytes: 12800
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        new Main().compute();
    }

    void compute() {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            int n = sc.nextInt();
            List<Integer> primes = new ArrayList<>();
            check:
            for (int i = 2; i <= n; i++) {
                for (int p : primes) {
                    if (p > Math.sqrt(i)) {
                        break;
                    }
                    if (i % p == 0) {
                        continue check;
                    }
                }
                primes.add(i);
            }
            System.out.println(primes.size());
        }
    }
}


Measured memory_bytes: 60628
#include<bits/stdc++.h>
#define io ios_base::sync_with_stdio(false); cin.tie(NULL);

#define N 1000
#define nl "\n"
#define f first
#define s second
#define pi acos(-1.0)
#define MOD 1000000007
#define pb push_back

typedef long long ll;
typedef double db;

using namespace std;

int a[N+5];
bool checkValidity(int a, int b, int c)
{
    if((a + b > c) && (a + c > b) && (b + c > a))
        return true;
    else
        return false;
}

int main()
{
    io;
    //freopen("in.txt" , "r" , stdin);
    //freopen("out.txt" , "w" , stdout);

    ///Let the showdown begin

    int n;
    cin >> n;

    for(int i=0 ; i<n ; i++)
        cin >> a[i];

    sort(a,a+n);

    ll cnt =0;
    for(int i=0 ; i<n-2 ; i++)
    {
        for(int j = i+1 ; j<n-1 ; j++)
        {
            if(a[i] == a[j])
                continue;
            else
            {
                for(int k = j+1 ; k<n ; k++)
                {
                    if(a[k] != a[j] && a[k] != a[i])
                    {
                        if(checkValidity(a[i],a[j],a[k]))
                            cnt++;
                    }
                }
            }
        }
    }
    cout << cnt << nl;

    ///Happily DONE
    return 0;
}


Measured memory_bytes: 3652
N, x = map(int, input().split())
a_list = sorted(list(map(int, input().split())))
res = 0

for i in range(N-1):
    if x >= a_list[i]:
        res += 1
        x -= a_list[i]
    else:
        break
if x == a_list[N-1]:
    res += 1
    
print(res)

Measured memory_bytes: 3060
def score(x):
    s=0;t=1
    for _ in[0]*10:
        a=2;b=3
        if x[t]==10:a=1
        elif x[t]+x[t+1]!=10:b=2
        s+=sum(x[t:t+b]);t+=a
    return x[0],s

while 1:
    n=int(input())
    if n==0:break
    A=sorted([score(list(map(int,input().split()))) for _ in [0]*n])
    for a,b in sorted(A,key=lambda x:-x[1]):print(a,b)

Measured memory_bytes: 7760
/*
  #問題：
  


  #分析：
  #オブジェクト：
  
  #条件：
  

  #要求：
  

  #解法：
  
*/

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
#include <initializer_list>
#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define uLL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;


const unsigned int BIT_FLAG_0 = (1<<0);
const unsigned int BIT_FLAG_1 = (1<<1);
const unsigned int BIT_FLAG_2 = (1<<2);
const unsigned int BIT_FLAG_3 = (1<<3);
const unsigned int BIT_FLAG_4 = (1<<4);
const unsigned int BIT_FLAG_5 = (1<<5);
const unsigned int BIT_FLAG_6 = (1<<6);
const unsigned int BIT_FLAG_7 = (1<<7);


#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
namespace mp = boost::multiprecision;

using Bint = mp::cpp_int;



int main(void){
  int a,b;
  int k;
  vector<int> array;
  int cnt=0;
  
  cin>>a>>b;
  cin>>k; int k_0=k-1;
  // FOR(i,1,100){
  //   if(a%i==0 && b%i==0){array[cnt]=i; cnt++;}
  // }
  // cout << array[k_0] << "\n";
  for (int i = 1; i <= 100; ++i) {
    if (a%i==0 && b%i==0) {
      array.push_back(i);
    }
  }

  
  for(auto x: array) cerr<<x<<" ";
  cerr<<endl;
  cout<<array[array.size() -k]<<endl;
    
  // std::iota(std::begin(container), std::end(container), );
  // auto Minmax = std::minmax_element(std::begin(container), std::end(container));
  // auto pos = std::max_element(std::begin(container), std::end(container));
  
  
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
signed main(){
  int N,K,X,Y; cin>>N>>K>>X>>Y;
  int ans=min(N,K)*X+max(0LL,N-K)*Y;
  cout<<ans<<endl;
  }


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int n, m;
    char cal;
    while(1){
        cin >> n >> cal >> m;     
        if(cal == '?')
            break;
        if(cal == '+')
            cout << n+m << endl;
        if(cal == '-')
            cout << n-m << endl;
        if(cal == '*')
            cout << n*m << endl;
        if(cal == '/')
            cout << n/m << endl;
    }    
    return 0;
}

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

using namespace std;


int main()
{

	int n;
	cin >> n;

	vector<int> a(n);

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

	sort(a.begin(), a.end());

	int b = 0;
	for (int i = 0; i < n; i++) {
		if (b == a[i]) {
			cout << "NO" << endl;
			return 0;
		}
		else {
			b = a[i];
		}
	}

	cout << "YES" << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(){

    int X, N; cin >> X >> N;
    vector<int> p(N);

    bool flag = false;
    int start, lY, uY;
    int lc=0; 
    int uc=0;

    string S;

    // while ( getline(S, ' ') ){
    //     v.push_back(s);
    // }

    // for (const string& s : v){         // vの中身を出力
    //     cout << s << endl;
    // }

    for(int i=0; i<N; i++){
        cin >> p.at(i);
        if(X == p.at(i)){
            flag = true;
        }
    }
    
    if(!flag){
        cout << X << endl;
        return 0;
    }

    sort(p.begin(), p.end());

    for(int i=0; i<N; i++){
        if(p.at(i) == X){
            start = i;
            break;
        }
    }

    lY = X;
    uY=X;

    for(int i=start; i>=0; i--){
        if(p.at(i) != lY) break;
        lc++;
        lY--;
    }
    for(int i=start; i<N; i++){
        if(p.at(i) != uY) break;
        uc++;
        uY++;
    }

    if(lc <= uc){
        cout << lY << endl;
    }
    else{
        cout << uY << endl;
    }


    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
int dp[100000];
int main(){
	int n;
	cin>>n;
	vector<vector<int> > dp(n, vector<int>(3));
	for(int i = 0; i<n; i++){
		cin>>dp[i][0]>>dp[i][1]>>dp[i][2];
		if(i != 0){
			dp[i][0] += max(dp[i-1][1], dp[i-1][2]);
			dp[i][1] += max(dp[i-1][0], dp[i-1][2]);
			dp[i][2] += max(dp[i-1][0], dp[i-1][1]);
		}
	}
	cout<<max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]));
	return 0;
}


Measured memory_bytes: 5760
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

#define rep(i, n) for(int i = 0; i < n; i++)
#define ALL(T) (T).begin(), (T).end()

using namespace std;

typedef vector<int> vi;

int main(void){
	int d; cin >> d;
	vi dp(d + 1);
	fill(ALL(dp), -1);
	dp[0] = 0;

	int x; cin >> x;
	rep(i, x){
		string ans;
		int s;
		cin >> ans >> s;

		if(ans != "D") continue;

		for(int j = d - 1; j >= 0; j--){
			if(!~dp[j]) continue;
			dp[j + 1] = max(dp[j + 1], dp[j] + s);
		}
	}

	int y; cin >> y;
	rep(i, y){
		string ans;
		int s;
		cin >> ans >> s;

		if(ans != "DD") continue;
		 
		for(int j = d - 2; j >= 0; j--){
			if(!~dp[j]) continue;
			dp[j + 2] = max(dp[j + 2], dp[j] + s);
		}
	}

	cout << *max_element(ALL(dp)) << endl;

	return 0;
}

Measured memory_bytes: 1212
N, M = map(int, input().split())
# 木だったらなんでもOK?
# いもす法

edge = [0] * (N + 1)
for _ in range(M):
    a, b = map(int, input().split())
    edge[a] += 1
    edge[b] -= 1

ans = "YES"
for i in range(N):
    edge[i + 1] += edge[i]
    if edge[i + 1] % 2 == 1:
        ans = "NO"
        break

print(ans)


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

int main(){
    int a[3];
    rep(i,3) cin >> a[i] ;
    sort(a,a+3);
    int ans = 0;
    rep(i,2){
        ans += abs(a[i] - a[i+1]);
    }

    cout << ans << endl;

    
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int abs (int x, int y) {
  return (x > y) ? x - y : y - x;  
}

int main () {
  int n;
  cin >> n;
  int t[n], x[n], y[n];
  for (int i = 0; i < n; i++) {
    cin >> t[i] >> x[i] >> y[i];  
  }  
  for (int i = 0; i < n; i++) {
    if (i == 0) {
      if (x[i] + y[i] <= t[i] &&
          (x[i] + y[i] - t[i]) % 2 == 0) {
        // ok  
      }   
      else {
        cout << "No" << endl;
        return 0;  
      }
    }  
    else {
      int xx = abs(x[i], x[i - 1]);
      int yy = abs(y[i], y[i - 1]);  
      int tt = t[i] - t[i - 1];
      if (xx + yy <= tt && (xx + yy - tt) % 2 == 0) {
        // ok  
      }
      else {
        cout << "No" << endl;
        return 0;  
      }
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define f(i,j,k) for(int i=j;i<k;i++)
using namespace std;
int main(){
    long long h,w,d;
    cin>>h>>w;
    string c[h];
    f(i,0,h){
        cin>>c[i];
    }
    f(i,0,2*h){
        d=i/2;
        cout<<c[d]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3616
from collections import deque

deq=deque()
k = input()
for i in range(len(k)):
	deq.append(k[i])
q=int(input())
x=True
for i in range(q):
	a=input()
	if a[0]=="1":
		x = not x
	elif a[2]=="1":
		if x==True:
			deq.appendleft(a[4])
		else:
			deq.append(a[4])
	else:
		if x==True:
			deq.append(a[4])
		else:
			deq.appendleft(a[4])
if x==True:
	c="".join(deq)
else:
	deq.reverse()
	c="".join(deq)
print(c)


Measured memory_bytes: 8820
import sys
sys.setrecursionlimit(1000000)
input = sys.stdin.readline
from bisect import *
from collections import *
from heapq import *
INF = 500000
mod = 10**9+7

a, b, c = map(int, input().split())
x = a+b
if 4*a*b < (c-x)**2 and c-x > 0:
    print('Yes')
else:
    print('No')


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

int main()
{
	int n;
	int a[5][110], dp[5][110] = { 0 };
	
	std::cin >> n;
	
	for (int i = 0; i < 2; ++i)
	{
		for (int j = 0; j < n; ++j)
		{
			std::cin >> a[i][j];
		}
	}
	
	dp[0][0] = a[0][0];
	dp[1][0] = a[1][0] + a[0][0];
	
	for (int j = 1; j < n; ++j)
	{
		dp[0][j] = dp[0][j - 1] + a[0][j];
		dp[1][j] = std::max(dp[0][j], dp[1][j - 1]) + a[1][j];
	}
	
	std::cout << dp[1][n - 1];
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
#include<set>
using namespace std;


const long long int mod=1000000007;
const long long int INF=99999999999999999;

long long int a,b;
int main() {
	cout << fixed << setprecision(18);
	cin>>a>>b;
	for(int i=0;i<max(a,b);i++){
		cout<<min(a,b);
	}
	
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=200005,INF=1<<20;

int DFS(string S,string T){
    if(S==T) return 0;
    int N=int(S.size());
    
    int mi=INF;
    for(int i=0;i<N;i++){
        if(S[i]!=T[i]){
            int diff=T[i]-S[i];
            if(diff<0) diff+=10;
            for(int j=i;j<N;j++){
                S[j]+=diff;
                if(S[j]>'9') S[j]-=10;
                mi=min(mi,DFS(S,T)+1);
            }
            
            break;
        }
    }
    
    return mi;
}

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        int N;cin>>N;
        if(N==0) break;
        string S,T;cin>>S>>T;
        cout<<DFS(S,T)<<endl;
    }
}





Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
using ll=long long int;
constexpr int  mod = 1e5 + 1;
int main() {
	int n; cin >> n; int m; cin >> m;
	map<int, vector<int>>mp; set<int>s;
	vector<int>v(n); int ans = 0;
	for (int i = 0; i < n; ++i) {
		int val; cin >> val;
		v[i] = val;
	}
	while (m--) {
		int a, b;
		cin >> a >> b;
		s.insert(a); s.insert(b);
		mp[a].push_back(b);
		mp[b].push_back(a);
	}
	for (auto ele : mp) {
		vector<int>res = ele.second; int f = 0;
		int t = ele.first; int ch = v[t - 1];
		for (int ele : res) {
			if (ch <= v[ele - 1]) {
				f = 1; break;
			}
		}
		if (f == 0)ans++;
	}
	cout << ans + n - s.size();
	return 0;
}

Measured memory_bytes: 17256
#include <iostream>
 
using namespace std;
 
typedef long long ll;
 
ll mod = 1000000007;
 
ll Prime_Factorization(ll N, ll *fac, ll mod) {
    ll N_ = N;
    ll ans = 1;
    for (ll i = 2; i*i <= N_; i++) {
        while (N % i == 0) {
            fac[i]++;
            N /= i;
        }
        ans *= fac[i]+1;
        ans %= mod;
    }
    if (N > 1) {
        fac[N]++;
        ans *= 2;
    }
    return ans;
}
 
int main() {
    ll N;  cin >> N;
    ll N_ = N;
 
    ll ans = 1;
    ll *cnt = new ll[N+1];
    for (ll i = 0; i <= N; i++)
        cnt[i] = 0;
 
    for (ll n = 2; n <= N; n++) {
        Prime_Factorization(n, cnt, mod);
    }
 
    for (ll i = 2; i <= N; i++) {
        ans *= cnt[i]+1;
        ans %= mod;
    }
 
    cout << ans << endl;
 
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main(int argc, char const *argv[])
{
    std::string input;
    std::cin >> input;
    std::string current;
    for(char c : input){
        if(c == 'B'){
            if(!current.empty()) current.pop_back();
        } else{
            current += c;
        }
    }
    std::cout << current << '\n';
    return 0;
}


Measured memory_bytes: 3628
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, n) revi(i, 0, n)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define allr(n) (n.rbegin(), n.rend())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

int main() {
  st O, E;
  ci(O, E);
  rep(i, sz(E)){
    cout << O.at(i) << E.at(i);
  }
  if(sz(O) != sz(E)){
    cout << O.at(sz(O) - 1) << endl;
  }
  else{
    cout << endl;
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define mod 1000000007
#define INF2 9999999999
#define INF (1 << 30)
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)

using namespace std;
using ll = __int64_t;

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

void solve(){
    int a, b, t, res=0;
    cin >> a >> b >> t;
    while(a <= t){
        t -= a;
        res += b;
    }
    cout << res << endl;
}

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

Measured memory_bytes: 256
n = int(input())
s = list(map(int,input().split()))
m = int(input())
t = list(map(int,input().split()))



def fn(num):
    left=0
    right=n-1
    mid=(left+right)//2
    while right-left>1:
        if s[mid]>num:
            right=mid
        else:
            left=mid
        mid=(left+right)//2
    if s[left]==num:
        return 1
    elif s[right]==num:
        return 1
    else:
        return 0
ans=0
for i in range(m):
    ans+=fn(t[i])
print(ans)



Measured memory_bytes: 16708
import sys
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

from math import ceil

d, g = na()
pc = nan(d)

ans = inf
for i in range(2 ** d):
    cur = g
    cnt = 0
    for j in range(d - 1, -1, -1):
        p, c = pc[j]
        if i >> j & 1:
            score = (j + 1) * 100 * p + c
            if score < cur:
                cur -= score
                cnt += p
            else:
                cnt += min(p, cur // ((j + 1) * 100))
                cur = 0
                break
    if cnt != 0 and cur == 0:
        ans = min(ans, cnt)

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define mod 1000000007
#define vll vector<ll>
ll val[105],wt[105],ti[100005][105];

ll func(ll sum,ll len)
{
    if(sum<=0) return 0;
    if(len<=0) return 1e16;

    if(ti[sum][len]!=-1) return ti[sum][len];

   return ti[sum][len]=min(func(sum,len-1),wt[len]+func(sum-val[len],len-1));

}


int main() {
	// your code goes here
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,w;
	cin>>n>>w;
	ll sum=0;
	memset(ti,-1,sizeof ti);
	for(ll i=1;i<=n;i++){
        cin>>wt[i]>>val[i];
        sum+=val[i];
	}

    for(ll i=sum;i>=0;i--)
    {
        if(func(i,n)<=w)
        {
            cout<<i<<endl;
            exit(0);
        }
    }
    cout<<"0"<<endl;

  //  ll ans=func(n,w);
   // cout<<ans<<endl;

	return 0;
}



Measured memory_bytes: 82304
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long N,A,B,C,D,E;
  cin>>N>>A>>B>>C>>D>>E;
  long long a,b,c,M;
  a=min(A,B);
  b=min(a,C);
  c=min(b,D);
  M=min(c,E);
  long long count;
  if(A==M){
    if(N%A==0){
      count=N/A+4;
    }
    else{
      count=N/A+5;
    }
  }
  if(B==M){
    if(N%B==0){
      count=N/B+4;
    }
    else{
      count=N/B+5;
    }
  }
  if(C==M){
    if(N%C==0){
      count=N/C+4;
    }
    else{
      count=N/C+5;
    }
  }
  if(D==M){
    if(N%D==0){
      count=N/D+4;
    }
    else{
      count=N/D+5;
    }
  }
  if(E==M){
    if(N%E==0){
      count=N/E+4;
    }
    else{
      count=N/E+5;
    }
  } 
  cout<<count<<endl;
}

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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())

lli data[100100];
bool vis[100100];
lli n,m;
string s;
bool b;

lli func(lli now){
	if(now<0)return INF;
	if(now==0){
		b=true;
		return 0;
	}
	if(b)return INF;
	if(vis[now])return data[now];
	if(DEBUG)cout<<"now="<<now<<endl;
	vis[now]=true;
	if(s.at(now)=='1')return data[now]=INF;

	for(lli i=m;i>=0;i--){
		data[now]=min(data[now],func(now-i)+1);
		if(b==true){
			cout<<i<<" ";
			break;
		}
	}
	return data[now];
}

signed main(){

	lli n;
	cin>>n>>m;
	REP(i,0,100100)data[i]=INF;

	b=false;
	cin>>s;

	data[0]=0;
	if(func(n)==INF){
		cout<<-1<<endl;
		return 0;
	}

	lli now=0;
	lli nowIndex=0;

	lli cnt[100010];

	if(DEBUG){
	REP(i,0,n+1){
		cout<<data[i]<<endl;
	}
	}

	REP(i,0,n+1){
		if(data[i]==INF)continue;
		cnt[data[i]]=i;
	}

	lli size = func(n);
	if(DEBUG){
	REP(i,0,size+1){
		cout<<cnt[i]<<endl;
	}
	}
	cout<<endl;


	return 0;
}

Measured memory_bytes: 4608
#include <iostream>

using namespace std;

int main()
{
	int a, b, sum = 0;

	cin >> a >> b;

	for(int i = a; i <= b; i++)
	{
		if(i/10000 == i%10 && (i/1000 - ((i/10000)*10)) == (i%100 - i%10)/10)
			sum++;
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n;
  cin>>n;
  vector<int>a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  int sum=0;
  for(int i=0;i<n-1;i++){
    for(int j=i+1;j<n;j++){
      sum+=a[i]*a[j];
    }
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 256