akhauriyash/Code-Regression huggingface dataset:
package main

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

type contest struct {
	in  io.Reader
	out io.Writer
}

func (con *contest) Scan(a ...interface{}) (int, error) {
	return fmt.Fscan(con.in, a...)
}
func (con *contest) Scanln(a ...interface{}) (int, error) {
	return fmt.Fscanln(con.in, a...)
}
func (con *contest) Scanf(f string, a ...interface{}) (int, error) {
	return fmt.Fscanf(con.in, f, a...)
}
func (con *contest) Print(a ...interface{}) (int, error) {
	return fmt.Fprint(con.out, a...)
}
func (con *contest) Println(a ...interface{}) (int, error) {
	return fmt.Fprintln(con.out, a...)
}
func (con *contest) Printf(f string, a ...interface{}) (int, error) {
	return fmt.Fprintf(con.out, f, a...)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	con := &contest{in: in, out: out}
	con.main()
}

func (con *contest) main() error {
	var s string
	con.Scan(&s)
	if 'A' <= s[0] && s[0] <= 'Z' {
		con.Println("A")
	} else {
		con.Println("a")
	}
	return nil
}


Measured memory_bytes: 1844
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner scanner = new Scanner(System.in);
        int A, B, C, X, Y;
        A = scanner.nextInt();
        B = scanner.nextInt();
        C = scanner.nextInt();
        X = scanner.nextInt();
        Y = scanner.nextInt();
        int ans = (int) 1e9;//1e9=10^9
        for (int i = 0; i < 2 * (X + Y) + 1; i++) {
            int ABpizza = i;
            int Apizza = Math.max(X - i / 2, 0);
            int Bpizza = Math.max(Y - i / 2, 0);
            ans = Math.min(ans, Apizza * A + Bpizza * B + ABpizza * C);
        }
        System.out.println(ans);
    }
}

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

int N, M;
#define MAX_N 100000
long long A[MAX_N];
int R[MAX_N], P[MAX_N];
map<int, vector<long long>> S;
vector<long long> X;
long long Z;

