akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;

int compare(const void *a,const void *b){
    return *(int*)a-*(int*)b;
}

int main(){
    int n;
    cin>>n;
    int d[n];
    for(int i=0;i<n;i++) cin>>d[i];
    qsort(d,n,sizeof(int),compare);

    int sum=d[n/2]-d[(n-1)/2];
    cout<<sum<<endl;
}

Measured memory_bytes: 1020
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <list>
#include <cstring>
   
using namespace std;

int main()
{
    int n;
    while(1){
        cin >> n;
        if(n == 0) break;
        long long int satisfaction[101], datetime[101];
        for(int i = 0; i < n; i++){
            int m;
            cin >> m >> satisfaction[i];
            long long int dt = 0;
            for(int j = 0; j < m; j++){
                int s, e;
                cin >> s >> e;
                s -= 6;
                e -= 6;
                for(int k = s; k < e; k++){
                    dt |= (1 << k);
                }  
            }
            datetime[i] = dt;
        }
        vector<long long int> result(1 << 16, -1);
        result[0] = 0;
        long long int ans = 0;
        for(int i = 0; i < (1 << 16); i++){
            // 1????????£???????????????????????§???????????£?????????
            if(result[i] == -1) continue;
            ans = max(ans, result[i]);
            for(int j = 0; j < n; j++){
                // ?¬????j??????????????¨????????????????????¨??????
                if((i & datetime[j]) != 0) continue;
                // cout <<"po" << endl;
                result[i | datetime[j]] = max(result[i | datetime[j]], result[i] + satisfaction[j]);
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1712
using System;
namespace csharptest
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] h = new int[100000];
            int[] w = new int[100000];
            int count;
            string[] str = Console.ReadLine().Split(' ');
            for (count = 0; str[0] != "0" && str[1] != "0"; count++)
            {
                h[count] = int.Parse(str[0]);
                w[count] = int.Parse(str[1]);
                str = Console.ReadLine().Split(' ');
            }
            for (int n = 0; n < count; n++)
            {
                for (int H = 0; H < h[n]; H++)
                {
                    for (int W = 0; W < w[n]; W++)
                    {
                        Console.Write("#");
                    }
                    Console.WriteLine();
                }
                Console.WriteLine();
            }
        }
    }
}

Measured memory_bytes: 6072
n,T=map(int,input().split())
t=[int(i) for i in input().split()]
t =[0]+t
time=t[-1]
for a in range(1,n+1):
    if t[a]-t[a-1]>T:
        time-=(t[a]-t[a-1])-T
print(time+T)

Measured memory_bytes: 25196
#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
#include <cmath>
#include <queue>
using namespace std;
#define mod (long)(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr start, itr goal){ for(auto i = start; i != goal; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<long> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } long C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

int main(){
    long A, B;
    cin >> A >> B;
    long ans = 0;
    B++;
    int i = 0;
    ans |= (1 << i) * ((B / 2 + A / 2) % 2);
    i++;
    for(; i < 60; i++){
        ans |= (1l << i) * ((max(0l, B % (2l << i) - (1l << i)) + max(0l, A % (2l << i) - (1l << i))) % 2);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	int n,x,a,b,c,ret;
	
	for(;;){
		scanf("%d %d",&n,&x);
		if(n==0&&x==0)break;
		
		ret = 0;
		for(c=1;c<=n;++c){
			for(b=1;b<c;++b){
				a=x-c-b;
				if(a<b&&a>0){
					ret++;
				}
			}
		}
		printf("%d\n",ret);
		
		}
		return 0;
	}	

Measured memory_bytes: 600
a, b = (int(x) for x in input().split())
ans=0
if a==b:
  for i in range(a):
    ans+=a*pow(10,i)
elif a>b:
  for i in range(a):
    ans+=b*pow(10,i)
else:
  for i in range(b):
    ans+=a*pow(10,i)
print(ans)

Measured memory_bytes: 9172
#include<bits/stdc++.h>
#include <unistd.h>
using namespace std;
#define nl cout<<"\n"
#define pb push_back
#define se second
#define fi first
#define pi =3.14159265358979323846264338327950L;
typedef long long int ll;


int main(){
	ios_base :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//freopen("input.txt", "r", stdin); 
    //freopen("output.txt", "w", stdout);
	int n,k;
	cin>>n>>k;
	int ar[n];
	for(int i=0;i<n;i++) cin>>ar[i];
	vector<int> dp(n,INT_MAX);
	dp[0]=0;
	for(int i=1;i<n;i++){
		for(int j=1;j<=k;j++){
			if(i-j>=0){ 
				dp[i]=min(dp[i],abs(ar[i]-ar[i-j])+dp[i-j]);
			}
		}
	}
	cout<<dp[n-1];
    return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl
int main() {
  int n, m;
  cin >> n >> m;
  unordered_map<int, int> mp;
  rep(i, n) mp[i] = -1;
  rep(i, m) {
    int s, c;
    cin >> s >> c;
    s = n - s;
    if(mp[s] != -1 && mp[s] != c) {
      cout << "-1" << endl;
      return 0;
    }
    mp[s] = c;
  }

  int x = 0;
  int b = 1;
  for(int keta = 0; keta < n; keta++) {
    int c = mp[keta];
    if(c == -1) {
      if(keta != 0 && keta == n - 1)
        c = 1;
      else
        c = 0;
    }
    x += c * b;
    b *= 10;
  }

  int y = 0;
  b = 1;
  for(int keta = 0; keta < n; keta++) {
    y += 9 * b;
    b *= 10;
  }
  if(x > y) {
    cout << "-1" << endl;
    return 0;
  }

  int z = 1;
  for(int keta = 0; keta < n - 1; keta++) z *= 10;
  if(n == 1) z = -1;

  if(x < z) {
    cout << "-1" << endl;
    return 0;
  }

  cout << x << endl;
  return 0;
}


Measured memory_bytes: 384
/*                                  /   \                                                                   (Hello)//JSM//*/      
/*                                 /*****\                                                                              */
/*     Jai Shree Mataji           /       \ |\| |_| $ |-| K                                                            */
#include<vector>
#include<iostream>
#include<algorithm>                
#include<string.h>                 
#include<bits/stdc++.h>            
#include<cstring>                  
#include<map>                     
#include<cmath>                  
#include<set>
using namespace std;            
#define ll long long int        
#define ld long double
#define MOD 1000000007 
#define PI 3.1415926535897932384626433832795                                               
#define YY cout<<"YES"
#define NN cout<<"NO"
#define Yy cout<<"Yes"
#define Nn cout<<"No"
#define yy cout<<"yes"
#define nn cout<<"no"
#define EE cout<<"\n"
#define ee cout<<"\n"
#define ne cout<<"-1"
#define pb push_back 
#define fi first
#define se second
#define mkp make_pair    
#define mkt make_tuple
#define sall(v ) sort(v.begin(), v.end())      
#define all(v )  v.begin(), v.end()      
#define fo(i , n) for(ll i = 0 ; i < n ; i++)
#define vl vector<ll>
#define vc vector<char> 
#define vll vector< pair<ll,ll> > 
#define mps map<string ,ll>
#define mpc map<char ,ll>
#define mpl map<ll, ll>
#define pr pair<ll,ll>
ll pd(ll x,ll y){if(x%y==0) return x/y;else return x/y+1;}
ll pow1(ll n,ll p){if(p==0)return 1;ll x=pow1(n, p/2);x=(x%MOD*x%MOD)%MOD;if(p%2==0) return x;else return (x*n)%MOD;}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);	
	  ll tt=1;

//	   cin>>tt;
	      while(tt--)
{
ll a,b,c;
cin>>a>>b>>c;
if(a<=b*c)
cout<<"Yes";
else
cout<<"No";
ee;
	
	
}
return 0;
}



