akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;

signed main(){
	rep(i,7){
		int x, y;
		scanf("%lld%lld", &x, &y);
		printf("%lld\n", x-y);
	}
	return 0;
}








Measured memory_bytes: 3232
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <math.h>
using namespace std;

struct Graph {
    struct Vertex { int n; int64_t c; };
    struct Edge { int i, n; int64_t c; };
    Graph(int n, int m) : v(n, { -1, 0 }), e(m), n(n), m(0) {}
    void add_edge(int i, int j, int c) {
        e[m] = { j, v[i].n, c };
        v[i].n = m;
        m++;
    }
    void dfs(int i, int p, int64_t c) {
        v[i].c = c;
        for (int j = v[i].n; j >= 0; j = e[j].n) {
            Edge& o = e[j];
            if (o.i == p) continue;
            dfs(o.i, i, c + o.c);
        }
    }
    vector<Vertex> v;
    vector<Edge> e;
    int n, m;
};

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

    int n;
    cin >> n;

    Graph g(n, (n - 1) * 2);
    for (int i = 0; i < n - 1; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;

        g.add_edge(a, b, c);
        g.add_edge(b, a, c);
    }

    int q, k;
    cin >> q >> k;
    k--;
    g.dfs(k, -1, 0);

    for (int i = 0; i < q; i++) {
        int x, y;
        cin >> x >> y;
        x--; y--;

        cout << g.v[x].c + g.v[y].c << '\n';
    }

    return 0;
}

Measured memory_bytes: 8960
#coding:utf-8
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]
    MOD = 10**9 + 7
    YesNo = lambda c : print('Yes') if c else print('No')

    c = input()
    print(chr(ord(c)+1))





if __name__ == '__main__':
    main()

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

int n,a[55];