int find(int v) {
  if(P[v] == v) return v;
  return P[v] = find(P[v]);
}
void unite(int v, int w) {
  v = find(v); w = find(w);
  if(v == w) return;
  if(R[v] > R[w]) swap(v, w);
  P[v] = w; if(R[v] == R[w]) ++R[w];
}
int main() {
  cin >> N >> M;
  for(int v = 0; v < N; ++v) {
    cin >> A[v]; P[v] = v;
  }
  for(int i = 0; i < M; ++i) {
    int x, y; cin >> x >> y; unite(x, y);
  }
  for(int v = 0; v < N; ++v) S[find(v)].push_back(A[v]);
  int K = S.size();
  if(K == 1) { cout << 0 << endl; return 0; }
  for(auto kv : S) {
    vector<long long>& a = kv.second;
    sort(a.begin(), a.end());
    Z += a[0];
    for(int i = 1; i < (int)a.size(); ++i) X.push_back(a[i]);
  }
  if((int)X.size() < K - 2) { cout << "Impossible" << endl; return 0; }
  sort(X.begin(), X.end());
  for(int i = 0; i < K - 2; ++i) Z += X[i];
  cout << Z << endl;
  return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
 
#define FS              ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll              long long int
#define ld              long double
#define pb              push_back
#define bp              __builtin_popcount
#define sz              size()
#define ff              first
#define ss              second
#define vll             vector<ll>
#define vbool           vector<bool>
#define vpll            vector<pair<ll,ll>>
#define pll             pair<ll,ll>
#define vllv            vector<vector<ll>>
#define setpri(x)       cout<<setprecision(x)<<fixed;
#define all(v)          v.begin(),v.end()
#define allr(v)         v.rbegin(),v.rend()
#define yesr {cout<<"YES"<<endl;return;}
#define nor {cout<<"NO"<<endl;return;}
// getline (std::cin,name);
ll MOD=1e9+7;
ll ceil1(ll n,ll x){return (n-1)/x+(n>0);}

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

ll pow1(ll n,ll m ,ll mod=MOD );
ll pow2(ll n,ll k);

ll modinv(ll n,ll mod=MOD){  return pow1(n,mod-2,mod);}

bool func(pair<ll,ll> &a,pair<ll,ll> &b ){
        if(a.ff != b.ff)return a.ff < b.ff;
        return a.ss > b.ss;
}

ll const N=(ll)2e6+11;
ll const LG=(ll)log2(N)+1;


void solve(){
        ll i,j,k,l,n,m,x,y,z,r;

        
        cin>>x;
        cout<<1-x<<endl;
        
        
}       
int main(){
        FS;
        
        ll i,j,k,n,m,x,y,z,q;
        q=1;
        // cin>>q;
        for(ll tc=1;tc<=q;tc++){
                // cout<<"Case #"<<tc<<": ";
                solve();
        }
        return 0;
}


ll pow1(ll n,ll m,ll mod){
        if(m==0)return 1;
        
        if(m%2==0)return pow1((n*n)%mod,m/2,mod);
            
            return (pow1((n*n)%mod,m/2,mod)*n)%mod;
}

ll pow2(ll n,ll k){
        ll ans=1;
            while(k>0){
                if(k%2==1)ans=ans*n;
                n=n*n;
                k/=2;
            }
            return ans;
}


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

using namespace std;

#define int		long long

void solve()
{
	int d,t,s;
	cin >> d >> t >> s;
	t *= s;
	if(t>=d)
		cout << "Yes" ;
	else
		cout << "No" ;
}

int32_t main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	//int t;cin >> t ;while(t--)
	 	solve();
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;
 
const ll INF=(1ll<<31)-1;
int a[100001];
int b[1005];
int main(){
    int n,q;
    cin>>n>>q;
    int sqn=sqrt(n);
    int bn=(n+sqn-1)/sqn;
    rep(i,n) a[i]=INF;
    rep(i,bn) b[i]=INF;
    int com;
    rep(i,q){
        cin>>com;
        if(com==0){
            int s,t,x;
            //[s,t)
            cin>>s>>t>>x;
            ++t;
            rep(j,bn){
                int l=j*sqn,r=(j+1)*sqn;
                if(r<=s||t<=l) continue;
                if(s<=l&&r<=t) b[j]=x;
                else{
                    FOR(k,l,r){
                        if(k>=max(s,l)&&k<min(t,r)) a[k]=x;
                        else if(b[j]!=INF) a[k]=b[j];
                    }
                    b[j]=INF;
                }
            }
        }
        if(com==1){
            int k;
            cin>>k;
            int cur=k/sqn;
            if(b[cur]!=INF){
                FOR(j,cur*sqn,(cur+1)*sqn){
                    a[j]=b[cur];
                }
                b[cur]=INF;
            }
            cout<<a[k]<<endl;
        }
    }
    return 0;
}


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

int prev[1000000];
int next[1000000];

int main(){
  int dice_num,side_num,cutback;
  
  while(~scanf("%d %d %d",&dice_num,&side_num,&cutback)){
    if(dice_num == 0) break;
    memset(prev,0,sizeof(prev));
    memset(next,0,sizeof(next));
    
    for(int i=1;i<=side_num;i++) prev[i] = 1;

    for(int i=1;i<dice_num;i++){
      for(int from=1;from<=side_num*dice_num;from++){
	for(int spots=1;spots<=side_num;spots++){
	  next[from+spots] += prev[from];
	}
      }
      memcpy(prev,next,sizeof(int)*1000000);
      memset(next,0,sizeof(next));
    }

    int sum = 0;
    for(int i=0;i<=side_num*dice_num;i++){
      sum += prev[i];
    }

    double exp = 0.0;
    for(int i=0;i<=side_num*dice_num;i++){
      double prob = (double)prev[i]/(double)sum;
      if(i-cutback <= 0){
	exp += 1.0 * prob;
      }
      else{
	exp += (double)(i-cutback) * prob;
      }
    }

    printf("%.8lf\n",exp);
  }
}

Measured memory_bytes: 9048
/*..................................
manojeet24
....................................*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define fl(i,a,b) for(int i=a;i<b;i++)
#define flr(i,a,b) for(int i=a;i>b;i--)
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define endl '\n'
#define mod 1000000007
char grid[1001][1001];
ll dp[1001][1001];
ll solve(int h,int w)
{
    if(h==0 && w==0) return 1;
    if(dp[h][w]!=-1)    return dp[h][w]%mod;
    if(grid[h][w]=='#') return dp[h][w]=0;
    if(h==0)
        return dp[h][w]=solve(h,w-1);
    if(w==0)
        return dp[h][w]=solve(h-1,w);
    return dp[h][w]=(solve(h-1,w)%mod+solve(h,w-1)%mod)%mod;
}
int main()
{
    int h,w;
    cin>>h>>w;
    fl(i,0,h)
    {
        fl(j,0,w)
        {
            dp[i][j]=-1;
            cin>>grid[i][j];
        }
    }
    cout<<solve(h-1,w-1);

}



Measured memory_bytes: 9088
require 'pp'

def gets; ARGF.gets; end

class Solver

  def initialize
  end

  def main
    a, b = gets.chomp.split.map(&:to_i)

    if a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0
      puts "Possible"
    else
      puts "Impossible"
    end
  end
end

if __FILE__ == $0
  Solver.new.main
end


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

int A, B, C, D;

int main() {
    cin >> A >> B >> C >> D;
    while (true){
        C -= B;
        if (C <= 0) {
            cout << "Yes" << endl;
            break;
        }
        A -= D;
        if (A <= 0) {
            cout << "No" << endl;
            break;
        }
    }
}

Measured memory_bytes: 3624
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
#include <set>
#include <random>
using namespace std;

int main() {
  int N;
  cin >> N;
  vector <int> a(N);
  int ans = 0;
  for (int i = 0; i < N; i++) {
	  cin >> a[i];
	  ans += a[i] - 1;
	}
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
n=int(input())
l=[]
for i in range(n):
        a=int(input())
        l.append(a)

ans=l[0]-1
nowmin=2
for i in range(1,n):
        if l[i] == nowmin:
                nowmin+=1
                continue
        if l[i]%nowmin==0:
                l[i]-=(nowmin+1)
                ans+=1
        ans += l[i]//nowmin
print(ans)

Measured memory_bytes: 80612
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sz size()
#define ll long long
#define all(_v) _v.begin(), _v.end()

/**
int n, m, q;
pair <pair <int, int>, pair <int, int> > a[60];
vector <vector <int> > P;
vector <int> c;
void rec(int x) {
    if(x == n + 1) {
        P.pb(c);
        return;
    }
    for(int i = 1; i <= m; ++i) c[x] = i, rec(x + 1);
}**/
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	/**cin >> n >> m >> q;
	c.resize(m + 3);
	bool ch = 0;
	for(int i = 1; i <= q; ++i)
        cin >> a[i].f.s >> a[i].s.f >> a[i].s.s >> a[i].f.f;
	rec(1);
	cout << P.sz;
	system("pause");
	return 0;
	ll ans = 0;
	for(auto vec : P) {
        ll sum = 0;
        for(int j = 1; j <= q; ++j)
            if(vec[a[j].s.f] - vec[a[j].f.s] == a[j].s.s)  sum += a[j].f.f;
        ans = max(ans, sum);
	}
	cout << ans;**/
	ll a, b, n;
	cin >> a >> b >> n;
	ll x = min(b - 1, n);
	cout << (a * x) / b - a * (x / b);
	return 0;
}