Measured memory_bytes: 3608
import Data.Maybe

solve :: [String] -> Maybe Int
solve [_,"?",_] = Nothing
solve [x,"+",y] = Just (read x + read y)
solve [x,"-",y] = Just (read x - read y)
solve [x,"*",y] = Just (read x * read y)
solve [x,"/",y] = Just (read x `div` read y)

main :: IO ()
main  = getContents
    >>= return . map words . lines
    >>= return . map solve
    >>= return . map fromJust . takeWhile (/= Nothing)
    >>= mapM_ print

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

#define fi first
#define se second

const long long MOD = 1e9 + 7;
const int N = 4100;
long long dp[N][N], f[2*N], inv[2*N], n;
long long ans;
pair<int,int> a[1<<18];

long long pow(long long x, long long p) {
    long long ans = 1;
    for (;p;p>>=1) { if (p&1) ans = ans*x%MOD; x = x*x%MOD; }
    return ans;
}

long long C (int a, int b) { return f[a] * inv[b] % MOD * inv[a-b] % MOD; }

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i].fi >> a[i].se;
        dp[2001-a[i].fi][2001-a[i].se]++;
    }
    f[0] = 1;
    for (int i = 1; i <= 2*N; i++) f[i] = f[i-1] * i % MOD, inv[i] = pow(f[i],MOD-2);
    for (int i = 1; i < N; i++) for (int j = 1; j < N; j++)
        dp[i][j] = (dp[i][j] + dp[i-1][j] + dp[i][j-1]) % MOD;

    for (int i = 0; i < n; i++) {
        ans = (MOD + ans + dp[2001+a[i].fi][2001+a[i].se] - C(2*(a[i].fi+a[i].se),2*a[i].fi)) % MOD;
    }
    cout << (ans * 500000004) % MOD;
}


Measured memory_bytes: 133248
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if(a + b >= c){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
        
    }
}


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


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


    int n;
    cin >> n;

    int res[4] = {0, 0, 0, 0};

    vector<string> s;
    rep(i, n) {
        string buf;
        cin >> buf;

        if (buf == "AC") res[0]++;
        if (buf == "WA") res[1]++;
        if (buf == "TLE") res[2]++;
        if (buf == "RE") res[3]++;
    }

    cout << "AC x " << res[0] << endl;
    cout << "WA x " << res[1] << endl;
    cout << "TLE x " << res[2] << endl;
    cout << "RE x " << res[3] << endl;


    return 0;
}



Measured memory_bytes: 3656
n = int(input())
a = [int(i) for i in input().split()]
x = max(a)
a.remove(x)
ans = float("INF")
for i in range(n-1):
  if abs(ans - x/2) > abs(a[i] - x/2):
    ans = a[i]
print(x, ans)

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

typedef long long ll;

