akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"math/rand"
	"time"
	"os"
	"bufio"
	"fmt"
	"strconv"
	"strings"
)

var(
	sc = bufio.NewScanner(os.Stdin)
	mod = 1000000007
	mod9 = 1000000009
)

func init()  {
	rand.Seed(time.Now().UnixNano())
	buf := make([]byte, 0) //ここのサイズは何でもよさそう
	sc.Buffer(buf, 1000000009)
}


//||||||||||||||||||||||||||入力|||||||||||||||||||||||||||||||||||||||\
//数字一文字入力
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

//文字列を一行入力
func nextLine() string {
	sc.Scan()
	return sc.Text()
}

//空白区切りの文字列の入力
func spaceLine() []string {
	sc.Scan()
	return strings.Split(sc.Text()," ")
}

//数字を一行入力
func intLine() []int {
	str := spaceLine()
	buf := make([]int,len(str))
	for i,s:=range str{
		buf[i],_ = strconv.Atoi(s)
	}
	return buf
}

//|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

//ソートする
//sは最初のインデックス fは最後のインデックス
func Sort(ls []int,l int,r int)  {
	if r - l <= 0{return}
	pipot := l + rand.Intn(r-l+1)
	ls[r],ls[pipot] = ls[pipot],ls[r]
	i := l
	for j:=l;j<r;j++{
		if ls[j] < ls[r]{
			ls[i],ls[j] = ls[j],ls[i]
			i ++
		}
	}
	ls[i],ls[r] = ls[r],ls[i]
	Sort(ls,l,i-1)
	Sort(ls,i+1,r)
}

//配列の大小を指定した要素で比較
//a < bならtrue
func sizeCheck(a []int,b []int,ls []int) bool {
	for _,i:= range ls{
		if a[i] < b[i]{
			return true
		} else if a[i] > b[i] {
			return false
		}
	}
	return false
}

//二次元配列のソート
func Sort2D(ls [][]int,l int,r int,index ...int)  {
	if r - l <= 0{return}
	pipot := l + rand.Intn(r-l+1)
	ls[r],ls[pipot] = ls[pipot],ls[r]
	i := l
	for j:=l;j<r;j++{
		if sizeCheck(ls[j],ls[r],index){
			ls[i],ls[j] = ls[j],ls[i]
			i ++
		}
	}
	ls[i],ls[r] = ls[r],ls[i]
	Sort2D(ls,l,i-1,index ...)
	Sort2D(ls,i+1,r,index ...)
}

func main() {
	o := intLine()
	n,k := o[0],o[1]
	v := intLine()
	ans := 0
	for i:=0;i<k+1;i++{
		for j:=0;j<k-i+1;j++{
			if i + j > n{continue}
			dmax := k - i - j
			score := 0
			ls := make([]int,i+j)
			for l:=0;l<i;l++{
				ls[l] = v[l]
				score += v[l]
			}
			for l:= n - j;l<n;l++{
				ls[i+l-n+j] = v[l]
				score += v[l]
			}
			Sort(ls,0,len(ls)-1)
			for l:=0;l<min(len(ls),dmax);l++{
				if ls[l] >= 0{break}
				score -= ls[l]
			}
			if ans < score{ans = score}
		}
	}
	fmt.Println(ans)
}