Measured memory_bytes: 3648
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
# from collections import deque
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np
# from numpy import cumsum  # accumulate

def solve():
    N = II()
    # N = 1000000000000001
    # N = 1000
    # N = 475254

    abc = [chr(i) for i in range(ord('a'), ord('z') + 1)]
    ans = []
    while N != 0:
        N -= 1
        ans.append(abc[N % 26])
        N //= 26
    printlist(ans[::-1], '')


if __name__ == '__main__':
    solve()


Measured memory_bytes: 9260
package main

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

func main() {
	N := nextInt()
	c := 0

	for i := 0; i < N; i++ {
		a := nextInt()

		if i%2 == 0 && a%2 == 1 {
			c++
		}
	}

	fmt.Println(c)
}

var stdin = initStdin()

func initStdin() *bufio.Scanner {
	bufsize := 1 * 1024 * 1024 // 1 MB
	var stdin = bufio.NewScanner(os.Stdin)
	stdin.Buffer(make([]byte, bufsize), bufsize)
	stdin.Split(bufio.ScanWords)
	return stdin
}

func nextString() string {
	stdin.Scan()
	return stdin.Text()
}

func nextBytes() []byte {
	stdin.Scan()
	return stdin.Bytes()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextString())
	return i
}

func nextInt64() int64 {
	i, _ := strconv.ParseInt(nextString(), 10, 64)
	return i
}

func debug(args ...interface{}) {
	fmt.Fprintln(os.Stderr, args)
}


Measured memory_bytes: 1804
import Data.List
main = interact $ unlines . map (concat . intersperse "\n" . videotape . map read . words) . takeWhile (/= "-1 -1 -1") . lines
videotape [t,h,s] = [to_hms (7200 - to_sec t h s), to_hms (3 * (7200 - to_sec t h s))]
 where
  to_sec t h s = 3600*t + 60*h + s
  to_hms s = concat $ intersperse ":" $ map show_digit [div s 3600, mod (div s 60) 60, mod s 60]
  show_digit s = (if length (show s) < 2 then "0" else "") ++ show s

Measured memory_bytes: 4088
#include<iostream>
#include <algorithm>
#include <vector>
using namespace std;
int N_MAX = 100000;
int main()
{
  int n,m;
  cin >> n >> m;
  if(n>=m){
    cout << "0" << endl;
    return 0;
  }
  int res=0;
  int t=m-n;
  int x[N_MAX];
  for(int i=0;i<m;i++)
    cin >> x[i];
  sort(x,x+m);
  for(int i=m-1;i>0;i--)
    x[i]-=x[i-1];
  sort(x+1,x+m);
  for(int i=0;i<t;i++)
    res+=x[i+1];
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 640
//Bismillahir Rahmanir Rahim 
#include<bits/stdc++.h>

using namespace std;

#define ll long long 
#define gcd(a,b) __gcd(a,b)
#define endl '\n'
const int N=2e5+10;
const int inf=1e9;
const int mod=1e9+7;

int  main(int argc, char const *argv[])
{
	/*#ifndef ONLINE_JUDGE
      freopen("input.txt","r",stdin);
      freopen("output.txt","w",stdout);
    #endif*/
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);

	ll n, k;
	cin >> n >> k;

	ll rem=n%k;

	cout << min(rem, k-rem) << endl;
	
	return 0;
}

Measured memory_bytes: 256
//
//  header_useful.h
//  c++_acm
//
//  Created by 李弘辰 on 2019/7/23.
//  Copyright  2019 李弘辰. All rights reserved.
//

#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <vector>
#include <list>
#include <set>
#include <unordered_set>
#include <utility> // pair
#include <map>
#include <unordered_map>
#include <iostream>
#include <sstream>
#include <algorithm> // sort
#include <string>
#include <stack>
#include <queue>
#include <fstream>
#include <bitset>


using namespace std;

#define ll long long
#define lll __int128
#define uchar unsigned char
#define ushort unsigned short
#define uint unsigned int
#define ulong unsigned long
#define ull unsigned long long

#define INT_INF 0x7fffffff

#define pi acos(-1)

#define mx(a,b) (a) > (b) ? (a) : (b)
#define mn(a,b) (a) < (b) ? (a) : (b)
#define mem(a,b) memset(a,b,sizeof(a))
#define fre(a) freopen(a,"r",stdin)

#define cio ios::sync_with_stdio(false); // Do not use it with "scanf" and other c input!
#define pb push_back
#define rep(i,a,b) for (int i = a;i <= b;i ++)
#define pre(i,a,b) for (int i = a;i >= b;i --)
#define REP(i,a,b) for (int i = a;i < b;i ++)

#define read(a,s,n) rep(i,s,n) scanf("%d",a + i);
#define READ(a,s,n) REP(i,s,n) scanf("%d",a + i);

#define read_ll(a,s,n) rep(i,s,n) scanf("%lld",a + i);
#define READ_ll(a,s,n) REP(i,s,n) scanf("%lld",a + i);

