akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(auto i=0;i<n;++i)
#define REPR(i,n) for(auto i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(auto i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d",&tmp);v.push_back(tmp);}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  int a[3];
  cin >> a[0] >> a[1] >> a[2];

  int ans = INF;
  REP(i,3){
    REP(j,3){
      if(i == j) continue;
      REP(k,3){
        if(i==k || j ==k) continue;
        ans = min(ans, abs(a[k] - a[j]) + abs(a[j] - a[i]));
      }
    }
  }
  cout << ans << endl;
  return 0;
}



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

int n,m,ans = 0;
vector<vector<int>> G;
bool visited[8];

void dfs(int i){
    if(visited[i]) return;
    visited[i] = true;
    for(auto j : G[i]){
        dfs(j);
    }

    bool flag = true;
    for(int j = 0; j < n; j++){
        if(!visited[j]) flag = false;
    }
    if(flag) ans++;
    visited[i] = false;
}

signed main() {
    cin >> n >> m;

    G.resize(n);
    for(int i = 0; i < m; i++){
        int a,b;
        cin >> a >> b;
        a--,b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    dfs(0);
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>

int main() {
  uint32_t N = 0;
  std::cin >> N;
  std::vector<uint32_t> A(N);
  for (auto &&a : A) std::cin >> a;

  uint32_t count = 0;
  std::vector<uint32_t> G;
  for (size_t i = 1; i <= N; i = 3 * i + 1) G.push_back(i);
  std::reverse(G.begin(), G.end());

  for (auto &&g : G) {
    for (size_t i = g; i < N; i++) {
      for (size_t j = 0; i >= g * (j + 1); j++) {
        if (A[i - g * j] >= A[i - g * (j + 1)]) break;
        auto temp = A[i - g * (j + 1)];
        A[i - g * (j + 1)] = A[i - g * j];
        A[i - g * j] = temp;
        count++;
      }
    }
  }

  std::cout << G.size() << std::endl;
  for (uint32_t i = 0; i < G.size() - 1; i++) std::cout << G[i] << " ";
  std::cout << G.back() << std::endl;
  std::cout << count << std::endl;
  for (auto &&a : A) std::cout << a << std::endl;

  return 0;
}


Measured memory_bytes: 6696
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back
const ll mod = 1e9+7;
int g[1003][1003];
int cl[1003][1003];
int h,w;
int ch,cw;
int dh,dw;
int clr;
bool chk(int x, int y){
    return (x<=h and x>=1 and y<=w and y>=1 and g[x][y]==1);
}
int dx[4] = {0,0,-1,+1};
int dy[4] = {+1,-1,0,0};
void dfs(int x, int y){
    cl[x][y] = clr;
    for(int i=0;i<4;i++){
        int nx = x+dx[i];
        int ny = y+dy[i];
        if(!chk(nx,ny))continue;
        if(cl[nx][ny]>0)continue;
        dfs(nx,ny);
    }
}
vector<int>v[1000006];
bool vis[1000006];
int dis[1000006];
void bfs(int x){
    memset(dis,0x3f,sizeof dis);
    dis[x] = 0;
    queue<int>q;
    q.push(x);
    vis[x] = true;
    while(!q.empty()){
        int x = q.front();
        q.pop();
        for(int y:v[x]){
            if(vis[y])continue;
            vis[y] = true;
            q.push(y);
            dis[y] = min(dis[y],dis[x]+1);
        }
    }
}
void solve(){
    cin>>h>>w>>ch>>cw>>dh>>dw;
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            char c;
            cin>>c;
            if(c=='.')g[i][j] = 1;
            else g[i][j] = -1;
        }
    }
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            if(g[i][j]==1 and cl[i][j]==0){
                clr++;
                dfs(i,j);
            }
        }
    }
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            if(g[i][j]==-1)continue;
            for(int a = -2;a<=2;a++){
                for(int b = -2;b<=2;b++){
                    int x = i+a;
                    int y = j+b;
                    if(!chk(x,y))continue;
                    if(cl[x][y]==cl[i][j])continue;
                    v[cl[x][y]].pb(cl[i][j]);
                    v[cl[i][j]].pb(cl[x][y]);
                }
            }
        }
    }
    bfs(cl[ch][cw]);
    int ans = dis[cl[dh][dw]];
    if(ans>1e6)ans = -1;
    cout<<ans<<endl;
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
//    cin>>t;
    while(t--)solve();
    return 0;
}


Measured memory_bytes: 60884
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long int
#define ull unsigned long long
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define mod 1000000007


bool isPrime(int n)
{
    // Corner cases
    if (n <= 1)  return false;
    if (n <= 3)  return true;

    // This is checked so that we can skip
    // middle five numbers in below loop
    if (n%2 == 0 || n%3 == 0) return false;

    for (int i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
            return false;

    return true;
}


ll max(ll a,ll b)
{
    if(a>b)
    {
        return a;
    }
    return b;
}

ll min(ll a,ll b)
{
    if(a<b)
    {
        return a;
    }
    return b;
}

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

ll lcm(ll a, ll b)
{
    return (a*b)/gcd(a, b);
}


ll fact(ll n)
{
    ll res = 1;
    for (ll i = 2; i <= n; i++)
        res = res * i;
    return res;
}

ll nCr(ll n, ll r)
{
    return fact(n) / (fact(r) * fact(n - r));
}

ll fastpow(ll base,ll exp)
{
    base%=mod;
    ll ans=1;
    while(exp)
    {
        if(exp&1) {ans*=base; ans%=mod;}
        exp/=2;
        base*=base;
        base%=mod;
    }
    return ans;
}

class DSU {
public:
    int n;
    vector<int> parent,size;

    DSU(int a) {
        n = a;
        parent.assign(n,0);
        size.assign(n,0);
        for(int i=0 ; i<n ; i++) {
            parent[i] = i;
            size[i] = 1;
        }
    }

    void makeSets(int k) {
        for(int i=0 ; i<n ; i++) {
            if(find(i) != i) {
                size[i] = 0;
            }
        }
    }

    int find(int a) {
        int root = a;
        while(root != parent[root]) {
            root = parent[root];
        }
        while(root != a) {
            int temp = parent[a];
            parent[a] = root;
            a = temp;
        }
        return root;
    }

    void unionSet(int a, int b) {
        int root_a = find(a);
        int root_b = find(b);
        if(root_a == root_b) return;
        if(size[a] < size[b]) {
            parent[root_a] = root_b;
            size[root_b] += size[root_a];
        }
        else {
            parent[root_b] = root_a;
            size[root_a] += size[root_b];
        }
    }
};




int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);



