akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;

int n, m;

int main(){
  cin >> n >> m;
  int x = m / 1000, y = 0, z = 0;
  int sum = x;
  bool flag = false;
  while(sum >= n || x != 0 || y != 0){
    if(sum == n){
      flag = true;
      break;
    }
    if(sum >= n + 4 && x >= 5){
      x -= 5;
      y++;
      sum -= 4;
    }else if(y >= 2){
      y -= 2;
      z += 1;
      sum--;
    }else{
      break;
    }
  }
  if(!flag){
    x = -1, y = -1, z = -1;
  }
  cout << z << " " << y << " " << x << endl;
}


Measured memory_bytes: 256
if __name__ == '__main__':
    N,K=input().split(" ")
    p=int(N)
    q=int(K)
    a=[0]*p
    judge=0
    for i in range(0,q):
        k=int(input())
        b=[int(t) for t in input().split()]
        for j in range(0,len(b)):
            a[b[j]-1]+=1
    for m in range(0,p):
        if a[m]==0:
            judge+=1
    print(judge)


Measured memory_bytes: 9196
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}
const int dm = 1400000;
char dn[dm], * di = dn;
const int MAX = 20000;
class unko {
public:
	char C[MAX * 7 + 10], *K[MAX + 10];
	constexpr unko() : C(), K() {
		auto di = C + 3;
		C[0] = '0';
		C[0] = ' ';
		C[0] = '\n';
		K[0] = C;
		K[1] = di;
		rep1(i, MAX) {
			int X = i;
			int keta = 0;
			char c[10] = {};
			while (X) {
				*(c + keta) = '0' + X % 10;
				X /= 10;
				keta++;
			}
			for (int j = keta - 1; j >= 0; j--)* di++ = (*(c + j));
			*di++ = ' ';
			*di++ = '\n';
			K[i + 1] = di;
		}
	}
};
constexpr unko f;
inline void putint(int X) {
	if (X > 20000) {
		int ue = X / 10;
		for (auto i = f.K[ue]; *i != ' '; i++) *di++ = *i;
		*di++ = '0' + X % 10;
		*di++ = ' ';
	}
	else for (auto i = f.K[X]; *i != '\n'; i++)* di++ = *i;
}

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


	int N = getint(), K = getint();

	int A[200001];
	rep(i, N) A[i] = getint();
	ll owa = ll(N) * N;

	rep(p, K) {
		int B[200001] = {};
		rep(i, N) {
			B[max(0, i - A[i])]++;
			B[min(N, i + A[i] + 1)]--;
		}
		ll kei = B[0];
		A[0] = B[0];
		rep1(i, N - 1) {
			kei += (A[i] = A[i - 1] + B[i]);
		}
		if (kei == owa) break;
	}

	rep(i, N) putint(A[i]);
	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}

Measured memory_bytes: 7248
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    long long int res = 0;
    for (int i = 0; i < (1 << n); i++) {
        string s1, s2;
        for (int j = 0; j < n; j++) {
            if ((i >> j) % 2 == 1) {
                s1.push_back(s[j]);
            } else {
                s2.push_back(s[j]);
            }
        }
        // reverse(s2.begin(), s2.end());

        int n1 = s1.size(), n2 = s2.size();
        vector<vector<int>> v(n1 + 1, vector<int>(n2 + 1, 0));
        v[0][0] = 1;
        for (int a = 0; a <= n1; a++) {
            for (int b = 0; b <= n2; b++) {
                if (v[a][b] == 0) continue;
                if (a < n1) {
                    if (s[2 * n - 1 - a - b] == s1[a]) {
                        v[a + 1][b] += v[a][b];
                    }
                }
                if (b < n2) {
                    if (s[2 * n - 1 - a - b] == s2[b]) {
                        v[a][b + 1] += v[a][b];
                    }
                }
            }
        }
        res += v[n1][n2];
    }
    cout << res << endl;
}




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

