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

using namespace std;

int main() {
	int a;
	long long b,t[200200],ans=0LL;
	scanf("%d %lld",&a,&b);
	for(long long i=0;i<a;i++) {
		scanf("%lld",&t[i]);
	}
	int ptr = 1;
	int pos = 0;
	while(ptr<a) {
		long long d = t[ptr] - t[ptr-1];
		if(d>b) {
			ans+=t[ptr-1] + b - pos;
			pos = t[ptr];
		}
		ptr++;
	}
	ans+=t[ptr-1] + b - pos;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1792
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef  long long ll;
double pi=3.1415926535898;
//double pi=acos(-1.0);
#define speed      ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
#define rng(i,a,b) for(int i=a;i>=int(b);i--)
#define rep(i,a,b) for(int i=a;i<=int(b);++i)
#define lop(i,n)   for(int i=0;i<int(n);i++)
#define ms(x,a)    memset(x,a,sizeof(x))
#define all(x)     (x).begin(),(x).end()
#define sz(x)      int(x.size())
#define pb         push_back
#define r0         return 0;
#define CC         continue;
#define bb(x)      cerr<< x <<endl;
#define pii        pair<int,int>
#define pis        pair<int,string>
#define vi         vector<int>
#define F          first
#define S          second
//#define max(a,b) a<b?b:a  __builtin_popcount;
//#define min(a,b) a<b?a:b
//freopen("output.txt","w",stdout),freopen("input.txt","r",stdin);
const ll M  = 1e9+7 ;
const int N = 50500;
const int inf = INT_MAX;
const double eps = 1e-6;
//////////////////////    Hi    ^_^  hack me if you can :P

int main()
{
    int a,b;
    cin>>a>>b;
    if (a==1) a=14;
    if (b==1) b=14;
    if (a>b) cout<<"Alice";
    if (a<b) cout<<"Bob";
    if (a==b) cout<<"Draw";
}
/*



https://ideone.com/goT6Vy//http:
codeforces.com/problemset/problem/466/D

, vector < pair <int,int > >, greater <pair <int, int> >
http://codeforces.com/contest/295/submission/17929453
freopen("output.txt","w",stdout);
freopen("input.txt","r",stdin);

ll pwmod(ll a, ll n, ll mod)
{
    ll ret = 1;
    while (n)
    {
        if (n & 1) ret = ret * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return ret;
}

for (int i=0; i<n; i++)            Hi    ^_^  hack me if you can :P

int mx[]= {0,0,1,-1, 1,1,-1,-1};
int my[]= {1,-1,0,0, 1,-1,1,-1};
bool inside (int i,int j){return (i>=0 && i<n && j>=0 && j<m);}

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void gcd(LL n,LL m,LL &d,LL &xx,LL &yy)
{
    if(!m)
    {
        d=n;
        xx=1;
        yy=0;
    }
    else
    {
        gcd(m,n%m,d,yy,xx);
        yy-=xx*(n/m);
    }
}

int getm(int l,int r)
{
    if(l>r)
        return N;
    if(l==r)
        return 0;
    if(l==r-1)
        return s[l] != s[r];
    if(s[l]==s[r])
        return getm(l+1,r-1);
    else
        return 1+min(getm(l+1,r),getm(l,r-1));
}

int BIT[si], a[si], n;
void update(int x, int delta)
{
    for(; x <= N; x += x&-x)
        BIT[x] += delta;
}
int query(int x)
{
    int sum = 0;
    for(; x > 0; x -= x&-x)
        sum += BIT[x];
    return sum;
}

#define sc(x)      scanf("%d",&x)
#define scl(x)     scanf("%lld",&x)
#define pr(x)      printf("%d ",x)
#define prl(x)     printf("%lld ",x)
#define prln(x)    printf("%d\n",x)
#define prlln(x)   printf("%lld\n",x)
#define scd(x)     scanf("%lf",&x)
#define prd(x)     printf("%.10f\n",x)


*/


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int N, A, m;
	char *ans;

	scanf("%d", &N);
	scanf("%d", &A);

	m=N-(N/500)*500;
	if(A>=m){
		ans="Yes";
	}else{
		ans="No";
	}
	printf("%s\n", ans);
	return 0;
}

Measured memory_bytes: 128
//Created by Kira

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

#define IOS cin.sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pii pair<int,int> 
#define pb push_back
#define vi vector<int> 
using ll = long long;

const int mod = 1e9 + 7;

ll pwr(ll a, ll b);
    

const int hax = 1e4+5;
const int nax = 1e3+5;
int dp[nax][hax];


int main(){
   IOS

    int h, n; cin>>h>>n;

    vi a(n), b(n);

    for(int i = 0; i < n; i++){
        cin>>a[i]>>b[i];
    }

    for(int j = 0; j <= h; j++) 
        dp[0][j] = 1e9;
    
    for(int i = 0; i <= n; i++)
        dp[i][0] = 0;

    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= h; j++){
                dp[i][j] = min(dp[i-1][j], b[i-1] + dp[i][max(0,j-a[i-1])]);
            
        }
    }

    // for(int i = 0; i <= n; i++){
    //     for(int j = 0; j <= h; j++){
    //         cout<<dp[i][j]<<" ";
    //     }cout<<endl;
    // }

   
   cout<<dp[n][h]<<"\n";

    



   


}

ll pwr(ll a, ll b){
   a %= mod;	//Remove mod if not required
   ll res = 1;
   while(b > 0){
    if(b&1)
        res = res * a % mod;
        a = a * a % mod;
    b >>= 1;
    }

    return res;
}



Measured memory_bytes: 39424
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ONLINE_JUDGE
int dp[100005];
void ravi()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
int frog(vector<int> & vc,int pos)
{
    // Base condition
    if (pos == vc.size()-1)
        return 0;
    if (dp[pos] != -1)
        return dp[pos];
    long long  left = abs(vc[pos]-vc[pos+1]) + frog(vc,pos+1);
    long long right;
    if (pos+2 > vc.size()-1)
        right = INT_MAX;
    else
        right = abs(vc[pos]-vc[pos+2]) + frog(vc,pos+2);
    return dp[pos] = (min(left,right));
} 
int main()
{
    ravi();
    int n;
    cin>>n;
    vector<int> arr;
    int temp;
    memset(dp,-1,sizeof(dp));
    for(int i = 0;i<n;i++)
    {
        cin>>temp;
        arr.push_back(temp);
    }
    cout<<frog(arr,0);
	return 0;
}