ll a,b;
cin>>a>>b;
ll c=a%b;

if(c>abs(c-b))
{
    c=abs(c-b);
}
cout<<c;





    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#define pb push_back
using namespace std;

int main(void){
  long long int n,x,i,j;
  int flag;
  int maxi,maxt;
  long long int sum,k,tmp;
  vector<int> a,b;
  flag=sum=0;
  cin>>n;
  for(i=0;i<n;i++){
    cin>>x;
    sum+=x;
    a.pb(x);
  }
  if(n==1){
    cout<<"YES"<<endl;
    return 0;
  }
  k=sum/((n*(n+1))/2);
  for(i=0;i<n-1;i++){
    b.pb(a[i+1]-a[i]);
  }
  b.pb(a[0]-a[n-1]);
  tmp=0;

  for(i=0;i<b.size();i++){
    maxt=max(maxt,b[i]);
  }
  for(i=0;i<b.size();i++){
    if(k<0) break;
    while(b[i]<maxt){
      b[i]+=n;
      k--;
    }
  }

  for(i=0;i<b.size();i++){
    if(b[0]!=b[i]) flag=1;
  }
  if(flag==1||k!=0) cout<<"NO"<<endl;
  else cout<<"YES"<<endl;
  return 0;
}

Measured memory_bytes: 1400
#include <iostream>

using namespace std;

int main(void) {
  int N;
  int *a, tmp, max;
  
  cin >> N;
  a = new int[100001];
  max = 0;
  for (int i = 0; i < 100001; i++)
    a[i] = 0;
  for (int i = 0; i < N; i++) {
    cin >> tmp;
    if (tmp != 0) {
      a[tmp-1]++;
      max = max < a[tmp-1] ? a[tmp-1] : max;
    }
    a[tmp]++;
    max = max < a[tmp] ? a[tmp] : max;
    if (tmp != 100001) {
      a[tmp+1]++;
      max = max < a[tmp+1] ? a[tmp+1] : max;
    }
  }
  cout << max << endl;
  return 0;
}

Measured memory_bytes: 640
/*  -*- coding: utf-8 -*-
 *
 * d.cc: D - String Formation
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;
const int MAX_Q = 200000;

/* typedef */

/* global variables */

char s[MAX_N + 4], h[MAX_Q + 4], t[MAX_Q + 4];

/* subroutines */

/* main */

int main() {
  int q;
  scanf("%s%d", s, &q);

  int r = 0, hn = 0, tn = 0;
  while (q--) {
    int ti;
    scanf("%d", &ti);

    if (ti == 1) {
      r ^= 1;
    }
    else {
      int fi;
      char ci[4];
      scanf("%d%s", &fi, ci);
      fi--;

      if (! (r ^ fi)) h[hn++] = ci[0];
      else t[tn++] = ci[0];
    }
  }

  if (! r) {
    reverse(h, h + hn);
    printf("%s%s%s\n", h, s, t);
  }
  else {
    int sn = strlen(s);
    reverse(s, s + sn);
    reverse(t, t + tn);
    printf("%s%s%s\n", t, s, h);
  }
  return 0;
}


Measured memory_bytes: 896
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_int2(int *a1, int *a2) {
  char buf[100];
  if(!fgets(buf, 100, stdin)) return -1;
  return sscanf(buf, "%d %d", a1, a2);
}

int get_int4(int *a1, int *a2, int *a3, int *a4) {
  char buf[100];
  if(!fgets(buf, 100, stdin)) return -1;
  return sscanf(buf, "%d %d %d %d", a1, a2, a3, a4);
}


enum {
    COMMAND_ADD,
    COMMAND_GET,
};

#define QUERY_MAX 100000
#define NUM2_MAX (1<<17)

struct range {
    int start;
    int end;
};

int is_overlap(struct range r1, struct range r2) {
    return r1.end > r2.start && r2.end > r1.start;
}

int is_contain(struct range this, struct range in) {
    return in.start <= this.start && this.end <= in.end;
}

void add(int *seg, struct range r, int val, int node, struct range this) {
    if(is_contain(this, r)) {
        seg[node] += val;
    } else if (is_overlap(r, this)) {
        struct range left = {this.start, (this.start+this.end)/2};
        struct range right = {(this.start+this.end)/2, this.end};
        add(seg, r, val, node*2, left);
        add(seg, r, val, node*2+1, right);
    }
    // if not overlap, do nothing
    return;
}

int get(int *seg, int num, int idx) {
    int node = num + idx;
    int ans = 0;
    while(node) {
        ans += seg[node];
        node /= 2;
    }
    return ans;
}

#define ROOT_NODE 1
int main(void) {
    int num, queries;
    int num2 = 1;
    get_int2(&num, &queries);
    while(num > num2) num2 *= 2;

    int i;

    static int ans[QUERY_MAX];
    int aidx = 0;
    static int seg[NUM2_MAX*2];
    struct range whole = {0, num2};
    for(i = 0; i < queries; i++) {
        int type, arg1, arg2, arg3;
        get_int4(&type, &arg1, &arg2, &arg3);
        arg1--; arg2--; // 1-indexed -> 0-indexed
        switch(type) {
            case COMMAND_ADD:
                {
                    struct range r = {arg1, arg2+1};
                    int x = arg3;
                    add(seg, r, x, ROOT_NODE, whole);
                }
                break;
            case COMMAND_GET:
                {
                    ans[aidx++] = get(seg, num2, arg1);
                }
                break;
            default:
                break;
        }
    }

    for(i = 0; i < aidx; i++) {
        printf("%d\n", ans[i]);
    }
    return 0;
}



