akhauriyash/Code-Regression huggingface dataset:
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
//#define int long long

using namespace std;

// conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

typedef long long ll;

const ll MOD = 1e9 + 7;

class FPlayingTagOnTree {
    vector<vector<int>> edges_;

    void fillDepth(const int prev, const int cur, const int depth, vector<int>& leafDepth) {
        if (edges_[cur].size() == 1 && edges_[cur].front() == prev) {
            leafDepth[cur] = depth;
            return;
        }
        for (const auto& next : edges_[cur]) {
            if (next == prev) continue;
            fillDepth(cur, next, depth+1, leafDepth);
        }
    }
public:
	void solve(std::istream& in, std::ostream& out) {
	    int N, u, v;
	    in >> N >> u >> v;
	    vector<int> A(N), B(N);
	    REP(i,1,N) in >> A[i] >> B[i];
	    edges_ = vector<vector<int>> (N+1);
	    REP(i,1,N) {
	        edges_[A[i]].emplace_back(B[i]);
	        edges_[B[i]].emplace_back(A[i]);
	    }
	    vector<int> leafDepthU(N+1), leafDepthV(N+1);
	    fillDepth(-1, u, 0, leafDepthU);
	    fillDepth(-1, v, 0, leafDepthV);
	    int answer = 0;
        REP(i,1,N+1) {
            if (leafDepthU[i] == 0 && leafDepthV[i] == 0 || leafDepthU[i] >= leafDepthV[i]) continue;
            answer = max(answer, leafDepthV[i] - 1);
        }
        out << answer << "\n";
	}
};


signed main() {
	FPlayingTagOnTree solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 9728
#include<iostream>
using namespace std;
int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int step=0;
    while(a>0 && c>0)
    {
        if(step==0)
        {
            c-=b;
            step=1;
        }
        else
        {
            a-=d;
            step=0;
        }
    }
    if(step==1)
    {
        cout << "Yes" ;
    }
    else
    {
        cout << "No";
    }
    return 0;
}



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

typedef long long ll;
typedef pair<ll, ll> pi;
typedef vector<ll> vi;
typedef vector<pi> vpi;

const ll MX = 2e5 + 5;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;

#define F0R(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define re(x) cin >> x
#define ps(x) cout << x << "\n";
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) begin(x), end(x)
#define sz(x) (ll)x.size()
#define rall(x) (x).rbegin(), (x).rend() 
#define rsz resize
#define ins insert 

void setIn(string s) { freopen(s.c_str(),"r",stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }
void setIO(string s = "") {	
		ios_base::sync_with_stdio(0); cin.tie(0); // fast I/O
		// cin.exceptions(cin.failbit); 
		// throws exception when do smth illegal
		// ex. try to read letter llo ll
		if (sz(s)) { setIn(s+".in"), setOut(s+".out"); } // for USACO
}

ll N, W;
ll dp[MX];

int main() {
	setIO();
	re(N), re(W);

	F0R(i, MX) dp[i] = INF;

	dp[0] = 0;
	F0R(i, N) {
		ll a, b; re(a), re(b);
		for (ll j = MX - 1; j >= 0; j--) if (j + b < MX) {
			if (dp[j] != INF && dp[j] + a <= W) {
				dp[b + j] = min(dp[b + j], dp[j] + a);
				//cout << b + j << " " << dp[b + j] << "\n";
			}
		}
	}

	ll ans = 0;
	F0R(i, MX) if (dp[i] != INF) {
		ans = max(ans, i);
	}
	ps(ans);
}







Measured memory_bytes: 5192
def main():
    n, m = map(int,input().split())
    a = [0] * m
    for i in range(m):
        a[i] = int(input())
    ans = [0] * (n+1)
    head = 0
    MOD = 10**9 + 7
    ans[0] = 1
    for i in range(1,n+1):

        if head < m and a[head] == i:
            ans[i] = 0
            head += 1
        else:
            if i == 1:
                ans[i] = 1
            else:
                
                ans[i] = (ans[i-1] + ans[i-2]) % MOD

    print(ans[n] % MOD)



if __name__ == '__main__':
    main()


Measured memory_bytes: 7668
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define pii pair<int,int>
#define pb push_back
#define fi first
#define se second
#define UP(a,b,c) for(ll (a)=(b);(a)<(c);(a)++)
#define UU(a,b,c) for(ll (a)=(b);(a)<=(c);(a)++)
#define DN(a,b,c) for(ll (a)=(b);(a)>(c);(a)--)
#define DU(a,b,c) for(ll (a)=(b);(a)>=(c);(a)--)

int r, c, sx, sy,ex,ey;
char grid[3005][3005];

void reset()
{
}

void input()
{
	cin>>r>>c;
	cin>>sy>>sx;
	cin>>ey>>ex;
	UU(j,1,r)
	{
		UU(i,1,c)
		{
			cin>>grid[j][i];
		}
	}
}

int mx[] = {1, -1, 0, 0};
int my[] = {0, 0, 1, -1};

bool vis[3005][3005] = {0};
int djikstra()
{
	priority_queue<pair<int,pair<int,int> > , vector<pair<int,pair<int,int> > > ,greater<pair<int,pair<int,int> > > >pq;
	pq.push({0,{sx,sy}});
	
	while(!pq.empty())
	{
		int cost = pq.top().fi, x = pq.top().se.fi, y = pq.top().se.se;
		pq.pop();
		if(vis[y][x] == 0)
		{
			vis[y][x] = 1;
			if(y == ey && x ==ex)
			{
				return cost;
				
			}
			UU(j,-2,2)
			{
				UU(i,-2,2)
				{
					int tx = x + i,ty = y + j;
					if(tx < 0 || tx > c || ty < 0 || ty > r)
					{
						continue;
					}
					else if(vis[ty][tx] == 0 && grid[ty][tx] == '.')
					{
						if(abs(j) + abs(i) == 1)
						{
							pq.push({cost,{tx,ty}});
						}
						else
						{
							pq.push({cost + 1,{tx,ty}});
						}
					}
				}
			}
		}
	}
	return -1;
}

void solve()
{
	cout<<djikstra()<<endl;
}

void LetsRock()
{
	solve();	
}

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

		input();
		reset();
		LetsRock();
	
	return 0;
}


