akhauriyash/Code-Regression huggingface dataset:
//#pragma warning(disable:4996)
//#pragma comment(linker, "/STACK:336777216")
//#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
#define int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <db, db> pdd;
typedef vector<int> vi;
typedef vector<vector<int> > matrix;

#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))

#define fi first
#define se second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>

inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}
const double EPS = 1e-9;
const ll MOD =998244353;
const ll hell=1000000007;
const int INF = 1e17;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
template<typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
std::mt19937 rng(seed);

double startTime;
double getCurrentTime() {
    return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}
const int dx[] = { -1, 0, 1, 0 };
const int dy[] = { 0, 1, 0, -1 };

const int N=200005;

void solve()
{

    int n,k;
    cin>>n>>k;
    int ans=0,z;
    for(int i=k;i<=n+1;i++)
    {
        z=(i*(n-i+1))%hell;
        z=(z+1)%hell;
       // cout<<z<<endl;
        ans=(ans+z)%hell;
    }
   // ans=(ans+1)%hell;
    cout<<ans<<endl;
}


int32_t main()
{
    IOS;
    int t;
    t=1;
    // cin>>t;
    while(t--)
    {
        
        solve();
    }
    return 0;
}


Measured memory_bytes: 3656
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;

/*
AC
同時にとるなら、帰りにとる
*/

ll n,x,a[200010],dp[200010];
unsigned long long ans=1e18;