Measured memory_bytes: 5880
#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
// #pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
// #pragma GCC target("avx2") //Enable AVX

#include <bits/stdc++.h>

#define int long long

using namespace std;

#ifdef LOCAL
#include "/media/brayand/BrayanD/debugger.h"
#else
template<typename... Args>
void db(Args... args) {}
#endif

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

    int N;
    cin >> N;

    vector<int> stones;

    for(int i = 0 ; i < N ; i++)
    {
        int n;
        cin >> n;
        stones.push_back(n);
    }

    int X = stones[0];
    int Y = stones[1];

    int Z = 0;

    for(int i = 2 ; i < N ; i++)
    {
        Z ^= stones[i];
    }

    vector<pair<int,int>> v1, v2;

    for(int mask = 0 ; mask < (1<<20) ; mask++)
    {
        int num1 = 0, num2 = 0;
        for(int i = 0 ; i < 20 ; i++)
        {
            if(Z&(1<<i))
            {
                if(mask&(1<<i))
                {
                    num1 += (1<<i);
                }
                else
                {
                    num2 += (1<<i);
                }
            }
            else
            {
                if(mask&(1<<i))
                {
                    num1 += (1<<i);
                    num2 += (1<<i);
                }
                else
                {
                }
            }
        }
        v1.push_back({num1,num2});
    }

    for(int mask = 0 ; mask < (1<<20) ; mask++)
    {
        int num1 = 0, num2 = 0;
        for(int i = 0 ; i < 20 ; i++)
        {
            if(Z&(1ll<<(i+20)))
            {
                if(mask&(1<<i))
                {
                    num1 += (1ll<<(i+20));
                }
                else
                {
                    num2 += (1ll<<(i+20));
                }
            }
            else
            {
                if(mask&(1<<i))
                {
                    num1 += (1ll<<(i+20));
                    num2 += (1ll<<(i+20));
                }
                else
                {
                }
            }
        }
        v2.push_back({num1,num2});
    }

    vector<pair<int,int>> mp;

    for(int i = 0 ; i < v2.size() ; i++)
    {
        mp.push_back({v2[i].first + v2[i].second, v2[i].second});
    }

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

    int sol = 1e18;

    for(int i = 0 ; i < v1.size() ; i++)
    {
        int sum = v1[i].first+v1[i].second;

        int temp = X+Y-sum;

        if(temp < 0)continue;

        pair<int,int> f = {temp,Y-v1[i].second};

        auto pos = lower_bound(mp.begin(),mp.end(),f);

        if(pos != mp.end())
        {
            if((*pos).first != temp)continue;
            if(((*pos).second+v1[i].second) - Y < X)sol = min(sol,((*pos).second+v1[i].second) - Y);
        }
    }

    if(sol != 1e18)cout << sol << '\n';
    else cout << -1 << '\n';


    return 0;
}


Measured memory_bytes: 60560
#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1e9+7;

int main() { 
  int n, m, a;
  cin >> n >> m;
  bool step[n+1] = {0};
  for(int i = 0; i < m; ++i) {
    cin >> a;
    step[a] = 1;
  }

  int dp[n+1] = {0};
  dp[0] = 1;
  if(step[0] == 0) dp[1] = dp[0];
  for(int i = 2; i <= n; ++i) {
    if(step[i-1] == 0) dp[i] += dp[i-1];
    if(step[i-2] == 0) dp[i] += dp[i-2];
    dp[i] %= MOD;
  }
  cout << dp[n] << '\n';
}


Measured memory_bytes: 768
N,M,Q = map(int,input().split())
src = [tuple(map(int,input().split())) for i in range(M)]
qs = [tuple(map(int,input().split())) for i in range(Q)]

imos = [[0]*(N+1) for i in range(N+1)]
for l,r in src:
    imos[l][r] += 1

for i in range(N+1):
    for j in range(N):
        imos[i][j+1] += imos[i][j]
for i in range(N):
    for j in range(N+1):
        imos[i+1][j] += imos[i][j]

for p,q in qs:
    ans = imos[p-1][p-1] + imos[q][q] - imos[p-1][q] - imos[q][p-1]
    print(ans)

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