Measured memory_bytes: 9872
<?php

function countBills($num_bills, $total_bills)
{

    $num_ten_thousand_jpy = floor($total_bills / 10000);
    $tmp_total = $total_bills - $num_ten_thousand_jpy * 10000;
    $num_five_thousand_jpy = floor($tmp_total / 5000);
    $tmp_total = $tmp_total - $num_five_thousand_jpy * 5000;
    $num_one_thousand_jpy = floor($tmp_total / 1000);
    if ($num_ten_thousand_jpy + $num_five_thousand_jpy + $num_one_thousand_jpy == $num_bills) {
        return "$num_ten_thousand_jpy $num_five_thousand_jpy $num_one_thousand_jpy";
    }

    if ($num_ten_thousand_jpy + $num_five_thousand_jpy + $num_one_thousand_jpy > $num_bills) {
        return "-1 -1 -1";
    }

    $num_ten_thousand_jpy = $num_ten_thousand_jpy - 1;

    for($num_ten_thousand_jpy; 0 <= $num_ten_thousand_jpy; $num_ten_thousand_jpy--) {
        $num_one_thousand_jpy = abs(floor(5 * ($num_bills + $num_ten_thousand_jpy) / 4 - $total_bills / 4000));
        $num_five_thousand_jpy = abs(floor(- ($num_bills + 9 * $num_ten_thousand_jpy) / 4 + $total_bills / 4000));
        if ($num_ten_thousand_jpy + $num_five_thousand_jpy + $num_one_thousand_jpy == $num_bills) {
            return "$num_ten_thousand_jpy $num_five_thousand_jpy $num_one_thousand_jpy";
        }
    }

    return "-1 -1 -1";
}

$input = fgets(STDIN);
list($N, $Y) = explode(" ", $input);
$result = countBills($N, $Y);
echo $result . PHP_EOL;

Measured memory_bytes: 4732
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H, W;
  cin >> H>>W;
  
  char s[100][100];
  for (int i=0;i<H;i++){
        for(int j=0; j<W; j++){
  		  cin >> s[i][j];
        }
  }
  
  char map[102][102];
  
  for (int i=0; i<H+2; i++){
    for(int j=0; j<W+2; j++){
      map[i][j] = '#';
    }
  }
  for (int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      map[i+1][j+1] = s[i][j];
    }
  }
  
  for (int i=0; i<H+2; i++){
    for(int j=0; j<W+2; j++){
      cout << map[i][j];
    }
    cout << endl;
  }
  
  
  
  
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define B
#ifdef A
int main(void)
{
	int a, b;
	cin >> a >> b;
	if (a == b)
		cout << "a == b" << endl;
	else if (a < b)
		cout << "a < b" << endl;
	else
		cout << "a > b" << endl;

	return 0;
}
#endif
#ifdef B
int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	if (a < b && b < c)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}
#endif
#ifdef C
int main()
{
	int a, b;
	cin >> a >> b;
	cout << a *b << " " << 2 * (a + b) << endl;
	return 0;
}
#endif
#ifdef D
int main()
{
	int S;
	cin >> S;
	int h = S / 3600, m = S / 60 % 60, s = S % 60;

	cout << h << ":" << m << ":" << s << endl;

	return 0;
}
#endif

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


int main(){
	long long int LL=1000000007;
	int n,k;
	cin >> n >> k;
	int64_t sum = 0;
	for(int64_t i=k;i<n+2;i++){
		sum = sum + ((n+1-i)*i +1);
		sum = sum%LL;
	}
	cout << sum << endl;
}


Measured memory_bytes: 3568
A,B = map(int,input().split())
coin = 0

if A > B :
    coin = coin + A
    A = A-1
    if A > B:
        coin = coin +A
    else : 
        coin = coin + B
elif B >=A :
    coin = coin + B
    B = B-1
    if A > B:
        coin = coin + A
    else :
        coin = coin + B
    
