akhauriyash/Code-Regression huggingface dataset:
#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())

signed main(){

	lli a,b,c,d,e,f;
	cin>>a>>b>>c>>d>>e>>f;

	//全探索で水を全部作る
	//また全探索で砂糖を全部作る
	//最後に水と砂糖のマッチングを行い、
	//一番近いものを出力する

	lli waters[3100];
	REP(i,0,3100)waters[i]=0;
	lli now=0;
	while(now<3100){
		waters[now] = 1;
		now+=a*100;
	}
	REP(i,0,3100){
		if(waters[i]==0)continue;
		now=i+b*100;
		while(now<3100){
			waters[now]=1;
			now+=b*100;
		}
	}

	lli sugars[3100];
	REP(i,0,3100)sugars[i]=0;
	
	now=0;
	while(now<3100){
		sugars[now]=1;
		now+=c;
	}

	REP(i,0,3100){
		if(sugars[i]==0)continue;
		now = i+d;
		while(now<3100){
			sugars[now]=1;
			now+=d;
		}
	}

	double maxM=0;
	lli maxW=0;
	lli maxS=0;

	REP(i,1,3100){
		if(waters[i]==0)continue;
		lli nowW=i;
		//if(DEBUG)cout<<"nowW="<<nowW<<endl;
		REP(j,0,3100){
			if(sugars[j]==0)continue;
			lli nowS=j;
			//if(DEBUG)cout<<"nowS="<<nowS<<endl;
			lli av = nowW/100 * e;
			if(nowS<=av && (nowW+nowS)<=f){
				double nowM = (100*nowS)/(double)(nowW+nowS);
				if(nowM>=maxM){
					if(DEBUG)cout<<"nowM"<<nowM<<"nowW="<<nowW<<"nowS="<<nowS<<endl;
					maxM=nowM;
					maxW=nowW+nowS;
					maxS=nowS;
				}
			}
		}
	}

	cout<<maxW<<" "<<maxS<<endl;




	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<int>>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18;
const int MOD = 1e9 + 7;

int main() {
    int r;
    cin >> r;
    cout << r*r << endl;
    return 0;
}


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

typedef int64_t Int;
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << '\n'; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << '\n';
}

int main() {
    Int n;
    while (cin >> n and n) {
        Int m;
        cin >> m;
        vector<vector<pair<Int, Int>>> a(4, vector<pair<Int, Int>>(m - 1));
        vector<pair<Int, Int>> p(m);
        for (Int i = 0; i < m; i++) {
            cin >> p[i].first >> p[i].second;
        }
        for (Int i = 0; i < m - 1; i++) {
            a[0][i] = {p[i + 1].first - p[i].first, p[i + 1].second - p[i].second};
            a[1][i] = {-a[0][i].second, a[0][i].first};
            a[2][i] = {-a[0][i].first, -a[0][i].second};
            a[3][i] = {-a[1][i].first, -a[1][i].second};
        }
        vector<vector<pair<Int, Int>>> b(n);
        for (Int i = 0; i < n; i++) {
            Int l;
            cin >> l;
            vector<pair<Int, Int>> c(l);
            for (Int j = 0; j < l; j++) {
                cin >> c[j].first >> c[j].second;
            }
            b[i].reserve(l - 1);
            for (Int j = 0; j < l - 1; j++) {
                b[i][j] = {c[j + 1].first - c[j].first, c[j + 1].second - c[j].second};
            }
            if (m != l) continue;
            vector<pair<Int, Int>> d(l - 1);
            for (Int k = 0; k < l - 1; k++) {
                d[k] = b[i][k];
            }
            reverse(all(d));
            for (Int j = 0; j < l - 1; j++) {
                d[j] = {-d[j].first, -d[j].second};
            }
            bool check = false;
            for (Int j = 0; j < 4; j++) {
                bool check2 = true;
                for (Int k = 0; k < min(l - 1, m - 1); k++) {
                    if (a[j][k] != b[i][k]) {
                        check2 = false;
                    }
                }
                if (check2) {
                    check = true;
                }
            }
            for (Int j = 0; j < 4; j++) {
                bool check2 = true;
                for (Int k = 0; k < min(l - 1, m - 1); k++) {
                    if (a[j][k] != d[k]) {
                        check2 = false;
                    }
                }
                if (check2) {
                    check = true;
                }
            }
            if (check) {
                print(i + 1);
            }
        }
        print("+++++");
    }
    return 0;
}