#define _T_(T) int T;scanf("%d",&T);while (T --)
#define __T _T_(TTESTCASES)
#define _E_(T) while (~T)

#define Tprint(a,s,e) {int f=1;REP(i,s,e){if(f)f=0;else printf(" ");printf("%d",a[i]);}}


#define endl '\n'

#define itn int
#define iny int
#define nit int
#define inr int
#define mian main
#define iman main
#define mina main
#define mian main
#define ednl endl
#define fro for
#define fir for
#define reutrn return
#define retunr return
#define reutnr return


/* header_useful_h */


const int MAXN = 2e5 + 10;
int n,k;
int a[MAXN];

inline bool check(int m)
{
    int ans = 0;
    rep(i,1,n) {
        if (a[i] != m) ans += a[i] / m;
        if (ans > k) return 0;
    }
    return ans <= k;
}

int main()
{
    scanf("%d%d",&n,&k);
    int l = 1;
    int r = -1;
    rep(i,1,n) {
        scanf("%d",a + i);
        if (i == 1) {
            r = a[i];
        } else {
            
            r = max(r,a[i]);
        }
    }
    
//    rep(i,1,r) {
//        printf("%d: %d\n",i,check(i));
//    }
    
//    if (k == 0) {
//        printf("%d\n",r);
//        return 0;
//    }
    int m;
    int ans = 1;

    while (l < r) {

        m = (l + r) / 2;
        if (check(m)) {
            r = m;
            ans = m;
        } else l = m + 1;
    }
    printf("%d\n",r);
    return 0;
}


Measured memory_bytes: 3976
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    int p[8], q[8];
    rep(i, n) cin >> p[i];
    rep(i, n) cin >> q[i];
    vector<int> order(n);
    rep(i, n) order[i] = i + 1;
    int a1 = -1, a2 = -1;
    int cnt = 0;
    do {
        bool ok = true;
        rep(i, n) {
            if(p[i] != order[i]) ok = false;
        }
        if(ok) a1 = cnt;
        ok = true;
        rep(i, n) {
            if(q[i] != order[i]) ok = false;
        }
        if(ok) a2 = cnt;
        cnt++;
    }while(next_permutation(order.begin(), order.end()));
    cout << abs(a1 - a2) << endl;

    return 0;
}


Measured memory_bytes: 256
while True:
    N = int(input())
    if N == 0:
        break
    words = [len(input()) for _ in range(N)]

    for i in range(N):
        now = i
        tanku = [5, 7, 5, 7, 7][::-1]
        while tanku:
            while tanku[-1] > 0:
                tanku[-1] -= words[now]
                now += 1
            if tanku[-1] == 0:
                tanku.pop()
            else:
                break
        else:
            print(i + 1)
            break

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

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

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

    int N; cin >> N;
    string S; cin >> S;

    int cnt = 0;
    for (int i = 0;i < N-2;i++){
        if(S[i] == 'A' && S[i+1] == 'B' && S[i+2] == 'C') cnt++;
    }

    cout << cnt << endl;

    return 0;

}

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

int main() {
  vector<ll> t(2), a(2), b(2);
  cin >> t[0] >> t[1] >> a[0] >> a[1] >> b[0] >> b[1];

  ll as = t[0] * a[0] + t[1] * a[1], bs = t[0] * b[0] + t[1] * b[1];
  if (as == bs) {
    cout << "infinity" << endl;
    return 0;
  } else if (as < bs) {
    swap(a[0], b[0]);
    swap(a[1], b[1]);
  }

  vector<ll> d{t[0] * a[0] - t[0] * b[0], t[1] * a[1] - t[1] * b[1]};
  d[1] += d[0];
  if (d[0] > 0) {
    cout << 0 << endl;
    return 0;
  }
  cout << ((-d[0]) % d[1] == 0 ? (-d[0]) / d[1] * 2 : (-d[0]) / d[1] * 2 + 1) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;

long long N, M, L, Q, S, T, A[1 << 18], B[1 << 18], C[1 << 18];
long long dist[309][309];

int main() {
	cin >> N >> M >> L;
	for (int i = 1; i <= N; i++) { for (int j = 1; j <= N; j++) dist[i][j] = (1LL << 60); dist[i][i] = 0; }
	for (int i = 1; i <= M; i++) {
		cin >> A[i] >> B[i] >> C[i];
		dist[A[i]][B[i]] = min(dist[A[i]][B[i]], C[i]);
		dist[B[i]][A[i]] = min(dist[B[i]][A[i]], C[i]);
	}
	for (int k = 1; k <= N; k++) {
		for (int i = 1; i <= N; i++) {
			for (int j = 1; j <= N; j++) dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
		}
	}
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= N; j++) {
			if (dist[i][j] == 0) dist[i][j] = 0;
			else if (dist[i][j] <= L) dist[i][j] = 1;
			else dist[i][j] = (1LL << 60);
		}
	}
	for (int k = 1; k <= N; k++) {
		for (int i = 1; i <= N; i++) {
			for (int j = 1; j <= N; j++) dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
		}
	}

	cin >> Q;
	for (int i = 1; i <= Q; i++) {
		cin >> S >> T;
		if (dist[S][T] == (1LL << 60)) cout << "-1" << endl;
		else cout << dist[S][T] - 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 5632
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            int N = cin.ReadInt;
            double jpy = 0;
            double btc = 0;
            for (int i = 0; i < N; i++)
            {
                var inp = cin.ReadLine.Split(' ');
                if (inp[1] == "JPY")
                {
                    double tempJpy = 0;
                    double.TryParse(inp[0], out tempJpy);
                    jpy += tempJpy;
                }
                else
                {
                    double tempBtc = 0;
                    double.TryParse(inp[0], out tempBtc);
                    btc += tempBtc;
                }
            }
            jpy = jpy + btc * 380000.0;
            Console.WriteLine(jpy);

        }

    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