print(coin)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
int main(){
  ll N;
  cin >> N;
  ll a[N];
  for(ll i = 0; i < N; i++) cin >> a[i];
  ll ans = 1145148931919810;
  for(ll i = -100; i <= 100; i++){
    ll tmp = 0;
    for(ll j = 0; j < N; j++) tmp += (a[j] - i) * (a[j] - i);
    ans = min(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn=2e5+7;

int main()
{
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    if(k<=a){
        printf("%d\n",k);
    }
    else
    if(k>a&&k<=a+b){
        printf("%d\n",a);
    }
    else
    if(k>a+b){
        printf("%d\n",a-(k-a-b));
    }
    return 0;
}


Measured memory_bytes: 3752
#include<bits/stdc++.h>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const long long INF = 1LL << 60;

int main()
{
  int A,B;
  cin >> A >> B;
  cout << max(0,A-2*B);
}


Measured memory_bytes: 256
main :: IO ()
main = do
    [x1, y1, x2, y2] <- fmap (map read . words) getLine :: IO [Int]
    let dx = x1 - x2
        dy = y1 - y2
    putStrLn $ unwords $ map show [x2 + dy, y2 - dx, x1 + dy, y1 - dx]


Measured memory_bytes: 508
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def solve():
    d = []
    for _ in range(3):
        d.append(list(map(int, input().split())))

    N = int(input())
    for _ in range(N):
        b = int(input())
        for i in range(3):
            for j in range(3):
                if d[i][j] == b:
                    d[i][j] = 0

    for i in range(3):
        if sum(d[i]) == 0:
            print("Yes")
            return

    for j in range(3):
        t = 0
        for i in range(3):
            t += d[i][j]
        if t == 0:
            print("Yes")
            return

    if d[0][0] + d[1][1] + d[2][2] == 0:
        print("Yes")
        return

    if d[0][2] + d[1][1] + d[2][0] == 0:
        print("Yes")
        return

    print("No")


def main():
    solve()


if __name__ == '__main__':
    main()


Measured memory_bytes: 9940
#include <stdio.h>
int main(void){
    long long int n, k, a[2000+1];
    scanf("%lld %lld", &n, &k);
    int mod=1000000007;
    for(int i=0; i<n; i++)scanf("%lld", &a[i]);
    
    long long int n_bfr=0, n_aft=0;
    for(int i=0; i<n; i++){
        for(int j=0; j<i; j++)if(a[i]>a[j])n_bfr++;
        for(int j=i; j<n; j++)if(a[i]>a[j])n_aft++;
    }
    long long int ans=(n_bfr+n_aft)*(k*(k-1)/2%mod)+k*n_aft;
    printf("%lld\n", ans%mod);
    return 0;
}


Measured memory_bytes: 1728
#include <iostream>
#include <cstdlib>

using namespace std;

int comp(const void *c1, const void *c2){
        int tmp1 = *(int *)c1;
        int tmp2 = *(int *)c2;
        if(tmp1 > tmp2){
                return -1; 
        }else if(tmp1 == tmp2){
                return 0;
        }else{
                return 1;
        }   
}
int main(){
        int n,i,j;
        int l[3];
        string out;
        cin >> n;
        for(i = 0 ; i < n ; i++){
                for(j = 0 ; j < 3 ; j++){
                        cin >> l[j];
                }   
                qsort(l, 3, sizeof(int), comp);
                if(l[0]*l[0] == l[1]*l[1]+l[2]*l[2]){
                        out += "YES\n";
                }else{
                        out += "NO\n";
                }   
        }   
        cout << out << flush;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <array>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>






int main() {
	int n, k; std::cin >> n >> k;
	std::vector<int> heights(n); for (auto& h : heights) std::cin >> h;
	std::cout << std::count_if(heights.begin(), heights.end(), [k](const int h) {return h >= k; }) << std::endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n);
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

int main()
{
    vector<int> n(4);
    REP(i,4) cin>>n[i];
    SORT(n);
    cout<<(n[0] == 1 && n[3] == 9 && n[2] == 7 && n[1] == 4 ? "YES" : "NO")<<endl;

    return 0;
}


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

const int INF = 1000000000;

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

    int ab[N][2], cd[M][2];
    for (int i = 0; i < N; i++)
    {
        cin >> ab[i][0] >> ab[i][1];
    }
    for (int i = 0; i < M; i++)
    {
        cin >> cd[i][0] >> cd[i][1];
    }
    
    int dist[N][2];
    for (int i = 0; i < N; i++)
    {
        dist[i][0] = INF;
        dist[i][1] = -1;
    }
    
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < M; j++)
        {
            if(dist[i][0] > abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])){
                dist[i][0] = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1]);
                dist[i][1] = j + 1;
            }
        }
    }
    
    for (int i = 0; i < N; i++)
    {
        cout << dist[i][1] << endl;
    }
    
}

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

using namespace std;

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

  string s;
  cin >> s;
  int res = 0;
  int n = s.size();
  for (int i = 0; i < n/2; ++i) {
    if (s[i] != s[n-1-i]) ++res;
  }
  cout << res << endl;

  return 0;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
const int MAXN = 2e5+5;
const int MOD= 998244353;
int n,b[MAXN];
struct node{
    int x,y;
}a[MAXN];
bool cmp(node a,node b){
    return a.x<b.x;
}
struct nd{int id,x;};
ll dp[MAXN];
int main()
{
    scanf("%d",&n);
    rep(i,1,n){
        scanf("%d%d",&a[i].x,&a[i].y);
        a[i].y+=a[i].x-1;
    }
    a[n+1].x=0x3f3f3f3f;
    sort(a+1,a+n+1,cmp);
    rep(i,1,n)b[i]=a[i].x;
    dp[n+1]=1;
    stack<int>st;
    st.push(n+1);
    per(i,n,1){
        while(a[i].y>=a[st.top()].x)st.pop();
        dp[i]=(dp[i+1]+dp[st.top()])%MOD;
        st.push(i);
    }
    printf("%lld\n",dp[1]);
}


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

#define REP(i,n) for(int i=0,_n=(int)(n); i < _n; i++)
typedef long long ll;

const ll MOD = 1e9+7;

int T[100000];
int P[100000];
int X[100000];

void main2() {
  int N; cin >> N;
  REP(i, N) cin >> T[i];
  int M; cin >> M;
  REP(i, M) {
    cin >> P[i] >> X[i];
  }
  int sum = 0;
  REP(i, N) sum += T[i];
  REP(i, M) {
    int d = X[i] - T[P[i] - 1];
    cout << sum + d << endl;
  }
  
}


int main() {
  while (!cin.eof()) {
    main2();
    cin >> ws;
  }
  return 0;
}




Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<climits>
#include<set>
#include<utility>
using namespace std;
typedef long long int ll;
const ll MOD=1e9+7;

