akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define debug(x) cerr << x << " = "(x) << endl;
#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
// 変数はti[D]。これをいじるのみで良い結果を探す
int D;
int p_contest[27];
vector<int> last_contest[27];
int schedule[500][27];
int ti[500];
ll score=0;
ll calc_score(int d){
    ll ans = 0;
    ans += schedule[d][ti[d]];
    last_contest[ti[d]].push_back(d);
    rep(j,1,27){ //penalty
        ans -= p_contest[j] * (d - last_contest[j][last_contest[j].size()-1] );
    }
    return ans;
}

ll move_and_eval(int d,int q){
    try{
    ll sa=0;
    auto result = lower_bound(all(last_contest[ti[d]]),d);
    auto next = result+1;
    auto prev = result-1;
    if(next != last_contest[ti[d]].end()){
        sa -= (*next - *result) * (*result - *prev) * p_contest[ti[d]];
    }else{
        sa -= (D - *result) * (*result - *prev) * p_contest[ti[d]];
    }
    sa -= schedule[d][ti[d]];
    //cout << sa << endl;
    last_contest[ti[d]].erase(result);

    ti[d] = q;
    sa += schedule[d][ti[d]];
    result = upper_bound(all(last_contest[ti[d]]),d);
    prev = result-1;
    sa += (*result - d) * (d - *prev) * p_contest[ti[d]];
    last_contest[ti[d]].insert(result,d);
    //cout << sa << endl;
    return sa;
    }catch(char *str){ 
        return -1;
    }
}

int main(){
    mt19937 mt{ std::random_device{}() };

    clock_t start = clock(); //time calc
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    cin >> D;
    uniform_int_distribution<int> dist1(1, D);
    uniform_int_distribution<int> dist(1, 26);
    rep(i,1,27){
        cin >> p_contest[i];
        last_contest[i].push_back(0);
    }
    rep(i,1,D+1){
        rep(j,1,27){
            cin >> schedule[i][j];
        }
    }
    //greedy
    rep(i,1,D+1){
        ti[i] = 1;
        ll sum = 0;
        rep(j,1,26){ 
            if(sum < schedule[i][j]){
                sum = schedule[i][j];
                ti[i] = j;
            }
        }
        score += calc_score(i);
    }
    //cout << score << endl;
    int cnt = 0;
    while( cnt < 100){
        //int d,q; cin >> d >> q;
        int d = dist1(mt);
        int q = dist(mt);
        int tq = ti[d];
        ti[d] = q;
        //if(move_and_eval(d,q) < 0) ti[d] = tq; 
        //cout << "a" << endl;
        cnt++;
    }
    rep(i,1,D+1){
        cout << ti[i] << endl;
    }
}

Measured memory_bytes: 3756
#include<bits/stdc++.h>
using namespace std;
//unordered_map<string, long long int>dp;
long long int dp[102][100003];

long long int n;
long long int w[103], v[103];

long long int ks(long long int idx, long long int u)
{
	if(u < 0)
	return -1e18;
	if(u == 0)
	return 0;
	if(idx == n)
	return 0;
	 if(u<1e5+2 && dp[idx][u] != -1)
	return dp[idx][u];
	
long long int p1 = v[idx]+ks(idx+1, u-w[idx] );
long long int p2 = ks(idx+1, u);

long long int maxi = max(p1, p2);
return dp[idx][u] = maxi ; 
}
main(){

long long int u;
cin >> n >> u;
long long int i, j;
for(i=0;i<n;i++)
cin >> w[i] >> v[i] ;
 
 for(i=0;i<100002; i++)
 for(j = 0; j<101;j++)
 dp[j][i] = -1;
 
cout << ks(0, u);

return 0;
}