int n,x,m[1010]={},minn=1010,ans=0;
int main()
{
	cin>>n>>x;
	for (int i=1;i<=n;i++)
	{
		cin>>m[i];
		x-=m[i];
		ans++;
		if (m[i]<minn) minn=m[i];
    }

	ans+=x/minn;
	cout<<ans;
	return 0;
} 

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

using namespace std;

int main() {
    ios :: sync_with_stdio(0);
    cin.tie(nullptr);
    string s;
    cin >> s;
    int i, j;
    for(i = 0, j = s.size(); i < j;) {
        if (s[i] != 'A')
            ++i;
        if (s[j] != 'Z')
            --j;
        if (s[i] == 'A' && s[j] == 'Z')
            break;
    }

    cout << j - i + 1;

    return 0;
}


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

int main() {

  int N,K;
  cin >> N>>K;
  long long int A[N+1];
  A[0]=0;
  for(int i=1;i<N+1;i++){
    cin >>A[i];
  }
  for(int i=K+1;i<N+1;i++){
   if(A[i]>A[i-K]){
     cout << "Yes"<<endl;
   }
    else{
      cout <<"No"<<endl;
  }
  }

 return 0;
}


Measured memory_bytes: 5192
#include "bits/stdc++.h"
#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##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define write(x) cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int N, M, s, t;

void dijkstra(const vv<pair<ll, int>>& graph, vector<ll>& dist, int s) {
    dist.assign(N, LINF);
    dist[s] = 0;
    priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> pq;
    pq.emplace(0, s);
    int cnt_visited = 0;

    while (!pq.empty()) {
        auto v = pq.top(); pq.pop();
        if (v.first > dist[v.second]) continue;
        else if (++cnt_visited == 2 * N) break;

        for (auto& u : graph[v.second]) {
            if (v.first + u.first < dist[u.second]) {
                dist[u.second] = v.first + u.first;
                pq.emplace(v.first + u.first, u.second);
            }
        }
    }
}

int main() {
    cin >> N >> M >> s >> t;
    s--; t--;
    vv<pair<ll, int>> graph_yen(N), graph_snuuk(N);
    rep(i, M) {
        int u, v, a, b;
        cin >> u >> v >> a >> b;
        u--; v--;
        graph_yen[u].emplace_back(a, v);
        graph_yen[v].emplace_back(a, u);
        graph_snuuk[u].emplace_back(b, v);
        graph_snuuk[v].emplace_back(b, u);
    }

    vector<ll> dist_s, dist_t;
    dijkstra(graph_yen, dist_s, s);
    dijkstra(graph_snuuk, dist_t, t);

    vector<ll> ans(N);
    const ll Max = 1'000'000'000'000'000LL;
    ans[N - 1] = Max - dist_s[N - 1] - dist_t[N - 1];

    for (int i = N - 2; i >= 0; --i) {
        ans[i] = max(ans[i + 1], Max - dist_s[i] - dist_t[i]);
    }

    for (ll a : ans) {
        write(a);
    }
}

Measured memory_bytes: 19016
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int op,a,b;
	scanf("%d%d%d",&op,&a,&b);
	if(op==1){
		printf("Hello World\n");
	}else{
		printf("%d\n",a+b);
	}
	return 0;
}

Measured memory_bytes: 256
import sys

def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))
def RN(N): return [input().strip() for i in range(N)]


def main():
    K = II()
    S = input()
    Sl = len(S)
    if Sl <= K:
        print(S)
    else:
        ans = S[:K] + "..."
        print(ans)



if __name__ == "__main__":
	main()

Measured memory_bytes: 61948
def main():
    N, M = (int(i) for i in input().split())
    H = [int(i) for i in input().split()]
    AB = [[int(i) for i in input().split()] for j in range(M)]
    ans = {i+1 for i in range(N)}
    for a, b in AB:
        if H[a-1] < H[b-1]:
            ans.discard(a)
        elif H[b-1] < H[a-1]:
            ans.discard(b)
        else:
            ans.discard(a)
            ans.discard(b)
    print(len(ans))


if __name__ == '__main__':
    main()


Measured memory_bytes: 106600
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
#define ll long lnog 
#define rep(i, s, n) for(int i = s; i < n; i++)

int main() {
    string s;
    cin >> s;
    map<char, int> mp;
    rep(i, 0, s.size()) {
        mp[s[i]]++;
    }
    queue<char> que;
    rep(i, 0, 26) {
        if(mp['a'+i] == 0) {
            que.push('a'+i);
        }
    }

    string t = "";
    if(que.size() == 0 && s == "zyxwvutsrqponmlkjihgfedcba") {
        cout << -1 << endl;
    }
    else if(que.size() != 0) {
        s += que.front();
        cout << s << endl;
    }
    else {
        string r = s;
        next_permutation(r.begin(), r.end());
        rep(i, 0, s.size()) {
           if(r[i] == s[i]) {
               t += r[i];
           }
           else {
               t += r[i];
               cout << t << endl;
               break;
           }
        }
    }
    return 0;
}

