akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
// using namespace atcoder;
void Main()
{
    ll n;
    cin >> n;
    vector<ll> A(n);
    rep(i, n) cin >> A[i];

    ll minus = 0, zero = 0;
    rep(i, n) {
        if (A[i] < 0) minus++;
        if (A[i] == 0) zero++;
    }

    ll res = 0;
    if (zero >= 1 || minus % 2 == 0) {
        rep(i, n) res += abs(A[i]);
    }
    else {
        // かならず1個だけ-になる
        ll v = 1e10;
        rep(i, n) {
            v = min(v, abs(A[i]));
        }

        rep(i, n) res += abs(A[i]);
        res -= 2 * v;
    }
    put(res);
}
signed main(){ Main();return 0;}

Measured memory_bytes: 3972
#include<bits/stdc++.h>
#define MAX_N 100011
#define N MAX_N
#define rank dfasfds
using namespace std;
typedef long long ll;
typedef vector<int>::iterator V;
int par[MAX_N],rank[MAX_N];
ll val[MAX_N];
vector<int> G[N];

void init(int n){for(int i=0;i<N;i++)par[i]=i,rank[i]=0;}

int find(int x){
  if(par[x]==x)return x;
  return par[x]=find(par[x]);
}

bool same(int x,int y){return find(x)==find(y);}

void unite(int x,int y){
  x=find(x),y=find(y);
  if(x==y)return;
  if(rank[x]<rank[y])par[x]=y,val[y]+=val[x];
  else{
    par[y]=x;
    val[x]+=val[y];
    if(rank[x]==rank[y])rank[x]++;
  }
}

int used[N];
vector<int> path;
void dfs(int pos,int pre){
  if(used[pos]||pos!=find(pos)) {
    while(path.size())unite(0,path.back()),path.pop_back();
    return;
  }
  used[pos]=1;
  path.push_back(pos);
  for(V it=G[pos].begin();it!=G[pos].end();it++)if(*it!=pre)dfs(*it,pos);
  used[pos]=0;
  if(path.size()&&path.back()==pos) path.pop_back();
}

vector<int>col[N];
ll get_mx(int pos){
  used[pos]=1;
  ll res=0;
  for(int i=0;i<col[pos].size();i++)
    for(V it=G[col[pos][i]].begin();it!=G[col[pos][i]].end();it++)
      if(!used[find(*it)])res=max(res,get_mx(find(*it)));
  return res+val[find(pos)];
}

int main(){
  int n,m;
  cin>>n>>m;
  for(int i=0;i<n;i++) cin>>val[i];
  for(int i=0,a,b;i<m;i++){
    cin>>a>>b;a--,b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  init(n);
  dfs(0,-1);
  for(int i=0;i<n;i++) col[find(i)].push_back(i);
  cout <<get_mx(find(0))<<endl;

  return 0;
}

Measured memory_bytes: 23832
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto N = readln.chomp.to!int;
    int[] bs, cs;
    bs.length = N;
    cs.length = N;
    foreach (i, a; readln.split.to!(int[])) {
        bs[i] = a;
        ++cs[a];
    }
    bs = bs.sort().uniq().array;
    auto small = bs[0];
    if (bs.length == 1) {
        writeln(small <= N/2 || small == N-1 ? "Yes" : "No");
        return;
    } else if (bs.length > 2) {
        writeln("No");
        return;
    } else if (bs[0]+1 != bs[1]) {
        writeln("No");
        return;
    }
    writeln(cs[small] <= small && small-cs[small]+1 <= cs[small+1]/2 ? "Yes" : "No");
}

Measured memory_bytes: 4528
#include<bits/stdc++.h>
# define    all(a)              a.begin(), a.end()
#define forn(i, a, b) for (int i=a; i<b; i++)
#define pb push_back
#define mp make_pair
#define MOD int(1e9+7)
using namespace std;

typedef long long int ll;

bool cmp(int a, int b) {
    return a < b;
}

void printV(vector<int> nums) {
    for (int i: nums) {
        printf("%d ", i);// << " ";
    }
    printf("\n");
}

// void printV(vector<ll> nums) {
//     for (ll i: nums) {
//         printf("%lld ", i);// << " ";
//     }
//     printf("\n");
// }



int dir[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};

bool valid(int i, int j, int n, int m) {
    if (i >= 0 && i < n && j >=0 && j < m)
        return true;
    else 
        return false;
}

vector<int> seive(int n) {
    vector<int> prime;
    vector<bool> flag(n+1);
    int cnt = 0;
    for (int i=2; i<=n+1; i++) {
        cnt++;
        if (!flag[i]) {
            for (int j=2; j*i<=n; j++) {
                flag[i*j] = true;
                cnt++;
            }
        }
    }
    // cout << cnt << endl;
    for (int i=2; i<=n; i++)
        if (!flag[i])
            prime.pb(i);
    return prime;
}


int main() {
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
    // ios_base::sync_with_stdio(false);
    // cin.tie(0);cout.tie(0);
    // time_t start, end;
    // time(&start);
    int n;
    cin >> n;
    if (n < 1200)
    cout << "ABC" << endl;
else
cout << "ARC" << endl;

    // printV(res);
    // time(&end); 
    // double time_taken = double(end - start);
    // cout << "Time Taken: " << fixed << time_taken << setprecision(5);
    // cout << " sec" << endl;
    return 0;
}      

Measured memory_bytes: 3580
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

int n;
string s;

int main(){
	//IO("input.txt", "output.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n >> s;
	int cnt = 0;
	for(int i = 1; i < (int)s.length(); i++)
		if(s[i] != s[i - 1]) cnt++;
	cout << cnt + 1 << "\n"; 
	return 0;
}