Measured memory_bytes: 3064
#include <stdio.h>
int main(void){
    int D,G,i,j,k,res=1<<30;
    int p[100],c[100];
    scanf("%d%d",&D,&G);
    for(i=0;i<D;i++) scanf("%d%d",&p[i],&c[i]);
    for(i=0;i<(1<<D);i++){
        int sum=0,cnt=0;
        for(j=0;j<D;j++){
            if(i&(1<<j)){
                sum+=p[j]*100*(j+1)+c[j];
                cnt+=p[j];
            }
        }
        if(sum<=G){
            for(j=D-1;j>=0;j--){
                if(i&(1<<j)) continue;
                for(k=0;k<p[j];k++){
                    if(sum>=G) break;
                    sum+=100*(j+1);
                    cnt++;
                }
            }
        }
        if(res>cnt) res=cnt;
    }
    printf("%d\n",res);
    return 0;
}


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

using namespace std;

const int OO = 1e9;
const double EPS = 1e-9;

#define ndl cout << '\n'
#define sz(v) int(v.size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define present(a, x) (a.find(x) != a.end())
#ifdef LOCAL
#define db(...) ({cout << "> Line " << __LINE__  \
		<< ": "; _db(#__VA_ARGS__, __VA_ARGS__);})
#define RNG() rng()
#else
#define db(...) true
#define RNG() true
#endif

template<class T>
void _db(const char *dbStr, T e) {
	cout << dbStr << " = " << e << endl;
}
template<class T, class... L>
void _db(const char *dbStr, T e, L... r) {
  while(*dbStr != ',') cout << *dbStr++;
  cout << " = " << e << ','; _db(dbStr + 1, r...);
}
template<class S, class T>
ostream& operator<<(ostream& o, const map<S, T>& v) {
	o << "["; int i = 0;
	for (const pair<S, T>& pr : v) o << (!i++ ? "" : ", ") << "{"
	<< pr.fs << " : " << pr.sc << "}"; return o << "]";
}
template<template <class, class...> class S, class T, class... L>
ostream& operator<<(ostream& o, const S<T, L...>& v) {
	o << "["; int i = 0;
	for (const auto& e : v) o << (!i++ ? "" : ", ") << e;
	return o << "]";
}
template<class S, class T>
ostream& operator<<(ostream& o, const pair<S, T>& pr) {
	return o << "(" << pr.fs << ", " << pr.sc << ")";
}
ostream& operator<<(ostream& o, const string& s) {
	for (const char& c : s) o << c;
	return o;
}

template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
template<class T> using VVV = VV<V<T>>;
using ll = long long;
using pii = pair<int, int>;
using vi = V<int>;
using vii = V<pii>;
using vvi = VV<int>;
using mii = map<int, int>;
using umii = unordered_map<int, int>;
using si = set<int>;
using usi = unordered_set<int>;





int main() {
	#ifdef LOCAL
	auto stTime = clock();
//	freopen("in.txt", "r", stdin);
	mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
	#endif
	ios::sync_with_stdio(false);
	cout.precision(10);
	cin.tie(0);

	string s;
	cin >> s;
	for (int i = 0; i < sz(s); ++i) {
		cout << 'x';
	}
	ndl;



	#ifdef LOCAL
	cout << "\n\n\nExecution time: " <<
		(clock() - stTime) * 1e3 / CLOCKS_PER_SEC << " ms" << endl;
	#endif
	return 0;
}


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

int main() {
    int a,b;
    cin >> a >> b;
    cout << a*b << endl;
    return 0;
}


Measured memory_bytes: 3652
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	fmt.Printf("%d:", n)
	for i := 2; i*i <= n; i++ {
		for n%i == 0 {
			fmt.Printf(" %d", i)
			n /= i
		}
	}
	if n > 1 {
		fmt.Printf(" %d", n)
	}
	fmt.Println("")
}



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

const int BASE = 6200;
int N, mod;
int dp[6009][12409][3];
long long ret[12409];

void solve(int p1, int p2) {
	// 最大値を更新する場合
	for (int i = 0; i <= 2; i++) {
		int r = 0;
		if (i == 0) r = -1;
		if (i == 1) r = 1;
		dp[p1][p2][0] += 1LL * dp[p1 - 1][p2 - r][i] % mod;
		if (dp[p1][p2][0] >= mod) dp[p1][p2][0] -= mod;
	}

	// 最大値を更新しない場合
	for (int i = 1; i <= 2; i++) {
		dp[p1][p2][i] += 1LL * (p1 - 1LL) * dp[p1 - 1][p2][i - 1] % mod;
		if (dp[p1][p2][i] >= mod) dp[p1][p2][i] -= mod;
	}
}

int main() {
	cin >> N >> mod;
	dp[1][BASE][0] = 1;

	for (int i = 2; i <= 3 * N; i++) {
		for (int j = 1; j <= BASE * 2 - 1; j++) {
			solve(i, j);
		}
	}

	for (int i = 1; i <= BASE * 2 - 1; i++) {
		for (int j = 0; j <= 2; j++) {
			int r = 0;
			if (j == 0) r = -1;
			if (j == 1) r = 1;
			ret[i + r] += dp[3 * N][i][j];
		}
	}

	long long Answer = 0;
	for (int i = 0; i <= BASE; i++) Answer += ret[i];
	cout << Answer % mod << endl;
	return 0;
}