Measured memory_bytes: 256
// https://onlinejudge.u-aizu.ac.jp/courses/lesson/2/ITP1/9/ITP1_9_B

#include <iostream>

int main()
{
    int m, h;
    std::string cards;

    while (std::cin >> cards && cards != "-")
    {
        int len = cards.length();
        std::cin >> m;
        for (int i = 0; i < m; i++)
        {
            std::cin >> h;
            cards += cards;
            cards = cards.substr(h, len);
        }
        std::cout << cards << std::endl;
    }
}


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

class Procon
{
    public Procon() { }
    static void Main(string[] agrs)
    {
        new Procon().Do();
    }

    Scanner cin;

    public void Do()
    {
        cin = new Scanner();

        int A = cin.nextInt();
        int B = cin.nextInt();
        int T = cin.nextInt();

        int ret = B * ((T * 10 + 5) / (A * 10));

        Console.WriteLine(ret);
    }
}

class Scanner
{
    string[] s;
    int i;
    int max_i;

    public Scanner()
    {
        s = new string[0];
        max_i = 0;
        i = 0;
    }

    public string nextString()
    {
        if (i >= s.Length)
        {
            s = Console.ReadLine().Split(' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0)
            {
                return "";
            }
            return s[i++];
        }
        else
        {
            return s[i++];
        }
    }

    public int nextInt()
    {
        return int.Parse(nextString());
    }

    public long nextLong()
    {
        return long.Parse(nextString());
    }

    public double nextDouble()
    {
        return double.Parse(nextString());
    }

    public string[] arrayString()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] arrayInt()
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] array = new int[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = int.Parse(str[i]);
        }
        return array;
    }

    public long[] arrayLong()
    {
        string[] str = Console.ReadLine().Split(' ');
        long[] array = new long[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = long.Parse(str[i]);
        }
        return array;
    }

    public double[] arrayDouble()
    {
        string[] str = Console.ReadLine().Split(' ');
        double[] array = new double[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = double.Parse(str[i]);
        }
        return array;
    }
}

Measured memory_bytes: 11092
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int p = scan.nextInt();

		int ans = (a*3+p)/2;

		System.out.print(ans);
		scan.close();

	}

}


Measured memory_bytes: 21972
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<string>
using namespace std; 
int cmp(int a, int  b){
	return a>b;
}
int main(){
	    int num[11];
    for( int i = 0; i < 10; i ++)cin>> num[i];
	sort(num,num+10,cmp);
	
	for( int i = 0; i < 3; i ++)cout << num[i]<<endl; 
	return 0;
}

Measured memory_bytes: 0
/*mohammadreza motabar*/
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define ll long long
#define pb push_back
typedef pair<int,int> pii;
const ll MAX_N = 1e2,INF = 1e9;
ll x[MAX_N];
ll y[MAX_N];
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n,k;cin>>n>>k;
	for(int i=1;i<=n;i++)
		cin>>x[i]>>y[i];
	ll ans=1e9;
	ans*=1e9;
	ans*=5;
	for(ll i=1;i<=n;i++)
		for(ll j=1;j<=n;j++)
			for(ll ii=1;ii<=n;ii++)
				for(ll jj=1;jj<=n;jj++){
					ll cnt=0;
					for(ll k=1;k<=n;k++)
						if(x[k]>=x[i]&&x[k]<=x[ii]&&y[k]>=y[j]&&y[k]<=y[jj])
							cnt++;
					if(cnt<k)
						continue;
					ll area=(abs(x[i]-x[ii]))*(abs(y[j]-y[jj]));
					ans=min(area,ans);
				}
	cout<<ans;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    private static Scanner scan = new Scanner(System.in);

    public static void main(String[] args) {
	long A = Long.parseLong(scan.next());
	String op = scan.next();
	long B = Long.parseLong(scan.next());

	long ans = (op.equals("+") ? A+B : A-B);
	System.out.println(ans);
	scan.close();
    }
}


Measured memory_bytes: 23636
while 1:
    try:
        roma = list(input())
    except:
        break
    l = len(roma)
    prev = ""
    ans = 0
    for i, r in enumerate(roma):
        if r == "I":
            if i != l-1:
                if roma[i+1] == "V" or roma[i+1] == "X":
                    ans -= 1
                else:
                    ans += 1
            else:
                ans += 1
        elif r == "V":
            ans += 5
        elif r == "X":
            if i != l-1:
                if roma[i+1] == "L" or roma[i+1] == "C":
                    ans -= 10
                else:
                    ans += 10
            else:
                ans += 10
        elif r == "L":
            ans += 50
        elif r == "C":
            if i != l-1:
                if roma[i+1] == "D" or roma[i+1] == "M":
                    ans -= 100
                else:
                    ans += 100
            else:
                ans += 100
        elif r == "D":
            ans += 500
        elif r == "M":
            ans += 1000

    print(ans)



Measured memory_bytes: 5564
#include "bits//stdc++.h"
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
typedef pair<int, int> P;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define ALL(v) v.begin(), v.end()
struct edge {
	int to, cap, rev;
	edge(int to, int cap, int rev) :to(to), cap(cap), rev(rev) {}
};

vector<vector<edge>> G;
vector<bool> used;

void add_edge(int from, int to, int cap) {
	G[from].emplace_back(to, cap, G[to].size());
	G[to].emplace_back(from, 0, G[from].size() - 1);
}

