akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
    int n, ans = 0;
    cin >> n;
    vector<vector<pair<int, int>>> e(n);
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        for(int j = 0; j < a; j++){
            int x, y;
            cin >> x >> y;
            x--;
            e[i].emplace_back(x, y);
        }
    }
    for(int i = 0; i < (1<<n); i++){
        int cnt = 0;
        bool f = true;
        for(int j = 0; j < n; j++){
            if(((i>>j) & 1) != 1) continue;
            cnt++;
            for(auto&& k : e[j]){
                if(((i >> k.first) & 1) != k.second){
                    f = false;
                    break;
                }
            }
        }
        if(f) ans = max(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 105,W = 100005;
int n,w;
long long dp[N][W],wyn = 0;
int main(){
    scanf("%d %d",&n,&w);
    for(int i = 1; i <= n; i++){
        int x,y; scanf("%d %d",&x,&y);
        for(int j = 0; j < x; j++) dp[i][j] = dp[i-1][j];
        for(int j = x; j <= w; j++) dp[i][j] = max(dp[i-1][j],dp[i-1][j-x]+y);
    }
    for(int i = 0; i <= w; i++) wyn = max(dp[n][i],wyn);
    printf("%lld",wyn);
    return 0;
}

Measured memory_bytes: 79360
/**
 * Я слил Atcoder Beginner Contest 172, решив всего две задачи!
 * Я не могу апнуть синего!
 * Я постоянно сливаю раунды, либо не решив тупую задачу, либо набрав штрафа!
 * Я постоянно уступаю всем своим друзьям и знакомым в контестах и нахожу этому оправдания!
 * Я постоянно придумываю сложные неверные решения к простым задачам!
 * -------------------------------------------------------------
 * -Решать сложные задачи
 * -Участвовать в контестах
 * -Делать виртуальные соревнования
 * -------------------------------------------------------------
 * Не уберу это, пока не начну нормально решать задачи, а не заниматься ерундой!!!
**/
  
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")

typedef long long  ll;
#define press_F_to_pay_respect ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn for(int i=0;i<n;i++) 
#define fore(i,a,b) for(int i = a; i < (b); i++)
#define pb push_back 
#define pob pop_back()
#define mp make_pair 
#define sc second 
#define f first 
#define ld long double
#define kek cout<<endl; 
#define rep(i,a,b) for(int i=a;i<b;i++)
#define all(v) ((v).begin()), ((v).end()) 
#define halt {cout<<"NO"; return 0;}
const ll MOD = 1e9 + 7;
const ll MOD1 = 998244353;
const int N = 200010;
const int INF = 1e8;
const ll LL_INF=1e10;
const long double pi=3.1415926535;
using namespace std;
using namespace __gnu_pbds;
typedef tree<ld,null_type,less<ld>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
// Template functions
string bin_rep(ll n)
{
     string s="";
      for(int i=63;i>=0;i--)
   {
           if(n&(1LL<<i)) s+='1';
           else s+='0';
   }
   return s;
}
int first_bit(int n)
{
  for(int i=0;i<=31;i++)
   {
           if(n&(1<<i)) return i;
   }
}

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

int main()
{
    #if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
    #endif
 press_F_to_pay_respect;
 // cout << fixed << setprecision(12) << ans;
 // string al = "abcdefghijklmnopqrstuvwxyz";
 int n;
 cin>>n;
 vector<int> v(n+1,0);
 for(ll i=1;i<=n;i++)
 {
           if(i*i>n) break;
           for(ll j=1;j<=n;j++)
           {
                     if(i*j>n || i*i>n || j*j>n) break;
                     for(ll k=1;k<=n;k++)
                     {
                               ll val=i*i+j*j+k*k+i*j+i*k+j*k;
                               if(val>n) break;
                              // cout<<val<<" ";
                               v[val]++;
                     }
           }
 }
 for(int i=1;i<=n;i++) cout<<v[i]<<endl;

 
 
  // cout <<"Runtime is:"<<clock() * 1.0 / CLOCKS_PER_SEC <<endl;
   return 0;
   
   
 
}

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int n;
  cin >> n;
  int ans = 0;
  rep(i,n) {
    int a;
    cin >> a;
    while(a % 2 == 0) {
      ans++;
      a /= 2;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>	
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE int
#define MEMSET(a) memset(a,0,sizeof(a))
const int mod=(int)1e09+7;

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
double din(void){
	double i;scanf("%lf",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void dprint(double a){
	printf("%.10f\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}
long long llabs(long long a){
	return a>0?a:-a;
}
double dmax(double a,double b){
	return a>b?a:b;
}
int cmp(const void *a,const void *b){
	return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
	return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
	return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
	return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
	int t=*a;
	*a=*b;
	*b=t;
}
long long gcd(long long x,long long y){
	return x%y?gcd(y,x%y):y;
}
long long lcm(long long x,long long y){
	return x/gcd(x,y)*y;
}

int main(void){
	int c[3][3],i,j;
	rep(i,3)rep(j,3)c[i][j]=in();
	rep(i,3){
		if(c[0][i]-c[0][(i+1)%3]!=c[1][i]-c[1][(i+1)%3]||c[1][i]-c[1][(i+1)%3]!=c[2][i]-c[2][(i+1)%3]){
			puts("No");
			return 0;
		}
	}
	rep(i,3){
		if(c[i][0]-c[(i+1)%3][0]!=c[i][1]-c[(i+1)%3][1]||c[i][1]-c[(i+1)%3][1]!=c[i][2]-c[(i+1)%3][2]){
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}

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

int main() {
	int m[50],f[50],r[50];
	
	for(int i=0;i<50;i++){
	    cin>>m[i]>>f[i]>>r[i];
	    
	    if(m[i]==-1 && f[i]==-1 && r[i]==-1){
	        break;
	    }
	    else if(m[i]==-1 || f[i]==-1){
	        cout<<'F'<<'\n';
	    }
	    else if(m[i]+f[i] >=80){
	        cout<<'A'<<'\n';	        
	    }
	    else if(m[i]+f[i] >=65){
	        cout<<'B'<<'\n';	        
	    }
	    else if(m[i]+f[i] >=50 || (m[i]+f[i] >=30 && r[i]>=50)){
	        cout<<'C'<<'\n';	        
	    }
	    else if(m[i]+f[i] >=30){
	        cout<<'D'<<'\n';	        
	    }
	    else{
	        cout<<'F'<<'\n';
	    }
	}
	return 0;
}



Measured memory_bytes: 2992
#!/usr/bin/env python3
import math

MOD = 10**9
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

R = int(input())
print(2*R*math.pi)


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

int main()
{
    string a, b;
    cin >> a >> b;
    int n = stoi(a+b);

    for(int i = 0; i <= 1000; i++){
        if(i*i == n){
            puts("Yes");
            return 0;
        }
    }
    puts("No");
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define rev(a,b,c) for(int a=b;a>=c;a--)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define end end()
#define vec vector<ll>
#define se set<ll>
#define mults multiset<ll>
#define F first
#define S second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b
#define get(a) cin>>a
#define nextl cout<<endl
const ll mod = 1000000007;
const ll maxn = 500005;
const ll mm = 1e+18;
ll power(ll x, ll y)
{
    ll res = 1;
    x = x % mod;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % mod;
        y = y>>1;
        x = (x*x) % mod;
    }
    return res;
}
ll ncr(ll n, ll k)
{
    ll C[k+1];
    memset(C, 0, sizeof(C));

    C[0] = 1;

    for (ll i = 1; i <= n; i++)
    {
        for (ll j = min(i, k); j > 0; j--)
            C[j] = (C[j] + C[j-1])%mod;
    }
    return C[k];
}
void solve()
{
    int a,b;
    cin>>a>>b;
    if(a<10&&b<10) cout<<a*b;
    else cout<<"-1";
}
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
   // cin>>t;
    while(t--){
        solve();
      //  nextl;
    }
    return 0;
}


Measured memory_bytes: 256
N=int(input())
T=[list(map(int,input().split())) for _ in range(N)]

T.insert(0,[0,0,0])

ans='Yes'
for i in range(1,N+1):
    if T[i][0]-T[i-1][0]<abs(T[i][1]-T[i-1][1])+abs(T[i][2]-T[i-1][2]):
        ans='No'
    
for j in range(1,N+1):
    if (T[j][1]+T[j][2])%2!=T[j][0]%2:
        ans='No'

print(ans)

Measured memory_bytes: 27300
#include<stdio.h>

void GCD(int,int); 

int main()
{
  int x,y;
  scanf("%d%d",&x,&y);
  GCD(x,y);

  return 0;
}
/*最大公約数を求める*/
void GCD(int x,int y)
{
  int a,n;
  if(x<y)
    {
      a=x;
      x=y;
      y=a;
    }
  n=x%y;
  while(n!=0)
    {
      x=y;
      y=n;
      n=x%y;
    }
  printf("%d\n",y);
}



Measured memory_bytes: 2144
//============================================================================
// Name        : 75b.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include<vector>
#include<string>
#include<map>
using namespace std;

int main() {
	int h,w;cin>>h>>w;
	vector<string> s(h);
	map<int,map<int,int>> m;
	for(int i=0;i<h;i++){
		cin>>s[i];
	}
	for(int i=-1;i<=h;i++){
		for(int j=-1;j<=w;j++){
			m[i][j]=0;
			if(i==-1)continue;
			if(i==h)continue;
			if(j==-1)continue;
			if(j==w)continue;
			if(s[i][j]=='#')m[i][j]=-1;;
		}
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(m[i][j]==-1){
				cout<<'#';
			}else{
				int ans=0;
				for(int k=-1;k<2;k++){
					for(int l=-1;l<2;l++){
						ans+=-m[i+k][j+l];
					}
				}
				cout<<ans;
			}
		}cout<<endl;
	}

	return 0;
}

Measured memory_bytes: 384
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

struct pnt {
	int x, y;
	constexpr pnt(int x = 0, int y = 0) noexcept : x(x), y(y) {};
	constexpr bool operator==(const pnt &rhs) const noexcept { return x == rhs.x && y == rhs.y; }
	constexpr bool operator<(const pnt & rhs) const noexcept { return x < rhs.x || x == rhs.x && y < rhs.y; }
	constexpr pnt operator+(const pnt &rhs) const noexcept { return pnt(x + rhs.x, y + rhs.y); }
	constexpr pnt operator-(const pnt &rhs) const noexcept { return pnt(x - rhs.x, y - rhs.y); }
	constexpr pnt operator-() const noexcept { return pnt(-x, -y); }
	constexpr int operator*(const pnt &rhs) const noexcept { return x * rhs.x + y * rhs.y; }
	friend istream& operator>>(istream& is, pnt &p) { return is >> p.x >> p.y; }
	friend ostream& operator<<(ostream& os, const pnt &p) { return os << p.x << " " << p.y << "\n"; }
	constexpr pnt nor(const pnt &rhs) const noexcept { return pnt(rhs.y, -rhs.x); }
	template<class T> T& operator[](vector<vector<T>> &v) { return v[x][y]; }
};

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

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int H, W;
	cin >> H >> W;

	vector<vector<char>> grid(H, vector<char>(W));
	for (int i = 0; i < H; i++) for (int j = 0; j < W; j++)  cin >> grid[i][j];
	DMP(grid);

	auto shortest_path = [&](pnt st) {

		if (st[grid] == '#') return 0;
		
		queue<pnt> que;
		que.emplace(st);
		vector<vector<int>> used(H, vector<int>(W, INF));
		st[used] = 0;

		int res = 0;
		while (!que.empty()) {

			pnt now = que.front();
			que.pop();
			chmax(res, now[used]);

			vector<pnt> dxdy{ {-1,0},{1,0},{0,1},{0,-1} };
			for (const auto &d : dxdy) {
				pnt next = now + d;
				if (0 <= next.x && next.x < H && 0 <= next.y && next.y < W && next[grid] == '.' && next[used] == INF) {
					que.emplace(next);
					next[used] = now[used] + 1;
				}
			}

		}
		DMP(used);
		return res;

	};

	int ans = 0;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			chmax(ans, shortest_path(pnt(i, j)));
		}
	}

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int64_t n;
  cin >> n;
  int64_t ans=0,t=1;
  while(ans<n){
    ans+=t;
    t++;
  }
  cout << t-1;
}


Measured memory_bytes: 256
s = gets.chomp.chars.map(&:ord).sort
t = gets.chomp.chars.map(&:ord).sort.reverse
s << 0
t << -1

t.length.times{ |i|
  s_min = s[i]
  t_max = t[i]
  if s[i].nil? || s_min < t_max
    puts 'Yes'
    break
  elsif s_min > t_max
    puts 'No'
    break
  end
}


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

int n, a, b, pass=0, passb=0;
string part;

int main() {
	cin >> n >> a >> b >> part;

	for(char element: part){
		if (element == 'a'){
			if(pass < a+b){
				cout << "Yes" << endl;
				pass++;
			}
			else
				cout << "No" << endl;
		}
		else if (element == 'b'){
			if(pass < a+b && passb < b){
				cout << "Yes" << endl;
				pass++;
				passb++;
			}
			else
				cout << "No" << endl;
		}
		else{
			cout << "No" << endl;
		}
	}
}

Measured memory_bytes: 896
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        m: usize,
        a: [usize; n],
        mut bc: [(usize, usize); m],
    }

    for a_ in a {
        bc.push((1, a_));
    }
    bc.sort_by(|a, b| a.1.cmp(&b.1).reverse());

    let mut cnt = n.clone();
    let mut ans = 0;
    for (v_, k_ ) in bc {
        let v__ = min(v_, cnt);
        ans += v__ * k_;
        cnt -= v__;
    }
    println!("{}", ans);
}


Measured memory_bytes: 14588
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;


int main() {
    long long int n;
    long long int k;
    cin >> n >> k;
    vector<int> v(n);
    vector<int> ans(n);
    for (int i = 0 ; i < n ; i++){
        int a ; 
        cin >> a;
        v[i] = a;
        ans[i] = INT32_MAX;
    }

    ans[0] = 0;
    ans[1] = abs(v[1] - v[0]);
    for (int i = 2 ; i < n ; i++){
        for (int j = 1 ; j <= k ; j++){
            if(j <= i){
                int ans1 = ans[i -j] + abs(v[i-j] - v[i]);
                ans[i] = min(ans[i], ans1);
            }
            else break;
            
        }
    }
    cout << ans[n-1];
    return 0;
}


Measured memory_bytes: 4052
#![allow(unused_imports)]
// use itertools::Itertools;
use proconio::{input, marker::*};

fn main() {
    input! {
        mut abc: [usize; 3]
    };
    abc.sort();
    println!(
        "{}",
        if abc[0] + abc[1] == abc[2] {
            "Yes"
        } else {
            "No"
        }
    );
}


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

using namespace std;

int main() {
	int n, k;
	
	scanf("%d %d", &n, &k);
	k--;
	char str[n];
	scanf("%s", str);
	
	str[k] = str[k] - 'A' + 'a';
	printf("%s", str);
}


Measured memory_bytes: 256
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

n = int(input())

if n == 1:
    print(0)
    exit()

prime = factorization(n)

ans = 0


for i in range(len(prime)):
    s = 0
    for j in range(1, prime[i][1]+1):
        if j*(j+1)/2 <= prime[i][1]:
            s = max(s, j)
    ans += s

print(ans)


Measured memory_bytes: 9500
#ifdef DEBUG_IS_VALID
#define DEB 1 
#define _LIBCPP_DEBUG 0
#else
#define DEB 0
#define NDEBUG
#endif

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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#pragma GCC optimize ("-O3")

using namespace std;

#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){cout << "{"; for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

const int INF = 1<<29;
const long long LINF=1LL<<59;


void solve(long long N, std::vector<long long> H){
  ll ans = 0;
  ll ma = 0;
  rep(i,N){
    if(ma<=H[i]) ans++;
    chmax(ma,H[i]);
  }
  cout << ans << endl;
}

int main(){
  long long N;
  scanf("%lld",&N);
  std::vector<long long> H(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&H[i]);
  }
  solve(N, std::move(H));
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <cstring>
#include <deque>
#include <stack>
#include <stdio.h>
#include <map>
#include <set>
#include <time.h>
#include <string>
#include <fstream>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <assert.h>
#include <list>
#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define pdd pair<double,double>
#define pii pair<ll,ll>
#define PI 3.14159265358979323846
#define MOD 1000000007
#define MOD2 1000000009
#define INF ((ll)1e+18)
#define x1 fldgjdflgjhrthrl
#define x2 fldgjdflgrtyrtyjl
#define y1 fldggfhfghjdflgjl
#define y2 ffgfldgjdflgjl
#define N 131072
#define SUM 377
#define MAG 33554431
#define RED 0
#define BLUE 1
#define ALP 26
typedef long long ll;
typedef long double ld;
using namespace std;
ll i,j,n,k,l,m,r,x,y,K,tot,h,H;
string s,t,s1;
ll used[100500];
vector<ll> g[100500], f;
void dfs(ll v, ll tim)
{
    if (used[v])
        return;
    used[v] = tim;
    tot++;
    for (int i = 0; i < g[v].size(); i++)
    {
        ll to = g[v][i];
        if (used[to] && (tim-used[to])%2 == 0)
            H = 1;
        if (!used[to])
            dfs(to, tim+1);
        //else
        //    cout << v << " " << to << " " << used[to] << " " << tim << endl;
    }
}
int main() {
	//freopen("input.txt","r",stdin);
 	//freopen("output.txt","w",stdout);
    cin >> n >> m;
    for (i = 0; i < m; i++)
    {
        cin >> x  >> y;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    ll tmp = 2*n-1;
    ll NN = n;
    x = 0; y = 0;
    for (i = 1; i <= n; i++)
        if (!used[i])
        {
            tot = h = 0;

            H = 0;
            dfs(i, 1);

            if (tot == 1)
            {
                k += tmp;
                tmp -= 2;
                NN--;
                continue;
            }

            k++;
            if (H == 0)
            {
                k++;
                x++;
            }
            y++;
            //cout << tot << endl;
        }
    ll sum = 0;
    n = NN;
    cout << k + (x*(x-1)*2 + y*(y-1)-x*(x-1)) << endl;
    return 0;
}


Measured memory_bytes: 12416
#include <cstdio>
int main()
{
	
	int a = 0,b = 0;
	char c;
	scanf ("%d %c %d",&a,&c,&b);
	switch (c){
		case '+':printf ("%d",a + b);break;
		case '-':printf ("%d",a - b);
		}
	return 0;
	}

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, double> pid;
typedef pair<double, int> pdi;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	int X, Y;

	cin >> X >> Y;

	if (abs(X - Y) <= 1)
	{
		cout << "Brown" << endl;
	}
	else
	{
		cout << "Alice" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	    String line = br.readLine();
	    StringTokenizer st = new StringTokenizer(line);
	    int a = Integer.parseInt(st.nextToken());
	    int b = Integer.parseInt(st.nextToken());
	    if ((a*b) % 2==0) {
	    		System.out.println("Even");
	    }
	    else {
	    		System.out.println("Odd");
	    }

	}

}


Measured memory_bytes: 22484
#include <cstdio>
#include <algorithm>
using namespace std;

int main()
{
bool submit[30] = {false};
for(int i = 0; i < 28; ++i) {
int t;
scanf("%d", &t);
submit[t - 1] = true;
}
for(int i = 0; i < 30; ++i) {
if(!submit[i])
printf("%d\n", i + 1);
}
return 0;
}

Measured memory_bytes: 1020
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;
using namespace std;

#define rep(i, n) for (int(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (int i = (a); i < (b); i++)
#define rrrep(i, a, b) for (int i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl

ll n, cnt, ans = LINF, a, b, d, tmp, tmpp, m, h, w, x, y, sum, pos, k;
ld doua;
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
bool fl;
struct edge
{
    int to, cost;
};
map<char, ll> aru;

//-------------------------↓↓↓↓↓↓------------------------

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

    cin >> s;
    rep(i, Size(s)) aru[s[i]] = 1;
    for (char c = 'a'; c <= 'z'; c++)
    {
        if (aru[c] == 0)
            continue;
        cnt = 0;
        ll iti[ohara];
        ll iti_cou = 1;
        iti[0] = -1;
        rep(i, Size(s))
        {
            if (s[i] == c)
                iti[iti_cou++] = i;
        }
        iti[iti_cou++] = Size(s);
        rrep(i, 1, iti_cou - 1)
        {
            cnt = max(cnt, max(iti[i] - iti[i - 1] - 1, iti[i + 1] - iti[i] - 1));
        }
        ans = min(ans, cnt);
    }
    Cout(ans);
    return 0;
}


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

using namespace std;
typedef long long LL;

#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}
}star;
#define DEBUG if(0)
#endif

#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}

class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }};