int main() 
{
	ios_base::sync_with_stdio(false);
	//freopen(".inp","r",stdin);
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	sort(a+1,a+n+1);
	double sum=a[1];
	for(int i=2;i<=n;i++)
		sum=double(sum+a[i])/2.0;
	cout<<setprecision(6)<<fixed<<sum;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;

//#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define mkt make_tuple
#define no {cout << "No"; return;}

void solve() {
    ll n; cin >> n;
    cout << n * (n - 1) / 2;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //int t; cin >> t; loop(i, t)
    solve();
    return 0;
}

Measured memory_bytes: 3580
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
#include <set>

using namespace std;
set<string> mode(vector<string> s){
    set<string> modes;
    int count_max = 0;
    int count = 1;
    for(int i=0 ; i<s.size()-1; i++){
        if(s.at(i) == s.at(i+1)){
            count++;
        }else{
            count = 1;
        }
        if(count_max == count){
            modes.insert(s.at(i));
        }else if(count_max < count){
            count_max = count;
            modes.clear();
            modes.insert(s.at(i));
        }
        }
        
    if(count_max == 1){
        modes.insert(s.at(s.size()-1));
    }

    return modes;
}

int main(void){
    int n;
    cin >> n;
    vector<string> s(n);
    for(int i=0; i<n; i++){
        cin >> s.at(i);
    }
    sort(s.begin(), s.end());
    set<string> ans=mode(s);
        for(auto itr = ans.begin(); itr != ans.end(); ++itr) {
        std::cout << *itr << endl;
    }
}


Measured memory_bytes: 23652
#include "bits/stdc++.h"
using namespace std;
int main()
{
	int n,a,b;
	scanf("%d %d %d",&n,&a,&b);
	//边界：1~n 
	while(1)
	{
		if(a+1<=n&&a+1!=b)
		{
			a+=1;
		}
		else if(a+1==b&&a-1>0)
		{
			a-=1;
		}
		else if(a-1<1&&a+1==b)
		{
			printf("Borys\n");
			break;
		}
		//printf("%d %d\n",a,b);
		if(b-1>0&&b-1!=a)
		{
			b-=1;
		}
		else if(b+1<=n&&b-1==a)
		{
			b+=1;
		}
		else if(b+1>n&&b-1==a)
		{
			printf("Alice\n");
			break;
		}
		//printf("%d %d\n",a,b);
	} 
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <numeric>
#include <functional>
#include <math.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

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

enum Dir {
    R, L, U, D,
};

int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    ll MinX[4] = {INFLL, INFLL, INFLL, INFLL};
    ll MaxX[4] = {-INFLL, -INFLL, -INFLL, -INFLL};
    ll MinY[4] = {INFLL, INFLL, INFLL, INFLL};
    ll MaxY[4] = {-INFLL, -INFLL, -INFLL, -INFLL};
    int N;
    cin >> N;
    for (int n = 0; n < N; ++n) {
        int x, y;
        char cd;
        Dir d;
        cin >> x >> y >> cd;
        switch (cd) {
            case 'R': d = R; break;
            case 'L': d = L; break;
            case 'U': d = U; break;
            case 'D': d = D; break;
            default: break;
        }
        if (MinX[d] > x) MinX[d] = x;
        if (MaxX[d] < x) MaxX[d] = x;
        if (MinY[d] > y) MinY[d] = y;
        if (MaxY[d] < y) MaxY[d] = y;
    }
    
    auto Calc = [&](double T)
    {
        double X, Y;
        {
            double Min = INFLL;
            Min = min(Min, MinX[R]+T);
            Min = min(Min, MinX[L]-T);
            Min = min(Min, MinX[U]+0.0);
            Min = min(Min, MinX[D]+0.0);
            double Max = -INFLL;
            Max = max(Max, MaxX[R]+T);
            Max = max(Max, MaxX[L]-T);
            Max = max(Max, MaxX[U]+0.0);
            Max = max(Max, MaxX[D]+0.0);
            X = Max - Min;
        }
        {
            double Min = INFLL;
            Min = min(Min, MinY[R]+0.0);
            Min = min(Min, MinY[L]+0.0);
            Min = min(Min, MinY[U]+T);
            Min = min(Min, MinY[D]-T);
            double Max = -INFLL;
            Max = max(Max, MaxY[R]+0.0);
            Max = max(Max, MaxY[L]+0.0);
            Max = max(Max, MaxY[U]+T);
            Max = max(Max, MaxY[D]-T);
            Y = Max - Min;
        }
        return X * Y;
    };
    
    double l = 0.0, r = 1e10;
    for (int _ = 0; _ < 200; ++_) {
        double x1 = (2*l+r) / 3;
        double x2 = (l+2*r) / 3;
        if (Calc(x1) < Calc(x2)) {
            r = x2;
        } else {
            l = x1;
        }
    }
    cout << fixed;
    cout.precision(15);
    cerr << l << endl;
    cout << Calc((l+r)/2) << endl;
    
    return 0;
}


Measured memory_bytes: 256
N = int(input())
S = []
for i in range(N):
    S.append(input())
S.sort()
S.append("A")
B = []
M = 1
T = 1
for i in range(N):
    if S[i] == S[i+1]:
        T += 1
    elif T < M:
        T = 1
    elif T == M:
        T = 1
        B.append(S[i])
    else:
        M = T
        T = 1
        B = [S[i]]

for i in range(len(B)):
    print(B[i])

Measured memory_bytes: 20680
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
    int n, m; cin>>n>>m;
    int q; cin>>q;
    int a[100010];
    for(int i=0; i<q; i++){
        cin>>a[i];
    }
    int ind[100010];
    fill(ind, ind+m+1, -1);
    int cnt[100010]={};
    vector<int> v;
    for(int i=q-1; i>=0; i--){
        if(ind[a[i]]==-1){
            ind[a[i]]=cnt[0];
            v.push_back(a[i]);
            cnt[0]++;
        }else{
            int l=0, r=n;
            while(r-l>1){
                int mid=(l+r)/2;
                if(cnt[mid]<=ind[a[i]]) r=mid;
                else l=mid;
            }
            if(r<n && cnt[r]==ind[a[i]]) cnt[r]++;
        }
    }
    for(int i=1; i<=m; i++) if(ind[i]==-1) v.push_back(i);
    int mn=0;
    for(int i=m-1; i>=1; i--){
        if(v[i]<v[i-1]){
            mn=i; break;
        }
    }
    for(int i=0; i<n; i++){
        if(cnt[i]<mn){
            cout<<"No"<<endl; return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    vec a(5);
    rep(i, 5) cin >> a[i];
    int res = 0;
    rep(i, 5){
        if(a[i] == 0) res = i;
    }
    cout << res+1 << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 7732
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include<iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <cstdio>

using namespace std;

int main()
{
	vector<int> a(10, 0);
	for (int i = 0; i < 10; ++i)
		cin>>a[i];
	
	sort(a.begin(), a.end());
	cout<<a[9]<<endl;
	cout<<a[8]<<endl;
	cout<<a[7]<<endl;
	
	return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define REP(i, n) for (LL i = 0; i < (LL)(n); i++)
#define REP2(i, n) for (LL i = 1; i <= (LL)(n); i++)
#define FOR(i, m, n) for (LL i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define REVE(x) reverse(x.begin(), x.end())
#define ALL(x) (x).begin(), (x).end()
#define SUM(x) accumulate(x.begin(), x.end(),0)
#define vLL(v,n) vector<LL> v(n); REP(i,n)cin>>v[i];
#define vstr(v,n) vector<string> v(n); REP(i,n)REP(i,n)cin>>v[i];
LL INF = 1e9 + 1;
LL MOD = 1e9+7;
  LL a,b,c,d,e,n,m,l,k,r,x,y,z,ans=0,ans2=0,h,w;
string s,S,t;
int main() {
ios_base::sync_with_stdio(false);
vector<LL>L(87);
L[0]=2;
L[1]=1;
cin >> n;
FOR(i,2,87){
    L[i]=L[i-2]+L[i-1];
}
cout <<L[n];
}


Measured memory_bytes: 3632
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A,*B;

  int C[VMAX +1];
  int n,i,j;
  scanf("%d",&n);

  A = malloc(sizeof(short) *n +1);
  B = malloc(sizeof(short) *n +1);

  for(i = 0;i <= VMAX;i++)
    C[i] = 0;
  
  for(i = 0;i < n;i++){
    scanf("%hu",&A[i +1]);
    C[A[i +1]]++;
  }

  for(i = 1;i <= VMAX;i++)
    C[i] = C[i] + C[i -1];

  for(j = 1;j <=n;j++){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }

  for(i = 1;i <= n;i++){
    if(i > 1)
      printf(" ");
    printf("%d",B[i]);
  }
  printf("\n");

  return 0;
}



Measured memory_bytes: 9656
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <complex>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << (x) << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010


int main(){
  int n, a, b, q;
  int x[SIZE], y[SIZE], h[SIZE];
  char c[SIZE];

  pair<int,int> from[SIZE], to[SIZE];

  scanf("%d%d%d%d",&n,&a,&b,&q);

  for(int i=0;i<a;i++){
    scanf("%d %c",x+i, c+i);
    x[i]--;
  }

  int s = 0;
  
  for(int i=0;i<=b;i++){
    if(i < b)
      scanf("%d%d",y+i, h+i);
    else
      y[i] = n+1;
    
    if(i>0){
      if(h[i-1] != 0){
        from[s] = {y[i-1]-1, y[i]-2};
        to[s] = {h[i-1]-1, h[i-1] + y[i]-y[i-1] - 2};
        s++;
      }
    }
  }

  unordered_map<int,char> dic;
  queue<pair<int,char> > que;

  for(int i=0;i<a;i++){
    que.push({x[i], c[i]});
  }

  while(que.size()){
    auto p = que.front();
    que.pop();

    int pos = p.first;
    int ch = p.second;

    if(dic.find(pos) != dic.end()) continue;
    dic[pos] = ch;
    
    for(int i=0;i<s;i++){
      if(from[i].first <= pos && pos <= from[i].second){
        int newpos = (pos - to[i].first) % (from[i].first - to[i].first) + to[i].first;
        que.push({newpos, ch});
      }
    }
  }


  char ansStr[SIZE] = {};
  
  for(int i=0;i<q;i++){
    int z;
    char ans = '?';
    scanf("%d",&z);
    z--;

    queue<int> que;
    unordered_set<int> visited;

    if(dic.find(z) != dic.end())
      ans = dic[z];
    else
      que.push(z);
    
    while(que.size()){
      int pos = que.front(); que.pop();

      if(visited.find(pos) != visited.end()) continue;
      visited.insert(pos);
      
      for(int i=0;i<s;i++){
        if(from[i].first <= pos && pos <= from[i].second){
          int newpos = (pos - to[i].first) % (from[i].first - to[i].first) + to[i].first;

          if(dic.find(newpos) != dic.end()){
            que = queue<int>();
            ans = dic[newpos];
            break;
          }else{
            que.push(newpos);
          }
        }
      }
    }

    ansStr[i] = ans;
  }

  printf("%s\n",ansStr);
  
  return 0;
}




Measured memory_bytes: 43180
#include <stdio.h>

int main()

{
	
	int n,m;
	scanf("%d %d", &n,&m);
	
	if(m>=n)
	
{
	printf("Yes");
}	
    else if(m<n)
{
	printf("No");
} 
    return 0;
	    
    
}

Measured memory_bytes: 3208
#include <iostream>
#include <cstring>
using namespace std;
const int INF=0x3f3f3f3f,maxn=404;
int f[maxn][maxn],a[44],b[44],c[44],m,n,na,nb,sa[44],sb[44];
int main()
{
	int i,j,k,ans=INF;
	cin>>n>>na>>nb;
	memset(f,INF,sizeof(f));
	for(i=1;i<=n;i++)
	{
		cin>>a[i]>>b[i]>>c[i];
		sa[i]=sa[i-1]+a[i];
		sb[i]=sb[i-1]+b[i];
		//f[a[i]][b[i]]=min(f[a[i]][b[i]],c[i]);
	}
	f[0][0]=0;
	for(k=1;k<=n;k++)
	{
		for(i=sa[k];i>=a[k];i--)
		{
			for(j=sb[k];j>=b[k];j--)
			{
				f[i][j]=min(f[i][j],f[i-a[k]][j-b[k]]+c[k]);
			}
		}
	}
	for(i=1;i<maxn;i++)
	{
		for(j=1;j<maxn;j++)
		{
			if(i*nb==j*na)
				ans=min(ans,f[i][j]);
		}
	}
	if(ans==INF)
	{
		cout<<"-1";
		return 0;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 896
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
int main()
{
	char str[6] = {0};
	scanf("%s",str);
	int i;
	for(i=0;i<5;i++)
	{
		if(str[i]=='A' && str[i+1]=='C')
		{
			printf("Yes\n");
			break;
		}
	}
	if(i == 5)
		printf("No\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define bug(args ...) cerr << __LINE__ << ">> ", err(new istringstream(string(#args)), args), cerr << '\n'
#define all(x) x.begin(), x.end()
#define F first
#define S second
#define M_PI 3.14159265358979323846
#define MOD 1000000007
#define int ll
typedef unsigned long long BITMASK; typedef long long ll; typedef long double ld; typedef pair<int, int> pii; typedef pair<double, double> pdd; typedef pair<long long, long long> pll; typedef cc_hash_table<int, int, hash<int>> intHashTable;
struct custom_hash { static uint64_t splitmix64(uint64_t x) { x += 0x9e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31); } size_t operator()(uint64_t x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM); } };
inline int powMod(int a, int b) { int x = 1; while (b > 0) { if (b&1) x = (x*a) % MOD; a = (a*a) % MOD; b >>= 1; } return x; }
inline int multiply(int x, int y) { return ((x % MOD) * (y % MOD)) % MOD; }
inline int divide(int x, int y) { return ((x % MOD) * powMod(y % MOD, MOD-2)) % MOD; }
inline int ceil(int a, int b) { return (a+b-1)/b; }
int gcd (int a, int b) { while (b) { a %= b; swap(a, b); } return a; }
int lcm (int a, int b) { return a / gcd(a, b) * b; }
int inverseMod(int a, int m) { a = a % m; for (ll x = 1; x < m; x++) if ((a * x) % m == 1) return x; return -1; }
void err(istringstream *iss) {} template<typename T, typename ... Args> void err(istringstream *iss, const T &_val, const Args & ... args) { string _name; *iss >> _name; if (_name.back()==',') _name.pop_back(); cerr << _name << " = " << _val << "; ", err(iss, args ...); }
int str_replace(string& str, const string& from, const string& to, int limit = -1) { if(from.empty()) return 0; size_t start_pos = 0; int cnt = 0; while((start_pos = str.find(from, start_pos)) != std::string::npos) { str.replace(start_pos, from.length(), to); start_pos += to.length(); cnt++; if (cnt == limit) break; } return cnt; }
template<int D, typename T> struct vec : public vector<vec<D - 1, T>> { static_assert(D >= 1, "Vector dimension must be greater than zero!");  template<typename... Args> vec(int n = 0, Args... args) : vector<vec<D - 1, T>>(n, vec<D - 1, T>(args...)) { } }; template<typename T> struct vec<1, T> : public vector<T> { vec(int n = 0, T val = T()) : vector<T>(n, val) { }};

signed main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    unordered_map<string, int> rec;
    int n; cin >> n;
    while (n--)
    {
        string str; cin >> str;
        rec[str]++;
    }
    cout << rec.size() << '\n';
    return 0;
}

Measured memory_bytes: 17720
#include<cstdio>
#include<cmath>
using namespace std;

int main(){
	double q, x;
	while(1){
		scanf("%lf", &q);
		if( q == -1.0 ){
			break;
		}
		x = q / 2.0;
		while( fabs(x*x*x-q) >= 0.00001*q ){
			x = x - (x*x*x-q)/(3*x*x);
		}
		printf("%.6f\n", x);
	}
	return 0;
}

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

long long gcd(long long a, long long b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}
 
long long lcm(long long a, long long b) {
    long long d = gcd(a, b);
    return a / d * b;
}

int main(){
  int n;
  cin >> n;
  long long ans = 1;
  for(int i=0; i<n; i++){
    long long num;
    cin >> num;
    ans = lcm(ans, num);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3600
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))


using namespace std;


int dy[4] = { 0,0,1,-1 };
int dx[4] = { 1,-1,0,0 };
int dxx[8] = { 0,0,1,1,1,-1,-1,-1 };
int dyy[8] = { 1,-1,0,1,-1,0,1,-1 };




ll gcd(ll x, ll y) {
	ll m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}

ll myPow(ll x, ll n, ll m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}

ll pow2(int a, int n) {//aのn乗を計算します。
	int x = 1;
	while (n > 0) {//全てのbitが捨てられるまで。
		if (n & 1) {//1番右のbitが1のとき。
			x = x * a;
		}
		a = a * a;
		n >>= 1;//bit全体を右に1つシフトして一番右を捨てる。
	}
	return x;
}

long long nCr(int n, int r) {
	if (r > n / 2) r = n - r; // because C(n, r) == C(n, n - r)
	long long ans = 1;
	int i;

	for (i = 1; i <= r; i++) {
		ans *= n - r + i;
		ans /= i;
	}

	return ans;
}


const int MOD = 1000000007;

bool arr[1000100];
int sosuu[100010];
void Eratosthenes() {
	ll N = 1000100;
	int c = 0;
	for (int i = 0; i < N; i++) {
		arr[i] = 1;
	}
	for (int i = 2; i < sqrt(N); i++) {
		if (arr[i]) {
			for (int j = 0; i * (j + 2) < N; j++) {
				arr[i *(j + 2)] = 0;
			}
		}
	}

	for (int i = 2; i < N; i++) {
		if (arr[i]) {
			sosuu[c] = i;
			//cout << sosuu[c] << " ";
			c++;
		}
	}
	//cout << endl;
	//cout << c << endl;
}

int yaku[100010];

void bunkai(ll n, int c) {
	while (n > 1) {
		REP(i, c + 1) {
			if (sosuu[i] > n)break;
			if (n%sosuu[i] == 0) {
				yaku[i]++;
				n /= sosuu[i];
				break;
			}
		}
	}
}

int a[100010];
vector<int>v;
int main() {
	int N; cin >> N;
	REP(i, N) {
		cin >> a[i];
		v.push_back(a[i]);
	}
	if (N == 1) {
		if (a[0] % 2 == 1) {
			cout << "first" << endl;
			return 0;
		}
		else {
			cout << "second" << endl;
			return 0;
		}
	}
	SORT(a, N);
	VSORT(v);
	/*
	if (a[N - 1] % 2 == 0) {
		if (a[0] % 2 == 1) {
			cout << "first" << endl;
		}
		else cout << "second" << endl;
		return 0;
	}
	else {
		cout << "first" << endl;
		return 0;
	}
	*/
	if (v[N - 1] % 2 == 0) {
		REP(i, N - 1) {
			if (v[i] % 2 == 1) {
				cout << "first" << endl;
				return 0;
			}
		}
		cout << "second" << endl;
		return 0;
	}
	else {
		cout << "first" << endl;
		return 0;
	}
}


Measured memory_bytes: 1148
n = int(input())
b = list(map(int, input().split()))

a = [0]*n
a[0] = b[0]
a[-1] = b[-1]
for i in range(n-2):
    if b[i] > b[i+1]:
        b[i] = b[i+1]
    a[i+1] = b[i]

print(sum(a))

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;
 
static const int tx[] = {0,1,0,-1};
static const int ty[] = {-1,0,1,0};
 
static const double EPS = 1e-8;

class UnionFindTree{
private:
  int _size;
  int* _parent;
  int* _rank;
public:
  UnionFindTree(int n){
    _size = n;
    _parent = new int[_size]();
    _rank = new int[_size]();
    for(int i = 0; i < _size; i++){
      _parent[i] = i;
      _rank[i] = 1;
    }
  }

  ~UnionFindTree(){
    delete[] _parent;
    delete[] _rank;
  }

  int find(int child){
    int next = _parent[child];
    if(next == child) return child;
    else return find(next);
  }

  bool same(int lhs,int rhs){
    lhs = find(lhs);
    rhs = find(rhs);
    return (lhs == rhs);
  }
  
  bool unite(int lhs,int rhs){
    lhs = find(lhs);
    rhs = find(rhs);
    if(same(lhs,rhs)) return false;
    
    if(_rank[lhs] < _rank[rhs]){
      _parent[rhs] = lhs;
      _rank[lhs] += _rank[rhs];
    }
    else {
      _parent[lhs] = rhs;
      _rank[rhs] += _rank[lhs];
    }
    return true;
  }

};

class State {
public:
  int _from,_to;
  double _distance;
  State(int from,int to,double distance)
    : _from(from),_to(to),_distance(distance) {}
  bool operator<(const State& s) const {
    return _distance < s._distance;
  }
  bool operator>(const State& s) const {
    return _distance > s._distance;
  }
};

int main(){
  int num_of_magical_piles;
  int num_of_magical_fences;
  while(~scanf("%d %d",
               &num_of_magical_piles,
               &num_of_magical_fences)){
    
    vector<P> piles;
    for(int pile_i = 0; pile_i < num_of_magical_piles; pile_i++){
      int x,y;
      scanf("%d %d",&x,&y);
      piles.push_back(P(x,y));
    }

    double sum = 0;
    priority_queue<State,vector<State>,less<State> > que;

    for(int fence_i = 0; fence_i < num_of_magical_fences; fence_i++){
      int from,to;
      scanf("%d %d",&from,&to);
      from--; to--;
      int from_x = piles[from].first;
      int from_y = piles[from].second;

      int to_x = piles[to].first;
      int to_y = piles[to].second;

      double distance = sqrt((double)((from_x - to_x) * (from_x - to_x)
                                      + (from_y - to_y) * (from_y - to_y)));
      sum += distance;
      que.push(State(from,to,distance));
    }

    UnionFindTree uft(num_of_magical_piles);
    double after_ruined = 0;
    while(!que.empty()){
      State s = que.top();
      que.pop();
      if(uft.same(s._from ,s._to)){
        continue;
      }
      uft.unite(s._from,s._to);
      after_ruined += s._distance;
    }
    printf("%lf\n",sum - after_ruined);
  }
}

Measured memory_bytes: 1732
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    a = list(map(int, input().split()))

    kai = [1] * (N+2)
    MOD = int(1e9) + 7
    for i in range(1, N+2):
        kai[i] *= kai[i-1] * i
        kai[i] %= MOD
    # print(kai)
    dic = {}
    for i in range(N+1):
        if a[i] in dic:
            left = dic[a[i]]
            right = N - i
        else:
            dic[a[i]] = i
    
    for i in range(1, N+2):
        tmp = kai[N+1] * pow(kai[N+1-i], MOD-2, MOD) * pow(kai[i], MOD-2, MOD)
        tmp %= MOD
        if i - 1 <= left + right:
            tmp2 = kai[left+right] * pow(kai[left+right+1-i], MOD-2, MOD) * pow(kai[i-1], MOD-2, MOD)
            tmp2 %= MOD
            tmp = (tmp + MOD - tmp2) % MOD
        print(tmp)

if __name__ == "__main__":
    main()

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

int main(){
  
  //入力
  int N;
  cin>>N;
  int a[N];
  int b[N];
  int c[N];   
  for(int i=0;i<N;i++){
    cin>>a[i]>>b[i]>>c[i];
  }
  
  //dpテーブルを0で初期化
  int dp[N][3];
  for(int i=0;i<N;i++){
    for(int j=0;j<3;j++){
      dp[i][j]=0;
    }
  }
  
  //dp
  
  dp[0][0]=a[0];
  dp[0][1]=b[0];
  dp[0][2]=c[0];
  
  for(int i=1;i<N;i++){
    dp[i][0]=max(dp[i][0],dp[i-1][1]+a[i]);
    dp[i][0]=max(dp[i][0],dp[i-1][2]+a[i]);
    dp[i][1]=max(dp[i][1],dp[i-1][0]+b[i]);
    dp[i][1]=max(dp[i][1],dp[i-1][2]+b[i]);    
    dp[i][2]=max(dp[i][2],dp[i-1][0]+c[i]);
    dp[i][2]=max(dp[i][2],dp[i-1][1]+c[i]); 
  }
  cout<<max(max(dp[N-1][0],dp[N-1][1]),dp[N-1][2])<<endl;
  return 0;
}


Measured memory_bytes: 5984
n = int(input())
KeyLst = ['AC','WA','TLE','RE']
dic = {key:0 for key in KeyLst}
for _ in range(n):
  result = str(input())
  try:
  	dic[result] += 1
  except KeyError as e:
    print(e)
for key in KeyLst:
  print('{} x {}'.format(key,dic[key]))

Measured memory_bytes: 9216
def main():
  n, t, s = map(int, input().split())
  A = []
  B = []
  for _ in range(n):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
  
  """
  dp[x + 1][y] ... 店xまででで時刻yまでの最大値
  dp[x + 1][y] = max(dp[x][y], dp[x + 1][y - 1], dp[x][y - B[x]] + A[x]) (not y - B[x] < s < y)
  dp[x + 1][y] = max(dp[x][y], dp[x + 1][y - 1])
  """

  dp = [[0] * (t + 1) for _ in range(n + 1)]
  for x in range(n):
    bx = B[x]
    ax = A[x]
    dpx = dp[x]
    dpx1 = dp[x + 1]
    for y in range(1, t + 1):
      if 0 <= y - bx and (not (y - bx < s < y)):
        dpx1[y] = max(dpx[y], dpx1[y - 1], dpx[y - bx] + ax)
      else:
        dpx1[y] = max(dpx[y], dpx1[y - 1])
   
  print(dp[n][t])
 
main()


Measured memory_bytes: 171732
typedef long long ll;

#define shi5 100000+10
#define MOD 1000000007

 #include <bits/stdc++.h>
using namespace std;
struct mystruct{
  long long v;
  mystruct * next;
};
int structcmp(const void *v1,const void *v2){return ((mystruct *)v1)->v - ((mystruct *)v2)->v;}
int intcmp(const void *v1,const void *v2){return *(int *)v1-*(int *)v2;}
long long minn(long long v1,long long v2){return v1<v2?v1:v2;}
long long maxx(long long v1,long long v2){return v1>v2?v1:v2;}

// M TLE -> 1900ms 1/2
// N-M < 100ms

int m,n;

int main(){
  int n,m;
  cin>>n>>m;
  int tsum= (n-m)*100+1900*m;
  while(m--){
    tsum<<=1;
  }
  cout<<tsum<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		String line = null;
		try (Scanner sc = new Scanner(System.in)) {
			line = sc.nextLine();
			SimpleDateFormat sd = new SimpleDateFormat("yyyy/MM/dd");

			Date d1 = sd.parse(line);
			Date d2 = sd.parse("2019/04/30");

			String result = "Heisei";
			if (d1.compareTo(d2) > 0) {
				result = "TBD";
			}
			System.out.println(result);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}


Measured memory_bytes: 23880
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();
		if(x>=r&&x<=W-r&&y>=r&&y<=H-r){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
		
	}
}

Measured memory_bytes: 26276
#include<bits/stdc++.h>
#define ll long long

using namespace std;
vector<int> adj[200010];
map<pair<int,int>,int> mp;
pair<int,int> a[200010];
int n;
int mx = 0,mx_node=0;
int vis[200010];
void bfs(){
    // current_node ,previous_node
    queue<pair<int,int>> q;
    q.push({mx_node,0});
    while(!q.empty()){
        int current = q.front().first;
        int prev = q.front().second;
        vis[current]=1;
        //cout<<current<<' '<<prev<<'\n';

        q.pop();
        int colour = 1;
        for(auto k:adj[current]){
            if(!vis[k]){
                if(prev==0){
                    mp[{k,current}]=colour;
                    mp[{current,k}]=colour;
                    colour++;
                    q.push({k,current});
                }else{
                    if(colour==mp[{current,prev}])
                        colour++;
                    mp[{k,current}]=colour;
                    mp[{current,k}]=colour;
                    colour++;
                    q.push({k,current});
                }
            }
        }
    }
}
int main(){

    cin>>n;
    for(int i=0;i<n-1;i++){
        int x,y;
        cin>>x>>y;
        adj[x].push_back(y);
        adj[y].push_back(x);
        a[i].first = x;
        a[i].second = y;
    }

    for(int i=1;i<=n;i++){
        if(adj[i].size()>mx){
            mx_node = i;
            mx= adj[i].size();
        }
    }
    bfs();
    cout<<mx<<'\n';
    for(int i=0;i<n-1;i++){
        cout<<mp[{a[i].first,a[i].second}]<<'\n';
    }
}


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

#define mp make_pair
#define pb push_back 
#define pf push_front 
#define pbp pop_back
#define pfp pop_front 
#define sz(x) x.size()
#define all(x) x.begin(),x.end() 
#define ios_base ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define open(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout)
#define F first
#define S second

using namespace std;

typedef unsigned long long ul;
typedef long long ll;
typedef long double ld;
typedef int I;

const int mod = 1e9+7;
const int N = 1e6 + 10;
const int inf = 1e9+123;
const long long INF = 1e18;
const double eps = 1e-5;
int n, k, x;
map <int, int> m;
int main (){
 ios_base
	cin >> n >> k;
 for(int i = 1; i <= k; i ++){
 	cin >> x;
 	m[x]++;
	}
	for(int i=n; ;i++){
		int q = i,c=1;
		while(q>0){
			if(m[q%10]==1){
				c=0;
			}
			q/=10;
		}
		if(c==1)return cout<<i, 0;
	}
 return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

int main(void)
{
	ll a,b,c,d;
	scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
	ll ans = max(max(a*c, a*d), max(b*c, b*d));
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 1732
#include <stdio.h>
#include <string.h>
// #include <math.h>

int main() {
    int h,w,i,j;

    while(1){
        scanf("%d %d",&h,&w);
        if(h==0&&w==0){
            break;
        }
        for(i=0;i<h;i++){
            for(j=0;j<w;j++){
               if((j+i)%2==0){
                   printf("#");
               }else{
                   printf(".");
               }
            }
            printf("\n");
        }
        printf("\n");
    }
    
    return 0;
}



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

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0) : x((x%mod+mod)%mod) {}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main() {
  ll n,k;
  cin >> n >> k;
  mint comb1(1), comb2(1), ans;
  ll nz = min(k,n-1);
  mint res(2), temp(1);
  ans += 1;
  for (int i = 1; i <= min(k,n-1); ++i) {
    comb1 *= (n-i+1);
    comb1 /= i;
    comb2 *= (n-1-i+1);
    comb2 /= i;
    ans += comb1*comb2;
  }
  cout << ans.x << endl;
  return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <cstdio>
#include <climits>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;


//container util

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

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()


struct Edge {
    int to, cost, nm;
    Edge(int to, int cost, int nm): to(to), cost(cost), nm(nm) {}
};

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<Edge>> AdjList;
AdjList graph;
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
const int INF = 100000000;

ll GCD(ll a, ll b){
    if(a < b) swap(a, b);
    if(b == 0) return a;
    return GCD(b, a%b);
}

bool cmp(const pii& a, const pii& b){
    if(a.first == b.first){
        return a.second < b.second;
    }
    return a.first < b.first;
}

bool isPalindrome(string s) {

    bool isPalindrome = true;
    int i = 0, j = s.size() - 1;
    while(isPalindrome && i <= j) {
        isPalindrome &= s[i] == s[j];
        i++;
        j--;
    }
    return isPalindrome;
}

int main()
{
    //cin.tie(0);
    //ios::sync_with_stdio(false);
    //cout << fixed << setprecision(10);

    ll N, A, B; cin >> N >> A >> B;

    ll X[100010];
    REP(i, N) cin >> X[i];

    ll ans = 0;
    for(int i=1; i<N; ++i){
        ll dx = X[i]-X[i-1];
        ans += (dx*A>B)?B:dx*A;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
// #define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
// #pragma GCC optimize ("-O3")
// using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
// typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
// template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
// template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

using namespace std;

int main()
{
  int N,M,X;
  cin>>N>>M>>X;
  
  vector<int> C;
  vector<vector<int>> A;
  C.resize(N);
  A.resize(N);
  rep(i,0,N){
    cin>>C[i];
    A[i].resize(M);
    rep(j,0,M){
      cin>>A[i][j];
    }
  }
  
  int res=10000000;
  bool flag_(false);
  rep(bit,0,(1<<N)){
    vector<int> eachX(M,0);
    int cur=0;
    rep(i,0,N){
      if(bit&(1<<i)){
        cur+=C[i];
        rep(j,0,M){
          eachX[j]+=A[i][j];
        }
      }
    }
    if(*min_element(all(eachX))>=X){
      flag_=true;
      res=min(cur,res);
    }
  }
  
  if(flag_){
    cout<<res<<endl;
  }
  else{
    cout<<"-1"<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 3640
using System;

namespace ABC083_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var sss = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var n = sss[0];
            var a = sss[1];
            var b = sss[2];
            var sum = 0;

            for(var i=0;i<=n;i++)
            {
                int c = 0;
                int d = i;
                for(int j=0;j<5;j++)
                {
                    c += d % 10;
                    d /= 10;
                }
                if (a <= c && c <= b)
                    sum += i;
            }
            Console.WriteLine(sum);
        }
    }
}


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

int func(int x)
{
    if(x%2==0)
    {
        return x/2;
    }
    else
    {
        return 3*x+1;
    }
}
int main()
{
    ll n,a,b;
    cin>>n>>a>>b;
    ll repeat_count = n/(a+b);

    if((n%(a+b))<=a)
    {
        cout<<a*repeat_count+n%(a+b)<<endl;
    }
    else
    {
        cout<<a*repeat_count+a<<endl;
    }
    return 0;
}

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

int n;
int a[20];
int x[20][20];
int y[20][20];

int counter(int x){//bitsに何個1が立ってるか数える
    if(x == 0) return 0;
    return counter(x >> 1) + (x & 1);//末尾が1かどうか見てシフトしていく
}

int main(){
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        for(int j = 1; j <= a[i]; j++){
            cin >> x[i][j] >> y[i][j];
        }
    }
    int ans = 0;
    for(int bits = 1; bits < (1 << n); bits++){//全員不親切の場合は絶対に正解なので今回は飛ばす
        bool ok = true;
        for(int i = 1; i <= n; i++){
            if(!(bits & (1 << (i - 1)))) continue;//iの人が不親切なら飛ばす
            for(int j = 1; j <= a[i]; j++){//正直のときiの人の証言の数だけ調べる
                if(((bits >> (x[i][j] - 1)) & 1) ^ y[i][j]) ok = false;//証言が矛盾してたらok変更
            }
        }
        if(ok) ans = max(ans, counter(bits));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func main() {
	input := strings.Split(line(), "")
	a, _ := strconv.Atoi(input[0])
	b, _ := strconv.Atoi(input[1])
	c, _ := strconv.Atoi(input[2])
	d, _ := strconv.Atoi(input[3])
	if isMonth(a, b) {
		if isMonth(c, d) {
			fmt.Println("AMBIGUOUS")
		} else {
			fmt.Println("MMYY")
		}
	} else {
		if isMonth(c, d) {
			fmt.Println("YYMM")
		} else {
			fmt.Println("NA")
		}
	}

}

func isMonth(a int, b int) bool {
	if a == 1 {
		if b == 0 || b == 1 || b == 2 {
			return true
		}
	} else if a == 0 && b != 0 {
		return true
	}
	return false
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
 
int main() {
	int D, N; 
    cin >> D >> N;
	int S = 1; 
    for (int i = 0; i < D; i++) 
        S *= 100;
	if (N <= 99) {
		cout << S * N << endl;
	}
	else {
		cout << S * 101 << endl;
	}
	return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
using namespace std;

int main()
{
    string S;
    cin >> S;
    vector<bool> appear(26, false);
    for (char c : S)
        appear[c - 'a'] = true;

    REP (i, 26) {
        if (!appear[i]) {
            printf("%c\n", 'a' + i);
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}


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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  REP(i,N) cin >> A[i];

  ll res = A[0] - 1;
  A[0] = 1;
  int Pmax = 2;
  for(int i = 1; i < N; ++i) {
    if(A[i] == Pmax) {
      Pmax++;
    }else if(A[i] > Pmax){
      res += (A[i] - 1) / Pmax;
      A[i] = 1 + (A[i] - 1) % Pmax;
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	static final int MOD = 1000000007;

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int sx = in.nextInt();
		int sy = in.nextInt();
		int tx = in.nextInt();
		int ty = in.nextInt();
		int dx = tx - sx;
		int dy = ty - sy;
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < dx; i++) {
			sb.append('R');
		}
		for (int i = 0; i < dy; i++) {
			sb.append('U');
		}
		for (int i = 0; i < dx; i++) {
			sb.append('L');
		}
		for (int i = 0; i < dy; i++) {
			sb.append('D');
		}
		sb.append('D');
		for (int i = 0; i <= dx; i++) {
			sb.append('R');
		}
		for (int i = 0; i <= dy; i++) {
			sb.append('U');
		}
		sb.append('L');
		sb.append('U');
		for (int i = 0; i <= dx; i++) {
			sb.append('L');
		}
		for (int i = 0; i <= dy; i++) {
			sb.append('D');
		}
		sb.append('R');
		System.out.println(sb.toString());
		in.close();
	}
}

Measured memory_bytes: 21460