int dfs(int v, int t, int f) {
	if (v == t) return f;
	used[v] = 1;
	for (edge &e : G[v]) {
		if (!used[e.to] && e.cap > 0) {
			int d = dfs(e.to, t, min(f, e.cap));
			if (d > 0) {
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}

int max_flow(int s, int t) {
	int flow = 0;
	used.resize(G.size());
	for (;;) {
		fill(ALL(used), 0);
		int f = dfs(s, t, 1 << 30);
		if (f == 0) return  flow;
		flow += f;
	}
}
int deg[100000];
int main() {
	int N, M;
	cin >> N >> M;
	G.resize(N);
	rep(i, M) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		add_edge(a, b, 1);
		add_edge(b, a, 1);
		deg[a]++;
		deg[b]++;
	}
	bool ok = 0;
	vector<int> four;
	rep(i, N) {
		if (deg[i] % 2) {
			cout << "No" << endl;
			return 0;
		}
		if (deg[i] >= 6) ok = 1;
		if (deg[i] == 4) four.push_back(i);
	}
	if (ok || four.size() >= 3) {
		cout << "Yes" << endl;
		return 0;
	}
	if (four.size() <= 1) {
		cout << "No" << endl;
		return 0;
	}
	if (max_flow(four[0], four[1]) == 2) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 10624
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

const int _infinity = 5000;
VEC(int) A, B, C;
int dp[41][401][401];

int f(int i, int a, int b)
{
    if (i == A.size())
        return a == 0 && b == 0 ? 0 : _infinity;

    int& ans = dp[i][a][b];
    if (ans >= 0)
        return ans;

    ans = f(i + 1, a, b);
    if (A[i] <= a && B[i] <= b)
        ans = min(ans, C[i] + f(i + 1, a - A[i], b - B[i]));
    return ans;
}

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int N, Ma, Mb;
    cin >> N >> Ma >> Mb;
    FOR(i, 0, N) {
        int a, b, c;
        cin >> a >> b >> c;
        A.push_back(a);
        B.push_back(b);
        C.push_back(c);
    }

    memset(dp, -1, sizeof dp);

    int ret = _infinity;
    for (int k = 1;k * Ma <= 400 && k * Mb <= 400; k++)
        ret = min(ret, f(0, k * Ma, k * Mb));

    cout << (ret >= _infinity ? -1 : ret) << endl;
    return 0;
};


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

int main() {
  ll n,ans=1;
  string s;
  char tmp;
  cin >> n >> s;
  tmp=s.at(0);
  rep(i,n-1){
  	 if(tmp!=s.at(i+1)) {
  	 	ans++;
  	 	tmp=s.at(i+1);
  	 }
  }
  cout << ans << endl; 
}


Measured memory_bytes: 512
#include <cstdio>
using namespace std;
 
// http://ja.wikipedia.org/wiki/Xorshift
inline unsigned random() {
  static unsigned x = 123456789;
  static unsigned y = 362436069;
  static unsigned z = 521288629;
  static unsigned w = 88675123;
  unsigned t;
 
  t = x ^ (x << 11);
  x = y; y = z; z = w;
  return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
}
 
inline int random(int n) { return (int)(random() & 0x7fffff) % n; }
 
char a[10][10];
 
int main() {
  int N; scanf("%d", &N);
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < N; ++j) {
      scanf(" %c", &a[i][j]);
    }
  }
 
  int hand = random(N);
  for (int i = 0; i < 1000; ++i) {
    printf("%d\n", hand+1); fflush(stdout);
    int ai_hand; scanf("%d", &ai_hand); --ai_hand;
    if (a[hand][ai_hand] == 'x') { hand = random(N); }
  }
}

Measured memory_bytes: 0
#include<cstdio>
#include<string>
#include<iostream>
#pragma warning(disable:4996);
using namespace std;

int main(void)
{
	int k;
	string s;
	scanf("%d", &k);
	cin >> s;
	if (s.length() <= k)
		cout << s;
	else
	{
		s = s.substr(0, k);
		s += "...";
		cout << s;
	}
	return 0;
}

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

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

long long MOD = 10000000000 + 7;

int main(){
  cout << setprecision(10);
  map<string,string> m;
  m["Sunny"] = "Cloudy";
  m["Cloudy"] = "Rainy";
  m["Rainy"] = "Sunny";

  string S; cin >> S;
  cout << m[S] << endl;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;cin>>N;
  vector<int> v(N);
  for(int i=0;i<N;i++)cin>>v[i];
  sort(v.begin(),v.end());
  float X=v[0];
  for(int i=1;i<N;i++){
    X=(X+v[i])/2.0;
  }
  cout<<X<<endl;
}

Measured memory_bytes: 256
def main():
    N = int(input())
    W = [input() for j in range(N)]

    D = []
    ans = 'Yes'
    for i in range(N - 1):
        if W[i] in D:
            ans = 'No'
            break
        elif W[i][-1] != W[i + 1][0]:
            ans = 'No'
            break
        else:
            D.append(W[i])

    if W[-1] in D:
        ans = 'No'

    print(ans)


main()


Measured memory_bytes: 3060
N = int(input())
S = []
T = []

for i in range(N):
    s, t = input().split()
    t = int(t)
    S.append(s)
    T.append(t)

X = input()

ans = 0
flag = False
for i, name in enumerate(S):
    if X == name:
        flag = True
        continue
    
    if flag:
        ans += T[i]

print(ans)

Measured memory_bytes: 38384
use std::io::Read;
use std::str::SplitWhitespace;
use std::str::FromStr;

pub fn read_stdin() -> String {
    let mut s = String::new();
    ::std::io::stdin().read_to_string(&mut s).unwrap();
    s
}