int main() {
	LL d, n, m;
	cin >> n >> m >> d;
	LL num = (m - 1)*(n - d) * 2;
	if (d == 0)num = (m - 1)*n;
	cout << fixed<<setprecision(10);
	cout << num * 1.0 / (n*n) << endl;

	return 0;
}


Measured memory_bytes: 256
submit = True


def solve_e(test=False, n=2, k=3, a_list=[8, 20]):

    if not test:
        n, k = map(int, input().split())
        a_list = list(map(int, input().split()))

    a_sum = sum(a_list)
    q_list = []

    for i in range(1, int(a_sum ** 0.5)+1):
        if a_sum % i == 0:
            q_list.append(i)
            if i != a_sum // i:
                q_list.append(a_sum // i)

    res = 1
    for q in q_list:
        r_list = [0] * n
        for i in range(n):
            r_list[i] = a_list[i] % q
        r_list_s = sorted(r_list)
        cnt = 0
        right = n - 1
        for i in range(n):
            if r_list_s[i] == q:
                break
            r = r_list_s[i]
            cnt += r
            while r > 0:
                d = q - r_list_s[right]
                if r >= d:
                    r -= d
                    r_list_s[right] = q
                    right -= 1
                else:
                    r_list_s[right] += r
                    r = 0
            r_list_s[i] = 0
        if cnt <= k:
            if q > res:
                res = q

    print(res)


if __name__ == "__main__":
    if submit:
        solve_e()
    else:
        solve_e(test=True, n=2, k=3, a_list=[8, 20])
        solve_e(test=True, n=2, k=10, a_list=[3, 5])
        solve_e(test=True, n=4, k=5, a_list=[10, 1, 2, 22])
        solve_e(test=True, n=8, k=7, a_list=[1, 7, 5, 6, 8, 2, 6, 5])



Measured memory_bytes: 43372
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty ;; $n:expr) => {
        (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
    };
}