Measured memory_bytes: 875972
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <numeric>
#include <complex>

using namespace std;

typedef long long ll;

#define mp make_pair
#define pb push_back
#define PI 3.1415926535897932384626433832795

#define fill(x, v)  fillchar(x, v, sizeof(x))
typedef pair<int, int>  pii;
typedef vector<int>     vi;
typedef vector< pii >   vpii;

#define MAXN 1010
#define MOD (int)(1e9 + 7)

char s[MAXN];
int f[MAXN][MAXN];
int r, c;

int main() {
    scanf("%i%i", &r, &c);
    for(int i = 0; i < r; ++i) {
        scanf("%s", s);
        for(int j = 0; j < c; ++j) {
            if (i + j == 0) {
                f[i][j] = 1;
                continue;
            }

            if (s[j] == '#') continue;
            if (j > 0) f[i][j] = (f[i][j] + f[i][j - 1]) % MOD;
            if (i > 0) f[i][j] = (f[i][j] + f[i - 1][j]) % MOD;
        }
    }

    printf("%i\n", f[r - 1][c - 1]);

    return 0;
}

Measured memory_bytes: 4224
def run():
    s=input()
    command_num=int(input())
    
    for i in range(command_num):
        command = input().split()
        command = list(map(lambda x: int(x) if x.isdigit() else x,command))
        
        # print(s)
        if command[0] == "print":
            a=command[1]
            b=command[2]
            print(s[a:b+1])
            
        elif command[0] == "reverse":
            a=command[1]
            b=command[2]
            
            rev=s[a:b+1]
            rev=rev[::-1]
            #境界処理がめんどくさい
            pre= "" if a==0 else s[0:a]
            post="" if b==len(s)-1 else s[b+1:]
            
            s=pre+rev+post
            
            
        elif command[0] == "replace":
            a=command[1]
            b=command[2]
            p=command[3]
            #境界処理がめんどくさい
            pre= "" if a==0 else s[0:a]
            post="" if b==len(s)-1 else s[b+1:]
            
            s=pre+p+post
            
        else:
            assert False

run()


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

#define lli long long int
#define ii pair<int, int>
#define ll pair<lli, lli>
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mp make_pair
#define fi first
#define se second

using namespace std;

lli bigmod = 1000000007;

lli fex(lli a, lli b) {
	lli ret;
	if (b == 0)
		return 1;
	ret = fex(a, b / 2);
	ret = (ret * ret) % bigmod;
	if (b & 1)
		ret = (ret * a) % bigmod;
	return ret;
}