int main() {
  int a, b;
  cin >> a >> b;
  char s = 'x';
  if(a + b == 15) s = '+';
  else if(a * b == 15) s = '*';
  cout << s << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define MSET(x,y) memset(x,y,sizeof(x))
#define M 200005
using namespace std;
using LL = long long;
int n,h[M],a[M];
LL dp[M],tree[M];
int low(int x) {
    return x&-x;
}
LL ask(int x) {
    LL res = 0;
    for (int i=x; i>0; i-=low(i)) res = max(res, tree[i]);
    return res;
}
void upd(int x,LL v) {
    for (int i=x; i<=n; i+=low(i)) tree[i] = max(tree[i], v);
}

int main()
{
    scanf("%d", &n);
    REP(i,1,n) scanf("%d", &h[i]);
    REP(i,1,n) scanf("%d", &a[i]);
    
    REP(i,1,n) {
        dp[i] = ask(h[i]-1) + a[i];
        upd(h[i], dp[i]);
    }
    printf("%lld\n", *max_element(dp+1, dp+n+1));
    return 0;
}


Measured memory_bytes: 8552
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <sstream>
using namespace std;


int main() {
	long long M,rD,rR,cD,cR;
	cin >> M >> rD >> rR >> cD >> cR;
	
	long long w1 = (100*cD+rD-1)/ rD;
	long long w2 = (100*cR+rR-1)/ rR;
	if( M < w1+w2 ){
		cout << -1 << endl;
	}else{
		cout << M-(w1+w2) << endl;
	}
}

Measured memory_bytes: 1164
package main

import (
	"fmt"
	"sort"
)

// 入力順, 誕生年, 県番号, id
type City struct {
	num, year, pref int
	id              string
}

// 入力順でソート
type CitiesByNum []*City

func (cn CitiesByNum) Len() int {
	return len(cn)
}

func (cn CitiesByNum) Less(i, j int) bool {
	return cn[i].num < cn[j].num
}

func (cn CitiesByNum) Swap(i, j int) {
	cn[i], cn[j] = cn[j], cn[i]
}

// 誕生年でソート
type CitiesByYear []*City

func (cy CitiesByYear) Len() int {
	return len(cy)
}

func (cy CitiesByYear) Less(i, j int) bool {
	if cy[i].pref == cy[j].pref {
		return cy[i].year < cy[j].year
	}
	return cy[i].pref < cy[j].pref
}

func (cy CitiesByYear) Swap(i, j int) {
	cy[i], cy[j] = cy[j], cy[i]
}

func main() {
	var n, m int
	fmt.Scan(&n, &m)

	cities := make([]*City, m)
	for i := range cities {
		var p, y int
		fmt.Scan(&p, &y)
		cities[i] = &City{i, y, p, ""}
	}
	sort.Sort(CitiesByYear(cities))

	curPref, curOrder := 0, 0
	for i := range cities {
		if cities[i].pref != curPref {
			curOrder = 1
			curPref = cities[i].pref
		} else {
			curOrder++
		}
		cities[i].id = fmt.Sprintf("%06d%06d", cities[i].pref, curOrder)
	}

	sort.Sort(CitiesByNum(cities))

	for i := range cities {
		fmt.Println(cities[i].id)
	}
}


Measured memory_bytes: 13568
h,w = map(int,input().split())
s = [input() for i in range(h)]

ans = "Yes"
judge = 0

for i in range(w):
  for j in range(h):
    sign = 0
    
    if s[j][i] == ".":
      continue
    
    if (0<=j-1) and (s[j-1][i] == "#"):
      sign = 1
    
    if (0<=i-1) and (s[j][i-1] == "#"):
      sign = 1
      
    if (j+1<h) and (s[j+1][i] == "#"):
      sign = 1
      
    if (i+1<w) and (s[j][i+1] == "#"):
      sign = 1
      
    if sign != 1:
      ans = "No"
      judge = 1
      break
  
  if judge == 1:
    break
      
print(ans)

Measured memory_bytes: 3064
/// Bismillahir Rahmanir Rahim
//Author: Tanvir Hussain
//ICE,NSTU
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

using namespace std;

const long long MOD = 1000000007;
#define SET(x) memset(x, 0, sizeof(x))
#define SET2d(x,m,n) memset(x, 0, sizeof(x[0][0]) * m * n)
#define SETBOOL(x) memset(x,false,sizeof(x))
#define CLR(x) memset(x, -1, sizeof(x))
#define mp make_pair
#define PII pair<int, int>
#define pf printf

#define sf scanf

#define ALL(x) x.begin(),x.end()
#define pb push_back

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define np std::string::npos
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define cases(cs,t) for(int cs=1;cs<=t;cs++)
#define PI acos(-1)
#define no1 __builtin_popcount
#define BOUNDARY(i, j) ((i >= 0 && i < row) && (j >= 0 && j < column))
#define uniq(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define sz(a) int(a.size())
#define ff first
#define ss second
#define endl "\n"
#define forch(it,s) for(auto it:s)
#define each(it,s) for(auto it = s.begin(); it != s.end(); ++it)
#define rep(i,a) for(int i=0; i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const int maxx=100005;

//this fuction sorts vector pair according to first element in descending order.
bool sortinrev(const pair<int,int> &a,const pair<int,int> &b)
{
    return a.first>b.first;
}

template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}
double sq(double x) {return x*x;}
int ext_gcd(int a, int b, int & x, int & y) {
    //for finding modular inverse
    //if its return 1 ,then a has a mod inverse x mod b.
    if (a == 0) {
        x = 0;
        y = 1;
        return b;
    }
    int x1, y1;
    int d = ext_gcd(b % a, a, x1, y1);
    x = y1 - (b / a) * x1;
    y = x1;
    return d;
}
void solve(){

}

int main()

{
    IOS;
    /*#ifndef ONLINE_JUDGE
        freopen ("data.in","r",stdin);
        freopen ("data.out","w",stdout);
    #endif*/
    int k;
    string s;
    cin>>k>>s;
    if(sz(s)<=k) cout<<s<<endl;
    else{
        rep(i,k) cout<<s[i];
        cout<<"..."<<endl;
    }

     return 0;

}
///Alhamdulillah



Measured memory_bytes: 3656
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<map>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
ll bpow(ll,ll,ll);
typedef vector<int> vec;
typedef vector<vec> mat;
mat mul(mat &A,mat &B);
mat pow(mat A,ll n);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};


bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  ll N,factor[1001],res=1;
  fill(factor,factor+1001,0);
  cin >> N;
  for(int i=2;i<=N;i++){
    int f = 1;
    for(int j=2;j<i;j++){
      if(i % j == 0){
        f = 0;
        break;
      }
    }
    int d = i;
    if(f){
    while(d <= N){
      factor[i] += N/d;
      d *= i;
    }
    }
  }
  for(int i=0;i<=1000;i++){
    res = (res*(factor[i]+1)) % (1000000000+7);
  }
  cout << res << endl;
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

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

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

ll bpow(ll a, ll n,ll mod){
  int i = 0;
  ll res=1;
  while(n){
    if(n & 1)
      res = (res*a) % mod;
    a = (a*a) % mod;
    n >>= 1;
  }
  return res;
}
const int MOD = 1000000007;
mat mul(mat &A, mat &B){
  mat C(A.size(),vec(B[0].size()));
    REP(i,A.size())REP(k,B.size())REP(j,B[0].size()){
    C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % MOD;
  }
  return C;
}

mat pow(mat A,ll n)
{
  mat B(A.size(),vec(A.size()));
  REP(i,A.size()){
    B[i][i] = 1;
  }
  while(n > 0){
    if ( n & 1) B = mul(B,A);
    A = mul(A,A);
    n >>= 1;
  }
  return B;
}


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

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

string a[55];
vector<PII> g[30];
signed main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);

  int h, w;
  char st, t;
  cin >> h >> w >> st >> t;
  REP(i, h) cin >> a[i];

  vector<PII> pos(26, {-1, -1});
  REP(i, h) REP(j, w) {
    if('A' <= a[i][j] && a[i][j] <= 'Z') {
      pos[a[i][j]-'A'] = {i, j};
    }
  }
  // cout << pos << endl;

  REP(i, 26) {
    if(pos[i] == PII{-1, -1}) continue;
    // cout << i << endl;
    REP(j, 4) {
      int x = pos[i].second + 2*dx[j], y = pos[i].first + 2*dy[j];
      if(!IN(0LL, w, x) || !IN(0LL, h, y)) continue;
      if(dx[j] != 0 && a[y][x] != '-') continue;
      if(dy[j] != 0 && a[y][x] != '|') continue;
      while(IN(0LL, w, x) && IN(0LL, h, y)) {
        // cout << x << " " << y << endl;
        if('A' <= a[y][x] && a[y][x] <= 'Z') {
          g[i].PB({a[y][x]-'A', 1});
          g[a[y][x]-'A'].PB({i, 1});
          break;
        } else if(a[y][x] != '.') {
          x += dx[j], y += dy[j];
        } else {
          break;
        }
      }
    }
    // cout << g[i] << endl;
  }

  VI d(30);
  auto dijkstra = [&](int s) {
    d.assign(30, INF);
    d[s] = 0;
    priority_queue<PII, vector<PII>, greater<PII>> que;
    que.push(PII{d[s], s});

    while(que.size()) {
      PII p = que.top(); que.pop();
      // cout << p << endl;
      int v = p.second;
      if(d[v] < p.first) continue;
      for(PII &e: g[v]) {
        if(d[e.first] > d[v] + e.second) {
          d[e.first] = d[v] + e.second;
          que.push(PII{d[e.first], e.first});
        }
      }
    }
  };
  dijkstra(st-'A');
  cout << d[t-'A'] << endl;

  return 0;
}



Measured memory_bytes: 3228
# 2020/04/12
# AtCoder Beginner Contest 053 - B

# Input
s = input()

# Search 'A'
for i in range(len(s)):
    if s[i] == 'A':
        aidx = i
        break
    
# Search 'Z'
for i in range(len(s)-1, -1, -1):
    if s[i] == 'Z':
        zidx = i
        break

ans = zidx - aidx + 1

# Output
print(ans)


Measured memory_bytes: 3516
def read():
    N, M = list(map(int, input().split()))
    return N, M

def nC2(n):
    if n < 2:
        return 0
    return n * (n-1) // 2

def solve(N, M):
    return nC2(N) + nC2(M)

if __name__ == '__main__':
    inputs = read()
    print("{}".format(solve(*inputs)))


Measured memory_bytes: 2940
while True:
    H,W = map(int,input().split())
    if H == 0 and W == 0:
        break


    for i in range(0,H):
        c = "#" if i % 2 == 0 else "."
        
        for j in range(W):
            print(c, end="")
            
            if c == "#":
                c = "."
            else:
                c = "#"
        print()
    
    print()



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

using namespace std;