fn main() {
    let c: &str = &get!(String);
    let r = if ["a", "e", "i", "o", "u"].contains(&c) {
        "vowel"
    } else {
        "consonant"
    };
    println!("{}", r)
}

Measured memory_bytes: 4352
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_D main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif


int main_D() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N; cin >> N;
    vl A(N), B(N); REP(i, N) cin >> A[i] >> B[i];

    vector<pll> c;
    REP(i, N) c.push_back(pll(B[i], A[i]));
    sort(c.begin(), c.end());

    ll t = 0;
    bool ok = true;
    REP(i,N) {
        t += c[i].second;
        if (t > c[i].first){
            ok = false;
            break;
        }
    }

    string ans = ok ? "Yes" : "No";
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 9584
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

x, n = map(int, input().split())
p = list( map(int, input().split()))


for i in range(x,102):
    if i not in p:
        ans = i
        break

for i in reversed(range(-1,x)):
    if i not in p:
        if ans-x>=x-i:
            ans = i
        break
print(ans)


Measured memory_bytes: 61736
N = int(input())
count = [0, 0, 0, 0, 0]
pattern = [[0, 1, 2], [0, 1, 3], [0, 1, 4], [0, 2, 3], [0, 2, 4], [0, 3, 4], [1, 2, 3], [1, 2, 4], [1, 3, 4], [2, 3, 4]]
for i in range(N):
    s = input()
    if (s[0] == 'M'):
        count[0] += 1
    if (s[0] == 'A'):
        count[1] += 1
    if (s[0] == 'R'):
        count[2] += 1
    if (s[0] == 'C'):
        count[3] += 1
    if (s[0] == 'H'):
        count[4] += 1