func min(a ...int) int {
	ans := a[0]
	for i:=1;i<len(a);i++{
		if ans > a[i]{
			ans = a[i]
		}
	}
	return ans
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(void){
    int n, m, x, y, a, amax = -200, b, bmin = 200;
    cin >> n >> m >> x >> y;
    for (int i = 1; i <= n; i++) {
        cin >> a;
        if (amax < a) amax = a;
    }
    for (int i = 1; i <= n; i++) {
        cin >> b;
        if (bmin > b) bmin = b;
    }
    if (amax < bmin && x < bmin && y >= bmin) cout << "No War";
    else cout << "War";
    
    return 0;
}


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

int main(){
    vector<int> x(5); rep(i,0,5) cin >> x[i];
    rep(i,0,5){
        if(x[i] == 0) cout << i+1 << endl;
    }
}

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

int main() {
    string s, t;
    cin >> s >> t;
    bool flag = true;
    if((s.length()+1) == t.length()){
        for(int i = 0; i < s.length(); i++){
            if(s.at(i)!=t.at(i)){
                flag = false;
                break;
            }
        }
    }
    else flag = false;

    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3600
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <string>
#include <vector>
using namespace std;
using ll = int64_t;
#define rep(i, j, n) for (int i = j; i < (int)n; ++i)
#define rrep(i, j, n) for (int i = (int)n - 1; j <= i; --i)

int main() {
  int n;
  cin >> n;
  int ans = 111;
  while (ans < n) ans += 111;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define ll long long
#define Arman_Sykot ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
 
using namespace std;

int main() {
/*********************/
// Author:
        Arman_Sykot;
/*********************/

	int n;
	cin >> n;
	string s = "ACL";
	
	for (int i = 0; i < n; i++) 
		cout << s; 	
	return 0;
} 


Measured memory_bytes: 3516
#include <bits/stdc++.h>
#include <string>
#include <vector>
using namespace std;
int main()
{
    int n;

    cin >> n;

    if(n % 2 == 0){
        cout << n / 2 << endl;
    }else{
        cout << (n / 2) + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def mod_com_once(n, r, MOD):
    if n < r or n < 0 or r < 0:
        return 0
    r = min(r, n - r)
    numer = denom = 1
    for i in range(n - r + 1, n + 1):
        numer = numer * i % MOD
    for i in range(1, r + 1):
        denom = denom * i % MOD
    return numer * pow(denom, MOD - 2, MOD) % MOD


def main():
    n, a, b = map(int, read().split())

    ans = (pow(2, n, MOD) - mod_com_once(n, a, MOD) - mod_com_once(n, b, MOD) - 1) % MOD

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 63528
#include <bits/stdc++.h>
#define INF 1000000000
#define MAXN 110000
using namespace std;

long long h[MAXN], dp[MAXN];
int N, K;

int main()
{
    fill(dp, dp + MAXN, INF);
    cin >> N >> K;
    for (int i = 0; i < N; i++)
    {
        cin >> h[i];
    }
    dp[0] = 0;
    for (int i = 0; i < N - 1; i++)
    {
        for (int j = 1; j <= K; j++)
        {
            dp[i + j] = min(dp[i + j], dp[i] + abs(h[i + j] - h[i]));
        }
    }
    cout << dp[N - 1];
    return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;
 
int main(){

    int N;
    string S;
    cin>>N>>S;

    if(N<3200){
        cout <<"red"<<endl;
    }else{
        cout<<S<<endl;
    }

    return 0;
}

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
string to_str(ll x){string res; while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return res;}
template<class T> inline bool chmax(T& a,T b){ if(a<b){a=b;return 1;}return 0; }
template<class T> inline bool chmin(T& a,T b){ if(a>b){a=b;return 1;}return 0; }
//template end



int main(){
    int m; scanf("%d",&m);
    ll res=0,sum=0;
    rep(i,0,m){
        ll d,c; scanf("%lld%lld",&d,&c);
        sum+=d*c; res+=c;
    }
    res--; res+=(sum-1)/9;
    printf("%lld\n",res);
    return 0;
}

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

using namespace std;

int main()
{
    int n, a[100], cnt=0;
    cin>>n;
    for (int i=0; i<n; i++) cin>>a[i];
    for (int i=0; i<n-1; i++)
    {
        for (int j=0; j<n-1; j++)
        {
            if (a[j]>a[j+1])
            {
                swap(a[j], a[j+1]);
                cnt++;
            }
        }
    }
    for (int i=0; i<n; i++)
    {
        if (i!=n-1) cout<<a[i]<<' ';
        else cout<<a[i]<<'\n';
    }
    cout<<cnt<<'\n';
    return 0;
}



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

#define ll long long
#define vec vector<ll>
#define sortv(a); sort(a.begin(), a.end());
#define rev(a); reverse(a.begin(), a.end());
#define FOR(i,a,b) for (ll i = (ll)(a); i < (b); i++)
#define ROF(i,a,b) for (ll i = (ll)(b)-1; i >= (a); i--)

ll MOD = 1000000007;
ll INF = 1LL << 60;

/*****************************************************************************/


void solve() {
	
}

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	char c;cin>>c;
	if (c=='z') {
		cout<<'a';
	} else {
		cout<<(char)((int)(c+1));
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define Graph vector<vector<ll>>
#define INF (1ll<<60)
#define mod 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    ll n,k;cin>>n>>k;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];

    
    ll dp[50][2];// i桁目を見ている　smaller?
    rep(i,50) dp[i][false]=dp[i][true]=-1;//default
    dp[45][false]=0;//必ず0(大きいところは)

    for(ll i=44;i>=0;i--){
        ll twopow=1ll<<i;//高い桁から順に見る
        ll num=0;

        rep(j,n) if(a[j]&twopow) num++;//i桁目に立っているbitの数(a[i]に関して)

        if(dp[i+1][true]>=0){
            //前の桁smallerの時->max(今1のとき,今0のとき)
            chmax(dp[i][true],dp[i+1][true]+twopow*max(num,n-num));
            chmax(dp[i][false],dp[i+1][true]+twopow*max(num,n-num));
        }
        if(dp[i+1][false]>=0){
            if(k&twopow){//今見ている桁が1の時(k)
                
                //今の桁に対してsmallerの場合->0なので、i桁目の個数は不変でnumのまま
                chmax(dp[i][true],dp[i+1][false]+twopow*num);
                
                //一致する時->1なので、i桁目の個数はxor1によって変化し,n-num
                chmax(dp[i][false],dp[i+1][false]+twopow*(n-num));
            }else{//今見ている桁は0(k)
                
                //i桁目に関しては0しかないので一致しかない->i桁目不変
                chmax(dp[i][false],dp[i+1][false]+twopow*num);
            }
        }
    }

    cout<<max(dp[0][true],dp[0][false])<<endl;
    return 0;
}

Measured memory_bytes: 4044
import sys,re
for e in sys.stdin:
 for i in'0123456789'[any([len(x)>1 and x[0]=='X' for x in re.split('[+=]',e.strip())]):]:
  l,r=e.replace('X',i).split('=')
  if sum(map(int,l.split('+')))==int(r):print(i);break
 else:print('NA')


Measured memory_bytes: 6564
#include<iostream>
#include<cstdio>
using namespace std;
int n,m,b[1010][1010],c[1010][1010];
char a[1010][1010],S[10]=".#";
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	scanf("%s",a[i]+1);
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		if(i==1) b[i][j]=1;
		else if(i==n) c[i][j]=1;
		else if(a[i][j]=='#') b[i][j]=c[i][j]=1;
		else if(j&1) b[i][j]=1;
		else c[i][j]=1;
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		printf("%c",S[b[i][j]]);
		puts("");
	}puts("");
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		printf("%c",S[c[i][j]]);
		puts("");
	}
	return 0;
}

Measured memory_bytes: 8448
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

int v[5048][5048];
int main()
{	
	int n, m;
	scanf("%d %d", &n, &m);
	
	rep(i, m)
	{
		int x, y, l;

		cin >> y >> x >> l;
		
		chmax(v[y][x], l + 1);
	}
	
	int res = 0;
	REP(y, 1, n + 1) REP(x, 1, y + 1)
	{
		chmax(v[y][x], max(v[y-1][x] - 1, v[y-1][x-1] - 1));
		
		res += 0 < v[y][x];
	}
	
	cout << res << endl;
}

Measured memory_bytes: 28000
#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(){
    int H,W,D;
    cin >> H >> W >> D;
    vector<int> X(H*W),Y(H*W);
    rep(i,0,H)rep(j,0,W){
        int a;
        cin >> a;
        X[a-1] = j;
        Y[a-1] = i;
    }
    int dist[H*W] = {};
    rep(i,0,D){
        for(int j = i + D;j < H*W;j += D){
            dist[j] = dist[j-D] + abs(X[j] - X[j-D]) + abs(Y[j] - Y[j-D]);
        }
    }
    int Q;
    cin >> Q;
    rep(i,0,Q){
        int l,r;
        cin >> l >> r;
        cout << dist[r-1] - dist[l-1] << endl;
    }
}

Measured memory_bytes: 2176
//***Little by little one travels far***
 
#include<bits/stdc++.h>
using namespace std;
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
 
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
//ll fact[5*1000001];
ll m=1e9+7;

ll fpow(ll a,ll p){
    if(p==0) return(1);
    ll b=fpow(a,p/2);
    if(p%2==0) return((b*b)%m);
    else return((((b*b)%m)*a)%m);
}

ll fun(ll n){
    ll p=1;
    for(ll i=1;i<=n;i++)
    p=(p*i)%m;
    return(p);
}

int main()
{
    ll x,y;
    cin>>x>>y;
    if((x+y)%3!=0){
        cout<<"0";
        return 0;
    }

    /*fact[0]=1;
    for(ll i=1;i<=5*1000000;i++)
    fact[i]=(fact[i-1]*i)%m;
    */
    ll n=(x+y)/3;
    //cout<<n<<" ";
    if(((x+y)!=3*n)||(x<n)||(y<n)){
        cout<<"0";
        return 0;
    }
    ll an=fun(n);
    //cout<<an<<" ";
    an=(an*fpow(fun(x-n),m-2))%m;
    an=(an*fpow(fun(2*n-x),m-2))%m;
    cout<<an;
}

Measured memory_bytes: 256
n = gets.to_i
m = gets.to_i
cards = (1..2*n).to_a

m.times do
  k = gets.to_i
  if k == 0
    new_cards = Array.new
    n.times do |i|
      new_cards << cards[i] << cards[n+i]
    end
    cards = new_cards
  else
    cards = cards[k...2*n] + cards[0...k]
  end
end

puts cards

Measured memory_bytes: 7560
#include <bits/stdc++.h>
using namespace std;
#define all(n) begin(n), end(n)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    int K, T;
    cin >> K >> T;
    vint a(T);
    for (size_t i = 0; i < T; i++)
    {
        cin >> a[i];
    }
    int prev = -1, ans = 0;
    while (K > 0)
    {
        int M = *max_element(all(a)),M2=0;
        bool ok = false;
        for (size_t i = 0; i < T; i++)
        {
            if(prev != i and a[i] == M)
            {
                prev = i;
                a[i]--;
                ok=true;
                break;
            }
        }
        if(!ok)
        {
        for (size_t i = 0; i < T; i++)
        {
            if(prev != i)
            {
                chmax(M2,a[i]);
            }
        }
        for (size_t i = 0; i < T; i++)
        {
            if(prev != i and a[i] == M2 and M2 > 0)
            {
                prev = i;
                a[i]--;
                ok=true;
                break;
            }
        }
        if(!ok)
        {
            for (size_t i = 0; i < T; i++)
            {
                if(a[i]==M)
                a[i]--;
            }
            
        ans++;
        }

        }
        K--;
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

#define REPI(x) for(int i=0;i<x;i++)
#define REPJ(x) for(int j=0;j<x;j++)

int main(){
    int N,M;
    int bufb,bufc;

    scanf("%d%d",&N,&M);
    vector<int> A(N);
    vector<pair<int, int> > p(M);
    for(int i=0;i<N;i++)
        scanf("%d",&A[i]);

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

    for(int i=0;i<M;i++){
        scanf("%d%d",&bufb,&bufc);
        p[i] = make_pair(bufc,bufb);
    }

    sort(p.begin(),p.end(),greater<pair<int, int> >());
    int amin = 0;
    for(int i=0;i<M;i++){
        if(p[i].first<A[amin])
            break;
        for(int j=0;j<p[i].second;j++){
            if(A[amin]<p[i].first){
                A[amin]=p[i].first;
                amin++;
            }
            else
                break;
        }
    }

    long long res=0;
    for(int i=0;i<N;i++)
        res+=A[i];
    
    printf("%lld\n",res);
    return 0;
}

Measured memory_bytes: 1408
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		try {
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			String integers = br.readLine();
			System.out.println(sort(toIntArray(integers)));
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	private static int[] toIntArray(String stringArray) {
		String[] integerss = stringArray.split(" ");
		int[] IntArray = new int[5];
		IntArray[0] = Integer.parseInt(integerss[0]);
		IntArray[1] = Integer.parseInt(integerss[1]);
		IntArray[2] = Integer.parseInt(integerss[2]);
		IntArray[3] = Integer.parseInt(integerss[3]);
		IntArray[4] = Integer.parseInt(integerss[4]);
		return IntArray;
	}

	private static String sort(int[] integers) {
		int W = integers[0];
		int H = integers[1];
		int x = integers[2];
		int y = integers[3];
		int r = integers[4];
		if (x - r < 0 || y - r < 0) {
			return "No";
		} else if (x + r > W || y + r > H) {
			return "No";
		}
		return "Yes";
	}
}


Measured memory_bytes: 24260
N,A,B,C,D = map(int,input().split())
s = input()
#print(s)
if "##" in s[B:D] or "##" in s[A:C]:
  print("No")
  exit()
elif C > D and "..." not in s[B-2:D+1]:
  print("No")
  exit() 
print("Yes")

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
int main(void){
   string N;
   cin >> N;
   if(N[0] == N[1] && N[0] == N[2]) cout << "Yes" << endl;
   else if(N[3] == N[1] && N[3] == N[2]) cout << "Yes" << endl;
   else cout << "No" << endl;
}


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val a = (0 until n).map { sc.next().toLong() }
    println(problem125d(n, a))
}

fun problem125d(n: Int, a: List<Long>): Long {
    if (a.contains(0)) return a.map { Math.abs(it) }.sum()
    if (a.count { it < 0L } % 2 == 0) {
        return a.map { Math.abs(it) }.sum()
    }
    val min = a.map { Math.abs(it) }.min()!!
    return a.map { Math.abs(it) }.sum() - (min * 2)
}

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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

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); }

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

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}