Measured memory_bytes: 512
from Queue import Queue
mv=((-1,0),(1,0),(0,-1),(0,1))
while True:
    X,Y=map(int,raw_input().split())
    if X==Y==0:break
    tx,ty=map(int,raw_input().split())
    kx,ky=map(int,raw_input().split())
    tx,ty,kx,ky=tx-1,ty-1,kx-1,ky-1
    D=[map(int,raw_input().split()) for i in range(Y)]
    Q=Queue()
    Q.put((tx,ty,kx,ky,0))
    visited=set()
    visited.add((tx,ty,kx,ky))
    while not Q.empty():
        tx,ty,kx,ky,t=Q.get()
        if t>=100:
            print "NA"
            break
        if tx==kx and ty==ky:
            print t
            break
        for i in range(4):
            dtx,dty=tx+mv[i][0],ty+mv[i][1]
            dkx,dky=kx-mv[i][0],ky-mv[i][1]
            if dtx<0 or dtx>=X or dty<0 or dty>=Y:
                dtx,dty=tx,ty
            if dkx<0 or dkx>=X or dky<0 or dky>=Y:
                dkx,dky=kx,ky
            if D[dty][dtx]==1:
                dtx,dty=tx,ty
            if D[dky][dkx]==1:
                dkx,dky=kx,ky
            if (dtx,dty,dkx,dky) not in visited:
                visited.add((dtx,dty,dkx,dky))
                Q.put((dtx,dty,dkx,dky,t+1))
    else:
        print "NA"

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

#define LL long long
typedef pair<int, int> pii;

template< typename T > inline void read(T &x)
{
    static char _c;
    static bool _f;

    x = 0;
    _f = 0;
    _c = getchar();

    while(_c < '0' || '9' < _c) {if(_c == '-') _f = true; _c = getchar();}
    while('0' <= _c && _c <= '9') {x = (x << 1) + (x << 3) + (_c & 15); _c = getchar();}
    if(_f) x = -x;
}

template < typename T > inline void Min(T &x, T y) {if(y < x) x = y;}
template < typename T > inline void Max(T &x, T y) {if(x < y) x = y;}


#define lowbit(x) ((x) & -(x))
#define lson l,mid,id<<1
#define rson mid+1,r,id<<1|1
#define ls id<<1
#define rs id<<1|1
#define MID(l,r) ((l)+(((r)-(l))>>1))
#define fi first
#define se second
#define mk make_pair
#define pb push_back

const int INF = 0x3f3f3f3f;
const int MOD = (int) 998244353;
const int maxn = (int) 200000 + 20;
const int maxm = (int) 1000000 + 20;
const double pi = (double) acos(-1.0);
const double eps = (double) 1e-8;

inline int sig(double x) {return x < -eps ? -1 : eps < x;}
LL fp(LL a, LL n, LL m = MOD) {LL res = 1; for(; n; n >>= 1, a = a * a % m) if(n & 1) res = res * a % m; return res;}

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

void work()
{
    read(n);
    for(int i = 1; i <= n; i++) read(a[i]);
    for(int i = 1; i <= n; i++) b[i] = -INF;
    b[0] = 0;

    for(int i = 1; i <= n; i++)
    {
        int v = a[i];
        b[v] = max(b[v], b[v - 1] + 1);
    }

    int ans = 0;
    for(int i = 1; i <= n; i++) ans = max(ans, b[i]);

    if(ans < 1) cout <<-1 <<endl;
    else cout <<n - ans <<endl;
}