s = 0
for pat in pattern:
    temp = count[pat[0]] * count[pat[1]] * count[pat[2]]
    s += temp
print(s)


Measured memory_bytes: 3064
#include <stdio.h>

int main(void)
{
	int sum;
	int n, m;
	int map[1000];
	int i;
	int dice[1000];
	
	while (1){
		scanf("%d %d", &n, &m);
		if (!n && !m){
			break;
		}
		
		for (i = 0; i < n; i++){
			scanf("%d", &map[i]);
		}
		
		for (i = 0; i < m; i++){
			scanf("%d", &dice[i]);
		}
		
		for (i = 0, sum = 1; i < m; i++){
			sum += dice[i];
			if (sum >= n){
				printf("%d\n", i + 1);
				break;
			}
			sum += map[sum - 1];
			if (sum >= n){
				printf("%d\n", i + 1);
				break;
			}
		}
	}
	
	return (0);
}

Measured memory_bytes: 608
using System;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var A = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var subordinate = new int[N];
            foreach (int n in A) subordinate[n - 1]++;
            foreach (int n in subordinate) Console.WriteLine(n);
        }
    }
}


Measured memory_bytes: 42660
#include<bits/stdc++.h>
#define IO ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define ff first
#define ss second
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 5;
const int mod = 1e9 + 7;
const ll INF = 1e18 + 5;
int get_jj(int i, int j){
    int x = (i / 2) - 3;
    return j - x;
}
int main() {
    IO;
    int n;
    cin >> n;
    vector<ll> a(n);
    for(ll &x: a)
        cin >> x;
    // dp[i][j][k] -> maximum sum when chose j elements from first i elements, and no two elements are adjacent
    //                  k says, if last element was taken or not
    vector<vector<vector<ll> > > dp(n, vector<vector<ll> >(5, vector<ll>(2, -INF)));;
    dp[0][get_jj(0, 0)][0] = 0;
    dp[0][get_jj(0, 1)][1] = a[0];
    for(int i = 0; i < n - 1; i++){
        for(int j = (i / 2) - 3; j <= (i / 2) + 1 && j <= (i + 1); j++){
            if(j < 0) continue;

            for(int k = 0; k < 2; k++) {
                if (dp[i][get_jj(i, j)][k] == -INF) continue;
                if (k == 1) {
                    if(get_jj(i + 1, j) >= 0 && get_jj(i + 1, j) < 5)
                        dp[i + 1][get_jj(i + 1, j)][1 - k] = max(dp[i + 1][get_jj(i + 1, j)][1 - k], dp[i][get_jj(i, j)][k]);
//                    cout << i << ' ' << j << ' ' << k << " -> " << i + 1 << ' ' << j << ' ' << 1 - k << '\n';
                }
                else{
                    if(get_jj(i + 1, j + 1) >= 0 && get_jj(i + 1, j + 1) < 5)
                        dp[i + 1][get_jj(i + 1, j + 1)][1 - k] = max(dp[i + 1][get_jj(i + 1, j + 1)][1 - k], dp[i][get_jj(i, j)][k] + a[i + 1]);
                    if(get_jj(i + 1, j) >= 0 && get_jj(i + 1, j) < 5)
                        dp[i + 1][get_jj(i + 1, j)][k] = max(dp[i + 1][get_jj(i + 1, j)][k], dp[i][get_jj(i, j)][k]);

//                    cout << i << ' ' << j << ' ' << k << " -> " << i + 1 << ' ' << j + 1 << ' ' << 1 - k << " And " << i + 1 << ' ' << j << ' ' << k << '\n';
                }
            }
        }
    }

//    int x = 0;
//    jj = (n - 1) / 2 - 1;
//    x += (n / 2) - jj;
    cout << max(dp[n - 1][get_jj(n - 1, n / 2)][0], dp[n - 1][get_jj(n - 1, n / 2)][1]) << '\n';
    return 0;
}