int main()
{
	int n;
	cin >> n;
	
	int res = 0;
	int ans = 1;
	for (int i = 1; i <= n; i++) {
		int count = 0;
		int j = i;
		while (j % 2 == 0) {
			j /= 2;
			count++;
		}
		if (res < count) {
			ans = i;
			res = count;
		}
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;


class Main{
  
  
  
	public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
      
      int n = sc.nextInt();
      int k = sc.nextInt();
      int x = sc.nextInt();
      int y = sc.nextInt();
      int ans = 0;
      
     for(int i=0;i<n;i++){
     	if(i<k){
        	ans += x;
        } else {
        	ans += y;
        }
     }
      System.out.println(ans);
	}
}


Measured memory_bytes: 35692
#include<stdio.h>

int main(){
	int i;
	int day,totalDay;
	int month;

	while(scanf("%d %d",&month, &day), month){
		totalDay = day;
		month--;
		while(month > 0){
			switch (month){
				case 2:
					totalDay+=29;
					month--;
					break;
				case 4:
				case 6:
				case 9:
				case 11:
					totalDay+=30;
					month--;
					break;
				default:
					totalDay+= 31;
					month--;
					break;
			}
		}

		switch((totalDay - 1) % 7){
			case 0: printf("Thursday\n"); break;
			case 1: printf("Friday\n"); break;
			case 2: printf("Saturday\n"); break;
			case 3: printf("Sunday\n"); break;
			case 4: printf("Monday\n"); break;
			case 5: printf("Tuesday\n"); break;
			case 6: printf("Wednesday\n"); break;
		}

	}

	return 0;
}

Measured memory_bytes: 584
import statistics

if __name__ == "__main__":
    N = int(input())
    A = [float(x) for x in input().split(" ")]
    A = [a - i - 1 for i, a in enumerate(A)]
    med = statistics.median(A)
    A = [abs(a - med) for a in A]
    print(int(sum(A)))


Measured memory_bytes: 33908
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;



int main(void){
  int n, m;
  cin >> n >> m;
  map<int, int> freq;
  REP(i, 0, m) {
    int u, v;
    cin >> u >> v;
    freq[u] += 1;
    freq[v] += 1;
  }
  for (map<int, int>::iterator it = freq.begin(); freq.end() != it; ++it) {
    if (it->second % 2 != 0) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,n) for(int i=s;i<n;i++)
#define rep_bit(n) for (int bit = 0; bit < (1<<n); ++bit)
#define all(x) (x).begin(),(x).end()
#define ll long long
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
using namespace std;
typedef vector<vector<int> > Graph;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
//条件式 ? 真の場合の文 : 偽の場合の文
//abs(x) = (x の絶対値)
//string S  S,at(i),S += T,S += c,S.size(),S.substr(l),S.substr(l, r)
//*min_element(all(x)) *max_element(all(x))
//vi x; x.back(),x.front(),x.push_back(),x.pop_back()
//swap(a, b)
//gcd(a, b)最大公約数
//sort(all(x)),reverse(all(x)),sort(x.begin()+l,a.begin()+r)lからrまで
//stack<int> a; a.push(x),a.pop(),a.top(),a.empty()bool
//queue<int> b; b.push(x),b.pop(),b.front(),b.empty()bool,b.size() 要素が小さい順
//priority_queue<int, vector<int>, greater<int>> c,c.top()
//map<int, int> M1; 変数[key] = value; 変数.erase(key); 変数.at(key); 変数.count(key)所属判定　変数.size()
//find(all(x), key)boolソート済みのベクトル
//*lower_bound(all(x),k)以上の最小の要素,*uppper_bound(all(x),k)より大きい最小の要素

int main(){

    int n,q;
    cin >> n >>q;
    string s;
    cin >> s;
    vi l(q),r(q);
    rep(i,q){
        cin >> l.at(i) >> r.at(i);
    }
    vi sum(n+1,0);
    for(int i = 2; i < n+1;i++){
        if(s.at(i-2) == 'A' && s.at(i-1) == 'C') sum.at(i) = sum.at(i-1)+1;
        else sum.at(i) = sum.at(i-1);
    }
    rep(i,q){
        cout << sum.at(r.at(i)) - sum.at(l.at(i)) << endl;
    }
    return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std; 
    
int main(){
  int A,B,H,M;
  cin >> A >> B >> H >> M;
  double C=acos(-1)*(60*H+M)/360-acos(-1)*M/30;
  double ans=sqrt(A*A+B*B-2*A*B*cos(C));
  cout << fixed << setprecision(15) << ans << endl;
}
  

Measured memory_bytes: 4172
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・ス
		Scanner sc = new Scanner(System.in);
		int tyou=0;
		int hishi=0;
        int c1 = 0;
        int c2 = 0;

        while(sc.hasNext()){

            String[] s=sc.nextLine().split(",");

           int a=Integer.parseInt(s[0]);
            int b=Integer.parseInt(s[1]);
            int c=Integer.parseInt(s[2]);


            c1=a*a+b*b;
            c2=c*c;

            if(c1==c2){
            	tyou++;

            }else if(a==b){
            	hishi++;
            }

        }
        System.out.println(tyou);
        System.out.println(hishi);


    }
}


Measured memory_bytes: 25948
#include <bits/stdc++.h>
using namespace std;
#define fast_io {cin.sync_with_stdio(0); cout.sync_with_stdio(0);}
#define out(x,y) {cout<<x<<y;}
using ll = long long int;

int main(){
	fast_io;
	ll n; cin>>n;
	vector<ll>v(n,0);
	for(ll i=0;i<n-1;i++){
		ll x; cin>>x; v[--x]++;
	}
	for(ll i=0;i<n;i++){
		cout<<v[i]<<"\n";
	}
}

Measured memory_bytes: 4760
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n");
var [h,w]=arr.shift().split(" ").map(Number);
var b=[];
for(var i=0;i<h;i++){
   var two=[];
   arr[i].split("").forEach((v,j)=>{
      if(v=="B")two.push([i,j]);
   });
   if(two.length==1)b.push(two[0]);
   else if(two.length>=2)b.push(two[0],two[two.length-1]);
}
var max=0;
for(var i=0;i<b.length;i++){
   for(var j=i+1;j<b.length;j++){
      var d=Math.abs(b[i][0]-b[j][0])+Math.abs(b[i][1]-b[j][1]);
      max=Math.max(max,d);
   }
}
console.log(max);



Measured memory_bytes: 20360
import scala.io.StdIn

object Main extends App {
  val n = StdIn.readLine()
  val w = StdIn.readLine().split(" ").map(_.toInt)
  var l: Array[Int]  = Array.empty

  w.foreach { i =>
    if (l.isEmpty) {
      l = l :+ i
    } else {
      l = l :+ (i + l.last)
    }
  }

  println(l.dropRight(1).map{i => Math.abs(l.last - 2 * i)}.min)
}
  



Measured memory_bytes: 27216
use whiteread::parse_line;

fn main() {
    let (n, a, b): (i64, i64, i64) = parse_line().unwrap();
    let t: i64 = n / (a+b);
    let mut ac: i64 = t * a;

    let t: i64 = n % (a+b);
    if t != 0 {
        if t <= a {
            ac = ac + t;
        } else {
            ac = ac + a;
        }
    }

    println!("{}", ac);
}


Measured memory_bytes: 2188
// Problem : C - A x B + C
// Contest : AtCoder - AtCoder Beginner Contest 179
// URL : https://atcoder.jp/contests/abc179/tasks/abc179_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define int long long
#define db double
#define mod 1000000007
#define pb push_back
#define pp pair<int,int>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repe(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=b;i>=a;i--)
#define maxn 1000005
#define ss second
#define ff first
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
int inv(int a, int b){
 return 1<a ? b - inv(b%a,a)*b/a : 1;
}
int spf[maxn];
void solve()
{
	int n,ans = 1;
	cin >> n;
	for(int i=1;i<=n;i++)
		spf[i] = i;
	for(int i=2;i<=n;i++)
		if(spf[i] == i)
			for(int j=i;j<=n;j+=i)
				if(spf[j] == j)
					spf[j] = i;
	for(int i=2;i<n;i++)
	{
		unordered_map<int,int> mp;
		int j = i;
		while(j > 1)
		{
			mp[spf[j]]++;
			j /= spf[j];
		}
		int tmp = 1;
		for(auto [a,b]:mp)
			tmp *= (b+1);
		ans += tmp;
	}
	cout << ans;
}
signed main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin >> t;
    while(t--)
    solve();
    return 0;
}