Measured memory_bytes: 2852
// Problem: F - Contrast
// Contest: AtCoder - AtCoder Beginner Contest 178
// URL: https://atcoder.jp/contests/abc178/tasks/abc178_f
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)


#include <bits/stdc++.h>
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wunused-parameter"
#pragma GCC diagnostic ignored "-Wunused-but-set-variable" 
//#pragma GCC diagnostic ignored "-Wformat"
using namespace std ;

#define   Pi     2*acos(0.0)
#define   LINF   1LL<<63
#define   ll     long long
#define   ull    unsigned long long
#define   pb     push_back
#define   mp     make_pair
#define   MAX    500006
#define   MAX1   10000008
#define   mem(a,v)   memset(a,v,sizeof(a))
#define   all(x) x.begin(),x.end()
#define lcm(a, b)        ((a)*((b)/gcd(a,b)))
#define yes   cout<<"YES"<<endl
#define no   cout<<"NO"<<endl
#define buga  cout<<1<<endl
#define bugb  cout<<2<<endl
#define bugc  cout<<3<<endl
#define bugd  cout<<4<<endl
#define buge  cout<<5<<endl

void fastIO (){ios_base::sync_with_stdio(false);cin.tie(0); cout.precision(20);}

ll A[MAX];
ll B[MAX];
ll C[MAX];
vector< ll >V;
vector< ll >Ans;
vector< pair<ll,ll> >VP;
map< ll,ll >M;
vector<ll>prime;
bool mark[MAX1];
ll N=1e7;
void seive (){int limit = sqrt(N*1.0)+2;mark[1]=1;for (int i=4;i<=N;i+=2)mark[i]=1;prime.push_back(2);for (int i=3;i<=N;i+=2){if(!mark[i]){prime.push_back(i);if(i<=limit){for (int j=i*i;j<=N;j+=i*2)mark[j]=1;}}}}

/*
ll bin_pow(ll o, ll s) {
    if (s == 0) return 1;
    if (s == 1) return o % mod;
    ll d = bin_pow(o, s/2);
    d = (d * 1ll * d) % mod;
    if (s % 2 == 1)
        d = (d * 1ll * o) % mod;
    return d;
}
*/

int main ()
{
    fastIO();
    ll a,b,c,d,n,m,k,l,p,q,r,t,x,y;
    ll cnt=0,cntr=0,sum=0,ans=1,check=0;
    ll Max= 0,Max1=-1e18+1,Min=LINF;
    string s,s1,s3,s4;
    
   t = 1;
    //cin >> t;
    while(t--){
  		cin>> n;
  		if(!n)cout<<1<<endl;
  		else cout<<0<<endl;
  	}
 

    return 0;
}


Measured memory_bytes: 3640
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<list>
#include<bitset>
#include<sstream>
using namespace std;

