akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define pq priority_queue
using namespace std;
const ll INF=(ll)1e9;
const ll MOD=(ll)1e9+7;
const ll MAX=510000;
vector<int> dx={1,0,-1,0,1,-1,1,-1},dy={0,1,0,-1,1,-1,-1,1};
template<class T> inline bool chmax(T& a, T b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a>b) { a=b; return 1; } return 0; }

int main(){
    ll N,cnt=0;
    cin>>N;
    ll A[N];
    for(ll i=0;i<N;i++) cin>>A[i];
    
    if(A[0]!=0){
        cout<<"-1"<<endl;
        return 0;
    }
    for(ll i=0;i<N-1;i++){
        if(A[i+1]-A[i]>1){
            cout<<"-1"<<endl;
            return 0;
        }
    }
    for(ll i=0;i<N;i++){
        if(A[i+1]-A[i]!=1) cnt+=A[i];
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>

using namespace std;

int main() {
    std::ios::sync_with_stdio(0); cin.tie(0);
    int A;
    double b=0;

    cin >> A;
    for(int i=0;i<A;i++){
        double z;
        string p;
        cin >> z;
        cin >> p;
        if(p=="BTC") {
            b += z*380000;
        }else if(p=="JPY"){
            b += z;
        }
    }
    cout << b << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <stdbool.h>
typedef long long LL;
typedef long double Lf;
#define in (void)scanf
#define Rep(i,a,n)for(int i=(int)(a);i<(int)(n);i++)
//#define Rep(i,a,n)for(LL i=(LL)(a);i<(LL)(n);i++)
#define rep(i,n)Rep(i,0,n)
#define Repp(i,l,r,k)for(int i=(int)(l);i<(int)(r);i+=(int)(k))
//#define Repp(i,l,r,k)for(LL i=(LL)(l);i<(LL)(r);i+=(LL)(k))
#define Ma(x,y) ((x)>(y)?(x):(y))
#define mi(x,y) ((x)<(y)?(x):(y))
#define MOD 1000000007//998244353,1000000007,1000000009,4999999999999997
int upi(const void* a, const void* b) { return*(int*)a<*(int*)b ? -1 : *(int*)a> * (int*)b ? 1 : 0; }
int downi(const void* a, const void* b) { return*(int*)a<*(int*)b ? 1 : *(int*)a> * (int*)b ? -1 : 0; }
void sortupi(int* a, int n) { qsort(a, n, sizeof(int), upi); } //1,2,3,4,...
void sortdowni(int* a, int n) { qsort(a, n, sizeof(int), downi); }
int upLL(const void* a, const void* b) { return*(LL*)a<*(LL*)b ? -1 : *(LL*)a> * (LL*)b ? 1 : 0; }
int downLL(const void* a, const void* b) { return*(LL*)a<*(LL*)b ? 1 : *(LL*)a> * (LL*)b ? -1 : 0; }
void sortupLL(LL* a, int n) { qsort(a, n, sizeof(LL), upLL); }
void sortdownLL(LL* a, int n) { qsort(a, n, sizeof(LL), downLL); }
int cmp_char(const void* a, const void* b) { return *(char*)a - *(char*)b; } // a,b,c,d
int cmp_str(const void* a, const void* b) { return strcmp(*(const char**)a, *(const char**)b); } // aaa,aab
LL gcd(LL p, LL q) { while (q) { LL t = p % q; p = q; q = t; }return p; }
LL modpow(LL a,LL n,int m){LL x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
#define invmodpow(b,p)modpow(b,p-2,p)// a/b≡a*b^{-1}(mod p)...return b^{-1}(mod p)
typedef struct fac { LL n, exp; }F;
LL fact(LL n,F*a){LL x,i,j,c=0;x=n;for(i=2;i*i<=x;i++){for(j=1;x%i==0;j++)x/=i;if(j>1){a[c].n=i;a[c++].exp=j-1;}}if(x-1){a[c].n=x;a[c++].exp=1;}return c;}
//snippet



#define N 1111111

void run() {
	int n, a[N], g;
	in("%d", &n);
	rep(i, n) {
		in("%d", &a[i]);
		if (!i)g = a[i];
		else g = gcd(a[i], g);
	}
	if (g - 1) {
		printf("not coprime\n");
		return;
	}

	int d[N] = { 0 };
	rep(i, n) {
		F f[N];
		int c = fact(a[i], f);
		rep(j, c)d[f[j].n]++;
	}
	rep(i, N)if (d[i] > 1) {
		printf("setwise coprime\n");
		return;
	}
	printf("pairwise coprime\n");
}

int main() {
	int test = 1;
//	in("%d", &test);
	while (test--) {
		run();
	}
}

Measured memory_bytes: 9876
N = int(input())
A = [[]]*N
B = list(map(int, input().split()))
A[0] = B[0]
A[N-1] = B[N-2]
for i in range(N-2):
    if B[i] <= B[i+1]:
        A[i+1] = B[i]
    else:
        A[i+1] = B[i+1]
        
ans = sum(A)
print(ans)

Measured memory_bytes: 3064
#include <iostream>

auto xor_sum(long long x){
  long long one = 1, ans = 0;
  for(int i = 40; i >= 1; i--){
    ans <<= 1;
    if(!(x&1) && ((x>>i)&1)) ans++;
  }
  ans <<= 1;
  if(x%4==1 || x%4==2) ans++;
  return ans;
}

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

  if(A==0) A=1;
  std::cout << (xor_sum(B)^xor_sum(A-1)) << std::endl;

  return 0;
}



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

using namespace std;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define pb push_back
#define int long long

signed main(){

	int a,b;
	cin>>a>>b;

	int ans=a-b;

	if(ans<=0){
		cout<<0<<endl;
	}else{
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
  static final long MOD = 1_000_000_007;
  static int n;

  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    n = sc.nextInt();

    long ans = 1;
    for(int i = 1; i <= n; i++){
      ans = (ans * (long)i) % MOD;
    }

    System.out.println(ans);
  }
}


Measured memory_bytes: 21844
let reads f = stdin.ReadLine().Split() |> Array.map f
let count xs =
    let rec loop ys i =
        match ys with
        | [] | [_] -> i
        | h::hs when h <> hs.[0] -> loop hs (i+1)
        | h::hs -> loop hs i
    loop xs 0
let [| n; k; |] = reads int
let s = (stdin.ReadLine()).ToCharArray() |> Array.toList
n - 1 + (min 0 (2*k-(count s)))
|> printfn "%d"

Measured memory_bytes: 22744
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <functional>
#include <utility>
#include <unordered_map>
#include <map>
#include <set>
#define INF 2147483647
#define INF_LL 9223372036854775807
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


int main() {
	int N, M;
	cin >> N >> M;
	vector<vector<int> > d(N+1, vector<int>(N+1, INF/3));
	vector<vector<int> > n(N+1, vector<int>(N+1));
	for (int i = 1; i < N+1; i++)for (int j = 1; j < N+1; j++) {
		if (i == j)d[i][j] = 0;
		n[i][j] = j;
	}
	for (int i = 0; i < M; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		d[a][b] = d[b][a] = c;
	}
	for (int k = 1; k < N + 1; k++)for (int i = 1; i < N + 1; i++)for (int j = 1; j < N + 1; j++) {
		if (d[i][j] > d[i][k] + d[k][j]) {
			d[i][j] = d[i][k] + d[k][j];
			n[i][j] = n[i][k];
		}
	}
	set<pair<int, int> > l;
	for (int i = 1; i < N + 1; i++)for (int j = 1; j < N + 1; j++) {
		if (i == j)continue;
		int a = i, b = n[i][j];
		if (a > b)swap(a, b);
		l.insert({ a,b });
	}
	cout << M - (int)l.size() << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#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 revrep(i, s) for (int i = s-1; i > 0; i--)
#define revrrep(i, s) for (int i = s-1; i >= 0; i--)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    int W, H, N; cin >> W >> H >> N;
    int min_h = 0, max_h = H;
    int min_w = 0, max_w = W;
    rep (i, 0, N) {
        int x, y, a; cin >> x >> y >> a;
        if (1 == a) min_w = max(min_w, x);
        if (2 == a) max_w = min(max_w, x);
        if (3 == a) min_h = max(min_h, y);
        if (4 == a) max_h = min(max_h, y);
    }
    if ((max_h - min_h <= 0) or (max_w - min_w <= 0)) {
        cout << 0 << endl;
        return 0;
    }
    cout << (max_h - min_h) * (max_w - min_w) << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

const int N = (int)2*1e5;
typedef long long ll;
int a[N];
int n;
ll c[2][N];

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

	c[0][0] = a[0];
	c[1][0] = -a[0];
	for (int i = 1; i < n; i++) {
		c[0][i] = max(c[0][i-1] + a[i], c[1][i-1] - a[i]);
		c[1][i] = max(c[0][i-1] - a[i], c[1][i-1] + a[i]);
	}
	cout << c[0][n-1] << endl;
}


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

long long N, a[11111], b[11111], Sa = 0, Sb = 0, S, Sd;

int main(){
    scanf("%lld", &N);
    for(int i = 0; i < N; ++i){
        scanf("%lld", a + i);
        Sa += a[i];
    }
    for(int i = 0; i < N; ++i){
        scanf("%lld", b + i);
        Sb += b[i];
        Sd += a[i] > b[i] ? a[i] - b[i] : ((a[i] ^ b[i]) & 1);
    }
    sort(a, a + N);
    sort(b, b + N);
    S = Sb - Sa;
    if(Sd > S)return 0 & puts("No");
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 384
fun main(args: Array<String>) 
{
    val (sx, sy, tx, ty) = readLine()!!.split(" ").map {x -> x.toInt()} //入力
    val dx = tx-sx
    val dy = ty-sy
    print("U".repeat(dy)+"R".repeat(dx)+"D".repeat(dy)+"L".repeat(dx))//内側の一往復
    println("L" + "U".repeat(dy + 1) + "R".repeat(dx + 1)  + "D" + 
            "R" + "D".repeat(dy + 1) + "L".repeat(dx + 1)  + "U")//外側の一往復
}

Measured memory_bytes: 37680
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>
#include <cmath>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

template <class T>
void debug(T& v)
{
    for(auto& x: v) cout << x << " ";
    cout << endl;
}

int main()
{
    ll M;
    cin >> M;
    vector<ll> d(M), c(M);
    for(int i=0; i<M; i++) cin >> d[i] >> c[i];

    ll s = 0, n = 0;
    for(int i=0; i<M; i++){
        s += d[i] * c[i];
        n += c[i];
    }

    ll ans = n-1+s/9;
    if(s%9==0) ans--;
    cout << ans << endl;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>
using namespace std;
 
template <class T> using V = vector<T>;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(b);i>(ll)(a);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n,m;
  	ci(n>>m);
  if(n==0&&m==100){
    co(101)
  }
  else if(n==1&&m==100){
    co(10100)
  }
  else if(n==2&&m==100){
    co(1010000)
  }
  else{
  ll a=pow(100,n); 
  co(a*m)
  }
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# モジュールのインポート
import math


def get_input() -> tuple:
    """
    標準入力を取得する.

    Returns:\n
        tuple: 標準入力
    """
    # 標準入力を取得
    N, K = list(map(int, input().split()))
    A = list(map(int, input().split()))

    return N, K, A


def main(N: int, K: int) -> None:
    """
    メイン処理.

    Args:\n
        N (int): 数列の長さ(2 <= K <= N <= 10**5)
        K (int): 選択する要素数(2 <= K <= N <= 10**5)
    """
    # 求解処理
    ans = math.ceil((N - 1) / (K - 1))

    # 結果出力
    print(ans)


if __name__ == "__main__":
    # 標準入力を取得
    N, K, A = get_input()

    # メイン処理
    main(N, K)


Measured memory_bytes: 20580
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()

n = ni()
h = na()
dp = [10 ** 9 + 7] * (n + 1)
dp[0] = 0
dp[1] = abs(h[1] - h[0])
for i in range(2, n):
    dp[i] = min(dp[i-1] + abs(h[i] - h[i - 1]), dp[i-2] + abs(h[i] - h[i - 2]))
print(dp[n-1])

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

int main() {
	int N, M;
	cin >> N >> M;
	if (N == 1 && M == 0) {
		puts("0");
		return 0;
	}
	string number = "";
	number.push_back('1');
	rep(i, N - 1) {
		number.push_back('0');
	}
	vector<bool> judge(N, true);
	rep(i, M) {
		int s, c;
		cin >> s >> c;
		if (judge.at(s - 1) == false) {
			if (number.at(s - 1) != c + 48) {
				puts("-1");
				return 0;
			}
		}
		else {
			judge.at(s - 1) = false;
			number.at(s - 1) = c + 48;
		}
	}
	cout << (to_string(stoi(number)).size() == N ? stoi(number) : -1) << endl;
	return 0;
}


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


int main()
{
	int a,b;
	scanf("%d %d", &a,&b);
	if (a>b)
		printf("a > b\n",a,b);
	if (a<b)
		printf("a < b\n", a, b);
	if (a==b)
		printf("a == b\n", a, b);
}


Measured memory_bytes: 3172
#include<bits/stdc++.h>
#define re register
using namespace std;
inline int read(){
	re int t=0;re char v=getchar();
	while(v<'0')v=getchar();
	while(v>='0')t=(t<<3)+(t<<1)+v-48,v=getchar();
	return t;
}
int n,ans;
map<string,bool>v;
char s[12];
int main(){
	n=read();
	while(n--){
		scanf("%s",s);
		if(!v[s])++ans,v[s]=1;
	}
	printf("%d",ans);
}


Measured memory_bytes: 19284
import sys

#sys.stdin = open('b_2.txt', 'r')

N = int(raw_input())
rest = [0 for _ in range(N)]
ins = [0 for _ in range(N)]
pairs = 0
for x in range(N):
	n = long(raw_input())
	ins[x] = n
	pairs += n / 2
	rest[x] = n % 2

for x in range(0, N - 1, 1):
	if ((rest[x] == 1) and (rest[x + 1] == 1)):
		pairs += 1
		rest[x] = 0
		rest[x + 1] = 0
	elif ((rest[x] == 1) and (rest[x + 1] == 0) and (ins[x + 1] > 0)):
		rest[x + 1] = 1
		ins[x + 1] -= 2
		rest[x] = 0
	else:
		pass

print str(pairs)


Measured memory_bytes: 13704
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int count = 0;
        for (int i = 0; i < s.length() - 1; i++) {
            if (s.charAt(i) == s.charAt(i + 1)) count++;
        }
        if (count >= 1) System.out.println("Bad");
        else System.out.println("Good");
    }
}

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

using namespace std;

inline int read()
{
    int ret=0,flag=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')flag=-1;c=getchar();}
    while(c>='0'&&c<='9')ret=ret*10+(c^'0'),c=getchar();
    return flag*ret;
}

const int N=1e5+5;
int h,n;

int main()
{
    h=read(),n=read();
    while(n--)h-=read();
    if(h<=0)printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 256
t = int(input())

import sys
sys.setrecursionlimit(10 ** 6)

def calc(x):
    if x in dp:
        return dp[x]#メモ済の場合はそれを利用
    
    divs = [5, 3, 2]
    costs = [c, b, a]
    res = d * x #全てDでいった場合が初期設定
    for div, cost in zip(divs, costs):
        dived = x//div
        res = min(res, calc(dived) + cost + abs(x-dived*div) * d)#floorでの再帰
        if x > div:#Nのほうが小さい場合は不要
            dived = x//div+1
            res = min(res, calc(dived) + cost + abs(x-dived*div) * d)#ceilでの再帰
    dp[x] = res#メモしておく
    return res

for _ in range(t):
    n, a, b, c, d = list(map(int, input().split()))
    dp = {}#辞書で管理
    dp[0] = 0
    dp[1] = d
    print(calc(n))

Measured memory_bytes: 93096
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

const ll INF = 1000000002;

template <typename T>
struct BIT
{
    int n;
    vector<T> bit;
    
    BIT(){}
    
    BIT(int n) : n(n){
        bit.resize(n + 1);
    }
    
    T sum(int i){
        i++;
        T res = 0;
        while(i){
            res += bit[i];
            i -= (i & -i);
        }
        return res;
    }
    
    void add(int i, T x){
        i++;
        while(i <= n){
            bit[i] += x;
            i += (i & -i);
        }
    }
};

int main()
{
    ll n, d, a;
    cin >> n >> d >> a;
    P p[200002];
    for(int i = 0; i < n; i++){
        ll x, h;
        cin >> x >> h;
        h = (h - 1) / a + 1;
        p[i] = P(x, h);
    }
    sort(p, p + n);
    BIT<ll> bit(n + 1);
    ll ans = 0;
    for(int i = 0; i < n; i++){
        ll l = bit.sum(i);
        if(l >= p[i].second) continue;
        ans += p[i].second - l;
        int t = upper_bound(p, p + n, P(p[i].first + d * 2, INF)) - p;
        bit.add(i, p[i].second - l);
        bit.add(t, l - p[i].second);
    }
    cout << ans << endl;
}

Measured memory_bytes: 4992
import numpy as np

def main():
    args = input().rstrip().split(' ')
    N = int(args[0])
    args = input().rstrip().split(' ')
    A = np.array([int(val) for val in args])
    sup = np.zeros(N-1, dtype=np.int)
    
    for a in A:
        sup[a-1] += 1
    for val in sup:
        print(val)
    print(0)
    
if __name__ == "__main__":
    main()

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

int main() {
  int n, k;
  cin >> n >> k;
  ll ans = k;
  rep(i,n-1) ans *= k-1;
  cout << ans << endl;
}

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

using namespace std;

//// my original verion
//void Main() {
//    long long N;
//    cin >> N;
//    map<long long, set<pair<long long, long long> > > tree;
//    for (long long i = 0; i < N - 1; ++i) {
//        long long a, b, c;
//        cin >> a >> b >> c;
//        if (tree.count(a) == 0) {
//            tree.insert(make_pair(a, set<pair<long long, long long> >()));
//        }
//        tree[a].insert(make_pair(b, c));
//        if (tree.count(b) == 0) {
//            tree.insert(make_pair(b, set<pair<long long, long long> >()));
//        }
//        tree[b].insert(make_pair(a, c));
//    }
//
//    long long Q, K;
//    cin >> Q >> K;
//    vector<long long> distanceFromK(N + 1, -1LL);
//    distanceFromK[K] = 0LL;
//    queue<long long> q;
//    q.push(K);
//    while (!q.empty()) {
//        long long f = q.front();
//        q.pop();
//        long long distanceFromTop = distanceFromK[f];
//        const set<pair<long long, long long> >& nextNodes = tree[f];
//        for (auto e : nextNodes) {
//            if (distanceFromK[e.first] < 0) {
//                q.push(e.first);
//                distanceFromK[e.first] = e.second + distanceFromTop;
//            }
//        }
//    }
//
//    for (long long i = 0; i < Q; ++i) {
//        long long x, y;
//        cin >> x >> y;
//        long long dx = distanceFromK[x];
//        long long dy = distanceFromK[y];
//        cout << (dx + dy) << endl;
//    }
//
//}

void dfs(int curr, const map<int, set<pair<int, long long> > >& tree, vector<long long>& distance) {
    auto nextNodes = tree.at(curr);
    for (auto p : nextNodes) {
        int next = p.first;
        long long d = p.second;
        if (distance[next] < 0) {
            distance[next] = distance[curr] + d;
            dfs(next, tree, distance);
        }
    }
}

void Main() {
    int N;
    cin >> N;
    map<int, set<pair<int, long long> > > tree;
    for (int i = 0; i < N - 1; ++i) {
        int a, b;
        long long c;
        cin >> a >> b >> c;
        tree[a].insert(make_pair(b, c));
        tree[b].insert(make_pair(a, c));
    }
    int Q, K;
    cin >> Q >> K;
    vector<long long> distance(N + 1, -1LL);
    distance[K] = 0LL;
    dfs(K, tree, distance);

    for (int i = 0; i < Q; ++i) {
        int x, y;
        cin >> x >> y;
        cout << (distance[x] + distance[y]) << endl;
    }

}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 53832
#include<iostream>

using namespace std;

int main(void) {
	string event;
	bool first, second, third, home;
	int inning, out, points;
	int i;

	cin >> inning;
	for(i = 0; i < inning; i++) {
		points = 0;
		out = 0;
		first = false;
		second = false;
		third = false;
		home = false;
		while(out < 3) {
			cin >> event;
			if(event == "HIT") {
				home = third;
				third = second;
				second = first;
				first = true;
				if(home) {
					points++;
					home = false;
				}
			} else if(event == "HOMERUN") {
				if(first) {
					points++;
					first = false;
				}
				if(second) {
					points++;
					second = false;
				}
				if(third) {
					points++;
					third = false;
				}
				points++;
			} else if(event == "OUT") {
				out++;
			}
		}
		cout << points << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define DEBUG(x)                   cout << '>' << #x << ':' << x << endl;
//log(n)*n*n
map<string,vector<int> > m;
bool check(int mid,string s,int n)
{
    if(mid>=n)
        return false;
    string s1="",s2="";
    for(int i=0; i<mid; i++)
    {
        s1+=s[i];
    }
    int temp=0;
    m[s1].push_back(mid-1);
    for(int i=mid; i<n; i++)
    {
        s1.erase(s1.begin());
        s1.push_back(s[i]);
        if(m[s1].size()!=0)
        {
            if(m[s1][0]<=(i-mid))
                return true;
        }
        else
            m[s1].push_back(i);
    }
    return false;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie();
    cout.tie();
    int n;
    string s;
    cin>>n;
    cin>>s;
    int len=s.size()/2;
    int last=0;
    int hi=len+2,lo=1,mid;
    while(hi-lo>5)
    {
        m.clear();
        mid=(lo+hi)>>1;
        if(check(mid,s,n)==true)
        {
            lo=mid;
        }
        else
            hi=mid-1;

    }
    while(check(lo,s,n)==true)
        lo++;
    cout<<lo-1<<endl;
    return 0;
}


Measured memory_bytes: 36588
def nC2 (n):
    return n*(n-1)//2 

N = int(input())
A = tuple(map(int,input().split()))
cnt = [0]*200005
tot = 0
for i in A:
    cnt[i] += 1
for i in cnt:
    tot += nC2(i)
for i in range(N):
    ans = tot - nC2(cnt[A[i]]) + nC2(cnt[A[i]]-1)
    print(ans)

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

 int main() {
 string s, t;
 cin >> s >> t;
 int ans = 0;
 if(s[0] == t[0]) ans++;
 if(s[1] == t[1]) ans++;
 if(s[2] == t[2]) ans++;
 cout << ans << endl;
 }

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

#define int long long int
#define ld long double
int32_t main()

{   ld m;
	int n,y,x;
    cin>>n>>m;
    x=m;
    
    
    y=n*x;
    ld z=m-x;
    z=(ld)n*z;
    y=y+z;
    cout<< y <<"\n";
}


Measured memory_bytes: 3712
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt(), b = sc.nextInt();

        for (int i = 1; i <= 1009; i++) {
            int x = (int) Math.floor(i * 0.08);
            int y = (int) Math.floor(i * 0.1);
            if (x == a && y == b) {
                System.out.println(i);
                return;
            }
        }
        System.out.println(-1);
    }
}

Measured memory_bytes: 25300
#include<stdio.h>

bool map[ 92 ][ 92 ] ;

int mx[] = { 0 ,1 ,-1 ,0 } ;
int my[] = { 1 ,0 ,0 ,-1 } ;

int ans ;

int move( int y ,int x ,int cnt )
{
	map[ y ][ x ] = false ;

	if( cnt > ans )
	{
		ans = cnt ;
	}

	for( int i = 0 ; i < 4 ; i++ )
	{
		int yy = y + my[ i ] ;
		int xx = x + mx[ i ] ;

		if( map[ yy ][ xx ] == true )
		{
			move( yy ,xx ,cnt + 1 )	;
		}
	}

	map[ y ][ x ] = true ;

	return ans ;
}



int main()
{
	int h ,w ;

	while( true )
	{
		scanf( "%d %d" ,&h ,&w ) ;

		if( w == h && !w )
		{
			return 0 ;
		}

		ans = 0 ;

		for( int i = 1 ; i <= h ; i++ )
		{
			for( int j = 1 ; j <= w ; j++ )
			{
				scanf( "%d" ,&map[ i ][ j ] ) ;
			}
		}

		for( int i = 1 ; i <= h ; i++ )
		{
			for( int j = 1 ; j <= w ; j++ )
			{
				if( map[ i ][ j ] == 1 )
				{
					int ans_ = move( i ,j ,1 ) ;
					ans = ans < ans_ ? ans_ : ans ;
				}
			}
		}

		printf( "%d\n" ,ans ) ;
	}
}

Measured memory_bytes: 2676
n = int(input())
a = list(map(int,input().split()))
d = {}
for ai in a:
  if ai in d:
    d[ai] += 1
  else:
    d[ai] = 1
d = sorted(d.items(),reverse = True)
r = []
for k,v in d:
  if len(r) >= 2:
    break
  if v >= 4:
    r.append(k)
    r.append(k)
  elif v >= 2:
    r.append(k)
if len(r) < 2:
  print(0)
else:
  print(r[0]*r[1])


Measured memory_bytes: 68376
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvdi(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)

#define rep(i,n) for(auto i=0; i<(n); i++)
#define isValidPoint(x, y, mx, my) x >= 0 && x  < mx && y >= 0 && y < my

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

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;
  }
};


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

  long n,k,q;
  cin >> n >> k >> q;

  vector<long> a(n);

  rep(i, n) {
    a[i] = k-q;
  }

  rep(i, q) {
    int x;
    cin >> x;
    a[x-1]++;
  }

  rep(i, n) {
    cout << (a[i]>0?"Yes":"No")<<endl;
  }
  
}


Measured memory_bytes: 1408
#include <algorithm>
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <vector>
#include <queue>
#include <math.h>
#include <string> 
#include <bits/stdc++.h>
using namespace std;

int main(){
    int X;
    cin >> X;
    int Happy1 =0;
    int Happy2 =0;
    Happy1 = X/500;
    Happy2 = (X%500)/5;
    cout << Happy1*1000 + Happy2*5 << endl;

}

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

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

template <class T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
	for (const auto& e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}
template <class T>
ostream& operator<<(ostream& os, const set<T>& st) {
	for (const auto& e : st) os << e << " ";
	return os;
}
template <class T1, class T2>
ostream& operator<<(ostream& os, const pair<T1, T2>& p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}
template <class T1, class T2>
ostream& operator<<(ostream& os, const map<T1, T2>& mp) {
	for (const auto& e : mp) os << e << " ";
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T&& h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head&& h, Tail&&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

vector<vector<Int>> G;
vector<Int> disF;//フェネックからの距離
vector<Int> disS;//すぬけからの距離
Int N;

void dfs(Int s,Int d, vector<Int>& v) {

	v[s] = d;

	for (auto e : G[s]) {
		if (v[e] != -INF)continue;
		else dfs(e, d + 1, v);
	}

}

int main() {

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

	cin >> N;

	G.resize(N);
	disF.resize(N,-INF);
	disS.resize(N,-INF);

	Int a, b;
	for (Int i = 0; i < N-1; i++) {
		cin >> a >> b;
		a--;
		b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}

	dfs(0, 0,disF);
	dfs(N - 1,0, disS);
	
	DMP(disF, disS);

	Int cntF = 1;
	Int cntS = 1;

	for (Int i = 1; i < N-1; i++) {
		if (disF[i] <= disS[i])cntF++;
		else cntS++;
	}

	if (cntF > cntS) {
		cout << "Fennec" << "\n";
	}
	else {
		cout << "Snuke" << "\n";
	}

}


Measured memory_bytes: 12032
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
static const int dx[4] = { 0, 1, 0, -1 };
static const int dy[4] = { 1, 0, -1, 0 };
static const char dir[4] = { 'u', 'r', 'd', 'l' };
static const ll INF = 1ll << 50;
static const ll MOD = 1e9 + 7;
int N, M;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> N >> M;

    const int NMAX = 1000;
    const int MMAX = 2000;
    int a[MMAX], b[MMAX];
    ll c[MMAX];

    rep(i, M)
    {
        cin >> a[i] >> b[i] >> c[i];
        --a[i], --b[i];
        c[i] *= -1; // コストに負をかけて最短経路を求める
    }

    ll dist[NMAX];

    rep(i, N)
    {
        dist[i] = INF;
    }

    dist[0] = 0; // 頂点1の最短距離は0

    rep(i, N - 1) // 経路の長さは最大でN-1なので最短距離の更新はN-1回行う
    {
        rep(j, M)
        {
            if (dist[a[j]] == INF) { // a[j]には行けない
                continue;
            }
            if (dist[b[j]] > dist[a[j]] + c[j]) { //
                dist[b[j]] = dist[a[j]] + c[j];
            }
        }
    }

    ll ans = dist[N - 1]; // 頂点への最短距離(負を掛けているので)

    bool negative[NMAX]; // 負経路を検出するための配列
    memset(negative, false, sizeof(negative));

    // 負経路の影響がある点を計測する
    // この時,N番目のノードにまで影響があれば"inf"
    rep(i, N)
    {
        rep(j, M)
        {
            if (dist[a[j]] == INF) {
                continue;
            }
            if (dist[b[j]] > dist[a[j]] + c[j]) {
                dist[b[j]] = dist[a[j]] + c[j];
                negative[b[j]] = true;
            }
            if (negative[a[j]] == true) {
                negative[b[j]] = true;
            }
        }
    }

    if (negative[N - 1]) {
        cout << "inf" << endl;
    } else {
        cout << -ans << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vs = vector<char>;
bool ok(vs a){
  int n = a.size();
  bool flag = true;
  for(int i=0;i<n;i++){
    if(!(a.at(i)=='A' || a.at(i)=='T' || a.at(i)=='C' || a.at(i)=='G') ){
      flag = false;
    }
  }
  return flag;
}
int main() {
  string s;
  cin >> s;
  int n = s.size();
  vs ss(n);
  for(int i=0;i<n;i++){
    ss.at(i) = s.at(i);
  }
  int max = 0;
  for(int i=0;i<n;i++){
    for(int j=i;j<n;j++){
      vs sss = vector(ss.begin() + i, ss.begin() + j + 1);
      if(ok(sss)){
        if(j-i+1 > max){
          max = j-i+1;
        }
      }
    }
  }
  cout << max << endl;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h> 
using namespace std; 
#define ll long long
#define mod (int)(1e9 + 7) 
bool is_perfect(ll n)
{
    ll x=sqrt(n);
    return x*x==n;
}
int main() 
{ 
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll n,m,ans=0;
    cin>>n>>m;
    vector<vector<ll>> arr;
    for(ll i=0;i<n;i++)
    {
        vector<ll> row;
        for(ll j=0;j<m;j++)
        {
            ll t;
            cin>>t;
            row.push_back(t);
        }
        arr.push_back(row);
    }
    for(ll i=0;i<n;i++)
    {
        for(ll j=i+1;j<n;j++)
        {
            ll d=0;
            for(ll k=0;k<m;k++)
            {
                d+=pow(abs(arr[i][k]-arr[j][k]),2);
            }
            if(is_perfect(d))ans++;
        }
    }
    cout<<ans;
    return 0;
} 


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;

int segdata[(1<<18)-1];
void seginit(){
    rep(i,(1<<18)-1) segdata[i]=0;
}
void segupdate(int i,int x){
    i+=(1<<17)-1;
    segdata[i]=x;
    while(i>0){
        i=(i-1)/2;
        segdata[i]=segdata[i*2+1]+segdata[i*2+2];
    }
}
int segsum(int a,int b,int k,int l,int r){
    if(r<=a || b<=l) return 0;
    if(a<=l && r<=b) return segdata[k];
    else{
        int left=segsum(a,b,k*2+1,l,(l+r)/2);
        int right=segsum(a,b,k*2+2,(l+r)/2,r);
        return left+right;
    }
}

vector<bool> prime;
void primeinit(int N){
    if(N+1>prime.size()){
        prime.resize(N+1,true);
    } 
    prime[0] = false;
    prime[1] = false;
    for(int i=2; i*i<=N;i++) if(prime[i]) for(int j=2; i*j<=N;j++) prime[i*j]=false;
}
bool odd[100500];

int main(void){
    primeinit(100500);
    for(int i=1;i<100200;i+=2) if(prime[i] && prime[(i+1)/2]) odd[i]=true;
    seginit();
    rep(i,100200) segupdate(i+1,odd[i+1]);
    int Q;
    cin >> Q;
    int l[Q],r[Q];
    rep(i,Q) cin >> l[i] >> r[i];
    rep(i,Q) cout << segsum(l[i],r[i]+1,0,0,(1<<17)) << endl;
}

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

int main(){
  char c;
  cin >> c;
  
  if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o'){
    cout << "vowel" << endl;
  }
  else{
    cout << "consonant" << endl;
  }
}


Measured memory_bytes: 3576
// https://atcoder.jp/contests/dp/tasks/dp_b
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
#include <limits>
using namespace std;

#define FOR(i, n) for (int i = 0; i < n; i++)
#define EACH(i, n) for (auto &i: n)

int main() {
  int n, k;

  cin >> n >> k;

  vector<long long> h(n + k, 0);
  vector<long long> dp(n + k, numeric_limits<long long>::max());
  FOR(i, n) {
    cin >> h[i];
  }

  dp[0] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 1; j <= k; j++) {
      dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
    }
  }
  cout << dp[n - 1] << endl;

  return 0;
}


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

struct UnionFind{
    vector<int> Parent;
    vector<int> sizes;
    UnionFind(int n):Parent(n),sizes(n,1){ rep(i,n)Parent[i]=i; }
    //find the root of x
    int root(int x){
        if(x!=Parent[x]){
        Parent[x] = root(Parent[x]);
        }
        return Parent[x];
    }
    //merge x and y
    void unite(int x,int y){
        x = root(x);
        y = root(y);
        if(x == y) return;
        if(sizes[x] < sizes[y]) swap(x, y);
        Parent[y] = x;
        sizes[x] += sizes[y];
    }
    bool same(int x,int y){ return root(x) == root(y); }
    int size(int x){ return sizes[root(x)]; }
};

int main() {
	int N,M;
	cin>>N>>M;
	vector<int> a(M),b(M);
	rep(i,M){
		cin>>a[i]>>b[i];
		a[i]--;b[i]--;
	}
	int ans = 0;
	rep(i,M){
		UnionFind tree(N);
		rep(j,M){
			if(i!=j){
				if(!(tree.same(a[j],b[j]))){
					tree.unite(a[j],b[j]);
				}
			}
		}
		if(!(tree.same(a[i],b[i])))ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
#ifdef LOCAL
#define debug(x) cerr << #x << ": " << x << endl
#else
#define debug(x)
#endif
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

char C;
signed main(){
	cin >> C;
	cout << (char)(C+1) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;
using ll = long long;
using ii = pair<int, int>;

template<int V, class T = ll> class max_flow {
	static const T INF = numeric_limits<T>::max();
	struct edge {
		int t, rev;
		T cap, f;
	};
	vector<edge> adj[V];
	int dist[V];
	int ptr[V];
	bool bfs(int s, int t) {
		memset(dist, -1, sizeof dist);
		dist[s] = 0;
		queue<int> q({ s });
		while (!q.empty() && dist[t] == -1) {
			int n = q.front();
			q.pop();
			for (auto& e : adj[n]) {
				if (dist[e.t] == -1 && e.cap != e.f) {
					dist[e.t] = dist[n] + 1;
					q.push(e.t);
				}
			}
		}
		return dist[t] != -1;
	}
	T augment(int n, T amt, int t) {
		if (n == t) return amt;
		for (; ptr[n] < adj[n].size(); ptr[n]++) {
			edge& e = adj[n][ptr[n]];
			if (dist[e.t] == dist[n] + 1 && e.cap != e.f) {
				T flow = augment(e.t, min(amt, e.cap - e.f), t);
				if (flow != 0) {
					e.f += flow;
					adj[e.t][e.rev].f -= flow;
					return flow;
				}
			}
		}
		return 0;
	}
public:
	void add(int u, int v, T cap = 1, T rcap=0) {
		adj[u].push_back({ v, (int) adj[v].size(), cap, 0 });
		adj[v].push_back({ u, (int) adj[u].size() - 1, rcap, 0 });
	}
	T calc(int s, int t) {
		T flow = 0;
		while (bfs(s, t)) {
			memset(ptr, 0, sizeof ptr);
			while (T df = augment(s, INF, t)) flow += df;
		}
		return flow;
	}
	void clear() {
		for (int n = 0; n < V; n++) adj[n].clear();
	}
};

int a[101];

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

	int N;
	cin >> N;
	for (int i = 1; i <= N; ++i) cin >> a[i];

	max_flow<111, ll> MF;
	int S = 0, T = N + 1;
	ll ans = 0;
	for (int i = 1; i <= N; ++i) {
		if (a[i] <= 0) MF.add(S, i, -a[i]);
		else ans += a[i], MF.add(i, T, a[i]);
		for (int j = 2*i; j <= N; j += i) MF.add(i, j, 1e12);
	}
	cout << ans - MF.calc(S, T);
}

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

#define ll long long

signed main()
{
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int X = (a+d-1)/d;
  int Y = (c+b-1)/b;
  cout << ((X>=Y)? "Yes":"No");
}

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

int main()
{
	string n;
	cin >> n;
	int ans = 0;
	if (n.at(0) == '1')ans++;
	if (n.at(1)== '1')ans++;
	if (n.at(2) == '1')ans++;
	
	
	cout << ans << endl;


}


Measured memory_bytes: 3604
#include<iostream>

using namespace std;

const int MAX_N = 100000;

int N;
int cost[MAX_N+1];
int h[MAX_N+1];

void solve() {
    for (int i = 1; i <= N; i++) {
        if (i == 1) {
            cost[1] = 0;
        } else if (i == 2) {
            cost[2] = abs(h[2] - h[1]);
        } else {
            cost[i] = min(cost[i-1] + abs(h[i]-h[i-1]), cost[i-2] + abs(h[i]-h[i-2]));
        }
    }
    cout << cost[N] << endl;
}

int main() {
    cin >> N;
    for (int i = 1; i <= N; i++) {
        cin >> h[i];
    }
    solve();
}

Measured memory_bytes: 1024
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}
const ld gold = (1+sqrt(ld(5)))/2;


int main() {
    cout << fixed << setprecision(13);
    ios::sync_with_stdio(false);
    cin.tie(0);
    const int n = 6;
    vvi p(2, vi(n));
    rep(i, 2) rep(j, n) {
        cin >> p[i][j];
    }  

    auto func = [&](ld x) {
        ld res = 0;
        rep(i, n) {
            res += max(p[0][i]*x, p[1][i]*(1-x));
        }
        return res;
    };

    ld a, b, c;
    a = 0;
    c = 1;
    b = gold/(1+gold);
    rep(kjjhufibdjuh, 100) {
        ld x;
        if(c-b > b-a) {
            x = b+(c-b)/(1+gold);
            if(func(b) < func(x)) {
                c = x;
            } else {
                a = b;
                b = x;
            }
        } else {
            x = b-(b-a)/(1+gold);
            if(func(x) < func(b)) {
                c = b;
                b = x;
            } else {
                a = x;
            }
        }
    }

    cout << func(c)/100 << endl;
}

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

// Type alias
using ll=long long;
using ld=double;

using pi=pair<int,int>;
using pll=pair<ll,ll>;
using pld=pair<ld,ld>;
using ti3=tuple<int, int, int>;

using vi=vector<int>;
using vll=vector<ll>;
using vld=vector<ld>;
using vpi=vector<pi>;
using vpll=vector<ll>;
using vpld=vector<ld>;
using vti3=vector<ti3>;

// Constants
const double EPS = 1e-9;
const int inf = numeric_limits<int>::max() / 2;
const ll mod = 1e9+7;

// Macro
#define rep(i,n) for(int i=0;i<int(n);++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;--i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(i,a,b) for(int i=int(b-1);i>=int(a);--i)
#define SHOW(a) cout << #a << " = " << a << endl
#define ARR(a,n) for(int i=0;i<int(n);++i) cout << #a << "[" << i << "]" << " = " << a[i] << endl

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

// Funtcions
ll pow(ll base, ll i, ll mod){
  ll a = 1;
  while(i){
    if (i & 1) {
      a *= base;
      a %= mod;
    }
    base *= base;
    base %= mod;
    i >>= 1;
  }
  return a;
}
ll gcd(ll a, ll b){
  while(b){
    ll c = a % b;
    a = b;
    b = c;
  }
  return a;
}
ll lcm(ll a, ll b){
  return a / gcd(a, b) * b;
}
template<typename T> bool chmin(T& a, const T& b) {
  if (a > b) return a = b, true; else return false;
}

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


void solve(){
  int N;
  cin >> N;

  vector<pi> A;
  rep(i, N){
    int a, b;
    cin >> a >> b;
    A.emplace_back(make_pair(a, b));
  }

  sort(ALL(A), [](pi l, pi r){return l.second < r.second;});

  ll time = 0;
  for(auto e : A){
    time += e.first;
    if(time > e.second){
      cout << "No" << endl;
      return;
    }
  }

  cout << "Yes" << endl;
}

int main(){
// FastIO
//ios_base::sync_with_stdio(false);
cin.tie(NULL);
  solve();
  return 0;
}

Measured memory_bytes: 2420
#include<iostream>
#include<cstdio>
#include<algorithm>
#define mod 1000000007
using namespace std;
int dp[310][310][310];
struct xxx{int l,r,x;}q[310];
bool cmp(xxx a,xxx b){return a.r<b.r;}
int main()
{
	int n,m;scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)scanf("%d%d%d",&q[i].l,&q[i].r,&q[i].x);
	sort(q+1,q+m+1,cmp);
	int j=1;
	dp[0][0][1]=3;
	for(int i=1;i<=n;i++)
	{
		int kkk;
		for(int b=0;b<i;b++)
		{
			for(int a=0;a<max(b,1);a++)
			{
				int k=j;
				while(j<=m&&q[j].r==i)
				{
					int ok=0;
					if(q[j].l<=a)ok++;
					if(q[j].l<=b)ok++;
					if(q[j].l<=i)ok++;
					if(ok!=q[j].x)dp[a][b][i]=0;
					j++;
				}
				kkk=j;j=k;
				dp[a][b][i+1]=(dp[a][b][i+1]+dp[a][b][i])%mod;
				dp[a][i][i+1]=(dp[a][i][i+1]+dp[a][b][i])%mod;
				dp[b][i][i+1]=(dp[b][i][i+1]+dp[a][b][i])%mod;	
			}
		}
		j=kkk;
	}
	int ans=0;
	for(int b=0;b<n;b++)for(int a=0;a<max(b,1);a++)ans=(ans+dp[a][b][n])%mod;
	printf("%d",ans);return 0;
}

Measured memory_bytes: 112768
#include<iostream>
using namespace std;
int n,m;
char jz[105][105];
int count;
int xx[]={1,0,-1,0};
int yy[]={0,1,0,-1};
void dfs(int x,int y,char ttemp)
{
    int i,j,tx,ty;
    jz[x][y]='.';
    for(i=0;i<4;i++)
    {
        tx=x+xx[i];
        ty=y+yy[i];
        if(jz[tx][ty]!=ttemp||tx<0||ty<0||tx>=n||ty>=m)continue;
        dfs(tx,ty,ttemp);
    }
}
int main()
{
    while(cin>>n>>m&&n&&m)
    {
        int i,j;
        count=0;
        for(i=0;i<n;i++)
        {
            for(j=0;j<m;j++)
            cin>>jz[i][j];
        }
        for(i=0;i<n;i++)
        {
            for(j=0;j<m;j++)
            {
                if(jz[i][j]!='.')
                {
                    dfs(i,j,jz[i][j]);
                    count++;
                }
            }
        }
        cout<<count<<endl;
    }
    return 0;
}

Measured memory_bytes: 3548
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int a, b, c;
    int count = 0;
    scanf("%d %d %d", &a, &b, &c);
    
    //評価
    for (int i=a; a<=i && i<=b; i++) {
        if (c%i == 0) {
            count++;
        }
    }
    printf("%d\n", count);
    
    return 0;
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef long long ll;
typedef vector<pii> vpii;
#define reps(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define all(g) (g).begin(),(g).end()
#define pb push_back
const int mod = 1e9 + 7;
#define INF 1<<25
/*
input case
output case
*/


ll mo=1000000007;
ll dp[5050][5050];
int N,L;
string S;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> S;
    string s;
    L = S.size();

    dp[0][0]=1;
    rep(i,N) rep(x,N+1) if(dp[i][x]) {
        (dp[i+1][x+1] += 2*dp[i][x])%=mo;
        (dp[i+1][max(0,x-1)] += dp[i][x])%=mo;
    }

    ll ret=dp[N][L];
    rep(i,L) ret=ret*(mo+1)/2%mo;
    cout<<ret<<endl;

}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template<typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template<typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template<typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template<typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

void solve() {
  vi32 cnt(9);
  int N; cin >> N;
  rep(i, N) {
    int a; cin >> a;
    cnt[min(a / 400, 8)]++;
  }
  int ans = 0;
  rep(i, 8) if (cnt[i] > 0) ans++;
  if (ans == 0) {
    cout << 1 << " " << cnt[8] << '\n';
  } else {
    cout << ans << " " << ans + cnt[8] << '\n';
  }
}


Measured memory_bytes: 256