using ll = long long;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORE(i, a, b) for (int i = (a); i <= (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define SP cout << fixed << setprecision(10)
typedef pair<int, int> P;
const int INF = (int)1e9;
const ll MOD = (ll)1e9 + 7;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

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

    int n, m;
    cin >> n >> m;
    vector<int> ok(n + 1, true);
    rep(i, m) {
        int a;
        cin >> a;
        ok[a] = false;
    }

    vector<ll> dp(n + 1);
    dp[0] = 1;
    rep(i, n) {
        FORE(j, i + 1, min(n, i + 2)) {
            if (ok[j]) {
                dp[j] += dp[i];
                dp[j] %= MOD;
            }
        }
    }

    cout << dp[n] << endl;

    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define F               first
#define S               second
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define endl            '\n'
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define forI(i,a,n)     for(int i=a;i<=n;i++)
#define forD(i,a,n)     for(int i=n;i>=a;i--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
void init(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}

void solve(){
    int n, k;   cin>>n>>k;
    mk(h, n, int);  forI(i, 0, n-1) cin>>h[i];
    int cost[n];
    memset(cost, mod, sizeof cost);
    cost[0] = 0;
    cost[1] = abs(h[0]-h[1]);
    // cout<<cost[0]<<' '<<cost[1]<<' ';
    forI(i, 2, n-1){
        forI(j, 1, k){
            if(i-j >= 0){
                cost[i] = min(cost[i], cost[i-j]+abs(h[i-j]-h[i]));
            }
        }
        // cout<<cost[i]<<' ';
    }

    cout<<cost[n-1]<<endl;
}

int32_t main(){
    init();
    // w(t) 
    solve();
    return 0;
}

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

int main()
{
    int a[10];
    for(int i=0; i<5; i++){
        cin>>a[i];
    }

    for(int i=0; i<5; i++){
        if(a[i]==0){
            cout<<i+1;
            break;
        }
    }
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false), cin.tie(0)
#define debug(a) cout << #a ": " << a << endl
using namespace std;
typedef long long ll;

int main(void){
    IOS;
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int now = 0, win;
    while (1){
        if (now == 0){
            c -= b;
            if (c <= 0){
                win = 0; break;
            }
            now ^= 1;
        }else{
            a -= d;
            if (a <= 0){
                win = 1; break;
            }
            now ^= 1;
        }
    }
    if (win == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;
const LL MX = 1e8-1;
const LL INF = 1e15;

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

  LL x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  LL N;
  cin >> N;
  vector<PLL> xs(N);
  REP(i,N)
	cin >> xs[i];
  if(x2 < x1){
	x1 = MX - x1;
	x2 = MX - x2;
	for(auto& x: xs)
	  x.FF = MX - x.FF;
  }
  if(y2 < y1){
	y1 = MX - y1;
	y2 = MX - y2;
	for(auto& x: xs)
	  x.SS = MX - x.SS;
  }

  vector<PLL> ps;
  REP(i,N)
	if(x1 <= xs[i].FF && xs[i].FF <= x2
	   && y1 <= xs[i].SS && xs[i].SS <= y2)
	  ps.EB(xs[i].FF, xs[i].SS);

  double ans = 100. * (x2 - x1 + y2 - y1);
  LL mn = min(x2-x1, y2-y1);
  SORT(ps);
  VL lis(N+1, INF);
  for(auto& p: ps){
	*lower_bound(ALL(lis), p.SS) = p.SS;
  }
  LL n = lower_bound(ALL(lis), INF) - begin(lis);
  ans += n * (-20. + 5. * PI);
  if(n == mn+1)
	ans += 5.*PI;
  cout << fixed << setprecision(12) << ans << endl;

  return 0;
}


Measured memory_bytes: 9584
def r(i):
    indr = s.find('<', i)
    return indr - i if indr != -1 else n - i - 1
def l(i):
    indl = s.rfind('>', 0, i)
    return i - indl -1 if indl != -1 else i 
s = input()
n = len(s) + 1
print(sum([max(r(i), l(i)) for i in range(n)]))

Measured memory_bytes: 29924
#include<bits/stdc++.h>
using namespace std;
#define itn int
#define int unsigned long long
#define mod 1000000007
#define fi first
#define se second
#define be begin()
#define en end()
#define re reverse
#define Set setprecision
#define NO cout<<"NO\n"
#define YES cout<<"YES\n"
#define No cout<<"No\n"
#define Yes cout<<"Yes\n"
const int INFi=2147483647;
const long long INFl=9223372036854775807LL;
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //int a;
    string a,b="hi";
    cin>>a;
    for(int i=0;i<20;i++){
	if(a==b){
	    Yes;
	    return 0;
	}
	b+="hi";
    }
    No;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Progaram
{
    static void Main(string[] args)
    {
        var l = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        var n = l[0]; var k = l[1];
        long a = (long)(k * Math.Pow((k - 1), n - 1));
        Console.WriteLine(a);
    }
}


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

int main() {
  string s;
  cin >>  s;
  int n = s.size();
  bool ok = true;
  rep(i,n){
    if(i%2==0 && s[i]=='L') ok = false;
    if(i%2==1 && s[i]=='R') ok = false;
  }
  if (ok) cout << "Yes" <<endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define P pair < int , ll >
#define PP pair < int , P >
#define st first
#define nd second
//This code is written by Itst
using namespace std;

inline int read(){
	int a = 0;
	char c = getchar();
	bool f = 0;
	while(!isdigit(c) && c != EOF){
		if(c == '-')
			f = 1;
		c = getchar();
	}
	if(c == EOF)
		exit(0);
	while(isdigit(c)){
		a = (a << 3) + (a << 1) + (c ^ '0');
		c = getchar();
	}
	return f ? -a : a;
}

map < P , int > dp;
int N , M , ans , head[45] , val[45] , cntEd;
struct Edge{
	int end , upEd;
}Ed[2010];
ll fj[45];

inline void addEd(int a , int b){
	Ed[++cntEd].end = b;
	Ed[cntEd].upEd = head[a];
	head[a] = cntEd;
	fj[a] |= 1ll << b;
}

void Dijk(){
    priority_queue < PP > q;
	int all = 0;
	for(int i = 0 ; i < N ; ++i)
		if(fj[0] & (1 << i))
			all += val[i];
	dp.clear();
	dp[P(0 , fj[0])] = all;
	q.push(PP(-all , P(0 , fj[0])));
	while(!q.empty()){
		PP t = q.top();
		q.pop();
		if(-t.st > dp[t.nd])
			continue;
		int x = t.nd.st , cost = dp[t.nd];
		ll y = t.nd.nd;
		if(x == N - 1){
			ans = cost;
			return;
		}
		for(int i = head[x] ; i ; i = Ed[i].upEd){
			ll k = y | fj[Ed[i].end];
			int c = 0;
			for(int j = 0 ; j < N ; ++j)
				if(k & (1ll << j))
					c += val[j];
			if(!dp.count(P(Ed[i].end , k)) || dp[P(Ed[i].end , k)] > c){
				dp[P(Ed[i].end , k)] = c;
				q.push(PP(-c , P(Ed[i].end , k)));
			}
		}
	}
}

int main(){
	while(1){
		N = read();
		M = read();
		ans = 1e9;
		for(int i = 0 ; i < N ; ++i)
			val[i] = read();
		cntEd = 0;
		memset(head , 0 , sizeof(head));
		for(int i = 0 ; i < N ; ++i)
			fj[i] = 1ll << i;
		for(int i = 1 ; i <= M ; ++i){
			int a = read() - 1 , b = read() - 1;
			addEd(a , b);
			addEd(b , a);
		}
		Dijk();
		printf("%d\n" , ans);
	}
	return 0;
}



Measured memory_bytes: 4568
N, M = map(int, input().split())
useful_num_list = list(map(int, input().split()))

need_matches = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]

dp = [-1] * (N+1)
dp[0] = 0
for i in range(1, N+1):
    max_scale = -1
    for num in useful_num_list:
        if need_matches[num] <= i:
            scale = dp[i-need_matches[num]] + 1
            if max_scale < scale:
                max_scale = scale
    dp[i] = max_scale

useful_num_list.sort(reverse=True)
ans = 0
n = N
while n > 0:
    for num in useful_num_list:
        if n < need_matches[num]:
            continue
        if dp[n] - 1 == dp[n - need_matches[num]]:
            ans += num * (10**(dp[n]-1))
            n -= need_matches[num]
            break
print(ans)


Measured memory_bytes: 3408
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
#include <map>

using namespace std;

typedef long long ll;

void solver_main()
{
	int N;
	map<string, ll> mp;

	cin >> N;

	for (ll i = 0; i < N; i++) {
		string tmp;
		cin >> tmp;
		sort(tmp.begin(), tmp.end());
		auto itr = mp.find(tmp);
		if (itr != mp.end()) {
			mp[tmp]++;
		}
		else {
			mp[tmp] = 1;
		}
	}

	ll sum = 0;
	for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
		if (itr->second > 1) {
			ll ans = 1;
			for (ll i = itr->second; i > itr->second - 2; --i) {
				ans = ans * i;
			}
			sum += ans / 2;
		}
	}

	cout << sum << endl;

}

int main(void)
{
	solver_main();
	return 0;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int n, m;
    cin >> n >> m;
    vec g[200010];
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    vec dist(n, INF);
    dist[0] = 0;

    queue<int> que;
    que.push(0);

    while (!que.empty()) {
        int v = que.front();
        que.pop();

        for (auto&& c : g[v]) {
            if (dist[c] == INF) {
                dist[c] = dist[v] + 1;
                que.push(c);
            }
        }
    }

    if (dist[n-1] == 2) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
    return 0;
}

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

int t[110000], x[110000], y[110000];
int main() {
    int n;
    cin >> n;
    t[0] = x[0] = x[0] = 0;
    for (int i = 1; i < n + 1; i++) cin >> t[i] >> x[i] >> y[i];
    bool can = true;
    for (int i = 0; i < n; i++) {
        int dt = t[i+1] - t[i];
        int dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]);
        if (dt < dist || dist % 2 != dt % 2)
            can = false;
    }
    cout << (can ? "Yes" : "No") << endl;
}


