akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <string>
#include <cmath>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<ll> vll;
 
#define all(v) v.begin(),v.end()
#define test() int t;cin>>t;while(t--) 
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ff first
#define ss second
#define pb push_back
const int mod = 998244353;
const ll INF = -(ll)1e10;

int main()
{
    int n, q;
    cin>>n>>q;
    ll ans = (n-2) * 1LL * (n-2);
    set<pii> row = {{n, n}};
    set<pii> col = {{n, n}};
    while(q--)
    {
        int x, y;
        cin>>x>>y;
        if(x==1)
        {
            pii it = *row.lower_bound({y, -1});
            ans-=(it.ss - 2);
            col.insert({it.ss, y});
        }
        else
        {
            pii it = *col.lower_bound({y, -1});
            ans-=(it.ss - 2);
            row.insert({it.ss, y});
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 13012
#include <iostream>

using namespace std;

int main(void){

  int score, sum = 0;
  for(int i = 0; i < 5; i++){
    cin >> score;
    if(score < 40)	score = 40;
    sum += score;
  }
  cout << sum/5 << endl;

  return 0;
}

Measured memory_bytes: 1160
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
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():
    h,w,m = LI()
    fx = [0]*w
    fy = [0]*h
    f = defaultdict(lambda : 0)
    for _ in range(m):
        y,x = LI()
        y -= 1
        x -= 1
        f[(y,x)] = 1
        fx[x] += 1
        fy[y] += 1
    m = 0
    lisx = []
    for x in range(w):
        srx = fx[x]
        if m < srx:
            m = srx
    for x in range(w):
        srx = fx[x]
        if m == srx:
            lisx.append(x)
    M = 0
    lisy = []
    for y in range(h):
        srx = fy[y]
        if M < srx:
            M = srx
    for y in range(h):
        srx = fy[y]
        if M == srx:
            lisy.append(y)
    ans = m+M
    for y in lisy:
        for x in lisx:
            if not f[(y,x)]:
                print(ans)
                return
    print(ans-1)
    return

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


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

#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;

int main() {
    int minnum = 9, lastadd, ans = 0;
    vector<int> ordertime(5);
    rep(i, 5) {
        cin >> ordertime[i];
        if (minnum >= ordertime[i]%10 && ordertime[i]%10 != 0) {
            lastadd = i;
            minnum = ordertime[i] % 10;
        }
    }
    rep(i, 5) { 
        if (i != lastadd){
            ans += (ordertime[i] + (10 - ordertime[i]%10) % 10);
        }
    }
    ans += ordertime[lastadd];

    cout << ans << endl;
}

Measured memory_bytes: 3196
num_list = []
try:
    while True:
        num = input()
        num_list.append(num)
except EOFError:
    num = 0
finally:
    t = 1
    kei = int(num_list[0])
    num2 = len(num_list) / 2
    for num1 in range(int(num2)):
        if num_list[t] == "+":
            kei += int(num_list[t + 1])
        if num_list[t] == "-":
            kei -= int(num_list[t + 1])
        if num_list[t] == "*":
            kei *= int(num_list[t + 1])
        if num_list[t] == "/":
            kei /= int(num_list[t + 1])
            kei = int(kei)
        if num_list[t] == "=":
            print(kei)
        t += 2
        continue


Measured memory_bytes: 5600
#include <iostream>
 
using namespace std;
 
int main()
{
string s;
cin>>s;
int x=0 , y=0 , z=0 ;
if (s[0] == 'A'){
    x++;
}
for (int i = 2 ; i < s.size()-1; i++){
    if (s[i]=='C')
        y++;
}
for (int i=0 ;i <s.size(); i++){
    if(s[i]>=65&&s[i]<=90){
        z++;
    }
}
if(x==1 && y==1 && z==2)
    cout<<"AC";
else
    cout<<"WA";
 
 
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int h,w;
int mapp[150][150];
int mp[150][150];
int main()
{
    cin>>h>>w;
    for(int i=0;i<h;i++)
    {
        scanf("%s",mapp[i]);
    }
    for(int i=0;i<h+2;i++)
    {
        if(i==0)
        {
            for(int j=0;j<w+2;j++)
            {
                printf("#");
            }
            printf("\n");
        }
        else if(i==h+1)
        {
            for(int j=0;j<w+2;j++)
            {
                printf("#");
            }
            printf("\n");
        }
        else
        {
            printf("#");
            printf("%s",mapp[i-1]);
            printf("#\n");
        }
    }
    //cout << "Hello world!" << endl;
    return 0;
}


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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9

int main(){ 
  int N;
  cin >> N;
  vector<int> h(N);
  REP(i, N){
    cin >> h[i];
  }
  bool flag = true;
  int cnt = 0;
  while(flag){
    flag = false;
    REP(i, N){
      if(h[i]){
        h[i]--;
        flag = true;
        if(i < N-1 && h[i+1] == 0){
          cnt++;
        }
        else if(i == N-1){
          cnt++;
        }
      }
    }
  }
  cout << cnt << endl;
  return 0;
}



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

int i, j, k, n, x, m, menu[30], dp[1000000],prime[1000001], ans;
int main(){
  for(i = 2;i <= 1000;i++){
    if(prime[i] == 1)continue;
    for(j = i * i;j < 1000000;j += i){
      prime[j] = 1;
    }
  }
  while(1){
    scanf("%d%d", &n, &x);
    if(n == 0 && x == 0)return 0;
    memset(dp, 0, sizeof(dp));
    dp[0] = 1;
    for(i = 0;i < n;i++){
      scanf("%d", menu + i);
    }
    ans = 0;
    for(i = 1;i <= x;i++){
      for(j = 0;j < n;j++){
	if(i - menu[j] >= 0 && dp[i - menu[j]] == 1){
	  dp[i] = 1;
	  break;
	}
      }
      if(dp[i] == 1 && prime[i] == 0){
	ans = i;
      }
    }
    if(ans == 0)
      puts("NA");
    else
      printf("%d\n", ans);
  }
}

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

using namespace std;

int main()
{
  int N, A[3] = {};

  cin >> N;
  for(int i = 0; i < N; i++) {
    int s;
    cin >> s;
    ++A[s % 3];
  }

  if(A[1] < A[2]) swap(A[1], A[2]);

  if(A[1] == 0) {
    cout << 1 << endl;
  } else {
    int get = min(A[1] - 1, A[2]);
    A[1] -= get + 1;
    A[2] -= get;
    int up = get * 2 + A[0] + 1;
    if(A[1] > 0) ++up, --A[1];
    if(A[1] > 0 || A[2] > 0) ++up;
    cout << up << endl;
  }
}

Measured memory_bytes: 3088
#include <iostream>
#include <string>
#include <vector>
using ll=long long;
using namespace std;

int main(){
    string N;
    cin>>N;
    int end=N.size();
    int sum=0;
    for(int i=0;i<end;i++){
        sum+=(int)N[i]-'0';
    }
    if(sum%9==0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

    return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
int main(){
    int A,B,C,D;
    cin >>A>>B>>C>>D;
    int begin=max(A,C);
    int end=min(B,D);
    if(end-begin<0){
        cout <<"0"<<endl;
        return 0;
    }
    cout<<end-begin<<endl;
}


Measured memory_bytes: 256
#問題文
#高橋くんは N 種類の料理が食べ放題のビュッフェに行き、全種類の料理 (料理1, 料理2,…, 料理N) を 
#1度ずつ食べました。
#高橋くんがi (1≤i≤N)番目に食べた料理は料理Aiでした。高橋くんは、料理i(1≤i≤N) を食べると満足度Bi を得ます。
#また、料理i (1≤i≤N−1)を食べた直後に料理i+1を食べると満足度Ci を追加で得ます。
#高橋くんが得た満足度の合計を求めてください。

#制約
#入力は全て整数である。
#2≤N≤20
#1≤Ai≤N
#A1,A2,...,AN は全て異なる。
#1≤Bi≤50
#1≤Ci≤50

num = int(input())
order = input().split()
order = [int(i) for i in order]
manzoku = input().split()
additional = input().split()

prev = -1
ans = 0
for i in order:
  ans += int(manzoku[i-1])
  if i == prev+1:
    ans += int(additional[i-2])
  prev = i
  
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int n;

struct Edge{
    int to,id; //枝のid
};

//木の問題は大体深さ優先探索
vector<vector<Edge>> g;
vector<int> ans;
//隣り合ってる頂点を列挙したリスト　a[i]={i,j,k,l...}

void dfs(int v,int c=-1,int p=-1){
    int k=1;
    rep(i,g[v].size()){
        int u = g[v][i].to,ei=g[v][i].id;
        if(u==p) continue; //親から来た場合は無視
        if(k==c) k++; //親辺と一致しそうならとばす
        ans[ei]=k;
        k++;
        dfs(u,ans[ei],v);
    }
}

int main(){
    cin>>n;
    g.resize(n);
    ans=vector<int>(n);
    rep(i,n-1){
        int a,b;
        cin>>a>>b;
        a--;b--;
        g[a].push_back((Edge){b,i});//向かう点とid追加
        g[b].push_back((Edge){a,i}); //双方向に
    }
    dfs(0);
    //cout<<"eskape"<<endl;
    int mx=0;
    rep(i,n) mx= max(mx,int(g[i].size()));
    cout<<mx<<endl;
    rep(i,n-1){
        cout<<ans[i]<<endl;
    }
    return 0;
}

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

signed main() {
  int a,b,c,k; cin>>a>>b>>c>>k;
  
  if(c>b && b>a){
    cout<<"Yes"<<endl;
    return 0;
  }
  else if(c>=b && b>a){
    cout<<"Yes"<<endl;
    return 0;
  }
  for(int i=0;i<k;i++){
    b*=2;
    if(b>a){
      k-=(i+1);
      break;
    }
  }
  if(b<=a){
    cout<<"No"<<endl;
    return 0;
  }
  for(int j=0;j<k;j++){
    c*=2;
    if(c>b){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
}

Measured memory_bytes: 3612
#include<iostream>
#include<functional>
#include<utility>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>

#define MOD 1000000007
using namespace std;

int n, m;
string s;

int main() {
	cin >> n >> m;
	vector<int> l(n);
	for (int i = 0; i < n; i++)
	{
		cin >> l[i];
	}
	int cnt = 0;
	int ans = 1;
	for (int i = 0; i < n; i++)
	{
		if (cnt > m)break;
		cnt += l[i];
		if (cnt <= m) { ans++; }
		else break;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
ans = 0
if N >= 2:
    for i in range(N):
        for j in range(i+1, N):
            ans += 1
if M >= 2:
    for i in range(M):
        for j in range(i+1, M):
            ans += 1
print(ans)

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

int arr[100001];
int main()
{
	int a,b,x=0,c,t1,t2;
	cin>>a>>b;
	while(b--)
	{
	cin>>t1>>t2;
	arr[t1]++;
	arr[t2]++;
	
	}
	bool f=0;
	for(int i=1;i<=a;i++)
	{
	
		if(arr[i]%2==1)
		{
		f=1;
		break;
		}
	}

	if(f==1)
		cout<<"NO"<<endl;
	else
		cout<<"YES"<<endl;

return 0;
}

Measured memory_bytes: 640
package main

import "fmt"


func main() {
	var N, tmp uint64
	var A [5]uint64

	fmt.Scan(&N)
	fmt.Scan(&A[0])
	fmt.Scan(&A[1])
	fmt.Scan(&A[2])
	fmt.Scan(&A[3])
	fmt.Scan(&A[4])

	tmp = 10000000000000000
	for i := 0; i < 5; i++ {
		if tmp > A[i] {
			tmp = A[i]
		}
	}

	if N % tmp == 0 {
		fmt.Println(N / tmp + 4)
	} else {
		fmt.Println(N / tmp + 5)
	}
}

Measured memory_bytes: 1836
import java.util.Scanner

val sc = Scanner(System.`in`)
val n = sc.nextInt()

fun main(args: Array<String>) {
    val plist = mutableListOf<Int>()
    for (i in 0 until n) {
        plist.add(sc.nextInt())
    }
    println(plist.sum() - plist.max()!!/2)
}


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

int main(void){
    ll d,t,s;
    cin >> d >> t >> s;
    
    if(t * s >= d)cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		double ans = Math.ceil((double)(b - 1) / (a - 1));
		System.out.println((int)ans);
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
 
#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);
 
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;
 
constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433;
 
template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
	int H,A; cin >> H >> A;
	cout << H/A + (H%A!=0) << endl;



    return 0;
}

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

using namespace std;
// using namespace atcoder;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG
/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#else
#define print(...)
#endif

void solve() {
    string S;
    cin >> S;
    ll N = S.size();
    vector<vector<ll>> dp(N + 1, vector<ll>(2, 0));
    rep(i, N) {
        if (i == 0) {
            dp[i + 1][0] = 1;
            dp[i + 1][1] = 0;
        } else {
            if (S[i] == S[i - 1]) {
                dp[i + 1][1] = dp[i - 1][0] + 1;
                dp[i + 1][0] = dp[i][1] + 1;
            } else {
                dp[i + 1][0] = dp[i][0] + 1;
                dp[i + 1][1] = dp[i - 1][0] + 1;
            }
        }
    }
    cout << max(dp[N][0], dp[N][1]) << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 14452
import queue
K = int(input())
q = queue.Queue()
for i in range(1,10):
    q.put(i)

for i in range(K):
    x = q.get()
    a = x%10
    if a !=0:
        q.put(10*x +a -1)
    q.put(10*x +a )
    if a != 9:
        q.put(10*x +a +1)
print(x)

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

//定数
const long long MOD1=1000000007;
const long long MOD2=998244353;
const long double PI=3.1415926535897932;
const long long MAXLL=9223372036854775807;
const long long INF=2305843009213693951;
const long long dx[]={0,1,0,-1,1,-1,1,-1};
const long long dy[]={1,0,-1,0,1,1,-1,-1};

//型名省略
#define ll long long
#define ull unsigned long long
#define ld long double
#define uld unsigned long double
#define pll pair<long long,long long>
#define tll(n) array<long long,(int)(n)>
#define pcc pair<char,char>
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vp vector<pair<long long,long long>>
#define vt(n) vector<array<long long,(int)(n)>>
#define umap unordered_map
#define uset unordered_set
#define Lqueue priority_queue<long long>
#define Squeue priority_queue<long long,vector<long long>,greater<long long>>
#define Fi first
#define Se second
#define mp make_pair
#define eb emplace_back

//マクロ
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rbf(a,x) for(auto& a:x)
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s);i<(long long)(n);i++)
#define bitrep(i,s,n) for(long long i=(s);i<(1LL<<(n));i++)
#define Maxe(x) *max_element((x).begin(),(x).end())
#define Mine(x) *min_element((x).begin(),(x).end())
#define Size(x) ((long long)(x).size())
#define lin(s) getline(cin,(s))

//Yes,No
void Yes(bool a){cout<<(a?"Yes":"No")<<endl;}
//YES.NO
void YES(bool a){cout<<(a?"YES":"NO")<<endl;}

//MAX,MIN
template<class T,class U> auto max(T a,U b){return a>b?a:b;}
template<class T,class U> auto min(T a,U b){return a<b?a:b;}

//最大公約数,最小公倍数
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a,long long b){return a/gcd(a,b)*b;}

//累乗
template<typename t>
constexpr t mypow(t a,long long b){
    if(b==0)return 1;
    if(a==0)return 0;
    t x=1;
    while(b>0){
        if(b&1LL)x*=a;
        a*=a;
        b>>=1LL;
        }
    return x;
}
#define pow mypow

//chmin,chmax
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;}

//組み合わせ O(r)
template<typename t>
constexpr t nCr(t n,long long r){
    if(r==0)return 1;
    if(n==0)return 0;
    if(n<r)return 0;
    t x=1;
    for(long long i=1;i<=r;i++){
        x*=n-i+1;
        x/=i;
    }
    return x;
}

//main関数
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n;
    cin>>n;
    vl A(n);
    rep(i,n)cin>>A[i];
    Lqueue L;
    rep(i,n)L.push(A[i]);
    rep(i,n){
        ll a=L.top();
        if(a==A[i])L.pop();
        cout<<L.top()<<endl;
        if(a==A[i])L.push(a);
    }
}

Measured memory_bytes: 6872
#include <iostream>
#include <bits/stdc++.h>
#define mod 998244353
typedef long long ll;

using namespace std;

void Fastio(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

ll fact[1000006], inv[1000006];

ll fp(ll base, ll exp)
{
    if (exp == 0)
        return 1;
    ll ans = fp(base, exp / 2);
    ans = (ans * ans) % mod;
    if (exp % 2 != 0)
        ans = (ans * (base % mod)) % mod;
    return ans;
}

void calcFacAndInv(ll n)
{
    fact[0] = inv[0] = 1;
    for (ll i = 1; i <= n; i++)
    {
        fact[i] = (i * fact[i - 1]) ;
        inv[i] = fp(fact[i], mod - 2);
    }
}

ll ncr(ll n, ll r)
{
    return ((fact[n] * inv[r]) % mod * inv[n - r]) % mod;
}

ll npr(ll n, ll r)
{
    return (fact[n] * inv[n - r]) % mod;
}

long double  NCR(int n, int m){
    long double res = 1;
    m = min(m, n - m);
    for(int i = 0; i < m; i++){
        res = res * ( n - i) / (i + 1);
 }
    return res;
}
ll tol(string a){
    ll res=0;
    while(a[0]=='0'){
        a.erase(a.begin());
    }
    if(a=="")a="0";
    for(int i=0; i<a.size(); i++){
        res*=10; res+=a[i]-'0';
    }
    return res;
}
int check(string a, string b){
    for(int i=0; i<a.size(); i++){
        if(a[i]>b[i])return 1;
        if(b[i]>a[i])return -1;
    }
    return 0;
}
class data{
public:
    ll v,d,p;
    data(){}
    data(ll vv, ll dd, ll pp){
        v=vv;  d=dd; p=pp;
    }
};

int primeFactors(int n)
{
    ll c=0;
    while (n % 2 == 0)
    {
        c++;
        n = n/2;
    }
    for (int i = 3; i*i <= n; i = i + 2)
    {
        while (n % i == 0)
        {
            c++;
            n = n/i;
        }
    }
    if (n > 2)
        c++;
    return c;
}
int n,m, counter;
vector<int>arr[200005];
int vis[200005];
void dfs(int node){
    vis[node]=1; counter++;
    for(int i=0; i<arr[node].size(); i++){
        if(!vis[arr[node][i]])dfs(arr[node][i]);
    }
}
int main()
{
    Fastio();
    double n,k,pos=0; cin>>n>>k; k--;
    for(int i=0; i<n; i++){
        int x; cin>>x;
        if(x==1)pos=i;
    }
    ll tmp1, tmp2;
    int p=pos,kk=k;
    while(p%kk && p+1<n)p++;
    pos=p; tmp1=ceil(pos/k);
    tmp2=ceil((n-pos-1)/k);
    ll res=tmp1+tmp2;
    cout<<res<<'\n';

    return 0;
}



Measured memory_bytes: 5632
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define x first
#define y second
#define bug(x) cerr<<#x<<'='<<x<<' '
#define debug(x) cerr<<#x<<'='<<x<<'\n'
#define FOR(a,b,c) for(int a=(b),a##_end=(c);a<=a##_end;++a)
#define ROF(a,b,c) for(int a=(b),a##_end=(c);a>=a##_end;--a)
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
const int INF=0x3f3f3f3f,N=1e5+10,P=1e9+7;
template<class T>inline bool chkmin(T &A,const T &B){return B<A?A=B,1:0;}
template<class T>inline bool chkmax(T &A,const T &B){return A<B?A=B,1:0;}
int cnt[30],n;
char str[N];
int main(){
	scanf("%d",&n);
	scanf("%s",str+1);
	FOR(i,1,n)cnt[str[i]-'a']++;
	ll ans=1;
	FOR(i,0,25)ans=ans*(cnt[i]+1)%P;
	ans=(ans-1+P)%P;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;

const int NMAX = 1e2 + 11;
const int KMAX = 1e5 + 11;

int  n, k, a[NMAX];
bool vis[KMAX], mem[KMAX];

bool wins(int stones)
{
    bool &ans = mem[stones];

    if (vis[stones])
        return ans;

    vis[stones] = true;
    for (int i = 0; i < n; ++i)
        if (stones - a[i] >= 0 and not wins(stones - a[i]))
            return (ans = true);
    return (ans = false);
}

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

    cout << (wins(k) ? "First" : "Second") << endl;

    return 0;
}


Measured memory_bytes: 5120
using System;
using System.Linq;

class C
{
	static void Main()
	{
		Func<int[]> read = () => Console.ReadLine().Split().Select(int.Parse).ToArray();
		Console.ReadLine();
		var a1 = read();
		var a2 = read();

		int t1 = a1[0], t2 = a2.Sum(), M = t1 + t2;
		for (int i = 1; i < a1.Length; i++)
			M = Math.Max(M, (t1 += a1[i]) + (t2 -= a2[i - 1]));
		Console.WriteLine(M);
	}
}


Measured memory_bytes: 13396
hyo = []
x = []
ans = 0
for i in range(3):
    x = [int(e) for e in input().split()]
    hyo.extend(x)
    
kaz = int(input())

for j in range(kaz):
    num = int(input())
    for k in range(9):
        if hyo[k] == num:
            hyo[k] = 0
            break
for l in range(3):
    if hyo[3*l] == 0 and hyo[3*l+1] == 0 and hyo[3*l+2] == 0:
        ans = 1
    elif hyo[l] == 0 and hyo[3+l] == 0 and hyo[6+l] == 0:
        ans = 1
if hyo[0] ==0 and hyo[4] == 0 and hyo[8] == 0:
    ans =1
elif hyo[2] == 0 and hyo[4] == 0 and hyo[6] == 0:
    ans = 1
    
if ans == 1:
    print("Yes")
elif ans == 0:
    print("No")

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

#define INF 10e8

typedef pair<int ,int> pii;
typedef pair<pii ,pii> iiii;

int N,_N;
int P[400020];
priority_queue<iiii ,vector<iiii> ,greater<iiii> > Q;
int seg_odd[800020],seg_even[800020];
int po[400020];

void init()
{
    int res = 1;
    while(N > res)res *= 2;
    _N = res;
    for(int i = 0; i < 2 * _N - 1; i++)seg_odd[i] = seg_even[i] = INF;
    return;
}

void update(int k,int x)
{
    k += _N - 1;
    if(k % 2)
    {
        seg_even[k] = x;
        while(k > 0)
        {
            k = (k - 1) / 2;
            seg_even[k] = min(seg_even[k * 2 + 1],seg_even[k * 2 + 2]);
        }
    }
    else
    {
        seg_odd[k] = x;
        while(k > 0)
        {
            k = (k - 1) / 2;
            seg_odd[k] = min(seg_odd[k * 2 + 1],seg_odd[k * 2 + 2]);
        }
    }
    return;
}

int getmin_odd(int a,int b,int k,int l,int r)
{
    if(r <= a || b <= l)return INF;
    if(a <= l && r <= b)return seg_odd[k];
    int res1 = getmin_odd(a,b,k * 2 + 1,l,(l + r) / 2);
    int res2 = getmin_odd(a,b,k * 2 + 2,(l + r) / 2,r);
    return min(res1,res2);
}

int getmin_even(int a,int b,int k,int l,int r)
{
    if(r <= a || b <= l)return INF;
    if(a <= l && r <= b)return seg_even[k];
    int res1 = getmin_even(a,b,k * 2 + 1,l,(l + r) / 2);
    int res2 = getmin_even(a,b,k * 2 + 2,(l + r) / 2,r);
    return min(res1,res2);
}

void construct(int l,int r)
{
    if(N <= l)return;
    if(r - l < 2)return;
    int L,R;
    if(l % 2)
    {
        L = getmin_odd(l,r,0,0,_N);
        R = getmin_even(po[L],r,0,0,_N);
    }
    else
    {
        L = getmin_even(l,r,0,0,_N);
        R = getmin_odd(po[L],r,0,0,_N);
    }
    Q.push(make_pair(make_pair(L,R),make_pair(l,r)));
    return;
}

int main()
{
    scanf("%d",&N);
    init();
    for(int i = 0; i < N; i++)
    {
        scanf("%d",&P[i]);
        po[P[i]] = i;
        update(i,P[i]);
    }
    construct(0,N);
    for(int i = 0; i < N / 2; i++)
    {
        iiii now = Q.top();Q.pop();
        printf("%d %d",now.first.first,now.first.second);
        if(i != N / 2 - 1)printf(" ");
        construct(now.second.first,po[now.first.first]);
        construct(po[now.first.first] + 1,po[now.first.second]);
        construct(po[now.first.second] + 1,now.second.second);
    }printf("\n");
    return 0;
}


Measured memory_bytes: 10100
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    string S;
    cin >> S;
    int N = S.size();
    ll dp[N+1][4];
    dp[N][3] = 1;
    dp[N][0] = dp[N][1] = dp[N][2] = 0;
    for(int i = N-1;i >= 0;i--){
        int m1 = (S[i] == '?' ? 3 : 1);
        rep(j,0,3){
            int m2 = (S[i] == '?' || S[i] == ('A' + j) ? 1 : 0);
            dp[i][j] = (dp[i+1][j] * m1 + dp[i+1][j+1] * m2) % MOD;
        }
        dp[i][3] = (dp[i+1][3] * m1) % MOD;
    }
    cout << dp[0][0] << endl;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pint = pair<int,int>;


const long long INFLL = 1LL << 60;
const int INFI = 1000000000;


int main() {
    int N,M,K; cin >> N >> M >> K;
    bool result=false;
    for(int i=0;i<=N;i++){
        for(int j=0;j<=M;j++){
            if(i*M+j*N-2*i*j == K) {result=true;break;}
        }
    }
    if(result) cout << "Yes" << endl;
    else cout << "No"<< endl;
}



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

int main() {
    int n;
    cin>>n;
    int h[n][3];
    int dp[n][3];
    for(int i=0; i<n; i++) {
        cin>>h[i][0]>>h[i][1]>>h[i][2];
        dp[i][0] = 0; dp[i][1] = 0; dp[i][2] = 0;
    }
    dp[0][0] = h[0][0]; dp[0][1] = h[0][1]; dp[0][2] = h[0][2];
    for(int i=1; i<n; i++) {
    	for(int j=0; j<3; j++) {
    		for(int k=0; k<3; k++) {
    			if(k==j) continue;
    			dp[i][k] = max(dp[i][k], dp[i-1][j] + h[i][k]) ;
    		}	
    	}
    }
    cout<<max(max(dp[n-1][0], dp[n-1][1]) ,dp[n-1][2]);
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 1e5 + 5, mod = 1e9 + 7;

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll ans_c = b / c - (a - 1) / c;
    ll ans_d = b / d - (a - 1) / d;
    ll lcm = c / __gcd(c, d) * d;
    ll common = b / lcm - (a - 1) / lcm;
    ll kam = ans_c + ans_d - common;
    cout << b - a + 1 - kam;

    return 0;

}



Measured memory_bytes: 256
while True:
    try:
        S = input()
        n1 = int(S[:2])
        n2 = int(S[2:])
        isYYMM = False
        isMMYY = False
        if 1<=n1<=12:
            isMMYY = True
        if 1<=n2<=12:
            isYYMM = True
        if isMMYY and isYYMM:
            print("AMBIGUOUS")
        elif (not isMMYY) and (not isYYMM):
            print("NA")
        elif isMMYY:
            print("MMYY")
        elif isYYMM:
            print("YYMM")
    except:
        break

Measured memory_bytes: 3064
n,l = map(int, input().split())
s = [[""]*l for syoki in [""]*n]
flag = [["ok"]*l for syoki in ["ok"]*n]
dummy = ""
#print(s)
for i in range(n):
  dummy = input()
  count = 0
  for q in dummy:
    s[i][count] = q
    count = count + 1

#文字列判定
for j in range(n):
  for k in range(n-1):
    for m in range(l):
      if s[j][m] < s[k][m]:
        dummy = s[j]
        s[j] = s[k]
        s[k] = dummy
        break
      elif s[j][m] > s[k][m]:
        break
out = ""  
for f in range(n):
  for g in range(l):
    out = out + s[f][g]
print(out)



Measured memory_bytes: 3188
#include <iostream>
#include <string>

using namespace std;

int main() {

	int len;
	int cnt = 0;
	string s;
	const string text = "ABC";
	cin >> len;
	cin >> s;


	for (int i = 0; i < len-2; i++) {
		//cout << s[i] << endl;
		if (s[i] == text[0]) {
			if (s[i + 1] == text[1] && s[i + 2] == text[2])cnt++;
		}
	}
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    for(int i = 0;i < s.size();i++) {
        if(s[i] == ',') {
            cout << " ";
        } else {
            cout << s[i];
        }
    }
    cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define N 3000005
#define endl "\n"
#define mod 1000000007
bool comp(const pair<string,pair<ll,ll>>&a,const pair<string,pair<ll,ll>>&b){
	if(a.fs<b.fs){
		return true;
	}
	else if(a.fs==b.fs){
		if(a.sc.fs>b.sc.fs){
			return true;
		}
		else return false;
	}
	else return false;
}
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,k,l,n;
	cin>>n;

	vector< pair<string,pair<ll,ll> > > vc;
	string a;
	for(i=1;i<=n;i++){
		cin>>a>>k;
		vc.ps({a,{k,i}});
	}
	sort(all(vc),comp);

	for(i=0;i<n;i++){
		cout<<vc[i].sc.sc<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
N=int(input())
S1=input()
S2=input()
MOD=1000000007

p=[]
i=0
while i<N:
    if S1[i]==S2[i]:
        p.append(0)
        i+=1
    else:
        p.append(1)
        i+=2

ans=3 if p[0]==0 else 6
for i in range(1,len(p)):
    if p[i]==0 and p[i-1]==0:
        ans=ans*2%MOD
    if p[i]==0 and p[i-1]==1:
        ans=ans*1%MOD
    if p[i]==1 and p[i-1]==0:
        ans=ans*2%MOD
    if p[i]==1 and p[i-1]==1:
        ans=ans*3%MOD

print(ans)

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

string s;
string s1,s2;
int cnt;

int main()
{
	cin >> s;
	for(int i=0;i<s.length();i++)
	{
		s2+=s[i];
		if(s2!=s1)
		{
			cnt++;
			s1=s2; 
			s2.erase(0,s2.length());
		}
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
const int MAXN=100005;
int N;
vector<int>adj[MAXN];
int dist[2][MAXN];
int type;
int cnt;
void dfs(int i,int last=-1)
{
	if(last!=-1)
		dist[type][i]=dist[type][last]+1;
	for(int j=0;j<adj[i].size();j++)
		if(adj[i][j]!=last)
			dfs(adj[i][j],i);
}
int main()
{
	scanf("%d",&N);
	for(int i=0;i<N-1;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		adj[x].push_back(y);
		adj[y].push_back(x);
	}
	type=0;
	dfs(1);
	type=1;
	dfs(N);
	for(int i=1;i<=N;i++)
		if(dist[0][i]<=dist[1][i])
			cnt++;
	printf("%s\n",cnt>N/2?"Fennec":"Snuke");
	return 0;
}


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

int main() {
    string S; cin >> S;
    bool willBeAC = true;
    int counter = 0;
    for (int i = 0; i < S.size(); i++) {
        if (i == 0) {
            if (S[0] != 'A') {
                willBeAC = false;
            }
        } else if (i >= 2 && i <= S.size() - 2) {
            if (S[i] == 'C') {
                counter++;
            }
            if (S[i] != 'C' && (S[i] < 97 || S[i] > 122)) {
                willBeAC = false;
            }
        } else {
            if (S[i] < 97 || S[i] > 122) {
                willBeAC = false;
            }
        }
    }
    if (counter != 1) {
        willBeAC = false;
    }
    if (willBeAC) {
        cout << "AC" << endl;
    } else {
        cout << "WA" << endl;
    }
}


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

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

    sort(d.begin(),d.end());
    if(d[n/2]==d[(n/2)-1]) cout << 0 << endl;
    else cout << d[n/2]-d[(n/2)-1] << endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define int long long
  #define all(v) v.begin(),v.end()
  #define rep(i,a,b) for(int i = a; i <=b; i++)
  #define rep2(i,a,b) for(int i = a; i>=b; i--)
  #define f first
  #define s second
  #define PB push_back
  #define MP make_pair
  #define db long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

  #define cases int testcases;cin>>testcases; while(testcases--)
      


int32_t main()
{
       

    
    int n;
    cin >> n;
    int a[n+1],b[n+1],c[n+1];

    rep(i,1,n)
    {
      cin >> a[i] >> b[i] >> c[i];
    }

    int dp1[n+1],dp2[n+1],dp3[n+1];
    dp1[1] = a[1];
    dp2[1] = b[1];
    dp3[1] = c[1];

    

    rep(i,2,n)
    {
      dp1[i] = max(dp2[i-1] + a[i],dp3[i-1]+a[i]);
      dp2[i] = max(dp1[i-1]+b[i],dp3[i-1]+b[i]);
      dp3[i] = max(dp1[i-1]+c[i],dp2[i-1]+c[i]);
    }

      cout << max({dp1[n],dp2[n],dp3[n]});

   return 0;
}  

Measured memory_bytes: 4992
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

s = list(input())
t = list(input())
n = len(s)
for i in range(n):
    tmp = [s[-1]] + s[:n-1]
    s = tmp[::]
    if s == t:
        print('Yes')
        break
else:
    print('No')

Measured memory_bytes: 5332
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#include <sstream>
#include <bitset>
#define ALL(x) (x).begin(), (x).end()
#define sz(a) int(a.size())
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define chu(x)  if(DEBUG_Switch) cout<<"["<<#x<<" "<<(x)<<"]"<<endl
#define du3(a,b,c) scanf("%d %d %d",&(a),&(b),&(c))
#define du2(a,b) scanf("%d %d",&(a),&(b))
#define du1(a) scanf("%d",&(a));
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
ll powmod(ll a, ll b, ll MOD) { if (a == 0ll) {return 0ll;} a %= MOD; ll ans = 1; while (b) {if (b & 1) {ans = ans * a % MOD;} a = a * a % MOD; b >>= 1;} return ans;}
ll poww(ll a, ll b) { if (a == 0ll) {return 0ll;} ll ans = 1; while (b) {if (b & 1) {ans = ans * a ;} a = a * a ; b >>= 1;} return ans;}
void Pv(const vector<int> &V) {int Len = sz(V); for (int i = 0; i < Len; ++i) {printf("%d", V[i] ); if (i != Len - 1) {printf(" ");} else {printf("\n");}}}
void Pvl(const vector<ll> &V) {int Len = sz(V); for (int i = 0; i < Len; ++i) {printf("%lld", V[i] ); if (i != Len - 1) {printf(" ");} else {printf("\n");}}}
inline long long readll() {long long tmp = 0, fh = 1; char c = getchar(); while (c < '0' || c > '9') {if (c == '-') fh = -1; c = getchar();} while (c >= '0' && c <= '9') tmp = tmp * 10 + c - 48, c = getchar(); return tmp * fh;}
inline int readint() {int tmp = 0, fh = 1; char c = getchar(); while (c < '0' || c > '9') {if (c == '-') fh = -1; c = getchar();} while (c >= '0' && c <= '9') tmp = tmp * 10 + c - 48, c = getchar(); return tmp * fh;}
const int maxn = 1000010;
const int inf = 0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
#define DEBUG_Switch 0
ll n;
ll ans;
int solve(ll x, ll k)
{
    if (k == 1)
        return 0;
    while (x >= k)
    {
        if ((x % k) == 0)
        {
            x /= k;
        } else
        {
            x %= k;
        }
    }
    return x == 1;
}
int main()
{
#if DEBUG_Switch
    freopen("C:\\code\\input.txt", "r", stdin);
#endif
    //freopen("C:\\code\\output.txt","r",stdin);
    n = readll();
    for (ll i = 1ll; i * i <= n; ++i)
    {
        if (n % i == 0)
        {
            ans += solve(n, i);
            if (i * i != n)
            {
                ans += solve(n, n / i);
            }
        }
    }
    n--;
    for (ll i = 1ll; i * i <= n; ++i)
    {
        if (n % i == 0)
        {
            ans += solve(n + 1, i);
            if (i * i != n)
            {
                ans += solve(n + 1, n / i);
            }
        }
    }
    printf("%lld\n", ans );

    return 0;
}




Measured memory_bytes: 256
use std::io;


/// https://beta.atcoder.jp/contests/abc063/tasks/abc063_b
fn main() {
    let mut s = read_one::<String>().chars().collect::<Vec<char>>();
    let bef = s.len();
    s.sort();
    s.dedup();
    let aft = s.len();
    if bef == aft { println!("yes"); }
    else { println!("no"); }
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

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

int a[4];

int main(){
	int total = 0;
	for(int i=0;i<3;i++){
		int x;
		scanf("%d",&x);
		total+=x;
	}
	if(total >= 22) printf("bust\n");
	else printf("win\n");
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"


int main() {
	vector<string>emacs;
	while (1) {
		string st;
		getline(cin, st);
		
		if (st == "END_OF_TEXT") {
			break;
		}
		else {
			emacs.push_back(st);
		}
	}
	int x = 0, y = 0;
	vector<string>buf;
	while (1) {
		char c; cin >> c;
		switch (c) {
		case 'a':
			x = 0;
			break;
		case 'e':
			x = emacs[y].size();
			break;
		case 'p':
			if (y) {
				y--;
			}
			x = 0;
			break;
		case 'n':
			if (y != emacs.size() - 1) {
				y++;
			}
			x = 0;
			break;
		case 'f':
			if (x != emacs[y].size())x++;
			else {
				if (y != emacs.size() - 1) {
					y++;
					x = 0;
				}
			}
			break;
		case 'b':
			if (x)x--;
			else {
				if (y) {
					y--;
					x = emacs[y].size();
				}
			}
			break;
		case 'd':
			if (x != emacs[y].size()) {
				emacs[y].erase(emacs[y].begin() + x);
			}
			else {
				if (y != emacs.size() - 1) {
					emacs[y].insert(emacs[y].end(), emacs[y + 1].begin(), emacs[y + 1].end());
					emacs.erase(emacs.begin() + y + 1);
				}
			}
			break;
		case 'k':
			if (x == emacs[y].size()) {
				if (y != emacs.size() - 1) {
					emacs[y].insert(emacs[y].end(), emacs[y + 1].begin(), emacs[y + 1].end());
					emacs.erase(emacs.begin() + y + 1);
					buf = vector<string>(1);
				}
			}
			else {
				buf = vector<string>(1, emacs[y].substr(x));
				emacs[y].erase(emacs[y].begin() + x, emacs[y].end());
			}
			break;
		case 'y':
			if (buf.empty()) {

			}
			else {
				if (buf[0] == "") {
					string rest = emacs[y].substr(x);
					emacs[y].erase(emacs[y].begin() + x, emacs[y].end());
					emacs.insert(emacs.begin() + y+1, rest);
					y++;
					x = 0;
				}
				else {
					emacs[y].insert(emacs[y].begin() + x, buf[0].begin(), buf[0].end());
					x += buf[0].size();
				}
			}
			break;
		}
		if (c=='-')break;/*
		for (auto s : emacs) {
			cout << s << endl;
		}
		cout << "x: " << x << endl << "y: " << y << endl;*/
	}
	for (auto s : emacs) {
		cout << s << endl;
	}
	return 0;
}

Measured memory_bytes: 3096
import sys

input = sys.stdin.readline

s = input()

a = int(s[0])
b = int(s[1])
c = int(s[2])
d = int(s[3])

if a + b + c + d == 7:
    print(str(a) + "+" + str(b) + "+" + str(c) + "+" + str(d) + "=7")
elif a + b + c - d == 7:
    print(str(a) + "+" + str(b) + "+" + str(c) + "-" + str(d) + "=7")
elif a + b - c + d == 7:
    print(str(a) + "+" + str(b) + "-" + str(c) + "+" + str(d) + "=7")
elif a + b - c - d == 7:
    print(str(a) + "+" + str(b) + "-" + str(c) + "-" + str(d) + "=7")
elif a - b + c + d == 7:
    print(str(a) + "-" + str(b) + "+" + str(c) + "+" + str(d) + "=7")
elif a - b + c - d == 7:
    print(str(a) + "-" + str(b) + "+" + str(c) + "-" + str(d) + "=7")
elif a - b - c + d == 7:
    print(str(a) + "-" + str(b) + "-" + str(c) + "+" + str(d) + "=7")
elif a - b - c - d == 7:
    print(str(a) + "-" + str(b) + "-" + str(c) + "-" + str(d) + "=7")


Measured memory_bytes: 3064
// Therefore
#include <cmath>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;

int main() {
    int N; cin >> N;
    int x = N % 10;
    if (x == 2 || x == 4 || x == 5 || x == 7 || x == 9) cout << "hon" << endl;
    if (x == 0 || x == 1 || x == 6 || x == 8) cout << "pon" << endl;
    if (x == 3) cout << "bon" << endl;
    return 0;
}

Measured memory_bytes: 3592
import math
def p(d): print(d)
def i(): return input()

def LI():  # Line Integer
    # 1行 1つの数字
    return int(input())
def LIS():  # Line IntegerS
    # 1行 mつの数字
    return [int(x) for x in input().split()]
def MLIS(n):  # Multi Line IntegerS
    # n行 mつの数字
    return [[int(x) for x in input().split()] for y in range(n)]
def LC():  # Line Character
    # 1行 1つの文字列
    return input()
def LCS(): # Line CharacterS
    # 1行 nつの文字列
    return [x for x in input().split()]
def MLCS(n): # Multi Line CharacterS
    # n行 mつの文字列
    return [[x for x in input().split()] for y in range(n)]

def alp2int(alphabet):
    # アルファベットの番号を返す
    return ord(alphabet) - ord('a')
def int2alp(num):
    # 番号からアルファベットを返す
    return chr(num + ord('a'))
def cnt2dic(lst, dic={}):
    # 同じものをカウントして辞書型にする
    for x in lst:
        key = str(x)
        if key in dic:
            dic[key] += 1
        else:
            dic[key] = 1
    return dic
def dic2lst(dic, key=lambda x:x[1]):
    # 辞書をタプルの配列にする
    return sorted(list(dic.items()), key=key);

def unqlst(lst):
    return list(set(lst))

def A():
    a = LC()
    if a[0] == a[2]:
        print('Yes')
    else:
        print('No')

def B():
    a, b, c, d = LIS()
    s = max(a, c)
    e = min(b, d)
    if s < e:
        p(e-s)
    else:
        p(0)

def C():
    N = LI()
    reds = sorted(MLIS(N), key=lambda x:x[0])
    blues = sorted(MLIS(N), key=lambda x:x[0])

    blueF = [False for x in range(N)]

    count = 0

    for i in range(N):
        for j in range(N):
            if blueF[j] == False and reds[i] < blues[j]:
                blueF[j] = True
                count += 1
                break
    print(count)

def D():
    pass

def E():
    s = LC()
    k = LI()
    words = []
    for b in range(len(s)):
        for e in range(1, 6):
            if s[b:b+e] != '':
                words.append(s[b:b+e])
    words = sorted(unqlst(words))
    print(words[k-1])
def F():
    pass

def G():
    pass

def H():
    pass

E()


Measured memory_bytes: 5176
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
typedef long long ll ;
#define rep(i, a, b) for (int i = a; i <= b; ++i)
using namespace std;

template <typename tn> void read (tn & a) {
	tn x = 0, f = 1; char c = getchar();
	while (c < '0' || c > '9'){ if (c == '-') f = -1; c = getchar(); }
	while (c >= '0' && c <= '9'){ x = x * 10 + c - '0'; c = getchar(); }
	a = f == 1 ? x : -x;
}

const int MAXN = 210000;
const int Ln = 22;
const int INF = 2e9;
int n, k, q, x;
int a[MAXN], b[MAXN];
int ans;
priority_queue<int> que;

int count (int x) {
	rep(i, 1, n) b[i] = a[i];
	while (!que.empty()) que.pop();
	int i = 1;
	while (i <= n) {
		while (b[i] < x) { ++i; }
		if (i > n) continue;
		int j = i;
		while (j < n && b[j + 1] >= x) ++j;
		sort(b + i, b + j + 1);
		rep(l, i, j - k + 1) {
			que.push(-b[l]);
		}
		i = j + 1;
	}
	int an = 0;
	rep(i, 1, q) {
		if (que.empty()) return INF;
		an = -que.top();
		que.pop();
	}
	return an;
}

void solve () {
	ans = INF;
	rep(xx, 1, n) {
		x = a[xx];
		ans = min(ans, count(x) - x);
	}
} 

int main() {
//	freopen("in.txt","r",stdin);
	read(n);
	read(k);
	read(q);
	rep(i, 1, n) read(a[i]);
	solve();
	cout << ans << "\n";
	return 0;
} 


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(a) a.begin(),a.end()
int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    REP(i,N)cin >> A[i];
    int p = 0;
    bool exist = false;
    REP(i,N){
        if(A[i]==p+1){
            exist = true;
            p ++;
        }
    }
    if(exist)cout << N-p << endl;
    else cout << "-1" << endl;
    return 0;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
    
    public static void main(String[] args) {

        Scanner sc = null;
        sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long c = sc.nextLong();
        long d = sc.nextLong();
        sc.close();

        ArrayList<Long> numList = new ArrayList<Long>();
        numList.add(a * c);
        numList.add(a * d);
        numList.add(b * c);
        numList.add(b * d);

        System.out.println(Collections.max(numList));

    }
}

Measured memory_bytes: 36088
#include<stdio.h>
#define lint long long
#define rep(i,n) for(lint i=0;i<n;i++)
int main(void){
    int a,b,c,x,cnt=0;
    scanf("%d%d%d%d",&a,&b,&c,&x);
    rep(i,a+1)rep(j,b+1)rep(k,c+1){
        if(i*500+j*100+k*50==x)cnt++;
    }
    printf("%d",cnt);
    return 0;
}

Measured memory_bytes: 128