int main() {
	ios::sync_with_stdio(0);
	
	vector<int> a(3);
	int ans = 0;
	cin >> a[0] >> a[1] >> a[2];
	while (a[0] != a[1] || a[1] != a[2] || a[0] != a[2]) {
		sort(a.begin(), a.end());
		ans++;
		if (a[0] != a[1]) {
			a[0] += 2;
		} else {
			a[0]++;
			a[1]++;
		}
	} 
	cout << ans;
	
	return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int k, x;
  cin >> k >> x;
  
  if(500 * k >= x) {
    cout << "Yes" << endl;
  }else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
let () =
  let rec print_tbl tbl = function
    | 'a'..'z' as c ->
      Printf.printf "%c : %d\n"
        c (if Hashtbl.mem tbl c then Hashtbl.find tbl c else 0);
      print_tbl tbl (Char.code c |> (+) 1 |> Char.chr)
    | _ -> ()
  in
  let buf = Buffer.create 1024 in
  try
    while true do
      Buffer.add_string buf (read_line ());
    done
  with End_of_file ->
    let chars = Buffer.contents buf in
    let rec loop tbl = function
      | -1 -> tbl
      | i ->  match chars.[i] with
        | 'a'..'z' | 'A'..'Z' as c ->
          let lc = Char.lowercase c in
          Hashtbl.replace tbl lc
            (if Hashtbl.mem tbl lc then Hashtbl.find tbl lc |> (+) 1 else 1);
          loop tbl (i-1)
        | _ -> loop tbl (i-1)
    in
    let tbl = loop (Hashtbl.create 32) ((String.length chars) - 1) in
    print_tbl tbl 'a'

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

int main(){
  int R; cin>>R;
  if(R<1200){
    cout<<"ABC"<<endl;
  }
  else if(1200<=R && R<2800){
    cout<<"ARC"<<endl;
  }
  else {
    cout<<"AGC"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		Scanner scanner = new Scanner(System.in);
	    int n = scanner.nextInt();
	    
	    long []  arr = new long[n];
	    for(int i = 0; i < n; i++){
	    	arr[i] = scanner.nextLong();
	    }
	    
	    long res = 0;
	    for(int i = 1; i < n ; i++){
	    	if(arr[i] < arr[i-1]){
	    		res += arr[i-1] - arr[i];
	    		arr[i] += arr[i-1] - arr[i]; 
	    	}
	    }
	    
	    System.out.println(res);
	}
}

Measured memory_bytes: 62780
#include <bits/stdc++.h>
#define max 300000

using namespace std;

struct stak{
	int st[max];
	int now;
};

void init(stak *s){
	s->now = 0;
}
void push (stak *s, int a){
	s->st[s->now] = a;
	s->now++;
}
int pop(stak* s){
	int ans;
	if(s->now == 0){
		return -1;
	}
	s->now--;
	ans = s->st[s->now];
	return ans;
}

int main(void)
{
	string s; cin>>s;
	int len = s.size();
	stak w;
	init(&w);
	for(int i = 0; i < len; i++){
		if(s[i] == 'S'){
			push(&w,7);
			//cout<<"push S"<<endl;
		}
		else if(s[i] == 'T'){
			if(w.st[w.now-1] == 7){
				int a = pop(&w);
				//cout<<pop<<endl;
			}
			else{
				//cout<<"push T"<<endl;
				push(&w,5);
			}
		}
		//cout<<"i = "<<i<<", w.now = "<<w.now<<endl;
	}
	/*
	cout<<"\n"<<endl;
	for(int i = 0; i < w.now; i++){
		cout<<"i = "<<i<<", w.st[i] = "<<w.st[i]<<endl;
	}
	*/
	cout<<w.now<<endl;
	return 0;
}



Measured memory_bytes: 1412
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second
#define INF (int)1e9+1
#define INFLL (int)1e18+1
#define sz(bb) (int)bb.size()
#define all(qq) qq.begin(), qq.end() 
#define Max(a, b, c) max(a, max(b, c))
#define Min(a, b, c) min(a, min(b, c))
const double PI=acos(-1);
// #define int unsigned long long int//used when x<=2^64-1 && x>0
#define int long long//used when x<=2^63-1
//bool cmp if returns true it keeps 1st as first else swaps
typedef long long  ll;


void multiply(int **a, int **b, int n)
{
    int lol[n][n];
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            lol[i][j]=0;
            for(int k=0;k<n;k++)
            {
                lol[i][j]=lol[i][j]+(a[i][k]*b[k][j])%mod;
                lol[i][j]%=mod;
            }
        }
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            a[i][j]=lol[i][j];
        }
    }
}
void solve()
{
    int n, k;
    cin>>n>>k;
    int **arr=(int**)malloc(n*sizeof(int));
    int **ans=(int**)malloc(n*sizeof(int));
    for(int i=0;i<n;i++)
    {
        ans[i]=(int*)malloc(n*sizeof(int));
        arr[i]=(int*)malloc(n*sizeof(int));
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(i==j)
                ans[i][j]=1;
            else
                ans[i][j]=0;
        }
    }
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            cin>>arr[i][j];
    while(k)
    {
        if(k&1)
            multiply(ans, arr, n);
        multiply(arr, arr, n);
        k/=2;
    }
    int lol=0;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            lol=lol+ans[i][j];
            lol%=mod;
        }
    }
    cout<<lol<<"\n";
}
int32_t main()
{
    IOS;
    int t;
    // cin>>t;
    t=1;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3700
import java.io.*
import java.util.*
import java.lang.*
import java.lang.Math.*


fun solve() {
    val (X, K, D) = rd.readLongArray()

    var ans = 0L
    if (abs(X)/D >= K) {
        ans = abs(X) - D*K
    } else {
        val mv = abs(X)/D
        val pos = X%D
        val rest = K - mv
        ans = if (rest%2L == 0L) abs(pos) else D - abs(pos)
    }

    println(ans)
}


//val rd = debug.Reader("abc", "175", "c", "sample-1")
val rd = Reader()


fun main(args: Array<String>) {
    try {
        var exception: Throwable? = null
        val sth = Thread(null, SolveThread(), "solveThread", 128 * 1024 * 1024)
        sth.setUncaughtExceptionHandler { _, e -> exception = e }
        sth.start(); sth.join()
        if (exception != null) throw exception!!
    } catch (e: Exception) { throw e }
}
const val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2
const val EPS = 1e-9; fun DBLEQ(a: Double, b: Double): Boolean {return abs(a - b) < EPS}
data class IntPair(val first: Int, val second: Int)
data class To(val idx: Int, val cost: Long)
typealias ALI = ArrayList<Int>
fun <T>edge(V: Int): Array<ArrayList<T>> { return Array(V){ArrayList<T>()} }
val errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }
fun rAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("EAssert Error: $msg"); throw Error(msg) }
}
fun tAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("TAssert Error: $msg"); Thread.sleep(3000) }
}
class SolveThread : Runnable {
    override fun run() { solve() }
}
class Reader {
    private val br = BufferedReader(InputStreamReader(System.`in`))
    val readString: () -> String = { br.readLine() }
    val readInt: () -> Int = { br.readLine().toInt() }
    val readLong: () -> Long = { br.readLine().toLong() }
    val readIntArray: () -> IntArray = { br.readLine().split(' ').map { it.toInt() }.toIntArray() }
    val readLongArray: () -> LongArray = { br.readLine().split(' ').map { it.toLong() }.toLongArray() }
    val readListInt: () -> List<Int> = { br.readLine().split(' ').map { it.toInt() } }
    val readListLong: () -> List<Long> = { br.readLine().split(' ').map { it.toLong() } }
}