int n;
string s;
ll dp[3005][3005];

int main(){
  cin>>n>>s;
  
  rep(i,n) dp[0][i]=1;
  
  rep(i,n-1){
    if(s[i]=='<'){
      for(int j=n-2; j>=0; j--) (dp[i+1][j]=dp[i+1][j+1]+dp[i][j+1])%=MOD;
    
    }else{ // >
      for(int j=0; j<n-i-1; j++){
        dp[i+1][j]=dp[i][j];
        if(j-1>=0) (dp[i+1][j]+=dp[i+1][j-1])%=MOD;
      }
    }
  }
  
  cout<<dp[n-1][0]<<endl;
}

Measured memory_bytes: 70656
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>

using namespace std;


int main(int argc, char const *argv[])
{
    vector<int> bel(3);

    for(auto &x:bel){
        cin>>x;
    }

    cout<<accumulate(bel.begin(),bel.end(),0)-*max_element(bel.begin(),bel.end())<<endl;


    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int m, n; string s; vector<int> vec;
int main() {
	while(cin >> m >> n,m) {
    int cnt = 0;
    vec.clear();
		for(int i=1; i<=m; i++) vec.push_back(i);
		for(int i=1; i<=n; i++) {
			cin >> s;
			if(i%15 == 0) {
				if(s != "FizzBuzz" && vec.size()-1) vec.erase(vec.begin()+cnt);
				else cnt++;
			}
			else if(i%3 == 0) {
				if(s != "Fizz" && vec.size()-1) vec.erase(vec.begin()+cnt);
				else cnt++;
			}
			else if(i%5 == 0) {
				if(s != "Buzz" && vec.size()-1) vec.erase(vec.begin()+cnt);
				else cnt++;
			}
			else {
				if(s != to_string(i) && vec.size()-1) vec.erase(vec.begin()+cnt);
				else cnt++;
			}
			cnt %= vec.size();
		}
		for(int i=0; i<vec.size(); i++) {
			if(i) cout << " ";
			cout << vec[i];
		}
		cout << endl;
	}
}


Measured memory_bytes: 3216
a=int(input())
b=int(input())
c=int(input())
x=int(input())
count=0

for i in range(a+1):
  for j in range(b+1):
    for h in range(c+1):
      if i*500+j*100+h*50==x:
        count+=1
print(count)
  

Measured memory_bytes: 39536
import java.util.*;

public class Main{
 public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
    int A =sc.nextInt();
    int B =sc.nextInt();
    int T =sc.nextInt();
    int count = T/A;
    int sum=0; 
   
for(int i=0;i<count;i++){
  sum+=B;
}
     System.out.print(sum);
   }
}