Measured memory_bytes: 11388
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
using P = pair<int,int>;
using ll = long long;
static const int INF = 1000000000;
static const ll MOD = 1000000007;

ll gcd(ll a, ll b){return b!=0 ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}

int main(){
	int h, w, a, b;
	cin >> h >> w >> a >> b;
	
	int ans = (h - a) * (w - b);
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int A = in.nextInt();
            int B = in.nextInt();

            int sum2 = 0;
            for (int i = 1; i <= N; i++) {
                int sum = sum(i);
                if (sum >= A && sum <= B) {
                    sum2 += i;
                }
            }

            System.out.println(sum2);
        }
    }

    private static int sum(int n) {
        int sum = 0;
        for (; n > 0;) {
            sum += n % 10;
            n /= 10;
        }
        return sum;
    }
}


Measured memory_bytes: 27116
# アナグラムかどうかは文字列を文字単位にソートして同一かどうかを調べればいい
# ソート結果文字列毎に組み合わせ数を求める
n = gets.to_i
h = Hash.new{|h,k| h[k] = 0}
n.times.each do
  h[gets.chomp.chars.sort] += 1
end
ans = h.values.inject(0) do |x, v|
  x += Array.new(v).combination(2).size
end
p ans


Measured memory_bytes: 89980
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned ll
#define PI acos(-1)
#define vi vector<int>
#define pi pair<int, int>
#define pl pair<ll, ll>
template<typename T> using v2 = vector<vector<T>>;
template<typename T> using v3 = vector<vector<vector<T>>>;
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int MOD = 998244353;
const int INF = 1e9 + 200;
const ll INFLL = 2e18 + 200;

string dfs(ll now) {
    if (now == 0) return "";
    now--;
    string temp = dfs(now / 26);
    temp.push_back('a' + now % 26);
    return temp;
}