Measured memory_bytes: 36724
Class Main
    Public Shared Sub Main()
        Dim N As Integer
        Dim K As Integer
        Dim arr() As String
        arr = Split(Console.ReadLine())
        N = arr(0) : K = arr(1)
        Dim cnt As Integer = 1
        While K ^ cnt <= N
            cnt += 1
        End While
        Console.WriteLine(cnt)
    End Sub
End Class


Measured memory_bytes: 13532
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        int[] h = new int[n];
        String line = br.readLine();
        String[] parts = line.split(" ");
        for(int i = 0; i < n; i++) {
            h[i] = Integer.parseInt(parts[i]);
        }
        int[] dp = new int[n];
        Arrays.fill(dp, Integer.MAX_VALUE);
        dp[0] = 0;
        dp[1] = Math.abs(h[1] - h[0]);
        for(int i = 2; i < n; i++) {
            for(int j = 1; j <= 2; j++) {
                dp[i] = Math.min(dp[i], dp[i - j] + Math.abs(h[i] - h[i - j]));
            }
        }
        System.out.println(dp[n - 1]);
    }
}


Measured memory_bytes: 34184
#include <iostream>
#include <assert.h>
#include <vector>
#include <unordered_map>
#include <queue>
#include <climits>
using namespace std;
constexpr int64_t MOD = 1000000007;

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

  int32_t N;
  cin >> N;
  vector<pair<string, int>> play_list;
  for (int i = 0; i < N; i++) {
    string s;
    int t;
    cin >> s;
    cin >> t;
    play_list.push_back(make_pair(s,t));
  }
  string X;
  cin >> X;
  
  int sleep_time = 0;
  bool sleep = false;
  for (int i = 0; i < N; i++) {
    if (sleep == true) {
      sleep_time += play_list[i].second;
    } else if (play_list[i].first == X) {
      sleep = true;
    }
  }
  cout << sleep_time << endl;


  return 0;
}


Measured memory_bytes: 256
inline = list(map(int,input().split()))
sx = inline[0]
sy = inline[1]
tx = inline[2]
ty = inline[3]

h = sy-ty
w = sx-tx

for i in range(abs(h)):
    if h > 0:
        print("D",end = "")
    else:
        print("U",end="")

for i in range(abs(w)):
    if w > 0:
        print("L",end = "")
    else:
        print("R",end="")

for i in range(abs(h)):
    if h < 0:
        print("D",end = "")
    else:
        print("U",end="")

for i in range(abs(w)):
    if w < 0:
        print("L",end = "")
    else:
        print("R",end="")

if h>0:
    print("U",end="")
else:
    print("D",end="")

for i in range(abs(w)+1):
    if w > 0:
        print("L",end = "")
    else:
        print("R",end="")
for i in range(abs(h)+1):
    if h > 0:
        print("D",end = "")
    else:
        print("U",end="")

if w>0:
    print("R",end="")
else:
    print("L",end="")

if h<0:
    print("U",end="")
else:
    print("D",end="")

for i in range(abs(w)+1):
    if w < 0:
        print("L",end = "")
    else:
        print("R",end="")
for i in range(abs(h)+1):
    if h < 0:
        print("D",end = "")
    else:
        print("U",end="")

if w<0:
    print("R")
else:
    print("L")

Measured memory_bytes: 4596
using System;
public class OCP {
    public static void Main() {
        string[] read = new string[2];
        read = Console.ReadLine().Split(' ');
        int A = int.Parse(read[0]);
        int B = int.Parse(read[1]);
        if (A == B) {
            Console.WriteLine("Draw");
        } else if (A > B) {
            if (B == 1) {
                Console.WriteLine("Bob");
            } else {
                Console.WriteLine("Alice");
            }
        } else {
            if (A == 1) {
                Console.WriteLine("Alice");
            } else {
                Console.WriteLine("Bob");
            }
        }
    }
}

Measured memory_bytes: 13140
#include <stdio.h>
#include <algorithm>
using namespace std;

int N;