Measured memory_bytes: 79104
#include <stdio.h>
int main(void){
	int a,b,sum=0,i;
	scanf("%d",&a);
	scanf("%d",&b);
	for(i=0;i<2;i++){
		if(a>=b){
			sum = sum + a;
			a = a-1;
		}else{
			sum = sum + b;
			b = b-1;
		}
	}
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 128
fun main(args: Array<String>) = abc161d()

fun abc161d() {
    val k = readLine()!!.toInt()

    val list = mutableListOf<Long>()

    fun dfs(curr: Long) {
        if (curr.toString().length == 12) return
        list.add(curr)
        val max = Math.min(curr % 10 + 1, 9)
        val min = Math.max(curr % 10 - 1, 0)
        if (max in 0..9 && min in 0..9) {
            (min..max).map { dfs(curr * 10 + it) }
        }
    }

    (1..9L).forEach { dfs(it) }

    val answer = list.sorted()[k - 1]

    println(answer)
}


Measured memory_bytes: 124424
(let ((lst (loop repeat (read) collect (read))))
  (do ((l (sort lst #'<) (cdr l))
       (n 1)
       (count 0))
      ((null l) (princ count))
    (if (eql (car l) (cadr l))
	(incf n)
	(and (incf count (if (oddp n) 1 0))
	     (setf n 1)))))
	    

Measured memory_bytes: 69732
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
#include <map>
#include <queue>
#include <cctype>
using namespace std;
using ll = long long;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[100001];
//char str[1010][1010];
//typedef pair<ll,ll> A;
//vector<A> pc;
//int ABS(int a){return max(a,-a);}
int main() {
  int s;
  int y,m;
  cin>>s;
  y=(s/100)%10+(s/1000)*10;//cout<<y;
  m=s%10+(s/10)%10*10;//cout<<m;
  if(y<=12&&m<=12&&y>0&&m>0) cout<<"AMBIGUOUS";
  else if(y==0&&m>0&&m<=12) cout<<"YYMM";
  else if(y>0&&y<=12&&m==0) cout<<"MMYY";
  else if(y<=12&&y>0&&m>=13) cout<<"MMYY";
  else if(y>=13&&m<=12&&m>0) cout<<"YYMM";
  else if(y==0&&m==0) cout<<"NA";
  else cout<<"NA";
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include<iomanip>
#include<limits>
#include <utility>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
#define INF 1e18
 
int main()
{
	
	int N,M;
	cin >> N>>M;
	vector<int> L(N),R(M);
	int l,r;
	int ll = -1;
	int rr = 100021;
	rep(i,M) {
		cin>>l>>r;
		if (l > ll) ll = l;
		if (r < rr) rr = r;
	}
 //cout << ll <<":"<< rr<< endl;
	int ans = (rr - ll +1);
	ans = max(ans,0);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
n = int(input())
s = input()
sample = s.replace("W","1").replace("E","0")
num = 0
num2 = sample.count("0")
sample2 = list(map(int, sample))
sample2.insert(0,0)
sample3 = s.replace("W","0").replace("E","1")
sample4 = list(map(int, sample3))
out = n
for i in range(n):
    num += sample2[i]
    num2 -= sample4[i]
    out = min(num+num2,out)
print(out)

Measured memory_bytes: 8908
s = input()
if s[0] == s[1] and s[1] != s[2] and s[2] == s[3]:
    print("Yes")
elif s[0] == s[2] and s[1] != s[0] and s[1] == s[3]:
    print("Yes")
elif s[0] == s[3] and s[0] != s[2] and s[1] == s[2]:
    print("Yes")
else:
    print("No")



Measured memory_bytes: 38384
#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>;

int main() {
    int a, b, c;;
    cin >> a >> b >> c;
    
    if (a==b && b==c) cout << "No" << endl;
    else if (a!=b && b!=c && a!=c) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}

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

int main()
{
  int n,k;
  cin>>n>>k;
  int a[n];
  for(int i=0; i<n; i++)
    cin>>a[i];
  int ans;
  ans = (n-1)/(k-1);
  if((n-1)%(k-1)>0) ans++;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 640
/* package whatever; // don't place package name! */

import java.util.*;

public class Main {
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        String b = sc.next();
        
        if(b.equals("A")){
        	System.out.println("T");
        } else if(b.equals("T")){
        	System.out.println("A");
        } else if(b.equals("C")){
        	System.out.println("G");
        } else if(b.equals("G")){
        	System.out.println("C");
        }
        
        sc.close();
        
    }
}

Measured memory_bytes: 20820
#include <bits/stdc++.h>
#define lli long long int
#define MOD 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define repf(i, n) for(int i=1; i<(int)(n+1); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<lli>
#define vvi vector<vector<lli>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
using namespace std;

// 半公倍数の個数を計算
lli hcm(vi &a, lli n, lli m){
    // a1,...,anを全て奇数になるまで割る
    while(a[0]%2 == 0){
        rep(i, n){
            if(a[i]%2 != 0) return 0;
            a[i] /= 2;
        }
        m = floor(m/2.0);
    }
    rep(i, n) if(a[i]%2 == 0) return 0;

    // a1,...,anの最小公倍数の計算
    lli lcm = 1;
    rep(i, n){
        lli gcd = __gcd(lcm, a[i]);
        lcm = (lcm * a[i]) / gcd;
        if(lcm > m) return 0;
    }

    // m以下である最小公倍数lcmを奇数倍した数の個数
    return (m/lcm +1) / 2;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    lli n, m;
    cin >> n >> m;
    vi a(n);
    rep(i, n) cin >> a[i], a[i] /= 2;
    cout << hcm(a, n, m) << endl;
}

Measured memory_bytes: 1024
class DualSegmentTree():

    def __init__(self, n, op, e):
        """
        :param n: 配列の要素数
        :param op: 作用素（モノイド＝結合則＋単位元存在）
        :param e:  単位元
        """
        self.n = n
        self.op = op
        self.e = e
        self.depth = (self.n - 1).bit_length()
        self.size = 1 << self.depth
        self.lazy = [self.e] * ((self.size << 1) + 1)

    def built(self, array):
        """
        arrayを初期値とするセグメント木を構築
        """
        for i in range(self.n):
            self.lazy[self.size + i] = array[i]

    def update(self, l, r, x):
        """
        半開区間 [l, r) の各々の要素 a に op(x, a)を作用させる （ 0-indexed ）　（ O(logN) ）
        """
        l += self.size
        r += self.size
        self.propagate(l//(l&-l))
        self.propagate((r//(r&-r))-1)
        while l < r:
            if r&1:
                r -= 1              # 半開区間なので先に引いてる
                self.lazy[r] = self.op(x, self.lazy[r])
            if l&1:
                self.lazy[l] = self.op(x, self.lazy[l])
                l += 1
            l >>= 1
            r >>= 1

    def propagate(self, i):
        """
        根から葉に伝搬させる。可換モノイドの場合は更新時の伝搬をサボれる。　（ O(logN) ）
        """
        for k in range(i.bit_length()-1, 0,-1):
            x = i>>k
            if self.lazy[x] == self.e:
                continue
            self.lazy[(x<<1)|1] = self.op(self.lazy[x], self.lazy[(x<<1)|1])
            self.lazy[x<<1] = self.op(self.lazy[x], self.lazy[x<<1])
            self.lazy[x] = self.e

    def get(self, i):
        """
        i 番目の値を取得（ 0-indexed ） ( O(logN) )
        """
        i += self.size
        self.propagate(i)
        return self.lazy[i]

    def __getitem__(self, i):
        return self.get(i)

    def __iter__(self):
        for x in range(1, self.size):
            if self.lazy[x] == self.e:
                continue
            self.lazy[(x<<1)|1] = self.op(self.lazy[x], self.lazy[(x<<1)|1])
            self.lazy[x<<1] = self.op(self.lazy[x], self.lazy[x<<1])
            self.lazy[x] = self.e
        for a in self.lazy[self.size:self.size+self.n]:
            yield a

    def __str__(self):
        for x in range(1, self.size):
            if self.lazy[x] == self.e:
                continue
            self.lazy[(x<<1)|1] = self.op(self.lazy[x], self.lazy[(x<<1)|1])
            self.lazy[x<<1] = self.op(self.lazy[x], self.lazy[x<<1])
            self.lazy[x] = self.e
        return str(self.lazy[self.size:self.size + self.n])

##################################################################################################################
import sys
from bisect import *
input = sys.stdin.readline

N, Q = map(int, input().split())

e = -1
op = lambda x, y: x if x != e else y
st = DualSegmentTree(Q, op, e)

Qu = [list(map(int, input().split())) for _ in range(N)]
Qu.sort(key=lambda x:x[2], reverse=True)

D = [int(input()) for _ in range(Q)]

for q in Qu:
    S, T, X = q
    L = bisect_left(D,S-X)
    R = bisect_left(D,T-X)
    st.update(L, R, X)
print(*st, sep="\n")

Measured memory_bytes: 146356
#include <iostream>

using namespace std;
constexpr int order[] = {-1, 14, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
int main() {
  int alice, bob;
  cin >> alice >> bob;
  if(alice == bob) {
    cout << "Draw" << endl;
  }
  else if(order[alice] > order[bob]) {
    cout << "Alice" << endl;
  }
  else {
    cout << "Bob" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef vector<ll> vll;
#define INF 0x3f3f3f3f
#define MOD 1000000007LL
#define EPSILON 0.00001
#define f first
#define s second
#define pb push_back
#define mp make_pair

#define FOR(i, a, b) for (ll i=(a); i<=(signed)(b); i++)
#define F0R(i, a) for (ll i=0; i<(signed)(a); i++)
#define RFOR(i, a, b) for (ll i=(a); i >= b; i--)

#define MN 1005
int n;
int s, w;

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

    cin >> s >> w;
    if(w >= s) cout << "unsafe\n";
    else cout << "safe\n";

    return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define ll unsigned long long int
// #define m 1000000007
// ll max(ll a,ll b)
// {
//     if(a>b) return a;
//     else return b;
// }
int main()
{
    std::ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k;
    cin>>n>>k;
    if(n<=k)    cout<<min(n,k-n);
    else        cout<<min(n%k,k-n%k);
}

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

using namespace std; 

int main() {

	int a, b; 

	cin >> a >> b; 

	if(a > b) {
		cout << a + a - 1 << endl; 
	}

	else if(a == b) {
		cout << 2*a << endl; 
	}

	else {
		cout << b + b - 1 << endl; 
	}

	return 0; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define DEBUG
#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
	template <typename Arg1>
	void __f(const char* name, Arg1&& arg1){
		cerr << name << " : " << arg1 << std::endl;
	}
	template <typename Arg1, typename... Args>
	void __f(const char* names, Arg1&& arg1, Args&&... args){
		const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
	}
#else
#define debug(...)
#endif
#define FOR(i,a,b) 	for(int i=a;i<b;++i)
#define RFOR(i,a,b) 	for(int i=a;i>=b;--i)
#define ln 		"\n"
#define mp make_pair
#define pb push_back
#define sz(a)	ll(a.size())
#define F first
#define S second
#define all(c)	c.begin(),c.end()
#define rall(c) c.rbegin(), c.rend()
#define trace(c,x) for(auto &x:c)
#define pii pair<ll,ll>
#define init(a, x) memset(a,x,sizeof(a))
typedef long long ll;
typedef long double ld;
typedef	priority_queue<pii,std::vector<pii>,greater<pii> > revpr;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds;
// ordered_set X
//K-th smallest
//*X.find_by_order(k-1)
//NO OF ELEMENTS < A
//X.order_of_key(A)
const int L=1e6+7;
map<ll,ll> counter;
ll fastexpo(ll x,ll y,ll m=1e9+7)
{
	ll temp=1;
	while(y>0)
	{
		if(y&1)temp = ((temp%m)*(x%m))%m;
		x = ((x%m)*(x%m))%m;
		y>>=1;
	}return temp;
}
ll x[L], y[L];
void fff()
{
	ll n;
	cin >> n;
	ll mx1, mx2, mx3, mx4;
	mx1 = mx2 = mx3 = mx4 = LLONG_MIN;
	FOR(i,0,n)
	{
		cin >> x[i] >> y[i];	
		mx1 = max(mx1, x[i] + y[i]);
		mx2 = max(mx2, -x[i] + y[i]);
		mx3 = max(mx3, x[i] - y[i]);
		mx4 = max(mx4, -x[i] - y[i]);
	}
	std::vector<pii> v;
	FOR(i,0,n)
	{
		if(x[i] + y[i] == mx1)
		{
			v.pb({x[i], y[i]});
			break;
		}
	}
	FOR(i,0,n)
	{
		if(-x[i] + y[i] == mx2)
		{
			v.pb({x[i], y[i]});
			break;
		}
	}
	FOR(i,0,n)
	{
		if(x[i] - y[i] == mx3)
		{
			v.pb({x[i], y[i]});
			break;
		}
	}
	FOR(i,0,n)
	{
		if(-x[i] - y[i] == mx4)
		{
			v.pb({x[i], y[i]});
			break;
		}
	}
	ll cur1, cur2, cur3, cur4,ans = LLONG_MIN;
	FOR(i,0,n)
	{
		trace(v,cur)
		{
			ans = max(ans, abs(x[i]-cur.F) + abs(y[i]-cur.S));
		}
	}
	cout << ans << ln;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//int t;cin >> t;while(t--)
	fff();
	return 0;
}

Measured memory_bytes: 6764
#include<stdio.h>

#define MOD 1000000007

long long ab(long long x){
	if(x<0)return -x;
	return x;
}

long long kaizyo(long long x){
	long long ans=1;
	for(long long i=1;i<=x;i++){
		ans*=i;
		ans%=MOD;
	}
	return ans;
}

int main(){
	long long N,M,ans;
	scanf("%lld%lld",&N,&M);
	
	if(ab(N-M)>1){
		printf("0\n");
		return 0;
	}
	
	if(N==M)ans=(kaizyo(N)*kaizyo(M)*2)%MOD;
	else{
		if(N<M){
			long long tmp=N;
			N=M;
			M=tmp;
		}
		ans=(kaizyo(N)*kaizyo(M))%MOD;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 128
'use strict'
function main(input) {
    const tmp = input.split(' ').map((elem) => parseInt(elem, 10));
    const sx = tmp[0];
    const sy = tmp[1];
    const tx = tmp[2];
    const ty = tmp[3];

    const diffx = tx - sx;
    const diffy = ty - sy;

    let route1 = [];
    let route2 = [];

    for (let i = 0; i < diffy; i++) {
        route1 += 'U';
    }

    for (let i = 0; i < diffx; i++) {
        route1 += 'R';
    }

    route1 += reverse(route1);

    route2 += 'L';

    for (let i = 0; i < diffy + 1; i++) {
        route2 += 'U';
    }

    for (let i = 0; i < diffx + 1; i++) {
        route2 += 'R';
    }

    route2 += 'D';

    route2 += reverse(route2);

    console.log(route1 + route2);
}

function reverse(route) {
    let reversed = [];
    for (let r of route) {
        switch (r) {
            case 'U':
                reversed += 'D';
                break;
            case 'D':
                reversed += 'U';
                break;
            case 'L':
                reversed += 'R';
                break;
            case 'R':
                reversed += 'L';
                break;
        }
    }

    return reversed;
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 8084
#pragma GCC optimize("O3")
#pragma GCC target("sse4.2")

#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

typedef int Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef pair<Weight, int> Result;
Result visit(int p, int v, const Graph &g) {
  int f = g[v].size()==2;
  Result r(0, v);
  for(auto &e: g[v]) if (e.dst != p) {
    Result t = visit(v, e.dst, g);
    t.first += f; //e->weight;
    if (r.first < t.first) r = t;
  }
  return r;
}
Weight diameter(const Graph &g) {
  Result r = visit(-1, 0, g);
  Result t = visit(-1, r.second, g);
  return t.first; // (r.second, t.second) is farthest pair
}

int main(){
	int V,s,t;
	scanf("%d",&V);
	Graph g(V);
	for(;V>1;V--)scanf("%d%d",&s,&t),s--,t--,g[s].push_back(Edge(s,t,1)),g[t].push_back(Edge(t,s,1));
	printf("%d\n",diameter(g)+count_if(g.begin(),g.end(),[](auto &e){return e.size()==1;}));
}

Measured memory_bytes: 6656
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
const long long INF = 1LL << 60;

int k,s;

int main()
{
  cin >> k >> s;
  int res = 0;
  for(int x = 0; x <= k; x++)
  {
    for(int y = 0; y <= k; y++)
    {
      int z = s-x-y;
      if(z >= 0 && z <= k) res++;
    }
  }
  cout << res << endl;
}

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

vector<ll> divisor(ll x){
  vector<ll> res;
  for(ll i=1;i*i<=x;++i){
    if(x%i==0){
      res.push_back(i);
      if(i!=x/i){
	res.push_back(x/i);
      }
    }
  }
  sort(res.begin(), res.end());
  return res;
}

int main()
{
  ll n;cin >> n;

  vector<ll> div = divisor(n);
  vector<ll> div2 = divisor(n-1);
  ll res = div2.size() - 1;

  rep(i,div.size()) {
    ll k = div[i];
    if(k == 1) continue;
    ll nn = n;
    while(nn % k == 0) nn /= k;
    if( (nn - 1) % k == 0) res++;
  }
  cout << res << "\n";
  
  return 0;
}


Measured memory_bytes: 384
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func solve() {
	n := getInt()
	a1 := getIntSlice(n)
	a2 := getIntSlice(n)

	ans := -1
	for i := 0; i < n; i++ {
		s := sum(a1[0:i+1]...) + sum(a2[i:n]...)
		ans = max(ans, s)
	}

	fmt.Fprintln(wr, ans)
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func sum(ns ...int) int {
	var sum int
	for _, n := range ns {
		sum += n
	}
	return sum
}

// -----------------------------------------

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

func getInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	sc.Scan()
	s := sc.Text()
	return s
}


Measured memory_bytes: 640
class abc_165:
    
    def __init__(self):
        pass
    
    def A(self):
        K=int(input())
        AB=list(map(int,input().split()))
        flag=False
        
        for i in range(AB[0],AB[1]+1):
            if i%K==0:
                flag=True
                break
            else :pass
        
        if flag==True:print("OK")
        else: print("NG")
    
    def B(self):
        pass
    
    def C(self):
        pass
        
    def D(self):
        pass
    
    def E(self):
        pass
    
    def F(self):
        pass
    
    
if __name__=='__main__':
    obj=abc_165()
    obj.A()
    

Measured memory_bytes: 61796
import java.util.Scanner;
public class Main {

			public static void main(String[]args) {
			
				Scanner sc = new Scanner(System.in);
				int N = sc.nextInt();
				int max=0;
				int sum=0;
				int scan;
				
				for(int i =0; i<N; i++) {
					scan = sc.nextInt();
					if(scan>max) {
						sum += max;
						max = scan;
					}else {
						sum +=scan;
					}
				}
				if(max<sum)System.out.println("Yes");
				else System.out.println("No");
			}
}


Measured memory_bytes: 23764
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<numeric>
#include<iomanip>
#define int long long
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define ll long long
const double pi = 3.141592653589793;

using namespace std;

//最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) {
		return a;
	}
	return gcd(b, a % b);
}

//最小公倍数
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

//階乗
ll fact(ll a) {
	int ans = 1;
	for (int i = 1; i <= a; i++) {
		ans *= i;
	}
	return ans;
}

//コンビネーション
ll combi(ll a, ll b) {
	return fact(a) / (fact(b) * fact(a - b));
}

signed main() {
	int n;
	cin >> n;
	ll ans = 1;
	vector<ll>a(n, 0);

	rep(i, n) {
		cin >> a[i];
		if (a[i] == 0) {
			cout << 0 << endl;
			return 0;
		}
	}
	rep(i, n) {
		if (ans <= 1000000000000000000 / a[i]) {
			ans *= a[i];
		}
		else {
			cout << -1 << endl;
			return 0;
		}
	}

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

Measured memory_bytes: 4052
x,y=map(int,input().split())

def nCr(n,r,mod=10**9+7):
    r=min(r,n-r)
    a=b=1
    for i in range(1,r+1):
        a=a*n%mod
        b=b*i%mod
        n-=1
    return a*pow(b,mod-2,mod)%mod

z=x+y
if z%3!=0 or x-(z//3)<0 or y-(z//3)<0:
    print(0)
else:
    z//=3
    # print(z)
    # print(min(x,y)-z)
    print(nCr(z,min(x,y)-z))



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

using namespace std;
typedef long long ll;
const long double pi=3.14159265358979323846;
#define x  first
#define y  second

bool isP(ll x)
{
    for(int i=2;i<=sqrt(x);i++)
    {
        if(x%i==0)return 0;
    }
    return 1;
}

int main()
{
    cin.tie(0);
    cin.sync_with_stdio(0);
    //freopen("op.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    ll t=1;
    //cin>>t;
    while(t--)
    {
        char a;
        cin>>a;
        if(a>90)cout<<'a';
        else cout<<'A';
    }
    return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define int long long

using namespace std;

const int maxn=100+10, maxw=1e5+10;
int n, W;
int w[maxn];
int v[maxn];
int dp[maxw][maxn];

int32_t main(){
	scanf("%lld%lld", &n, &W);

	for(int i=0; i<n; i++){
		scanf("%lld%lld", &w[i], &v[i]);
	}

	for(int i=0; i<=W; i++){
		if(i >= w[0]){
			dp[i][0] = v[0];
		}
	}

	for(int i=1; i<n; i++){
		for(int j=0; j<=W; j++){
			if(w[i] <= j){
				dp[j][i] = max(v[i] + dp[j-w[i]][i-1], dp[j][i-1]);
			}
			else{
				dp[j][i] = dp[j][i-1];
			}
		}
	}

	printf("%lld\n", dp[W][n-1]);
}


Measured memory_bytes: 89532
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
  int N;
  cin >> N;
  int A[N+2];
  int total = 0;
  A[0] = 0;
  A[N+1] = 0;
  for(int i = 1; i < N+1; i++){
    cin >> A[i];
    total += abs(A[i]-A[i-1]);
  }
  total += abs(A[N+1]-A[N]);

  for(int i = 1; i < N+1; i++){
    int Ans = total;
    Ans += abs(A[i-1]-A[i+1]);
    Ans -= abs(A[i-1]-A[i]) + abs(A[i]-A[i+1]);
    printf("%d\n",Ans);
  }

  return 0;
}


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

using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)


typedef long long ll;
typedef unsigned long long int llt;

const int N = 5e5 + 10;

vector<int> g[N];
bool viss[N];
int vis[N];

void dfs(int curr, int par)
{
  for(auto x: g[curr])
    if(x != par)
      dfs(x, curr);
}

void dfs1(int curr, int par)
{
  viss[curr] = 1;
  for(auto x: g[curr])
    if(!viss[x])
      dfs1(x, curr);
}

void dfs2(int curr, int par, int num)
{
  vis[curr] = num;
  for(auto x: g[curr])
    if(vis[x] == 0)
      dfs2(x, curr, num);
}

ll fxor(ll n)
{
  if(n < 0) return 0;
  if(n % 4 == 3) return 0;
  else if(n % 4 == 0) return n;
  else if(n % 4 == 1) return n^(n-1);
  else if(n%4 == 2) return n^(n-1)^(n-2);
}

llt ppow(llt x, llt y)
{
  llt res = 1;
  while(y > 0){
    if(y&1)
      res = (res * x)%M;
    y = y >> 1;
    x = (x * x)%M;
  }
  return res;
}

string ans ="";
void convert10tob(llt N, int b)
{
     if (N == 0)
        return;
     int x = N % b;
     N /= b;
     if (x < 0)
        N += 1;
     convert10tob(N, b);
     ans += to_string(x);
     return;
}

llt convertback(string a, int b)
{
  llt aa = 0;
  llt mul = 1;
  for(int i=a.length()-1; i>=0; i--)
  {
    int curr = a[i] - '0';
    aa += (curr * mul);
    mul *= b;
  }
  return aa;
}
bool num[10];

bool check(int n)
{
  string x = to_string(n);
  for(int i=0; i<x.length(); i++)
  {
    int a = x[i] - '0';
    if(num[a] == 1) return 0;
  }
  return 1;
}

int main()
{
  int n, k;
  cin>>n>>k;

  rep(i, 0, k)
  {
    int a;
    cin>>a;
    num[a] = 1;
  }
  while(true)
  {
    if(check(n))
    {
      cout<<n<<endl;
      break;
    }
    n++;
  }
  return 0;
}


Measured memory_bytes: 12416
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
#include <set> 
 
using namespace std;
 
#define int long long
#define val(x) cout << #x << " equals to " << x << endl
 
const int N = 2e6 + 7;
const int INF = 1e18;

int n, m, k, q, a[N];

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    #ifdef LOCAL
        freopen("C:/Users/emrey/Code/in.txt", "r", stdin);
    #endif

    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    int sum = 0;
    sort(a + 1, a + n + 1, greater<int>());
    for (int i = 2; i <= n - 1; i++)
        if (i & 1)
            sum += a[i - (i / 2)];
        else
            sum += a[i - (i / 2) + 1];
    cout << sum + a[1];
}

Measured memory_bytes: 5172
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = (1e+9)+7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
ll p[1 << 17];
ll sum[1 << 17];
int n;
ll extgcd(ll a, ll b, ll& x, ll& y) {
	ll d = a;
	if (b != 0) {
		d = extgcd(b, a%b, y, x);
		y -= (a / b)*x;
	}
	else {
		x = 1; y = 0;
	}
	return d;
}
//aのmod mでの逆元を求める
ll mod_inverse(ll a) {
	ll x, y;
	extgcd(a, mod, x, y);
	return (mod + x % mod) % mod;
}
void init() {
	p[0] = 1;
	Rep(i,1, 1 << 17) {
		p[i] = p[i - 1] * i%mod;
	}
	sum[0] = 0;
	Rep(i, 1, 1 << 17) {
		sum[i] = sum[i - 1] + p[n] * mod_inverse(i);
		sum[i] %= mod;
	}
}
ll a[1<< 17];
int main(){
	cin >> n; init();
	rep(i, n) {
		cin >> a[i];
	}
	ll out = 0;
	rep(i, n) {
		ll times = sum[i + 1] + sum[n - i] - sum[1];
		times %= mod;
		out += a[i] * times;
		out %= mod;
	}
	cout << out << endl;
	return 0;
}

Measured memory_bytes: 3072
import sys
input = sys.stdin.readline

def main():
    k, n = map(int, input().split())
    a = list(map(int, input().split()))
    longest = a[0] + k - a[-1]
    for i in range(n - 1):
        longest = max(longest, a[i+1] - a[i])

    print(k - longest)


if __name__ == '__main__':
    main()


Measured memory_bytes: 26060
#include <bits/stdc++.h>
#include <atcoder/all>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n - 1); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
using namespace std;
using namespace atcoder;
using P = pair<int, int>;
typedef long long ll;
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 dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int A_MAX = 300005;

int op(int a, int b) {
  return max(a, b);
}
int e() {
  return 0;
}


int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i, n){
    cin >> a[i];
  }
  segtree<int, op, e> dp(A_MAX);
  rep(i, n){
    int x = a[i];
    int l = x - k, r = x + k + 1;
    l = max(0, l);
    r = min(r, A_MAX);
    int now = dp.prod(l, r) + 1;
    dp.set(x, now);
  }
  cout << dp.prod(0, A_MAX) << endl;
}

Measured memory_bytes: 9620
//{
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define FILL(i,n) memset(i,n,sizeof i)
#define X first
#define Y second
#define SZ(_a) (int)_a.size()
#define ALL(_a) _a.begin(),_a.end()
#define pb push_back
#ifdef brian
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // brian
//}


const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=ll(1e15);

int main()
{
    IOS();
    ll n,T;
    cin>>n>>T;
    ll mn = INF;
    REP(i,n)
    {
      ll a,b;
      cin>>a>>b;
      if(b <= T)mn = min(mn,a);
    }
    if(mn == INF)cout<<"TLE"<<endl;
    else cout<<mn<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define comp3(a,b,c) ((a)==(b)&&(b)==(c)&&(c)==(a))
#define comp2(a,b,c) ((a)==(b)||(b)==(c)||(c)==(a))
int main(){
  int n,res=0;
  string a,b,c;
  cin>>n>>a>>b>>c;
  for(int i=0;i<n;++i){
    if(comp3(a[i],b[i],c[i]))continue;
    else if(comp2(a[i],b[i],c[i]))res++;
    else res+=2;
  }
  cout<<res;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
  int n;
  cin>>n;
  map<char,int> cnt;
  rep(i,0,n){
    char s;
    cin>>s;
    cnt[s]++;
  }
  int ans=0;
  for(auto b:cnt){
    ans++;
  }
  if(ans==4)cout<<"Four"<<endl;
  else cout<<"Three"<<endl;

 
}

Measured memory_bytes: 3640
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
  
  int n,t[10000];
  long long ans=0,sum=0;
  scanf("%d",&n);
  while(n != 0){
    ans = sum = 0;
    for(int i=0;i<n;i++) scanf("%d",&t[i]);
    sort(t,t+n);
    for(int i=0;i<n;i++){
      ans += sum;
      sum += t[i];
    }
    printf("%lld\n",ans);
    scanf("%d",&n);
  }
  return (0);
}

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

string divide[4] = {"dream", "dreamer", "erase", "eraser"};

int main(){
    string S;
    cin >> S;
    reverse(S.begin(), S.end());
    for (int i = 0; i < 4; i++) {
        reverse(divide[i].begin(), divide[i].end());
    }
    bool flag = true;
    for (int i = 0; i < (int)S.size(); ) {
        bool _flag = false;
        for (int j = 0; j < 4; j++) {
            string d = divide[j];
            if (S.substr(i, d.size()) == d) {
                _flag = true;
                i += d.size();
            }
        }
        if (!_flag) {
            flag = false;
            break;
        }
    }
    cout << (flag ? "YES" : "NO") << endl;
     return 0;
}


Measured memory_bytes: 512
A,B,C = map(int,input().split())
x = [0,0,0]
K = int(input())
flag = False
for i in range(K+1):
    for j in range(K+1):
        for k in range(K+1):
            x = A*(2**i)
            y = B*(2**j)
            z = C*(2**k)
            if i+j+k<=K and x<y and y<z:
                flag = True
                break
if flag == True:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9144
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <list>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)

int main(){
    ll a,b,c;
    cin >> a >> b >> c;
    if(c <= a+b) cout << b+c << endl;
    else cout << 2*b+a+1 << endl;
}

Measured memory_bytes: 256
n, m, c = (int(_) for _ in input().split())
b = list(int(_) for _ in input().split())
a = [[int(i) for i in input().split()] for i in range(n)]
ret = 0


for i in range(n):
    r = 0
    for j in range(m):
        r += a[i][j] * b[j]
    if (r + c > 0):
        ret += 1

print(ret)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define fin(ans) cout << ans << endl

int main(void) {
  string s;
  cin >> s;
  bool isgood = true;

  for (int i = 0; i < 3; i++) {
    if (s[i] == s[i+1]) isgood = false;
  }

  if (isgood)
    fin("Good");
  else
    fin("Bad");

  return 0;
}


Measured memory_bytes: 256
import Data.List.Split
import Data.List

main = do
    a <- getContents
    let aa = splitOn "\n" a
    let cc = map (\x -> if length x == 0 then "0" else x) aa
    let dd = tail $ reverse cc
    let bb = map read dd :: [Int]
    let tt = reverse $ sort bb

    putStrLn $ show $ head tt
    putStrLn $ show $ head $ tail tt
    putStrLn $ show $ head $ tail $ tail tt

    return ()




Measured memory_bytes: 3744
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, Scanner sn, PrintWriter out) {
            String a = sn.next();
            out.println("ABC" + a);
        }

    }
}



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

int main () {
  int n ;
  cin >> n ; 
  string a , b , c ;
  cin >> a >> b >> c ;
  
  int answer = 0 ;
  
  for (int  i = 0 ; i < n ;i++ ){
    if ( a[i] == b[i] && b[i] == c[i] ){
    } else if ( a.at(i) != b.at(i) && b.at(i) != c.at(i) && c.at(i) != a.at(i)) {
      answer +=2 ;
    } else {
      answer +=1 ;
    }
  }
  cout << answer << endl ;
}


Measured memory_bytes: 256
N = int(input())
a_list = list(map(int, input().split()))

ave_a = sum(a_list) / N
flame_i = 0
dif_a = abs(a_list[0] - ave_a)

for i in range(1, N):
  if dif_a > abs(a_list[i] - ave_a):
    dif_a = abs(a_list[i] - ave_a)
    flame_i = i

print(flame_i)

Measured memory_bytes: 3060
import java.util.*;

class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      		String S = sc.next();
            String T = sc.next();
      
      		if(S.substring(0,S.length()).equals(T.substring(0,S.length()))){
            	System.out.println("Yes");}
      		else{
            	System.out.println("No");}
    }
}


Measured memory_bytes: 35664
// In the name of god
#include <bits/stdc++.h>
#pragma GCC optimize("02")
#define F first
#define S second
#define pb push_back
using namespace std;
using ll=long long;
const ll maxn=1e5+5,inf = 1e18+18;
ll n,m,t;
string s;
int main(){
	ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0);
	cin>>s;
	cout<<s[0]<<s[1]<<s[2]<<endl;
}


Measured memory_bytes: 3640
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>

using namespace std;

int main(){
	
	int W, H, N;
	
	cin >> W >> H >> N;
	
	int ans = 0;
	
	int x_pre, y_pre, x_next, y_next;
	
	cin >> x_pre >> y_pre;
	
	for(int i = 0; i < N - 1; i++){
		cin >> x_next >> y_next;
		if((x_next - x_pre) * (y_next - y_pre) > 0){
			ans += max(abs(x_next - x_pre), abs(y_next - y_pre));
		}else{
			ans += abs(x_next - x_pre) + abs(y_next - y_pre);
		}
		x_pre = x_next;
		y_pre = y_next;
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 3096
#include <cstdio>
#include <algorithm>

int main(void)
{
    int a, b;

    while (1) {
        scanf("%d %d", &a, &b);
        if (!a && !b)
            break;
        if (a > b)
            std::swap(a, b);
        printf("%d %d\n", a, b);
    }

    return 0;
}

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

using namespace std;

typedef long long ll;

double getTime() {
  return clock() / (double) CLOCKS_PER_SEC;
}

void read() {};

template<typename T, typename... Args>
void read(T& a, Args&... args) {
  cin >> a;
  read(args...);
}

void print() {};

template <typename T, typename... Args>
void print(T a, Args... args) {
  cout << a << " \n"[sizeof...(args) == 0];
  print(args...);
}

bool can(ll x, ll p) {
  while(x % p == 0) {
    x /= p;
  }
  return x % p == 1;
}

int main() {
  ll n; cin >> n;
  set <ll> s;
  ll m = n - 1;
  for(ll i = 1; i * i <= m; i++) {
    if(m % i == 0) {
      s.insert(i);
      s.insert(m / i);
    }
  }
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      if(i != 1) if(can(n, i)) s.insert(i);
      if((n / i) != 1) if(can(n, n / i)) s.insert(n / i);
    }
  }
  s.erase(1);
  cout << s.size() << '\n';
}

Measured memory_bytes: 256
from itertools import permutations
import numpy as np

def calc_distance(point):
    _point = np.array(list(point))
    x = np.diff(_point, axis=0)
    every_distance = np.linalg.norm(x, axis=1)
    all_distance = np.sum(every_distance)
    return all_distance

n = int(input())
points = [[int(v) for v in input().split(' ')] for _ in range(n)]

sum = 0
for v in permutations(points):
    sum += calc_distance(v)


print(sum / len(list(permutations(points))))


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


int n,k;

int main(){
    cin >> n;
    cin >> k;
    if(n%2==0){
        if(n>=k*2){
            printf("YES");
        }else{
            printf("NO");
        }
    }else{
        if(n+1>=k*2){
            printf("YES");
        }else{
            printf("NO");
        }
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
#include <stdlib.h>

typedef unsigned long long int uint64;
typedef long long int          int64;

#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX(a,b) ((a)>(b)?(a):(b))


void get_AB (uint64 *a, uint64 *b)
{
  int cnt;
  
  cnt = scanf("%lld %lld", a, b);

  return;
}

int main()
{
  int cnt;
  uint64 i,j;
  uint64 L,R;
  uint64 modv;
  uint64 mini = 3000;
#if 0
  uint64 minj = 3000;
  uint64 ii = 0;
  uint64 jj = 0;
#endif
  uint64 limit = 0;

  get_AB(&L, &R);

#if 0
  if ((R - L + 1) >= 2019) {
    printf("0");
    return 0;
  }
#endif

  limit = MIN (R, L+2020);
  for (i=L; i<=limit; i++) {
    for (j=L; j<limit; j++) {
      if (i==j) continue;
      modv = (i*j)%2019;
      mini = MIN(mini, modv);
    }
  }

  printf("%lld", (mini));
  
#if 0
  for (i=L; i<=limit; i++) {
    modv = i % 2019;
    mini = MIN(modv, mini);
    if (mini == modv) ii=i;
  }
  for (i=L; i<=limit; i++) {
    if (i == ii) continue;
    modv = i % 2019;
    minj = MIN(modv, minj);
    if (minj == modv) jj=i;
  }

  printf("%lld", ((ii*jj)%2019));
#endif

  return 0;
}



Measured memory_bytes: 128
#include<iostream> 
#include<string>
#include<bits/stdc++.h>
using namespace std;
int main(){	
	int a,b,c;
	cin>>a>>b>>c;
	if(a-b>=c){
		cout<<"0";
	} 
	else{
		cout<<c-(a-b);
	}
    return 0;
} 

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

int main() {
    int N, X, T;
    cin >> N >> X >> T;
    if (N%X == 0){
        cout << (N/X)*T << endl;
    }
    else {
        cout << (N/X + 1)*T << endl;
    }
}

Measured memory_bytes: 3580
import collections
N=int(input())
x=list(map(int,input().split()))
c=collections.Counter(x)
t=[2**i for i in range(len(str(bin(max(x)*2))[2:])+1)[::-1]]
count=0
start=0
x.sort()
for i in range(len(x))[::-1]:
    for j in range(start,len(t)):
        if t[j] > 2*x[i]:
            start = j
        if t[j] < x[i]:
            break
        if t[j]-x[i] in c.keys():
            if t[j]-x[i] == x[i]:
                if c[x[i]] >= 2:
                    c[x[i]] -= 2
                    count +=1
            else:
                if c[t[j]-x[i]]>0 and c[x[i]]>0:
                    c[t[j]-x[i]] -= 1
                    c[x[i]] -= 1
                    count+=1
print(count)

Measured memory_bytes: 33296
def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    assert N == len(A)
    votes = sum(A)
    count = 0
    for i in A:
        if i * 4 * M >= votes:
            count += 1
    print("Yes") if count >= M else print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7 # 998244353
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n, m = map(int,input().split())
    
    if n & 1: 
        left = 1
        right = n - 1
        for _ in range(m):
            print(left, right)
            left += 1
            right -= 1
        return

    # 最初に 1 から n/2 - 1 を埋める
    left = 1
    right = n // 2 - 1
    while left < right:
        print(left, right)
        m -= 1
        if m == 0:
            return
        left += 1
        right -= 1

    left = n // 2
    right = n - 1
    while left < right:
        print(left, right)
        m -= 1
        if m == 0:
            return
        left += 1
        right -= 1
resolve()

Measured memory_bytes: 69568
#include <iostream>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
string L;
ll binpow(ll u, int v) {
	if(v==0) return 1;
	if(v==1) return u;
	ll T = binpow(u,v/2);
	T = T*T; if(T>=mod) T%=mod;
	if(v&1) return (T*u)%mod;
	return T;
}
main() {
	cin >> L;
	ll ans = 0, cur = 1; 
	for(int i = 0; i<L.size();i++){
		if(L[i] == '0') continue;
		ll tmp = cur*binpow(3,L.size()-i-1); if(tmp>mod) tmp%=mod;
		ans += tmp; if(ans>mod) ans%=mod;
		if(L[i] == '1') 	{
			cur*=2;
			if(cur > mod) cur%=mod;
		}
	}
	ans += cur; if(ans>=mod) ans%=mod;
	cout << ans ; 
}

Measured memory_bytes: 512
# coding: utf-8
# Your code here!
S=input()
S=list(map(int,S))

def calc(index,num):
    if index&1==1:
        return [num,"+"]
    else:
        return [-num,"-"]

for i in range(8):
    ans=S[0]
    s1=calc(i,S[1])[1]
    ans+=calc(i,S[1])[0]
    s2=calc(i>>1,S[2])[1]
    ans+=calc(i>>1,S[2])[0]
    s3=calc(i>>2,S[3])[1]
    ans+=calc(i>>2,S[3])[0]
    if ans==7:
        print(str(S[0])+s1+str(S[1])+s2+str(S[2])+s3+str(S[3])+"=7")
        exit()
        
 


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(ll i=0;i<n;++i)
#define ocut cout
#define ouct cout
#define itn int

struct Union{
  vector<ll> par;
  Union(ll a){
  par=vector<ll>(a,-1);
  }
  ll find(ll a){
    if(par[a]<0){
      return a;
    }
    else{
      return par[a]=find(par[a]);
    }
  }
  bool same(ll a,ll b){
    return (find(a)==find(b));
  }
  ll size(ll a){
    return -par[find(a)];
  }
  void unite(ll a,ll b){
    ll c=find(a),d=find(b);
    if(c==d)
      return;
    if(size(c)<size(d)){
      swap(c,d);
    }
    par[c]+=par[d];
    par[d]=c;
  }
};
ll Nagaemon1;
void swap(ll i,ll j){
  Nagaemon1=i;
  i=j;
  j=Nagaemon1;
}
int main(void){
    long long a,c=0;
    string s;
    cin >> a >> s;
    long long e=(s[0]-'0')*100+(s[2]-'0')*10+(s[3]-'0');
    if(s=="10.00")e=1000;
    c=a*e/100;
    cout<< c << endl;
}

Measured memory_bytes: 3632
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = Integer.parseInt(sc.next());
        int L = Integer.parseInt(sc.next());

        List<String> array = new ArrayList<String>();

        for (int i=0; i<N; i++){
        	array.add(sc.next());
        }

        Collections.sort(array);

        for (String a : array) {
        	  System.out.print(a);
       }
    }
}

Measured memory_bytes: 21716