int main()
{
#ifdef yukihana0416
freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
#endif // yukihana0416
//    get_prime();
    int tc = 1;
//    read(tc);
    for(int ca = 1; ca <= tc; ca++)
    {
//        printf("Case #%d: ", ca);
        work();
    }
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N,P;
int A[101];
int o=0;
int z=0;
LL kaizyou(int n,int k){
   LL ans=1;
   REP(i,k){
       ans*=(n-i);
       ans/=(i+1);
   }
   return ans;
}

int main(){
    cin>>N>>P;
    REP(i,N){
        cin>>A[i];
        A[i]%=2;
        if(A[i]==0){
           z++;
        }else{
           o++;
        }
    }
    LL ans=0;
    if(P==0){
       LL oo=0;
       for(int i=0;i*2<=o;i++){
           oo+=kaizyou(o,i*2);
       }
       LL zero=0;
       for(int i=0;i<=z;i++){
           zero+=kaizyou(z,i);
       }       
       //ans++;
       ans+=(zero*oo);
       cout<<ans<<endl;
    }else{
       //cout<<o<<z<<endl;
       LL oo=0;
       for(int i=0;i*2+1<=o;i++){
           oo+=kaizyou(o,i*2+1);
       }
       LL zz=0;
       for(int i=0;i<=z;i++){
          zz+=kaizyou(z,i);
       }
       ans=zz*oo;
       cout<<ans<<endl;
    }
    return(0);
}

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

using namespace std;

int hoge[200010];

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	int n = s.length();
	array<bool, 27> used{};
	array<int, 26> idx{};
	deque<int> foo[26];
	int cur = 0, cnt = 0;
	for (int i = n - 1; i >= 0; i--) {
		hoge[i] = cur;
		used[s[i] - 'a'] = true;
		idx[s[i] - 'a'] = i;
		while (used[cur]) cur++;
		if (cur == 26) {
			cur = 0;
			cnt++;
			for (int i = 0; i < 26; i++) {
				used[i] = false;
				foo[i].push_front(idx[i]);
				idx[i] = 0;
			}
		}
	}

	cur = 0;
	while (used[cur]) {
		cur++;
	}

	string ans = "";
	ans += (char)('a' + cur);
	for (int i = 0; i < cnt; i++) {
		cur = hoge[foo[cur][i]];
		ans += (char)('a' + cur);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2196
#include<stdio.h>
int main()
{
    char ch[100000],m,n,a,b;
    int i,j=0,k;
    scanf("%d",&k);
    a=getchar();
    gets(ch);
    for(i=0;i<k;i++)
    {
        if(ch[i]!=ch[i+1])
            j++;
    }
    printf("%d\n",j);
    return 0;
}


Measured memory_bytes: 256
n = int(input())
A = [int(i) for i in input().split()]

B = []

for i, a in zip(range(1, n+1), A):
   B.append(a - i)

B.sort()
if n % 2 == 0:
    b = (B[n//2] + B[n//2-1]) // 2
else:
    b = B[n//2]

sum = 0

for i, a in zip(range(1, n+1), A):
    sum += abs(a-(b+i))
    
print(sum)

Measured memory_bytes: 26128
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
#include <string.h>
#define ll long long

int main()
{
    int A , B , C;
    scanf("%d %d %d",&A,&B,&C);

    int div = B/A;

    if (div<C)printf("%d",div);
    else printf("%d",C);


    return 0;
}


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

int main(){
	cin >> S;
	int i=0,j=S.size()-1;
	int ans = 0;
	bool judge = true;
	while(i<j){
		if(S[i]==S[j]){
			i++;
			j--;
		}else{
			if(S[i]=='x'){
				ans++;
				i++;
			}else if(S[j]=='x'){
				ans++;
				j--;
			}else{
				judge = false;
				break;
			}
		}
	}
	if(i==j){
		if(S[i]!=S[j]) judge = false; 
	}
	if(judge) cout << ans << endl;
	else cout << -1 << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

int n;
string s;
int solve(){
    vector<int>W(n+1,0),E(n+1,0);
    rep(i,n){
        if(s[i]=='E')W[i+1]=W[i];
        else W[i+1]=W[i]+1;
    }
    for(int i=n-2;i>=0;i--){
        if(s[i+1]=='W')E[i]=E[i+1];
        else E[i]=E[i+1]+1;
    }
    int ans=n;

    rep(i,n)chmin(ans,W[i]+E[i]);
    return ans;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin>>n>>s;
    cout<<solve()<<endl;    
    return 0;
}

Measured memory_bytes: 2964
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

int gcd(int a,int b)
{
	return b==0?a:gcd(b,a%b);
}

int fpow(int b,int e)
{
	if(e==0) return 1;
	if(e==1) return b;
	int tmp=fpow(b,e/2);
	if(e%2) return b*tmp*tmp;
	else return tmp*tmp;
}

int fpowm(int b,int e,int mod)
{
	if(e==0) return 1;
	if(e==1) return b;
	int tmp=fpow(b,e/2)%mod;
	if(e%2) return b*tmp%mod*tmp%mod;
	else return tmp*tmp%mod;
}

int fnd(vector<int> &ac,int tar)
{
	int hi=sz(ac),lo=-1;
	while(hi-lo>1)
	{
		int m=(hi+lo)/2;
		if(ac[m]>tar) hi=m;
		else lo=m;
	}
	return lo;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n,q; cin>>n>>q;
	string s;
	vector<int> ac;
	cin>>s;
	For(i,0,sz(s)-2)
	{
		if(s[i]=='A' && s[i+1]=='C') ac.emplace_back(i);
	}
	//for(auto i:ac) cout<<i<<" "; cout<<"\n";
	int l,r;
	For(idx,0,q-1)
	{
		cin>>l>>r;
		l--; r--;
		int a=fnd(ac,l-1),b=fnd(ac,r-1);
		cout<<b-a<<"\n";
		//cout<<a<<" "<<b<<" "<<b-a<<"\n";
	}
	return 0;
}








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

using namespace std;

int main(void){
int X;
int tmp = 3;
int flag = 0;
//int N;
cin >> X;

vector<int> sosuu;
sosuu.push_back(2); 
/*int result = 0;

for(int i = 0; i < N; i++){
  cin >> P.data[i];
}
for(int i = 0; i < N; i++){
  cin >> Q.data[i];
}*/

while(sosuu.back() < X){
  flag = 0;
  for(int i = 0; i < sosuu.size(); i++){
    if(tmp%sosuu[i] == 0) break;
    flag++;
  }
  if(flag == sosuu.size()) sosuu.push_back(tmp);
  tmp++;
}

cout << sosuu.back() << endl;

return 0;
}


Measured memory_bytes: 384
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

if __name__ == '__main__':
    a = [int(i) for i in input().split()]
    
    if a[0] % a[1] > 0:
        print(1)
    else:
        print(0)

Measured memory_bytes: 3828
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <assert.h>
#include <numeric>
#include <iomanip>
#define rep(i, a, b) for (int(i) = (a); i < (b); i++)
using namespace std;

using ll = long long;

typedef pair<int, int> P;

const int INF = 100000000;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

ll pow_mod(ll x, ll y, ll mod)
{
	if (y == 0)
		return 1;

	if (y == 1)
		return x % mod;

	return (pow_mod(x, y - 1, mod) * x) % mod;
}

ll N, H;
ll ans = 0;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	//問題文中の添え字が0-indexか1-indexか確認!
	cin >> N >> H;
	vector<ll> a(N), b(N);
	rep(i, 0, N) cin >> a[i] >> b[i];
	sort(a.begin(), a.end(), greater<ll>());
	ll maxa = a[0];
	sort(b.begin(), b.end(), greater<ll>());
	rep(i, 0, N)
	{
		if (b[i] < maxa || H <= 0)
			break;
		ans++;
		H -= b[i];
	}
	if (H > 0)
	{
		ans += ((H - 1) / maxa) + 1;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;
typedef pair<int,int> pi;
const int R=1e5+1;
const int INF=987654321;
int n,ans;
int arr[R];
pi a[2],b[2];
vector<int> even,odd;

pi f(int val,int num){
    vector<int> v;
    if(num==0) v=even;
    else v=odd;

    int s=val;
    int cnt=0;
    int mx=0;
    int ret=-1;
    int tmp=-1;
    for(int i=0;i<v.size();i++){
        if(s==v[i]) continue;
        if(tmp!=v[i]) cnt=1;
        else cnt++;

        if(mx<cnt){
            mx=cnt;
            ret=v[i];
        }
        tmp=v[i];
    }

    if(ret==val) ret=0;

    return {ret,mx};
}

int main(){
    scanf("%d",&n);
    ans=INF;

    for(int i=0;i<n;i++){
        scanf("%d",&arr[i]);
        if(i&1) odd.push_back(arr[i]);
        else even.push_back(arr[i]);
    }

    sort(odd.begin(),odd.end());
    sort(even.begin(),even.end());

    a[0]=f(0,0);
    a[1]=f(a[0].first,0);

    b[0]=f(0,1);
    b[1]=f(b[0].first,1);
    int os=odd.size();
    int es=even.size();

    if(a[0].first!=b[0].first) printf("%d\n",n-a[0].second-b[0].second);
    else printf("%d\n",n-max(a[0].second+b[1].second,a[1].second+b[0].second));

    return 0;
}

Measured memory_bytes: 1276
# coding: utf-8
N=int(input())
A=list(map(int,input().split()))
flg=True

for i in range(N):
    if A[i]%2 == 0:
        if A[i]%3==0 or A[i]%5==0:
            continue
        else:
            flg=False

if flg:
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 3060
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <map>
#include <cmath>

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;

//約数のリストを返す

int main(){
    ll N;
    cin >> N;

    ll res = 1;

    for(ll i = N; i >= 1; --i)
    {
      if(i * i <= N)
      {
        res = i * i;
        break;
      }
    }

    cout << res << endl;

    return 0;    
}



Measured memory_bytes: 256
#include<stdio.h>
int main (void)
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a<b&&b<c)
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	return 0;
}



Measured memory_bytes: 1972
n = gets.to_i
s = gets.to_s
A= s.split(" ")

def selectionSort(array , n)
   exchange_cnt = 0

   for i in 0..(n  - 1)
	  exchange_flg = 0

	  minj = i
	  for j in i..( n - 1 )
		 if array[j].to_i < array[minj].to_i
			minj = j
			exchange_flg  = 1
		 end
	  end

	  # A[i] と A[minj] を交換
	  if exchange_flg == 1
		 tmp = array[i]
		 array[i] = array[minj]
		 array[minj] = tmp
		 exchange_cnt += 1		 
	  end
   end

   puts array.join(' ')
   puts exchange_cnt
end

selectionSort(A,n)



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

using namespace std;

int main()
{
    string A, B;
    cin >> A;
    cin >> B;

    if(A.length() > B.length()) {
        cout << "GREATER" << endl;
        return 0;
    } else if(A.length() < B.length()) {
        cout << "LESS" << endl;
        return 0;
    } else {
        for(int i = 0; i < A.length(); i++) {
            if(A[i] > B[i]) {
                cout << "GREATER" << endl;
                return 0;
            } else if(A[i] < B[i]) {
                cout << "LESS" << endl;
                return 0;
            }
        }
    }
    cout << "EQUAL" << endl;
    return 0;
}


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

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


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)

int main() {
  while (1) {
    int n;
    cin >> n;
    if (n == 0)
      break;
    int w[n];
    rep(i, n) cin >> w[i];

    vector<vector<int> > dp(n + 1, vector<int>(n + 1));
    for (int W = 2; W <= n; ++W) {
      rep(l, n) {
        int r = l + W;
        if (r > n)
          continue;
        if (dp[l + 1][r - 1] == W - 2 && abs(w[l] - w[r - 1]) <= 1) {
          dp[l][r] = W;
        }

        for (int m = l; m <= r; ++m) {
          dp[l][r] = max(dp[l][r], dp[l][m] + dp[m][r]);
        }
      }
    }

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


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

int main(){
  while(true){
    int n;
    cin>>n;
    if(n==0){
      break;
    }
    int a[1000];
    for(int i=0;i<n;i++){
      cin>>a[i];
    }
    int dif=1000001;
    for(int i=0;i<n-1;i++){
      for(int j=i+1;j<n;j++){
        int d=abs(a[i]-a[j]);
        if(d<dif){
          dif=d;
        }
      }
    }
    cout<<dif<<endl;
  }
  return 0;
}


Measured memory_bytes: 3092
from math import gcd
from collections import defaultdict
mod = 10**9+7
n = int(input())
mp = defaultdict(lambda: [0, 0])
zerozero = 0
for i in range(n):
    a, b = map(int, input().split())
    if (a, b) == (0, 0):
        zerozero += 1
        continue
    g = gcd(a, b)
    a //= g
    b //= g
    rot_cnt = 0
    while not (a > 0 and b >= 0):
        a, b = -b, a
        rot_cnt += 1
    mp[(a,b)][rot_cnt%2] += 1
ans = 1
for s, t in mp.values():
    now = (pow(2, s, mod) + pow(2, t, mod) - 1) % mod
    ans = (ans * now) % mod
ans = (ans - 1 + zerozero) % mod 
print(ans)

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code

int main(int argc, char const* argv[])
{
	LL n,m;
	cin >> n >> m;
	if (n == 1 or m == 1) {
		if (n == m) {
			cout << 1 << endl;
		}
		else {
			cout << max(n,m) - 2 << endl;
		}
		return 0;
	}

	cout << (n-2)*(m-2) << endl;
	return 0;
}


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

int main() {
  int N;
  string S;
  cin>>N;
  int pink=0,white=0,green=0,yellow=0;
  for (int i = 0; i < N; i++) {
    cin>>S;
    if(S=="P"){
      pink++;
    }
    else if(S=="W"){
      white++;
    }
    else if(S=="G"){
      green++;
    }
    else{
      yellow++;
    }
  }
  if(pink>0&&white>0&&green>0&&yellow>0){
    cout<<"Four"<<endl;
  }
  else{
    cout<<"Three"<<endl;
  }

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll MOD=1000000007;
const ll INF=1000000000LL;
const int MAX=100001;
const double EPS=1e-10;
struct edge{int to,cost;};
typedef pair<int,int> P;
int main(){
    int n,a;
    cin>>n>>a;
    int x[51];
    for(int i=1;i<=n;i++){
        cin>>x[i];
    }
    ll dp[51][51][2600]={};
    dp[0][0][0]=1;
    for(int i=0;i<n;i++){
        for(int k=0;k<=i;k++){
        for(int j=0;j<2505;j++){
            dp[i+1][k+1][j+x[i+1]]+=dp[i][k][j];
            dp[i+1][k][j]+=dp[i][k][j];
        }
        }
    }
    ll ans=0;
    for(int i=1;i<=n;i++){
        ans+=dp[n][i][a*i];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 53120
#include <iostream>
#include <math.h>
#include <cstring>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define DIV 1000000007;
#define INF 1e9

using namespace std;

ll n, a=1, b=1, c=1;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++) {
		a *= 10, a %= DIV;
		b *= 9, b %= DIV;
		c *= 8, c %= DIV;
	}
	a += 2*DIV;
	cout << (a - 2 * b + c) % DIV;
	return 0;
}

Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for (int i = (a); i <= (b); ++i)
#define REPD(i,a,b) for (int i = (a); i >= (b); --i)
#define FORI(i,n) REP(i,1,n)
#define FOR(i,n) REP(i,0,int(n)-1)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define SZ(x) int((x).size())
#define DBG(v) cerr << #v << " = " << (v) << endl;
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
#define fi first
#define se second

const int N = 100100;

int n;
pii t[N];
pair<ll,ll> v[N];
int used[N];

int main() {
	scanf("%d", &n);
	ll res = 0, maxl = -1, minr = 1e9+4;
	FOR(i,n) {
		scanf("%d%d", &t[i].fi, &t[i].se);
		maxl = max(maxl, 1LL*t[i].fi);
		minr = min(minr, 1LL*t[i].se);
		res = max(res, 1LL*(t[i].se-t[i].fi+1));
	}
	//printf("minr = %d, maxl = %d\n", minr, maxl);
	ll llen = 1e9+3, rlen = 1e9+3;
	int m = 0;
	if (minr < maxl) {
		FOR(i,n) {
			if (t[i].fi > minr) {
				used[i] = 1;
				rlen = min(rlen, t[i].se-maxl+1);
			} else if (t[i].se < maxl) {
				used[i] = 1;
				llen = min(llen, minr-t[i].fi+1);
			}
		}
		FOR(i,n) if (!used[i]) {
			ll rlim = t[i].se-maxl+1, llim = minr-t[i].fi+1;
			if (rlim >= rlen || llim >= llen) continue;
			v[m++] = mp(llim, rlim);
		}
	} else {
		FOR(i,n) {
			if (t[i].fi == maxl && t[i].se == minr) {
				printf("%lld\n", res+t[i].se-t[i].fi+1);
				return 0;
			}
			if (t[i].fi == maxl) {
				rlen = min(rlen, t[i].se-maxl+1);
				used[i] = 1;
			} else if (t[i].se == minr) {
				llen = min(llen, minr-t[i].fi+1);
				used[i] = 1;
			}
		}
		FOR(i,n) if (!used[i]) {
			ll rlim = t[i].se-maxl+1, llim = minr-t[i].fi+1;
			if (rlim >= rlen || llim >= llen) continue;
			v[m++] = mp(llim, rlim);
		}
		res += minr-maxl+1;
	}
	sort(v,v+m);
	//printf("lengths = %d %d\n", llen, rlen);
	//FOR(i,m) printf("%d %d\n", v[i].fi, v[i].se);
	FOR(i,m) {
		res = max(res, rlen + v[i].fi);
		rlen = min(rlen, v[i].se);
	}
	res = max(res, llen+rlen);
	printf("%lld\n", res);
	return 0;
}


Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
//const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << '\n'; exit(0);}

int main()
{
  ll N, M, V, P;
  cin >> N >> M >> V >> P;
  ll v = N - V;

  map<ll, ll> mp;
  for (ll i = 0; i < N; i++)
  {
    ll A;
    cin >> A;
    mp[A]++;
  }

  vector<ll> A, B;
  for (auto m : mp)
  {
    A.push_back(m.first);
    B.push_back(m.second);
  }
  reverse(A.begin(), A.end());
  reverse(B.begin(), B.end());
  A.push_back(-INF), B.push_back(1);
  N = A.size();

  vector<ll> C(N);
  C.at(0) = B.at(0);
  for (ll i = 1; i < N; i++)
  {
    C.at(i) = C.at(i - 1) + B.at(i);
  }

  auto Tit = lower_bound(C.begin(), C.end(), P);
  ll Ti = Tit - C.begin();
  ll T = *Tit;
  //cerr << Ti << " " << T << endl;

  ll ok = Ti, ng = N - 1;
  while (abs(ok - ng) > 1)
  {
    ll mid = (ok + ng) / 2;
    ll tmp = 0;
    bool flg = true;
    for (ll i = Ti; i < mid; i++)
    {
      if (A.at(i) - A.at(mid) > M)
      {
        flg = false;
        break;
      }
      tmp += (A.at(i) - A.at(mid)) * B.at(i);
    }
    if (flg)
      flg = (tmp <= M * v);
    //cerr << flg << endl;
    if (flg)
      ok = mid;
    else
      ng = mid;

    //cerr << ok << " " << ng << endl;
  }

  ll ans = C.at(ok);
  cout << ans << endl;
}

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

using namespace std;

int main() {

    int n;

    while(cin >> n, n) {

        int ans = 0;

        for(int i = 1; i < n; ++i) {
            int sum = 0;
            for(int j = i; j < n; ++j) {
                sum += j;
                if(sum == n) {
                    ++ans;
                    break;
                } else if(sum > n) {
                    break;
                }
            }
        }

        cout << ans << endl;

    }

}

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

void bubbleSort(vector<int>& A_ref, int N, int& change_cnt){ // N 個の要素を含む 0-オリジンの配列 A
    int flag = 1; // 逆の隣接要素が存在する
    while (flag){
        flag = 0;
        for (int j=N-1;j>0;j--){
            if (A_ref[j] < A_ref[j-1]){
                int tmp_Aj = A_ref[j];
                A_ref[j]=A_ref[j-1];
                A_ref[j-1]=tmp_Aj;
                change_cnt++;
                flag = 1;
            }
        }
    }
}

int main(){
    int N, change_cnt=0;
    cin >> N;
    vector<int> A(N);
    for (int i=0;i<N;i++) cin >> A.at(i);
    bubbleSort(A, N, change_cnt);
    for (int i=0;i<N;i++) {
        cout << A.at(i);
        if (i==N-1) break;
        cout << ' ';
    }
    cout << endl;
    cout << change_cnt << endl;
}


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

int main(){
  int N, Q;
  cin >> N >> Q;
  string str;
  cin >> str;

  vector<int> s(N+1, 0);
  for(int i=0; i<N; i++){
    if(i+1<N && str[i]=='A' && str[i+1]=='C') s[i+1]=s[i]+1;
    else s[i+1]=s[i];
  }

  for(int q=0; q<Q; q++){
    int l, r;
    cin >> l >> r;
    l--, r--;
    cout << s[r]-s[l] << endl;
  }
}

Measured memory_bytes: 1408
t = int(input())
if 400 <= t <= 599:
    print("8")
elif 600 <= t <= 799:
    print("7")
elif 800 <= t <= 999:
    print("6")
elif 1000 <= t <= 1199:
    print("5")
elif 1200 <= t <= 1399:
    print("4")
elif 1400 <= t <= 1599:
    print("3")
elif 1600 <= t <= 1799:
    print("2")
elif 1800 <= t <= 1999:
    print("1")

Measured memory_bytes: 9188
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n::Int=parseInt(readline())
    a::Vector{Int}=parseMap(split(readline()))
    cnt::Dict{Int,Int}=Dict{Int,Int}()
    for i in a
        if haskey(cnt,i)
            cnt[i]+=1
        else
            cnt[i]=1
        end
    end
    ans::Int=0
    for key in keys(cnt)
        ans+=key*cnt[key]
    end
    q::Int=parseInt(readline())
    for i in 1:q
        b::Int,c::Int=parseMap(split(readline()))
        if haskey(cnt,b)
            if haskey(cnt,c)
                cnt[c]+=cnt[b]
            else
                cnt[c]=cnt[b]
            end
            ans+=c*cnt[b]
            ans-=b*cnt[b]
            cnt[b]=0
        end
        println(ans)
    end
end
main()

Measured memory_bytes: 207140
#include <iostream>

using namespace std;

int a, b;

int rezolva () {
  int x, y;
  for (int i = 0; i <= 10000; i++) {
    x = i * 0.08; y = i * 0.1;
    if (x == a and y == b)
      return i;
  }
  return -1;
}

int main()
{
  cin >> a >> b;
  cout << rezolva ();
  return 0;
}


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


void solve(std::string S){
    int len = S.size();
    int ans =0;
    for(int i= 0;i<len;i++){
        if(S[i] != S[len-1-i]){
            // cout << S[i] << S[len-1-i] << endl;
            ans++;
        }
    }
    ans /= 2;
    cout << ans << endl;

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
random_device rnd;
mt19937 mt(rnd());
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;
const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1000000007;

int main()
{
    int n, x, t;
    cin >> n >> x >> t;
    cout << ((n + x - 1) / x) * t << endl;

    return 0;
}

Measured memory_bytes: 3628
import qualified Data.ByteString.Char8 as B
import Data.ByteString.Char8 (ByteString)
import Control.Monad.Trans.State.Strict
import Control.Applicative
import Data.Char

main :: IO ()
main = B.interact $ output . solve . input

output :: Int -> ByteString
output = B.pack . show

solve :: [Int] -> Int
solve = sum . map pred

input :: ByteString -> [Int]
input = maybe (error "parse error") fst . runStateT (parseInt *> many parseInt)

parseInt :: StateT ByteString Maybe Int
parseInt = StateT $ B.readInt . B.dropWhile isSpace

Measured memory_bytes: 1148
#include <bits/stdc++.h>
#define ll long long
using namespace std;
string s;
int main(){

    cin>>s;
    int sum = 0;
    for(int i=0;i<s.size();i++)
        sum += s[i] -'0',sum %= 9;
    cout<<(sum == 0?"Yes":"No")<<endl;
}

Measured memory_bytes: 3756
#include<vector>
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
#include<stack>
#include<string.h>
#include<list>
#define ll long long int
#define MOD 1000000007LL
using namespace std;

int main() {
    string s;
    cin>>s;
    ll n=s.length();
    ll ans=(n*(n-1))/2;
    ll c[26]={};
    for(int i=0;i<n;i++){
        c[s[i]-'a']++;
    }
    for(int i=0;i<26;i++){
        ans-=(c[i]*(c[i]-1))/2;
    }
    cout<<ans+1<<endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF LLONG_MAX - 100
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define lowb lower_bound
#define upb upper_bound
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
int month[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};

template <uint_fast64_t Modulus> class modint {
  using u64 = std::uint_fast64_t;

public:
  u64 a;

  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};

int a[10010], fact[1000010];

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

    int n;
    cin >> n;
    rep(i, n) {
        cin >> a[i];
        int A = a[i];
        for(int i = 2; i * i <= A; i++) {
            int cnt = 0;
            while(A % i == 0) {
                cnt++;
                A /= i;
            }
            chmax(fact[i], cnt);
        }
        if(A > 1) chmax(fact[A], (ll)1);
    }

    modint<MOD> lcm = 1;
    for(int i = 1; i <= 1000000; i++) {
        if(fact[i] >= 0) {
            rep(j, fact[i]) {
                lcm *= i;
            }
        }
    }
    modint<MOD> ans = 0;
    rep(i, n) {
        ans += lcm / a[i];
    }
    cout << ans.value() << endl;
    return 0;
}

Measured memory_bytes: 6656
#include <bits/stdc++.h>
using namespace std;
#define int long long
// #define endl '\n'

int mod = 998244353;

int pw(int a, int k) {
    if (k == 0) return 1;
    if (k % 2) return ((long long) pw(a, k - 1) * a) % mod;
    int t = pw(a, k / 2);
    return ((long long) t * t) % mod;
}

int rv(int a) {
    return pw(a, mod - 2);
}

int ml(int a, int b) {
    return ((long long)a * b) % mod;
}

int ml(int a, int b, int c) {
    return ml(ml(a, b), c);
}

int dv(int a, int b) {
    return ml(a, rv(b));
}

int sm(int a, int b) {
    return (a + b) % mod;
}

int df(int a, int b) {
    return ((long long)a + mod - b) % mod;
}

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

string yy = "Yes\n";
string nn = "No\n";
string imp = "IMPOSSIBLE\n";



int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t = 1; // cin >> t;
    while (t--) {
        int n; cin >> n;
        int k; cin >> k;
        vector<int> l(k), r(k);
        for (int i =0 ; i < k; i++) {
            cin >> l[i] >> r[i];
        }
        vector<int> dp(n);
        vector<int> sm(n + 1);
        dp[0] = 1;
        sm[1] = 1;
        for (int i = 1; i < n; i++) {
            for (int j = 0; j < k; j++) {
                if (l[j] > i + 1) continue;
                if (r[j] >= i + 1) {
                    dp[i] += sm[i + 1 - l[j]];
                    dp[i] %= mod;
                }
                else {
                    dp[i] += df(sm[i + 1 - l[j]], sm[i - r[j]]);
                    dp[i] %= mod;
                }
            }
            sm[i + 1] = (sm[i] + dp[i]) % mod;
            // cout << dp[i] << endl;
        }
        cout << dp[n - 1] << endl;
    }
    return 0;
}


Measured memory_bytes: 6348
N = int(input())
a = list(map(int, input().split()))

d = [0] * (N+1)
for i in range(N):
    d[a[i]] = i

left = list(range(N+1))
right = list(range(N+1))

ans = 0
for i in range(N, 0, -1):
    di = d[i]
    ans += i * (right[di]-di+1) * (di-left[di]+1)
    right[left[di] - 1] = right[di]
    left[right[di] + 1] = left[di]

print(ans)

Measured memory_bytes: 35624
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
template<class T> inline bool chmax(T& a, T b) { if(a < b){ a=b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if(a > b){ a=b; return 1; } return 0;}

ll ext_gcd(ll a, ll b, ll &x, ll &y){
	if(b==0){
		x = 1;
		y = 0;
		return a;
	}
	
	ll d = ext_gcd(b, a%b, y, x);
	y -= a/b * x;
	return d;
}

ll mod_inv(ll a, ll m){
	ll x,y;
	ext_gcd(a,m,x,y);
	return (m + x%m)%m;
}

int main(){
	ll n,k;
	cin >> n >> k;
	const ll mod = 1000000007;
	
	ll ans = 0;
	for(ll i=1; i<=k; i++){
		// (k-i) tama
		// (i-1) shikiri
		// (k-1)!/ (k-i)! ((i-1)!)
		ll blue = 1;
		for(ll j=(k-i)+1; j<=(k-1); j++){
			blue *= j;
			blue %= mod;
		}
		for(ll j=1; j<=(i-1); j++){
			blue *= mod_inv(j,mod);
			blue %= mod;
		}
		
		// (n-k-i+1) tama
		// i shikiri
		// (n-k+1)! / (n-k-i+1)!   ((i)!)
		ll red = 1;
		for(ll j=1; j<=i; j++){
			red *= (n-k+1)-j+1;
			red %= mod;
		}
		for(ll j=1; j<=i; j++){
			red *= mod_inv(j,mod);
			red %= mod;
		}
		
		ans = (blue*red)%mod;
		cout << ans << endl;
	}
	
	
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>

int main(void) {
    int x, y, z;
    int tmp;
    std::cin >> x >> y >> z;

    tmp = x;
    x = y;
    y = tmp;

    tmp = x;
    x = z;
    z = tmp;

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

    return 0;
}


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

int main() {
	int n, K;
	cin >> n >> K;
	vector<int> v(n);
	for(int i = 0; i < n; i++) {
		cin >> v[i], v[i]--;
	}

	vector<int> cnt(100100);
	int c = 0;
	int p = 0;
	int ans = 1e9;
	for(int i = 0; i < n; i++) {
		while(p < n && c < K) {
			if(v[p] < K) {
				cnt[v[p]]++;
				if(cnt[v[p]] == 1) c++;
			}
			p++;
		}
		if(c == K) {
			ans = min(ans, p - i);
		}
		if(v[i] < K) {
			cnt[v[i]]--;
			if(!cnt[v[i]]) c--;
		}

	}
	
	cout << (ans == 1e9 ? 0 : ans) << endl;
}

Measured memory_bytes: 3624
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <cassert>
#include <string.h>
//#include <unordered_set>
//#include <unordered_map>
//#include <bits/stdc++.h>

#define MP(A,B) make_pair(A,B)
#define PB(A) push_back(A)
#define SIZE(A) ((int)A.size())
#define LEN(A) ((int)A.length())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define fi first
#define se second

using namespace std;

template<typename T>inline bool upmin(T &x,T y) { return y<x?x=y,1:0; }
template<typename T>inline bool upmax(T &x,T y) { return x<y?x=y,1:0; }

typedef long long ll;
typedef unsigned long long ull;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod eps=1e-11;
const lod pi=acos(-1);
const int oo=1<<30;
const ll loo=1ll<<62;
const int mods=1e9+7;
const int MAXN=600005;
const int INF=0x3f3f3f3f;//1061109567
/*--------------------------------------------------------------------*/
inline int read()
{
	int f=1,x=0; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') f=-1; c=getchar(); }
	while (c>='0'&&c<='9') { x=(x<<3)+(x<<1)+(c^48); c=getchar(); }
	return x*f;
}
char st[MAXN];
int f[MAXN][8];
int to[8][2]={{2,1},{4,3},{6,5},{3,3},{7,1},{2,1},{2,2},{4,4}};
int upd(int x,int y){ return x+y>=mods?x+y-mods:x+y; }
int main()
{
	scanf("%s",st);
	int len=strlen(st);
	f[0][0]=1;
	for (int i=0;i<len;i++)
		for (int j=0;j<=7;j++) 
		{
			if (st[i]!='0') f[i+1][to[j][1]]=upd(f[i+1][to[j][1]],f[i][j]);
			if (st[i]!='1') f[i+1][to[j][0]]=upd(f[i+1][to[j][0]],f[i][j]);
		}
	printf("%d\n",upd(f[len][1],f[len][3]));
	return 0;
}

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

int main() {

 int a, b, c, d, e, f;
 char op;
 while (true)
 {
  cin >> a >> op >> b;
  if (op == '?')
   break;
  c = a + b;
  d = a - b;
  e = a * b;
  if(b != 0)
  f = a / b;

  if (op == '+')
   cout << c << "\n";
  if (op == '-')
   cout << d << "\n";
  if (op == '*')
   cout << e << "\n";
  if (op == '/')
   cout << f << "\n";
 }
}

Measured memory_bytes: 1168
import java.io.BufferedReader;
import java.io.InputStreamReader;



class Main{

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String[] s = br.readLine().split("");
		int count = 0;
		int count2 = 0;
		for(int i = 0;i < n;i++){
			if(s[i].equals("(")){
				count += 1;
			}else if(s[i].equals(")")){
				count2 += 1;
				if(i == 0){
					s[0] = "(" + s[0];
					count += 1;
				}else if(count < count2){
					s[0] = "(" + s[0];
					count += 1;
				}
			}
		}
		if(count > count2){
			for(int i = 0;i < count - count2;i++){
				s[n-1] += ")";
			}
		}
		for(int i = 0;i < n;i++){
			System.out.print(s[i]);
		}
		System.out.println();
	}

}


Measured memory_bytes: 21332
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}
string YN(bool v) { return v ? "Yes":"No"; }

#define INF (1LL<<60)

/*
*/
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N;
	while(cin>>N) {
		VI A(N);
		REP(i, N) cin>>A[i];
		sort(ALL(A));
		ll mx = A[N-1];
		auto mi = MP((double)INF, 0LL);
		REP(i, N) {
			minUpdate(mi, MP(abs((double)A[i]-(double)mx/2), A[i]));
		}
		cout<<mx<<" "<<mi.SE<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;

int main(){
  long long N, K;
  cin >> N >> K;
  priority_queue<int> H;
  for(int i = 0; i < N; i++){
    long long a;
    cin >> a;
    H.push(a);
  }
  for(int i = 0; i < K; i++){
    if(!H.empty())H.pop();
  }
  long long counter = 0;
  while(!H.empty()){
    counter += H.top();
    H.pop();
  }
  cout << counter << endl;
}

Measured memory_bytes: 1400