int main()
{
	scanf ("%d", &N);
	long long ans = 0;
	for (int i = 1; i <= N; i++) ans += 1ll * i * (N - i + 1);
	for (int i = 1; i < N; i++){
		int x, y; scanf ("%d %d", &x, &y);
		if (x > y) swap(x, y);
		ans -= 1ll * x * (N - y + 1);
	}
	printf ("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;
#define reverse(s) reverse(s.begin(),s.end())


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

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

int main(){
    int n;
    cin >> n;
    pair<int,int> usagi[n];

    rep(i,n){
        int a;  cin >> a;
        a--;
        usagi[i] = make_pair(i,a);
    }

    int ans(0);
    rep(i,n){
        int t = usagi[i].second;
        if(usagi[t].second == i){
            ans++;
            usagi[t].second = -1;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4328
/**So..a**/
#include<bits/stdc++.h>
//#include <chrono>
// Success after trying 5 hour 11 minute :(


using namespace std;
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define PB(x, v) x.push_back(v);
#define M_P(a, b) make_pair(a, b)
#define pll pair<ll, ll>
#define ll long long
#define mll map<ll, ll>
#define vl vector<ll>
#define fa(x, v) for(auto x: v)
#define fr(i, a, b) for(ll i= a;i <=b; i++)
#define TEST  int test; cin >> test; while(test--)
#define FTEST int TesT; cin >> TesT; for(int test = 1; test<=TesT; test++)

#define B_ begin()
#define E_ end()
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define NL_ "\n"
#define F first
#define S second
#define FF first.first
#define FS first.second
#define SF second.first
#define SS second.second

#define MOD 1000000007
#define  ull unsigned long long

ll cnt[2000+10];
bool ch[2000+10];
ll n;
ll make(ll n)
{
    if(n<3) return 0;

    ll sum = 0;
    if(ch[n]) return cnt[n];
        for(ll i = 3; i+3<=n; i++)
          sum+= make(n-i), sum%=MOD;
     ch[n] = 1;
     cnt[n] += sum;
     cnt[n]%=MOD;
     return cnt[n];
}
int main()
{
    memset(ch, 0, sizeof(ch));
    scanf("%lld", &n);
    cnt[1] = cnt[2] = 0;
    fr(i, 3 , n) cnt[i] = 1;
    make(n);
    printf("%lld", cnt[n]);

    return 0;
}


Measured memory_bytes: 3804
import collections

n = int(input())
vs = list(map(int, input().split()))

counter_e = collections.Counter()
counter_o = collections.Counter()
for i, v in enumerate(vs):
    if i % 2 == 0:
        counter_e[v] += 1
    else:
        counter_o[v] += 1
key_e, max_e = sorted(counter_e.items(), key=lambda x: (x[1], -x[0]))[-1]
key_o, max_o = sorted(counter_o.items(), key=lambda x: (x[1], x[0]))[-1]
if key_e != key_o:
    print(n - max_e - max_o)
elif len(counter_e.keys()) == 1 and len(counter_o.keys()) == 1:
    print(n // 2)
elif len(counter_e.keys()) == 1:
    key_o2, max_o2 = sorted(counter_o.items(), key=lambda x: (x[1], x[0]))[-2]
    print(n - max_e - max_o2)
elif len(counter_e.keys()) == 2 and len(counter_o.keys()) == 1:
    key_e2, max_e2 = sorted(counter_e.items(), key=lambda x: (x[1], -x[0]))[-2]
    print(n - max_e2 - max_o)
else:
    key_e2, max_e2 = sorted(counter_e.items(), key=lambda x: (x[1], -x[0]))[-2]
    key_o2, max_o2 = sorted(counter_o.items(), key=lambda x: (x[1], x[0]))[-2]
    print(min(n - max_e - max_o2, n - max_e2 - max_o))

Measured memory_bytes: 22300
import sys
sys.setrecursionlimit(10 ** 7)
read = sys.stdin.buffer.read 
input = sys.stdin.buffer.readline
def inputS(): return input().rstrip().decode()
readlines = sys.stdin.buffer.readlines  

A, B, K = map(int, input().split())

if K <= A:
  A -= K
  print(A, B)
elif K <= (A+B):  
  B -= (K-A)
  print(0, B)
else: # (A+B) < K
  print(0, 0)  
  

Measured memory_bytes: 3060
#include <stdio.h>
#include <math.h>

/**
 * 右と左を入れ替える関数。
 */
void swap_right_left( int *a, int *b ){
    int temp = 0;
    
    temp = *a;
    *a = *b;
    *b = temp;
}

/**
 * クイックソートする関数。
 */
int quick_sort( int sum[], int left, int right){
    int result = 0;
    int pivot;
    int Left, Right;

    Left = left, Right = right;

    // 基準値を設ける
    pivot = sum[( right + left ) / 2 ];

    while( 1 ){
        // 左から参照（中央値より小さい間は要素数をインクリメント）
        while( sum[Left] < pivot ){
            Left++;
        }

        // 右から参照（中央値より大きい間は要素数をデクリメント）
        while( pivot < sum[Right] ){
            Right--;
        }


        // 左と右のカーソルが重なったらループを抜ける
        if( Left >= Right ){
            break;
        }

        // rightとleftを入れ替え
        swap_right_left( &sum[Left], &sum[Right] );
        Right--;
        Left++;
    }
    // 左のグループを対象にクイックソートを再帰
    if( left < Left - 1 ){
        quick_sort( sum, left, ( Left - 1 ) );
    }

    if( Right + 1 < right ){
        quick_sort( sum, (Right + 1), right );
    }

    // 処理終了
    result = 1;

    return result;
}

int main(void){
    // 変数宣言
    int n;
    int x[100];
    int sum[100];   // 消費体力の総和がpパターンごとに格納される
    int i, j;
    int p = 100;    // パターン
    int result = 0;
    
    // 入力
    scanf("%d", &n);

    for( i = 0 ; i < n ; i++ ){
        scanf( "%d", &x[i] );
    }

    //初期化
    for( i = 0 ; i < p ; i++ ){
        sum[i] = 0;
    }

    // 消費体力の総和をpパターン毎に格納
    for( j = 0 ; j < p ; j++ ){
        for( i = 0; i < n ; i++ ){
            sum[j] += pow( x[i] - j , 2.0 ); 
        }
    }

    // 最小値を出す
    result = quick_sort( sum, 0, (p - 1) );

    // 出力
    printf( "%d", sum[0] );
    
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include <list>
#include<stack>
#include<queue>
#include <vector>
#include <set>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include <functional>

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define ll long long
#define CLR(a) memset((a),0,sizeof(a))
#define SZ(x) (int((x).size()))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl
using namespace std;

const ll MOD = 1000000007;// 10^9+7
const int INF = (1 << 30);


//変数
ll N, A, B;
vector<ll> ans_;





//サブ関数
//入力
void input()
{
	cin >> N >> A >> B;
}

bool can(ll N, ll A, ll B) {
	if (A + B <= N + 1 && A*B >= N)return true;
	else return false;
}

//計算
void calc()
{
	if (!can(N, A, B)) {
		cout << "-1" << endl;
	}
	else if (min(A, B) == 1) {
		if (B == 1) {
			REP(i, N)cout << i + 1 << " ";
		}
		else {
			REP(i, N)cout << N - i << " ";
		}
		cout << endl;
	}
	else {
		vector<ll> res(A + 1, B);
		res[0] = 0;
		ll sum = A * B;
		ll i = A + 1;

		while (sum > N) {
			i--;
			res[i] = 1;
			sum -= B - 1;
		}
		while (sum < N) {
			res[i]++;
			sum++;
		}
		REP(i, A)res[i + 1] += res[i];
		REP(i, A)for (ll j = res[i + 1]; j > res[i]; j--) {
			cout << j << " ";
		}
		cout << endl;
	}
}

//デバッグ
void debug()
{
	int N;
	cin>>N;
}


//メイン関数
int main()
{
	input();
	calc();
	debug();
	
	return 0;
}


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

const int INF = 10000000;

template <typename T>
struct Edge
{
    int to;
    T cap;
    int rev;
};

template <typename T>
struct Flow
{
    int n, c;
    vector<vector<Edge<T>>> g;
    vector<int> ch;
    
    Flow(int n) : n(n), c(1){
        g.resize(n);
        ch.resize(n);
    }
    
    void add_edge(int from, int to, T cap){
        g[from].push_back((Edge<T>){to, cap, (int)g[to].size()});
        g[to].push_back((Edge<T>){from, 0, (int)g[from].size() - 1});
    }
    
    T dfs(int u, T f, int t){
        if(u == t) return f;
        ch[u] = c;
        for(int i = 0; i < (int)g[u].size(); i++){
            Edge<T> &e = g[u][i];
            int v = e.to;
            if(e.cap > 0 && ch[v] != c){
                T fl = dfs(v, min(f, e.cap), t);
                if(fl > 0){
                    e.cap -= fl;
                    g[v][e.rev].cap += fl;
                    return fl;
                }
            }
        }
        return 0;
    }
    
    T max_flow(int s, int t){
        T res = 0;
        for(T f; (f = dfs(s, INF, t)) > 0; c++) res += f;
        return res;
    }
};

int main()
{
    int h, w;
    cin >> h >> w;
    string a[102];
    for(int i = 0; i < h; i++) cin >> a[i];
    Flow<int> g(h * w * 2);
    int s, t;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(a[i][j] == '.') continue;
            if(a[i][j] == 'T'){
                t = i * w + j;
                continue;
            }
            for(int x = 0; x < h; x++){
                if(x != i && a[x][j] != '.' && a[x][j] != 'S') g.add_edge(i * w + j + h * w, x * w + j, 1);
            }
            for(int y = 0; y < w; y++){
                if(y != j && a[i][y] != '.' && a[i][y] != 'S') g.add_edge(i * w + j + h * w, i * w + y, 1);
            }
            if(a[i][j] == 'S'){
                s = i * w + j + h * w;
                continue;
            }
            g.add_edge(i * w + j, i * w + j + h * w, 1);
        }
    }
    if((s - h * w) / w == t / w || (s - h * w) % w == t % w) cout << -1 << endl;
    else cout << g.max_flow(s, t) << endl;
}

Measured memory_bytes: 63360
package main

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

func min(a ...int) int {
	m := a[0]
	for i, v := range a {
		if i == 0 {
			continue
		}
		if m > v {
			m = v
		}
	}
	return m
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

var sc = bufio.NewScanner(os.Stdin)

func main() {
	// Code for B - Nice Shopping
	var A, B, M int
	fmt.Scanf("%d %d %d", &A, &B, &M)

	sc.Split(bufio.ScanWords)
	var mina int = 1000000
	a := make([]int, A)
	for i := 0; i < A; i++ {
		a[i] = nextInt()
		if mina > a[i] {
			mina = a[i]
		}
	}

	var minb int = 1000000
	b := make([]int, B)
	for i := 0; i < B; i++ {
		b[i] = nextInt()
		if minb > b[i] {
			minb = b[i]
		}
	}

	var x, y, c int
	var ans int = mina + minb
	for i := 0; i < M; i++ {
		x = nextInt()
		y = nextInt()
		c = nextInt()
		temp := a[x-1] + b[y-1] - c
		ans = min(ans, temp)
	}

	fmt.Println(ans)
}


Measured memory_bytes: 5940
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i, N) cin >> A[i];
  int ans = 0;
  bool flag = true;
  int cur = 1;
  int index = 0;
  while (index < N) {
    if (A[index] == cur) {
      cur++; index++;
    } else {
      ans++; // レンガを砕く
      index++;
    }
  }
  if (cur == 1) ans = -1;
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 4032
while True:
    N = int(input())
    if N == 0:
        break

    table = [[0 for i in range(5)] for j in range(6000)]
    blocks = [0 for i in range(5)]
    for l in range(N):
        d,p,q = [int(i) for i in input().split()]
        q -= 1
        if d == 1:
            maxtop = 0
            for i in range(q, q+p):
                cnt = 0
                t = 0
                if blocks[i] > 0:
                    for j in range(5000):
                        cnt += table[j][i]
                        if cnt == blocks[i]:
                            t = j+1
                            break

                maxtop = max(maxtop, t)
            for i in range(q, q+p):
                table[maxtop][i] = 1
                blocks[i] += 1
            if table[maxtop][0]*table[maxtop][1]*table[maxtop][2]*table[maxtop][3]*table[maxtop][4] == 1:
                del table[maxtop]
                for i in range(5):
                    blocks[i] -= 1

        else:
            maxtop = 0
            cnt = 0
            if blocks[q] > 0:
                t = 0
                for i in range(5000):
                    cnt += table[i][q]
                    if cnt == blocks[q]:
                        t = i + 1
                        break
                maxtop = t

            for i in range(p):
                table[maxtop + i][q] = 1
            blocks[q] += p

            for i in range(p-1, -1, -1):
                k = maxtop + i
                if table[k][0]*table[k][1]*table[k][2]*table[k][3]*table[k][4] == 1:
                    del table[k]
                    for j in range(5):
                        blocks[j] -= 1

    ans = 0
#    for i in range(9,-1,-1):
#        for j in range(5):
#            print(table[i][j], end = "")
#        print("")

    for i in range(5000):
        for j in range(5):
            ans += table[i][j]

    print(ans)



Measured memory_bytes: 6972
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int ans = 0;
    int n = s.length();
    for(int i=0;i<n;i++)
    {
        int curr = 0;
        while(i<n&&s[i]=='R')
        {
            i++;
            curr++;
        }
        ans = max(ans,curr);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3580
#include<bits/stdc++.h>
#define LL long long
#define ffor(i,s,n) for(int i=(s);i<(n);i++)
#define efor(i,s,n) for(int i=(s);i<=(n);i++)
using namespace std;
char c[10];
int main(){

    cin>>c;
	int s=0;
	ffor(i,0,4){
		if(c[i]=='+') s+=1;
		else s-=1;
	}
	cout<<s<<endl;
    return 0;

}


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

int main(){
  int n;
  cin >> n;
  while(n--){
    string str;
    set<string> train;
    cin >> str;
    for(int i=0;i < str.size();i++){
      string s1 = str.substr(0,i);
      string s2 = str.substr(i);
      for(int k=0;k < 2;k++){
        for(int l=0;l < 2;l++){
          train.insert(s1 + s2);
          train.insert(s2 + s1);
          reverse(s1.begin(),s1.end());
        }
        reverse(s2.begin(),s2.end());
      }
    }
    cout << train.size() << endl;
  }
}


Measured memory_bytes: 3152
#include <cstdio>
#include <iostream>
using namespace std;
const int maxn=21;

int f[1<<maxn][maxn],n,K;
char sx[1<<maxn];

int main(void)
{
    scanf("%d%d",&n,&K);
    for(int i=0;i<=n;++i)
    {
        scanf("%s",sx);
        for(int j=0;j<(1<<i);++j)
            f[j|(1<<i)][i]=sx[j]=='1';
    }
    for(int i=n;i>=0;--i)
        for(int s=0;s<(1<<i);++s)
            for(int j=i;j>=0;--j)
            {
                int tmp=f[(1<<i)|s][j];
                int s1=s>>j;
                int s2=s&((1<<j)-1);
                if(j) f[(1<<(i-j))|s1][0]+=tmp;
                if(s2)
                {
                    int p=j-1;while(!((s2>>p)&1)) --p;
                    f[(1<<(i-j+p+1))|(s1<<(p+1))|(1<<p)|(s2&((1<<p)-1))][p]+=tmp;
                }
                if(((1<<j)-1)&(~s2))
                {
                    int p=j-1;while((s2>>p)&1) --p;
                    f[(1<<(i-j+p+1))|(s1<<(p+1))|(s2&(1<<p)-1)][p]+=tmp;
                }
            }
    for(int i=n;i>=0;--i)
        for(int j=0;j<(1<<i);++j)
            if(f[(1<<i)|j][0]>=K)
            {
                for(int k=i-1;k>=0;--k) printf("%d",(j>>k)&1);
                return 0;
            }
    return 0;
}


Measured memory_bytes: 173440
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,H,W;
  cin>>N>>H>>W;
  int ans=0;
  for(int i=1;i<=N;i++){
    int A,B;
    cin>>A>>B;
    if(A>=H&&B>=W)ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
M = 10**9 + 7
dp = [0] * 4
dp[0] = 1
idx = {'A': 1, 'B': 2, 'C': 3}
m = lambda x: x % M if x > M else x
for c in input():
    if c == '?':
        N, A, AB, ABC = dp
        dp = [m(N * 3), m(A * 3 + N), m(AB * 3 + A), m(ABC * 3 + AB)]
    else:
        dp[idx[c]] += dp[idx[c] - 1]
print(dp[3] % M)

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

// Loops
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define _rrep(i, n) rrepi(i, n, 0)
#define rrepi(i, a, b) for (int i = int(a) - 1; i >= int(b); --i)

#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(xi, x) for (auto &&xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)

// typedef
template <class T> using vec = vector<T>;
using ll = long long;
using vi = vec<ll>;
using vvi = vec<vi>;
using vvvi = vec<vvi>;
using pii = pair<ll, ll>;

// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define mp make_pair

// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase(unique(all(v)), v.end())
#define perm(c)                                                                \
  sort(all(c));                                                                \
  for (bool c##p = 1; c##p; c##p = next_permutation(all(c)))

template <class T> pair<T, size_t> max(vector<T> &x) {
  auto it = max_element(all(x));
  return mp(*it, it - x.begin());
}
template <class T> pair<T, size_t> min(vector<T> &x) {
  auto it = min_element(all(x));
  return mp(*it, it - x.begin());
}

template <class T> inline bool chmax(T &maxval, const T &newval) {
  if (maxval < newval) {
    maxval = newval;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &minval, const T &newval) {
  if (minval > newval) {
    minval = newval;
    return 1;
  }
  return 0;
}

// Utilities
// Grid world utilities
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
#define inside(H, W, y, x) 0 <= (x) && (x) < (W) && 0 <= (y) && (y) < (H)

// Debug
#ifdef LOCAL
#include "dump.hpp"
#define debug(x) cerr << #x << ": " << x << '\n'
#else
#define dump(...)
#define debug(x)
#endif

// Yes or No
void yesno(bool ok, string yes = "Yes", string no = "No") {
  cout << (ok ? yes : no) << endl;
}

// Paste snippets here!!

//

void solve(long long A, long long B, long long C, long long D) {
  for(;;){
    // takahashi attack
    C -= B;
    if(C<=0) { cout << "Yes" << endl; return; }
    A -= D;
    if(A<=0) { cout << "No" << endl; return; }
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false); // Magic for faster cin
  cout.precision(12);
  long long A;
  std::cin >> A;
  long long B;
  std::cin >> B;
  long long C;
  std::cin >> C;
  long long D;
  std::cin >> D;
  solve(A, B, C, D);
  return 0;
}


Measured memory_bytes: 3656
from collections import defaultdict
# import numpy as np

N = int(input())

ab = []

for _ in range(N - 1):
    ab.append(tuple(map(int, input().split())))

c = sorted(list(map(int, input().split())), reverse=True)
# argsort = np.argsort(c)[::-1]

nodes = defaultdict(set)
for a, b in ab:
    nodes[a].add(b)
    nodes[b].add(a)


d = {}
done = set()
stack = [1]
ci = 0
node = 1
while stack:
    node = stack.pop()
    d[node] = c[ci]
    stack += list(nodes[node] - done)
    done.add(node)
    ci += 1

print(sum(c[1:]))
for i in range(N):
    print(d[i + 1], end=' ')
print()


Measured memory_bytes: 9644
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String str = scanner.next();
		int l = str.length();
		do {
			l -= 1;
			str = str.substring(0, l);
		} while (!isOddString(str) && l > 0);
		System.out.println(l);
	}
	
	private static Boolean isOddString(String str) {
		int l = str.length() / 2;
		String a = str.substring(0, l);
		String b = str.substring(l, str.length());
		return (a.equals(b));
	}
}

Measured memory_bytes: 21588
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
// https://atcoder.jp/contests/abc102/tasks/abc102_b
int solver(int aN,vector<int> n){
    int result;
    sort(n.begin(),n.end(),greater<int>());
 /**
    for (int j = 0; j < aN; j++)
    {
        cout << n.at(j) << ",";
    }
    cout << endl;
**/    
    result = n.at(0)-n.at(aN-1);
    return result;
}
int main(void){
    int N,answer;
    cin >> N;
    vector<int> A(N);
    for(int j=0;j<N;j++){
        cin >> A.at(j);
    }
    answer = solver(N,A);
    cout << answer << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.util.*
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min

val MOD = 1_000_000_007L

class Solver(stream: InputStream, private val out: java.io.PrintWriter) {
  fun solve() {
    val N = ni()
    out.println((1000 - N % 1000) % 1000)
  }













































  private val isDebug = try {
    // なんか本番でエラーでる
    System.getenv("MY_DEBUG") != null
  } catch (t: Throwable) {
    false
  }

  private var tokenizer: StringTokenizer? = null
  private val reader = BufferedReader(InputStreamReader(stream), 32768)
  private fun next(): String {
    while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {
      tokenizer = StringTokenizer(reader.readLine())
    }
    return tokenizer!!.nextToken()
  }

  private fun ni() = next().toInt()
  private fun nl() = next().toLong()
  private fun ns() = next()
  private fun na(n: Int, offset: Int = 0): IntArray {
    return map(n) { ni() + offset }
  }
  private fun nal(n: Int, offset: Int = 0): LongArray {
    val res = LongArray(n)
    for (i in 0 until n) {
      res[i] = nl() + offset
    }
    return res
  }

  private fun na2(n: Int, offset: Int = 0): Array<IntArray> {
    val a  = Array(2){IntArray(n)}
    for (i in 0 until n) {
      for (e in a) {
        e[i] = ni() + offset
      }
    }
    return a
  }

  private inline fun map(n: Int, f: (Int) -> Int): IntArray {
    val res = IntArray(n)
    for (i in 0 until n) {
      res[i] = f(i)
    }
    return res
  }

  private inline fun debug(msg: () -> String) {
    if (isDebug) System.err.println(msg())
  }

  private fun debug(a: LongArray) {
    debug { a.joinToString(" ") }
  }

  private fun debug(a: IntArray) {
    debug { a.joinToString(" ") }
  }

  private fun debug(a: BooleanArray) {
    debug { a.map { if (it) 1 else 0 }.joinToString("") }
  }

  private fun debugDim(A: Array<LongArray>) {
    if (isDebug) {
      for (a in A) {
        debug(a)
      }
    }
  }
  private fun debugDim(A: Array<IntArray>) {
    if (isDebug) {
      for (a in A) {
        debug(a)
      }
    }
  }

  /**
   * 勝手にimport消されるのを防ぎたい
   */
  private fun hoge() {
    min(1, 2)
    max(1, 2)
    abs(-10)
  }
}

fun main() {
  val out = java.io.PrintWriter(System.out)
  Solver(System.`in`, out).solve()
  out.flush()
}

Measured memory_bytes: 34688
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const int INF = 1000000007;

int main(){
	int n; cin>>n;
	if(n % 2 == 0) cout<< n <<endl;
	else cout<< 2*n <<endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

static const int MAX = 500;
static const int INF = (1<<21);

int main() {
  int n,i,j,k,c,m,s,mins;
  int M[MAX][MAX],d[MAX],v[MAX];

  scanf("%d", &n);
  for ( i = 0; i< n; i++ ){
    for ( j = 0; j < n; j++ ){
      M[i][j] = INF;
    }
  }

  for ( i = 0; i < n; i++ ){
    scanf("%d %d", &m, &k);
    for ( j = 0; j < k; j++ ){
      scanf("%d %d", &s, &c);
      M[m][s] = c;
    }
  }

  for ( i = 0; i < n; i++ ) {
    d[i] = INF;
    v[i] = 0;
  }

  d[0] = 0;

  while(1){
    mins = INF;
    m = -1;
    for ( i = 0; i < n; i++ ){
      if ( mins > d[i] && !v[i] ){
	m = i;
	mins = d[i];
      }
    }
    if ( m == -1 ) break;
    v[m] = 1;
    for ( s = 0; s < n; s++ ){
      if ( !v[s] && M[m][s] != INF ){
	if ( d[s] > d[m] + M[m][s] ){
	  d[s] = d[m] + M[m][s];
	}
      }
    }
  }

  for ( i = 0; i < n; i++ ){
    printf("%d %d\n", i, (d[i]==INF?-1:d[i]));
  }

  return 0;
}



Measured memory_bytes: 2112
#include<stdio.h>
#include<algorithm>
using namespace std;
int main(){
    int n;
    scanf("%d",&n);
    long long m=0;
    for(int i=1;i<=n;++i){
        for(int j=1;j<=n;++j){
            for(int k=1;k<=n;++k){
                m+=__gcd(i,__gcd(j,k));
            }
        }
    }
    printf("%lld\n",m);
}

Measured memory_bytes: 1732
#include<bits/stdc++.h>
 
using namespace std;
 
int main() {
  int a, b, c, d, r1, r2;
  cin >> a >> b >> c >> d;
  r1 = a * b;
  r2 = c * d;
  if (r1 >= r2) {
    cout << r1 << endl;
  } else {
    cout << r2 << endl;
  } 
  return 0;
}

Measured memory_bytes: 256