int main() {
	lli n, x[100005], f, dist, temp, ans = 0, mul = 0;
	scanf("%lld", &n);
	f = 1;
	for (lli i = 2; i < n; i++)
		f = (f * i) % bigmod;
	for (lli i = 0; i < n; i++)
		scanf("%lld", &x[i]);
	for (lli i = 1; i < n; i++) {
		dist = x[i] - x[i - 1];
		temp = (f * fex(i, bigmod - 2)) % bigmod;
		mul = (mul + temp) % bigmod;
		temp = (mul * dist) % bigmod;
		ans = (ans + temp) % bigmod;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <string.h>
using namespace std;
int main()
{
    int A,B,C,X,cnt=0;
    cin>>A>>B>>C>>X;
    for(int i=0;i<=A;i++)
        for(int j=0;j<=B;j++)
            for(int d=0;d<=C;d++){
                if(500*i+100*j+50*d==X)
                    cnt++;} 
    cout<<cnt<<endl;
return 0;
}


Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def LS(): return [list(x) for x in sys.stdin.readline().split()]


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


def LIR(n):
    return [LI() for i in range(n)]


def SR(n):
    return [S() for i in range(n)]


def LSR(n):
    return [LS() for i in range(n)]


sys.setrecursionlimit(1000000)
mod = 1000000007


def solve():
    n = I()
    sli = [input() for i in range(n)]
    rank = defaultdict(lambda: 0)
    for i in sli:
        rank[i] += 1
    rank = list(rank.items())
    rank.sort(key=lambda x: (-x[1], x[0]))
    for i, j in rank:
        if j == rank[0][1]:
            print(i)


# Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 119248
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<ll>a(n),b(m),c(m);
    rep(i,n)cin >> a[i];
    sort(a.rbegin(),a.rend());
    priority_queue<pair<ll,ll>>pq;
    rep(i,n)pq.emplace(a[i],1);
    rep(i,m){
        cin >> b[i] >> c[i];
        pq.emplace(c[i],b[i]);
    }
    ll ans = 0;
    int cnt = 0;
    while(cnt < n){
        auto x = pq.top();
        pq.pop();
        ans += x.first;
        cnt++;
        x.second--;
        if(x.second>0)pq.push(x);
    }
    cout << ans << endl;
}

Measured memory_bytes: 8432
using System;
using System.Collections.Generic;
using System.Linq;
using console=System.Console;
namespace AtCoderTemplate
{
    public class App
    {
        public static void Main(string[] args)
        {
            var p = console.ReadLine();
            if(p.Count()==26)
            {
                 var q = p.Skip(1).Zip(p,(a,b)=>a-b);
                 var r = p.Count() - 1 - q.Reverse().TakeWhile(i=>i<0).Count();
                 if(r==0)
                 console.WriteLine(-1);
                 else
                 {
                 var s = p.Take(r).ToArray();
                 s[r-1]=p.Last(c=>c>s[r-1]);
                 console.WriteLine(string.Join("",s));
                 }
            }
            else
                console.WriteLine(p +(char)('a'+ p.OrderBy(c=>c).Where((c,i)=>c-i=='a').Count()));
        }
    }
}


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

using namespace std;

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();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

const int w = 15, h = 19;

typedef pair<int, pair<int, pii>> State;
#define F first
#define S second

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

int main(void){
    vs field(h + 2);

    rep(x, w + 2) field[0].pb('#'), field[h + 1].pb('@');

    pii s;
    map<pii, int> stone_id;
    int cnt_id = 0;

    range(y, 1, h + 1){
        cin >> field[y];
        field[y] = "#" + field[y] + "#";

        if(y == h) range(x, 1, w + 1) if(field[y][x] == '.') field[y][x] = '@';
        rep(x, w + 2){
            if(field[y][x] == 'O') s = mp(y, x), field[y][x] = '.';
            if(field[y][x] == 'X'){
                stone_id[mp(y, x)] = cnt_id++;
            }
        }
    }

    queue<State> q;
    q.push(mp(0, mp(0, s)));

    int res = -1;
    while(!q.empty()){
        int cur_stones = q.front().F; 
        pii cur_pos = q.front().S.S;
        int cur_turn = q.front().S.F; q.pop();

        if(field[cur_pos.F][cur_pos.S] == '@'){
            res = cur_turn;
            break;
        }

        rep(i, 8){
            int next_stones = cur_stones;
            pii next_pos = cur_pos;
            int next_turn = cur_turn + 1;
         
            while( field[next_pos.F + dy[i]][next_pos.S + dx[i]] == 'X' &&
                 !((next_stones >> stone_id[mp(next_pos.F + dy[i], next_pos.S + dx[i])]) & 1)){
                next_pos.F += dy[i];
                next_pos.S += dx[i];

                int id = stone_id[next_pos];
                next_stones |= (1 << id);
            }

            if(cur_pos == next_pos || field[next_pos.F += dy[i]][next_pos.S += dx[i]] == '#') continue;

            State next = mp(next_stones, mp(next_turn, next_pos));
            q.push(next);
        }
    }

    cout << res << endl;

	return 0;
}

Measured memory_bytes: 21616
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <array>
#include <math.h>
#include <sstream>
typedef long long ll;
using namespace std;

int main(int argc, char const *argv[])
{
    int h, w;
    std::cin >> h >> w;
    vector<vector<char>> a(h);
    int count = 0;
    for (int i = 0; i < h; i++) {
        a[i].resize(w);
    }
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            std::cin >> a[i][j];
        }
    }
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (a[i][j] == '#') count++;
        }
    }
    if (count > h+w-1) {
        std::cout << "Impossible" << std::endl;
    } else {
        std::cout << "Possible" << std::endl;
    }
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define pb(a) push_back
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), (n))
#define ub(v,n) upper_bound(v.begin(), v.end(), (n))
#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
const int MOD = 1e9+7; const int MAX = 200020;
const double pi = acos(-1); const double EPS = 1e-12;
const ll INF = 1e18;


void solve() {
	int K, A, B; cin >> K >> A >> B;
	if (K < A) {
		print(K + 1); return;
	}
	if (A+1 < B) {
		K -= A - 1;
		int c = K / 2;
		ll sum = A;
		sum += c * (B - A);
		if (K & 1)sum++;
		print(sum);
	}
	else print(K + 1);
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q; cin >> q;
	//while (q--)
	solve();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  string s;
  cin >> s;
  int n = s.size();
  int cnt = 0;
  int ans = 0;
  rep(i,n){
    char c = s[i];
    if(c=='A'||c=='C'||c=='G'||c=='T') cnt++;
    else{
      ans = max(ans,cnt);
      cnt = 0;
    }
  }
  ans = max(ans,cnt);
  cout << ans << endl;
  return 0;
}


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

typedef long long ll;

ll ans, now = 100, n;