int main() {
    ll N;
    cin >> N;
    cout << dfs(N) << endl;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vec = vector<ll>;
using vecp = vector<P>;
using mat = vector<vec>;
using matp = vector<vecp>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define all(v) v.begin(), v.end()
    

int main(){
  ll X;
  cin >> X;
  rep(i,1e5){
    if((i*(i+1))/2>=X){
      cout << i << endl;
      return 0;
    }
  }
  
}
        

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define INF 1000000000
using namespace std;
typedef pair<int, int> pii;
namespace MyLib {

	class Dijkstra {
		struct edge {
			int to, cost;
			edge(int to_, int cost_) : to(to_), cost(cost_) {}
		};
		bool isdirected;
		vector<int> d;
		vector<vector<edge>> G;
		int V, E;
	public:
		Dijkstra(int _V, bool _isdirected = true) : isdirected(_isdirected), V(_V), E(0), d(_V), G(_V) { }
		void add(int a, int b, int c) {
			G[a].push_back(edge(b, c));
			if (!isdirected) G[b].push_back(edge(a, c));
			E++;
		}
		void calc(int start) {
			fill(d.begin(), d.end(), INF);
			priority_queue<pii, vector<pii>, greater<pii>> que;
			d[start] = 0;
			que.push(pii(0, start));

			while (!que.empty()) {
				pii p = que.top(); que.pop();
				int v = p.second;
				if (d[v] < p.first) continue;
				for (size_t i = 0; i < G[v].size(); i++) {
					edge e = G[v][i];
					if (d[e.to] > d[v] + e.cost) {
						d[e.to] = d[v] + e.cost;
						que.push(pii(d[e.to], e.to));
					}
				}
			}
		}
		int dist(int to) {
			return d[to];
		}
	};
}
using namespace MyLib;
int main()
{
	int v, e, r;
	cin >> v >> e >> r;
	Dijkstra dk(v);
	for (int i = 0, s, t, d; i < e; i++) {
		cin >> s >> t >> d;
		dk.add(s, t, d);
	}
	dk.calc(r);
	for (int i = 0; i < v; i++) {
		if (dk.dist(i) == INF)
			cout << "INF" << endl;
		else
			cout << dk.dist(i) << endl;
	}
	return 0;
}

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


//region Template
#include "ext/pb_ds/assoc_container.hpp"

using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const int MOD2 = 998244353;
const int MOD = 1000000007;
using namespace std;
#define finish(x) cout << x; exit(0);
#define fastIO cin.tie(0); cin.sync_with_stdio(false);

void setIn(string s) { freopen(s.c_str(), "r", stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }

//const string USCAO_TAG = "mountains";
void usaco(const string& USACO_TAG) { setIn(USACO_TAG + ".in"); setOut(USACO_TAG + ".out"); }
#define is_empty(...) ( sizeof( (char[]){#__VA_ARGS__} ) == 1 )

void print() {}
template<typename T, typename... Args>
void print(T firstArg, Args... args) {
	#ifdef LOCAL
	cout << firstArg << endl;
	print(args...);
	#endif
}

//endregion

/* Notes:
 * Fry my kartoshka
 */

const int MAXN = 100 + 2;
const int INF = 2e9;

int tre[4 * MAXN];
int a[] = {1, 2, 3, 4, 5};
int f[4 * MAXN];

void build(int v, int l, int r){
	if(l == r){
		tre[v] = a[l];
	}
	else{
		int m = (l + r) / 2;
		build(2 * v, l, m);
		build(2 * v + 1, m + 1, r);
		tre[v] = tre[v * 2] + tre[v * 2 + 1];
	}
}
void push(int v, int l, int m, int r){
	f[2 * v] += f[v];
	f[2 * v + 1] += f[v];
	tre[2 * v] += (m - l + 1) * f[v];
	tre[2 * v + 1] += (r - m) * f[v];
	f[v] = 0;
}

void update(int v, int tl, int tr, int l, int r, int val) {
	if (l > r)
		return;
	if (l == tl && r == tr) {
		tre[v] += val * (r - l + 1);
		f[v] += val;
		return;
	}

	int tm = (tl + tr) / 2;
	push(v, tl, tm, tr);

	update(v * 2, tl, tm, l, min(r, tm), val);
	update(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r, val);

	tre[v] = tre[2 * v] + tre[2 * v + 1];
}


int sum(int v, int tl, int tr, int l, int r) {
	if (l > r)
		return 0;
	if (l == tl && r == tr) {;
		return tre[v];
	}
	int tm = (tl + tr) / 2;
	push(v, tl, tm, tr);
	return sum(v * 2, tl, tm, l, min(r, tm))
		   + sum(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r);
}


int g[MAXN][MAXN];

int main() {
	//usaco("milkvisits");

#ifdef LOCAL
	setIn("in.txt");
	setOut("out.txt");
#endif

	int n, d;
	cin >> n >> d;

	int p[n][d];
	for(int i = 0 ; i < n; i++){
		for(int j = 0; j < d; j++){
			cin >> p[i][j];
		}
	}


	int cnt = 0;
	for(int i = 0; i < n; i++){
		for(int j = i + 1; j < n; j++){

			long double dis = 0;
			for(int k = 0; k < d; k++){
				dis += (p[i][k] - p[j][k]) *  (p[i][k] - p[j][k]);
			}
			dis = sqrt(dis);
			if(dis - floor(dis) == 0) {
				cnt++;
				//cout << dis << " " << i << " " << j << endl;
			}
		}
	}

	cout << cnt;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <map>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<ld> vld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)

class mod {
public:
    mod() {m_n = 0;}
    mod(ll n) {if (n >= 0) m_n = n % MOD; else m_n = n % MOD + MOD;}
    friend bool operator== (const mod& a, const mod& b) {return a.m_n == b.m_n;}
    friend bool operator!= (const mod& a, const mod& b) {return !(a == b);}
    friend mod operator+ (const mod& a, const mod& b) {return (a.m_n + b.m_n) % MOD;}
    friend mod& operator+= (mod& a, const mod& b) {return a = a + b;}
    friend mod operator- (const mod& a) {return -a.m_n;}
    friend mod operator- (const mod& a, const mod& b) {return (a.m_n + (-b.m_n)) % MOD;}
    friend mod& operator-= (mod& a, const mod& b) {return a = a - b;}
    friend mod operator* (const mod& a, const mod& b) {return (a.m_n * b.m_n) % MOD;}
    friend mod& operator*= (mod& a, const mod& b) {return a = a * b;}
    friend mod pow(const mod& n, ll r) {
        if (r == 0) {
            return 1;
        } else if (r < 0) {
            return pow(n, (MOD - 2) * (-r));
        } else if (r % 2 == 0) {
            mod tmp = pow(n, r / 2);
            return tmp * tmp;
        } else {
            return n * pow(n, r - 1);
        }
    }
    friend mod operator/ (const mod& a, const mod& b) {return a * pow(b, -1);}
    friend mod& operator/= (mod& a, const mod& b) {return a = a / b;}
    friend ostream& operator<< (ostream& os, const mod& n) {os << n.m_n; return os;}
    friend istream& operator>> (istream& is, mod& n) {ll tmp; is >> tmp; n = mod(tmp); return is;}
private:
    ll m_n;
};
mod pow(ll n, ll r) {return pow(mod(n), r);}

#define FACT_MAX 100005
mod t_fact[FACT_MAX], t_fact_inv[FACT_MAX];
mod fact(int n)
{
    if (n == 0 || n == 1) return t_fact[n] = 1;
    if (t_fact[n] != 0) return t_fact[n];
    else return t_fact[n] = n * fact(n-1);
}
mod fact_inv(int n)
{
    if (t_fact_inv[n] != 0) return t_fact_inv[n];
    else return t_fact_inv[n] = pow(fact(n), -1);
}
mod comb(int n, int k) {if (n < 0 || k < 0 || k > n) return 0; else return fact(n) * fact_inv(n - k) * fact_inv(k);}
mod multi_choose(int n, int k) {return comb(n + k - 1, k);}

int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    int N;
    cin >> N;
    vll A(N);
    for (int n = 0; n < N; ++n) {
        cin >> A[n];
    }
    
    vector<mod> Sum(N+1);
    Sum[0] = 0;
    for (int n = 1; n <= N; ++n) {
        Sum[n] = Sum[n-1] + pow(n, -1);
    }
    vector<mod> Prob(N);
    for (int n = 0; n < N; ++n) {
        Prob[n] = Sum[n+1] + Sum[N-n] - 1;
    }
    
    mod Ans = 0;
    for (int n = 0; n < N; ++n) {
        Ans += A[n] * Prob[n];
    }
    Ans *= fact(N);
    cout << Ans << endl;

    return 0;
}


Measured memory_bytes: 5760
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <set>
#include <unordered_set>
#include <queue>
#include <cmath>
 
using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define FOR(i, n, m) for(int i=n; i<m; ++i)

using Graph = vector<vector<int>>;

// 深さ優先探索
vector<bool> seen;
void dfs(const Graph &G, int v) {
    seen[v] = true; // v を訪問済にする

    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue; // next_v が探索済だったらスルー
        dfs(G, next_v); // 再帰的に探索
    }
}

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main() {
  ll H, W, K;
  cin >> H >> W >> K;
  char b[10][10][70][70]={};
  rep(i,H){
    rep(j,W){
      cin >> b[i][j][0][0];
    }
  }

  rep(i,H){
    rep(j,W){
      rep(k,70){
        rep(l,70){
          b[i][j][k][l] = b[i][j][0][0];
        }
      }
    }
  }
  
  ll HP = 1;
  ll WP = 1;
  rep(i, H) HP *= 2;
  rep(j, W) WP *= 2;
  
  rep(i,HP){
    rep(i2,H){
      if(i & (1<<i2)){
        //cout << i << " " << i2 << endl;
        rep(i3,WP){
          rep(i4,W){
            b[i2][i4][i][i3] = '.';
          }
        }
      }
    }
  }
  rep(i,WP){
    rep(i2,W){
      if(i & (1<<i2)){
        //cout << i << " " << i2 << endl;
        rep(i3,HP){
          rep(i4,H){
            b[i4][i2][i3][i] = '.';
          }
        }
      }
    }
  }
  
  ll cnt = 0;
  ll tmp;
  
  rep(i,HP){
    rep(j,WP){
      tmp = 0;
      rep(k,H){
        rep(l,W){
          if(b[k][l][i][j]=='#') tmp++;
        }
      }
      if(tmp == K) cnt++;
    }
  }
  
  /*rep(k,H){
    rep(l,W){
      cout << b[k][l][0][0];
    }
    cout << endl;
  }*/
  
  cout << cnt << endl;  
}

