akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<LL,LL>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    LL from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};

int main(){

    CIN(A);CIN(B);CIN(C);
    I vec ={A,B,C};
    sort(ALL(vec),greater<int>());
    COUT(vec.at(0)*10+vec.at(1)+vec.at(2));
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int i,j,k;
	char c[21];
	int w,h;
	int map[22][22];
	int mapindex[22*22];
	int map_now,mapindex_now;
	
	while(1){
		scanf("%d %d",&w,&h);
		if(w==0){
			break;
		}
		for(i=0;i<22;i++){
			for(j=0;j<22;j++){
				map[i][j]=-1;
				mapindex[i*w+j]=0;
			}
		}
		for(j=0;j<=h;j++){
			gets(c);
			if(j!=0){
				for(i=1;i<=w;i++){
					switch(c[i-1]){
						case '#':map[i][j]=-1;break;
						case '@':map[i][j]=1;mapindex[1]=i+j*(w+1);break;
						case '.':map[i][j]=0;break;
						default :break;
					}
				}
			}
		}
		/*
		for(j=0;j<22;j++){
			for(i=0;i<22;i++){
				printf("%2d",map[i][j]);
			}
			printf("\n");
		}*/
		
		map_now=1;
		mapindex_now=1;
		while(mapindex[mapindex_now]!=0){
			int x=(mapindex[mapindex_now]-1)%(w+1)+1;
			int y=mapindex[mapindex_now]/(w+1);
			for(i=0;i<4;i++){
				if(i==0){
					if(map[x-1][y]==0){
						map_now++;
						map[x-1][y]=map_now;
						mapindex[map_now]=(x-1)+y*(w+1);
					}
				}else if(i==1){
					if(map[x+1][y]==0){
						map_now++;
						map[x+1][y]=map_now;
						mapindex[map_now]=(x+1)+y*(w+1);
					}
				}else if(i==2){
					if(map[x][y-1]==0){
						map_now++;
						map[x][y-1]=map_now;
						mapindex[map_now]=x+(y-1)*(w+1);
					}
				}else if(i==3){
					if(map[x][y+1]==0){
						map_now++;
						map[x][y+1]=map_now;
						mapindex[map_now]=x+(y+1)*(w+1);
					}
				}
			}
			mapindex_now++;
		}
		printf("%d\n",mapindex_now-1);
		/*for(j=0;j<22;j++){
			for(i=0;i<22;i++){
				printf("%2d",map[i][j]);
			}
			printf("\n");
		}
		for(i=0;i<10;i++){
			for(j=0;j<10;j++){
				printf("%d\n",mapindex[i*w+j]);
			}
			printf("\n");
		}*/
	}
	return 0;
}

Measured memory_bytes: 608
#include<bits/stdc++.h>
// debug
#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl;
#define ddd(x, y, z) cerr << "(" #x "," #y "," #z "):(" << x << "," << y << "," << z << ")" << endl;
#define dump(v) cerr<<#v":[ ";for (auto macro_vi:v){cerr<<macro_vi<< " ";}cerr<<"]"<<endl;
#define ddump(v) cerr<<#v":"<<endl;for(auto macro_row:v) {cerr<<"["; for (auto macro__vi:macro_row){cerr<<macro__vi<< " ";}cerr<<"]"<<endl;}
#define damp(m) for(auto macro_pair:m){cerr<< macro_pair.first<<":"<<macro_pair.second<<endl;}
#define dpair(p) cerr << #p":"<<"(" << p.first << "," << p.second << ")" << endl;
// iterate
#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define reprrev(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define reprev(i, n) reprrev(i, 0, n)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
// etc
#define chmin(mi, val) mi = min(mi, val);
#define chmax(ma, val) ma = max(ma, val);
using ll = long long;

