akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>                                           
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
//#define int long long
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
 
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define fastio ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define s second
#define f first
 
 
 
 
typedef pair < long long, long long > pll;    
typedef pair < int, int > pii;  
typedef unsigned long long ull;         
typedef vector < pii > vpii;                                   	
typedef vector < int > vi;
typedef long double ldb;  
typedef long long ll;  
typedef double db;
 
typedef tree < int, null_type, less < int >, rb_tree_tag, tree_order_statistics_node_update > ordered_set;

 
const int inf = 1e9, maxn = 1e5 + 48, mod = 998244353, N = 1e6 + 12;
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 300;
const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);
const ldb eps = 1e-12, pi = acos(-1);
const ll INF = 1e18;

                                                     
map < pii, int > cnt[30];
int n, m, lst[30], p[N];
string s[N];
char t[N];
pii h[N];
ll ans;

bool cmp (int x, int y) {
	return sz(s[x]) < sz(s[y]);
}


main () {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		scanf("\n%s", t);

		m = strlen(t);
		reverse(t, t + m);
		for (int j = 0; j < m; ++j)
			s[i] += t[j];

		p[i] = i;
	}

	sort(p + 1, p + 1 + n, cmp);
	for (int i = 1; i <= n; ++i) {
		memset(lst, -1, sizeof(lst));
		
		int x = p[i];
		m = sz(s[x]);
		for (int j = 0; j < m; ++j) 
			t[j] = s[x][j]; 
		
		

		for (int j = 0; j < m; ++j)
			lst[t[j] - 'a'] = j;		

		for (int j = 0; j < m; ++j) {
		    if (j) {
				h[j] = mp((h[j - 1].f * 1ll * base.f + t[j]) % Mod.f, (h[j - 1].s * 1ll * base.s + t[j]) % Mod.s);
				for (int x = 0; x < 26; ++x)
					if (lst[x] >= j && cnt[x].count(h[j - 1])) 
						ans += cnt[x][h[j - 1]];
			} else {
				h[0] = {t[0], t[0]};
				for (int x = 0; x < 26; ++x) 
					if (lst[x] >= j && cnt[x].count(mp(-1, -1))) 
						ans += cnt[x][mp(-1, -1)];
					
			}
		}

		if (m > 1)
			++cnt[t[m - 1] - 'a'][h[m - 2]];
		else 
			++cnt[t[m - 1] - 'a'][mp(-1, -1)];						
	}

	cout << ans << endl;	
}



Measured memory_bytes: 48196
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    REP(h, 1, 3500) {
        REP(n, 1, 3500) {
            if (4 * n * h % N != 0) continue;
            int t = 4 * n * h / N;
            if (t - n - h <= 0) continue;
            if (h * n % (t - n - h) != 0) continue;
            int w = (h * n)/(t - n - h);
            cout << h << " " << n << " " << w << endl;
            return 0;
        }
    }

    return 0;
}

// 4nhw/N - nw - hw = hn
// w(4nh/N - n - h) = hn
// w = hn/(4nH/N - n - h)

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n, tpoint, hpoint int
	fmt.Scan(&n)
	for t := 0; t < n; t++ {
		var tcard, hcard string
		fmt.Scan(&tcard, &hcard)
		if tcard > hcard {
			tpoint += 3
		} else if tcard < hcard {
			hpoint += 3
		} else {
			tpoint++
			hpoint++
		}
	}
	fmt.Println(tpoint, hpoint)
}



Measured memory_bytes: 1176
n=int(input())

def keta(num):
    s = str(num)
    sm=0
    for i in range(len(s)):
        sm+=int(s[i])
    return sm

ans=10**10
for a in range(1,n):
    b=n-a
    ans=min(ans,keta(a)+keta(b))

print(ans)

Measured memory_bytes: 43004
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
using namespace std;
int main(){
    int K, X;
    cin >> K >> X;

    if(500 * K >= X)cout << "Yes";
    else cout << "No";
}

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