int main() {

	long long N;
	cin >> N;

	vector<long long> even;
	vector<long long> odd;

	long long a;
	for (long long i = 1; i <= N; i++) {
		cin >> a;
		if (i % 2 == 1) {
			odd.push_back(a);
		}
		else {
			even.push_back(a);
		}
	}

	vector<long long> b;
	if (N % 2 == 1) {
		for (long long i = odd.size() - 1; i >= 0; i--) {
			b.push_back(odd[i]);
		}
		for (long long i = 0; i < even.size(); i++) {
			b.push_back(even[i]);
		}
	}
	else {
		for (long long i = even.size() - 1; i >= 0; i--) {
			b.push_back(even[i]);
		}
		for (long long i = 0; i < odd.size(); i++) {
			b.push_back(odd[i]);
		}
	}

	for (long long i = 0; i < b.size(); i++) {
		cout << b[i] << " ";
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 6928
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<complex>
#include<set>
#include<map>
#include<queue>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define each(i,c) for(__typeof (c.begin()) i=c.begin(); i!=c.end(); i++)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<x<<endl
using namespace std;
typedef pair<int,int> P;
const int Cos[3] = {0,-1,0};
const int Sin[3] = {1,0,-1};
vector<P> Dini[20],Dini2[20];
vector<P> nH;
void Move(vector<P> s){
  rep(i,s.size()){
    nH.push_back(P(s[i].F-s[0].F,s[i].S-s[0].S));
  }
}


void CreateDiniAndDini2(vector<P> Must){
  rep(i,Must.size()){
    Dini[0].push_back(P(Must[i].F-Must[0].F,Must[i].S-Must[0].S));
    Dini2[0].push_back(P(Must[i].F-Must[Must.size()-1].F,Must[i].S-Must[Must.size()-1].S));   
  }
  reverse(all(Dini2[0]));

  rep(i,3){
    rep(j,Must.size()){
      Dini[i+1].push_back(P(Dini[0][j].F*Cos[i]-Dini[0][j].S*Sin[i], Dini[0][j].F*Sin[i]+Dini[0][j].S*Cos[i]));
      Dini2[i+1].push_back(P(Dini2[0][j].F*Cos[i]-Dini2[0][j].S*Sin[i],Dini2[0][j].F*Sin[i]+Dini2[0][j].S*Cos[i]));
    }
  }   
}

bool _check(int a,int b){
  return a == b?true:false;
}

bool IC(vector<P> isono){
  bool Isxo[8];
  if(Dini2[0].size() != isono.size())return false;
  rep(i,8)Isxo[i] = true;

  if(!(isono[0].F == 0 && isono[0].S == 0))reverse(all(isono));
 

  rep(i,Dini[0].size()){
    if(!(_check(Dini[0][i].F,isono[i].F) && _check(Dini[0][i].S,isono[i].S)))Isxo[0] = false;
    if(!(_check(Dini[1][i].F,isono[i].F) && _check(Dini[1][i].S,isono[i].S)))Isxo[1] = false;
    if(!(_check(Dini[2][i].F,isono[i].F) && _check(Dini[2][i].S,isono[i].S)))Isxo[2] = false;
    if(!(_check(Dini[3][i].F,isono[i].F) && _check(Dini[3][i].S,isono[i].S)))Isxo[3] = false;
    if(!(_check(Dini2[0][i].F,isono[i].F) && _check(Dini2[0][i].S,isono[i].S)))Isxo[4] = false;
    if(!(_check(Dini2[1][i].F,isono[i].F) && _check(Dini2[1][i].S,isono[i].S)))Isxo[5] = false;
    if(!(_check(Dini2[2][i].F,isono[i].F) && _check(Dini2[2][i].S,isono[i].S)))Isxo[6] = false;
    if(!(_check(Dini2[3][i].F,isono[i].F) && _check(Dini2[3][i].S,isono[i].S)))Isxo[7] = false;
  }
  rep(i,8)if(Isxo[i])return true;
  return false;
}


int main(){
  int m,n,x,y;
  vector<P> n0; 

  while(cin >> n && n){
    n0.clear();
    rep(i,20){
      Dini[i].clear();
      Dini2[i].clear();
    }
    cin >> m; 
    rep(i,m){
      cin >> x >> y;
      n0.push_back(P(x,y));
    }
    CreateDiniAndDini2(n0);

    rep(i,n){
      cin >> m;
      n0.clear();
      rep(j,m){
	cin >> x >> y;
	n0.push_back(P(x,y));
      }
      nH.clear();
      Move(n0);
      if(IC(nH))cout << i+1 << endl;
    }
    cout << "+++++" << endl;

  }
  return 0;
}

Measured memory_bytes: 0
#include <stdio.h>

int main(int argc, char const *argv[]) {
    int x;
    for (int i = 1; ; i++) {
        scanf("%d", &x);
        if (x == 0) {
            break;
        } else {
            printf("Case %d: %d\n", i, x);
        }
    }

    return 0;
}


Measured memory_bytes: 2016
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
typedef long long ll;
using namespace std;
const ll mod=1000000007,mod9=1000000009;
template <class T>inline T lcm(T a,T b){return (a*b/__gcd(a,b));}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin>>a>>b;
    int c=max(a+b,a-b);
    cout << (max(a*b,c))<<endl;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
using namespace std;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[10000001];
//char str[1010][1010];
//vector<pair<int,int> > pc[100001];
//int ABS(int a){return max(a,-a);}
//long long num[100000];
int main(){
	int n,cnt=0,ans;
	cin>>n;
	int a[n],c[100];
	for(int i=0;i<100;i++) c[i]=0;
	for(int i=0;i<n;i++){
		 cin>>a[i];
		 if(a[i]<400) c[0]=1;
		 else if(a[i]<800) c[1]=1;
		 else if(a[i]<1200) c[2]=1;
		 else if(a[i]<1600) c[3]=1;
		 else if(a[i]<2000) c[4]=1;
		 else if(a[i]<2400) c[5]=1;
		 else if(a[i]<2800) c[6]=1;
		 else if(a[i]<3200) c[7]=1;
		 else cnt++;
	}
	ans=c[0]+c[1]+c[2]+c[3]+c[4]+c[5]+c[6]+c[7];
	cnt+=ans;
	if(ans==0)ans=1;
	cout<<ans<<' '<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iomanip>
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <tuple>
#include <climits>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<double> VD;
typedef vector<LL> VLL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef vector<vector<long long>> VVLL;
typedef vector<vector<bool>> VVB;
typedef vector<vector<double>> VVD;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(a) (a).begin(),(a).end()

const int MOD = 1000000007;

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

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

void debug(VI &arr){
	int n=arr.size();
	rep(i,n){
		cout<<arr.at(i)<<endl;
	}
}

void debug(VVI &board){
	int h = board.size();
	int w = board.at(0).size();
	rep(i,h){
		rep(j,w){
			cout << board.at(i).at(j) << " ";
		}
		cout<<endl;
	}
}

void debug(VVLL &board){
	int h = board.size();
	int w = board.at(0).size();
	rep(i,h){
		rep(j,w){
			cout<<board.at(i).at(j)<<" ";
		}
		cout<<endl;
	}
}

void debug(VS &board){
	int h = board.size();
	rep(i,h){
		cout<<board.at(i)<<endl;
	}
	return;
}

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

LL lcm(LL a,LL b){
	return a*b/gcd(a,b);
}

int main(){
	//cout<<fixed;
	//cout<<setprecision(9)<<...
	int a,b;
	cin>>a>>b;
	cout<<a*b<<endl;
	return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10; 

int deg[N];
vector<int> g[N];
int n;
int parent[N];
int col[N];
int mx;

void dfs(int u,int p = -1,int c = -1){
   parent[u] = p;
   col[u] = c;
   int prv = c;
   for(auto &v : g[u]){
      if(v!=p){
         prv++;
         prv = prv%mx;
         if(c == prv){
            prv++;
         }
         prv = prv%mx;
         dfs(v,u,prv);
      }
   }
}

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   cin >> n;
   int u,v;
   vector<pii> edge(n-1);
   f(i,1,n){
      cin >> u >> v;
      g[u].pb(v);
      g[v].pb(u);
      edge[i-1] = {u,v};
      deg[u]++;
      deg[v]++;
      mx = max({mx,deg[u],deg[v]});
   }
   dfs(1);
   cout << mx << '\n';
   f(i,0,n-1){
      if(edge[i].F == parent[edge[i].S]){
         cout << col[edge[i].S]+1 << '\n';
      }else{
         cout << col[edge[i].F]+1 << '\n';
      }
   }
   return 0;
} 


Measured memory_bytes: 11392
#include<bits/stdc++.h>
using namespace std;
const int INF=1000000000;
int main(){
    int a, l, numlog[30];
    while (cin >> a >> l && l)
    {
        for (int i = 0; i < 30; i++){
            numlog[i] = 0;
        }
        numlog[0] = a;
        char tmp[l];
        int tmpa = a,flag=0;
        for (int j = 1;; j++){
            for (int i = 0; i < l; i++)
            {
                tmp[i] = tmpa % 10;
                tmpa /= 10;
            }
            int amax = 0, amin = 0;
            sort(tmp, tmp + l);
            for (int i = 0, p = 1; i < l; i++,p*=10){
                amin += (int)tmp[l - 1 - i] * p;
                amax += (int)tmp[i] * p;
            }
            tmpa = amax - amin;
            int now = 0;
            for (int i = 0; i<j;i++){
                if(numlog[i]==tmpa){
                    cout << i << " " << tmpa << " " << j - i<< endl;
                    flag = 1;
                    break;
                }
                now++;
            }
            numlog[now] = tmpa;
            if(flag)
                break;
            
        }
   }
   return 0;
}


Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

template<int Modulo = MOD> struct Mint {
	Int val;
	constexpr Mint(Int v = 0) noexcept : val(v% Modulo) {
		if (val < 0) v += Modulo;
	}
	constexpr int getmod() { return Modulo; }
	constexpr Mint operator - () const noexcept { return val ? Modulo - val : 0; }
	constexpr Mint operator + (const Mint& r) const noexcept { return Mint(*this) += r; }
	constexpr Mint operator - (const Mint& r) const noexcept { return Mint(*this) -= r; }
	constexpr Mint operator * (const Mint& r) const noexcept { return Mint(*this) *= r; }
	constexpr Mint operator / (const Mint& r) const noexcept { return Mint(*this) /= r; }
	constexpr Mint& operator += (const Mint& r) noexcept {
		val += r.val;
		if (val >= Modulo) val -= Modulo;
		return *this;
	}
	constexpr Mint& operator -= (const Mint& r) noexcept {
		val -= r.val;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr Mint& operator *= (const Mint& r) noexcept {
		val = val * r.val % Modulo;
		return *this;
	}
	constexpr Mint& operator /= (const Mint& r) noexcept {
		Int a = r.val, b = Modulo, u = 1, v = 0;
		while (b) {
			Int t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		val = val * u % Modulo;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr bool operator == (const Mint& r) const noexcept {
		return this->val == r.val;
	}
	constexpr bool operator != (const Mint& r) const noexcept {
		return this->val != r.val;
	}
	friend ostream& operator << (ostream& os, const Mint<Modulo>& x) noexcept {
		return os << x.val;
	}
	friend istream& operator >> (istream& is, Mint<Modulo>& x) noexcept {
		Int tmp; is >> tmp;
		x = Mint<Modulo>(tmp);
		return is;
	}
	friend constexpr Mint<Modulo> modpow(const Mint<Modulo>& a, Int n) noexcept {
		Mint res(1), tmp = a;
		while (n > 0) {
			if (n & 1) res *= tmp;
			tmp *= tmp;
			n >>= 1;
		}
		return res;
	}
};

using mint = Mint<>;
Int N=50;

vector<vector<bool>> graph(N, vector<bool>(N, false));
vector<bool> seen(N);

void dfs(Int v) {
	seen[v] = true;

	for (Int i = 0; i < N;i++) {
		if (graph[v][i] == false)continue;
		if (seen[i] == true)continue;
		dfs(i);
	}

}

int main() {

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

	Int M;
	cin >> N >> M;

	vector<Int> a(M);
	vector<Int> b(M);

	

	Int tempa, tempb;
	for (Int i = 0; i < M; i++) {
		cin >> tempa >> tempb;
		tempa--;
		tempb--;//0-indexed
		a[i] = tempa;
		b[i] = tempb;
		graph[tempa][tempb] = graph[tempb][tempa] = true;
	}

	Int ans = 0;
	for (Int i = 0; i < M; i++) {
		graph[a[i]][b[i]] = graph[b[i]][a[i]]=false;

		for (Int i = 0; i < N; i++) {
			seen[i] = false;
		}

		dfs(0);

		bool temp = true;
		for (Int j = 0; j < N; j++) {
			if (seen[j] == false) {
				temp = false;
				break;
			}
		}
		
		if (temp == false)ans++;
		graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;

	}

	cout << ans << "\n";

}

Measured memory_bytes: 256
N = int(raw_input())
health = map(int, raw_input().strip().split())

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

if len(health) == 1:
	print(health[0])
else:
	g = gcd(health[0], health[1])
	for i in range(2, len(health)):
		g = gcd(g, health[i])
print(g)

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e19;
//const int INF=(1<<30);


int main(){
  int a,b;
  cin >> a >> b;
  cout << (a-1)*(b-1) << endl;
}



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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

bool ng[10];

signed main(){
    int N,K;
    cin>>N>>K;
    rep(i,K){
        int d;cin>>d;
        ng[d]=true;
    }

    for(;;N++){
        stringstream ss;
        ss<<N;
        string s=ss.str();
        bool ok=true;
        rep(j,s.size())if(ng[s[j]-'0'])ok=false;
        if(ok){
            cout<<N<<endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using u32 = uint32_t;
using vi = vector<int>;    using vvi = vector<vi>;
using vb = vector<bool>;   using vvb = vector<vb>;
using vl = vector<ll>;     using vvl = vector<vl>;
using vd = vector<double>; using vvd = vector<vd>;

#define MAXC(c, x) (c = max(c, x))
#define MINC(c, x) (c = min(c, x))

#define REP(i,n) for(auto i = 0 * (n), i##_len = (n); i < i##_len; ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i,s,n) for(ll i=s, i##_len=(ll)(n); i<i##_len; ++i)
#define TEN(x) ((ll)1e##x)
const ll mod = TEN(9) + 7;

const ll INF = 1e9;

int main() {
	#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
	#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(50);

	ll n, a, b; cin >> n >> a >> b;
	if (a + b > n + 1 || n > a * b) {
		cout << -1 << endl;
	} else {
		ll i_a = (n - b + 1) - (a - 1);
		FOR(i, i_a, n - b + 1) cout << i << " ";
		for (ll i = i_a - (a - 1); true ; i -= a - 1) {
			FOR(j, max(i, 1ll), i + a - 1) cout << j << " ";
			if (i <= 1) break;
		}
		for (ll i = n; i >= n - b + 1; i--) cout << i << " ";
	}

	return 0;
}


Measured memory_bytes: 2176
s = input()
if s[0] != "A":
    print("WA")
    exit()
if s[1].isupper():
    print("WA")
    exit()
if s[-1].isupper() or s[-1] == "C":
    print("WA")
    exit()
flag = False
for c in s[2:]:
    if c == "C":
        if flag:
            print("WA")
            exit()
        else:
            flag = True
    else:
        if c.isupper():
            print("WA")
            exit()
if flag:
    print("AC")
else:
    print("WA")


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
typedef long long ll;

int main()
{
    long N;
    cin >> N;
    
    long cnt = 0;
    vector<long> a(N);
    rep(i, N) {
        cin >> a.at(i);
        if (a.at(i) == cnt + 1) {
            cnt++;
        }
    }

    if (cnt == 0) {
        cout << -1 << endl;
        return 0;
    }

    cout << N - cnt << endl;
    return 0;
}

Measured memory_bytes: 1792
#include"bits/stdc++.h"
using namespace std;
#define REP(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))
using ll=long long;
constexpr int LIM=100001;

int main()
{
	int X;
	cin>>X;
	bitset<LIM> bits;
	bits[0]=true;
	rep(i,LIM)if(bits[i]){
		REP(j,i+100, min(i+106,LIM)){
			bits[j] = true;	
		}
	}
	cout<<(bits[X]?1:0)<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    int X, Y, Z; cin >> X >> Y >> Z;
    swap(X, Y);
    swap(X, Z);
    cout << X << ' ' << Y << ' ' << Z << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define repB(i, z, n) for(int i = n - 1; i >= z; i--)
#define all(v) v.begin(), v.end()
typedef long long ll;
#define PI 3.14159265358979
//const int64_t INF = 1LL << 60;
const int INF = 1 << 29;
const int64_t MOD = 1000000007;
//const int64_t INF = 998244353;
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; }
using namespace std;
//#define P pair<int, int>
typedef pair<int, int> P;

int main(){
    int64_t A;
    double B;
    cin >> A >> B;
    int64_t C = (B + 0.001) * 100;
    int64_t D = (A * C) / 100;
    cout << D << endl;
}

Measured memory_bytes: 3720
#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>;

int main() {
  int a, b, h, m;
  cin >> a >> b >> h >> m;
  const double PI = acos(-1);
  double As = (PI * (h * 60 + m)) / 360;
  double Bs = (PI * m) / 30;
  double cosAB = cos(abs(As - Bs));
  double ansq;
  ansq = a * a + b * b - 2 * a * b * cosAB;
  double ans;
  ans = sqrt(ansq);
  cout << fixed << setprecision(10);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4208
n, a, b = [int(w) for w in input().split()]


def sum_digit(n):
    t = 0
    while n > 0:
        t += n % 10
        n //= 10
    return t


ans = 0
for i in range(1, n + 1):
    if a <= sum_digit(i) <= b:
        ans += i
print(ans)


Measured memory_bytes: 9072
import itertools

N, M, Q = map(int, input().split())

ABCD = [list(map(int, input().split())) for _ in range(Q)]

ALIST = list(itertools.combinations_with_replacement([i for i in range(1, M+1)], N))

total = 0

for A in ALIST:
  tokuten = 0
  for a, b, c, d in ABCD:
    diff = A[b-1] - A[a-1]
    if diff == c:
      tokuten += d
  total = max(total, tokuten)
print(total)


Measured memory_bytes: 84640
input = STDIN.read.split("\n").map{|l| l.split(" ").map{|a| a.to_i}}

N = input[0][0]
h = input[1]
yari = 0

while true
    has_yari = false
    yaring = false
    for i in 0..(h.length - 1)
        if h[i] > 0 && yaring == false
            yari = yari + 1
            yaring = true
            has_yari = true
        end

        if h[i] <= 0 && yaring == true
            yaring = false
            has_yari = true
        end
    end

    if has_yari == false
        break
    end
    h = h.map{|i| i - 1}
end

puts yari

Measured memory_bytes: 1916
import queue
def main():
	count_list = []

	w,h = map(int,input().split())
	while not(w == 0 and h == 0):
		data = []
		count = 0
		for _ in range(h):
			data.append(list(map(int,input().split())))

		for row,i in zip(data,range(len(data))):
			for cell,j in zip(row,range(len(row))):
				if cell == 1:
					fill_sea(data,j,i,w,h)
					count += 1

		w,h = map(int,input().split())
		count_list.append(count)




	for i in count_list:
		print(i)


def fill_sea(data,x,y,w,h):
	q = queue.LifoQueue()
	q.put((x,y))
	while not q.empty():
		current_cell = q.get()
		data[current_cell[1]][current_cell[0]] = 0


		for i in [-1,0,1]:
			if current_cell[1]+i <= -1 or  current_cell[1]+i >= h:
				continue
			for j in [-1,0,1]:
				if i == 0 and j == 0:
					continue
				if current_cell[0]+j <= -1 or current_cell[0]+j >= w :
					continue

				if data[current_cell[1]+i][current_cell[0]+j] == 1:
					q.put((current_cell[0]+j,current_cell[1]+i))


if __name__ == '__main__':
	main()


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


int main(){
  
  int K, S, Sum = 0;
  cin >> K >> S;
  
  for(int i = 0; i <= K; i++){
    for(int j = 0; j <= K; j++){
    
      if(S - i - j <= K && S - i - j >= 0) Sum++;
    }
  }
  cout << Sum << endl;
  return 0;
}

Measured memory_bytes: 256
import Data.List

main :: IO ()
main = do
  n <- readLn :: IO Int
  as <- map read . words <$> getLine :: IO [Integer]
  putStrLn . unwords . map show $ solve n as

solve n as = map (2*) $ x1 : (reverse . tail $ scanl' (\acc x -> x - acc) x1 . reverse $ tail as)
  where
    evens = map fst . filter (\(_, i) -> even i) $ zip as [1..]
    x1 = (sum as) `div` 2 - sum evens


Measured memory_bytes: 73084
N = (input())
N = N[-1]

hon = [str(n) for n in list([2,4,5,7,9])]
pon = [str(n) for n in list([0,1,6,8])]
bon = ["3"]

if N in hon:
  print('hon')
elif N in pon:
  print("pon")
elif N in bon:
  print("bon") 
else:
  print("booom")

Measured memory_bytes: 9084
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

bool desc_comp(int x, int y) {
  if (x > y) return true;
  else return false;
}

int main() {
  vector<int> cards;
  int N;
  cin >> N;
  cards.resize(N);

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

  sort(cards.begin(), cards.end(), desc_comp);

  int A, B;
  A = B = 0;
  for (int i = 0; i < N; ++i) {
    if (i % 2) {
      B += cards[i];
    } else {
      A += cards[i];
    }
  }

  cout << A - B << endl;

  return 0;
}


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

int	main()
{
	int N;
	cin >> N;
	string S, T;
	cin >> S >> T;
	for (int i = 0; i < N; ++i) {
		cout << S.at(i) << T.at(i);
	}
	cout << endl;
}


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

using namespace std;

string x[] = { "dream", "dreamer", "erase", "eraser" };

int main() {
	bool flag;
	string s;
	cin >> s;
	while (true) {
		flag = false;
		for (int i = 0; i < 4; i++) {
			if (s.length() >= x[i].length() && (s.substr(s.length()-x[i].length(),x[i].length())).compare(x[i]) == 0) {
				flag = true;
				s = s.substr(0, s.length() - x[i].length());
				break;
			}
		}
		if (s.compare("") == 0 || !flag)break;
	}

	if (flag) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 544
n, m = map(int, input().split())
a = []
for _ in range(n):
    a.append([0]*n)
    
for _ in range(m):
    i, j = map(int, input().split())
    a[i-1][j-1] += 1
    a[j-1][i-1] += 1
for a_ in a:
    print(sum(a_))

Measured memory_bytes: 3060
#include <cstdio>
using namespace std;
const int maxn = 200000;
int N,A[maxn],mx1,mx2;
int main() {
    scanf("%d",&N); for (int i = 0;i < N;i++) scanf("%d",&A[i]);
    for (int i = 0;i < N;i++) {
        if (A[i] > mx1) mx2 = mx1,mx1 = A[i];
        else if (A[i] > mx2) mx2 = A[i];
    }
    for (int i = 0;i < N;i++) if (A[i] == mx1) printf("%d\n",mx2); else printf("%d\n",mx1);
}


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

int main()
{
	int a,b;
	cin >> a >> b;
	int c = (a+b)%3;
	if(a%3 == 0 || b%3 == 0 || (a+b)%3 == 0){
		cout << "Possible" << endl;
	}else{
		cout << "Impossible" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>       // printf,scanf
#include <stdlib.h>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>  //sort,binarySearch
#include <functional> 
#include <iomanip>    // setprecision
#include <utility>    // c+11 Array
#include <set>
#include <sstream>
#include <map>
#include <bits/stdc++.h>
#define MOD 1000000007
#define PI 3.141592653589793238462643383279
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define pb(x) push_back(x)
#define debug(x) cout << #x << " = " << x << endl;
#define debret(x) debug(x) ; return 0;

using namespace std;

int main(void){

    int num,color;

    cin >> num >> color;

    int ans;

    if(num != 1){
        ans = color*pow((color-1),(num-1));
    }else{
        ans = color;
    }

    cout << ans << endl;

    return 0;
}


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

#define fi first
#define sd second
#define lson (nd<<1)
#define rson (nd<<11)
#define PB push_back
#define mid (l+r>>1)
#define MP make_pair
#define SZ(x) (int)x.size()

using namespace std;

typedef long long LL;

typedef vector<int> VI;

typedef pair<int,int> PII;

inline int read(){
    int res=0, f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){res=res*10+ch-'0';ch=getchar();}
    return res*f;
}

const int MAXN = 200'005;

const int MOD = 1000000007;

int main(){
    int n,m;
    n=read();m=read();

    int ans=n*(n-1)/2+m*(m-1)/2;

    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<deque>
#include<set>
#include<map>
#include<bitset>
#include<ctime>
#include<queue>
using namespace std;
#define int long long
#define mn 100005
#define inf 4444444444444444444
#define mod 1000000009
#define FLN "test"
#define pii pair <int, int>
#define XX first
#define YY second

int n, p;
int cnt[1000006];

signed main()
{
#ifdef lowie
	freopen(FLN".inp", "r", stdin);
	freopen(FLN".out", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cin>>n>>p;
	for (int i=2; i<=1000000; i++)
	{
		while (p%i==0)
		{
			p/=i;
			cnt[i]++;
		}
	}
	
	int ans=1;
	if (n==1) if (p>1) ans=p;
	for (int i=2; i<=1000000; i++)
	{
		int c=cnt[i]/n;
		while (c--) ans*=i;
	}
	cout<<ans;
}

// PLEASE REMOVE "cout" AND "cerr" DEBUG LINES BEFORE SUBMITTING PROBLEMS
// Code by low_
// Contact me via mail: dung.totuan01@gmail.com
// ...or codeforces: www.codeforces.com/profiles/low_
// ...or if you're interested in food: www.instagram.com/lowie_review/


Measured memory_bytes: 2304
q=list(input().split())
a=int(q[0])
b=int(q[1])
for i in range(2):
  if a>=b:
    if i==0:
      r=a
    else:
      v=a
    a=a-1
  else:
    if i==0:
      r=b
    else:
      v=b
    b=b-1
g=int(r+v)
print(g)

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	#define int  long long int
	#define pb push_back
	#define fe first
    #define lb lower_bound 
    #define ub upper_bound
    #define pii pair<pair<int,int>,pair<int,int> >
	#define se second
	#define endl "\n"
	#define pi pair<int, int>
	#define vi vector<int> 
	#define vvi vector<vi>
    #define bs   binary_search
	#define rep(i,a,b) for(int i=a;i<b;i++)
	#define rep1(i,a,b) for(int i=a;i<=b;i++)	
    #define all(c) (c).begin(),(c).end()
    #define sz(x)       (int)x.size() 
	#define PI 3.14159265358979323846
    
	const int N =1e5+10;
    
     int mod= 998244353;
     int dx[4]={0,0,+1,-1};
     int dy[4]={+1,-1,0,0};
  
   
     vi v[N];
     multiset<int> mt;
     
  void solve() {
            
         int n,m;
         cin>>n>>m;        
         
         rep(i,0,n){             
             int x,y;
             cin>>x>>y;
             v[x].pb(y);    
         }  
         
         int tt=0;
         //~ cout<<"-------\n";
         //~ rep(i,0,sz(vp)){
             //~ cout<<vp[i].fe<<" "<<vp[i].se<<endl;
         //~ }
         
         for(int i=1;i<=m;i++){
              
              for(auto to:v[i])
                mt.insert(to);
            
             if(sz(mt)>0){ 
               auto it=mt.end();
               it--;
               
               //~ cout<<(*it)<<endl;
               tt+=(*it);
               mt.erase(it);             
             }       
         }
         
         cout<<tt<<endl;         
  }
 
   
  int32_t main() {
    cool;
    int t=1;
    while(t--)
       solve();
  
       return 0;	   
   }


Measured memory_bytes: 8320
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  long long N;
  cin >> N;
  long long tempN = N;
  vector<pair<int, int>> prime;
  bool is_prime = true;
  for (long long i = 2; i * i <= N; i++)
  {
    if (tempN % i == 0)
    {
      prime.push_back(make_pair(i, 0));
      while (tempN % i == 0)
      {
        tempN /= i;
        prime.back().second++;
      }
      is_prime = false;
    }
  }
  if (is_prime)
    prime.push_back(make_pair(N, 1));

  set<long long> st;
  st.insert(1);
  rep(i, prime.size()) rep(j, prime[i].second)
  {
    set<long long> temp_st = st;
    for (long long n : st)
    {
      temp_st.insert(n * prime[i].first);
    }
    st = temp_st;
  }

  long long ans = 0;
  for (long long a : st)
  {
    long long m = N / a - 1;
    if (m != 0 && N / m == N % m)
      ans += m;
  }
  cout << ans << endl;
  return 0;
}

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

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

using ll = long long int;
const ll MOD = 1e9 + 7;

int main() {
  int A, B, H, M;
  std::cin >> A >> B >> H >> M;

  const double PI = std::acos(-1);

  const int T = 60 * 60 * H + 60 * M;

  const double omega_l = 2.0 * PI / 60 / 60;
  const double omega_s = omega_l / 12;
  const double theta = std::abs(omega_l - omega_s) * T;

  double ans = std::sqrt(A * A + B * B - 2 * A * B * std::cos(theta));
  std::cout << std::fixed << std::setprecision(10) << ans << '\n';
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int ll;

int main()
{

	ios_base:: sync_with_stdio(false); cin.tie(0);
	int a,b,c;
	cin>>a>>b>>c;
	if(a==b&&b==c) {
		cout<<"Yes"<<endl;
	}
	else {
		cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int readint() {
    return readln.chomp.to!int;
}

int[] readints() {
    return readln.split.map!(to!int).array;
}

void main() {
    int n;
    while ((n = readint) > 0) {
        int ans = 0;
        for (int i = 3; i <= n; i += 2) {
            if (n % i == 0) {
                ans++;
            }
        }
        writeln(ans);
    }
}

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

using namespace std;

#define Rep(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) for (int i=0;i<(n);i++)
#define ll long long

int main()
{
	int d;

	cin >> d;

	string s = "Christmas";

	rep (i, 25 - d)
		s += " Eve";

	cout << s << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <numeric>
#include <algorithm>
//#include <iomanip> : 表示桁数

#define pi 3.14159265358979323846
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
typedef unsigned char Byte;
using namespace std;

//string ans = "Yes";
int ans = 0;
int N, M, goal;
vector<int> Value;
vector<vector<int>> A;

//動的計画法 setup
vector<vector<int>> recValue;
/*
int dynamic(vector<vector<int>> & status) {
	nowValue = 0;
	rep(i, N) {
		rep(j, M) {

		}
	}
	return 0;
}*/

int GetSum(const vector<Byte> & status) {
	int nowAns = 0;
	vector<int> exp(M, 0);
	rep(i, N) {
		if (status[i] == 1) {
			nowAns += Value[i];
			rep(j, M) exp[j] += A[i][j];
		}
	}

	//アウトかどうか
	rep(j, M) if (exp[j] < goal) return -1;

	return nowAns;
}

int main() {
	//set up

	cin >> N >> M >> goal;

	vector<int> argValue(N);
	Value = argValue;
	vector<int> argargA(M);
	vector<vector<int>> argA(N, argargA);
	A = argA;


	vector<int> tmpv(M, -1);
	vector<vector<int>> tmpvv(N, tmpv);
	recValue = tmpvv;

	//input
	rep(i, N) {
		cin >> Value[i];
		rep(j, M) {
			cin >> A[i][j];
		}
	}

	//main process
	bool isEnd = false;
	vector<Byte> isUsed(N, 0);

	ans = -1;

	while (!isEnd) {
		int tmpAns = GetSum(isUsed);
		if (tmpAns >= 0 && ans >= 0) ans = min(tmpAns, ans);
		else if (tmpAns >= 0) ans = tmpAns;

		//カウンタ処理
		int i = 0;
		isUsed[0]++;
		while (isUsed[i] > 1) {

			isUsed[i] = 0;
			i++;

			if (i >= N) {
				isEnd = true;
				break;
			}
			isUsed[i] ++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3592