Measured memory_bytes: 25172
N = int(input())
A = list(map(int, input().split()))
ans = 0
for i in range(len(A)-1):
  if (i+1 == A[i]):
    ans += 1
    A[i],A[i+1] = A[i+1],A[i]
if (A[-1] == len(A)):
  ans += 1
print(ans)

Measured memory_bytes: 52908
def prime_number(a):
    if a ==2 : return True

    if not a==1 and not a%2==0:
        k = 3
        while k <= a**(1/2):
            if a % k == 0:
                return False
                break
            k += 2
        return True


count_pn = 0
for i in range(int(input())):
    a = int(input())
    if prime_number(a):
        count_pn += 1
print(count_pn)

Measured memory_bytes: 7744
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <list>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

using Edges = vector<int>;
using Graph = vector<Edges>;

Graph graph;
vector<int> colors;

bool dfs(int v, int col) {
    colors[v] = col;

    for (auto e : graph[v]) {
        if (colors[e] == col) return false;
        if (colors[e] == 0 and not dfs(e, -col)) return false;
    }
    return true;
}

int main() {
    LL n, m; cin >> n >> m;
    graph.assign(n, Edges());
    rep(i, m) {
        int a, b; cin >> a >> b;
        --a; --b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    colors.assign(n, 0);
    if (dfs(0, 1)) {
        LL black = 0, white = 0;
        rep(i, n) {
            if (colors[i] == -1) white++;
            else if (colors[i] == 1) black++;
        }
        cout << white * black - m << endl;
    } else {
        cout << (n * (n - 1)) / 2 - m << endl;
    }
    return 0;
}


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

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

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

    vector<int> l(N);

    REP(i, N){
        cin >> l[i];
    }

    sort(l.rbegin(), l.rend());

    int len = 0;
    
    REP(i, K)
        len += l[i];
    
    cout << len << endl;
}

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