int main(){
    int n; cin >> n;
    ll x[n],y[n],h[n]; rep(i,n) cin >> x[i] >> y[i] >> h[i];

    for(ll i = 0; i < 101; ++i){
        for(ll j = 0; j < 101; ++j){
            ll ch = 0LL;
            bool flag = true;
            rep(k,n){
                if(h[k] > 0){
                    ch = h[k] + abs(x[k]-i) + abs(y[k]-j);
                    break;
                }
            }
            rep(k,n){
                if(h[k] != max(ch-abs(x[k]-i)-abs(y[k]-j), 0LL)){
                    flag = false;
                    break;
                }
            }
            if(flag){
                cout << i << " " << j << " " << ch << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define vb __int128
#define ll long long
#define ld long double
#define full(a) a.begin(),a.end()
#define stoink stack<ll>
#define vec vector <ll>
#define vg vector<vector<ll> >
#define vgw vector<vector<pair<ll,ll> >
#define pa pair<ll,ll>
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define prec 0.00000000000000000001
#define inf 1000000000000
#define mod (ll)(1e9 + 7)
ll n;
vec arr;
vec pre;
ll dp[101][100001];
int main()
{	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll k;
	cin >> n >> k;
	arr.resize(n+1);
	ll i,j;
	for(i = 1 ; i <= n ; i++) {
		cin >> arr[i];
	}
	dp[0][0] = 1;
	for(i = 1 ; i <= n ; i++) {
		vec pre(k+1);
		for(j = 0 ; j <= k ; j++) {
			if(j == 0) 
				pre[j] = dp[i-1][j];
			else
				pre[j] = dp[i-1][j] + pre[j-1]; 
		}
		for(j = 0; j <= k ; j++) {
			ll val;
			if(j <= arr[i])
				val = 0;
			else
				val = pre[j - arr[i] - 1];
			dp[i][j] = (pre[j] - val) % mod;
		}	

	}
	cout << dp[n][k] << endl;
	return 0;
}

Measured memory_bytes: 82460
import sys
readline=sys.stdin.readline

import numpy as np

N,K=map(int,readline().split())
A=np.array(readline().split(),dtype=int)

nega_list=A[A<0]
posi_list=A[A>0]
zero_num=A[A==0].size

# print(nega_list)
# print(posi_list)
# print(zero_num)

nega_list=np.sort(nega_list)
posi_list=np.sort(posi_list)

nega_cnt=nega_list.size * posi_list.size
posi_cnt=((posi_list.size * posi_list.size-1) // 2) + ((nega_list.size * nega_list.size-1) // 2)

zero_cnt=(zero_num * (zero_num-1)) // 2 + zero_num * (nega_list.size + posi_list.size)

# print(nega_cnt)
# print(posi_cnt)
# print(zero_cnt)


# Kがどこに属するかを判断
if K <= nega_cnt:
  # 負の数が答え
  # かけてX以下になる組み合わせをK個以上作れればOK
  
  def isOkNega(x):
    return np.searchsorted(nega_list,x//posi_list,side="right").sum() >= K
    
  ok=0
  ng=-10**18-1
  while (ok-ng)>1:
    mid=(ok+ng)//2
    if isOkNega(mid):
      ok=mid
    else:
      ng=mid
  print(ok)
  
elif K <= nega_cnt+zero_cnt:
  # 0が答え
  print(0)
  
else:  
  # 正の数が答え
  K-=(nega_cnt+zero_cnt)
  # 正のグループ内の積、負のグループ内の積、それぞれを合わせてX以下の数をK個以上作れる
  
  # 負の数リストは、掛け合わせた絶対値が小さいものを求める必要があるため、正のリストに変更
  nega_list = np.flipud(nega_list * (-1))
  
  # 自分自身との積は除外する必要があるため、自分同士の積リストを作成
  self_nega=nega_list * nega_list
  self_posi=posi_list * posi_list
  
  def isOkPosi(x):
    # print("x",x)
    # 重複を考えずに、負の数同士の積で条件を満たすものをカウント
    nega_all = np.searchsorted(nega_list, x // nega_list, side = "right")
    # print(nega_all)
    # print("self_nega[self_nega <= x]",self_nega[self_nega <= x])
    # 自分自身を掛け合わせたもので、条件を満たすものの個数はカウントから除外する必要がある
    nega_cnt = nega_all.sum() - self_nega[self_nega <= x].size
    # print(nega_cnt)
    
    # 同じペアを二回数えているため1/2する
    nega_cnt //= 2
    
    # 正の数リストで同じことをする
    posi_all = np.searchsorted(posi_list, x // posi_list, side = "right")
    # print(posi_all)
    # print("self_posi[self_posi <= x]",self_posi[self_posi <= x])
    posi_cnt = posi_all.sum() - self_posi[self_posi <= x].size
    # print(posi_cnt)
    posi_cnt //= 2
        
    return nega_cnt + posi_cnt >= K
  
  ok=10**18+1
  ng=0
  while abs(ok-ng)>1:
    mid=abs(ok+ng)//2
    if isOkPosi(mid):
      ok=mid
    else:
      ng=mid
  print(ok)


Measured memory_bytes: 34628
/* Bismillahir Rahmanir Rahim */

#include <bits/stdc++.h>

#define rep(i, n)	for(int i=0;i<n;i++)
#define repn(i, n)	for(int i=1;i<=n;i++)
#define set(i, n)	memset(i, n, sizeof(i))

#define pb	push_back

using namespace std;

const int N = 205;

int dp[N][N];

int recur(int x, int y){
	if(x < 2 && y < 2) return 1;
	if(dp[x][y] != -1) return dp[x][y];
	int ret = 1;
	for(int i=1;2*i<=x;i++){
		if(recur(x-2*i, y+i) == 1) ret = 0;
	}
	for(int i=1;2*i<=y;i++){
		if(recur(x+i, y-2*i) == 1) ret = 0;
	}
	return dp[x][y] = ret;
}

int main(){
	/*
	set(dp, -1);
	rep(i, 30){
		rep(j, 30){
//			cout << recur(i, j) << ' ';
			if(recur(i, j) == 1) cout << "( " << i << ", " << j << ")\n";
		}
//		cout << endl;

	}
	*/
	long long x, y;
	cin >> x >> y;
	long long ab = llabs(x - y);
	if(ab <= 1) cout << "Brown\n";
	else cout << "Alice\n";
	return 0;
}



Measured memory_bytes: 256
// finish date: 2018/05/13
#include <bits/stdc++.h>


using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi vector<vector<vector<int>>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define bigmod 1000000007
#define INF 1050000000
#define pii pair<int,int>

//掛け算
int mul(int a, int b) {
    return (int) (((ll) (a % bigmod) * (b % bigmod)) % bigmod);
}


int main() {
    int N;
    cin >> N;
    map<int, char> mp;
    rep(i, N) {
        int in;
        cin >> in;
        mp[in] = 'a';
    }
    rep(i, N) {
        int in;
        cin >> in;
        mp[in] = 'b';
    }
    int countA = 0, countB = 0;
    int ans = 1;
    for (auto e:mp) {
        if (e.second == 'a') {
            if (countB == 0) countA++;
            else {
                ans = mul(ans, countB);
                countB--;
            }
        } else {
            if (countA == 0) countB++;
            else {
                ans = mul(ans, countA);
                countA--;
            }
        }
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
main(){
int i,j,k,l,m;
while(cin>>m){
    int x[m];
    for(i=0;i<m;i++)cin>>x[i];
    sort(x,x+i); k=0;
     for(i=0;i<m;i++) {k+=x[i];
     k--;}
     if(k<0)k=0;
    cout<<k<<endl;
} return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define bp __builtin_popcountll
#define pb push_back
#define in(s) freopen(s, "r", stdin);
#define out(s) freopen(s, "w", stdout);
#define inout(s, end1, end2) freopen((string(s) + "." + end1).c_str(), "r", stdin),\
		freopen((string(s) + "." + end2).c_str(), "w", stdout);
#define fi first
#define se second
#define bw(i, r, l) for (int i = r - 1; i >= l; i--)
#define fw(i, l, r) for (int i = l; i < r; i++)
#define fa(i, x) for (auto i: x)
using namespace std;
const int mod = 1e9 + 7, inf = 1061109567;
const long long infll = 4557430888798830399;
const int N = 105;
int n, m;
char a[N][N];
struct Dinic {
   	int n, s, t;
   	struct Edge {
    	int to, cap, flow, rev;
    	Edge(int to = 0, int cap = 0, int flow = 0, int rev = 0) :
     	   to(to), cap(cap), flow(flow), rev(rev) {}
   	};
  	vector<int> d;
  	vector<int> ptr;
  	vector<vector<Edge>> g;
  	Dinic(int n = 0, int s = 0, int t = 0) : n(n), s(s), t(t), d(n), ptr(n), g(n) {}
   	void addEdge(int u, int v, int cap) {
//   			cout << "add edge from " << u << " to " << v << " cap " << cap << "\n";
        	g[u].emplace_back(v, cap, 0, g[v].size());
        	g[v].emplace_back(u, 0, 0, g[u].size() - 1);
    	}
   	bool bfs() {
      		fill(d.begin(), d.end(), -1);
      		fill(ptr.begin(), ptr.end(), 0);
      		queue<int> q;
      		d[s] = 0;
      		q.push(s);
      		while (!q.empty()) {
        		int u = q.front();
         		q.pop();
         		for (auto e : g[u]) {
            			if (d[e.to] == -1 && e.cap > e.flow) {
               				d[e.to] = d[u] + 1;
               				q.push(e.to);
            			}
         		}
      		}
      		return d[t] != -1;
   	}
   	int dfs(int u, int flow) {
      		if (u == t) {
      		    return flow;
      		}
      		for (int &i = ptr[u]; i < g[u].size(); ++i) {
        		auto &e = g[u][i];
       			if (e.cap <= e.flow || d[e.to] != d[u] + 1) continue;
         		int nxt = dfs(e.to, min(flow, e.cap - e.flow));
         		if (nxt) {
           		 	e.flow += nxt;
           	 	g[e.to][e.rev].flow -= nxt;
           			return nxt;
         		}
      		}
      		return 0;
   	}
   	int maxFlow() {
      		int ans = 0;
      		while (bfs()) {
         		while (true) {
        	    		int now = dfs(s, inf);
           	 		if (now) ans += now;
           	 		else break;
         		}
      		}
      		return ans;
   	}
} mf;
signed main() {
	#ifdef BLU
	in("blu.inp");
	#endif
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> m;
	fw (i, 0, n) fw (j, 0, m) cin >> a[i][j];
	//Make bipartie graph, left side contains rows, right side contains columns.
	mf = Dinic(n + m + 2, 0, n + m + 1);
	int si, sj, ti, tj;
	fw (i, 0, n) fw (j, 0, m) {
		if (a[i][j] == 'S') si = i, sj = j;
		if (a[i][j] == 'T') ti = i, tj = j;
	}
	mf.addEdge(0, si + 1, inf);
	mf.addEdge(tj + n + 1, n + m + 1, inf);
	fw (i, 0, n) fw (j, 0, m) if (a[i][j] != '.') {
		int cap = 1;
		if (a[i][j] == 'S' || a[i][j] == 'T') cap = inf;
		mf.addEdge(i + 1, j + n + 1, cap);
		mf.addEdge(j + n + 1, i + 1, cap);
	}
	int ans = mf.maxFlow();
	if (ans == inf) cout << "-1\n";
	else cout << ans << "\n";
	return 0;
}

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

int main(){
  string S; cin >> S;
  vector<char> a(4);
  for(int i = 0; i < 4; i++) a[i] = S[i];
  sort(a.begin(),a.end());
  if(a[0] == a[1] && a[2] == a[3] && a[1] != a[2]) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

res = 10**6

for _ in range(M):
    x, y, c = map(int, input().split())
    res = min(a[x-1]+b[y-1]-c, res)

a.sort()
b.sort()
print(min(res, a[0]+b[0]))

Measured memory_bytes: 18736
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;
ll const MOD = 1e9 + 7;

int main() {
  ll N;
  string S;
  cin >> N >> S;
  map<char, ll> m;
  for (int i = 0; i < N; i++) {
    if (m.find(S[i]) == m.end()) {
      m[S[i]] = 1;
    } else {
      m[S[i]]++;
    }
  }
  ll ans = 1;
  for (auto p : m) {
    ll cnt = p.second;
    ans = (ans * (cnt + 1) % MOD) % MOD;
  }
  cout << (ans - 1) % MOD << endl;
  return 0;
}

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

    using namespace std;

    int main() {
       string s;long long k; cin>>s>>k;

       for(int i=0;i<s.size();i++) {

            if(s[i] == 'a') continue;

            int op = 26-(s[i]-'a');


            if(op <= k) {
                k = k-op;
                s[i] = 'a';
            }


       }


       long long y = k%26;

       s[s.size()-1] = 'a' + (((s[s.size()-1]-'a') + y)%26);

       cout<<s;



       return 0;
    }


Measured memory_bytes: 512
memo = {}


def fib(n):
    """
    :param n: non-negative integer
    :return: n-th fibonacci number
    """
    if n == 0 or n == 1:
        return 1

    try:
        return memo[n]
    except KeyError:
        pass

    res = fib(n-1) + fib(n-2)
    memo[n] = res

    return res


n = int(input())
print(fib(n))


Measured memory_bytes: 5620
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
    int n,a,b;
    scanf("%lld%lld%lld",&n,&a,&b);

    int c=n/(a+b),d=n%(a+b);
    printf("%lld\n",c*a+min(a,d));

    system("pause");
    return 0;
}

Measured memory_bytes: 504
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main(){
    
    string s;
    cin >> s;
    ll ans = 19191919;
    for(ll i = 0; i + 2 < s.size(); i++){
        stringstream ss;
        for(ll j = 0; j < 3; j++)ss << s[i + j];
        ll num;
        ss >> num;
        ans = min(ans, abs(753LL - num));
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include<iostream>
#include<string>
#include <vector>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)

using namespace std;

int BUBBLE_SORT(int A[], int N){

	bool flag = true;
	int c = 0, tmp;

	while (flag){
		flag = false;
		for (int j = N - 1; j >= 1; j--){
			if (A[j] < A[j - 1]){
				tmp = A[j];
				A[j] = A[j - 1];
				A[j - 1] = tmp;
				c++;
				flag = true;
			}
		}
	}

	return c;
}


int main(){
	int N, A[100], time;
	scanf("%d", &N);
	REP(i, N){
		scanf(" %d", &A[i]);
	}

	time = BUBBLE_SORT(A, N);

	REP(i, N - 1){
		printf("%d ", A[i]);
	}
	printf("%d\n", A[N - 1]);
	printf("%d\n", time);


	return 0;
}





Measured memory_bytes: 3192
import java.util.Arrays;
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] A = new long[N];
        long[] B = new long[N];
        long sumA = 0;
        long sumB = 0;
        long[] D = new long[N];
        long shortage = 0;
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
            sumA += A[i];
        }
        for (int i = 0; i < N; i++) {
            B[i] = sc.nextInt();
            D[i] = A[i] - B[i];
            sumB += B[i];
            if (D[i] < 0)
                shortage += D[i];
        }
        if (sumA < sumB) {
            System.out.println("-1");
            sc.close();
            return;
        }
        Arrays.sort(D);
        long di = 0;
        int count = 0;
        int excessiveHead = N - 1;
        int shortageHead = 0;
        while (D[excessiveHead] > 0) {
            di = D[excessiveHead];
            if (D[shortageHead] >= 0)
                break;
            while (di > 0 && D[shortageHead] < 0) {
                if (di >= Math.abs(D[shortageHead])) {
                    di += D[shortageHead];
                    shortageHead++;
                    count++;
                } else {
                    D[shortageHead] += di;
                    di = 0;
                }
            }
            count++;
            excessiveHead--;
        }

        System.out.println(count);

        sc.close();
    }
}


Measured memory_bytes: 87868
#include <iostream>
    #include <deque>
    using namespace std;
     
    int main(){
      int n, a;
      cin >> n;
      deque<int> x;
      bool f = 1;
      for(int i = 0; i < n; i++){
        cin >> a;
        if(f) x.push_back(a);
        else x.push_front(a);
        f = !f;
      }
      if(f){
        for(auto& i : x) cout << i << ' ';
      } else {
        for(int i = x.size()-1; i >= 0; i--) cout << x[i] << ' ';
      }
    }


Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define nl cout<<endl

#define pii pair<ll,ll>
#define vi  vector<ll>
#define vii vector<pii>
#define mi  map<ll,ll>
#define all(a)  (a).begin(),(a).end()

#define pb push_back
#define ff first
#define ss second
#define hell 1000000007

#define test4(x,y,z,a) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<"		a is "<<a<<endl;
#define test3(x,y,z) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<endl;
#define test2(x,y) cout<<"x is "<<x<<"		y is "<<y<<endl;
#define test1(x) cout<<"x is "<<x<<endl;
#define N 300009

ll power(ll a,ll b,ll m)
{
	ll ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}
int main()
{	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
        ll n,m,l;cin>>n>>m>>l;
	ll dist[n+2][n+2];
	ll stops[n+2][n+2];
	rep(i,1,n+1)
	{
		rep(j,1,n+1)
		{
			dist[i][j]=hell;
			stops[i][j]=hell;
		}
	}

	rep(i,0,m)
	{
		ll l,r,c;cin>>l>>r>>c;
		dist[l][r]=c;
		dist[r][l]=c;
	}
	rep(i,1,n+1)
	dist[i][i]=0;
	rep(k,1,n+1)
	{
		rep(i,1,n+1)
		{
			rep(j,1,n+1)
			dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
		}	
	}
	rep(i,1,n+1)
	{
		rep(j,1,n+1)
		{	
			if(dist[i][j]<=l)
			stops[i][j]=0;
		}
	}
	rep(k,1,n+1)
	{
		rep(i,1,n+1)
		{
			rep(j,1,n+1)
			stops[i][j]=min(stops[i][j],1+stops[i][k]+stops[k][j]);
		}
	}
	ll q;cin>>q;
	while(q--)
	{
		ll l,r;cin>>l>>r;
		if(stops[l][r]==hell)
		cout<<-1<<endl;
		else
		cout<<stops[l][r]<<endl;
	}
}
	

Measured memory_bytes: 1920
#include <iostream>

using namespace std;

int main(){
    int a, b;
    cin >> a >> b;
    int sa, sb, sab;
    sa = a+a-1;
    sb = b+b-1;
    sab = a+b;

    if(sa>sb){
        if(sa>sab){
            cout << sa;
        } else{
            cout << sab;
        }
    } else{
        if(sb>sab){
            cout << sb;
        } else{
            cout << sab;
        }
    }
    cout << endl;

    return 0;
}


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

int main(){
    int n;
    int i;
    int j;
    while(cin >> n){
        i = 1;
        for(j=0;j<10;j++){
            if(n & 1){
                cout << i;
                i <<= 1;
                n >>= 1;
                break;
            }
            i <<= 1;
            n >>= 1;
        }
        for(j=j;j<10;j++){
            if(n & 1){
                cout << " ";
                cout << i;
            }
            i <<= 1;
            n >>= 1;
        }
        cout << endl;
    }
    return 0;
}
                

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,x,m,s=0,max_=987654321;
    scanf("%d%d",&n,&x);
    for(int i=0;i<n;i++){
        scanf("%d",&m);
        if(max_ > m) max_ = m;
        s+=m;
    }
    x-=s;
    printf("%d",n+x/max_);
}

Measured memory_bytes: 256
n, m, k = map(int, input().split())
p = 998244353
fct, inv = [1], [1]
for i in range(1, n):
    fct.append((fct[-1] * i) % p)
    inv.append((inv[-1] * pow(i, p - 2, p)) % p)
ans = 0
for i in range(k + 1):
    cmb = fct[n - 1] * inv[i] * inv[n - 1 - i]
    ans = (ans + cmb * m * pow(m - 1, n - 1 - i, p)) % p
print(ans)


Measured memory_bytes: 24980
#ifndef LOCAL
#define NDEBUG 1
#endif
#include<bits/stdc++.h>

struct point{
	double volume, value;
	point constexpr operator+(point other) const{return{volume+other.volume, value+other.value};}
	point constexpr operator-(point other) const{return{volume-other.volume, value-other.value};}
	point constexpr operator-() const{return{-volume, -value};}
	auto constexpr cross(point other) const{ return volume*other.value-value*other.volume; }
};

int main(){
	std::ios::sync_with_stdio(0);std::cin.tie(0);
	int number, capacity; std::cin>>number>>capacity;
	assert(capacity>0);

	std::deque<point> points{ {0, 0},{(double)capacity, 0} }; // sort by volume
	point offset{};

	std::cout<<std::fixed<<std::setprecision(7);
	for(int _=0; _<number; ++_){
		int64_t volume, temp; std::cin>>temp>>volume;
		assert(volume>0);
		offset.volume+=volume;
		offset.value+=volume*temp;

		while(points.size()>=2 and points.end()[-2].volume+offset.volume>=capacity)
			points.pop_back();
		if(points.back().volume+offset.volume>capacity){
			auto const a=points.end()[-2], b=points.back();
			auto const x=capacity-offset.volume;
			points.back()={x,
				double(b.value*(x-a.volume) + a.value*(b.volume-x))/double(b.volume-a.volume)
			};
		}


		while(points.size()>=2 and (points[0]+offset).cross(points[1]+offset)>=0)
			points.pop_front();
		points.push_front(-offset);


		std::cout<<
			(points.back()+offset).value/capacity
			<<'\n';
	}
}


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

int main() {
    int N;
    string S;
    cin >> N >> S;
    
    if (N%2 == 1) {
        cout << "No" << endl; 
        return 0;
    }
    for (int i=0; i<N/2; i++){
        if (S[i] != S[N/2 + i]) {
            cout << "No" << endl; 
            return 0;
            }
    }
    cout << "Yes" << endl;
return 0;
}

Measured memory_bytes: 256
// Union Find 木
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

// UnionFind
const int MAX_N = 200010;

struct union_find {
    int par[MAX_N]; // 親
    int rank_[MAX_N]; // 木の深さ

    // n要素で初期化
    union_find (int n) {
        for (int i = 0; i < n; i++) {
            par[i] = i;
            rank_[i] = 0;
        }
    }

    // 木の根を求める
    int find (int x) {
        if ((par[x] == x)) 
            return x;
        else 
            return par[x] = find(par[x]);
    }

    // xとyの属する集合を併合
    void unite (int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;

        if (rank_[x] < rank_[y]) {
            par[x] = y;
        } else {
            par[y] = x;
            if (rank_[x] == rank_[y]) rank_[x] ++;
        }
    }

    // xとyが同じ集合に属するか判定
    bool same (int x, int y) {
        return find(x) == find(y);
    }
};

int main() {

    int N, K, L;
    cin >> N >> K >> L;

    // 道と線路の二つのunion-findを初期化
    union_find road(N), train(N);

    int a, b;
    for (int i = 0; i < K; i++) {
        cin >> a >> b;
        a--, b--;
        if (!road.same(a, b)) road.unite(a, b);
    }
    for (int i = 0; i < L; i++) {
        cin >> a >> b;
        a--, b--;
        if (!train.same(a, b)) train.unite(a, b);
    }    
    
    vector<pint> com(N);
    map<pint, int> mp;
    for (int i = 0; i < N; i++) {
        com[i].first = road.find(i);
        com[i].second = train.find(i);
        mp[com[i]]++;
    }

    for (int i = 0; i < N; i++) {
        cout << mp[com[i]] << " ";
    }

    cout << endl;
    
    return 0;
}

Measured memory_bytes: 16640
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define N 2*10e5
#define precise cout<<fixed<<setprecision(10)
#pragma GCC optimize("O0")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")
#define rep(i,a,b) for(int i=a;i<b;i++)
#define min3(a,b,c) min(a,min(b,c))
#define nl cout<<"\n";
#define all(v) v.begin(),v.end()
#define F first
#define S second
typedef long long ll;
typedef vector<long long> vl;
typedef vector<pair<long,long>> vp;
void get(ll arr[],ll n){for(ll i=0;i<n;i++) cin>>arr[i];}
ll gcd(ll a,ll b);
ll binpow(ll a,ll b);
void solve()
{
	ll n;
	cin>>n;
	char c='a';
	string x="";
	//n--;
	do
	{
		if(n%26==0) x+='z',n--;
		else x+= c -1 + n%26;
		n/=26;
	}while(n>0);
	reverse(all(x));
	cout<<x;
	
}
int main()
{
 	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll t;
	t=1;
	//cin>>t;
	while(t--)
	{
	 	solve();
	}
	//cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}
ll binpow(ll a, ll b) {
   ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
ll gcd(ll a,ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}



Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long 
#define M 1000000007

ll n;
map<ll,ll> mp;

ll f(ll k){
  if(mp[k]) return mp[k];
  if(k==0) return mp[k]=1;
  if(k==1) return mp[k]=2;
  if(k%2==0) return mp[k]=(2*f(k/2-1)+f(k/2))%M;
  return mp[k] =(f(k/2-1)+2*f(k/2))%M;
}


int main(){
  cin>>n;

  cout<<f(n)<<endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
 
	public static void main( String args[] ) {
		Scanner scan = new Scanner(System.in);
	    long x, jikan, hun, byou;
	    x = scan.nextLong();
	    jikan = x / 3600;
	    hun = (x - (jikan * 3600)) / 60;
	    byou = x - (jikan * 3600 + hun * 60);
	    
	    
	    System.out.println(jikan + ":" + hun + ":" + byou);
	    
	    //System.out.println(jikan);
	    //System.out.println(hun);
	    //System.out.println(byou);
    } 
 
}

Measured memory_bytes: 26392
#include<bits/stdc++.h>
#define fr(i,c,b) for(int i=c;i<b;i++)
#define frl(i,c,b) for(ll i=c;i<b;i++)
#define si(x) int x; scanf("%d", &x)
#define sll(x) ll x; scanf("%lld", &x)
#define pi(x) printf("%d", x)
#define pll(x) printf("%lld", x)
#define nl printf("\n")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define MAX 100001
#define M 1000000007
#define pb push_back

typedef long long int ll;

using namespace std;

int main()
{
    si(n);
    ll a[n]; ll b[n]; ll c[n];
    fr(i,0,n)   cin>>a[i]>>b[i]>>c[i];
    ll dp[n][3];
    dp[0][0]=a[0]; dp[0][1]=b[0]; dp[0][2]=c[0]; // this is the base case 
    
    // now the recurrence relation is dp[i][0]=a[i]+max(dp[i-1][2],dp[i-1][1])   for a and similarly for other values
    
    fr(i,1,n)
    {
        dp[i][0]=a[i]+max(dp[i-1][2],dp[i-1][1]);
        dp[i][1]=b[i]+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2]=c[i]+max(dp[i-1][0],dp[i-1][1]);
    }
    --n;
    ll ans=max(dp[n][0],dp[n][1]);
    cout<<max(dp[n][2],ans);
}

Measured memory_bytes: 8348
#include <bits/stdc++.h>
using namespace std;
typedef pair<double, int> P;

int main(void) {
  int N;
  cin >> N;
  vector<P> a(N);
  double ave = 0;
  for (int i = 0; i < N; i++) {
    double tmp;
    cin >> tmp;
    a[i] = P(tmp, i);
    ave += tmp;
  }
  ave /= N;
  for (int i = 0; i < N; i++) {
    a[i] = P(abs(a[i].first - ave), a[i].second);
  }
  sort(a.begin(), a.end());
  cout << a[0].second << endl;
  return 0;
}

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

int main() {
    int N; cin >> N;
    vector<ll> c(N-1), s(N-1), f(N-1);
    for (int i = 0; i < N-1; i++) cin >> c[i] >> s[i] >> f[i];

    for (int i = 0; i < N-1; i++)
    {
        ll t = 0;
        for (int j = i; j < N-1; j++)
        {
            if(t<s[j]) t = s[j] + c[j];
            else{
                if(t%f[j]>0) t += f[j] - (t%f[j]);
                t += c[j];
            }
        }
        cout << t << '\n';
    }
    cout << 0 << '\n';
        
}

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

const int LIM = 2500;
const long long INF = (long long) 1e18;

int C[55], D[55];
int done[55][2505];
long long SP[55][2505];

vector< vector<int> > X[55];
priority_queue< vector<long long>, vector< vector<long long> >, greater< vector<long long> > > Q;

void relax(int ux, int uy, int vx, int vy, int w)
{
    if(SP[vx][vy] > SP[ux][uy] + w)
    {
        SP[vx][vy] = SP[ux][uy] + w;
        Q.push({SP[vx][vy], vx, vy});
    }
}

int main() {
    int n, m, s;
    cin >> n >> m >> s;

    while(m--)
    {
        int u, v, a, b;
        cin >> u >> v >> a >> b;

        X[u].push_back({v, a, b});
        X[v].push_back({u, a, b});
    }

    for (int i=1; i<=n; i++)
        cin >> C[i] >> D[i];

    for (int i=1; i<=n; i++)
        for (int j=0; j<=LIM; j++)
            SP[i][j] = INF;
    
    s = min(s, LIM);
    SP[1][s] = 0;
    Q.push({SP[1][s], 1, s});

    while(!Q.empty()) {
        auto q = Q.top();
        Q.pop();

        int indx = q[1], coins = q[2];

        if(done[indx][coins])
            continue;
        
        done[indx][coins] = 1;

        for (int i=1; coins+i<=LIM && i<=C[indx]; i++)
            if (!done[indx][coins+i])
                relax(indx, coins, indx, coins + i, D[indx]);
        
        for (auto x : X[indx])
            if (x[1] <= coins && !done[ x[0] ][ coins - x[1] ])
                relax(indx, coins, x[0], coins - x[1], x[2]);
    }

    for (int i=2; i<=n; i++)
        cout << *min_element(SP[i], SP[i]+LIM+1) << "\n";

    return 0;
}


Measured memory_bytes: 8132
using System;

class Maximum_Profit {
	public static void Main() {

		int n;
		n = int.Parse(Console.ReadLine());
		int[] a = new int[n];

		for(int i = 0; i < n; i++) {
			a[i] = int.Parse(Console.ReadLine());
		}

		int max = a[1] - a[0];
		int min = a[0];
		for(int i = 1; i <= n - 1; i++) {
			max = Math.Max(max, a[i] - min);
			min = Math.Min(min, a[i]);
		}

		Console.WriteLine(max);

	}
}

Measured memory_bytes: 10848
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
//#include <boost/lexical_cast.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define pb push_back
#define mp make_pair
#define endl '\n'
#define PI acos(-1)
#define bitcount(a) __builtin_popcountll(a)
#define P pair<int,int>
typedef tree<int,null_type,less_equal <int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

long mod=1e9+7;
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	cin>>n;
	int ans=0;
	int a[n+1],b[n+1],c[n+1];
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	for(int i=1;i<=n;i++)
		cin>>b[i];
	for(int i=1;i<=n;i++)
		cin>>c[i];
	for(int i=1;i<=n;i++)
	{
        ans+=b[a[i]];
        if(i==n)
        	break;
        if(a[i+1]==a[i]+1)
        {
        	ans+=c[a[i]];
        }
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF 1e18L
#define INF 1e9L
#define EPS 1e-9
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define pb push_back
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<int, int> pii;

int main(void)
{
    int n;
    cin >> n;
    if(n < 1000) pr("ABC");
    else pr("ABD");
}

Measured memory_bytes: 256
def func(n, A):
    count = 0
    for i in range(n):
        minj = i
        for j in range(i, n):
            if (A[j] < A[minj]):
                minj = j
        if (A[i] != A[minj]):
            A[i], A[minj] = A[minj], A[i]
            count += 1
    print (" ".join(map(str, A)))
    print (count)

n = int(input())
A = list(map(int, input().split(" ")))
func(n, A)


Measured memory_bytes: 5600
#include<vector>
#include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<limits.h>
#include<cmath>
using namespace std;

int main(){
  
  int n,k; cin >> n >> k;
  string s; cin >> s;
  char c = s[k-1];
  
  if (c=='A') s[k-1]='a';
  else if (c=='B') s[k-1]='b';
  else if (c=='C') s[k-1]='c';
  
  cout << s;
 
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	
	cin.tie( 0 );
	ios::sync_with_stdio( false );
	
	string s;
	
	while( getline( cin, s ) ){
		
		if( s == "END OF INPUT" ){ return 0;}
		
		s += ' '; //add SP
		int count {0};
		vector<int> vc;
		
		for( int i = 0; i < (int)s.size(); i++ ){
			
			if( s[i] != ' ' ){
				count++;
				continue;
			}
			
			vc.push_back( count );
			count = 0;
		
		}
		
		for( auto x : vc ){
			cout << x;
		}
		
		cout << endl;
		
	}
	
	return 0;

}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define RALL(a)     (a).rbegin(),(a).rend()
#define PRINT(a)   cout << (a) << endl

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second

#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

using ll = long long int;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

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

const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};


mint mpow(int x, int n){
  if(n==0)return 1;

  mint y = mpow(x, n/2);
  y *= y;

  if(n%2==1) y *=x;
  return y;
}

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};



int main(){
  map<char,int> mp;
  int n;
  cin >> n;
  REP(i,n){
    char c;
    cin >> c;
    mp[c]++;
  }

  mint ans=1;
  for(auto v: mp){
    ans *= (v.second+1);
  }
  ans -= 1;
  cout << ans.x << endl;
}



Measured memory_bytes: 3608
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 10000000000000007
#define ggr getchar(); getchar();return 0;
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}

long long n, a, b;

signed main() {
	cin >> n >> a >> b;
	if (a > b || (n == 1 && a != b))cout << 0 << endl;
	else if (n == 1 || n == 2)cout << 1 << endl;
	else cout << (a + b * (n - 1)) - (a*(n - 1) + b - 1) << endl;
	ggr
}

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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll modpow(ll n, ll k) {
    ll s = 1, p = n;
    for (ll i = 0; (1LL << i) <= k; ++i, p = (p * p) % MOD) {
        if (((k) & (1 << i)) == 0)
            continue;
        s *= p;
        s %= MOD;
    }
    return s;
}

ll combination(ll n, ll r) {
    ll p = 1;
    REP(i, r) {
        p = (p * (n - i)) % MOD;
    }
    ll ip = 1;
    REP(i, r) {
        ip = (ip * (i + 1)) % MOD;
    }
    ip = modpow(ip, MOD - 2);
    return (p * ip) % MOD;
}

int main() {
    ll N, A, B;
    cin >> N >> A >> B;

    ll p = modpow(2, N) - 1;
    ll ca = combination(N, A);
    ll cb = combination(N, B);

    p = (p + MOD - ca) % MOD;
    p = (p + MOD - cb) % MOD;
    cout << p << endl;

    return 0;
}

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

#define PI 3.141592653589793238
#define INF 1050000000

using namespace std;



//cout << fixed << setprecision(15) << << endl;
//cout << << endl;

int main() {

	int N;

	cin >> N;

	cout << N * 800 - (N / 15) * 200 << endl;



	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 99999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(150) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define Lower(v,X) lower_bound(v.begin(),v.end(),X)-v.begin();
#define mod 1000000007
#define MAX 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int ddx[8] = {1, 0, -1, 0, 1, -1, 1,-1};
int ddy[8] = {0, 1, 0, -1, 1, -1, -1,1};
int main(){
  lli A,B,C,D,E,F,N,M,K,L,R,X,Y,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> H >> W;
  DV(G,char,H,W,'.');
  DV(P,char,H,W,'.');
  rep(i,0,H)rep(j,0,W)cin >> G[i][j];
  rep(i,0,H)rep(j,0,W){
    sum=0;
    if(G[i][j]!='#'){
      rep(k,0,8){
        auto nx=i+ddx[k];
        auto ny=j+ddy[k];
        if(nx>H-1||ny>W-1||nx<0||ny<0)continue;
        if(G[nx][ny]=='#')sum++;
      }
      P[i][j]=(char)'0'+sum;
    }
    else P[i][j]='#';
  }
  rep(i,0,H)rep(j,0,W){
    if(j+1==W)Out(P[i][j]);
    else cout << P[i][j];
  }
}

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

int main() {
  int N;
  cin >> N;
  int64_t ans = 0;
  int M = 0;
  for (int i = 0; i < N; i++) {
    int p;
    cin >> p;
    ans += p;
    M = max(M, p);
  }
  cout << ans - M / 2 << endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define ALL(v) (v).begin(), (v).end()

int N, Q;
string s;
vector<char> t, d;

int sim(int x) {
  for (int i = 0; i < Q; ++i) {
    if (s[x] == t[i]) {
      if (d[i] == 'L') x--;
      else x++;
    }

    // マス１から落ちるとき
    if (x < 0) return -1;

    // マスNから落ちるとき
    else if (x > N-1) return -2;
  }

  return 0;
}

int main()
{
  cin >> N >> Q;
  cin >> s;
  t.resize(Q), d.resize(Q);

  for (int i = 0; i < Q; ++i) cin >> t[i] >> d[i];

  int le=-1, ri=N, mid;
  while (ri-le>1) {
    mid = (le+ri)/2;
    if (sim(mid) == -1) le = mid;
    else ri = mid;
  }

  int lle=-1, rri=N;
  while (rri-lle>1) {
    mid = (lle+rri)/2;
    if (sim(mid) == -2) rri = mid;
    else lle = mid;
  }

  cout << lle - ri + 1 << endl;
}

Measured memory_bytes: 900
(defun odd-helper (n)
  (find-if #'oddp n))

(defun zero-helper (n)
  (find-if #'zerop n))

(defun main (n)
  (shiftonly 0 (read-from-string (concatenate 'string "(" n ")"))))

(defun shiftonly (ans lis)
  (if (odd-helper lis)
      (format t "~a~%" ans)
      (if (zero-helper lis)
          (format t "~a~%" ans)
          (shiftonly (+ 1 ans) (mapcar #'(lambda (x) (/ x 2)) lis)))))

(read)
(main (read-line))

Measured memory_bytes: 6504
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    int n,m; cin>>n>>m;
    vector<int> p(n);
    rep(i,n) cin>>p[i];
    map<int,int> mp;
    int pre=0; mp[0]++;
    rep(i,n){
        pre+=p[i]; pre%=m; mp[pre]++;
    }
    ll ans=0;
    for(auto &v: mp){
        ll a=v.second;
        a=a*(a-1)/2;
        ans+=a;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3584
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<string>
#include<math.h>
#include<stdlib.h>
#include<time.h>
#include<map>
#include<queue>
#include<set>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
int n,a[110000],b[110000],c[110000],p,q;
long long ans;
int main(){
	scanf("%d",&n);
	fo(i,1,n) scanf("%d",&a[i]);
	fo(i,1,n) scanf("%d",&b[i]);
	fo(i,1,n) scanf("%d",&c[i]);
	sort(a+1,a+n+1);
	sort(b+1,b+n+1);
	sort(c+1,c+n+1);
	p=0;q=1;
	fo(i,1,n){
		while (p<n&&a[p+1]<b[i]) p++;
		while (q<=n&&c[q]<=b[i]) q++;
		ans+=p*(long long)(n-q+1);
	}
	printf("%lld\n",ans);
	return 0;
}


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

int main(void)
{
    int x, n;
    cin >> x >> n;

    vector<int> p(n),xp(n);

    rep(i,n)
    {
        cin >> p.at(i);
        xp.at(i) = abs(x - p.at(i));
    }

    sort(xp.begin(), xp.end());
    
    if(n==0||xp.at(0)!=0){
        cout << x << endl;
    }else{
        int nr=1,ans;
        rep(i,n)
        {
            if(i==0||xp.at(i)==xp.at(i-1))continue;
            if(i<n-1&&xp.at(i)==nr&&xp.at(i)==xp.at(i+1)){
                nr++;
            }else{
                break;
            }
        }
        
        ans=x-nr;
        
        rep(i,n)
        {
            if(p.at(i)==ans)ans=x+nr;
        }
        cout << ans << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    auto S = s.size();
    for (int i = 0; i < n; ++i) {
        int c = 0;
        string t;
        cin >> t;
        for (int j = 0; S+(S-1)*j <= t.length(); ++j) {
            for (int k = 0; k < t.length()-S-(S-1)*j+1; ++k) {
                int x = 1;
                for (int l = 0; l < S; ++l) {
                    if(s[l] != t[k+(j+1)*l]) x = 0;
                }
                c |= x;
            }
        }
        ans += c;
    }
    cout << ans << "\n";
    return 0;
}



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

//C++14 (GCC 5.4.1)

#define LLINF (1LL<<60)
typedef long long ll;
#define mod 1000000007

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(int i=(a);i>=(b);i--)

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

template<typename T> inline T divrup(T a, T b) { if (a % b) return a/b+1; else return a/b;}

#define dbg_v1(i,V) do{cout<<"-v1----\n";rep(i,V.size())cout<<" "<<i<<"\t:"<<V[i]<<endl;cout<<endl;}while(0)
#define dbg_v2(i,k,V) do{cout<<"-v2----\n";rep(i,V.size()){rep(k,V[0].size())cout<<" "<<V[i][k];cout<<endl;}}while(0)

int main() {
    int A,B,C;
    cin >>A>>B;
    int ans=A+B;

    if(ans%2)
        cout << "IMPOSSIBLE" <<endl;
    else  cout <<ans/2 <<endl;
    return (0);
}

Measured memory_bytes: 256