Measured memory_bytes: 4156
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.second < b.second; }
ll mod = 1e9+7;

signed main() {
    ll n,x; cin>>n>>x;
    //vl a(n);
    //rep(i,n)
    if(n<10)x+=100*(10-n);
    cout<<x<<endl;
}


Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Queue;
import java.util.Random;
import java.util.Scanner;
 


public class Main {
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static long mod =1000000007;
	//static 	ArrayList<Integer> cc = new ArrayList<>(100);
	
	
	public static void main(String[] args) {
		//int N=sc.nextInt();for(int i=0;i<N;i++) {}
		//int a[]=new int[N];
		//Ae2+Be2=Ce2
		//StringBuffer str = new StringBuffer(hoge1);
		//for(int i=0;i<N;i++) {}
		
		//int N=sc.nextInt();for(int i=0;i<N;i++) {}
		String S=sc.next();
		//0 48
		int a=S.charAt(S.length()-1);
		if(S.charAt(S.length()-1)==51) {
			p("bon");
		}else if(a==48||a==49||a==54||a==56) {
			p("pon");
		}else {
			p("hon");
		}
		
		
		
		
		
		
		
		
	}
		
		
		
		
		
	
	
	
	public static long lcm(long a, long b) {
        return a / gcd(a, b) * b;
	}
	
	public static long gcd(long a, long b) {
        return b == 0 ? a: gcd(b, a % b);
	}

	


	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	
}
	


Measured memory_bytes: 35648
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  if(a==1 && b==2){
    cout<<"3"<<'\n';
  }
   if(a==2 && b==3){
    cout<<"1"<<'\n';
  }
   if(a==3 && b==1){
    cout<<"2"<<'\n';
  }
   if(a==2 && b==1){
    cout<<"3"<<'\n';
  }
   if(a==3 && b==2){
    cout<<"1"<<'\n';
  }
   if(a==1 && b==3){
    cout<<"2"<<'\n';
  }
  return(0);
}


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