Measured memory_bytes: 65772
# This file is a "Hello, world!" in Python language by CPython for wandbox.
import sys

s = input()
if s != s[::-1]:
    print("No")
    sys.exit()
index = (int)(len(s) - 1) // 2
s1 = s[0:index]
if s1 != s1[::-1]:
    print("No")
    sys.exit()
index1 = (len(s)+3) // 2
s2 = s[index1:-1]
if s2 != s2[::-1]:
    print("No")
    sys.exit()
print("Yes")

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

int main(){
    int N; cin >> N;
    
    map<int, int> A;
    map<int, int> B;
    for(int i=1; i<=N; i++){
    int a; cin >> a;
    A[i] = a;
    }
    for(auto p : A){
        auto key = p.first;
        auto value = p.second;
        
        B[value] = key;
    }
    for(int i = 1; i<=N ; i++){
        cout << B.at(i);
        if(i!=N){
            cout << " ";
        }
        else{
            cout << endl;
        }
    }
}


Measured memory_bytes: 10240
#include <bits/stdc++.h>
using namespace std;
using lli = int_fast64_t;
using ulli = uint_fast64_t;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugst(x) auto xt = x;cerr << #x << " : {";for(int i=0;i<x.size();i++){ cerr << xt.top() << ", ";xt.pop();}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl

const lli MOD = 1000000007;
const lli LIMIT = 1000000000000000000 * 5;
const int tenfive = 100000;

//size持ちUnionFind
struct UnionFind
{
	vector<int> par, sizes;

	UnionFind(int n) : par(n), sizes(n, -1) {
		for (int i = 0; i < n; i++)
			par[i] = i;
	}

	// データxが属する木の根を得る
	int find(int x) {
		if (x == par[x]) return x;
		return par[x] = find(par[x]);
	}

	// 2つのデータx, yが属する木をマージする
	void unite(int x, int y) {
		x = find(x);
		y = find(y);

		if (x == y) return;

		if (sizes[x] < sizes[y]) swap(x, y);

		par[y] = x;
		sizes[x] += sizes[y];
	}

	// 2つのデータx, yが属する木が同じならtrueを返す
	bool same(int x, int y) {
		return find(x) == find(y);
	}

	// データxが含まれる木の大きさを返す
	int size(int x) {
		return sizes[find(x)];
	}
};

int main() {
	int N, M;
	cin >> N >> M;
	UnionFind uf(N);
	for (int i = 0; i < M; i++) {
		int l, r, z;
		cin >> l >> r >> z;
		uf.unite(l-1, r-1);
	}
	int count = 0;
	for (int i = 0; i < N; i++) {
		if (uf.par[i] == i)count++;
	}
	cout << count << endl;
	return 0;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>				//edit by thidailoc
using namespace std;				//team three wolves
typedef long long ll;
typedef vector<ll> vi;
#define fu(i,a,b)   for(ll i=a;i<b;i++)
#define fd(i,b,a)   for(ll i=b;i>=a;i--)
#define pb(i)	    push_back(i)
#define popb()    	pop_back()
#define sc(a) 	    cin>>a
#define sc2(a,b)    cin>>a>>b
#define pr(a)	    cout<<a<<" "
#define pr2(a,b)    cout<<a<<" "<<b<<" "
#define lowb(a,n,x) lower_bound(a,a+n,x) -a
#define lowb2(a,x)	lower_bound(a.begin(),a.end(),x) -a.begin()
#define all(x) 		(x).begin(), (x).end()
#define sz(a) 		(ll)a.size()
#define le			length()						
#define re 			return 	
#define debug(x)    cerr << #x << " = " << x << endl
#define INPUT       freopen("locin.txt", "r", stdin)
#define OUTPUT      freopen("locout.txt", "w", stdout)

double const eps = 1e-8;	//dung trong sai so
ll const Base=1e9+7;

ll Solves(){
	//INPUT;
	//OUTPUT;
	ll n,k,a,b,flag,ans=0;
	// PROCESSING IN HERE
	sc(n); sc2(a,b);
	if(a>b)re pr(0),0;
	
	pr(max(0LL,(b-a)*(n-2)+1));
	re 0;
}


int main(){

	ios_base::sync_with_stdio(0);	
	cin.tie(0);
	cout.tie(0);

	Solves();
}

Measured memory_bytes: 256
import numpy as np

ABK=np.array(input().split(),dtype=np.int64)

A=ABK[0]
B=ABK[1]
K=ABK[2]

if(A>=K):
    A=A-K
else:
    if(B>=K-A):
        B=B-(K-A)
    else:
        B=0
    A=0

print("{} {}".format(A,B))

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

int main() {
  long long N, A, B, C, D, E;
  cin >> N >> A >> B >> C >> D >> E;
  long long min = A;
  if (B < min) {
    min = B;
  }
  if (C < min) {
    min = C;
  }
  if (D < min) {
    min = D;
  }
  if (E < min) {
    min = E;
  }
  long long total_min = 5 + (N / min - 1);
  if (N % min != 0) {
    total_min++;
  }
  cout << total_min << endl;
  return 0;
}

Measured memory_bytes: 888
// *3 or /2

#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <ios>
#include <iomanip>
#include <string>
#include <numeric>

using namespace std;

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

    if (d == 0) {
        if (n == 100) {
            cout << 101 << endl;
        } else {
            cout << n << endl;
        }
    } else if (d == 1) {
        if (n == 100) {
            cout << 10100 << endl;
        } else {
            cout << 100 * n << endl;
        }
    } else {
        if (n == 100) {
            cout << 1010000 << endl;
        } else {
            cout << 10000 * n << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define ld long double
#define pb push_back
#define pf push_front
#define dll deque<ll>
#define vll vector<ll>
#define pll pair<ll,ll>
#define mapll map<ll,ll>
#define endl "\n"
#define all(v) v.begin(),v.end()
#define deb(x) cout<<x
using namespace std;
void swap(auto*,auto*);
ld dist(ll x1,ll y1,ll x2,ll y2)
{
	return (ld)sqrt((ll)pow(x1-x2,2)+(ll)pow(y1-y2,2));
}
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll n; cin>>n;
    ll c=0; char ch[n]; for(ll i=0;i<n;i++) {cin>>ch[i]; if(ch[i]=='R') c++;} ll count=0;
    for(ll i=0;i<c;i++) if(ch[i]!='R') count++;
    	cout<<count<<endl;
}
void swap(auto &a,auto &b)
{
    auto temp=a; a=b; b=temp;
}

Measured memory_bytes: 3804
#include<bits/stdc++.h>
using namespace std;
int main(){
  int i;char c;
  for(i=0;i<4;i++){
    cin>>c;
    cout << c;
  }
  cout <<' ';
  for(i=0;i<8;i++){
    cin>>c;
    cout << c;
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 384
x = int(input())

def q(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

l = 6
ans = 0
while l > 1:
    b = q(x)
    x += 1
    l = len(b)
print(x - 1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ll N;
    cin >> N;
    vector<ll> vec(N);
    rep(i,N){
        cin >> vec[i];
    }
    ll all_sum = 0;
    ll sub_sum = 0;
    rep(i,N){
        all_sum += vec[i];
    }
    ll ans = 10000000000000000;
    for(ll i = 0; i < N - 1; i++){
        sub_sum += vec[i];
        ans = min(ans, max(all_sum - 2 * sub_sum, 2 * sub_sum - all_sum));
    }
    cout << ans << endl;
}



Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ts cout<<"ok"<<endl
#define ll long long
#define hh puts("")
#define pc putchar
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
//char buf[1<<21],*p1=buf,*p2=buf;
using namespace std;
const int N=100005;
int n,q,m,head[N],cnt,rt[N],bz[N][20],dep[N],f[N],dis[N];
struct Edge{
	int v,nx,col,s;
}e[N<<1];
struct node{
	int gs,sum,ls,rs;
}tr[N*100];
inline int read(){
    int ret=0,ff=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-') ff=-1;ch=getchar();}
    while(isdigit(ch)){ret=ret*10+(ch^48);ch=getchar();}
    return ret*ff;
}
void write(int x){if(x<0){x=-x,pc('-');}if(x>9) write(x/10);pc(x%10+48);}
void writeln(int x){write(x),hh;}
void writesp(int x){write(x),pc(' ');}
//Á½¸ö¶¯Ì¬¿ªµãÏß¶ÎÊ÷,Î¬»¤¸öÊýºÍÈ¨Öµ 
void add(int x,int y,int col,int s){
	e[++cnt].v=y;
	e[cnt].col=col;
	e[cnt].s=s;
	e[cnt].nx=head[x];
	head[x]=cnt;
}
void build(int &now,int l,int r){
	now=++cnt;
	if(l==r) return;
	int mid=(l+r)>>1;
	build(tr[now].ls,l,mid);
	build(tr[now].rs,mid+1,r);
}
int update(int now,int pre,int l,int r,int x,int s){
	if(!now) now=++cnt;
	if(l==r){
		tr[now].gs=tr[pre].gs+1;
		tr[now].sum=tr[pre].sum+s;
		return now;
	}
	int mid=(l+r)>>1;
	if(x<=mid){
		tr[now].rs=tr[pre].rs;
		tr[now].ls=update(tr[now].ls,tr[pre].ls,l,mid,x,s);
	}
	else{
		tr[now].ls=tr[pre].ls;
		tr[now].rs=update(tr[now].rs,tr[pre].rs,mid+1,r,x,s);
	}
	return now;
}
void dfs(int now,int fa){
	f[now]=fa;bz[now][0]=fa;
	dep[now]=dep[fa]+1;
	for(int i=head[now];i;i=e[i].nx){
		int v=e[i].v;
		if(v==fa) continue;
		rt[v]=update(rt[v],rt[now],1,n,e[i].col,e[i].s);
		dis[v]=dis[now]+e[i].s;
		dfs(v,now);
	}
}
void init(){
	for(int k=1;k<=17;k++)
		for(int i=1;i<=n;i++)
			bz[i][k]=bz[bz[i][k-1]][k-1];
}
int LCA(int x,int y){
	if(dep[x]<dep[y]) swap(x,y);
	for(int i=17;i>=0;i--)
		if(dep[bz[x][i]]>=dep[y])
			x=bz[x][i];
	if(x==y) return x;
	for(int i=17;i>=0;i--)
		if(bz[x][i]!=bz[y][i])
			x=bz[x][i],y=bz[y][i];
	return bz[x][0];
}
node query(int now,int l,int r,int x){
	if(l==r) return tr[now];
	int mid=(l+r)>>1;
	if(x<=mid) return query(tr[now].ls,l,mid,x);
	else return query(tr[now].rs,mid+1,r,x);
}
signed main(){
	n=read(),q=read();
	for(int i=1;i<n;i++){
		int x=read(),y=read(),col=read(),s=read();
		add(x,y,col,s);
		add(y,x,col,s);
	}
	cnt=0;
	build(rt[1],1,n);
	dfs(1,0);
	init();
	while(q--){
		int col=read(),s=read(),x=read(),y=read();
		int lca=LCA(x,y);
		int len=dis[x]+dis[y]-2*dis[lca];
		node X=query(rt[x],1,n,col),Y=query(rt[y],1,n,col),Z=query(rt[lca],1,n,col);
		writeln(len-(X.sum+Y.sum-2*Z.sum)+(X.gs+Y.gs-2*Z.gs)*s);
	}
	return 0;
}

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

const char nl = '\n';

void solve()
{
    vector<char> v(128, 0);
    for (int i = 0; i < 26; ++i) {
        v['a' + i] = char('a' + i);
    }
    ll n; cin >> n;
    stack<char> s;
    while (n) {
        if (n == 1) {
            s.push('a');
        } else {
            if (n % 26 == 0) {
                s.push('z');
                --n;
            }
            else s.push(v['a' + n % 26 - 1]);
        }
        n /= 26;
    }
    while (!s.empty()) {
        cout << s.top();
        s.pop();
    }
    cout << nl;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    solve();
    return 0;
}

Measured memory_bytes: 3656