Measured memory_bytes: 1408
#include<stdio.h>
int main(void){
    int i,n,a,min=1000000,max=-1000000;
    long long int sum=0;
    scanf("%d",&n);
    i=0;
    for(i=0;i<n;i++){
        scanf("%d",&a);
        if(max<a){
            max=a;
        }
        if(min>a){
            min=a;
        }
        sum+=a;
    }
    printf("%d %d %lld\n",min,max,sum);
    return 0;
}


Measured memory_bytes: 2148
require 'matrix'

n, m, x = gets.split.map(&:to_i)
a = Matrix.zero(n, m + 1)
n.times do |i|
  b = gets.split.map(&:to_i)
  0.upto(m) do |j|
    a[i, j] = b[j]
  end
end
min = Float::INFINITY
1.upto(2 ** n - 1) do |bit|
  ans = 0
  sum = 0
  1.upto(m) do |j|
    sum = 0
    n.times do |i|
      if bit[i] == 1
        sum += a[i, j]
      end
    end
    break if sum < x
  end
  if sum >= x
    n.times do |i|
      if bit[i] == 1
        ans += a[i, 0]
      end
    end
    min = ans if min > ans
  end
end
puts (min == Float::INFINITY ? -1 : min)

Measured memory_bytes: 15152
//#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
using namespace std;
//using namespace __gnu_pbds;
//template <class c, class cmp = less<c> > using ordered_set = tree<c, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
template <typename T,typename U>pair<T,U> operator+(const pair<T,U> & l,const std::pair<T,U> & r) { return {l.first+r.first,l.second+r.second};}
typedef long long int ll;
const ll mod =1e9+7;
const int maxn = 300002;
#define endl '\n'
#define int ll
#define ld long double
#define all(x) (x).begin(),(x).end()