pub trait Parse<T> {
    fn parse(&mut self) -> T;
}

impl<'a, T> Parse<T> for SplitWhitespace<'a>
where
    T: FromStr,
{
    fn parse(&mut self) -> T {
        let word = self.next().unwrap();
        word.parse().ok().unwrap()
    }
}

fn main() {
    let source = read_stdin();
    let mut iter = source.split_whitespace();
    let height: u32 = iter.parse();
    let width: u32 = iter.parse();
    let h: u32 = iter.parse();
    let w: u32 = iter.parse();

    println!("{}", (height - h) * (width - w));
}

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

int main(){
    int64_t a, b, c, k, ans;
    cin >> a >> b >> c >> k;
    int64_t n = a + b + c;

    if( k <= a) {
        ans = k;
    }else if( a < k && k <= a + b){
        ans = a;
    }else{
        ans = a + (-1)*(k - a - b);
    }
    cout <<  ans  << endl;
}

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

using Int = long long;
const char newl = '\n';

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}
template<typename T=Int>
vector<T> read(size_t n){
  vector<T> ts(n);
  for(size_t i=0;i<n;i++) cin>>ts[i];
  return ts;
}

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  Int n,k;
  cin>>n>>k;

  auto ps=read(n);
  auto cs=read(n);

  for(Int &p:ps) p--;

  const Int INF = 1e18;
  if(k<=n*2){
    Int ans=-INF;
    for(Int i=0;i<n;i++){
      Int cur=i;
      Int res=0;
      for(Int j=0;j<k;j++){
        cur=ps[cur];
        res+=cs[cur];
        chmax(ans,res);
      }
    }
    cout<<ans<<newl;
    return 0;
  }

  Int ans=-INF;
  {
    for(Int i=0;i<n;i++){
      Int cur=i;
      Int res=0;
      for(Int j=0;j<(n*2);j++){
        cur=ps[cur];
        res+=cs[cur];
        chmax(ans,res);
      }
    }
  }

  for(Int i=0;i<n;i++){
    Int stp=k;
    Int res=0;
    Int cur=i;

    vector<Int> used(n,-1);
    Int len=0;
    for(Int j=0;;j++){
      // cout<<cur<<endl;
      if(~used[cur]){
        len=j-used[cur];
        break;
      }
      used[cur]=j;
      cur=ps[cur];
      res+=cs[cur];
      chmax(ans,res);
    }
    // cout<<":"<<len<<endl;

    res=0;
    cur=i;

    assert(stp>=used[cur]);
    stp-=used[cur];
    for(Int j=0;j<used[cur];j++){
      cur=ps[cur];
      res+=cs[cur];
      chmax(ans,res);
    }
    Int pre=cur;

    Int sum=0;
    for(Int j=0;j<len;j++){
      cur=ps[cur];
      sum+=cs[cur];
    }
    assert(cur==pre);

    // cout<<stp<<':'<<len<<endl;
    Int mv=(stp/len-1);
    res+=mv*sum;
    stp-=mv*len;

    for(Int i=0;i<stp;i++){
      cur=ps[cur];
      res+=cs[cur];
      chmax(ans,res);
    }
  }
  cout<<ans<<newl;
  return 0;
}


Measured memory_bytes: 3764
#include <stdio.h>

int
main(int argc, char *argv[])
{
  char a[50][51], b[50][51];
  int n, m;
  scanf("%d %d", &n, &m);
  for(int i = 0; i < n; i++) scanf("%s", a[i]);
  for(int j = 0; j < m; j++) scanf("%s", b[j]);

  int l = n - m; int cnt; char flag = 0;
  for(int i = 0; i <= l; i++){
    for(int j = 0; j <= l; j++){
      cnt = 0;
      for(int x = 0; x < m; x++){
	for(int y = 0; y < m; y++){
	  if(b[x][y] == a[i + x][j + y]) cnt++;
	}
      }
      if(cnt == m * m){
	flag = 1;
	break;
      }
    }
    if(flag == 1) break;
  }

  if(flag == 0) printf("No\n");
  else printf("Yes\n");

  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstdlib>
using namespace std;
long long n;
long long a,b,c,d;
int main()
{
	scanf("%lld%lld%lld%lld%lld",&n,&a,&b,&c,&d);
	if(a>b)swap(a,b);
	n--;
	if(d*n+a<b)
	{
		printf("NO");
		return 0;
	}
	if(a==b)
	{
		if(n&1)
		{
			if(!c)printf("YES");
			else printf("NO");
		}
		else printf("YES");
		return 0;
	}
	for(long long i=0;i<=n;i++)
	{
		if(a+i*c-(n-i)*d<=b && a+i*c-(n-i)*c>=b || a+a+i*d-(n-i)*d<=b && a+i*d-(n-i)*c>=b || a+i*c-(n-i)*d<=b && a+i*d-(n-i)*d>=b || a+i*c-(n-i)*c<=b && a+i*d-(n-i)*c>=b)
		{
			printf("YES");
			return 0;
		}
	}
	printf("NO");
	return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        s: chars,
    }
    if s.len() == 2 {
        if s[0] == s[1] {
            println!("1 2");
        } else {
            println!("-1 -1");
        }
        return;
    }

    for i in 0..s.len() - 2 {
        let mut acc = vec![];
        for j in 0..3 {
            acc.push(&s[i + j]);
        }
        acc.sort();
        acc.dedup();
        if acc.len() == 2 {
            return println!("{} {}", i + 1, i + 3);
        }
    }
    println!("-1 -1");
}


Measured memory_bytes: 4352