int main(void){
	dp[0]=0;
	cin>>n>>x;
	reg(i,1,n){
		cin>>a[i];
		dp[i]=a[i]+dp[i-1];
	}
	reg(i,1,n){//ゴミを捨てる回数＝往復回数
		unsigned long long sum=n*x+i*x;
		//なるべく均等になるように分配
		rep(j,n+2){
			if(n-j*i<=0)break;
			sum+=(dp[n-j*i]-dp[max(n-(j+1)*i,(ll)0)])*max(5,(j+1)*2+1);
		}
		ans=min(ans,sum);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <vector>
#include <unordered_map>

int main(void) {
    int N, K, buf;
    std::unordered_map<int, int> m;
    std::vector<int> v;

    std::cin >> N >> K;

    for(int i = 0; i < N; i++) {
        std::cin >> buf;
        m[buf]++;
    }

    v.reserve(N);
    for(auto i : m)
        v.push_back(i.second);

    m.clear();
    
    std::sort(v.begin(), v.end());

    int need_to_rewrite = v.size() - K;

    int ans = 0;
    for(auto i : v) {
        if(need_to_rewrite-- <= 0)
            break;
        ans += i;
    }

    std::cout << ans << std::endl;

    return 0;
}


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

int main(){
    int n;
    cin >> n;
    int hour, minute, second;
    hour = n / 3600;
    n %= 3600;
    minute = n / 60;
    second = n % 60;
    cout << hour << ":" << minute << ":" << second << endl;
}

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

using namespace std;

int main() {
    int N, K;
    string str;

    cin >> N >> K;
    cin >> str;

    int num_of_happiness = 0;
    char last_char;

    for (int i = 0; i<N; i++) {
        if (i == 0) {
            last_char = str[i];
        } else {
            if (last_char == str[i]) {
                num_of_happiness += 1;
            } 
            last_char = str[i];
        }
    }

    int res = num_of_happiness + 2 * K;
    if ((N-1) < res) {
        res = N-1;
    } 

    cout << res;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
 
int main(void)
{
	double a, b;
	cin >> a >> b;
	if (a > b) {
		cout << "GREATER" << endl;
	}
	else if (a < b) {
		cout << "LESS" << endl;
	}
	else {
		cout << "EQUAL" << endl;
 
	}
 
	return (0);
}

Measured memory_bytes: 256
n, x = gets.split.map(&:to_i)
# n, x = 2, 8

# require 'tapp'
# [n, x].tapp
@memo = {}
@memo[0] = [1, 1]
def trav(level, rest)
  # [level, rest].tapp
  if @memo[level] && @memo[level][0] <= rest
    return @memo[level]
  end

  eaten_total = 0
  forward_total = 0

  forward_total += 1
  rest -= 1
  if rest == 0
    return [forward_total, eaten_total]
  end

  forward, eaten = trav(level - 1, rest)
  forward_total += forward
  rest -= forward
  eaten_total += eaten
  if rest == 0
    return [forward_total, eaten_total]
  end

  forward_total += 1
  rest -= 1
  eaten_total += 1
  if rest == 0
    return [forward_total, eaten_total]
  end

  forward, eaten = trav(level - 1, rest)
  forward_total += forward
  rest -= forward
  eaten_total += eaten
  if rest == 0
    return [forward_total, eaten_total]
  end

  forward_total += 1
  rest -= 1

  @memo[level] = [forward_total, eaten_total]

  return [forward_total, eaten_total]
end

# n = 2
# x = 7
forward, eaten = trav(n, x)
puts eaten


Measured memory_bytes: 3836
#include<bits/stdc++.h>
#define endl enjoy_codeforces
void debug_impl(){std::cerr<<'\n';}
template<class Head,class...Tail>void debug_impl(Head head, Tail... tail){std::cerr << " " << head;debug_impl(tail...);}
    template<class Container,class Value=typename Container::value_type,std::enable_if_t<!std::is_same<Container,std::string>::value,std::nullptr_t> = nullptr>
std::ostream&operator<<(std::ostream&os,Container const&v)
{os<<"{";for(auto it=v.begin();it!=v.end();it++){os<<(it!=v.begin()?",":"")<<*it;}return os<<"}";}
    template<template<class...>class Tuple,class...Args,std::size_t...Inds,std::size_t=std::tuple_size<Tuple<Args...>>::value>
std::ostream&tuple_output_impl(std::ostream&os,const Tuple<Args...>&tuple,std::integer_sequence<std::size_t,Inds...>)
{os<<"(";(void)std::initializer_list<int>{((void)(os<<(Inds>0?",":"")<<std::get<Inds>(tuple)),0)...};return os<<")";}
    template<template<class...>class Tuple,class...Args,std::size_t=std::tuple_size<Tuple<Args...>>::value>
std::ostream&operator<<(std::ostream&os,const Tuple<Args...>&tuple)
{return tuple_output_impl(os,tuple,std::index_sequence_for<Args...>());}
#define DEBUG 1
#if DEBUG
#define debug(...)do{std::cerr<<std::boolalpha<<"["<<#__VA_ARGS__<<"]:";debug_impl(__VA_ARGS__);std::cerr<<std::noboolalpha;}while(false)
#else
#define debug(...) {}
#endif
int main(){
    std::vector<int>a(4);
    for(int&x:a){
        char c;std::cin>>c;
        x=c-'0';
    }
    for(int i=0;i<8;i++){
        int x=a.at(0);
        for(int j=0;j<3;j++){
            if(i>>j&1)x+=a.at(j+1);
            else x-=a.at(j+1);
        }
        if(x==7){
            std::cout<<a.at(0);
            for(int j=0;j<3;j++){
                std::cout<<(i>>j&1?'+':'-')<<a.at(j+1);
            }
            std::cout<<"=7";
            std::cout<<'\n';
            return 0;
        }
    }
}



Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define RREP(i,a,b) for (int i = a; i > (b); --i)
#define all(x) (x).begin(),(x).end()
#define YY cout << "Yes" << endl
#define NN cout << "No" << endl
const int INF = 1000000007;
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
int solve(){
  int n;
  cin>>n;
  map<string,int>m;
  rep(i,n){
    string tmp;
    cin>>tmp;
    m[tmp]++;
  }
  int mm = 0;
  for(auto i : m){
    mm = max(i.second,mm);
  }
  for(auto i : m){
    if(i.second == mm)cout<<i.first<<endl;
  }
  return 0;
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  // cout << fixed;cout << setprecision(16);
  solve();
  return 0;
}

Measured memory_bytes: 25216
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define ALL(a) (a).begin(), (a).end()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const double EPS = 1e-9;

int main() {
  int n; cin >> n;
  set<int> s;
  int tmp;
  rep(i,n) { cin >> tmp; s.insert(tmp); }
  int ans = s.size();
  if (ans%2 == 0) --ans;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4992
#include<iostream>

using namespace std;

int binary_search(int a[], int b[], int n, int q) {
	int left, right;
	int mid, count = 0;
	for (int i = 0; i < q; ++i) {
		left = 0;
		right = n;
		while (left < right) {
			mid = (left + right) / 2;
			if (a[mid] == b[i]) {
				++count;
				break;
			}
			else if (b[i] < a[mid]) right = mid;
			else left = mid + 1;
		}
	}
	return count;
}

int main() {
	int n, q, S[100000], T[50000];
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> S[i];
	}
	cin >> q;
	for (int i = 0; i < q; ++i) {
		cin >> T[i];
	}
	cout << binary_search(S,T,n,q) << endl;
	return 0;
}

Measured memory_bytes: 1744
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;
#define ll int64_t
const long mod = 1e9 + 7;


const long LINF = 1e13;
const long LLINF = 1e18;
const long ALPHABET = 26;

template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x; //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいい
  return is;
}


//最大公約数
int gcd( int m, int n ){
  // 引数に０がある場合は０を返す
  if ( ( 0 == m ) || ( 0 == n ) )
    return 0;
  // ユークリッドの方法
  while( m != n ){
    if ( m > n ) m = m - n;
    else         n = n - m;
  }
  return m;
}//gcd


//最小公倍数
int lcm( int m, int n ){  // 引数に０がある場合は０を返す
  if ( ( 0 == m ) || ( 0 == n ) )
    return 0;
  return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm




int main() {

  long a,b,k;

  cin >> a >>b >> k;

  long ans = 0;
  long count = 0;
  vector<long> stock;
 
  for (int i = 1; i <= max(a,b); ++i){
      if (a%i ==0 && b%i ==0){
        count++;
        stock.push_back(i);
      }

  }

  ans = stock[stock.size()-k ];


  cout << ans;



}




















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

int main() {
  ll A, B, C, K; cin >> A >> B >> C >> K;
  ll ans = (K % 2) ? B - A : A - B;
  cout << ( (ans > 1e18) ? "Unfair" : to_string(ans) ) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<string>
#include<map>
#include<vector>
#include<queue>


using namespace std;

const int N = 1000 + 5;

int main(){

    int n;
    cin >> n;
    int ans = 0, tmp = n;
    while(n > 0){
        ans += n % 10;
        n /= 10;
    }
    cout << (tmp % ans == 0?"Yes":"No") << endl;
}


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

int main() {
  int64_t A,B,N;
  cin>>A>>B>>N;
  int64_t answer;
  if(N<B)
    answer=(A*N)/B-A*(N/B);
  else
    answer=(A*(B-1))/B;
  cout<<answer;
}

Measured memory_bytes: 3624
import sys

cards_num = int(sys.stdin.readline())
cards =[ card[:-1] for card in sys.stdin.readlines() ]

all_cards = [ i + ' ' + str(j) for i in 'SHCD' for j in range(1,14) ]

missing_cards = [i for i in all_cards if not(i in cards) ]

for s in missing_cards:
    print(s)


Measured memory_bytes: 5604
#include <iostream>
#include <string.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <functional>
#include <cassert>
#include <utility>
#include <stack>
#include <queue>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
typedef long long ll;
typedef pair<int,int> Pii;
const int INF=(1<<30)-1;
const int MAX=310;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}
int main(){
	int n;
	cin>>n;
	ll a[n];
	REP(i,n){
		cin>>a[i];
	}
	ll min=2,max=2;
	for(int i=n-1;i>=0;i--){
		if(max<a[i]){
			cout<<"-1"<<endl;
			return 0;
		}
		
		ll maxt=(max/a[i])*a[i];
		ll mint=((min+a[i]-1)/a[i])*a[i];
		if(maxt<mint){
			cout<<"-1"<<endl;
			return 0;
		}
		max=maxt+a[i]-1;
		min=mint;
	}
	cout<<min<<" "<<max<<endl;
	return 0;
}
	

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)

const ll MOD = 10007;
const ll HIGHINF = (ll)1e18;

int main() {
  ll n; cin >> n;
  ll ans = 0;
  REP(i, n) {
    ll j = 2;
    ll a; cin >> a;
    bool is_prime = true;
    while (j*j<=a) {
      if (a % j == 0) {is_prime = false; break;}
      j++;
    }
    if (is_prime) ans++;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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

  int n;
  cin >> n;
  int a[n];
  rep(i,n) cin >> a[i];
  sort(a,a+n);
  deque<int> de;
  int e=n-1;
  int s=0;

  de.pb(a[e]); e--;
  while(1){
    if(s>e) break;
    de.pb(a[s]); s++;
    if(s>e) break;
    de.push_front(a[s]); s++;
    if(s>e) break;
    de.pb(a[e]); e--;
    if(s>e) break;
    de.push_front(a[e]); e--;
    if(s>e) break;
  }
  
  ll ans=0;
  rep(i,n-1){
    //    cout << de[i] << " ";
    ans+=abs(de[i]-de[i+1]);
    //    cout << ans << endl;
  }
  //  cout << ans << endl;
  ll ans2=0;
  deque<int> de2;
  int e2=n-1;
  int s2=0;
  de2.pb(a[s2]);s2++;
  while(1){
    if(s2>e2) break;
    de2.pb(a[e2]); e2--;
    if(s2>e2) break;
    de2.push_front(a[e2]); e2--;
    if(s2>e2) break;
    de2.pb(a[s2]); s2++;
    if(s2>e2) break;
    de2.push_front(a[s2]); s2++;
    if(s2>e2) break;
  }
  
  rep(i,n-1){
    ans2+=abs(de2[i]-de2[i+1]);
  }
  cout << max(ans, ans2) << endl;
  return 0;
    

}


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


int main() {
    int a,b;
    cin >>a>>b;
    int c =b-a;
    int sum =0;
    for(int i=1;i<c;i++){
        sum +=i;
    }
    cout << sum - a <<endl;
}

Measured memory_bytes: 256
let fs = require('fs');

const fuga = data => {
  lines = data.split("\n");
  lines = lines.map(line => line.split(" "));
  lines = lines.map(line => line.map(elem => parseInt(elem)));

  for(let i = 0; i < lines.length; i++) {
    let str = "";
    if(!lines[i][0]) return;
    for(let j = 0; j < lines[i][0]; j++) {
      for(let k = 0; k < lines[i][1]; k++) {
        str += "#";
      }
      console.log(str);
      str = "";
    }
    console.log("");
  }
}

const readFile = route => {
  fs.readFile(route, 'utf8', (err, data) => {
    fuga(data);
  });
}

const readFileWithoutArg = () => {
  const data = require('fs').readFileSync('/dev/stdin', 'utf8');
  fuga(data)
}

let sampleInputPath = "";

if(process.argv.length > 2) {
  sampleInputPath = process.argv[2];
  readFile(sampleInputPath);
} else {
  readFileWithoutArg();
}



Measured memory_bytes: 18776
N,M= map(int,input().split())
s=[]
c=[]
ans=-1
for i in range(M):
    s_i,c_i=input().split()
    s.append(int(s_i))
    c.append(c_i)
if N==1:
    for i in range(10):
        ans_bool=True
        for j in range(M):
            ans_bool=ans_bool and str(i)[s[j]-1]==str(c[j])
        if ans_bool:
            ans=i
            break
else:
    for i in range(int("1"+"0"*(N-1)),int("9"*N)+1):
        ans_bool=True
        for j in range(M):
            ans_bool=ans_bool and str(i)[s[j]-1]==str(c[j])
        if ans_bool:
            ans=i
            break
        
print(ans)

Measured memory_bytes: 3064
# https://atcoder.jp/contests/abc114/submissions/6262572

from itertools import product
N = int(input())
ans = 0
for i in range(3,10):
    for s in product(["3","5","7"],repeat=i):
        if int("".join(s)) <= N and "3" in s and "5" in s and "7" in s:
            ans += 1
print(ans)


Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<queue>
#include<cmath>
#include <numeric>
#include<iomanip>
#include <cstdint>

using namespace std;

int counter(int x) {
	if (x == 0) {
		return 0;
	}
	else {
		return counter(x >> 1) + (x & 1);
	}
}

int main() {
	int n;
	cin >> n;
	vector<int>a(n);
	vector<vector<pair<int, int>>>v(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		for (int j = 1; j <= a[i]; j++) {
			int x, y;
			cin >> x >> y;
			x--;
			v[i].emplace_back(x, y);
			//cout << v[i][0].first << endl;
		}
	}
	int ans = 0;
	for (int bits = 0; bits < (1 << n); bits++) {
		bool ok = true;
		for (int i = 0; i < n; i++) {
			if (!(bits & (1 << i))) {
				continue;
			}
			else {
				for (int j = 0; j < a[i]; j++) {
					if (((bits >> v[i][j].first) & 1) ^ v[i][j].second) {
						ok = false;
					}
				}
			}
		}
      				if (ok) {
					ans = max(ans, counter(bits));
				}
	}
	cout << ans << endl;
}


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

using namespace std;

typedef long long int ll;

double ret(ll q) {
	double x = q / 2., th = 0.00001 * q;
	do {
		double next = x / 3 * 2 + q / (3 * x * x);
		x = next;
	} while(abs(pow(x, 3) - q) > th);
	return x;
}

int main() {
	ll x;
	while(cin >> x, x != -1) {
		cout << fixed << setprecision(6) << ret(x) << endl;
	}
	return 0;
}



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

using namespace std;

#define MAX 45
#define NIL -1
int Memo[MAX];

int fibonacci(int n) {
    if (n == 0 || n == 1)
        return Memo[n] = 1;
    if (Memo[n] != NIL)
        return Memo[n];
    return Memo[n] = fibonacci(n - 1) + fibonacci(n - 2);
}

int main() {
    int n;
    scanf("%d", &n);
    fill_n(Memo, MAX, NIL);
    printf("%d\n", fibonacci(n));
}

Measured memory_bytes: 2732
n, m = map(int, input().split())
L = [0] * (int(1e5) + 10)
for i in range(m):
    l, r = map(int, input().split())
    L[l - 1] += 1
    L[r] -= 1

S = [0] * (int(1e5) + 11)
for i in range(len(L)):
    S[i + 1] = S[i] + L[i]

ans = 0
for s in S:
    if s == m : ans += 1

print(ans)

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

alpha = ['z'] + [chr(i) for i in range(ord('a'),ord('z')+1)]
step = 0
result = ''
while(True):
    t = n % 26
    result = alpha[t] + result
    if n <=26:
        break
    n //= 26
    if t == 0:
        n -= 1

print(result)


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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<ll,ll>;

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

ll A[100];
vector<P> v;

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

    int N;
    std::cin >> N;

    for(int i=0;i<N;++i){
        std::cin >> A[i];
    }

    int mx = 0;
    for(int i=1;i<N;++i){
        if(abs(A[i]) > abs(A[mx])){
            mx = i;
        }
    }
    
    if(A[mx] == 0){
        std::cout << 0 << std::endl;
        return 0;
    }else{
        for(int i=0;i<N;++i){
            if(i == mx){continue;}

            A[i] += A[mx];
            v.emplace_back(mx, i);
        }

        if(A[mx] > 0){
            for(int i=0;i+1<N;++i){
                if(A[i] > A[i+1]){
                    A[i+1] += A[i];
                    v.emplace_back(i, i+1);
                }
            }
        }else{
            for(int i=N-1;i-1>=0;--i){
                if(A[i-1] > A[i]){
                    A[i-1] += A[i];
                    v.emplace_back(i, i-1);
                }
            }
        }
    }
    
    // for(int j=0;j<N;++j){
    //     std::cout << A[j] << " \n"[j+1==N];
    // }

    assert(v.size() <= 2 * N);

    for(int i=0;i+1<N;++i){
        assert(A[i] <= A[i+1]);
    }
    
    std::cout << v.size() << std::endl;
    for(const auto& p : v){
        ll x, y;
        tie(x, y) = p;

        ++x; ++y;

        std::cout << x << " " << y << std::endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <set>
#include <numeric>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <cstring>
#include <queue>
#include <numeric>
#include <iomanip>
#define ll long long
using namespace std;
const int MAXN = 300005;
ll arr[MAXN],sz[MAXN],parent[MAXN];
multiset<int> group[MAXN];
long long ans = 0;
void init(){
    for(int i=0;i<MAXN;i++){
        sz[i] = 1;
        parent[i] = i;
        group[i].insert(arr[i]);
    }
}
int find(int u){
    return u == parent[u] ? u : parent[u] = find(parent[u]);
}
void mrg2(int u,int v){
    u = find(u) ,  v=find(v);
    if(u == v)return;
    if(group[u].size() == 0 || group[v].size() == 0)return;
    if(group[u].size() > group[v].size()) swap(u,v);
    parent[u] = v;
    sz[v] += sz[u];
    for(auto it:group[u]){
        group[v].insert(it);
    }
    group[u].clear();
}
void mrg(int u,int v){
    u = find(u),v = find(v);
    if(u == v)return;
    if(group[u].size() == 0 || group[v].size() == 0)return;
    if(group[u].size() > group[v].size()) swap(u,v);
    parent[u] = v;
    sz[v] += sz[u];
    ans += (*group[u].begin()  + *group[v].begin());
    group[u].erase(group[u].begin());
    group[v].erase(group[v].begin());
    for(auto it:group[u]){
        group[v].insert(it);
    }
    group[u].clear();
}


int main(){
    ios::sync_with_stdio(false); cin.tie(0);
    int n,m; cin>>n>>m;
    for(int i=1;i<=n;i++){
        cin>>arr[i];
    }
    init();
    for(int i=1;i<=m;i++){
        int u,v; cin>>u>>v;
        u++;
        v++;
        mrg2(u,v);
    }
    
    vector<pair<int,int> > vc;
    int root = 1; int MAX = 0;
    for(int i=1;i<=n;i++){
        if(find(i) == i){
            vc.push_back(make_pair(sz[i],i));
        }
    }
    sort(vc.begin(),vc.end());
    reverse(vc.begin(),vc.end());
    deque<int> dq;
    for(int i=0;i<vc.size();i++){
        dq.push_back(vc[i].second);
    }
    while(dq.size() >= 2){
        int id1 = dq.front(); dq.pop_front();
        int id2 = dq.front(); dq.pop_front();
        mrg(id1,id2);
        dq.push_front(find(id1));
    }
    if(sz[find(1)] != n){
        cout<<"Impossible";
    }
    else cout<<ans;
    

    
    
    return 0;
}


Measured memory_bytes: 35964
route=[]
cost=[]
error=[]

N,T=map(int,input().split())
for i in range(N):
    route.append([int(j) for j in input().split()])

for i in range(len(route)):
    if route[i][1]<=T:
        cost.append(route[i][0])
    if route[i][1]>T:
        error.append(route[i][1])
    

        
if len(error)==N:
    print("TLE")
else:
    print(min(cost))
            
    
    


    
    
    

    
	


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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//String s = sc.next();
		//String t = sc.next();
		//String g = sc.next();
		long n = sc.nextLong();
		//long m = sc.nextLong();
		//long k = sc.nextLong();
		//long l = sc.nextLong();
		long count=0;
		long[] array=new long[3];

		/*for(int i=0;i<=3;i++) {
			if(s.substring(i,i+1).equals("+")) {
				count++;
			}else {
				count--;
			}
		}*/
		Arrays.sort(array);
		if(n==3||n==5||n==7) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
		//System.out.println(n+m/2);
		//System.out.println(Math.abs(array[2]-array[1])+Math.abs(array[1]-array[0]));
	}
}




Measured memory_bytes: 23252
#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 ji -
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
#define fe(x) for(int i=be[x];i;i=e[i].ne)
using namespace std;
int n,xx,yy,et,be[120000],f[120000];
struct edg{
	int y,ne;
};
edg e[210000];
inline void add_edge(int x,int y){
	e[++et].y=y;
	e[et].ne=be[x];
	be[x]=et;
}
void dfs(int x,int fa){
	fe(x){
		int &y=e[i].y;
		if (y!=fa){
			dfs(y,x);
			f[x]^=f[y];
		}
	}
	f[x]++;
}
int main(){
	scanf("%d",&n);
	fo(i,2,n){
		scanf("%d%d",&xx,&yy);
		add_edge(xx,yy);
		add_edge(yy,xx);
	}
	dfs(1,-1);
	if (f[1]>1) printf("Alice\n");else printf("Bob\n");
	return 0;
}

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

using namespace std;
#define ll long long int
#define ull unsigned long long int
#define module 1000000007


int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
   
    int count=1;
    for(int i=1;i<n;i++)
    {
        if(s[i]!=s[i-1]) count++;
    }
    cout<<count<<endl;
    
    return 0;
}

Measured memory_bytes: 512
#include <iostream>

using namespace std;
typedef long long ll;

int main(){
    ll a, b;
    cin >> a >> b;
    if(b < a){
        ll t = b;
        b = a;
        a = t;
    }
    if((a + b) % 2 != 0){
        cout << "IMPOSSIBLE" << endl;
    }else{
        cout << (a + b) / 2 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a;
    while(scanf("%d",&a)!=EOF)
    {
        if(a==25)printf("Christmas\n");
        if(a==24)printf("Christmas Eve\n");
        if(a==23)printf("Christmas Eve Eve\n");
        if(a==22)printf("Christmas Eve Eve Eve\n");
    }
    return 0;
}


Measured memory_bytes: 128
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class Main {
	class Pair {
		int y, x;
		Pair(int y, int x) {
			this.y = y;
			this.x = x;
		}
	}
	void run() {
		Scanner scan = new Scanner(System.in);
		int h = scan.nextInt();
		int w = scan.nextInt();
		int n = scan.nextInt();
		char[][] field = new char[h][];
		int sy = 0, sx = 0;
		for (int i = 0; i < h; i++) {
			field[i] = scan.next().toCharArray();
			for (int j = 0; j < w; j++) {
				if (field[i][j] == 'S') {
					sy = i;
					sx = j;
				}
			}
		}
		
		int[][] ans = new int[h][];
		int life = 1;
		for (int i = 0; i < h; i++)
			ans[i] = new int[w];
		
		Queue<Pair> que = new LinkedList<Pair>();
		que.add(new Pair(sy, sx));
		while (!que.isEmpty()) {
			Pair p = que.poll();
			if (field[p.y][p.x] - '0' == n && life - 1 == n) {
				System.out.println(ans[p.y][p.x]);
				break;
			}
			int[] dy = { 0, 1,  0, -1 };
			int[] dx = { 1, 0, -1,  0 };
			for (int i = 0; i < 4; i++) {
				int ny = p.y + dy[i];
				int nx = p.x + dx[i];
				if (ny < 0 || nx < 0 || ny >= h || nx >= w)
					continue;
				if (ans[ny][nx] != 0)
					continue;
				if (field[ny][nx] == 'X')
					continue;
				int t = ans[p.y][p.x] + 1;
				if (field[ny][nx] - '0' == life) {
					life++;
					ans = new int[h][];
					for (int j = 0; j < h; j++) {
						ans[j] = new int[w];
					}
					que = new LinkedList<Pair>();
					ans[ny][nx] = t;
					que.add(new Pair(ny, nx));
					break;
				} else {
					ans[ny][nx] = t;
					que.add(new Pair(ny, nx));
				}
			}
		}
	}
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 164328
H, W = map(int, input().split())

def check(x):
    if x%2==0:
        return x//2
    return x//2 + 1

even_row = check(W)
odd_row = check(W-1)
cH = check(H)
total_even_row = even_row * cH
total_odd_ror = odd_row * (H - cH)

if W == 1 or H == 1:
    print(1)
else:
    print(total_even_row + total_odd_ror)

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <limits.h>

int cmp(const void* p, const void* q) {
	return *(int*)q - *(int*)p;
}

int main(void) {
	int n, m;
	int d[200000], t[200000];
	int flag = 0, buf = 0;

	scanf("%d", &n);
	for (int i = 0; i < n; i++) scanf("%d", &d[i]);
	scanf("%d", &m);
	for (int i = 0; i < m; i++) scanf("%d", &t[i]);

	qsort(d, n, sizeof(int), cmp);
	qsort(t, m, sizeof(int), cmp);
	for (int i = 0; i < m; i++) {
		for (int j = buf; j < n; j++) {
			if (t[i] == d[j]) {
				buf = j + 1, flag++;
				break;
			}
		}
	}
	//printf("flag=%d\n", flag);
	if (flag == m)printf("YES");
	else printf("NO");
	return 0;
}

Measured memory_bytes: 2556
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <deque>

using namespace std;

int main(int argc, char const *argv[])
{
	int x,a,b;

	cin >> x;
	cin >> a;
	cin >> b;

	int res = x-a;

	while(res-b >= 0)
	{
		res -= b;
	}

	cout << res << "\n";
	

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

const long long inf = (int) 1e18;
const int N = 1005;

int main() {
  int n, w;
  cin >> n >> w;
  int val[n], we[n];
  for (int i = 0; i < n; i++) {
    cin >> we[i] >> val[i];
  }
  long long dp[n][n * N];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n * N; j++) {
      dp[i][j] = inf;
    }
  }
  dp[0][val[0]] = we[0];
  for (int i = 1; i < n; i++) {
    dp[i][val[i]] = min(dp[i][val[i]], 1ll * we[i]);
    for (int j = 0; j < n * N; j++) {
      if (j + val[i] < n * N) {
        dp[i][j + val[i]] = min(dp[i][j + val[i]], dp[i - 1][j] + we[i]);
      }
      dp[i][j] = min(dp[i][j], dp[i - 1][j]);
    }
  }
  int ans = 0;
  for (int i = n * N - 1; i >= 0; i--) {
    if (dp[n - 1][i] <= w) {
      ans = max(ans, i);
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 78720
import Control.Applicative
import Control.Monad
import Control.Monad.ST
-- import qualified Data.ByteString as BS
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
--import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array
--import Data.Array.Unboxed
--import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
import GHC.ST
-- import System.IO.Unsafe
 
-- templete
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
getDoubles = map readDouble . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
tjoin :: (Show a, Show b) => (a, b) -> String
tjoin (x, y) = show x ++ (' ' : show y)
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
coverC :: Ord a => (a, a) -> a -> Bool
coverC (l,r) x = l<=x && x<=r
coverH :: Ord a => (a, a) -> a -> Bool
coverH (l,r) x = l<=x && x<r
ibsearch :: (Int -> Bool) -> (Int,Int) -> Int
ibsearch f (ok,ng) = if abs (ok-ng) <= 1 then ok else let mid = (ok + ng) `div` 2 in ibsearch f (if f mid then (mid,ng) else (ok,mid))
-- templete


main = getInts >>= print . sum
    



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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//List<String> list=new ArrayList<String>(Arrays.asList(s.split("")));
		List<Integer> list=new ArrayList<Integer>();
		//Long[] array = new Long[6];
		int n = sc.nextInt();
		for(int i=0;n>i;i++) {
			int a = sc.nextInt();
			list.add(a);
		}
		int count=0;
		for(int i=0;n>i;i++) {
			int a = list.get(i);
			if(a!=0) {
				count++;
				for(int j=i;n>j;j++) {
					int b = list.get(j);
					if(b==0)
						break;
					else {
						list.set(j, b-1);
					}
				}
				//System.out.println(list);
				i=-1;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 21844
# D - Good Grid

N, C =  map(int, input().split())
D = [list(map(int, input().split())) for _ in range(C)]
c = [list(map(int, input().split())) for _ in range(N)]

group0, group1, group2 = [0]*C, [0]*C, [0]*C
for row in range(N):
    for col in range(N):
        if (row + col) % 3 == 0:
            group0[c[row][col] -1] += 1
        elif (row + col) % 3 == 1:
            group1[c[row][col] -1] += 1
        else:
            group2[c[row][col] -1] += 1

ans = []
for color0 in range(C):
    for color1 in range(C):
        for color2 in range(C):
            if len(set([color0, color1, color2])) == 3:
                tmp = 0
                for idx in range(C):
                    tmp += D[idx][color0] * group0[idx]
                    tmp += D[idx][color1] * group1[idx]
                    tmp += D[idx][color2] * group2[idx]
                ans.append(tmp)

print(min(ans))

Measured memory_bytes: 6604
#template
from collections import Counter
def inputlist(): return [int(i) for i in input().split()]
#template
A,B,M = inputlist()
a = inputlist()
b = inputlist()
ma = sorted(a)[0]
mb = sorted(b)[0]
mc = ma+mb
for i in range(M):
    x,y,c = inputlist()
    x -=1
    y -=1
    mc = min(mc,a[x]+b[y]-c)
print(mc)

Measured memory_bytes: 72388
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let (A, B) = read!(i64, i64);

    println!("{}", max(A + A - 1, max(A + B, B + B - 1)))
}


Measured memory_bytes: 4352
import sys

global n, k, T


def cal_v(P):
    j = 0
    for i in range(k):
        con = 0
        while con + T[j] <= P:
            con += T[j]
            j += 1
            if j == n:
                return n
    return j


def cal_ans():
    left = 0
    right = sum(T)
    mid = (right-left) // 2
    while right - left > 1:
        mid = left + (right-left)//2
        if cal_v(mid) >= n:
            right = mid
        else:
            left = mid
    return right

if __name__ == "__main__":
    n, k = map(int, sys.stdin.readline().split())
    T = list(map(int, sys.stdin.readlines()))
    ans = cal_ans()
    print(ans)

Measured memory_bytes: 17652
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cctype>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <numeric>
#include <functional>
#include <cstdlib>
#include <regex>
#include <list>
int main() {
	std::vector<int> a(3);
	for (int i = 0;i < 3;++i) {
		std::cin >> a[i];
	}
	std::sort(a.begin(), a.end());
	for (int i = 0;i < 3;++i) {
		std::cout << a[i] << (i == 2 ? '\n' : ' ');
	}
	return 0;
}


Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int n;
ll ans;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		if(i%3==0||i%5==0)continue;
		ans+=i;
	}
	cout<<ans;
    return 0;
}

Measured memory_bytes: 3572
n,k = map(int,input().split())
a = list(map(int,input().split()))
t = [0]*n
ta = [0]*n
for i in range(n):
    cnt=0
    for j in range(i+1,n):
        if a[i]>a[j]:
            cnt +=1
    t[i]=cnt
for i in range(n):
    cnt=0
    for j in range(n):
        if a[i]>a[j]:
            cnt +=1
    ta[i]=cnt
ans=0
mod = 10**9+7
for i in range(n):
    ans+=t[i]*k%mod
    ans%=mod
    ans+=(ta[i]*k*(k-1)//2)%mod
    ans%=mod
print(int(ans))


Measured memory_bytes: 41964
let s = stdin.ReadLine()
let len = s.Length

let mutable a = Array.init (len + 1) (fun _ -> 0)
let mutable b = Array.init (len + 1) (fun _ -> 0)

for i in 0..(len - 1) do
 if s.[i] = '<' then a.[i+1] <- (a.[i] + 1) else ()

for i in 0..(len - 1) do
 if s.[(len - 1 )- i] = '>' then b.[i+1] <- (b.[i] + 1) else ()

let m = [for i in 0..len do yield max a.[i] b.[len - i]]

let sum64 a b = a + (int64 b)

m
|>List.fold sum64 0L
|>stdout.WriteLine

Measured memory_bytes: 39124
#include <bits/stdc++.h>
#include <iostream>
#include <functional>
#include <vector>
#include <stdio.h>
#include <queue>
#include <string.h>
#include <math.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define rep1(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=a;i>=n;i--)
#define per1(i,a,n) for (int i=a;i>n;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define endl "\n"
#define pi 3.14159265358979323846264338327950288419716939937510
#define IOS cin.sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll mod=1000000007;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
ll qpow(ll a,ll b){ll s=1;while(b>0){if(b%2==1){s=s*a;}a=a*a;b=b>>1;}return s;}
ll qpowmod(ll a, ll b, ll c){ll res, t;res=1;t=a%c;while(b){if(b & 1){res=res*t%c;}t=t*t%c;b>>=1;}return res;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline long long read(){long long k=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){k=k*10+ch-'0';ch=getchar();}return k*f;}
inline void write(long long x){if(x<0)x=-x,putchar('-');if(x>9)write(x/10);putchar(x%10+'0');}
// head
ll n,m,ans;
int main()
{
    //IOS;
    cin>>n>>m;
    if(n>=2)
    {
        ans+=(n*(n-1)/2);
    }
    if(m>=2)
    {
        ans+=(m*(m-1)/2);
    }
    cout<<ans<<endl;
    return 0;
}
/*

*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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() {
  ll a, b, x;
  cin >> a >> b >> x;

  if (b == 0) {
    cout << 1 << endl;
  } else if (a == 0) {
    cout << b / x + 1 << endl;
  } else {
    cout << b / x - (a - 1) / x << endl;
  }
}

Measured memory_bytes: 256
package main

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

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

func next() string {
	sc.Scan()
	return sc.Text()
}
func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}
func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextInt64() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

//var done []bool = make([]bool, 10)
//var memo []int = make([]int, 10)

var m map[string]int = make(map[string]int)
var mInt map[int]int = make(map[int]int)

func main() {
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!coution!!!! you must use Fprint(out, ) not Print()
	l := nextInt()
	var f float64 = float64(l) / float64(3)

	fmt.Fprint(out, f*f*f)
}


Measured memory_bytes: 640
#include<stdio.h>
int main()
{
   int a,b;
   scanf("%d%d",&a,&b);

   if(1<=a && a<=100 && 1<=b && b<=100){
        if((a+b)%3==0 || a%3==0 || b%3==0) printf("Possible");
        else  printf("Impossible");
   }
    return 0;
}

Measured memory_bytes: 1688
import sys

readline = sys.stdin.buffer.readline


def main():
    N = int(readline())
    A = list(map(int, readline().split()))

    D0 = A[0]
    D1 = sum(A[1:])
    M0 = [None] * (N-1)
    M0[0] = D0 - D1

    for i in range(1, N-1):
        M0[i] = M0[i-1] + 2 * A[i]

    M0 = list(map(lambda x: abs(x), M0))
    print(min(M0))


main()


Measured memory_bytes: 24884
K,A,B=list(map(int,input().split()))

if A-1>=K:
    print(K+1)
else:
    if B-A<=2:
        print(K+1)
    else:
        if (K-A+1)%2==0:
            print(A+((K-A+1)//2)*(B-A))
        else:
            print(A+1+((K-A+1)//2)*(B-A))

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

int main(){
    ll n;
    cin >> n;
    ll choten = n*n+n*(n-1)*(n-1)/2-n*(n-1)*(2*n-1)/6;
    ll hen = 0;
    rep(i,n-1){
        int u,v;
        cin >> u >> v;
        ll m = min(u,v);
        ll M = max(u,v);
        hen += m*(n+1-M);
    }
    cout << choten - hen << endl;
    return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  vector<int> a(3);
  REP(i, 3) cin >> a[i];
  sort(ALL(a));
  if(a[0] = 5 && a[1] == 5 && a[2] == 7) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

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

int main()
{
    long n, y;
    cin >> n >> y;
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= n; j++) {
            int k = n - i - j;
            long est = 10000 * i + 5000 * j + 1000 * k;
            if (k >= 0 && est == y) {
                cout << i << " " << j << " " << k << endl;
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
using namespace std;

typedef long long ll;

int H, W;
char S[1000][1000];
ll cnt[1000][1000];
bool flags[1000][1000];

bool cond (int h, int w){
	if (h<0 || h>=H || w<0 || w>=W)
		return false;

	if (S[h][w] == '#')
		return false;

	return true;
}

int main () {
	int Ch, Cw, Dh, Dw;
	cin >> H >> W;
	cin >> Ch >> Cw;
	cin >> Dh >> Dw;
	Ch --; Cw --; Dh --; Dw --;
	for (int h=0; h<H; h++) {
		for (int w=0; w<W; w++) {
			cin >> S[h][w];
			cnt[h][w] = -1;
			flags[h][w] = false;
		}
	}
	if (S[Ch][Cw]=='#' || S[Dh][Dw]=='#') {
		cout << -1 << endl;
		return 0;
	}

	priority_queue <
		pair <ll, pair <int, int>>,
		vector <pair <ll, pair <int, int> > >,
		less <pair <ll,  pair <int, int> > > > que;
	cnt[Ch][Cw] = 0;
	que.push ({0, {Ch, Cw}});

	vector< pair <int, int> > v;
	v.push_back ({-1,0});
	v.push_back ({1,0});
	v.push_back ({0,-1});
	v.push_back ({0,1});
	while (!que.empty ()) {
		pair <ll, pair<int, int> > st = que.top ();
		ll cost = st.first;
		pair <int, int> p = st.second;
		que.pop ();

		// cout << -cost << " " << p.first << " " << p.second << endl;
		if (flags[p.first][p.second])
			continue;

		// 移動A
		for (pair <int, int> pv: v) {
			int h = p.first + pv.first;
			int w = p.second + pv.second;
			if (cond (h,w)) {
				if (cnt[h][w]==-1 || cnt[h][w]>cnt[p.first][p.second]) {
					cnt[h][w] = cnt[p.first][p.second];
					que.push ({-cnt[h][w], {h,w}});
				}
			}
		}
		
		// 移動 B
		for (int i=-2; i<=2; i++) {
			for (int j=-2; j<=2; j++) {
				if ( (i==-1 && j==0) || (i==1 && j==0) || (i==0 && j==-1) || (i==0 && j==1) )
					continue;
				int h = p.first + i;
				int w = p.second + j;
				if (cond (h, w)) {
					if (cnt[h][w]==-1 || cnt[h][w]>cnt[p.first][p.second]+1) {
						cnt[h][w] = cnt[p.first][p.second] + 1;
						que.push ({-cnt[h][w], {h,w}});
					}
				}
			}
		}

		flags[p.first][p.second] = true;
	}


	if (cnt[Dh][Dw] < 0) {
		cout << -1 << endl;
	} else {
		cout << cnt[Dh][Dw] << endl;
	}

	return 0;
}

Measured memory_bytes: 13380