int main () {
  int N , Y ;
  cin >> N >> Y ;
  
  int res10000 = -1 , res5000 = -1 , res1000 = -1 ;
  
  for ( int a = 0 ; a <= N ; a++ ) {
    for ( int b = 0 ; a + b <= N ; b++ ) {
      int c = N - a - b ;
      if( Y == 10000*a + 5000 * b + 1000 * c ) {
        res10000 = a ;
        res5000 = b ;
        res1000 = c ;
      }
    }
  }
  
  cout << res10000 << ' ' << res5000 << ' ' << res1000 << endl ;
}

Measured memory_bytes: 256
import sys
import math


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())


w, h, n = inintm()

ll = [0,0]
rh = [w,h]

for i in range(n):
    x, y, a = inintm()
    if a == 1:
        ll[0] = max(ll[0], x)
    elif a == 2:
        rh[0] = min(rh[0], x)
    elif a == 3:
        ll[1] = max(ll[1], y)
    else:
        rh[1] = min(rh[1], y)

if rh[0]-ll[0] < 0 or rh[1]-ll[1] < 0:
    print(0)
else:
    print((rh[0]-ll[0])*(rh[1]-ll[1]))

Measured memory_bytes: 9180
from collections import*
H,*A=open(0)
H,W,K=map(int,H.split())
*A,=map(list,A)
for i,a in enumerate(A):
	if'S'in a:j=a.index('S');Q=deque([(0,i,j)])
d=1e9
while Q:
	c,i,j=Q.popleft();d=min(d,i,j,H-i-1,W-j-1)
	if c<K:
		for h,w in((i+1,j),(i,j+1),(i-1,j),(i,j-1)):
			if H>h>-1<w<W and'.'==A[h][w]:A[h][w]=0;Q+=(c+1,h,w),
print(1--d//K)

Measured memory_bytes: 102364
use std::io::*;
use std::str::FromStr;
/* 
The read function reads a string according to each one. 
*/
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

//main function
fn main() {
    let n: usize = read();
    let mut vec: Vec<i32> = Vec::with_capacity(n);
    unsafe{
	vec.set_len(n);
    }
    for i in 0..n{
	let num:i32 = read();
	vec[i] = num;
    }
    vec.sort();
    println!("{}",vec[n/2]-vec[n/2-1]);
}


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

int main(){
  int n;
  cin >> n;
  cout << (n/500)*1000 + ((n%500)/5)*5 << endl; 
  return 0;
}


Measured memory_bytes: 3608
s = input()

a = s[:2]
b = s[2:]

ans = 0

if int(a) <= 12 and int(a) >= 1:
    ans += 2

if int(b) <= 12 and int(b) >= 1:
  ans += 3
  
if ans == 0:
  print("NA")
elif ans == 2:
  print("MMYY")
elif ans == 3:
  print("YYMM")
elif ans == 5:
  print("AMBIGUOUS")


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

int main(){
  int N, K;
  cin >> N >> K;
  
  int l[60];
  for(int i = 0; i < N; i++){
    cin >> l[i];
  }
  
  sort(l, l+N, greater<int>());
  int total = 0;
  for(int i = 0; i < K; i++){
    total += l[i];
  }
  
  cout << total << endl;
}
  


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val k = sc.nextInt()
    val a = sc.nextInt()
    val b = sc.nextInt()
    println(problem165a(k, a, b))
}

fun problem165a(k: Int, a: Int, b: Int): String {
    for (i in a..b) {
        if (i % k == 0) return "OK"
    }
    return "NG"
}

Measured memory_bytes: 36392
import copy
n = int(input())
lst = list(map(int, input().split()))
clst = sorted(copy.deepcopy(lst))
lmed = clst[n // 2 - 1]
rmed = clst[n // 2]
for i in range(n):
  if lst[i] <= lmed:
    print(rmed)
  else:
    print(lmed)

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

class Program
{
    static void Main(string[] args)
    {
        new Program().Solve();
    }

    void Solve()
    {
        Scanner cin = new Scanner();
        string s = cin.Next();
        int numOfMatch = 15;
        int numWin = s.Where(e => e == 'o').Count();
        int remain = numOfMatch - s.Length;
        int needToWin = 8;
        if (needToWin - numWin <= remain)
        {
            Console.WriteLine("YES");
        }
        else
        {
            Console.WriteLine("NO");
        }

    }


}

class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string Next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return Next();
        i = 0;
        return s[i++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public char[] ArrayChar()
    {
        return Next().ToCharArray();
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = NextInt() + add;
        }
        return Array;
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = NextLong() + add;
        }
        return Array;
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = NextDouble() + add;
        }
        return Array;
    }
}

