akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
#define N 1007
#define INF 1000000007
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll fceil(ll a, ll b) { return (a % b == 0 ? a / b : a / b + 1); }
int main()
{
   int a;
   string s;
   cin >> a >> s;
   cout << (a >= 3200 ? s : "red") << endl;
   return 0;
}


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

using namespace std;

typedef long long LL;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int main(){
	int N,K; cin >> N >> K;
	vector<LL> a(N),s(N+1),p(N+1);
	s[0] = p[0] = 0;
	repp(i,0,N){
		cin >> a[i];
		s[i+1] = s[i]+a[i];
		p[i+1] = p[i]+max<LL>(0,a[i]);
	}
	LL ans = 0;
	repp(i,K,N+1){
		ans = max(ans,p[N]-p[i]+p[i-K]+max<LL>(0,s[i]-s[i-K]));
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
//#define MOD (1000000007)
#define MOD (998244353)
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
//ifstream cinn("input.txt");ofstream coutt("output.txt");

int x,y,a,b,c,n;

signed main(){
    FASTER;
    cin>>x>>y>>a>>b>>c;
    vi p(a),q(b),r(c);cin>>p>>q>>r;
    sort(all(p));reverse(all(p));
    sort(all(q));reverse(all(q));
    sort(all(r));reverse(all(r));
    
    vi v;
    int ans=0;
    for(int i=0;i<x;i++)v.push_back(p[i]);
    for(int i=0;i<y;i++)v.push_back(q[i]);
    for(int i=0;i<min((x+y),c);i++)v.push_back(r[i]);
    sort(all(v));reverse(all(v));
    
    for(int i=0;i<x+y;i++){
        ans+=v[i];
    }
    cout<<ans;
}


Measured memory_bytes: 8688
a,b = map(int,input().split())
import math
c = []
d =[]
for i in range(1300):
    if math.floor(i*0.08)==a and math.floor(i*0.1)==b:
        c.append(i)
    else:
        d.append(i)
if len(c) ==0 :
    print(-1)
else:
    print(min(c))



Measured memory_bytes: 3060
# -*- coding: utf-8 -*-
"""
Created on Sat Mar  9 22:02:12 2019

@author: yuta
"""

NMC = list(map(int,input().split()))
N = NMC[0]
M = NMC[1]
C = NMC[2]
AB = [list(map(int,input().split())) for _ in range(N+1)]

def main(n,m,c,ab):
    b = ab[0]
    count = 0
    for i in range(1,(n+1)):
        naiseki = 0
        for j in range(m):
            naiseki += b[j]*ab[i][j]
            takoushiki = naiseki + c
        if takoushiki > 0:
            count += 1
    print(count)

main(N,M,C,AB)

Measured memory_bytes: 3064
N,M=map(int,input().split())
Y=[0]*N*M
X=[0]*N*M
z=1
for a in map(int,input().split()):
	if Y[-a]:z=0
	Y[-a]=1
for b in map(int,input().split()):
	if X[-b]:z=0
	X[-b]=1
h=w=0
MD=10**9+7
for i in range(N*M):
	z*=[h*w-i,h,w,1][Y[i]*2+X[i]]
	z%=MD
	h+=Y[i]
	w+=X[i]
print(z)


Measured memory_bytes: 18676
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;
#pragma GCC optimize("O3")

using ii = pair<i64, i64>;
class KDTree {
    struct node {
        ii p;
        node *l, *r;
        node(const ii& p) : p(p), l(nullptr), r(nullptr) {}
    } *root;
    
    function<bool(int, ii, ii)> compare = [](int d, ii p, ii q) {
        return d ? p.first < q.first : p.second < q.second;
    };

    node *insert(node *t, int d, const ii &p) {
        if (t == nullptr) return new node(p);
        if (compare(d, p, t->p)) {
            t->l = insert(t->l, !d, p);
        } else {
            t->r = insert(t->r, !d, p);
        }
        return t;
    }

    void search(node *t, int d, const ii &ld, const ii &ru, vector<ii> &out) {
        if (t == nullptr) return;
        const ii &p = t->p;
        if (ld.first <= p.first && p.first <= ru.first && ld.second <= p.second && p.second <= ru.second) {
            out.push_back(p);
        }
        if (!compare(d, p, ld)) {
            search(t->l, !d, ld, ru, out);
        }
        if (!compare(d, ru, p)) {
            search(t->r, !d, ld, ru, out);
        }
    }

public:
    KDTree() : root(nullptr) {};

    void insert(const ii &p) {
        root = insert(root, 0, p);
    }

    // including border
    vector<ii> search(const ii &ld, const ii &ru) {
        vector<ii> ret;
        search(root, 0, ld, ru, ret);
        return ret;
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout.setf(ios::fixed);
    cout.precision(10);
    int n;
    cin >> n;
    KDTree kdtree;
    unordered_map<i64, int> id;
    vector<ii> ps;
    for (int i = 0; i < n; i++) {
        i64 x, y;
        cin >> x >> y;
        ps.push_back(ii(x, y));
        id[x * i64(1e9) + y] = i;
    }
    random_shuffle(ps.begin(), ps.end());
    for (ii& p: ps) {
        kdtree.insert(p);
    }
    int q;
    cin >> q;
    while (q--) {
        i64 sx, tx, sy, ty;
        cin >> sx >> tx >> sy >> ty;
        vector<ii> ret = kdtree.search(ii(sx, sy), ii(tx, ty));
        vi tmp;
        for (ii& p: ret) {
            tmp.push_back(id[p.first * i64(1e9) + p.second]);
        }
        sort(tmp.begin(), tmp.end());
        for (int t: tmp) {
            cout << t << '\n';
        }
        cout << '\n';
    }
}


Measured memory_bytes: 52492
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
using namespace std;
int main()
{
    int n,m,x,i,p[1000],y,pi,po;
    while(scanf("%d%d%d",&n,&m,&x)==3)
    {
        int a=0,b=0;
        memset(p,0,sizeof(p));
        for(i=0;i<m;i++)
        {
            scanf("%d",&y);
            p[y]=1;
        }
        if(x>n)
            pi=n+1,po=x;
        else
            pi=x+1,po=n;
        for(;pi<=po;pi++)
        {
            if(p[pi])
                a++;
        }
        for(pi=x-1;pi>=0;pi--)
        {
            if(p[pi])
                b++;
        }
        printf("%d\n",a>b?b:a);
    }
    return 0;
}


Measured memory_bytes: 128
#pragma GCC optimize "-O3"
#pragma GCC target ("avx")
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())
signed gcd(int a, int b){return b?gcd(b,a%b):a;}
signed lcm(int a, int b){return a*b/gcd(a,b);}

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int a,b,k;
    cin >> a >> b >> k;
    for(int i=100;i<=100;--i)
    {
        if(a%i==0&&b%i==0)
        {
            k--;
        }
        if(k==0)
        {
            cout << i << endl;
            break;
        }
    }
}


Measured memory_bytes: 256
import heapq
if __name__ == '__main__':
    N, M = map(int, input().split())
    A = list(map(lambda x: int(x) * (-1), input().split()))
    heapq.heapify(A)
    for _ in range(M):
        tmp = heapq.heappop(A)
        heapq.heappush(A, -(-tmp // 2))
    print(-sum(A))

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

long long t[200009];

int main()
{
  int N;
  long long T;
  cin >> N >> T;
  for(int i=0;i<N;i++) cin >> t[i];

  long long total_time = 0;
  for(int i=0;i<N-1;i++)
  {
    if(t[i+1]-t[i] < T) total_time += t[i+1]-t[i];
    else total_time += T;
  }
  total_time += T;
  cout << total_time << endl;
}


Measured memory_bytes: 1792
while True:
    try:
        a, b, c, d, e, f = map(float, input().split())
    except:
        break
    
    if b==0:
        x = c/a
        y = (f-d*x)/e
    
    elif e==0:
        x = f/d
        y = (c-a*x)/b
    
    else:
        x = (b*f-c*e)/(b*d-a*e)
        y = c/b - a*x/b
    
    if x==0:
        print(f'{abs(x):.3f} {y:.3f}')
    elif y==0:
        print(f'{x:.3f} {abs(y):.3f}')
    else:
        print(f'{x:.3f} {y:.3f}')


Measured memory_bytes: 5604
#include<stdio.h>
#include <stdlib.h>

int min(int now, int k) {
	int a = 2 * now;
	int b = now + k;
	if(a > b){
		return b;
	}
	else{
		return a;
	}
}

int main(void) {
  int N, K;
  scanf("%d %d", &N, &K);
	int x = 1;
	int y;
	int i;
	
	for(i=0; i <N; i++) {
		y = min(x, K);
		x = y;
	}

	printf("%d\n", y);

	return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF (1LL << 55)
#define MOD (1000 * 1000 * 1000 + 7)
#define maxn 200111

typedef long long ll;
typedef long double ld;

int a[maxn];
int b[maxn];
int ans, n;

void fun(int x){
	if(x == n){
		bool sod = 0;
		for(int i = 0; i < n; i++){
			if(b[i] % 2 == 0)
				sod = 1;
		}
		ans += sod;
		return;
	}
	for(int i = -1; i <= 1; i++){
		b[x] = a[x] + i;
		fun(x + 1);
	}
}



int main(){
	scanf("%d", &n);
	for(int i = 0; i < n; i++)
		scanf("%d", a + i);

	fun(0);
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
using namespace std;
int n,c,f[60][60],a[1000][1000],k[3][100],ans=1e9;
int main()
{
	scanf("%d%d",&n,&c);
	for(int i=1;i<=c;++i)
		for(int j=1;j<=c;++j) cin>>f[i][j];
	for(int i=1;i<=n;++i)
	{
		for(int j=1;j<=n;++j)
		scanf("%d",&a[i][j]);
	}
	int p=0;
	for(int i=1;i<=n;++i,p=(p+1)%3)
	{
		int x=1,y=i;
		for(int j=0;x+j<=n&&y-j>=1;++j)
		for(int z=1;z<=c;++z)
		{
			if(a[x+j][y-j]!=z)
			k[p][z]+=f[a[x+j][y-j]][z];
		}
	}
	for(int i=2;i<=n;++i,p=(p+1)%3)
	{
		int x=i,y=n;
		for(int j=0;x+j<=n&&y-j>=1;++j)
		for(int z=1;z<=c;++z)
		{
			if(a[x+j][y-j]!=z)
			k[p][z]+=f[a[x+j][y-j]][z];
		}
	}
	for(int t1=1;t1<=c;++t1)
		for(int t2=1;t2<=c;++t2)
			for(int t3=1;t3<=c;++t3)
			{
				if(t1==t2||t2==t3||t1==t3) continue;
				int tmp=min(k[1][t1]+k[2][t2]+k[0][t3],min(k[1][t1]+k[0][t2]+k[2][t3],min(k[2][t1]+k[1][t2]+k[0][t3],min(k[2][t1]+k[0][t2]+k[1][t3],min(k[0][t1]+k[2][t2]+k[1][t3],k[0][t1]+k[1][t2]+k[2][t3])))));
				ans=min(ans,tmp);
		}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 2176
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int x = Integer.parseInt(sc.next());
        int y = Integer.parseInt(sc.next());

        // 主処理
        int result = 0;
        int diff = Math.abs(Math.abs(x) - Math.abs(y));

        if (diff == 0 && x != y) {
            result++;

        } else if (x < y) {
            if (x < 0 && 0 < y) {
                result++;
            }
            result += diff;

        } else if (y < x) {
            if (x < 0 || 0 < y) {
                result += 2;
            } else {
                result++;
            }
            result += diff;
        }

        // 出力
        System.out.println(result);
        sc.close();
    }
}


Measured memory_bytes: 21844
function dfs(G,D,u,p,x)
	D[u]=x
	for (v,c)=G[u]
		if v!=p
			dfs(G,D,v,u,x+c)
		end
	end
end
function f(x,y,D)
	D[x]+D[y]
end
function main()
	lines=readlines()
	N=parse(Int,shift!(lines))
	G=[Pair{Int,Int}[] for _=1:N]
	for i=2:N
		a,b,c=map(x->parse(Int,x),split(shift!(lines)))
		push!(G[a],b=>c)
		push!(G[b],a=>c)
	end
	Q,K=map(x->parse(Int,x),split(shift!(lines)))
	D=[1145141919810 for _=1:N]
	dfs(G,D,K,-1,0)
	for s=lines
		x,y=map(x->parse(Int,x),split(s))
		println(f(x,y,D))
	end
end
main()


Measured memory_bytes: 178356
#include <cstdio>
struct edge
{
 int v,next;
}e[400005];
int head[200005],add[200005],ans[200005],cnt;
void addedge(int u,int v)
{
 e[++cnt].v=v;
 e[cnt].next=head[u];
 head[u]=cnt;
}
void dfs(int u,int fa,int val)
{
 ans[u]=val;
 for(int i=head[u];i;i=e[i].next)
  if(e[i].v!=fa)dfs(e[i].v,u,val+add[e[i].v]);
}
int main()
{
 int n,q;
 scanf("%d%d",&n,&q);
 for(int i=1;i<n;i++)
 {
  int u,v;
  scanf("%d%d",&u,&v);
  addedge(u,v);
  addedge(v,u);
 }
 for(int i=1;i<=q;i++)
 {
  int x,y;
  scanf("%d%d",&x,&y);
  add[x]+=y;
 }
 dfs(1,0,add[1]);
 for(int i=1;i<=n;i++)
  printf("%d ",ans[i]);
 return 0;
}

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

#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
#define PI 3.14159265358979
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}

vector<pair<int,ll>> vec[100000];
ll cost[100000];
void dfs(int now,ll COST){
    cost[now]=COST;
    int next;
    REP(i,vec[now].size()){
        next=vec[now][i].first;
        if(cost[next]<0){
            dfs(next,COST+vec[now][i].second);
        }
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    string S;
    cin>>N>>S;
    REP(i,S.length()){
        cout<<char('A'+(S[i]-'A'+N)%26);
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3584
import sys
from collections import deque

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')
in_nl = lambda: list(map(int, readline().split()))
in_nl2 = lambda H: [in_nl() for _ in range(H)]
in_map = lambda: [s == ord('.') for s in readline() if s != ord('\n')]
in_map2 = lambda H: [in_map() for _ in range(H)]
in_all = lambda: map(int, read().split())


INF = 10 * 5


def warshall_floyd(V, cost):
    for k in range(V):
        for i in range(V):
            for j in range(V):
                if cost[i][k] != INF and cost[k][j] != INF:
                    cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j])


def main():

    N, K = in_nn()

    G = [[INF] * N for _ in range(N)]
    ans = []

    for i in range(1, N):
        G[0][i] = 1
        G[i][0] = 1
        ans.append((1, i + 1))

    warshall_floyd(N, G)

    comb = []
    for i in range(N):
        for j in range(i + 1, N):
            if G[i][j] == 2:
                comb.append((i + 1, j + 1))

    comb = deque(comb)
    max_k = len(comb)

    if max_k < K:
        print(-1)
        exit()

    while max_k > K:
        max_k -= 1
        ans.append(comb.popleft())

    print(len(ans))
    for i, j in ans:
        print(i, j)


if __name__ == '__main__':
    main()


Measured memory_bytes: 74884
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<stack>
#include<map>
#include<queue>
#include<vector>
#include<cmath>
#include<set>
#include<utility>
#define inf 0x3f3f3f3f
#define lowbit(x) (x&-x)
typedef long long ll;

const int maxn=1e5+5;
const int mod=1e9+7;

using namespace std;
typedef pair<int,int>P;

char s[maxn];

int main()
{
    scanf("%s",s+1);
    int len=strlen(s+1);
    if(s[len]=='s')
        s[len+1]='e',s[len+2]='s';
    else
        s[len+1]='s';
    printf("%s",s+1);
}


Measured memory_bytes: 3244
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n = ni()
ans = ''
while n != 0:
    r = n % 2
    if r < 0:
        r += 2
    n = (n - r) // (-2)
    ans += str(r)
if ans == '':
    print(0)
else:
    print(ans[::-1])

Measured memory_bytes: 3696
package main

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

//scanで一行づつ読み込む
var sc = bufio.NewScanner(os.Stdin)
var wtr = bufio.NewWriter(os.Stdout)

//sort
// array := []int{5, 1, 4, 2, 3}
// sort.Sort(sort.IntSlice(array))

func main() {
	// A := strings.Split(nextLine(), " ")

	X := strings.Split(nextLine(), " ")

	// Z := strings.Split(nextLine(), " ")
	// n, _ := strconv.Atoi(input[0])

	// H, _ := strconv.Atoi(X[0])
	// W, _ := strconv.Atoi(X[1])
	// K, _ := strconv.Atoi(X[2]) //strconv.ParseInt(X[2], 10, 64)

	// Y := strings.Split(nextLine(), " ")

	// arr := make([][]bool, H)
	// for i := 0; i < H; i++ {
	// 	arr[i] = make([]bool, W)
	// }
	// for i := 0; i < K; i++ {
	// 	Y := strings.Split(nextLine(), " ")
	// 	r, _ := strconv.Atoi(Y[0])
	// 	c, _ := strconv.Atoi(Y[1])
	// 	arr[r-1][c-1] = true
	// }

	/*文字列連結高速化
	初期化:buf := make([]byte, 0,N+1)
	連結:buf=append(buf,str)
	出力:string(buf)
	*/
	// sort.Sort(sort.Reverse(dp[M][N]))

	ok := false

	y := X[0][0:4]
	m := X[0][5:7]
	d := X[0][8:10]

	mm := 0
	dd := 0
	yy, _ := strconv.Atoi(y)
	// strings.Join(y, "")
	if len(m) > 1 {
		mm, _ = strconv.Atoi(m)
	} else {
		mm, _ = strconv.Atoi(m[1:])
	}
	if len(d) > 1 {
		dd, _ = strconv.Atoi(d)
	} else {
		dd, _ = strconv.Atoi(d[1:])
	}

	if yy > 2019 {
		ok = true
	} else if yy == 2019 && mm > 4 {
		ok = true
	} else if yy == 2019 && mm == 4 && dd > 30 {
		ok = true
	}

	if !ok {
		fmt.Fprintln(wtr, "Heisei")

	} else {
		fmt.Fprintln(wtr, "TBD")

	}

	// fmt.Fprintln(wtr, mini)

	_ = wtr.Flush()
}

func culc(a, b, c, d int64) (ret int64) {
	ret = abs(a-c) + abs(b-d)
	return
}

func chmax(a *string, b string) {
	if len(*a) < len(b) {
		*a = b
	} else if len(*a) == len(b) && *a < b {
		*a = b
	}
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func min(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}
func max(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}
func com(a, b int) int {

	if a > b {
		return 0
	}
	return 0 //abs(a - b)
}

func abs(a int64) int64 {
	if a < 0 {
		return a * -1
	}
	return a
}
func sum(a []int) (sum int) {
	for _, num := range a {
		sum += num
	}
	return
}

type item struct {
	x int
	// y     int
	// point int
}

type que []item

func (p que) Len() int {
	return len(p)
}

func (p que) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p que) Less(i, j int) bool {

	// return p[i].point > p[j].point //p[i].x+p[i].y > p[j].x+p[j].y
	return p[i].x < p[j].x
}

func (p que) Push(in int) {
	p = append(p, item{x: in})
	sort.Sort(p)
}

func (p que) Pop() int {
	res := p[0].x
	p = p[1:]
	return res
}

func (p que) Peek() int {
	return p[0].x
}


Measured memory_bytes: 640
n,k = map(int,input().split())
a = list(map(int,input().split()))

a_dic = {}

for i in range(n):
    if a[i] not in a_dic:
        a_dic[a[i]] = 0
    a_dic[a[i]] += 1

a_val = sorted(a_dic.values(),reverse = True)

print(sum(a_val[k:]))




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

int main() {
    int y, m, d, n;
    scanf("%d/%d/%d", &y, &m, &d);
    n = (y * 12 + m) * 31 + d;
    if(n <= (2019*12+4)*31+30)
        cout << "Heisei" << endl;
    else
        cout << "TBD" << endl;
    return 0;
}


Measured memory_bytes: 256
/*hello! guys~*/
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int k,n,a[200001],mmin,mmax=0;
	cin>>k>>n;
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		if(i==0)mmin=a[0];
		if(i>0){
		if(mmax<a[i]-a[i-1])mmax=a[i]-a[i-1];}
		if(i==n-1)if(mmax<a[0]+k-a[i])mmax=a[0]+k-a[i];
	}
	printf("%d",k-mmax);
}

Measured memory_bytes: 1024
#include<iostream>
#include<sstream>
#include<string>
#include<cstdio>
using namespace std;
int main(){
long n,m,i,j;
string s,t;
stringstream ss;
string::size_type k;
char mm[9];
cin>>n;
for(i=0;i<n;i++){
cin>>m;
cout<<"Case "<<i+1<<":"<<endl;
for(j=0;j<10;j++){
sprintf(mm,"%08d",m*m);
s=string(mm);
t=s.substr(2,4);
k=t.find_first_not_of('0');
if(k==string::npos)cout<<'0'<<endl;else cout<<t.substr(k)<<endl;
ss.str("");ss.clear();
ss<<t;
ss>>m;
}
}
return 0;
}

Measured memory_bytes: 1276
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#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 int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
#define iter(v,ite) for(auto ite=(v).begin();ite!=(v).end();ite++)
#define mimunum(v,x) distance((v).begin(),lower_bound((v).begin(),(v).end(),x))

char s[200005];
int main(void){
	int sn=0,ans=0;
	scanf("%s",s);
	int ls=strlen(s);
	rep(i,ls){
		if(s[i]=='S')sn++;
		else{
			if(sn)sn--;
			else ans++;
		}
	}
	printf("%d\n",sn+ans);
	return 0;
}






Measured memory_bytes: 1020
import java.util.*;

class Main{
    public static void main(String args[]){
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        long[] a = new long[N];
        for (int i=0; i<N; i++) {
            a[i] = scan.nextInt();
        }

        long sum = 0;
        for (int i=0; i<N; i++) {
            sum += a[i];
        }

        for (int i=0; i<N; i++) {
            a[i] = Math.abs(N * a[i] - sum);
        }

        long min = 999999;
        int ans = 0;
        for (int i=0; i<N; i++) {
            if (a[i] < min) {
                min = a[i];
                ans = i;
            }
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 21844
//#include <stdio.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>

using namespace std;

#define ll long long
void solve()
{
    ll X;
    cin >> X;
    while (1)
    {
        bool isPrime = true;
        for (ll i = 2; i < X; i++)
        {
            if (X % i == 0)
            {
                isPrime = false;
                break;
            }
        }

        if (isPrime)
        {
            cout << X << endl;
            return;
        }

        X++;
    }

    return;
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
A - Still TBD
https://atcoder.jp/contests/abc119/tasks/abc119_a

"""
import sys


def main(args):
    S = input()
    yyyy, mm, dd = map(int, S.split('/'))
    if yyyy >= 2019 and mm >= 5:
        print('TBD')
    else:
        print('Heisei')

if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 2940
#define _USE_MATH_DEFINES


#include <iostream>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <numeric>
#include <array>
#include <set>
#include <sstream>
#include <cmath>

using namespace std;

typedef long long LL;


vector<vector<LL>> creat_matrix(LL h, LL w) {
	LL _temp;
	vector<vector<LL>> mat;
	for (LL i = 0; i < h; ++i) {
		vector<LL> vec;
		for (LL j = 0; j < w; ++j) {
			cin >> _temp;
			vec.emplace_back(_temp);
		}
		mat.emplace_back(vec);
	}
	return mat;
}


vector<vector<LL>> inner_product(vector<vector<LL>> X, vector<vector<LL>> Y) {
	size_t n = X.size();
	size_t m = X[0].size();
	size_t l = Y[0].size();

	vector<vector<LL>> mat(n, vector<LL>(l, 0));
	for (LL i = 0; i < n; ++i) {
		for (LL j = 0; j < m; ++j) {
			for (LL k = 0; k < l; ++k) {
				mat[i][k] += X[i][j] * Y[j][k];
			}
		}
	}
	return mat;
}


void show_matrix(vector<vector<LL>> mat) {
	size_t len = mat[0].size();
	for (auto&& t : mat) {
		for (LL i = 0; i < len; ++i) {
			printf("%d", t[i]);
			if (i != (len - 1)) printf(" ");
		}
		printf("\n");
	}
}


vector<string> split(const string& s, char delim) {
	vector<string> elems;
	stringstream ss(s);
	string item;

	while (getline(ss, item, delim)) {
		if (!item.empty()) {
			elems.push_back(item);
		}
	}

	return elems;
}


vector<string> results;

string run_command(string& str, vector<string>& commands) {
	auto _str = str;
	int a = stoi(commands[1]);
	int b = stoi(commands[2]);
	int print_num = b - a + 1;
	
	if (commands[0] == "print") {
		results.emplace_back(_str.substr(a, print_num));
	}
	else if (commands[0] == "reverse") {
		reverse(_str.begin() + a, _str.begin() + b + 1);
	}
	else if (commands[0] == "replace") {
		_str.replace(_str.begin() + a, _str.begin() + b + 1, commands[3]);
	}

	return _str;
}


int main() {
	double a, b, C;
	cin >> a >> b >> C;


	C = M_PI * C / 180;
	double S = 0.5 * a * b * sin(C);
	double c = sqrt(pow(a, 2.0) + pow(b, 2.0) - 2.0 * a * b * cos(C));
	double L = a + b + c;
	double h = b * sin(C);

	printf("%lf\n%lf\n%lf\n", S, L, h);
	return 0;
}



Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using ll = int64_t;
using ul = uint64_t;
using namespace std;

void solve() {
  int n;
  cin >> n;

  int sum = 1;
  int odd = 1;
  rep(_, n) {
    int n;
    cin >> n;
    if (n % 2 == 0)
      odd *= 2;
    else
      odd *= 1;
    sum *= 3;
  }
  cout << sum - odd << endl;
}

void wrapper() {
  rep(i, 4) {
    cout << "[TEST " << (i + 1) << "]\n";
    solve();
    cout << "\n";
  }
}

int main() {
  fastIO;
  // wrapper();
  solve();
}


Measured memory_bytes: 3608
n = int(input())
h = list(map(int, input().split()))
ans = 0
tmp = 0
j = h[0]
h.append(1000000001)
for i in range(1, len(h)):
    if j >= h[i]:
        tmp += 1
    else:
        ans = max(ans, tmp)
        tmp = 0
    j = h[i]
print(ans)


Measured memory_bytes: 14224
//たてなが

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

int main(){
    int H,W;
    cin>>H>>W;
    vector<vector<char>>origin(H,vector<char>(W));
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin>>origin.at(i).at(j);
        }
    }
    vector<vector<char>>data(H*2,vector<char>(W));
    for(int i=0;i<2*H;i++){
        for(int j=0;j<W;j++){
            data.at(i).at(j)=origin.at(i/2).at(j);
        }
    }
    for(int i=0;i<H*2;i++){
        for(int j=0;j<W;j++){
            cout<<data.at(i).at(j);
        }
        cout<<endl;
    }
   return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    string x;
    cin >> x;

    int diff = 753;
    for (int i=0; i<x.length()-2; i++)
    {
        int y = (x[i] - '0') * 100 + (x[i+1] - '0') * 10 + (x[i+2] - '0');
        diff = min(diff, abs(753 - y));
    }
    
    cout << diff << endl;
    return 0;
}

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

for i in range(N):
    x[i] = abs(X - x[i])

def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a%b)

d = x[0]
for i in range(1, N):
    d = gcd(d, x[i])

print(d)

Measured memory_bytes: 14252
# coding: utf-8
# Your code here!

# 互除法で最大公約数を求めて, 最小公倍数に変換する

A, B = map(int, input().split())

if A >= B : 
    L = A
    S = B
else : 
    L = B
    S = A

while True : 
    mod = L % S
    if mod != 0 : 
        L = S
        S = mod
    else : 
        GCD = S
        break

LCM = int((A/GCD) * (B/GCD) * GCD)

print(LCM)

Measured memory_bytes: 3060
#include<stdio.h>
#include<math.h>
int main()
{
    int n,a[100];
    scanf("%d",&n);
    int x=n,i=0;
    while(x!=0)
    {
        int c,d,f;
        c=x/10;
        a[i]=x-c*10;
        x/=10;
        i++;
    }
    int j,s=0;
    for(j=0;j<i;j++) s+=a[j];
    if(n%s==0) printf("Yes\n");
    else printf("No\n");
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
 ll n,i,j;
 cin>>n;
 ll arr[n];
 for(i=0;i<n;i++)
 {
  cin>>arr[i];
 }
 ll count=0;
 ll maxi=0;
 for(j=0;j<n-1;j++)
 {
  if(arr[j]>=arr[j+1])
  {
   count++;
  }
  else
  {
    maxi=max(maxi,count);
    count=0;
  }
 }
  maxi=max(maxi,count);
 cout<<maxi;
 return 0;
}

Measured memory_bytes: 1024
# inverse x^(-1)
def inv(x):
    global mod
    return pow(x,mod-2,mod)

mod=10**9+7
N = int(input())
C = [0]
C.extend(sorted(list(map(int,input().split())), reverse=True)) # 1-indexed, 降順

# print(C)
# C[i]が最後からj番目に操作される（コストが C[i]*j 掛かる）のは，c[1]~C[i-1]にj-1個操作すべきもの，すなわち，C[i]以上のものがあるとき。
# C[i+1]~C[N]の選び方は自由。
# ⇒ combi(i-1, j-1)*2**(N-i) を掛ける。
# 総和を計算すると，結局，2**N * Σ[i=1->N](2**(N-i)*Ci*(2**(i-2)*(i-1) + 2**(i-1))) になる

pow2 = [1]
for k in range(1, N+1):    
    pow2.append(pow2[-1] * 2 % mod)

# print(pow2)

ans=0
for i in range(1, N+1):
    temp = pow2[N - i] * C[i] * ((0 if i == 1 else (pow2[i - 2] * (i - 1))) + pow2[i - 1]) % mod
    ans = (ans + temp) % mod

ans = ans * pow2[N] % mod

print(ans)

Measured memory_bytes: 25772
#include <stdio.h>

int a,b,c;

int main() {
 scanf("%d %d %d",&a,&b,&c);
 if(a+b==c){printf("Yes");}
  
 else{
   if(b+c==a){printf("Yes");}
   
   else{
     if(a+c==b){printf("Yes");}
   
    else{printf("No");}}}
 
 
 
 
 
 
 return 0;
}

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

int main(){
  string S;
  cin >> S;
  int N=S.size();
  int64_t sum=0;
  string T="";
  vector<string> v;
  for(int64_t tmp=0;tmp<(1<<N-1);tmp++){
    bitset<9> s(tmp);
    for(int64_t i=0;i<N-1;i++){
      T+=S.at(i);
      if(s.test(i)){
        v.push_back(T);
        T="";
      }
    }
    T+=S.at(N-1);
    v.push_back(T);
    for(int64_t i=0;i<v.size();i++){
      sum+=stoll(v.at(i));
    }
    v.clear();
    T="";
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
static const ll mod = 1000000007;
/* ちゃんと考えて実装して問題なくACできた時嬉しいよ！！ */

int main(void){
    ll a,b,x;
    cin >> a >> b >> x;

    ll ans = 0;

    if(a!=0){
        ans = (b/x) - (a-1)/x;
    }
    else{
        ans = (b/x) + 1;
    }

    cout << ans;
    return 0;
}

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

using namespace std;

typedef long long ll;

const int __SIZE = 1 << 18;
char ibuf[__SIZE], *iS, *iT;

#define ge (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS++)) : *iS++)
#define ri read_int()
#define rl read_ll()
#define FILE(s) freopen(s"in", "r", stdin), freopen(s"out", "w", stdout)

template<typename T>
inline void read(T &x) {
	char ch, t = 0; x = 0;
	while(!isdigit(ch = ge)) t |= ch == '-';
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = ge;
	x = t ? -x : x;
}
inline int read_int() { int x; return read(x), x; }
inline ll read_ll() { ll x; return read(x), x; }

int main() {
	int n = ri;
	long double a = ri;
	long double d = ri;
	long double res = 0;
	while(n) {
		res += a + ((n << 1) - 1) / 2. * d;
		long double tmpa = 1. * (((n + 1) << 1) * a + 5. * d) / (n << 1);
		long double tmpd = 1. * (((n << 1) + 4) * d) / (n << 1);
		a = tmpa, d = tmpd, --n;
	}
	printf("%.10Lf\n", res);
	return 0;
}


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

using namespace std;

#define pb(n)	push_back(n)
#define mp(n,m) make_pair(n,m)
#define fi 	first
#define se 	second
#define all(r) (r).begin(),(r).end()

#define REP(i,s,e)	for(int i=(s); i<(e); i++)
#define rep(i,n)	REP(i,0,n)
#define REPE(i,s,e)	for(int i=s; i>e; i--)
#define repe(i,n)	REPE(i,n,-1)


typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

typedef vector<vi> vii;

const int IMAX = ((1 << 30) - 1) * 2 + 1;
const int INF = 100000000;
const double EPS = 1e-10;
//int mod=1000000007








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

}

Measured memory_bytes: 1160
#include<iostream>
#include <string>
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define endl "\n"
#define sz(v) (int)(v.size())
#define len(s) (int)(s.length())
#define M 1000000007
#define all(v) v.begin(),v.end()
#define fr(a,b,c) for(ll i=a;i<=b;i+=c)
#define inarr(arr,n); for(ll i=0;i<n;i++) cin >> arr[i];
#define outarr(arr,n); for(ll i=0;i<n;i++) cout<<arr[i]<<" ";
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const ll inf = 9e18;
const ld pi = 2*acos(0.0); 
using namespace std;
ll power(ll a,ll n) 
{
    if(n==0){
        return 1;
    }
    ll p=power(a,n/2) % M;
    p = (p * p) % M;
    if (n%2==1)
    {
        p=(p*a)%M;
    }
    return p;
}
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
}
const int N=1e6+5;
vector <ll> sieve(N,0); 
void si() 
{
    sieve[1]=1;
    for(int i=2;i<N;i++){
        if(sieve[i]==0){
            for(int j=i;j<N;j+=i){
                sieve[j]=i;
            }
        }
    }
}
int isprime(ll n){
    for(ll i=2;i<=sqrt(n);i++){
        if(n%i==0){
            return 0;
        }
    }
    return 1;
}
int main(){
    ios;
    string s,t;
    cin>>s>>t;
    if(len(t)!=len(s)+1){
        cout<<"No"<<endl;
        return 0;
    }
    int flag=1;
    for(int i=0;i<len(s);i++){
        if(t[i]!=s[i]){
            flag=0;
            break;
        }
    }
    if(flag){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 10980
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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;
const ll mod=1e9+7;

int main(){
    string s;
    cin >> s;
    ll n=s.length();
    if(n==2){
        cout << s << endl;
    }
    else{
        reverse(s.begin(),s.end());
        cout << s << endl;
    }
    return 0;
}


Measured memory_bytes: 3580
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
#define all(X) (X).begin(), (X).end()
#define reset(X) memset(X, 0, sizeof(X))
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define endl '\n'
#define fi first
#define se second



using namespace __gnu_pbds;
using namespace std;
// const int mod=1e9+7;
 const int mod=998244353;
const int INF=4e18+10;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define readv(x, n) vector<int> x(n); for(auto &i:x) cin>>i; 


int pow(int a, int b)
{
    int prod=1;
    int mult=a%mod;
    while(b!=0)
    {
        if(b%2)
        {
            prod*=mult;
            prod%=mod;
        }
        mult*=mult;
        mult%=mod;
        b/=2;
    }
    return prod;
}
int mod_inv(int q, int mod)
{
    return pow(q, mod-2);
}





signed main()

{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);  
       cout.tie(NULL);
     #ifndef ONLINE_JUDGE
        if(fopen("INPUT.txt","r"))
        {
        freopen ("INPUT.txt" , "r" , stdin);
        freopen ("OUTPUT.txt" , "w" , stdout);
        }
     #endif
    auto clk=clock(); 
    // -------------------------------------Code starts here---------------------------------------------------------------------     
    int n , m;
    cin>>n>>m;
    cout<<(n*(n-1)/2 + m*(m-1)/2)<<endl;


    // -------------------------------------Code ends here------------------------------------------------------------------

    clk = clock() - clk;
    cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
    return 0;
 }


Measured memory_bytes: 256
/*
 * AOJ 2164: Revenge of the Round Table
 * ?¢?????????\????????????n????????´??????????????????????±????????????¶?????¨?????????????¶????k?????????????°??§???????????????¬???????±??????????????§????????§???????
 * ?±???????P??lya?????°+DP
 * ??????????????¬i?????????????????°???gcd(n,i)???????????¨????±????????????????????????°i????????????d[i]?????¶?????£??\??¬???L=|G|*(d[c(p1)]+d[c(p2)]+...+d[c(pk)])???t[0/1][i][j]??¨?????\??????????§???????i?????\j???0???????°?????????°???d[i]?????\0????????´??????????????????0????????°???p??????????????±t[1][i-p][0~k-p]??¬?§??????°????????\d[i]=Sum(t[1][i-p][0~k-p])+t[1][i][1~k]???
 */


#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

typedef long long LL;

const LL MOD = 1000003ll;
LL t[2][1010][1010], s[2][1010][1010], d[1010];

void Dp(LL n, LL k) {
  memset(t, 0, sizeof(t));
  memset(s, 0, sizeof(s));
  memset(d, 0, sizeof(d));


  t[0][1][1] = 1;
  s[0][1][1] = 1;

  for (LL i = 2; i <= n; ++i) {
    for (int c = 0; c < 2; ++c) {
      t[c][i][1] = s[c][i][1] = s[1 - c][i - 1][min(k, i - 1)];
    }
    for (LL j = 2; j <= min(i, k); ++j) {
      for (int c = 0; c < 2; ++c) {
        t[c][i][j] = t[c][i - 1][j - 1];
        s[c][i][j] = (s[c][i][j - 1] + t[c][i][j]) % MOD;
      }
    }
    for (LL j = min(i, k) + 1; j <= k; ++j) {
      for (int c = 0; c < 2; ++c) {
        s[c][i][j] = s[c][i][j - 1];
      }
    }
  }

//  for (LL i = 1; i <= n; ++i) {
//    for (LL j = 1; j <= k; ++j) {
//      for (int c = 0; c < 1; ++c) {
//        printf("%d %lld %lld  : %lld %lld\n", c, i, j, t[c][i][j], s[c][i][j]);
//      }
//    }
//  }

  for (LL i = 1; i <= n; ++i) {
    d[i] = s[1][i][min(i, k)];
//    printf("B - d[%lld] = %lld\n", i, d[i]);
//    if (i <= k) ++d[i];
    for (LL p = 1; p <= min(k - 1, i - 2); ++p) {
      d[i] = (d[i] + s[1][i - p][min(k - p, i - 1 - p)]) % MOD;
    }
//    printf("d[%lld] = %lld\n", i, d[i]);
  }
}

LL Inverse(LL a, LL p) {
  if (a == 1) return 1;
  return ((-p / a * Inverse(p % a, p)) % p + p) % p;
}

LL Gcd(LL a, LL b) {
  for (LL t; t = b;) {
    b = a % b;
    a = t;
  }
  return a;
}

int main() {
//  freopen("/Users/yogy/acm-challenge-workbook/db.in", "r", stdin);
  LL n, k;
  while (scanf("%lld%lld", &n, &k) != EOF && n + k > 0) {
    if (n < k) k = n;
    LL ans = 0;
    Dp(n, k);
    for (LL i = 0; i < n; ++i) {
      ans = (ans + d[Gcd(n, i)]) % MOD;
    }
//    printf("%lld\n", ans);
    ans = (ans * 2 * Inverse(n, MOD)) % MOD;
    if (k >= n) ans+=2; // ????¬???¨??¨??????
    printf("%lld\n", ans);
  }
  return 0;
}

Measured memory_bytes: 34620
# 0114

def gcd(a, b):
	if b == 0: return a
	return gcd(b, a % b)

def lcm(a, b):
	return a * b / gcd(a, b)

def times(a, m):
	c = 1
	x = a * 1 % m
	while x != 1:
		x = a * x % m
		c += 1
	return c

while True:
	a1, m1, a2, m2, a3, m3 = map(int, input().split())
	
	if sum([a1, m1, a2, m2, a3, m3]) == 0:
		break

	c1 = times(a1, m1)
	c2 = times(a2, m2)
	c3 = times(a3, m3)

	print(int(lcm(c1, lcm(c2, c3))))

Measured memory_bytes: 6732
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

	static class ProblemC {
		public void solve(int testNumber, FastScanner in, PrintWriter out) {
			int n = in.nextInt();
			int[] t = new int[n + 1];
			int[] x = new int[n + 1];
			int[] y = new int[n + 1];
			for (int i = 0; i < n; i++) {
				t[i + 1] = in.nextInt();
				x[i + 1] = in.nextInt();
				y[i + 1] = in.nextInt();
				if (!can(t[i], x[i], y[i], t[i + 1], x[i + 1], y[i + 1])) {
					out.println("No");
					return;
				}
			}
			out.println("Yes");
		}

		private boolean can(int t1, int x1, int y1, int t2, int x2, int y2) {
			int dx = Math.abs(x1 - x2);
			int dy = Math.abs(y1 - y2);
			int dt = t2 - t1;
			if (dt < dx + dy) {
				return false;
			}
			dt -= dx + dy;
			return dt % 2 == 0;
		}

	}

	static class FastScanner {
		private BufferedReader in;
		private StringTokenizer st;

		public FastScanner(InputStream stream) {
			in = new BufferedReader(new InputStreamReader(stream));
		}

		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(in.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

	}
}



Measured memory_bytes: 41508
#include <stdio.h>
#include <string.h>

int main(){
  char str[101];
  int i, j, k, len, c;
  while(scanf("%s", str) != EOF){
    char result[101] = {};
    len = strlen(str);
    j = 0;
    for(i = 0;i < len;i++){
      if(str[i] == '@'){
	c = str[i + 1] - '0';
	for(k = 0;k < c;k++)
	  result[j + k] = str[i + 2];
	i += 2;
	j += c;
      }
      else result[j++] = str[i];
    }
    puts(result);
  }
  return 0;
}

Measured memory_bytes: 524
n=int(input())
l=[["a"]]+[[] for i in range(9)]
for i in range(9):
  for j in l[i]:
    k=len(set(list(j)))
    for h in range(k+1):
      l[i+1].append(j+chr(97+h))
for i in l[n-1]:print(i)


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

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <stdio.h>
using namespace std;
typedef long long ll;
int main() {
	int A,B;
	cin>>A>>B;
	if(A%3==0){
			cout<<"Possible"<<endl;
		}else{
			if(B%3==0){
				cout<<"Possible"<<endl;
			}else{
				if((A+B)%3==0){
					cout<<"Possible"<<endl;
				}else{
					cout<<"Impossible"<<endl;
				}
			}
		}

	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {

  static String s, t;

  public static void main(String[] args) throws Exception {

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    PrintWriter out = new PrintWriter(System.out);

    //String[] in = br.readLine().split(" ");
    s = br.readLine();
    t = br.readLine();

    /*
    =====templates=====
    ===inputs===
    static int n;
    in = br.readLine().split(" ");
    int[] a = Stream.of(in).mapToInt(Integer::parseInt).toArray();

    int n = Integer.parseInt(in[0]);
    long n = Long.parseLong(in[0]);
    int[] a = Stream.of(in).mapToInt(Integer::parseInt).toArray();

    ===outputs===
    PrintWriter out = new PrintWriter(System.out);
    out.println(ans);
    out.flush();
    */

    br.close();

    boolean flag = true;
    int n = s.length();
    int m = t.length();

    flag = s.equals(t.substring(0, n));

    out.println(flag ? "Yes" : "No");

    out.flush();

  }
}

Measured memory_bytes: 32616
#define _USE_MAT_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define INF 1e9
#define MOD 1000000007;//1e9+7

int main() {
    long long N, K;
    cin >> N >> K;
    for (int i = 0;; i++){
        if (pow(K, i) <= N&&N < pow(K, i + 1)) {
            cout << i + 1;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
const int INF = 1e9, MOD = 1e9 + 7; /// think
const ll LINF = 1e18;


const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

template<class T> bool umin (T &a, T b) {return a > b ? (a = b, true) : false; }
template<class T> bool umax (T &a, T b) {return a < b ? (a = b, true) : false; }

main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int d = h2 * 60 + m2 - h1 * 60 - m1;
    cout << max(0, d - k) << '\n';
}


Measured memory_bytes: 3628