bool find(int i, int j, vector<char> str){
    if(j==3){
        return true;
    }
    else if(i == n){
        return false;
    }
    else if(s[i] == str[j]){
        return find(i+1, j+1, str);
    }
    else return find(i+1, j, str);
}
int main(void){
    cin>>n;
    cin>>s;
    int ans=0;
    rep(k, 1000){
        string tmp = to_string(k);
        vector<char> str(3);
        rep(i, 3-tmp.size()) str[i]='0';
        rep(i, tmp.size()) str[i+3-tmp.size()]=tmp[i];
        if(find(0, 0, str)) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 6016
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <functional>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 100000000
template<class T, class C> void chmax(T& a, C b) { a>b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a<b ? : a = b; }
int n, m, d[100005] = { 0 }, imos[100005] = { 0 }, now = 0;
long long sum = 0;
int main() {
	cin >> n >> m;
	for (int i = 0; i <= n - 2; i++) {
		cin >> d[i];
	}
	for (int i = 0; i < m; i++) {
		int len;
		cin >> len;
		if (len > 0) {
			imos[now] += 1;
			imos[now + len] -= 1;
		}
		else {
			imos[now + len] += 1;
			imos[now] -= 1;
		}
		now = now + len;
	}
	sum += imos[0] * d[0];
	sum %= 100000;
	for (int i = 1; i <= n-2; i++) {
		imos[i] += imos[i - 1];
		if(imos[i]>=0) sum += imos[i] * d[i];
		sum %= 100000;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3848
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Queue;
import java.util.Scanner;

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

        while (true) {
            int w = sc.nextInt();
            int h = sc.nextInt();
            if (w + h == 0) {
                break;
            }

            int[][] maze = new int[2*h+1][2*w+1];
            maze_init(maze, 2*h+1, 2*w+1);

            for (int i=0; i<2*h-1; ++i) {
                for (int j=0; j<w-1+i%2; ++j) {
                    maze[i+1][2-(i%2)+j*2] = sc.nextInt();
                }
            }
            bfs(maze, 2*h+1, 2*w+1);
        }
        sc.close();
    }

    private static void bfs(int[][] maze, int height, int width) {
        Queue<CurrentNode> queue = new ArrayDeque<>();
        ArrayList<Integer> mem = new ArrayList<>();
        CurrentNode node = new CurrentNode(1, 1, 1);
        queue.add(node);
        mem.add(width+1);

        while (queue.size() > 0) {
            node = queue.poll();
            if (node.icur + node.jcur == height + width - 4) break;
            for (int i=0; i<2; ++i) {
                for (int j=0; j<2; ++j) {
                    int inext = (j*2-1)*i;
                    int jnext = (j*2-1)*(-1*i+1);
                    int encode = (node.icur + inext*2)*width + node.jcur + jnext*2;
                    if (maze[node.icur + inext][node.jcur + jnext] == 0 && !mem.contains(encode)) {
                        CurrentNode next = new CurrentNode(node.icur + inext*2, node.jcur + jnext*2, node.count+1);
                        mem.add(encode);
                        queue.add(next);
                    }
                }
            }
        }

        System.out.println(node.icur + node.jcur == height + width - 4 ? node.count : 0);
    }

    private static void maze_init(int[][] maze, int height, int width) {
        for (int i=0; i<height; ++i) {
            for (int j=0; j<width; ++j) {
                if (i == 0 || i == height-1) maze[i][j] = 1;
                else if (j == 0 || j == width-1) maze[i][j] = 1;
                else if (i % 2 + j % 2 == 0) maze[i][j] = 1;
            }
        }
    }

    private static class CurrentNode {
        private int icur;
        private int jcur;
        private int count = 0;

        private CurrentNode(int icur, int jcur, int count) {
            this.icur = icur;
            this.jcur = jcur;
            this.count = count;
        }
    }
}


Measured memory_bytes: 69824
#include<stdio.h>

int main(){
	int n,m,t[20001],max,i,j;
	
	while(0<=scanf("%d%d",&n,&m)){
		if(n==0 && m==0){
			break;
		}
		t[0]=0;
		for(i=1;i<=n+m;i++){
			scanf("%d",&t[i]);
		}
		
		for(i=1;i<=n+m;i++){
			for(j=i;j<=n+m;j++){
				if(t[j]<t[i]){
					max=t[j];
					t[j]=t[i];
					t[i]=max;
				}
			}
		}
		max=0;
		for(i=0;i<=n+m-1;i++){
			if(max<t[i+1]-t[i]){
				max=t[i+1]-t[i];
			}
		}
		
		printf("%d\n",max);
	}
	return 0;
}

Measured memory_bytes: 488
/**
 *   author: Shubham Srivastava
 *   created: 07 September 2019  17:30:50
**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    int n;cin>>n;
    cout<<pow(n,3);
return 0;
}

Measured memory_bytes: 512
def main():
    n = int(input())
    p = [int(i) for i in input().split()]
    Min = [10**9]
    ans = 0
    for i in range(n):
        Min.append(min(Min[-1],p[i]))
    for i in range(n):
        if Min[i]>p[i]:
            ans += 1
    print(ans)
main()

Measured memory_bytes: 32272
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}


int main() {
  int n,m; cin >>n >>m;
  cout <<n*(n-1)/2 + m*(m-1)/2 <<endl;
}


Measured memory_bytes: 764
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <sstream>
#include <map>

using namespace std;

const double eps=1e-10;

int main()
{
	double v;
	while(cin>>v){
		unsigned long long l=1,r=1e16,h;

		for(int i=0;i<1000;i++){

//			cout<<l<<" "<<r<<endl;

			h=(l+r)/2;
			double vv=2.0*9.8*(5*h-5);

			if(v*v>vv) l=h;
			else if(v*v<vv) r=h;
		}

		if( 2.0*9.8*(5*l-5)-v*v>=eps ) cout<<l<<endl;
		else cout<<r<<endl;

	}

	return 0;
}

Measured memory_bytes: 1212
//入力
fun readInts() = readLine()!!.split(" ").map { it.toInt() }
fun readLongs() = readLine()!!.split(" ").map { it.toLong() }
fun readLines(n:Int) = Array(n){readLine()!!}
//宣言
fun goban(h:Int,w:Int) = Array(h){Array(w){0}}
//ループ（breakは return@rep、continueはreturn）
fun rep(n:Int, f:(i:Int)->Unit){    for(i in 0 until n){f(i)}   }
fun rep(from:Int, to:Int, f:(i:Int)->Unit){    for(i in from until to){f(i)}    }

//計算
fun min(vararg values: Int) = values.min()!!
fun min(vararg values: Long) = values.min()!!
fun max(vararg values: Int) = values.max()!!
fun max(vararg values: Long) = values.max()!!

//ブール
fun Boolean.toInt() :Int  = if (this) 1 else 0

//出力
fun Yes(flag:Boolean) = if(flag) println("Yes") else println("No")

fun main(args: Array<String>) {
    val (H,W)=readInts()
    val s = readLines(H)
    val c = goban(H,W)

    rep(1,W){w->
        c[0][w] = c[0][w-1] + (s[0][w-1]!=s[0][w]).toInt()
    }
    rep(1,H){h->
        c[h][0] = c[h-1][0] + (s[h][0]!=s[h-1][0]).toInt()
        rep(1,W){w->
            var a = c[h][w-1] + (s[h][w-1]!=s[h][w]).toInt()
            var b = c[h-1][w] + (s[h-1][w]!=s[h][w]).toInt()
            c[h][w] += min(a,b)
        }
    }

    println(c.last().last()/2 + (s[0][0]=='#' || s.last().last()=='#').toInt())
}


Measured memory_bytes: 35960
#![allow(unused_imports, unused_macros, unknown_lints)]

use std::collections::{VecDeque, HashSet, HashMap, BinaryHeap};
use std::cmp::{max, min, Ordering};

macro_rules! dump {[$($e:expr), +] => {println!(concat!($(stringify!($e), " = {:?}\n"), +), $($e), +)}}
macro_rules! max {[$e0:expr, $($e:expr), +] => {{let mut r = $e0; $(r = max(r, $e);)+ r}}}
macro_rules! min {[$e0:expr, $($e:expr), +] => {{let mut r = $e0; $(r = min(r, $e);)+ r}}}
macro_rules! freq {($v:expr) => {{let mut h = HashMap::new(); for x in $v {*h.entry(x).or_insert(0) += 1} h}}}

fn main() {
  let s = get::chars();

  let ans =
    s.windows(2).zip(1..).
    flat_map(|(w,i)|if w[0]==w[1] {None} else {Some(max(i,s.len()-i))}).
    min().unwrap_or(s.len());

  println!("{}", ans)
}

#[allow(dead_code)]
mod get {
  use std::io::*;
  use std::str::*;

  pub fn val<T: FromStr>() -> T {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    buf.trim_right().parse::<T>().ok().unwrap()
  }

  pub fn vals<T: FromStr>(n: usize) -> Vec<T> {
    let mut vec: Vec<T> = vec![];
    for _ in 0 .. n {
      vec.push(val());
    }
    vec
  }

  pub fn tuple<T1: FromStr, T2: FromStr>() -> (T1, T2) {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    let mut it = buf.trim_right().split_whitespace();
    let x = it.next().unwrap().parse::<T1>().ok().unwrap();
    let y = it.next().unwrap().parse::<T2>().ok().unwrap();
    (x, y)
  }

  pub fn tuples<T1: FromStr, T2: FromStr>(n: usize) -> Vec<(T1, T2)> {
    let mut vec: Vec<(T1, T2)> = vec![];
    for _ in 0 .. n {
      vec.push(tuple());
    }
    vec
  }

  pub fn tuple3<T1: FromStr, T2: FromStr, T3: FromStr>() -> (T1, T2, T3) {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    let mut it = buf.trim_right().split_whitespace();
    let x = it.next().unwrap().parse::<T1>().ok().unwrap();
    let y = it.next().unwrap().parse::<T2>().ok().unwrap();
    let z = it.next().unwrap().parse::<T3>().ok().unwrap();
    (x, y, z)
  }

  pub fn tuple3s<T1: FromStr, T2: FromStr, T3: FromStr>(n: usize) -> Vec<(T1, T2, T3)> {
    let mut vec: Vec<(T1, T2, T3)> = vec![];
    for _ in 0 .. n {
      vec.push(tuple3());
    }
    vec
  }

  pub fn vec<T: FromStr>() -> Vec<T> {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    buf.trim_right().split_whitespace().map(|t| t.parse::<T>().ok().unwrap()).collect()
  }

  pub fn mat<T: FromStr>(h: usize) -> Vec<Vec<T>> {
    let mut mat = vec![];
    for _ in 0 .. h {
      mat.push(vec());
    }
    mat
  }

  pub fn chars() -> Vec<char> {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    buf.trim_right().chars().collect()
  }
}

#[allow(dead_code)]
mod put {
  use std::string::*;

  pub fn vec<T: ToString>(vec: &Vec<T>, sep: &str) {
    let out = vec.iter().map(|e| e.to_string()).collect::<Vec<_>>().as_slice().join(sep);
    println!("{}", out);
  }

  pub fn mat<T: ToString>(mat: &Vec<Vec<T>>, sep: &str) {
    for v in mat {
      vec(v, sep);
    }
  }
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
#include <utility>
#include <unordered_map>
#include <numeric>
using namespace std;
#define fol(i,n) for (int i=0;i<n;i++)
int main(){
    string A;
    cin >> A;
    int d =A.find("A");
    int n =A.rfind("Z");
    cout << n-d+1<<endl;
    return 0;
}


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

// ????¬???????????????°??????????????????????????????????????°?????????
using ll = long long;

struct RMQ {
	using type = int;
	static type id() { return INT_MAX; }
	static type op(const type& l, const type & r) { return min(l, r); }
};

template <typename M>
class node {
	using T = typename M::type;
public:
	T val;
	node<M> *l, *r;
	node(T val_) : val(val_), l(nullptr), r(nullptr) {}
};

template <typename M>
class DynamicSegmentTree {
	using T = typename M::type;
	const ll n;
	node<M> *root;
	T value(node<M> *t) {
		return t ? t->val : M::id();
	}
	T sub(ll l, ll r, node<M>* n, ll lb, ll ub) {
		if (!n || ub <= l || r <= lb) return M::id();
		if (l <= lb && ub <= r) return n->val;
		ll c = (lb + ub) / 2;
		return M::op(sub(l, r, n->l, lb, c), sub(l, r, n->r, c, ub));
	}
	node<M> *suc(ll p, node<M>* t, ll lb, ll ub, T val) {
		if (!t) t = new node<M>(M::id());
		if (lb + 1 == ub) {
			t->val = val;
			return t;
		}
		ll c = (lb + ub) / 2;
		if (p < c) t->l = suc(p, t->l, lb, c, val);
		else t->r = suc(p, t->r, c, ub, val);
		t->val = M::op(value(t->l), value(t->r));
		return t;
	}
public:
	DynamicSegmentTree(ll n_) :
		n(1 << (int)ceil(log2(n_))), root(nullptr) {}
	void update(ll p, T val) {
		root = suc(p, root, 0, n, val);
	}
	T find(ll l, ll r) {
		return sub(l, r + 1, root, 0, n);
	}
};

template <typename M>
class node2 {
	using T = typename M::type;
public:
	DynamicSegmentTree<M> val;
	node2<M> *l, *r;
	node2(ll size) : val(size), l(nullptr), r(nullptr) {}
};

template <typename M>
class DynamicSegmentTree2 {
	using T = typename M::type;
	const ll h, w;
	node2<M> *root;
	T value(node2<M> *t, ll p) {
		return t ? t->val.find(p, p) : M::id();
	}
	T sub(ll li, ll lj, ll ri, ll rj, node2<M>* n, ll lb, ll ub) {
		if (!n || ub <= li || ri <= lb) return M::id();
		if (li <= lb && ub <= ri) return n->val.find(lj, rj);
		ll c = (lb + ub) / 2;
		return M::op(sub(li, lj, ri, rj, n->l, lb, c), sub(li, lj, ri, rj, n->r, c, ub));
	}
	node2<M> *suc(ll pi, ll pj, node2<M>* t, ll lb, ll ub, T val) {
		if (!t) t = new node2<M>(w);
		if (lb + 1 == ub) {
			t->val.update(pj, val);
			return t;
		}
		ll c = (lb + ub) / 2;
		if (pi < c) t->l = suc(pi, pj, t->l, lb, c, val);
		else t->r = suc(pi, pj, t->r, c, ub, val);
		t->val.update(pj, M::op(value(t->l, pj), value(t->r, pj)));
		return t;
	}
public:
	DynamicSegmentTree2(ll h_, ll w_) :
		h(1ll << (ll)ceil(log2(h_))), w(w_), root(nullptr) {}
	void update(ll pi, ll pj, T val) {
		root = suc(pi, pj, root, 0, h, val);
	}
	T find(ll li, ll lj, ll ri, ll rj) {
		return sub(li, lj, ri + 1, rj, root, 0, h);
	}
};

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int n, q, com, x, y;
	cin >> n >> q;
	DynamicSegmentTree2<RMQ> st(n, 1);
	while (q--) {
		cin >> com >> x >> y;
		if (com) {
			printf("%d\n", st.find(x, 0, y, 0));
		}
		else {
			st.update(x, 0, y);
		}
	}
	return 0;
}

Measured memory_bytes: 12572