Measured memory_bytes: 11348
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define rrep(i,m,n) for(int i = m; i >= n; i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printa2(x,m,n) for(int i = 0; i < m; i++){ for(int j = 0; j < n; j++){ cout << x[i][j] << " ";} cout << endl;}
#define printp(x,n) for(int i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
typedef struct{
    ll to;
    ll cost;
} edge;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    ll h[100010];
    cin >> N;
    rep(i,0,N){
        cin >> h[i];
    }
    ll dp[100010] = {};
    dp[0] = 0;
    rep(i,0,N){
        if(i == 0){
            dp[i+1] = dp[i] + abs(h[i] - h[i+1]);
        }else{
            dp[i+1] = min(dp[i] + abs(h[i] - h[i+1]), dp[i-1] + abs(h[i-1] - h[i+1]));
        }
        // print(dp[i+1]);
    }
    print(dp[N-1]);
}


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

using namespace std;

int sweets[1280][4];

int main(void)
{
	int n;
	while (cin >> n, n){
		int P, Q, R, C;
		for (int i = 0; i < n; i++){
			cin >> sweets[i][0] >> sweets[i][1] >> sweets[i][2] >> sweets[i][3];
		}
		cin >> P >> Q >> R >> C;
		bool okf = false;
		for (int i = 0; i < n; i++){
			int ni = sweets[i][0], np = sweets[i][1], nq = sweets[i][2], nr = sweets[i][3];
			int cal = np * 4 + nq * 9 + nr * 4;
			if (np > P || nq > Q || nr > R || cal > C){
				continue;
			}
			okf = true;
			cout << ni << endl;
		}
		if (!okf){
			cout << "NA" << endl;
		}
	}

	return 0;
}

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

typedef long long ll;
//typedef ll int;
ll mod = 1000000007;


int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll a, b, c;
    ll ans = -1, first = 0, second = 0;
    ll x, y;
    cin >> a >> b >> c >> x >> y;
    if(2*c <= a && 2*c <= b) first = max(x, y) * 2 * c;
    else if(2*c <= a){
        first += (2*c*x);
        first += max(y-x, 0LL) * b;
    }
    else if(2 * c <= b){
        first += (2 * c * y);
        first += max(x-y, 0LL) * a;
    }
    else if(a + b >= 2*c){
        if(x > y){
            first += 2 * c * y;
            first += (x-y)*a;
        }
        else first += 2*c*x + (y-x) * b;
    }
    else first = (a*x + b *y);
    cout << first << endl;
}

Measured memory_bytes: 256
// B.

#include <iostream>
#include <sstream>
#include <vector>

using namespace std;
typedef pair<int, int> II;

void solve(int n) {
	vector<II> ans;
	int sum = (n * (n + 1)) / 2 - n - ((n % 2) ? 0 : 1);
	for (int i = 1; i <= n; ++i) {
		int ex = (n * (n + 1)) / 2 - i - sum;
		for (int j = 1; j <= n; ++j) {
			if (j != i && j != ex && j > i) {
				ans.push_back(II(i, j));
			}
		}
	}
	cout << ans.size() << endl;
	for (auto kv : ans) {
		cout << kv.first << " " << kv.second << endl;
	}
}

int main(int argc, char *argv[]) {
	int n;
	cin >> n;
	solve(n);
	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<cstdio>
#include<utility>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x,n) for(int i=x;i<n;i++)
using ll=long long;

int N,M;
int X[100],Y[100],h[100];

void gcl(int& x,int& y){
    if(x<y) swap(x,y);
    while(y>0){
        int t=x%y;
        x=y;
        y=t;
    }
    return;
}


int main(){
    int N;cin>>N;
    vector<int> ans;
  if(N==0){
    cout<<0<<endl;
    return 0;
  }  
    while(N!=0){
        int b=(abs)(N%(-2));
        ans.push_back(b);
        N=(N-b)/(-2);
    }
    for(auto it=ans.rbegin();it!=ans.rend();it++){
      cout<<*it;
    }
  cout<<endl;
  return 0;
}

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

int main() {
    ll n,s;
    std::cin >> n>> s;
    
    vector<ll> a(n);
    const ll MOD = 998244353;
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }
    
    vector<vector<ll>> dp(n+1,vector<ll>(3001,0));
    dp[0][0] = 1;
    
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j= 0; j <= s; j++) {
            dp[i+1][j] = dp[i][j];
        }
        for (int j = a[i]; j <= s; j++) {
            dp[i+1][j] += dp[i][j-a[i]];
            dp[i+1][j] %= MOD;
        }
        dp[i+1][a[i]]+=i;
    }
    for (int i = 1; i <= n; i++) {
        ans += dp[i][s];
        ans %= MOD;
    }
    std::cout << ans << std::endl;
}