int main(){

	int n;
	cin >> n;
	int ans=n;
	for(int i=0; i<=n; i++){
		int cc=0;
		int t=i;
		while(t>0){
			cc+=t%6;
			t/=6;
		}
		t=n-i;
		while(t>0){
			cc+=t%9;
			t/=9;
		}
		if(ans>cc){
			ans=cc;
		}
	}
	cout << ans << endl;

	return 0;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}


int main2() {

  int N = nextInt();
  int K = nextInt();


  if ((N-1)*(N-2)/2 < K) {
    cout << -1 << endl;
  } else {

    bool e[N][N];
    REP(i, N) REP(j, N) e[i][j] = 0;
    REP(i, N-1) e[i][N-1] = 1;
    int k = (N-1)*(N-2)/2;
    for (int i = 0; i < N-1; i++) {
      for (int j = i+1; j < N-1; j++) {
        if (k > K) {
          k--;
          e[i][j] = e[j][i] = 1;
        }
      }
    }

    int m = 0;
    REP(i, N) for (int j = i+1; j < N; j++) if (e[i][j]) m++;
    cout << m << endl;
    for (int i = 0; i < N; i++) {
      for (int j = i+1; j < N; j++) {
        if (e[i][j]) cout << (i+1) << " " << (j+1) << endl;
      }
    }

  }
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


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

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

        if(a[i]==0)
        {
            cout<<0<<endl;
            return 0;
        }
    }

    long long ans=1,max=1e+18;
    for(int i=0;i<n;i++)
    {
        if(ans>max/a[i])
        {
            cout<<-1<<endl;
            return 0;
        }

        else
        {
            ans*=a[i];
        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 4004
import java.util.*;
import java.io.*;

class Main {
  int A, B, len;
  String S;
  char[] cS;
  boolean flg;
  public static void main(String[] args) {
    Main m = new Main();
    m.input();
    m.solve();
    m.out();
  }

  public void input() {
    Scanner sc = new Scanner(System.in);
    A = sc.nextInt();
    B = sc.nextInt();
    S = sc.next();
    cS = S.toCharArray();
    len = cS.length;
  }

  public void solve() {
    if(len == A + B + 1) {
      if(cS[A] == '-') {
        for(int i = 0; i < A; i++) {
          if(cS[i] >= '0' && cS[i] <= '9') {
            flg = true;
          } else {
            flg = false;
            break;
          }
        }
        if(flg == true) {
          for(int i = A + 1; i < len; i++) {
            if(cS[i] >= '0' && cS[i] <= '9') {
              flg = true;
            } else {
              flg = false;
              break;
            }
          }
        }
      } else {
        flg = false;
      }
    } else {
      flg = false;
    }
  }

  public void out() {
    if(flg == true) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}


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

int main (){

  int n,i,cards[4][13],num,si,ni;
  char symbol;

  scanf("%d",&n);

  for(si=0;si<4;si++){
    for(ni=0;ni<13;ni++)cards[si][ni]=1;
  }
  
  for(i=0;i<2*n;i++){

    scanf("%c %d",&symbol,&num);

    if(symbol=='S')cards[0][num-1]=0;
    else if(symbol=='H')cards[1][num-1]=0;
    else if(symbol=='C')cards[2][num-1]=0;
    else if(symbol=='D')cards[3][num-1]=0;
  }
  
  char mark[4]={'S','H','C','D'};

  for(si=0;si<4;si++){
    for(ni=0;ni<13;ni++){
      if(cards[si][ni]==1){
	printf("%c %d\n",mark[si],ni+1);
      }
    }
  }


  return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <list>
#define ll long long
using namespace std;
int main()
{
  ios_base::sync_with_stdio(0);
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if(a>=c && a<=d && b>=c && b<=d){
    int ans = abs(a-b);
    cout << ans << endl;
  }
  else if(c>=a && c<=b && d>=a && d<=b){
    int ans = abs(c-d);
    cout << ans << endl;
  }
  else{
    if(a>c){
      if(d>=a && d<=b){
        int ans = abs(d-a);
        cout << ans << endl;
      }
      else{
        cout << "0" << endl;
      }
    }
    else{
      if(b>=c && b<=d){
        int ans = abs(c-b);
        cout << ans << endl;
      }
      else{
        cout << "0" << endl;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
n = input()
k = int(input())

D = [[[0] * (k+1) for i in range(len(n))] for j in range(2)]

D[0][0][0] = 1
D[0][0][1] = int(n[0]) - 1
D[1][0][1] = 1
kk = 1

for i in range(1, len(n)):
    D[0][i][0] = D[0][i-1][0]
    for j in range(1, k+1):
        D[0][i][j] += D[0][i-1][j-1] * 9 + D[0][i-1][j]
    if n[i] == "0":
        if kk < k+1:
            D[1][i][kk] += D[1][i-1][kk]
    else:
        if kk < k+1:
            D[0][i][kk] += D[1][i-1][kk]
        if kk+1 < k+1:
            D[1][i][kk+1] += D[1][i-1][kk]
            D[0][i][kk+1] += D[1][i-1][kk] * (int(n[i]) - 1)
        kk += 1

print(D[0][-1][-1] + D[1][-1][-1])
# print(D)

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

void Push(int);
int Pop(void);

int S[1000];
int top;

int main(){
	char s[100];
	int num1,num2;


	while(scanf("%s",s)!=EOF){
		if(s[0]=='+'){
			num1=Pop();
			num2=Pop();
			Push(num1+num2);
		}
		else if(s[0]=='-'){
			num2=Pop();
			num1=Pop();
			Push(num1-num2);
		}
		else	if(s[0]=='*'){
			num1=Pop();
			num2=Pop();
			Push(num1*num2);
		}
		else{
			Push(atoi(s));
		}
	}
	printf("%d\n",Pop());

	return 0;
}


void Push(int data){
        
  S[top]=data;	
  top=top+1;
}

int Pop(){
	top=top-1;
	return S[top];
	
}



Measured memory_bytes: 2108
#include<bits/stdc++.h>
using namespace std;
int n;
char s[105],maxn=0,l=0;
int main()
{
//	freopen("highest.in","r",stdin);
//	freopen("highest.out","w",stdout);
	scanf(" %d",&n);
	for(int i=0;i<n;i++)
	{
		scanf(" %c",&s[i]);
		if(s[i]=='I')
			l++;
		else
			l--;
		maxn=max(maxn,l);
	}
	printf("%d\n",maxn);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007
//S.size()
//配列名.Length()
using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<bool> VB;
typedef unsigned long long ll;


int main(void){
	char c; cin>>c;
	cout<<(c == 'a' ||c == 'i' || c=='u'||c=='e'||c=='o'?"vowel":"consonant");
}


Measured memory_bytes: 764
#include<iostream>
#include<vector>
#include<cmath>
#define MAX_COORDINATE 100
#define INF (1<<23)
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
int main()
{
    int n;
    cin>>n;
    vector<int> X(n);
    rep(i,n) cin>>X[i];
    ll ans=INF;
    rep(p,MAX_COORDINATE+1)
    {
        ll ans_tmp=0;
        rep(i,n)
        {
            ans_tmp+=pow(X[i]-p,2);
        }
        if(ans_tmp<ans)ans=ans_tmp;
    }
    cout<<ans<<endl;

    return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;

int main(){
    string s;
    cin>>s;
    int n = s.size();
    int ct = 0;
    for(int i=0; i<n/2; i++){
        if(s[i] != s[n-1-i]) ct++;
    }
    cout<<ct<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string.h>
using namespace std;
int main()
{
	char a;
	cin>>a;
	if(a=='a'||a=='e'||a=='i'||a=='o'||a=='u')
	{
		cout<<"vowel";
	}
	else{
		cout<<"consonant"<<endl;
	}
} 

Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <map>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

using ll = long long int;

int arr[100 * 100 + 10] = {};
int m[101][101] = {};


int main() {

	int h, w, n;

	cin >> h >> w >> n;

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

	int k = 0;

	for (int i = 0; i < h; i++) {
		if (i % 2 == 0) {
			for (int j = 0; j < w; j++) {
				if (arr[k] != 0) {
					m[i][j] = k+1;
					arr[k]--;
				}
				else {
					k++;
					m[i][j] = k + 1;
					arr[k]--;
				}
			}
		}
		else {
			for (int j = w - 1; j >= 0; j--) {
				if (arr[k] != 0) {
					m[i][j] = k + 1;
					arr[k]--;
				}
				else {
					k++;
					m[i][j] = k + 1;
					arr[k]--;
				}
			}

		}
	}

	for (int i = 0; i < h; i++)
		for (int j = 0; j < w; j++)
			cout << m[i][j] << (j == w-1 ? '\n' : ' ');


}



Measured memory_bytes: 384
N, K = map(int, input().split())
S = input()
c = 0
ans = 0
for i, j in zip(S, S[1:]):
    if i != j:
        c += 1
    else:
        ans += 1
if S[0] != S[-1]:
    c -= 1
c //= 2
if c <= K:
    ans += 2*c
    K -= c
    if K > 0 and S[0] != S[-1]:
        ans += 1
else:
    ans += K * 2
print(ans)


Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <map>
#include <queue>
using namespace std;

#define next '\n'
#define sp " "
#define print(x) cout << (x)
#define println(x) cout << (x) << next
#define stop return(0)
#define rep(i, n) for(int (i) = (0); (i) < (n); (++i))
#define FOR(i, start, end) for(int (i) = (start); (i) < (end); (++i))
#define foreach(e, elem) for(auto& (e) : (elem))
#define FAST ios::sync_with_stdio(false); cin.tie(nullptr)
#define size(s) (s).size()
#define all(vec) (vec).begin(), (vec).end()
using ll = long long;
using ull = unsigned long long;

vector<int> v;

int main() {
    FAST;

    int n;
    cin >> n;

    rep(i, n + 1){
        int x = floor(i * 1.08);
        if(x == n){
            println(i);
            stop;
        }
    }

    println(":(");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<vector<vector<char> >,int> P;
const long long int MOD = 1000000007;
const int INF = 1000000000;

string s;
int h, w;
char b[9][9];

void solve(){
    int ta = 0, yo = 0;
    rep(i,s.size()){
        if(s[i] == '/'){
            yo = 0;
            ta++;
            continue;
        }
        if('0' <= s[i] && s[i] <= '9'){
            int j = s[i]-'0';
            while(j){
                j--;
                b[ta][yo] = '_';
                yo++;
            }
        } else{
            b[ta][yo] = s[i];
            yo++;
        }
    }
    h = ta+1; w = yo;
    int x, y, xx, yy;
    cin >> y >> x >> yy >> xx;
    y--; x--; yy--; xx--;
    b[y][x] = '_';
    b[yy][xx] = 'b';
    string ans;
    rep(i,h){
        int now = 0;
        rep(j,w){
            if(b[i][j] == '_'){
                now++;
            } else{
                if(now > 0){
                    char num = '0'+now;
                    ans.push_back(num);
                }
                ans.push_back('b');
                now = 0;
            }
        }
        if(now > 0){
            char num = '0'+now;
            ans.push_back(num);
        }
        if(i != h-1) ans.push_back('/');
    }
    cout << ans << endl;
}

int main(){
    while(cin >> s){
        if(s == "#") break;
        solve();
    }
}

Measured memory_bytes: 3056
import heapq

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

# 交換できるカードを大きい順にリスト化する
exchange1 = []
for m in range(M):
    B, C = map(int, input().split())
    exchange1.append((B, C))
exchange1.sort(key=lambda x: -x[1])
exchange2 = []
for c in exchange1:
    exchange2.extend([c[1]] * c[0])
    # 手持ちのカード枚数を超えたら抜ける
    if len(exchange2) >= N:
        exchange2 = exchange2[:N]
        break

heapq.heapify(A)

for c in exchange2:
    x = heapq.heappop(A)
    if x >= c:
        # 先頭すでに十分大きい場合は抜ける
        heapq.heappush(A, x)
        break
    else:
        x = max(x, c)
        heapq.heappush(A, x)

print(sum(A))


Measured memory_bytes: 25720
#include <iostream>

using namespace std;

int main(){
  int n;
  int c[6]={500,100,50,10,5,1};
  while(cin>>n,n){
    int m=1000-n,a=0;
    for(int i=0;i<6;++i){
      a+=m/c[i];
      m-=m/c[i]*c[i];
    }
    cout<<a<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <iomanip>
#include <typeinfo>
#include <iterator>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <set>
#include <numeric>
using namespace std;

#define all(container) container.begin(), container.end()
#define sortall(container) (sort(container.begin(), container.end()))
#define yn(cond) ((cond) ? (cout << "Yes" << endl) : (cout << "No" << endl))
#define YN(cond) ((cond) ? (cout << "YES" << endl) : (cout << "NO" << endl))
#define LLONG_MAX numeric_limits<long long>::max()
#define INT_MAX numeric_limits<int>::max()

typedef long long       ll;
typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<string>  vs;
typedef vector<char>    vc;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;
typedef vector<vll>		vvll;
typedef vector<vi>		vvi;
typedef vector<vb>		vvb;
typedef vector<vs>		vvs;
typedef vector<vc>		vvc;

typedef struct edge_ {
	ll to;
	ll cost;
} edge;

typedef struct point_ {
	ll x, y;
	point_(ll x = 0, ll y = 0) : x(x), y(y) {}
} point;

constexpr double	PI = 3.14159265358979323846;
constexpr ll		INF = 1 << 15;
constexpr ll		MOD = (ll)1e9 + 7;
constexpr double	EPS = 1e-7;
constexpr int		dy4[4] = { 0, 1, 0, -1 };
constexpr int		dx4[4] = { 1, 0, -1, 0 };
constexpr int		dy8[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };
constexpr int		dx8[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
	for (const T& x : vec) os << x << " ";
	return os;
}

template<typename S, typename T>
istream& operator >> (istream& is, pair<S, T>& p) {
	is >> p.first >> p.second;
	return is;
}

istream& operator >> (istream& is, point& p) {
	is >> p.x >> p.y;
	return is;
}

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

ostream& operator << (ostream& os, const point& p) {
	os << "(" << p.x << " " << p.y << ")";
	return os;
}

/******************************************************************************/
/**********************         Don't make WA !!         **********************/
/******************************************************************************/


int main()
{
	int N;
	cin >> N;
	vi L(2 * N);
	cin >> L;
	sortall(L);
	int ans = 0;
	for (int i = 2 * N - 2; i >= 0; i -= 2)
		ans += L[i];
	cout << ans << endl;

	return 0;
}

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

int main(){
  string s;
  cin>>s;
  for(int i=0;i<s.size();i++){
    if(s[i] == s[i+1]){
      cout<<i+1<<" "<<i+2;
      return 0;
    }
    if(s[i] == s[i+2] && i+2<s.size()){
      cout<<i+1<<" "<<i+3;
      return 0;
    }
  }
  cout<<-1<<" "<<-1;
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;


    ll MOD = 998244353;
    ll dp[1000005];
 
int main() {

    int n,k;
    cin >> n >> k;
    vector<int> l(k);
    vector<int> r(k);
    rep(i,k)    cin >> l[i] >> r[i];
    vector<ll> wa(n+1);

    dp[0] = 1;
    wa[0] = 0;
    rep(i,n) {
        rep(j,k) {
            if(i - r[j] >= 0) {
                dp[i] += (wa[i-l[j]+1] - wa[i-r[j]])%MOD;
            }
            else if(i-l[j] >= 0) {
                dp[i] += (wa[i-l[j]+1] - wa[0])%MOD;
            }
        }
        wa[i+1] += (wa[i]+dp[i])%MOD;
    }
    dp[n-1] = dp[n-1]%MOD;
    if(dp[n-1]<0)   dp[n-1]+=MOD;

    cout<<dp[n-1]<<endl;

 return 0;
}


Measured memory_bytes: 6404
#include <iostream>
#include <vector>
#include <cmath>
#include<iomanip>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> x(n), y(n);
    double ans;

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

    for (int i = 0; i < n; i++)
    {
        for (int j = i; j < n; j++)
        {
            ans += sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j])) * 2/n;
        }
    }
    
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <limits>
#include <sstream>

using namespace std;

int main (void)
{
	int n;
	cin >> n;
	for (int u = 0; u < n; u++)
	{
		int a = 0,b = 0;

		cin >> a >> b;

		int p = 0;
		p = a % b;

		if (a <= b)
		{
			cout << a << endl;
		}
		else if (p == 0)
		{
			cout << b << endl;
		}
		else
		{
			cout << p << endl;
		}
	}
}



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

#define EB emplace_back
#define int double
#define F first
#define S second
#define N 100005
#define ALL(x) x.begin(),x.end()
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)


using namespace std;

int solve(int s) 
{ 
    // finding length 
    int length = s / 3; 
  
    s -= length; 
  
    // finding breadth 
    int breadth = s / 2; 
  
    // finding height 
    int height = s - breadth; 
  
    return length * breadth * height; 
} 

int32_t main()
{
    IOS;

    int tt=1;
    //cin>>tt;
    while(tt--)
    {
        double n; cin>>n;
        int ans = 0;
        cout<<fixed;
        cout<<std :: setprecision(8);
        //for (int i = 1; i <= n; i++)
		//{
			//for(int j = i; j<= n; j++)
			//{
				//ans = max(ans,i*j*(n-i-j));
			//}
			
		//}
		ans = solve(n);
		cout<<(double)ans;


		
		cout<<endl;
    }
    return 0;

}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int bubbleSort(int A[], int N);
static const int M = 100;
int main()
{
    int A[M] ,N;
    cin >> N;
    for(int i=0; i<N; i++){
        cin >> A[i];
    }
    bubbleSort(A, N);
    return 0;
}


int bubbleSort(int A[], int N){
    bool flag  = 1;
    int count = 0;
    
    while(flag){
        flag  = 0;
        
        
        for(int j = N-1; j>=1; j--){
        
            
            if( A[j] < A[j-1] ) {
                
                int v  = A[j];
                A[j]   = A[j-1];
                A[j-1] = v;
                flag = 1;
                count++;
            }
        }
    }
    for(int i = 0; i<N; i++) {
        
        if(i>0) cout <<" ";
        cout << A[i]; 
        if(i==N-1) cout <<"\n";
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 3112
import math

a, b, h, m = map(int, input().split())

h_angle = 2*math.pi*(h+m/60)/12

m_angle = 2*math.pi*m/60

theta = abs(h_angle-m_angle)

print(math.sqrt(a*a+b*b-2*a*b*math.cos(theta)))


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

int main() {
    int N;
    cin >> N;
    
    if (N<=9) cout << N << endl;
    else if (10<=N && N<=99) cout << 9 << endl;
    else if (100<=N && N<=999) cout << 9 + N - 100 + 1 << endl;
    else if (1000<=N && N<=9999) cout << 909 << endl;
    else if (10000<=N && N<=99999) cout << 909 + N - 10000 + 1 << endl;
    else if (N == 100000) cout << 90909 << endl;
}

Measured memory_bytes: 256
N,K=gets.split.map(&:to_i)
connected=Array.new(N,1)
visited=Array.new(N,false)
edge=Array.new(N){Array.new}

(N-1).times do
    a,b=gets.split.map(&:to_i)
    edge[a-1].push(b-1)
    edge[b-1].push(a-1)
end

queue=Array.new
queue.push([-1,0])
res=1
until queue.empty?
    parent,e=queue.shift
    next if visited[e]
    if parent==-1 && e==0
        res*=K
        parent=0
        visited[e]=true
        edge[e].each do |n|
            queue.push([e,n])
        end
    else
        res*=K-connected[parent]
        res%=1000000007
        connected[parent]+=1
        connected[e]+=1
        visited[e]=true
        edge[e].each do |n|
            queue.push([e,n])
        end
    end 
end
puts res

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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define ALL(a) a.begin(),a.end()
#define INIT(a,b) memset(a,b,sizeof(a))
using lint = long long int;

int main() {
    int N;
    lint D;
    cin >> N >> D;

    int ans = 0;
    for_(i,0,N) {
        lint x, y;
        cin >> x >> y;
        lint dst = x * x + y * y;
        if (dst <= D * D) ++ans;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
 
#define FOR(i, x, n) for(ll i = x; i < n; i++) 
#define pb push_back
#define pf push_front
#define ll long long
#define hii cout << "hii" << endl
#define pii pair<int, int>
#define pll pair<ll, ll>
#define int ll
#define mpp make_pair
#define endl '\n'
#define ff first 
#define ss second
#define vi vector<int>
#define all(s) s.begin(), s.end()
#define si size()
 
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; } 
 
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE
 
 
const int N = 5e5 + 5;
const int MAXN = 1e5 + 5;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const int INF = 1e15;
const int LG = 21;
 
int arr[N];
int posn[N];
int prime[N];

int DP[N];
int k;

int divisors(int n)
{
	int cnt = 0;
	for(int i = 1; i * i <= n; i++)
	{
		if(n % i == 0)
		{
			cnt += 2;
			cnt -= (i * i == n);
		}
	}
	return cnt - 1;
}

int f(int idx)
{
	if(idx < 1)
	{
		return 0;
	}
	if(idx == 1)
	{
		return 1;
	}
	int ret = 0;
	if(idx % k == 0)
	{
		return f(idx / k);
	}
	else
	{
		return ((idx - 1) % k == 0);
	}
}
 
void solve() 
{
	int n;
	cin >> n;
	vector<int> v;
	for(int i = 1; i * i <= n; i++)
	{
		if(n % i == 0)
		{
			v.push_back(i);
			if(i * i != n) v.push_back(n / i);
		}
	}
	int ret = divisors(n - 1);
	for(int x : v)
	{
		if(x == 1) continue;
		k = x;
		ret += f(n);
	}
	cout << ret << endl;
}
 
 
int32_t main() 
{	
    ios_base:: sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	    int t = 1;
	    // cin >> t;
	while(t--)solve();
	return 0;
}

Measured memory_bytes: 764
N, K, L = map(int, input().split())

def fp(x, parentList): #findParent
    if parentList[x] == x:
        return x
    else:
        parentList[x] = fp(parentList[x], parentList)
        return parentList[x]

#各ノードのparentをリストで表現(連結前は自身がparent)
road = [i for i in range(N)]
rail = [i for i in range(N)]

for _ in range(K):
    p, q = map(int, input().split())
    par_p, par_q = fp(p-1, road), fp(q-1, road) #p, qのparent 
    #連結する際、若い番号をparentとする
    if par_p < par_q:
        road[par_q] = par_p
    else:
        road[par_p] = par_q

#railについても同様
for _ in range(L):
    s, t = map(int, input().split())
    par_s, par_t = fp(s-1, rail), fp(t-1, rail)
    if par_s < par_t:
        rail[par_t] = par_s
    else:
        rail[par_s] = par_t

#連結成分の要素をカウント
cnt = {}
for i in range(N):
    key = (fp(i,road),fp(i,rail))
    if key in cnt:
        cnt[key] += 1
    else:
        cnt[key] = 1
#出力
for i in range(N):
    key = (fp(i,road),fp(i,rail))
    ans = cnt[key]
    print(ans, end=" ")


Measured memory_bytes: 55620
#include <vector>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
using namespace std;

int main(){
    int w,a,b;
    cin >> w >> a >> b;
    if(a+w<b){
        cout << b-(a+w);
    }else if(a<b&&b<a+w&&a+w<b+w){
        cout << 0;//min(a+w-b,b-a);
    }else if(b<a&&a<b+w&&b+w<a+w){
        cout << 0;//min(a+w-(b+w),b+w-a);
    }else if(b+w<a){
        cout << a-(b+w);
    }else if(a==b||a+w==b||a==b+w||a+w==b+w){
        cout << 0;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
int
int_cmp(const int*a, const int *b){
  if(*a < *b){
    return -1;
  }
  else if(*a > *b){
    return 1;
  }
  else {
    return 0;
  }
}
long long int wari(long long int n){
  int warin=0;
  do{
  warin++;
  n=n/2;
}while(n/2!=0);
return warin;
}

int main(void){
  long long int h;
  scanf("%lld",&h);
  long long int record[100];
  int i;

  long long int ans=0;
  //kiroku hituyou kamo
  for(i=0;i<=wari(h);i++){
    ans=ans+pow(2,i);
  }
  if(h==1){
    ans=1;
  }
  printf("%lld",ans);


  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc1 = new Scanner(System.in);

		int a = sc1.nextInt();
		int b = sc1.nextInt();

		if ((a * b) % 2 == 0) {
			System.out.println("No");
		}
		else {
			System.out.println("Yes");
		}

		sc1.close();

	}

}


Measured memory_bytes: 23636
#include <iostream>
#include<bits/stdc++.h>
#include <algorithm> 
#include<map>
#include<string>
#include<unordered_map>
#include <set>
#include <unordered_set>
using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	long long d,t,s;
	cin >> d>>t>>s;
	vector<long long>arr;
	long long ans = 0;
	if (t*s >= d) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	
	
	return 0;
}

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

int main() {
  int64_t a,b,c,d;
  cin >> a >> b >> c;
  d = c - a - b;
  if(d <= 0){
    cout << "No" << endl;
  }
  else if(d * d > 4 * a * b){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}



Measured memory_bytes: 256
#pragma region include
#include <stdio.h>
#include <string>
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#pragma endregion
using namespace std;

#pragma region 定数
#define INF_VAL (2147483647 - 1)
#define INF_VAL_MINUS -INFVAL
#pragma endregion

#pragma region マクロ
// 配列の長さを取得する(ただし関数内ではポインタサイズに注意)
#define SIZE_OF_ARRAY(array) sizeof(array) / sizeof(*array)

// for文
#define forn(i, size) for (long long(i) = 0; (i) < (size); (i)++)
#define for0(size) for (long(i) = 0; (i) < (size); (i)++)

// ソート
#define Sort(array, length) sort(array, array + length)
#define SortDESC(array, length, type_name) sort(array, array + length, std::greater<type_name>())

// 配列の最大値、最小値取得
#define MAX_OF_ARRAY(array, length) *max_element(array, array + length)
#define MIN_OF_ARRAY(array, length) *min_element(array, array + length)

// 結果出力系
#define YES                    \
    {                          \
        cout << "YES" << endl; \
        return 0;              \
    }
#define NO                    \
    {                         \
        cout << "NO" << endl; \
        return 0;             \
    }
#define Yes                    \
    {                          \
        cout << "Yes" << endl; \
        return 0;              \
    }
#define No                    \
    {                         \
        cout << "No" << endl; \
        return 0;             \
    }
#pragma endregion

#pragma region Utility
#pragma region 配列要素の合計値を取得
template <typename T>
T getSum(T array[], int length)
{
    T sum = 0;
    for (int i = 0; i < length; i++)
    {
        sum += array[i];
    }
    return sum;
}
#pragma endregion

#pragma region ToString(int)
string ToString(int i)
{
    char buffer[1000];
    sprintf(buffer, "%d", i);
    return string(buffer);
}
#pragma endregion

#pragma region 10進数からN進数(<= 10) へ変換
string convertToN(long n, int base)
{
    string ans = "";
    while (n != 0)
    {
        int temp = n % base; // 1桁取得
        ans = ToString(temp) + ans;
        n /= base;
    }
    return ans;
}
#pragma endregion
#pragma endregion

int main()
{
    // 標準入力から値を取得
    int A, B;
    cin >> A >> B;

    int ans_A = ceil(A / 0.08);
    int ans_B = ceil(B / 0.10);

    for (int i = min(ans_A, ans_B); i <= max(ans_A, ans_B); i++)
    {
        int tax_A = i * 0.08;
        int tax_B = i * 0.10;
        //printf("%d %d\n", tax_A, tax_B);
        if (tax_A == A && tax_B == B)
        {
            printf("%d\n", i);
            return 0;
        }
    }

    // 結果出力
//    printf("%d %d\n", ans_A, ans_B);
    printf("%d\n", -1);
}


Measured memory_bytes: 256