int32_t main()
{ 
   IOS


  string s;
  cin>>s;
  int  n = s.size();
  int dp[n+1];
  dp[0] =  1;
  vector<string> v;
  v.push_back("dream");
  v.push_back("erase");
  v.push_back("dreamer");
  v.push_back("eraser");
  for(int i = 1;i<=n;i++){
    dp[i] = 0;
    for(auto t:v){
      if(i>=t.size()){
        dp[i] = dp[i]||(dp[i-t.size()] and (s.substr(i-t.size(),t.size()) == t));
      }
    }
  }
  if(dp[n]){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }

  


  
  
    
    




  
}

Measured memory_bytes: 4500
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define maxn 5000010
const int mod=1e9+7;
ll qp(ll a,ll b)
{
	ll ans=1;
	while(b)
	{
		if(b&1) ans=ans*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return ans;	
}
ll dp[maxn];
vector<int> key[maxn];
int main()
{
	ll n,k;cin>>n>>k;
	int cnt=0;
	for(int i=1;i<=k;i++)
	{
		int ans=1;
		for(int j=2;j*i<=k;j++)
		{
			ans++;
			key[i].push_back(j*i);
		}
		dp[i]=ans;
	}

	ll ans=0;
	for(int i=k;i>=1;i--)
	{
//		cout<<i<<" "<<dp[i]<<endl;
		ll t=qp(dp[i],n);
		for(auto j:key[i]) t-=dp[j],t+=mod,t%=mod;
		dp[i]=t;
		ans+=dp[i]*i%mod;
		ans%=mod;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 127496
N = int(input())
A = list(map(int,input().split()))

MOD = 1000000007

#色ごとの人数
C=[0,0,0]
ans=1
for a in A:
    #人数が一致する色がなければOUT
    found=False
    count=C.count(a)
    if count==0:
        print(0)
        exit()
    #適当に1人足す
    C[C.index(a)]+=1
    #今見ている人の色の可能性はcount種類
    ans=ans*count%MOD

print(ans)

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

using namespace std;

#define REP(i,n)	for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,s,n)	for(int i=(s), i##_len=(n); i<i##_len; ++i)

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

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

typedef pair<int,int>			P;
typedef vector<int>				V;
typedef vector<V>				VV;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define MAX 		2505

const ll LINF = (ll)1e18+7;		//
const int INF = 1e9+7;			//2,147,483,647 (Max int)
const int MOD = 1e9+7;
// テンプレ終了
//====================================================================//

//
int main(){
	int N,X;cin >> N >> X;
	V a(N);
	REP(i,N)cin>>a[i];

	ll ans = 0;
	REPS(i,1,N){
		int d = a[i-1] + a[i];
		if(d > X){
			int diff = d-X;
			ans += diff;
			a[i] -= min(diff,a[i]);
		}
	}

	cout << ans << endl;

	return 0;
}




Measured memory_bytes: 768
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
#define pb(n,m) n.push_back(m)
#define pii pair<int,int>
using namespace std;
//using bint=boost::multiprecision::cpp_int;
typedef long long ll;
typedef unsigned long long ull;

int main(){
  int c=0;
  while(1){
    int a,b; cin>>a>>b;
    if(a==0 && b==0) break;
    if(a>b) swap(a,b);
    co(a<<" "<<b);
  }
  return 0;
}


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

int middle(int p1,int p2,int p3){
    if(p1 < p2){
        swap(p1,p2);
    }
    if(p1 < p3){
        swap(p1,p3);
    }
    if(p2 < p3){
        swap(p2,p3);
    }

    return p2;
}

int main() {
    int n;
    cin >> n;

    int p1,p2,ans = 0;

    cin >> p1 >> p2;

    for(int i = 0; i < n - 2; ++i){
        int p3;
        cin >> p3;

        if(middle(p1,p2,p3) == p2){
            ans++;
        }

        p1 = p2;
        p2 = p3;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const S = arg[0].split("");
    
    if(S.slice(0, 4).join("") === "YAKI") {
        console.log("Yes");
    } else {
        console.log("No");
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

typedef  long long ll;
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)

using namespace std;

int ctoi(char c) {
 switch (c) {
 case '0': return 0;
 case '1': return 1;
 case '2': return 2;
 case '3': return 3;
 case '4': return 4;
 case '5': return 5;
 case '6': return 6;
 case '7': return 7;
 case '8': return 8;
 case '9': return 9;
 default: return 0;
 }
}
 ll  a,b,c,i,j,k,x,y,z;
 ll A,B,C,X,Y,Z;
int main(){
  cin>>x>>a>>b;
  k=0;
  REP(i,x+1){
  	if(i%10+(i/10)%10+(i/100)%10+(i/1000)%10+(i/10000)%10<=b && i%10+(i/10)%10+(i/100)%10+(i/1000)%10+(i/10000)%10>=a)
  		k=k+i;
  }
  cout<<k;
 return 0;
}


Measured memory_bytes: 3624
use proconio::input;

fn solve(d: &usize, c: &Vec<usize>, s: &Vec<Vec<usize>>, t: &Vec<usize>) -> isize {
    let mut result: isize = 0;
    let mut contested: Vec<usize> = vec![0; 26];
    for i in 0..*d {
        result += s[i][t[i]] as isize;
        contested[t[i]] = i + 1;
        result -= contested.iter()
            .enumerate()
            .map(|pair| ((i + 1 - pair.1) * c[pair.0]) as isize)
            .sum::<isize>();
    }
    result
}

fn main() {
    input! {
        d: usize,
        c: [usize; 26],
        s: [[usize; 26]; d],
    }
    let mut t: Vec<usize> = (0..d).map(|_| rand::random::<usize>() % 26).collect();
    let mut result = solve(&d, &c, &s, &t);
    let limit: usize = 20000;
    for _ in 0..limit {
        let day = rand::random::<usize>() % d;
        let contest = rand::random::<usize>() % 26;
        let prev = t[day];
        t[day] = contest;
        let temp = solve(&d, &c, &s, &t);
        if temp < result {
            t[day] = prev;
        } else {
            result = temp;
        }
    }
    t.iter().for_each(|i| {
        println!("{}", i + 1);
    });
}

Measured memory_bytes: 2732
a, b, h, m = gets.split(' ').map(&:to_i)

ang_b = (6 * m).to_f
ang_a = (30 * h + 0.5 * m).to_f

c = Math.sqrt(a*a + b*b - 2*a*b*Math.cos((ang_b - ang_a).abs * Math::PI / 180))
puts c

Measured memory_bytes: 14748
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T> >;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repb(i, n) for(ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define reprb(i, a, b) for(ll i = (a)-1; i >= (b); i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(unsigned long long x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
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; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

// 隣接リスト
const ll MAX_V = 100010;
V<vp> g(MAX_V, vp());
vi visited(MAX_V, 0);
vll dist(MAX_V, 0);

// グラフに対する深さ優先探索
void dfs(ll node, ll d){
    visited[node] = 1;
    dist[node] = d;
    for(auto to: g[node]){
        if(!visited[to.first]) dfs(to.first, d+to.second);
    }
}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n;
    cin >> n;
    vll a(n-1), b(n-1), c(n-1);
    rep(i, n-1){
        cin >> a[i] >> b[i] >> c[i];
    }
    ll q, k;
    cin >> q >> k;
    vll x(q), y(q);
    rep(i, q){
        cin >> x[i] >> y[i];
    }
    
    rep(i, n-1){
        g[a[i]].emplace_back(b[i], c[i]);
        g[b[i]].emplace_back(a[i], c[i]);
    }
    dfs(k, 0);
    rep(i, q){
        cout << dist[x[i]]+dist[y[i]] << endl;
    }
    return 0;
}

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

int main(void){
    int v[3];
    rep(i,3){
        cin>>v[i];
    }
    sort(v,v+3);
    cout<<((v[0]+v[1]==v[2]) ? "Yes" : "No")<<endl;
    return 0;
}


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

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

int main() {
    int N = 20;
    string word(N, 'a');
    cin >> word;

    rep (i,word.size()) {
        if (word[i] == ',') word[i] = ' ';
    }

    string greeting;
    rep (i,word.size()) {
        greeting += word[i];
    }

    cout << greeting << endl;
    
    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
const int maxN = 2e5+10;
long long a[maxN],flag[maxN];
int main()
{
    int N;
    scanf("%d",&N);
    for(int i=1;i<=N;i++)scanf("%lld",&a[i]);
    for(int i=1;i<=N;i++)flag[a[i]]++;
    long long ans=0;
    for(int i=1;i<=N;i++)ans+=flag[i]*(flag[i]-1)/2;
    for(int i=1;i<=N;i++)printf("%lld\n",ans-flag[a[i]]+1);
}


Measured memory_bytes: 4736
#!/usr/bin/env python3

n, k = map(int, input().split())

lim = (n - 1) * (n - 2) // 2
if k > lim:
    print(-1)
    exit()

edges = []
for i in range(n - 1):
    edges.append((i, n - 1))

combs = []
for i in range(n - 1):
    for j in range(i):
        combs.append((j, i))

edges.extend(combs[:lim - k])

print(len(edges))
for a, b in edges:
    print(a + 1, b + 1)


Measured memory_bytes: 4020
#include <boost/multiprecision/cpp_int.hpp>
#include <iostream>
#include <limits.h>
#include <vector>
#include <algorithm>

using namespace boost::multiprecision;
using namespace std;

int main()
{
    int n = 2;
    cin >> n;

    string s = "RR";
    cin >> s;

    int c = 0;
    int cs = 0;
    int ce = n - 1;
    while (1) {
        for (int i = cs; i < n; ++i) {
            if (s[i] == 'W') {
                cs = i; break;
            }
            if (i == n - 1) {
                cs = n - 1; break;
            }
        }
        for (int i = ce; i >= 0; --i) {
            if (s[i] == 'R') {
                ce = i; break;
            }
            if (i == 0) {
                ce = 0; break;
            }
        }
        if (cs >= ce) break;
        ++c;
        cs++;
        ce--;
    }

    cout << c << endl;

    return 0;
}



Measured memory_bytes: 3520
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

//mod(1e9+7)
const int mod = 1e9+7;
struct mint {
    ll x;
    mint(ll x = 0) : x(x % 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;
    }
};

int main() {
    int n; cin >> n;
    mint sum = 1;
    for (int i = 1; i <= n; i++) {
        sum *= i;
    }
    cout << sum.x << endl;
}

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

using namespace std;

typedef long long ll;

static const int INTINF = (2147483647);
static const ll LLINF = (9223372036854775807);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;

namespace Printer{
    template<class T>
    void print(T x){
        cout << x << endl;
    }

    template<class T>
    void print(T x, T y){
        cout << x << "," << y << endl;
    }

    template<class T>
    void print(vector<T> v){
        rep(i, v.size()){
            if(i) cout << " ";
            cout<< v[i];
        }
        cout << endl;
    }

    template<class T>
    void print(vector<vector<T> > vv){
        rep(i, vv.size()){
            rep(j, vv[i].size()){
                if(j) cout << " ";
                cout << vv[i][j];
            }
            cout << endl;
        }
    }

    void print(pair<int, int> p){
        cout << "(" << p.first << ", " << p.second << ")" << endl;
    }
};
using namespace Printer;

//--global--//



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

int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------//

    char n;
    cin >> n;
    cout << char(n+1) << endl;
    
    return 0;
}


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

using namespace std;

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

  int N; cin>>N;
  map<int, int> cards;
  for (int i = 0; i < N; i++) {
    int a; cin>>a;
    cards[a]++;
  }
  map<int, int> ccmap;
  for (auto& c : cards) {
    ccmap[c.second]++;
  }
  struct Dpe {
    int d, kd;
  };
  vector<Dpe> cum(N+1);
  cum[0] = {0,0};
  for (int i = 1; i < N+1; i++) {
    cum[i] = cum[i-1];
    auto find = ccmap.find(i);
    if (find != ccmap.end()) {
      cum[i].d += find->second;
      cum[i].kd += i * find->second;
    }
  }

  auto max_len_div = [&](int div) {
    return floor(float(cum[div].kd + div*(cum[N].d - cum[div].d)) / div);
  };
  for (int k = 1; k <= N; k++) {
    int l = 1, r = N;
    int res = 0;
    while (l <= r) {
      int c = (l+r)/2;
      if (max_len_div(c) >= k) {
        l = c+1;
        res = c;
      } else {
        r = c-1;
      }
    }
    cout << res << endl;
  }

  return 0;
}


Measured memory_bytes: 16640
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
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;
}

int main(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = 0;
  ll n;
  cin >> n;
  // ll n, m;
  // cin >> n >> m;
  // ll n, m, k;
  // cin >> n >> m >> k;
  string s, t;
  cin >> s >> t;
  // if(s == t) {
  //   cout << n << endl;
  //   return 0;
  // }
  ans = 2 * n;
  fi(1, n + 1) {
    // if(s[n - 1 - i] == t[i])
    //   ans--;
    // else
    //   break;
    if(s.compare(n - i, i, t, 0, i) == 0)
      ans = 2 * n - i;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <cmath>

using namespace std;

#define ll long long

int main(void){
    ll n;
    cin >> n;
    vector<ll> x(n), l(n);
    for(ll i = 0;i < n;++i) cin >> x[i] >> l[i];
    vector<pair<ll, ll>> data(n);

    for(ll i = 0;i <n;++i){
        data[i].first = x[i]+l[i];
        data[i].second = x[i]-l[i];
    }

    sort(data.begin(), data.end());

    ll ans = 0;
    ll t = -10000000000;
        for(ll i = 0;i < n;++i){
            if(t <= data[i].second){
                ans++;
                t = data[i].first;
            }
        }
    

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3328