using namespace std;

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

    map<string, ll> mp;
    rep(i,n){
        string tmp;
        cin >> tmp;
        sort(tmp.begin(), tmp.end());
        mp[tmp]+=1;
    }
    damp(mp)
    ll ans=0LL;
    for(auto p : mp){
        ans+= (p.second-1)*(p.second)/2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 11264
def gcd(a, b):
    while b:
        a, b = b, a%b
    return a
def lcm(a, b):
	return a * b // gcd (a, b)

A, B, C, D = map(int, input().split())
c_div = max(B // C - ((A+C-1) // C) + 1, 0)
d_div = max(B // D - ((A+D-1) // D) + 1, 0)
cd_div = max(B // lcm(C, D) - ((A+lcm(C, D)-1) // lcm(C, D)) + 1, 0)
ans = B - A + 1 - c_div - d_div + cd_div
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <string>

typedef long long int ll;
typedef unsigned long long int ull;

using namespace std;

int main()
{
  int n, ans, max = 0;

  cin >> n;

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

  for (int i = 0; i < n; i++)
  {
    if (h[i] >= max)
    {
      max = h[i];
      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}

// ...###..

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100005
#define NIL -1

struct Node{ int p, l, r, depth, degree, sibling, height;};
struct Node T[MAX];

int gheight;
int n;

void maketree(int id, int l, int r){
  if( l != -1 ){
    T[id].l = l;
    T[l].p = id;
    T[l].sibling = r;
    T[id].degree++;
  }
  if( r != -1 ){
    T[id].r = r;
    T[r].p = id;
    T[r].sibling = l;
    T[id].degree++;
  }
}

int search(int u, int i){
  while(1){
    if(i != u){
      i = T[i].p;
      gheight++;
    }
    if(i == -1){ 
      return 0;
      break;
    }
    else if(i == u) return 1;
  }
}

void print(int u){
  int i = 0;

  T[u].height = 0;
  for(i=0; i<n; i++){
    gheight = 0;
    if(T[i].r == -1 && T[i].l == -1){
      if(search(u, i) && gheight > T[u].height) T[u].height = gheight;
    }
  }
  if(T[u].p == -1){
    printf("node %d: parent = %d, ", u, T[u].p); 
    printf("sibling = %d, ", -1);
    printf("degree = %d, depth = %d, height = %d, root", T[u].degree, T[u].depth, T[u].height);
  }
  else if(T[u].l == -1 && T[u].r == -1) printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, leaf", u, T[u].p, T[u].sibling, T[u].degree, T[u].depth, 0);
  else printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, internal node", u, T[u].p, T[u].sibling, T[u].degree, T[u].depth, T[u].height);
}

int main(){
  int parent, i, id, l, r;

  scanf("%d",&n);
  for ( i = 0; i < n; i++ ) {
    T[i].p = T[i].l = T[i].r = T[i].sibling = NIL;
    T[i].height = 0;
  }
  for(i = 0; i < n; i++ ){
    scanf("%d%d%d",&id,&l,&r);
    maketree(id, l, r);
  }
  for(i = 0; i < n; i++ ){
    parent = T[i].p;
    while(1){
      if(parent == -1) break;
      parent = T[parent].p;
      T[i].depth++;
    }
    print(i);
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 608
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;

int n;
vector<vector<pair<int,int>>> edge(100010);
vin ans(100010,inf);

void dfs(int x,int color){
    ans[x]=color;
    for(auto p:edge[x]){
        if(ans[p.first]==inf){
            if(p.second%2)dfs(p.first,!ans[x]);
            else dfs(p.first,ans[x]);
        }
    }
    return;
}

int main(){
    cin>>n;
    vin u(n),v(n),w(n);
    rep(i,n-1){
        cin>>u[i]>>v[i]>>w[i];
        edge[u[i]].push_back(mp(v[i],w[i]));
        edge[v[i]].push_back(mp(u[i],w[i]));
    }
    dfs(1,1);
    rep2(i,1,n+1){
        cout<<ans[i]<<endl;
    }
}

Measured memory_bytes: 49280
#include <iostream>
#include <map>
#include <vector>
#include <deque>
#include <algorithm>
using namespace std;

map<int,int> cnt;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, k;
    cin>>n>>k;
    int ans = 0;
    for (int i=0; i<n; i++) {
        int a;
        cin>>a;
        cnt[a]++;
    }
    deque<int> v;
    for (pair<int,int> p: cnt) {
        v.push_back(p.second);
    }
    sort(v.begin(), v.end());
    while (v.size()>k) {
        ans+=v[0];
        v.pop_front();
    }
    cout<<ans;
}


Measured memory_bytes: 10496
L,R = map(int,input().split())
nums = []
for i in range(L,min(L+2019,R)+1):
    for j in range(L, min(L + 2019, R) + 1):
        if i==j:
            continue
        else:
            nums.append((i*j)%2019)
print(min(nums))

Measured memory_bytes: 149656
fn input_one<T: std::str::FromStr> () -> Result<T, T::Err> {
    let mut n = String::new();
    std::io::stdin().read_line(&mut n).unwrap();
    n.trim().parse()
}

fn main() {
    let c: String = input_one().unwrap();
    let c: String = c.chars().map(|v| (v as u8 + 1) as char).collect();
    println!("{}", c);
}

Measured memory_bytes: 2144
#include <bits/stdc++.h>
#define LL long long
using namespace std;
struct dsu
{
    int parent[100050];
    int teamSize[100050];
    dsu()
    {
        for(int i=0;i<100050;i++)parent[i]=i,teamSize[i]=1;
    }

    int findParent(int i)
    {
        if(parent[i]==i)return i;
        return parent[i]=findParent(parent[i]);
    }

    bool sameTeam(int x,int y)
    {
        int leaderX=findParent(x),leaderY=findParent(y);
        return leaderX==leaderY;
    }
    void mergeTeamsBySize(int x,int y)
    {
        int leaderX=findParent(x),leaderY=findParent(y);
        if (leaderX==leaderY)return;
        if(teamSize[leaderX]>teamSize[leaderY])
        {
            parent[leaderY]=leaderX;
            teamSize[leaderX]+=teamSize[leaderY];
        }
        else
        {
            parent[leaderX]=leaderY;
            teamSize[leaderY]+=teamSize[leaderX];
        }
    }

}d;
struct pt{int i,y,x;};
bool cmpx(pt a,pt b){return a.x<b.x;}
bool cmpy(pt a,pt b){return a.y<b.y;}
struct edge{int f,t,c;};
bool cmp(edge a,edge b){return a.c<b.c;}
vector<edge>v;
vector<pt>vv;
int n;
pt z;
edge q;
int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d%d",&z.x,&z.y);
        z.i=i;
        vv.push_back(z);
    }
    sort(vv.begin(),vv.end(),cmpx);
    for(int i=0;i<n-1;i++)
    {
        q.f=vv[i].i;
        q.t=vv[i+1].i;
        q.c=vv[i+1].x-vv[i].x;
        v.push_back(q);
    }
    sort(vv.begin(),vv.end(),cmpy);
    for(int i=0;i<n-1;i++)
    {
        q.f=vv[i].i;
        q.t=vv[i+1].i;
        q.c=vv[i+1].y-vv[i].y;
        v.push_back(q);
    }
    sort(v.begin(),v.end(),cmp);
    LL ans=0;
    for(auto i:v)
    {
        if(!d.sameTeam(i.f,i.t))
        {
            d.mergeTeamsBySize(i.f,i.t);
            ans+=i.c;
        }
    }
    cout<<ans;
}

Measured memory_bytes: 6952
n, k = map(int, input().split())
MOD = 1e9+7

def s(i,n):
    s1 = (2 * i * i)
    s2 = (3 * n * (i+1)) 
    s3 = 8

    d = (s2 + s3 - s1)

    ans = ( int((i * d)/6 + 0.5) )
    
    return ans

ans = int(s(n+1,n) - s(k-1,n)) % MOD
if ans < 0:
    ans += MOD

print(int(ans))

Measured memory_bytes: 9144
def main():
    n=int(input())
    a = list(map(int,input().split()))
    ans = [0 for i in range(n)]
    for i in range(n-1):
        ans[a[i]-1]+=1
    for i in range(n):
        print(ans[i])

if __name__ == "__main__":
    main()

Measured memory_bytes: 32300
#include<cstdio>
int main()
{
	int a,b,t,m;
	scanf("%d %d",&a,&b);
	t=a/b;
	m=a%b;
	if(t==0)printf("1");
	else if(m==0)printf("%d",t);
	else printf("%d",t+1);
	return 0;
 } 

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

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

bool f(ll h0,ll w0,ll h1,ll w1){
  if(h0*h0+w0*w0==h1*h1+w1*w1)return h0 < h1;
  else return h0*h0+w0*w0 < h1*h1+w1*w1;
}

int main(){
  while(1){
    ll h,w;
    cin>>h>>w;
    if(h==0)break;
    ll ch=200,cw=200;
    repl(i,1,201)repl(j,i+1,201){
      if(f(h,w,i,j)&&f(i,j,ch,cw)){
        ch=i; cw=j;
      }
    }
    cout<<ch<<" "<<cw<<endl;
  }
  return 0;
}



Measured memory_bytes: 3004
#include<iostream>
#include<queue>

#define UP 0x01
#define RIGHT 0x02
#define DOWN 0x04
#define LEFT 0x08

#define MAX 31

static const int dir[] = {UP,RIGHT,DOWN,LEFT};
static const int di[] = {-1,0,1,0};
static const int dj[] = {0,1,0,-1};
static const int infty = 1 << 29;

using namespace std;

inline bool isinside(int i, int j, int h, int w)
{
  return 0<=i&&i<h&&0<=j&&j<w;
}

struct Tile{
  int adj;  // bit link
  int cost;
  Tile():adj(0),cost(infty){}
};

int bfs(int sti, int stj, int h, int w, Tile M[][MAX]){
  queue< pair<int,int> > qp;
  bool vis[MAX][MAX] = {{false,},};

  qp.push( make_pair(sti,stj) );
  M[sti][stj].cost = 0;
  while(!qp.empty()){
    pair<int,int> now = qp.front();
    qp.pop();
    int ni = now.first, nj = now.second;
    //cout << M[ni][nj].adj << endl;
    for(int k=0;k<sizeof(di)/sizeof(*di);++k){
      int nxi = now.first + di[k];
      int nxj = now.second + dj[k];
      if( isinside( nxi, nxj, h, w ) ){
	if( (M[ni][nj].adj & dir[k]) &&
	    !vis[nxi][nxj] ){
	  M[nxi][nxj].cost = min( M[nxi][nxj].cost, M[ni][nj].cost + 1 );
	  vis[nxi][nxj]=true;
	  qp.push( make_pair( nxi, nxj ) );
	}
      }
    }
  }

  return M[h-1][w-1].cost;
}

int main()
{
  while(true){
    int w,h;
    cin >> w >> h;
    if( w == 0 && h == 0 ) break;
    Tile M[MAX][MAX];
    for(int i = 0; i < 2*h - 1; ++i){
      for(int j = 0; j < w-(i%2==0?1:0); ++j){
	int d;
	cin >> d;
	if( d==0 ){
	  if( i % 2 == 0 ){
	    M[i/2][j].adj |= RIGHT;
	    M[i/2][j+1].adj |= LEFT;
	  }else{
	    M[(i-1)/2][j].adj |= DOWN;
	    M[(i-1)/2+1][j].adj |= UP;
	  }
	}
      }
    }
    /*
    for(int i = 0; i < h; ++i){
      for(int j = 0; j < w; ++j){
	cout << M[i][j].adj << ' ';
      }
      cout << endl;
    }
    cout << endl;
    */
    int ans = bfs( 0,0,h,w,M )+1;
    if( ans >= infty )
      cout << "0" << endl;
    else cout << ans << endl;
  }
  return 0;
}

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

int main() {
    string n; cin >> n;
    const int m = n.size();
    auto check = [&] (string s) {
        return s.find('3') != string::npos && s.find('5') != string::npos && s.find('7') != string::npos;
    };
    function<int(int, string)> dfs = [&] (int d, string s) {
        if(d == m) return (int)(check(s) && s <= n);
        return dfs(d + 1, s + "3") + dfs(d + 1, s + "5") + dfs(d + 1, s + "7") + check(s);
    };
    cout << dfs(0, "") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
const int inf = 1e9;

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

	string s;
	cin >> s;
	int l;
	l = s.size();
	int ans = 0;
	for(int i=0;i<l-1;i++){
		if(s[i]=='A' && s[i+1]=='C'){
			ans = 1;
			break;
		}
	}
	if(ans==1){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<string,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<Pi,int> P2;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};


int main() {

	int n;
	cin>>n;
	cout<<(n-3+1)*180<<endl;
	return 0;

}


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

int main(){
  int X,N;
  cin >> X >> N;
  vector<int> A(N);
  rep(i,N) cin >> A.at(i);
  int t = 0;
  int ans = 100000;
  int Z = 10000;
  int F = 0;
  if(N == 0){
    cout << X << endl;
    return 0;
  }
  for(int i = -100;i < 200;i++){
    F = 0;
    rep(j,N){
      if(i == A.at(j)){
        F = 1;
      }
    }
    if(F == 1){
      continue;
    }
    t = X - i;
    if(t < 0){
      t = t * -1;
    }
   if(t == ans){
        continue;
      }
    ans = min(ans,t);
    if(ans == t){

      Z = min(Z,i);
      if(i > -100 ){
        Z = i;
      }
    }
  }
  cout << Z << endl;
  return 0;
  
  }




Measured memory_bytes: 3596
#include<stdio.h>
void insertion(int a[], int n)
{
  int i,j,k,x=0;
  for(i=1; i<n; i++){
    int tmp=a[i];
    for(j=i; j>0&&a[j-1]>tmp; j--)
      a[j]=a[j-1];//基準値より大きかったら前にする
    a[j]=tmp;	  //その他は基準値に戻す
    for(k=0; k<n; k++){
      if(k<n-1) printf("%d ",a[k]);
      else printf("%d",a[k]);
    }
    putchar('\n');    
  }
  
}
int main()
{
  int i,n;
  scanf("%d",&n);
  int a[n];
  for(i=0; i<n; i++)
    scanf("%d",&a[i]);
  for(i=0; i<n; i++){
    if(i<n-1) printf("%d ",a[i]);
    else printf("%d",a[i]);
  }
  putchar('\n');
  insertion(a,n);
  return 0;
}


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

using namespace std;

#define IO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define ull unsigned long long int

const int INF = 1e9 + 7;
const int N = 1e5+5;


int main() {

	IO;

	int n, m;
	cin >> n >> m;
	
	if (n <= m) {
		for (int i = 1; i <= m; ++i) 
			cout << n;
	}
	else {
		for (int i = 1; i <= n; ++i) 
			cout << m;
	}

}


Measured memory_bytes: 3580
import scala.annotation.tailrec
import scala.collection.mutable

object Main extends App {

  import scala.io.StdIn._
  import scala.math._

  val n = readLine.trim.toInt
  val edges = List.tabulate(n){_ ⇒ readLine.trim.toLong}.sorted(Ordering[Long].reverse)
  println(
    search(edges) match {
      case Some(r) ⇒ r
      case None ⇒ 0
    }
  )
  def search(edges: List[Long]): Option[Long] = {
    val susA = searchSingle(edges).flatMap{case (r, rest) ⇒ searchSingle(rest).map{case (s, _) ⇒ r + s}}
    val susB = searchDouble(edges)
    (susA, susB) match {
      case (Some(a), Some(b)) ⇒ Some(math.max(a, b))
      case (Some(a), _) ⇒ Some(a)
      case (_, Some(b)) ⇒ Some(b)
      case _ ⇒ None
    }
  }
  @tailrec
  def searchSingle(edges: List[Long]): Option[(Long, List[Long])] = {
    edges match {
      case a::b::c::t if a < b + c ⇒ Some(a + b + c, t)
      case _::(r@_::_::_) ⇒ searchSingle(r)
      case _ ⇒ None
    }
  }
  @tailrec
  def searchDouble(edges: List[Long]): Option[Long] = {
    edges match {
      case a::b::c::d::e::f::_ if canMakeTwoDouble(a, b, c, d, e, f) ⇒ Some(a + b + c + d + e + f)
      case _::(r@_::_::_::_::_::_) ⇒ searchDouble(r)
      case _ ⇒ None
    }
  }
  def canMakeTwoDouble(a: Long, b: Long, c: Long, d: Long, e: Long, f: Long): Boolean = {
    //一番を下げる、2番を上げる、3番を上げる
    // 111222
    // 112122 => 111222
    // 112212
    // 112221
    // 121122 => 112122 => 111222
    // 121212 => 112212
    // 121221 => 112221
    // 122112
    // 122121
    // 122211
    a < b + c && d < e + f ||
    a < b + e && c < d + f ||
    a < b + f && c < d + e ||
    a < d + e && b < c + f ||
    a < d + f && b < c + e ||
    a < e + f && b < c + d
  }


  implicit class Extenion[T](val value :T){
    def also(func: T ⇒ Unit): T = {
      func(value)
      value
    }
    def let[R](func: T ⇒ R): R = func(value)
  }
}


Measured memory_bytes: 66664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define F first
#define S second
#define endl '\n'
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define maxp 22
#define EPS (ld)(1e-18)
#define mod (int)(1e9+7)
#define N (int)(1e5+1)


int main (){
fastio;

string s;
string t;
cin>>s>>t;
int n=s.size();
int ans=0;
int i;
for(i=0;i<n;i++)
    if(s[i]!=t[i])
    ans++;
cout<<ans;

}


Measured memory_bytes: 3796
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

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

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;
// }}}

int N, M;
int a[10];
const int nes[] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
string m[10001];

void init()
{
}

string rec(int n)
{
    if(n == 0) return "";
    if(n < 0) return to_string(-1);
    if(m[n] != "") return m[n];
    string ret = string("0");
    REP(i, M){
        if(n >= nes[a[i]]){
            string next = rec(n - nes[a[i]]);
            if(next == "-1") continue;
            string nnext = to_string(a[i]) + next;
            if(ret.size() < nnext.size() || ret.compare(nnext) < 0) ret = nnext;
        }
    }
    if(ret == "0") return to_string(-1);
    return m[n] = ret;
}

void solve()
{
    sort(a, a+M, greater<int>());
    cout << rec(N) << endl;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M;
    REP(i, M) cin >> a[i];
    solve();
    return 0;
}

// vim:set foldmethod=marker:


Measured memory_bytes: 32896
from collections import deque
from collections import Counter
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect
#pypyではscipy, numpyは使えない
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree
#from scipy.sparse import csr_matrix, coo_matrix, lil_matrix
#import numpy as np
from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')

def main():
  s, t = input().split()
  print(t+s)
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 5076
# bitDP(集合を数に変換して状態(=添字)として持つようなDPのこと)
# dp[i][S]=(男性はi人目までで、既にペアになった女性の集合がSであるような場合の数)
# 「既にペアになった女性の集合がS」なら「bitpopcount(S)人目までをチェックした」ってことになるから、iを状態として持つ必要は無いことがわかる
import sys
input = sys.stdin.readline
mod=10**9+7
def main():
    n=int(input())
    a=[list(map(int,input().split())) for i in range(n)]
    dp=[0]*(1<<n)
    dp[0]=1
    for i in range(1,1<<n):
        k=bin(i).count("1")
        for j in range(n):
            if i>>j&1 and a[k-1][j]:
                dp[i]=(dp[i]+dp[i^(1<<j)])%mod
    print(dp[(1<<n)-1])
main()

Measured memory_bytes: 57452
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
using namespace std;
#define int long long
//#define d  long double
//#define d long double
#define pii pair<int,int>
#define pb push_back
#define N 200003
#define inf (int)1e18
#define haha ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int mod=1e9+7;

int go(int x)
{
    if(x<=1)
    return 0;
    else
    return x*(x-1)/2;
}


 
signed main()
{
    haha
    int n,m;
    cin>>n>>m;
    cout<<go(n)+go(m);
    
   
    
   
 
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <stack>
#include <math.h>
#include <string.h>
#include <map>
#include <bitset>

#define Z class
#define ln cout<<'\n'
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (n); ++i)
//ASCII a=97, A=65
// int H[N]; rep(i,N) scanf("%d", &H[i]);
// int max_x = *std::max_element(x.begin(), x.end());
// int min_y = *std::min_element(y.begin(), y.end());
// sort(vec.begin(), vec.end()); std::greater<>()
// reverse(vec.begin(), vec.end());
// scanf("%s",s);
// printf("%d\n",end-start+1);
// ceil (a + (b - 1)) / b

using namespace std;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
using pll = pair<long long, long long>;

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;}
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
const long long INF = 1LL << 60;

pair<pair<string, int>, int> p[110];
int main(){
    int A; cin >> A;
    rep (i, A) {
        string city; cin >> city;
        int score; cin >> score;
        p[i] = make_pair(make_pair(city, score * -1), i);
    }
    sort(p, p+A);
    rep(i, A) cout << p[i].second+1 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i ,n) for(int i = 0 ; i < (n) ; i ++ )
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using vin=vector<int>;
const int inf=1e9+7;
const ll INF=1e18;



int main() {
  ll h;
  cin>>h;
  /////////
  ll ans=0;
  int m=0;
  while(h!=0){
    m++;
    h/=2;
  }
  //cout<<m<<endl;
  //ans=1+2+4+...+2^(m-1)
  rep(i,m){
   ans+=pow(2,i); 
  }
  cout<<ans<<endl;
}


 







Measured memory_bytes: 764
sx, sy, tx, ty = gets.split.map &:to_i
ans = ''
ans = ans + 'U'*(ty-sy) + 'R'*(tx-sx)
ans = ans + 'D'*(ty-sy) + 'L'*(tx-sx)
ans = ans + 'L' + 'U'*(ty-sy+1) + 'R'*(tx-sx+1)+'D'
ans = ans + 'R' + 'D'*(ty-sy+1) + 'L'*(tx-sx+1)+'U'
puts ans

Measured memory_bytes: 1916
#include <stdio.h>
int main() {
  int a, b, c;
  scanf("%d\n%d\n%d", &a, &b, &c);
  if (a == b && a == c) {
    printf("1");
  } else if (a == b && a != c) {
    printf("2");
  } else if (a == c && a != b) {
    printf("2");
  } else if (c == b && a != c) {
    printf("2");
  } else {
    printf("3");
  }
  return 0;
}

Measured memory_bytes: 128
n = int(input())
CSF = [list(map(int,input().split())) for _ in range(n-1)]
Ans = []
from math import ceil
count = 0
for c,s,f in CSF:
    for i in range(count):
        Ans[i] = max(ceil(Ans[i]/f)*f + c , s + c)
    count += 1
    Ans.append(s+c)
print(*Ans,sep = "\n")
print(0)    

Measured memory_bytes: 3188
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<vector>
using namespace std;
using uint = unsigned int;
using ll = long long;
const int M = 1e9 + 7;
const ll MLL = 1e18L + 9;
#pragma unused(M)
#pragma unused(MLL)
#ifdef LOCAL
#include"rprint.hpp"
#else
template <class... T> void printl(T&&...){ }
template <class... T> void printc(T&&...){ }
template <class... T> void prints(T&&...){ }
template <class... T> void printd(T&&...){ }
#endif

int main(){
    int n, w;
    cin >> n >> w;
    int w1, v1;
    cin >> w1 >> v1;
    vector<int> ws = {w1}, vs = {v1};
    for(int i=1;i<n;i++){
        int w, v;
        cin >> w >> v;
        ws.push_back(w);
        vs.push_back(v);
    }
    if(false && w1 < 1000){
        vector<vector<int>> dp(n + 1, vector<int> (w + 1));
        for(int i=0;i<n;i++){
            for(int j=0;j<=w;j++){
                // dp[i + 1][j + ws[i]] = max({dp[i][j + ws[i]], dp[i + 1][j + ws[i]], dp[i][j] + vs[i]});
                dp[i + 1][j] = max({dp[i][j], dp[i + 1][j], j - ws[i] >= 0 ? dp[i][j - ws[i]] + vs[i] : 0});
            }
        }
        int ans = 0;
        for(int i=0;i<=w;i++){
            ans = max(ans, dp[n][i]);
        }
        // prints(dp);
        cout << ans << '\n';
    }else{
        int rem = w % w1;
        printd(rem);
        vector<vector<vector<int>>> dp(n + 1, vector<vector<int>> (n + 1, vector<int> (3 * n + 1)));
        for(int i=0;i<n;i++){
            for(int j=1;j<=n;j++){
                for(int k=0;k<=3 * n;k++){
                    // dp[i + 1][j][k] = 
                    dp[i + 1][j][k] = max({
                        dp[i][j][k],
                        dp[i + 1][j][k],
                        k - (ws[i] - w1) >= 0 ? dp[i][j - 1][k - (ws[i] - w1)] + vs[i] : 0
                    });
                }
            }
        }
        prints(dp);
        int ans = 0;
        for(int j=0;j<=n;j++){
            for(int k=0;k<=3 * n;k++){
                if(j * w1 + k > w){ continue; }
                ans = max(ans, dp[n][j][k]);
            }
        }
        cout << ans << '\n';
    }
    return 0;
}


Measured memory_bytes: 13304
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int h = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		int r = sc.nextInt();
		//xの条件
		Boolean statusX = (x >= r && x <= (w-r)) ? true : false;
		//yの条件
		Boolean statusY = (y >= r && y <= (h-r)) ? true : false;
		
		if(statusX && statusY) System.out.println("Yes");
		else System.out.println("No");
	}

}

Measured memory_bytes: 17360
#if 0
date +%Y.%m.%d

以下二元组 (i, j) 均只考虑 i < j 的情况，询问假定 x < y 。

设 g[x][y] 为范围内最大值，即第一个答案。
g[x][y] 是很好算的，根据 (i=F[k], j=F[k + 1]) 是满足 f[i][j] = k 的最小二元组可以知道。
其中 F[k] 表示第 k 个斐波那契数。

称满足 f[i][j] = g[i][j] = k 的二元组 (i, j) 为 good pair of k 。
那么第二个答案就只需要统计范围内的 good pair of g[x][y] ，i = j 的另算。

然而 good pair 的数量巨大，比如所有 (i=1, j>1) 都是 good pair of 1 。
但注意到许多 good pair 经过一次 gcd 后就会变得一样，
把这些 good pair 缩在一起，用一个最小的来表示，称作 excellent pair 。
形式化的，(i, j) 是 excellent pair of k 当且仅当：
1. (i, j) 是 good pair of k
2. j <= 2i
那么 (i, j) 这个 excellent pair 实际上就代表了 (i, j), (i, j + i), (i, j + 2i) ...
这些 good pair 。

excellent pair 的数量是很少的，excellent pair of 只有恰好 k 个。
考虑怎么预处理 excellent pair ，
excellent pair 经过一次 gcd 后一定是一个 good pair ，
通过 excellent pair of k ，每个 (i, j) 改为 (j, i + j) 就是一个新的 excellent pair of k + 1 ，
另外还会多出来一个 excellent of k + 1 是 (F[k + 2], F[k] + F[k + 2]) 。
#endif
#include <cstdio>
#include <algorithm>
#include <vector>
#define debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long ll;
typedef std::pair<ll, ll> par;

struct {
	inline operator int () { int x; return scanf("%d", &x), x; }
	inline operator ll () { ll x; return scanf("%lld", &x), x; }
	template<class T> inline void operator () (T &x) { x = *this; }
	template<class T, class ...A> inline void operator () (T &x, A &...a)
	{ x = *this; this -> operator ()(a...); }
} read;

const int maxk = 100, mod = 1000000007;
ll fi[maxk];
std::vector<par> excellent[maxk];

int main() {
	int k = 1;
	fi[0] = fi[1] = 1;
	ll lim = 1000000000000000000;
	while(fi[k] + fi[k - 1] <= lim) {
		++ k;
		fi[k] = fi[k - 1] + fi[k - 2];
	}

	excellent[1].push_back(par(1, 2));
	for(int i = 2; i <= k; i ++) {
		for(par p : excellent[i - 1])
			excellent[i].push_back(par(p.second, p.first + p.second));
		excellent[i].push_back(par(fi[i + 1], fi[i + 1] + fi[i - 1]));
	}

	int q = read;
	while(q --) {
		ll x = read, y = read;
		if(x > y) std::swap(x, y);

		int max = 1;
		while(max + 2 <= k and fi[max + 1] <= x and fi[max + 2] <= y)
			++ max;

		/* debug("q\n"); */
		ll tot = 0;
		for(par p : excellent[max]) {
			/* debug("%lld %lld\n", p.first, p.second); */
			if(p.first <= x and p.second <= y)
				tot += (y - p.second) / p.first + 1;
			if(p.second <= x)
				tot += (x - p.second) / p.first + 1;
			tot %= mod;
		}

		if(max == 1)
			tot += x;

		printf("%d %lld\n", max, tot);
	}
}


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

#define int long long int
#define double long double
#define pb push_back
#define fi first
#define se second
#define vii vector<int>
#define pii pair<int,int>
#define vpii vector<pii>
#define pq priority_queue<int>
#define test int tcase; cin>>tcase; for(int tc = 1; tc <= tcase; tc++)
#define inp(a,n,f) int a[n+f];for(int hh=f;hh<n+f;hh++)cin>>a[hh];
#define prdec(k) cout<<fixed<<setprecision(k);
#define mem(a,k) memset(a,k,sizeof(a))
#define ub upper_bound
#define lb lower_bound
#define mii map<int,int>
#define all(v) v.begin(),v.end()
#define inf LLONG_MAX


signed main()
{
	#ifndef ONLINE_JUDGE
   		freopen("input.txt","r",stdin);
   		freopen("output.txt","w",stdout);   
	#endif

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

   	int n,i,ans=0;
   	cin>>n;
   	inp(a,n,0);
   	int mx=a[0];
   	for(i=1;i<n;i++)
   	{
   		if(a[i]<mx)
   			ans+=mx-a[i];
   		else
   			mx=max(mx,a[i]);
   	}
   	cout<<ans;
	return 0;
}


Measured memory_bytes: 5200
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
signed main(){
  int a,c=0;
  cin>>a;
  vector<int> b(a),d(a);
  fo(i,a)
    cin>>b[i];
/*  fo(i,a){
    if(b[i]>i+1)
      c=1;
  }*/
  int g=0;
  if(c)
    cout<<-1<<endl;
  else{
    while(b.size()>0){
      for(int j=b.size()-1;j>=0;j--){
        if(b[j]==j+1){
          d.insert(d.begin(),b[j]);
          b.erase(b.begin()+j);
          break;
        }
        else if(j==0){
          g=1;
          break;
        }
      }
        if(g==1)
          break;
    }
    if(g)
      cout<<-1<<endl;
    else{
      fo(i,a)
        cout<<d[i]<<endl;
    }
  }
}

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

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

using namespace std;
typedef long long ll;
typedef pair<int, int> pint;

const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;


int main() {
    int n; cin >> n;
    map<string, int> mp;
    rep(i, n) {
        string s; cin >> s;
        mp[s]++;
    }

    int mx = 0;
    for (auto m: mp) {
        mx = max(mx, m.second);
    }

    for (auto m: mp) {
        if (m.second == mx) cout << m.first << endl;
    }



    return 0;
}


    


Measured memory_bytes: 25216
#include<stdio.h>
int main(void)
{
	int a[100],i,x,j;
	for(i=0;i<10;i++){
		scanf("%d",&a[i]);
	}
	x=0;
	for(i=0;i<10;i++){
		for(j=i+1;j<10;j++){
			if(a[i]<a[j]){
				x=a[i];
				a[i]=a[j];
				a[j]=x;
			}
		}
	}
	printf("%d\n%d\n%d\n",a[0],a[1],a[2]);
	return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

template<class T1, class T2> void chmin(T1 &a, T2 b) { if (a>b)a = b; }

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////
int main() {
	ll N, M;
	cin >> N >> M;
	if (N * 2 >= M) {
		cout << M / 2 << endl;
	}
	else {
		ll ans = 0;
		ans += N;
		M -= 2 * N;
		ans += M / 4;
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 256
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998_244_353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(T)(ref T x, T y) { x.modm(y.modpow(mod - 2)); }

void main()
{
	auto S = RD;
	auto W = RD;

	writeln(W >= S ? "unsafe" : "safe");
	stdout.flush;
	debug readln;
}

Measured memory_bytes: 2680
import java.util.HashMap;
import java.util.List;
import java.util.Scanner;


public class Main {

    static void solve() {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int m = scan.nextInt();

        int v1 = n*(n-1)/2;
        int v2 = m*(m-1)/2;

        System.out.println(v1+v2);

    }


    public static void main(String[] args) {

        solve();

        //        Main m = new Main();
        //        Scanner scan = new Scanner(System.in);

        //        long n = scan.nextLong();
        //        long r = scan.nextLong();
        //        List<Long> list = new ArrayList<>();
        ////        int[] arr = new int[n];
        //        for (long i=0;i<n;i++){
        //            list.add(scan.nextLong());
        //        }
//            System.out.println(ch);
        //        solve(n, arr);
        //        scan.close();
    }


    class Counter extends HashMap<Integer, Integer> {
        public int get(int k) {
            return containsKey(k) ? super.get(k) : 0;
        }

        public void add(int k, int v) {
            put(k, get(k) + v);
        }
    }



    static class Node {
        int val;
        Node next;
        Node random;

        public Node(int val) {
            this.val = val;
            this.next = null;
            this.random = null;
        }
    }

//    static class Node {
//        int key;
//        int data;
//        Node next;
//        Node prev;
//
//        Node(int key, int data) {
//            this.key = key;
//            this.data = data;
//        }
//    }

    static class TreeNode {
        int val;
        TreeNode left;
        TreeNode right;

        TreeNode(int x) {
            val = x;
        }
    }

    static class Trie {
        void add(String word) {

        }

        boolean search(String w) {
            return false;
        }
    }

    static class Node1 {
        public int val;
        public List<Node1> children;

        public Node1() {
        }

        public Node1(int _val, List<Node1> _children) {
            val = _val;
            children = _children;
        }
    }

    ;

    static class TrieNode {

    }

    static class KvNode implements Comparable<KvNode> {
        String key;
        int freq;

        public KvNode(String key, int freq) {
            this.key = key;
            this.freq = freq;
        }

        @Override
        public int compareTo(KvNode o) {
            if (this.key.equals(o.key)) {
                return 0;
            }
            return Integer.compare(o.freq, this.freq);
        }
    }

    static class ListNode {
        int val;
        ListNode next;

        ListNode(int x) {
            val = x;
        }
    }
}


Measured memory_bytes: 21588
N, X = map(int, input().split())
min_amount = 1000
leftover = X
for i in range(N):
    amount = int(input())
    min_amount = min(amount, min_amount)
    leftover -= amount

doughnuts = N
while leftover >= min_amount:
    leftover -= min_amount
    doughnuts += 1

print(doughnuts)

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

int main() {
  int n;
  int flag = 0;
  int sum = 0;

  cin >> n;

  vector<int> a(n);
  vector<int> b(n,0);


  rep(i,n){
    cin >> a.at(i);
    if(a.at(i)%2==0){
      b.at(i) = 1;
      sum++;
    }
  }

  rep(i,n){
    if(b.at(i)==1){
      if(a.at(i)%3==0 || a.at(i)%5==0){
        flag ++ ;
      }
    }
  }

  if(flag == sum)
  cout << "APPROVED";
  else
  cout << "DENIED";
  
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
const int MAX_NUM = 999999999;
void solve() {
	string s; cin >> s;
	int year, month, day;
	sscanf(s.c_str(), "%d/%d/%d", &year, &month, &day);
	if (year <= 2019 && month <= 4 && day <= 30) {
		cout << "Heisei" << endl;
		return;
	}
	cout << "TBD" << endl;
	return;
}
int main() {
	solve();
	return 0;
}

Measured memory_bytes: 256
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() (int, []int) {
	n := readInt()
	return n, readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

// -----------------------------------------------------------------------------

func main() {
	defer stdout.Flush()
	H := readInt()
	W := readInt()
	h := readInt()
	w := readInt()
	println((H - h) * (W - w))
}

// -----------------------------------------------------------------------------


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(n);++i)
#define alrep(i,j,n) for(int i=0;i<(n);++i)for(int j=i+1;j<(n);++j)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int MOD=1e9+7;
const long long INF = 1LL << 60;
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 isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
void printb(unsigned int v) {
  unsigned int mask = (int)1 << (sizeof(v) * CHAR_BIT - 1);
  do putchar(mask & v ? '1' : '0');
  while (mask >>= 1);
}
void putb(unsigned int v) {putchar('0'), putchar('b'), printb(v), putchar('\n');}
#define ALL(W) (W).begin(),(W).end()

bool solve(int a){
  if(a>=1 && a<=9) return true;
  else return false;
}

signed main(){
  int A,B;
  cin >> A >> B;
  if(solve(A) && solve(B)) cout << A*B << endl;
  else cout << "-1" << endl;
  return 0;
}


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

int main(){
    int a,b;
    std::cin >> a>>b;
    if(a==1)a=14;
    if(b==1)b=14;
    if(a>b)std::cout << "Alice" << std::endl;
    else if(a==b)std::cout << "Draw" << std::endl;
    else std::cout << "Bob" << std::endl;
    
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
mod = 1000000007
cnt = [3 if i == 0 else 0 for i in range(N + 1)]
ans = 1

for a in A:
    ans = ans * cnt[a] % mod
    cnt[a] -= 1
    cnt[a+1] += 1

print(ans)

Measured memory_bytes: 14020
#include <stdio.h>;

int main() {
	int N,a[1001],i,j,tmp;
	scanf("%d",&N);
	for(i=0;i<N;i++){
		scanf("%d",&a[i]);
	}
	for(i=0;i<N;i++){
		for(j=0;j<N-1;j++){
			if(a[j]>a[j+1]){
				tmp = a[j];
				a[j] = a[j+1];
				a[j+1] = tmp;
			}
		}
	}
	printf("%d",a[N-1]-a[0]);

return 0;
}


Measured memory_bytes: 128
H, W = map(int, input().split())
A = []

for _ in range(H):
    row = list(input())
    if "#" in row:
        A.append(row)

for i in range(W):
    if "#" not in [a[i] for a in A]:
        for a in A:
            a[i] = None

for a in A:
    for i in range(W):
        s = a[i]
        if s != None:
            print(s, end="")
    print()


Measured memory_bytes: 4596
n = int(input())
height = [int(x) for x in input().split()]
step=0
max_step = 0
flag = height[0]
for h in height[1:]:
    if flag >= h:
        step += 1
    else:
        max_step = max(max_step, step)
        step=0
    flag = h
    if h == height[-1]:
        max_step = max(max_step, step)
print(max_step)

Measured memory_bytes: 14252