int main() {
	cin>>n;
	for(int i = 1; i; i++) {
		now = now + now/100;
		if(now >= n) {
			cout<<i<<endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3636
# ABC 127, B - algae
tmp = [int(el) for el in input().split(' ')]
r = tmp[0]
d = tmp[1]
X = [0 for i in range(11)]
X[0] = tmp[2]


for i in range(1, 11):
    X[i] = r*X[i-1] - d
    print(X[i])


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

const ll MAX = 200000;
const ll INF = 1001001001;
const ll MOD = 1000000007;

ll N, D, ans=0, tmp=0;
vector<ll> A;

signed main(){
    cin >> N >> D;
    D = D*D;
    for(int i=0;i<N;i++) {
        ll a, b;
        cin >> a >> b;
        a *= a;
        b *= b;
        if(D>=a+b) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

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

ll mod(ll a) {
	if (a > 0) return a % MOD;
	if (a % MOD == 0) return 0;
	ll x = -a / MOD + 1;
	a += x * MOD;
	return a % MOD;
}

template <typename T> void dump(T x) { cout << x << endl; }
void dumpf(double x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
// int dx[4]    = {1, 0, -1, 0};
// int dy[4]    = {0, 1, 0, -1};
// ll pas[5001][5002];

int main() {
	IOS();
	int n;
	cin >> n;
	vector<double> vmax(40010);
	vector<ll> t(n), v(n);
	for (int i = 0; i < n; ++i) { cin >> t[i]; }
	for (int i = 0; i < n; ++i) { cin >> v[i]; }
	double T = 0;
	for (int i = 0; i < n; ++i) {
		if (i) { vmax[T] = min(v[i], v[i - 1]); }
		for (int j = 1; j < 2 * t[i]; ++j) { vmax[T + j] = v[i]; }

		T += 2 * t[i];
	}
	vector<double> ans(T + 1);
	ans[0] = ans[T] = 0;
	for (int i = 1; i <= T; ++i) { ans[i] = min(ans[i - 1] + 0.5, vmax[i]); }
	for (int i = T - 1; i >= 0; --i) { ans[i] = min(ans[i + 1] + 0.5, ans[i]); }
	// for (int i = 0; i <= T; ++i) { dump(ans[i]); }
	double sum = 0;
	for (int i = 0; i < T; ++i) { sum += (ans[i] + ans[i + 1]) * 0.25; }
	dumpf(sum, 3);
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using pll = pair<ll, ll>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(i) begin(i), end(i)

const int INF = 0x3fffffff;
const ll MINF = 0x7fffffffffff;
const ld DINF = numeric_limits<ld>::infinity();
const int MOD = 1000000007;
const int MODD = 998244353;
const ld EPS = 1e-9;
const ld PI = 3.1415926535897932;

template<class T> bool chmin(T &a, const T &b){ if(a > b){ a = b; return 1; } else return 0; }
template<class T> bool chmax(T &a, const T &b){ if(a < b){ a = b; return 1; } else return 0; }
template<class T> auto min(const T& a){ return *min_element(all(a)); }
template<class T> auto max(const T& a){ return *max_element(all(a)); }

ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
ll lcm(ll a, ll b){ if(!a || !b) return 0; return a * b / gcd(a, b); }
ll pow_mod(ll n,ll k,ll m){ll r = 1;for(; k > 0;k >>= 1) {if (k & 1) r = (r * n) % m; n = (n * n) % m;}return r;}

//ここから。
int main(){
    int X,Y;
    cin >> X >> Y;
    if(Y%2 == 1){
        cout << "No" << endl;
        return 0;
    }
    if(2*X <= Y && 4*X >= Y){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b?gcd(b, a%b):a;}
ll lcm(ll a, ll b) { return a*b/gcd(a,b);}
ll MOD=1000000007;



int main(){
  string s;cin>>s;
  int ss=s.size();
  int cnt0=0;
  int cnt1=0;
  rep(i,ss){
    if(s.at(i)=='0') cnt0++;
    if(s.at(i)=='1') cnt1++;
  }
  cout<<2*min(cnt0,cnt1)<<endl;
}

Measured memory_bytes: 512
#include<stdio.h>
#define INFTY 1000000001
#define N 500000

int cnt;

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

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

int main(){

  int i,n,S[N];

  scanf("%d",&n);

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

  mergeSort(S,0,n);

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

  return 0;
}



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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  if(A+B==C+D) cout << "Balanced" << endl;
  else if(A+B>C+D) cout << "Left" << endl;
  else cout << "Right" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e9;
const static ll MAXN = 301;

int main(){
    int N; cin >> N;
    vector<int> V(101);
    if(N == 1) {
        cout << 0 << endl;
        return 0;
    }
    for(int i = 2; i <= N; i++) {
        int p = i;
        for(int j = 2; j*j<=i; j++){
            while(p%j==0){
                V[j]++;
                p/=j;
            }
        }
        if(p != 1) V[p]++;
    }
    ll ans = 0;
    map<int, int> M;
    
    for(int i = 2; i <= N; i++){
        if(V[i] >= 4){

            for(int j = i+1; j <= N; j++){
                if(j!=i && V[j] >= 4){

                    for(int k = 2; k <= N; k++){
                        if(k!=i && k!= j && V[k]>= 2) {
                            //cout << i << " " << j << " " << k << endl;
                            ans++;
                        }
                    }
                }
                
            }
        }
    }


    //cout << ans << endl;
    int tmp = 0;
    for(int i = 2; i <=N; i++){
        if(V[i] >= 14){
            for(int j = 2; j <= N; j++){
                if(V[j] >= 4 && i!=j){
                    tmp++;
                }
            }
        }
        
    }
    ans+= tmp;
    //cout << tmp << endl;
    tmp=0;
    for(int i = 2; i <=N; i++){
        if(V[i] >= 24){
            for(int j = 2; j <= N; j++){
                if(V[j] >= 2 && i!= j){
                    tmp++;
                }
            }
        }
        
    }
    ans+= tmp;
    //cout << tmp << endl;
    tmp=0;
    
    for(int i = 2; i <= N; i++) if(V[i] >= 74) ans++;
    cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
#define int long long
typedef pair<int,int>P;
#define F first
#define S second
 
signed main(){
  int a,b,c;
  cin>>a>>b;

  if(a<=5)cout<<0<<endl;
  else if(13<=a)cout<<b<<endl;
  else cout<<b/2<<endl;
}

Measured memory_bytes: 256
def main():
    import sys
    X=int(sys.stdin.readline())
    L1=[400,600,800,1000,1200,1400,1600,1800,2000]
    L2=[8,7,6,5,4,3,2,1]
    for i in range(len(L1)):
        if L1[i]<=X<L1[i+1]:
            print(L2[i])
            break


main()

Measured memory_bytes: 9112
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	a := make([]int, n)
	sum := 0
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
		sum += a[i]
	}

	sort.Ints(a)
	if a[n-m] >= (sum+4*m-1)/(4*m) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
short f(short a){
  if(a != 9 && a != 1)
    return a;
	return (a == 9 ? 1 : 9);
}
main(){
short sh ,st;
  cin >> sh;
  st = f(sh % 10) ,sh /= 10 ,st += f(sh % 10) * 10 ,sh /= 10 ,st += f(sh % 10) * 100;
  cout << st;}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <queue>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define fst first
#define snd second
const ll mod = 1000000007;
const ll INF = mod * mod;

int main() {
	ll n, a, b;
	cin >> n >> a >> b;
	ll ans = 0LL;
	ll temp;
	cin >> temp;
	for (ll i = 1; i < n; i++) {
		ll nek;
		cin >> nek;
		ans += min(a*(nek - temp), b);
		temp = nek;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)


const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;


long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a * g / b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}




const long double PI = 3.14159265359;
const int MAX_N = 100010;


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int h, w; cin >> h >> w;
	int ans = INF;
	int a = 0, b = 0, c = 0;
	rep(i, 2) {
		rep(j, w - 1) {
			a = (j + 1)*h;
			b = (h / 2)*(w - j - 1);
			c = ((h + 1) / 2)*(w - j - 1);
			chmin(ans, max({ a,b,c }) - min({ a,b,c }));
		}
		swap(h, w);
	}
	chmin(ans, min((w + 2) / 3*h - (w / 3)*h, (h + 2) / 3*w - (h / 3)*w));
	cout << ans << endl;
	return 0;
}

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

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


int main(){

    int n;
    scanf("%d",&n);

    int odd_num=0,tmp;
    while(n--){
        scanf("%d",&tmp);
        odd_num+=tmp%2;
    }

    printf("%s\n", odd_num % 2 ? "NO" : "YES");

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
double n, m, d;
int main(void){
    // Your code here!
    cin >> n >> m >> d;
    if (d == 0){
        cout << (m - 1) / n << endl;
    } else {
        cout <<fixed<<setprecision(6) << (m - 1) / n * (n - d) * 2 / n << endl;
    }
}


Measured memory_bytes: 256
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 1e5 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	cout << 3 * n * n << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <queue>
#include <list>
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define crep(i) for(char i='a';i<='z';i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define ALL(x) (x).begin(),(x).end()
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main(){
  ll N,A[200007],B[200007];
  cin >> N;
  rep(i,N){
    cin >> A[i];
    B[i]=A[i];
  }
  sort(B,B+N);
  ll l=B[N/2-1],r=B[N/2];
  rep(i,N){
    if(A[i]<r){
      cout << r << endl;
    }
    else{
      cout << l << endl;
    }
  }
}

Measured memory_bytes: 5376
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from bisect import bisect_right, bisect_left
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, gamma, log
from operator import mul
from functools import reduce
from copy import deepcopy

sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7

n =I()
G = [[] for _ in range(n)]
for _ in range(n - 1):
    a, b = LI()
    G[a - 1] += [b - 1]
    G[b - 1] += [a - 1]

fac = [1] * (n + 1)
inv = [1] * (n + 1)
for j in range(1, n + 1):
    fac[j] = fac[j-1] * j % mod

inv[n] = pow(fac[n], mod-2, mod)
for j in range(n-1, -1, -1):
    inv[j] = inv[j+1] * (j+1) % mod

def comb(n, r):
    if r > n or n < 0 or r < 0:
        return 0
    return fac[n] * inv[n - r] * inv[r] % mod

v_num = [-1] * n
par = [-1] * n
def f(u):
    ret = 1
    for v in G[u]:
        if v == par[u]:
            continue
        par[v] = u
        ret += f(v)
    v_num[u] = ret
    if u: return ret

f(0)
dp = [0] * n

def tree_dp(x):
    c = 1
    remain_v = v_num[x] - 1
    for y in G[x]:
        if y == par[x]:
            continue
        c = c * tree_dp(y) * comb(remain_v, v_num[y]) % mod
        remain_v -= v_num[y]
    dp[x] = c
    if x: return c

tree_dp(0)
ans = [0] * n

def dfs(d):
    e = 1
    inv_e = pow(comb(n - 1, v_num[d]) * dp[d], mod - 2, mod)
    ans[d] = dp[d] * ans[par[d]] * comb(n - 1, v_num[d] - 1) * inv_e % mod

q = deque([0])
ans[0] = dp[0]
while q:
    g = q.pop()
    for h in G[g]:
        if h == par[g]:
            continue
        dfs(h)
        q += [h]

for j in ans:
    print(j)



Measured memory_bytes: 86684
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void chey(){ cout <<"hey" <<endl; }


vector<pair<ll,ll>> pf;
map<ll,ll> dn,dn1;
ll res1 = 0;
ll N;

// 素因数分解O(√n)--------------------------------------------
template<class T> void prime_factor(ll n, map<ll,T> &res){
  for (ll i=2; i*i<=n; i++){ while (n%i==0){ res[i]++; n/=i; } }
  if (n!=1) res[n]+=1;
}

void dfs(ll i, ll endi, ll number){
  if (i == endi){
    if (number == 1) return;
    // numberが条件を満たすかチェック
    ll tmp = N;
    while (tmp % number == 0) tmp /= number;
    tmp %= number;
    if (tmp == 1) res1++;
    return;
  }
  for (ll d=0; d<=pf[i].second; d++){
    if (d > 0) number *= pf[i].first;
    dfs(i+1, endi, number);
  }
}

int main() {
  cin >>N;
  prime_factor(N-1,dn1);
  ll res2 = 1;
  for (auto p : dn1){ res2 *= p.second+1; }
  res2--; // N-1を素因数分解して得られる約数。最初から引き算のやつ

  prime_factor(N,dn);
  pf.assign(dn.size(), {0,0});
  ll tmpi = 0;
  for (auto p : dn){ pf[tmpi++] = {p.first, p.second}; }
  // pf[i]...素因数i個目。{a,b}...a^b
  // vector<ll> pfnum(dn.size());
  dfs(0, dn.size(), 1);
  ll res = res1 + res2;
  cout <<res <<endl;
}

  // N = K か N = K+1 になれば最終的に1になる
  // N = N/K を行ってKの倍数 → Kの倍数でない、となることはある
  // N = N-K を行ってKの倍数でない → Kの倍数、となることはない
  /*
    N = K となるのは N が K のべき乗で表されるとき(Kで割りまくってKになる)
    N = K+1 となるのは色々あるが途中絶対に N-1 が K の倍数になる
  */
/*
// N-1を素因数分解して得られる約数全て(1以外)は条件を満たす
// じゃあ１回はkで割れるやつらはどうだろう

Nを素因数分解して得られる
*/
/*
1 K   K^2    K^3
  K+1 (K+1)K (K+1)K^2
      2K+1   (2K+1)K
             3K+1
  
*/


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

int main() {
    int N, K, ans = 0;
    cin >> N >> K;
    vector<int> V(N);
    rep(i, N) cin >> V[i];

    rep(A, min(N, K) + 1) {
        rep(B, min(N, K) - A + 1) {
            vector<int> AB = V;
            AB.erase(begin(AB) + A, end(AB) - B);
            sort(begin(AB), end(AB));
            rep(i, K - A - B) {
                AB[i] = max(0, AB[i]);
            }
            ans = max(ans, accumulate(begin(AB), end(AB), 0));
        }
    }
    cout << ans << endl;
}

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

#define Q int t; scanf("%d", &t); for(int q=1; q<=t; q++)
typedef long long int lli;
typedef pair<int, int> pi;
typedef pair<lli, lli> pii;


int main()
{
    string s;
    cin >> s;
    int n = s.size();
    int mod = 0;
    lli ans = 0;
    lli cnt[2020] = {0};
    cnt[0]++;
    int po = 1;
    for(int i=n-1; i>=0; i--){
        int x = s[i] - '0';
        mod = (mod + x*po) % 2019;
        ans += cnt[mod];
        cnt[mod]++;
        po = (po*10)%2019;

    }
    cout << ans << "\n";


    return 0;
}


Measured memory_bytes: 3740
#include <bits/stdc++.h>
#define pb push_back
#define cmin(a,b) (a>b?a=b:a)
#define cmax(a,b) (a<b?a=b:a)
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
#define fore(i,v) for(int i=g[v],d=es[i].d;i;i=es[i].nxt,d=es[i].d)
using namespace std;

#define Pr(f,...) //printf(f,##__VA_ARGS__),fflush(stdout)

typedef long long ll;

int len,L,q,a,b,c,d;
void solve(){
	len=(max(a,b)+min(a,b))/(min(a,b)+1);
	int l=0,r=a+b+1;
	while(l<r){
		int z=(l+r)>>1;
		int aa=a-z/(len+1)*len-z%(len+1);
		int bb=b-z/(len+1);
		if(bb<=1ll*aa*len)l=z+1;else r=z;
	}
	L=l;
	while(c<=d){
		if(c<=L)putchar((c-1)%(len+1)==len?'B':'A'),++c;
		else putchar((a+b-c)%(len+1)==len?'A':'B'),++c;
	}
	puts("");
}

int main(int argc,char *argv[]){
#ifdef CURIOUSCAT
	freopen("dat.in","r",stdin);
	freopen("my.out","w",stdout);
#endif
	scanf("%d",&q);
	while(q--){
		scanf("%d%d%d%d",&a,&b,&c,&d);
		solve();
	}
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int q;
    cin>>q;
    priority_queue<ll> que1;
    priority_queue<ll,vector<ll>,greater<ll>> que2;
    ll off=0,sum1=0,sum2=0;
    while(q--){
        int c;
        cin>>c;
        if(c==1){
            ll a,b;
            cin>>a>>b;
            off+=b;
            if(que1.empty()){
                que1.push(a);
                sum1+=a;
                continue;
            }
            ll sz=que1.size()+que2.size()+1;
            ll now;
            if(a<=que1.top()){
                que1.push(a);
                sum1+=a;
                if(sz%2==0){
                    now=que1.top();
                    que1.pop();
                    que2.push(now);
                    sum1-=now;
                    sum2+=now;
                }
            }else{
                que2.push(a);
                sum2+=a;
                now=que2.top();
                if(sz%2==1){
                    que2.pop();
                    que1.push(now);
                    sum2-=now;
                    sum1+=now;
                }
            }
        }else{
            ll ans=off;
            ll x=que1.top();
            ans+=ll(que1.size())*x-sum1;
            ans+=sum2-ll(que2.size())*x;
            cout<<x<<' '<<ans<<endl;
        }
    }
}

Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
int a[1000005] = {0,};
vector<int> primeVec;
void genPrime(){
	for (int i=2;i<=1000000;i++){
		if (a[i]) continue;
		else{
			a[i] = 2;
			primeVec.push_back(i);
			if (i >= 1000) continue;
			for (int j=i*i;j<=1000000;j+=i) a[j] = 1;
		}
	}
}
int main(){
	genPrime();
	int n;
	while(cin >> n)
		cout << upper_bound(primeVec.begin(), primeVec.end(), n) - primeVec.begin() << endl;
	return 0;
}


Measured memory_bytes: 7184
//#include<bits/stdc++.h>
#include<iostream>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
ll n;
ll a[200005];
template <typename _Tp> inline void read(_Tp&x);
inline void print(__int128 x);
template <typename _Tp> inline void read(_Tp&x)
{
    char ch;
    bool flag=0;
    x=0;
    while(ch=getchar(),!isdigit(ch)) if(ch=='-')flag=1;
    while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
    if(flag) x=-x;
}
inline void print(__int128 x)
{
    if(x<0)
    {
        x=-x;
        putchar('-');
    }
    if(x>9) print(x/10);
    putchar(x%10+'0');
}
string s,t;
int main()
{
    cin>>s>>t;
    ll ls=s.length();
    ll lt=t.length();
    ll ans=100000;
    for(ll i=0;i+lt<=ls;i++)
    {
        ll sum=0;
        for(ll j=0;j<lt;j++)
        {
            if(s[i+j]!=t[j])
            {
                sum++;
            }
        }
        ans=min(ans,sum);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3636