Measured memory_bytes: 70784
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bits/stdc++.h>
using namespace std;
int main() {
	int c_num=0,l_num=0;
	string s;
	cin>>s;
	if (s[0]!='A') {
		cout<<"WA";
		return 0;
	}
	for (int i=2; i<s.size()-1; i++) {
		if (s[i]=='C')
			c_num++;
	}
	for (int i=1;i<s.size();i++)
		if (s[i]>='a' && s[i]<='z')
			l_num++;
	if (c_num==1 && c_num+l_num==s.size()-1) {
		cout<<"AC";
	} else
		cout<<"WA";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int n, x;
	while (true) {
		cin >> n >> x;
		int count = 0;
		if (n == 0 && x == 0) break;
		int m = (n < x ? n : x);
		int sum_ij;
		for (int i = 1; i <= m - 2; i++) {
			for (int j = i + 1; j <= m - 1; j++) {
				sum_ij = i + j;
				for (int k = j + 1; k <= m; k++) {
					if (sum_ij + k == x) count++;
				}
			}
		}
		cout << count << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
// Problem : F - Division or Substraction
// Contest : AtCoder Beginner Contest 161
// URL : https://atcoder.jp/contests/abc161/tasks/abc161_f
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

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

typedef long long   ll;
const ll mod = 1e9 + 7;

#define speedup_IO      ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,a,n)     for(ll i = a; i < n; i++)
#define ford(i,n,a)     for(ll i = n; i >= a; i--)
#define pb              push_back
#define lb              lower_bound		// first element >= val(itr) 
#define ub              upper_bound		// first element >  val(itr)
#define pll             pair<ll,ll>
#define all(a)          (a).begin(),(a).end()
#define reset(a,x)      memset(a,x,sizeof(a))	//x can be 0 or -1

ll mypow(ll base, ll exp) {ll res = 1; while (exp) {if (exp & 1) res = (res * base) % mod; exp >>= 1, base = (base * base) % mod;} return res;}
ll gcd(ll a, ll b)  { return b ? gcd(b, a % b) : a;            }
ll mult(ll a, ll b) { if (a < 0) {a += mod;} if (b < 0) {b += mod;} return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b)  { if (a < 0) {a += mod;} if (b < 0) {b += mod;} return (a % mod + b % mod) % mod;        }
ll sub(ll a, ll b)  { if (a < 0) {a += mod;} if (b < 0) {b += mod;} return (a % mod + mod - b % mod) % mod;  }

#ifdef LOCAL_TEST
	#include"/home/shrey/debug.h"
#endif

const ll inf = 1e18;
const int nax = 1e5 + 5;

bool check(ll n,ll k)
{
	while(n%k == 0)
	{
		n /= k;
	}
	
	return n%k == 1;
}

void SolveTestCase()
{
	ll n;
	cin>>n;
	
	set<ll>S;
	
	for(ll i=2;i*i<=n;i++)
	{
		if(n%i == 0)
		{
			if(check(n,i))
			{
				S.insert(i);
			}
			if(check(n,n/i))
			{
				S.insert(n/i);
			}
		}
	}
	
	for(ll i=1;i*i<=n-1;i++)
	{
		if((n-1)%i == 0)
		{
			S.insert(i);
			S.insert((n-1)/i);
		}
	}
	
	//cout<<S;
	
	cout<<S.size();
}

int main()
{
	speedup_IO;

	int t = 1;
	//cin >> t;
	forn(i,0,t)
	{
		SolveTestCase();
	}

	return 0;
}


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

int main(){
  long int N,A,B;
  cin >> N >> A >> B;
  long int S=A+B;
  long int set=N/S;
  long int other=N%S;
  long int answer;
  if(other>A){
    answer=set*A+A;
  }
  else{
    answer=set*A+other;
  }
  cout << answer << endl;
}

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

#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mk make_pair
#define mod 1000000007
#define mo 998244353
string str;
//map<int, int>::iterator itr; 
ull bin(ull a, ull n) {
    ull res = 1;
    while (n) {
        if (n & 1) res = 1LL * res * a % mo;
        a = 1LL * a * a % mo;
        n >>= 1;
    }
    return res;
}
void solve(){
ll n;
    cin>>n;
    if(n>=400&&n<=599)
    cout<<"8";
    else if(n>=600&&n<=799)
    cout<<"7";
    else if(n>=800&&n<=999)
    cout<<"6";
    else if(n>=1000&&n<=1199)
    cout<<"5";
    else if(n>=1200&&n<=1399)
    cout<<"4";
    else if(n>=1400&&n<=1599)
    cout<<"3";
    else if(n>=1600&&n<=1799)
    cout<<"2";
    else
    cout<<"1";
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;t=1;
    while(t--){
        solve();
        }
    return 0;
}


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

#define fio                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long
#define ld long double
#define endl "\n"
#define ff first
#define ss second
#define pi pair<ll, ll>
#define PI 3.141592653589793238462643383279502884L
#define mp make_pair
#define pb push_back
#define fall(i, a, b) for (int i = a; i < b; i++)
#define sz(x) (ll) x.size()
#define all(x) x.begin(), x.end()
#define ed cout << "ed";
ll M = 1e9 + 7;

ll mod(ll a, ll m)
{
    if (a == 0)
        return 0;
    else
        return (a % m + m) % m;
}

int main()
{
    fio;
    ll a, b, c, k, s = 0;
    cin >> a >> b >> c >> k;
    if (a >= k)
    {
        s += k;
        k = 0;
    }
    else
    {
        s += a;
        k -= a;
    }
    if (b >= k)
        k = 0;
    else
        k -= b;
    s -= k;
    cout << s;
    return 0;
}

Measured memory_bytes: 3640
//小 心 马 自 立
#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define Debug(v) for (auto i:v) printf("%lld ",i);puts("")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

int main(){
	ll s=read();
	ll x1=1e9,y2=s/x1;
	if (x1*y2<s) ++y2;
	ll x2=1,y1=x1*y2-s;
	printf("%d %d %lld %lld %lld %lld\n",0,0,x1,y1,x2,y2);
}

Measured memory_bytes: 3752
#include <stdio.h>

int main(void)
{
    int A,B,C,D;

    scanf("%d %d %d %d",&A,&B,&C,&D);

    while(1){
        C = C - B;
        if(C <= 0){
            printf("Yes\n");
            return 0;
        }
        A = A - D;
        if(A <= 0){
            printf("No\n");
            return 0;
        }

    }

}

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

int main() {
    cin.tie(0)->sync_with_stdio(false);
	int n, m; cin >> n >> m;
	vector<int> ab(n + 1, 0);
	while (m--) {
		int a, b; cin >> a >> b;
		ab[a]++;
		ab[b]++;
	}
	bool ok = true;
	for (auto x : ab)
		if (x % 2) {
			ok = false;
			break ;
		}
	cout << ((ok == true) ? "YES" : "NO") << '\n';
    return 0;
}


Measured memory_bytes: 3680
N, K = map(int, raw_input().split())

import math
val = K
curr_max = N
result = 0

pow_count = 0
while curr_max >= 1:
    if curr_max >= val:
        ceil = curr_max-math.ceil(val)+1
        result += ceil/N * ((0.5) ** pow_count)
        curr_max = math.ceil(val-1)
    val *= 0.5
    pow_count += 1

print result

Measured memory_bytes: 2568
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int inf{int(1e9)};
int main(void){
  int N, K;
  cin >> N >> K;
  double ans = 0.0;
   for (int i = 1; i <= N; i++){
     double tmp = 1.0 / N;
     int now = i;
     while (now < K){
       now *= 2;
       tmp /= 2;
     }
     ans += tmp;
   }
   cout << fixed << setprecision(10) << ans << endl;
  return 0;
}


Measured memory_bytes: 3756
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}

const ll sp = 426533971;
const ll sp2 = 79328929;

int main() {
    string s,t;
    cin >> s >> t;

    int n = s.size();
    int m = t.size();

    int flag[n+10] = {};
    int now = m % n;
    int start = 0;

    ll hash_s = 0;
    ll hash_t = 0; 
    ll rem = 1;
    ll hash_s2[n+10] = {}; // optional

    // hash_t作成
    rep(i,m){ 
        rem = (rem*sp2) % sp;
        hash_t += (int)t[m-1-i] * rem;
        hash_t %= sp;
    }
    // hash_s作成
    rem = 1;
    rep(i,m){
        rem = (rem*sp2) % sp;
        hash_s += (int)s[(m-1-i)%n] * rem;
        hash_s %= sp;
    }

    rep(i,n){
        if(hash_s==hash_t)flag[i] = 1;
        hash_s2[i] = hash_s; // optional
        hash_s += sp*sp2 - (int)s[start] * rem + (int)s[now];
        hash_s %= sp;
        hash_s *= sp2;
        hash_s %= sp;
        
        now++;
        now %= n;
        start++;
        start %= n;
    }



    int ans[n+10] = {};
    rep(i,n){
        if(flag[i]==1){
            int tmp = 1;
            flag[i] = i+10;
            ll ii = i;
            while(true){
                ii += m;
                ii %= n;
                if(flag[ii]==(i+10)){
                    cout << "-1" << endl;
                    return 0;
                }else if(flag[ii]>1){
                    tmp += ans[ii];
                    flag[ii] = i+10;
                    break;
                }else if(flag[ii]==1){
                    tmp++;
                    flag[ii] = i+10;
                    //break;
                }else{
                    break;
                }
            }
            ans[i] = tmp;
        }
    }
    /*
    rep(i,n)cout << flag[i];
    cout << endl;
    */


    int ma = 0;
    rep(i,n){
        ma = max(ans[i],ma);
    }

    cout << ma<< endl;

    return 0;
}
 
 


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

int main()
{ 
  int a, b, c ;
  cin >> a >> b >> c ;
  vector<int64_t> data(30) ;
  for(int i = 1 ; i < 31 ; i++)
  {
    data.at(i - 1) = i * b + c ;
  }

  bool answer = false ;
  for(int i = 0 ; i < 30 ; i++)
  {
    if(data.at(i) % a == 0)
    {
      answer = true ;
      break ;
    }
  }

  if(answer)
  {
    cout << "YES" << endl ;
  }
  else
  {
    cout << "NO" << endl ;
  }
  
}


Measured memory_bytes: 256
H,W = gets.split.map(&:to_i)

A = []
q = []
H.times do |y|
  s = gets.chomp
  A << Array.new(W) do |x|
    if s[x] == '#'
      q << [x,y]
      0
    else
      -1
    end
  end
end

ans = 0
while q.size > 0
  x,y = q.shift

  ans = A[y][x] + 1

  q << [x-1, y] if x-1 >= 0 && A[y][x-1] < 0 && A[y][x-1] = ans
  q << [x+1, y] if x+1 < W  && A[y][x+1] < 0 && A[y][x+1] = ans
  q << [x, y-1] if y-1 >= 0 && A[y-1][x] < 0 && A[y-1][x] = ans
  q << [x, y+1] if y+1 < H  && A[y+1][x] < 0 && A[y+1][x] = ans
end
puts ans - 1


Measured memory_bytes: 91260