akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n;
long long L, T, ans[N];

struct Ant {
    long long x, d;
    long long ed;
    bool operator < (const Ant &rhs) const {
        return ed < rhs.ed;
    }
}a[N];

int main() {
    scanf("%d%lld%lld", &n, &L, &T);
    long long cnt = 0;
    for(int i = 0; i < n; i++) {
        scanf("%lld%lld", &a[i].x, &a[i].d);
        if(a[i].d == 1) cnt++;
        a[i].ed = a[i].x + T*(a[i].d == 1 ? 1LL : -1LL);
        a[i].ed = (a[i].ed%L + L)%L;
    }
    long long cross = 0;
    if(a[0].d == 1) {
        cross += T/L*(n-cnt)*2;
    }else {
        cross += T/L*cnt*2;
    }
    for(int i = 1; i < n; i++) {
        if(a[i].d == a[0].d) continue;
        long long dis;
        if(a[i].d == 2) dis = abs(a[i].x - a[0].x);
        else dis = abs(a[0].x - a[i].x + L);
        if(dis <= T%L*2) cross++;
        if(dis+L <= T%L*2) cross++;
    }
    cross %= n;
    if(a[0].d == 2) cross = (n-cross)%n;
    for(int i = 1; i < n; i++) {
        if(a[0].d == 2 && a[i].ed < a[0].ed) a[i].ed += L;
        if(a[0].d == 1 && a[i].ed <= a[0].ed) a[i].ed += L;
    }
    sort(a+1, a+n);
    for(int i = 0; i < n; i++) {
        ans[(cross+i)%n] = a[i].ed%L;
    }
    for(int i = 0; i < n; i++) {
        printf("%d\n", (int)ans[i]);
    }
    return 0;
}


Measured memory_bytes: 4352
#include<iostream>
using namespace std;
int main(){
    int n, s[14], h[14], c[14], d[14], i;
    char ch;
    //scanf("%d", &n);
    cin>> n;
    for(i = 0;i<14;i++){s[i] = h[i] = c[i] = d[i] = 0;}

    while(n--){
        cin>> ch >> i;
        if(ch == 'S') s[i] = 1;
        if(ch == 'H') h[i] = 1;
        if(ch == 'C') c[i] = 1;
        if(ch == 'D') d[i] = 1;
    }
    for(i = 1;i<14;i++){
        if(s[i] != 1) cout<< "S " << i << endl;
    }
    for(i = 1;i<14;i++){
        if(h[i] != 1) cout<< "H " << i << endl;
    }
    for(i = 1;i<14;i++){
        if(c[i] != 1) cout<< "C " << i << endl;
    }
    for(i = 1;i<14;i++){
        if(d[i] != 1) cout<< "D " << i << endl;
    }
return 0;
}



Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P  = pair<int, int>;
int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int& i : a) cin >> i;
    for (int t = 0; t < min(50, k); ++t) {
        vector<int> b(n, 0);
        for (int i = 0; i < n; ++i) {
            ++b[max(0, i - a[i])];
            if (i + a[i] + 1 < n) --b[i + a[i] + 1];
        }
        for (int i = 1; i < n; ++i) b[i] += b[i - 1];
        a = b;
    }
    for (int i : a) cout << i << " ";
    return 0;
}


Measured memory_bytes: 4844
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

double todeg(double ang){
    return ang * 180 / pi;
}

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

    double a, b, x; cin>>a>>b>>x;
    double ans;
    if(a * a * b / 2 > x){
        double tan = b * b * a / 2 / x;
        double theta = atan(tan);
        ans = todeg(theta);
    }
    else{
        double tan = (2 * a * a * b - 2 * x) / a / a / a;
        double theta = atan(tan);
        ans = todeg(theta);
    }

    printf("%.10f\n", ans);

    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<cassert>
#include<cassert>
#include<unordered_map>
#include<unordered_set>
#include<functional>
#include<queue>
#include<stack>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<sstream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<numeric>
#include<random>
#include<chrono>
#include<bitset>
using namespace std;

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define xx first
#define yy second
#define sz(x) (int)(x).size()
#define gc getchar
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mp make_pair

#ifndef ONLINE_JUDGE
#  define LOG(x) (cerr << #x << " = " << (x) << endl)
#else
#  define LOG(x) ((void)0)
#endif

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const double PI=acos(-1);
const ll INF = 1LL<<62;
const ll MINF = -(1LL<<62);

template<typename T> T getint() {
	T val=0;
	char c;
	
	bool neg=false;
	while((c=gc()) && !(c>='0' && c<='9')) {
		neg|=c=='-';
	}

	do {
		val=(val*10)+c-'0';
	} while((c=gc()) && (c>='0' && c<='9'));

	return val*(neg?-1:1);
}

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); uniform_int_distribution<int>(0, n-1)(rng)

const ll mod=998244353;
ll fp(ll a, ll b) {
	if(b==0) return 1;
	ll fele=fp(a,b/2);
	ll ans=fele*fele%mod;
	if(b&1) ans=(a*ans)%mod;
	
	return ans;
}

ll fact[200001];
ll ifact[200001];

ll choose(ll a, ll b) {
	return fact[a]*ifact[b]%mod*ifact[a-b]%mod;
}


int main() {
	IO;
	fact[0]=1;
	ifact[0]=1;
	for(ll i=1;i<=200000;++i) {
		fact[i]=fact[i-1]*i%mod;
		ifact[i]=fp(fact[i], mod-2);
	}
	
	ll n,m,k;
	cin>>n>>m>>k;
	
	ll ans=0;
	for(int i=0;i<=k;++i) {
		ll diff=n-1-i;
		ans+=m*fp(m-1, diff)%mod*choose(n-1,i)%mod;

		ans%=mod;
	}
	
	if(ans<0) ans+=mod;
	cout<<ans<<"\n";
	return 0;
}


Measured memory_bytes: 6756
//includes
#include<iostream>
#include<vector>
#include<set>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<map>
#include<queue>
#include<iomanip>
#include<numeric>
#include<assert.h>
#include<cstring>
#include<unordered_map>
#include<bitset>

//macros and consts
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(),(a).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define FORE(i,a) for(auto &i : a)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define accm accumulate
#define Fi first
#define Se second
#define INF 1e9
#define llINF (1LL<<60)
#define mINF -1e9
#define mllINF -(1LL<<60)
#define endl "\n"
#define CONT continue
#define BRK break
#define modulo(n, m) (((n)%(m)+(m))%m)
#define int long long
//shorter types
using namespace std;
using ll = long long;
using vi = std::vector<int>;
using vc = std::vector<char>;
using vll = std::vector<long long>;
using vs = std::vector<string>;
using Mi = map<int,int>;
using Mll = map<ll,ll>;
using UMi = unordered_map<int,int>;
using UMll = unordered_map<ll,ll>;
using Pi = pair<int,int>;
using Pll = pair<ll,ll>;
using vPi = vector<Pi>;
using vPll = vector<Pll>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;
using pqgi = priority_queue<int,vector<int>,greater<int>>;
using pqsi = priority_queue<int,vector<int>,less<int>>;
using pqgll = priority_queue<int,vector<int>,greater<int>>;
using pssll = priority_queue<int,vector<int>,less<int>>;
template<class T>
using vec = vector<T>;

//here begins your code
signed main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  int N;
  cin >> N;
  vector<pair<int,int>> jobs;
  jobs.resize(N);

  for(int i = 0 ; i < N ; i++){
  	int X,L;
  	cin >> X >> L;
  	int s = X - L;
  	int f = X + L;
	jobs[i] = make_pair(f,s);
  }

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

  int g_f = mllINF;
  int ok = 0;
  for(int i = 0 ; i < N ; i++){
  	if(jobs[i].second >= g_f){
  		g_f = jobs[i].first;
  		ok++;
  	}
  }

  cout << ok << endl;

  //check types
  //do not eb if you resize
  //resize before you access by idx
  return 0;
} 

Measured memory_bytes: 1792
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> h(n);
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }
    int cnt = 0;
    int i = 0;
    while (i < n) {
        if (h[i] == 0) {
            i++;
            continue;
        }
        int j = i + 1;
        while (j < n && h[j]> 0) {
            j++;
        }
        for (int k = i; k < j; k++)
            h[k]--;
        cnt++;


    }
    cout << cnt << endl;
    return 0;
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int MOD = 1000000009;
const long long INF = 1LL << 60;

int main() {
    int N; 
    cin >> N;
    int abc[100010][3]{};
    for (int i = 0; i < N; ++i) for (int j = 0; j < 3; ++j) cin >> abc[i][j];
    int dp[100010][3]{};
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < 3; ++j) {
            for (int k = 0; k < 3; ++k) {
                if (j == k) continue;
                dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + abc[i][k]);
            }
        }
    }
    int res = 0;
    for (int i = 0; i < 3; ++i) res = max(res, dp[N][i]);
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 5968
N,W= map(int,input().split())
w=[]
v=[]
for  i in range(N):
    a,b=map(int,input().split())
    w.append(a)
    v.append(b)

dp =[ [0]*(W+1) for _ in range(N+1) ]

for i in range(N):
    for  j in range(W+1):
        dp[i+1][j]=dp[i][j]
        if j-w[i]>=0:
            dp[i+1][j]= max(dp[i][j] , dp[i][j-w[i]]+v[i])

print(dp[N][W])

Measured memory_bytes: 120172
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;

#define in(x) cin >> x
#define out(x) cout << x << endl

#define PI acos(-1)
#define pp push_back

#define Yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define No cout << "No" << endl
#define NO cout << "NO" << endl

#define vec2(type) vector<vector<type>>
#define vec3(type) vector<vector<vector<type>>>

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

#define Tcmp(X, Y) (abs(aryvec[i]->x) == X && abs(aryvec[i]->y) == Y)

template<typename T> void input(T *data, int n){
	For(i, n){
		cin >> data[i];
	}
}

template<typename T> void sort(vector<T> &ary){
	sort(ary.begin(), ary.end());
}

template<typename T> void rsort(vector<T> &ary){
	sort(ary.rbegin(), ary.rend());
}

void rstring(string &str){
	string temp = str;

	For(i, (int)str.size()){
		str[i] = temp[(str.size() - 1) - i];
	}
}

struct Vec{
	int x, y;
	Vec():
	x(0), y(0){}
};

int main(){

	string s;
	in(s);

	int miss = 0;

	//0101...基準
	For(i, (int)s.size()){
		if(i % 2 == 0){
			if(s[i] == '1'){
				miss++;
			}
		}
		else{
			if(s[i] == '0'){
				miss++;
			}
		}
	}

	if(miss > (int)s.size() - miss){
		miss = (int)s.size() - miss;
	}

	out(miss);

	return 0;

}

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

signed main(void)
{
	int n, k;
	cin >> n >> k;
	vector<int> cnt(26, 0);
	rep(i, n) 
	{
		string p;
		cin >> p;
		cnt[p[0] - 'A']++;
	}
	sort(cnt.rbegin(), cnt.rend());
	int ans = 0;
	while(true)
	{
		rep(i, k)
		{
			if (cnt[i] == 0)
			{
				cout << ans << endl;
				return 0;
			}
			cnt[i]--;
		}
		ans++;
		sort(cnt.rbegin(), cnt.rend());
	}
	cout << ans << endl;
	return 0;
}


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

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

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

class Progaram
{
    static void Main(String[] args)
    {
        var sl = Console.ReadLine().Split('/').Select(x => int.Parse(x)).ToArray();
        
        if (sl[1] > 4)
        {
            Console.WriteLine("TBD");
        }
        else if (sl[1] < 4)
        {
            Console.WriteLine("Heisei");
        }
        else
        {
            if (sl[2] > 30)
            {
                Console.WriteLine("TBD");
            }
            else
            {
                Console.WriteLine("Heisei");
            }
        }
    }
}


Measured memory_bytes: 28240
#!/usr/bin/python3
# -*- coding:utf-8 -*-

def main():
  n = int(input())
  Hs = list(map(int, input().strip().split()))
  count = 0
  maximum = 0
  for i in range(1, n):
    if Hs[i-1] < Hs[i]:
      if maximum < count:
        maximum = count
      count = 0
      continue
    count += 1
  print(max(maximum, count))
  
if __name__=='__main__':
  main()



Measured memory_bytes: 14224
package main

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

var (
	readString func() string
	readBytes  func() []byte
	stdout     *bufio.Writer
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func min64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func max64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func abs64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func gcd64(a, b int64) int64 {
	if b == 0 {
		return a
	}
	return gcd64(b, a%b)
}

// readString() string
// readInt() int
// readInt64() int64
// readFloat64() float64

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

func main() {
	defer stdout.Flush()
	A:=readInt()
	B:=readInt()
	C:=readInt()
	if C <= A+B{
		println("Yes")
	} else{
		println("No")
	}
}

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


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

int main() {
    string o, e, ans;
    cin >> o >> e;
    int n = o.size() + e.size();
    for(int i=0;i<n;i++){
        if(i%2 == 0) ans.push_back(o[i/2]);
        else ans.push_back(e[i/2]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
/*

road to the IOI
&author : kair011a_

*/
#include <bits/stdc++.h>

#define PB push_back
#define F first
#define S second
#define ll long long
#define lb lower_bound
#define ub upper_bound
#define all(x) (x).begin(), (x).end()

#define open(name) \
    freopen(name".in", "r", stdin); \
    freopen (name".out", "w", stdout);

using namespace std;

const int N = 1e5 + 7;
const int logg = 20;
const int INF = 1e9 + 7;
const int p = 31;

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

int n, k;
int a[N], dp[N], ans[N];

void solve() {
    cin >> n >> k;
    for (int i = 1; i <= n; i ++) {
        cin >> a[i];
        dp[i] = INF;
    }
    dp[0] = 0;
    dp[1] = 0;
    for (int i = 2; i <= n; i ++) {
        for (int j = 1; j <= k; j ++) {
            if (i - j > 0) {
                int q1 = abs(a[i] - a[i - j]) + dp[i - j];
                dp[i] = min(q1, dp[i]);
            } else {
                break;
            }
        }
    }
    cout << dp[n];
}

main() {
    ios::sync_with_stdio(false);
    //open("LOSER");
    solve();
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int d = scan.nextInt();
		int x = scan.nextInt();
		int[] a = new int[n];
		for(int i=0;i<n;i++) {
			a[i]=scan.nextInt();
		}
		int choco = 0;
		for(int i=0;i<n;i++) {
			choco =choco+ d/a[i];
			if(d%a[i]!=0) {
				choco++;
			}
		}
		System.out.println(x+choco);
	}

}


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

using namespace std;

int gcd(int a, int b)
{
	return b ? gcd(b, a % b) : a;
}

void solve()
{
	int n;
	cin >> n;
	vector<int> w(n);
	for(auto&& i : w)
	{
		cin >> i;
	}
	int ans = accumulate(begin(w), end(w), 0);
	for(int i = 1; i < n; i++)
	{
		ans = min(ans, abs(accumulate(begin(w), begin(w) + i, 0)
			- accumulate(begin(w) + i, end(w), 0)));
	}
	cout << ans << "\n";
}

int main()
{
	solve();
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case, unused)]

use std::cmp::*;
use std::collections::*;
use std::ops::*;

macro_rules! eprint {
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = write!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! eprintln {
	() => { eprintln!(""); };
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = writeln!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! dbg {
	($v:expr) => {{
		let val = $v;
		eprintln!("[{}:{}] {} = {:?}", file!(), line!(), stringify!($v), val);
		val
	}}
}

macro_rules! mat {
	($($e:expr),*) => { Vec::from(vec![$($e),*]) };
	($($e:expr,)*) => { Vec::from(vec![$($e),*]) };
	($e:expr; $d:expr) => { Vec::from(vec![$e; $d]) };
	($e:expr; $d:expr $(; $ds:expr)+) => { Vec::from(vec![mat![$e $(; $ds)*]; $d]) };
}

macro_rules! ok {
	($a:ident$([$i:expr])*.$f:ident()$(@$t:ident)*) => {
		$a$([$i])*.$f($($t),*)
	};
	($a:ident$([$i:expr])*.$f:ident($e:expr$(,$es:expr)*)$(@$t:ident)*) => { {
		let t = $e;
		ok!($a$([$i])*.$f($($es),*)$(@$t)*@t)
	} };
}

pub fn readln() -> String {
	let mut line = String::new();
	::std::io::stdin().read_line(&mut line).unwrap_or_else(|e| panic!("{}", e));
	line
}

macro_rules! read {
	($($t:tt),*; $n:expr) => {{
		let stdin = ::std::io::stdin();
		let ret = ::std::io::BufRead::lines(stdin.lock()).take($n).map(|line| {
			let line = line.unwrap();
			let mut it = line.split_whitespace();
			_read!(it; $($t),*)
		}).collect::<Vec<_>>();
		ret
	}};
	($($t:tt),*) => {{
		let line = readln();
		let mut it = line.split_whitespace();
		_read!(it; $($t),*)
	}};
}

macro_rules! _read {
	($it:ident; [char]) => {
		_read!($it; String).chars().collect::<Vec<_>>()
	};
	($it:ident; [u8]) => {
		Vec::from(_read!($it; String).into_bytes())
	};
	($it:ident; usize1) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1
	};
	($it:ident; [usize1]) => {
		$it.map(|s| s.parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1).collect::<Vec<_>>()
	};
	($it:ident; [$t:ty]) => {
		$it.map(|s| s.parse::<$t>().unwrap_or_else(|e| panic!("{}", e))).collect::<Vec<_>>()
	};
	($it:ident; $t:ty) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<$t>().unwrap_or_else(|e| panic!("{}", e))
	};
	($it:ident; $($t:tt),+) => {
		($(_read!($it; $t)),*)
	};
}

pub fn main() {
	let _ = ::std::thread::Builder::new().name("run".to_string()).stack_size(32 * 1024 * 1024).spawn(run).unwrap().join();
}

const MOD: usize = 1_000_000_007;
const INF: i64 = std::i64::MAX/2;

fn solve() {
	let (a,b,c,d) = read!(i64,i64,i64,i64);
	let mut x = a;
	let mut y = c;
	let mut turn = 0;	
	let mut ans = 0;
	loop {
		if turn==0 {
			y -= b;
			if y<=0 {
				ans = 0;
				break;
			}
		}
		else{
			x -= d;
			if x<=0 {
				ans = 1;
				break;
			}
		}
		turn = 1 - turn;
	}
	if ans==0 {
		println!("Yes");
	}
	else {
		println!("No");
	}
}

fn run() {
    solve();
}


Measured memory_bytes: 2188
/*
title:C - Strange Bank

url:https://abc099.contest.atcoder.jp/tasks/abc099_c

再帰で解く
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define INF 1000000007

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

//残金leftを消費するのに必要な最小の枚数を返す関数
int solve(int left)
{
    if (left < 9)
    {
        if (left < 6)
            return left;
        return 1 + (left - 6);
    }

    int dcr_nine = 1;
    while (left >= dcr_nine * 9)
    {
        dcr_nine *= 9;
    }

    int dcr_six = 1;
    while (left >= dcr_six * 6)
    {
        dcr_six *= 6;
    }

    return min(1 + solve(left - dcr_six), 1 + solve(left - dcr_nine));
}

int main()
{
    int n;
    cin >> n;
    cout << solve(n) << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
B_list = list(map(int, input().split()))

A_list = [0] * N
A_list[0] = B_list[0]

if len(B_list) >=1:
    for i in range(N-2):
        A_list[i+1] = min(B_list[i], B_list[i+1])

    A_list[N-1] = B_list[N-2]
else:
    A_list[1] = B_list[0]

print(sum(A_list))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define rnfor(i,a,b) for(ll (i) = (a) - 1; (i) >= (b); --(i))
#define ll long long
#define mod (1000000007)
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()

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

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

ll factorial(ll n){
    ll t = 1;
    rep1(i, n)t *= i;
    return t;
}

ll combinations(ll n, ll k) {
    ll r = 1;
    rep1(i, k)r = r * n-- / i;
    return r;
}

int main(){
    double sum[1001];
    sum[0] = 0;
    rep1(i, 1000)sum[i] = sum[i - 1] + i;
    
    ll n,k;
    cin >> n >> k;
    vector<double> cnt(n);
    rep0(i, n){
        double p;
        cin >> p;
        if(i != 0)cnt[i] = cnt[i - 1] + sum[(int)p] / p;
        else cnt[i] = sum[(int)p] / p;
    }
    
    double ans = 0;
    nfor(i, k - 1, n){
        if(i >= k)ans = max(ans,cnt[i] - cnt[i - k]);
        else ans = cnt[i];
    }
    printf("%.9f",ans);
    return 0;
}


Measured memory_bytes: 1792
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Apolloliu
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

using namespace std;

void get() {

}

int sum[510][510];
typedef pair<int,int> pii;

class DAtCoderExpress2 {
public:
	void solve(std::istream& in, std::ostream& out) {
		int n, m, q, x, y;
		in >> n >> m >> q;
		memset(sum, 0, sizeof(sum));

		for (int i = 0; i < m; ++i) {
			in >> x >> y;
			sum[x][y] ++;
		}

		for (int i = 1; i <= n ; ++i) {
			for (int j = 1; j <= n ; ++j) {
				sum[i][j] += sum[i][j-1];
				sum[i][j] += sum[i-1][j];
				sum[i][j] -= sum[i-1][j-1];
			}
		}
		for (int i = 0; i < q; ++i) {
			in >> x >> y;
			out << sum[y][y] - sum[y][x-1] - sum[x-1][y] + sum[x-1][x-1] << '\n';
		}
	}
};


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	DAtCoderExpress2 solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

Measured memory_bytes: 1920
s = str(input())
n = int(input())
m = []

for i in range(n):
    m = list(input().split())
    i1 = int(m[1])
    i2 = int(m[2])+1
    if m[0] == "replace":
        s = s[0:i1] + m[3] + s[i2::]
        # print(s)
    elif m[0] == "reverse":
        sr = s[i1:i2]
        sr = sr[::-1]
        s = s[0:i1] + sr + s[i2::]
        # print(s)
    elif m[0] == "print":
        print(s[i1:i2])




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

int main () {
  int N , Q ;
  int line[N] ;
  line[0] == 0 ;
  cin >> N >> Q ;
  string A ;
  cin >> A ;
  for(int i = 1 ; i < N ; i++ ){
    if( A.at(i-1) == 'A' && A.at(i) == 'C' ){
      line[i] = line[i-1] + 1 ;
    } else {
      line[i] = line[i-1] ;
    }
  }
  for(int j = 0 ; j < Q ; j++ ){
    int a , b ;
    cin >> a >> b ;
    cout << line[b-1] - line[a -1 ] << endl ;
  }
  //for(int i = 0 ; i < N ; i++ ) cout <<  line[i] ;
}

Measured memory_bytes: 3200
import sys
k = int(input())
a, b = list(map(int, input().split()))
if a == b:
    if a%k == 0:
        print('OK')
    else:
        print('NG')
    sys.exit()
for i in range(a,b+1):
    if i%k == 0:
        print('OK')
        sys.exit()
print('NG')

Measured memory_bytes: 9188
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

ll MOD;

// DPの更新
vector<ll> matmul(vector<ll> &dp, vector<vector<ll>> &mt, int m){
    vector<ll> ret(m,0);
    rep(i,m){
        rep(j,m){
            ret[i] += mt[i][j] * dp[j] % MOD;
            ret[i] %= MOD;
        }
    }
    return ret;
}
// 遷移行列の更新
vector<vector<ll>> update_matmul(vector<vector<ll>> &mt, int m){
    vector<vector<ll>> ret(m, vector<ll>(m,0));
    rep(i,m){
        rep(j,m){
            rep(k,m){
                ret[i][j] += mt[i][k] * mt[k][j] % MOD;
                ret[i][j] %= MOD;
            }
        }
    }
    return ret;
}

void matpow(vector<ll> &dp, vector<vector<ll>> &mt, int m, ll k){
    while(k){
        if(k & 1) dp = matmul(dp, mt, m);
        mt = update_matmul(mt, m);
        k /= 2;
    }
}


int main() {
    ll l, a, b;
    cin >> l >> a >> b >> MOD;

    ll s[19], g[19];
    ll ten[19];
    rep(i,19){
        s[i] = 0;
        g[i] = 0;
        if(i == 0) ten[i] = 1;
        else ten[i] = ten[i-1] * 10;
    } 

    srep(i,1,19){
        s[i] = g[i-1];
        if(s[i] == l){
            g[i] = l;
        }else if(a >= ten[i]){
            g[i] = 0;
        }else if(a + b*(l-1) < ten[i-1]){
            g[i] = l;
        }else if(a+b*s[i] >= ten[i]){
            g[i] = s[i];
        }else{
            ll x = s[i];
            ll y = l;
            while(x + 1 < y){
                ll m = (x + y) / 2;
                if(a+b*m < ten[i]){
                    x = m;
                }else{
                    y = m;
                }
            }
            g[i] = y;
        }
    }


    ll ans = 0;

    /*
    rep(i,19){
        cout << s[i] << ' ' << g[i] << endl;
    }
    */

    srep(i,1,19){
        int m = 3;
        ll k = g[i] - s[i];
        if(k == 0)continue;

        vector<ll> dp(m);
        dp[0] = ans % MOD;
        dp[1] = (a % MOD + ((b % MOD) * (s[i] % MOD)) % MOD) % MOD;
        dp[2] = b % MOD;

        vector<vector<ll>> mt(m,vector<ll>(m));
        mt[0][0] = ten[i] % MOD; mt[0][1] = 1; mt[0][2] = 0;
        mt[1][0] = 0; mt[1][1] = 1; mt[1][2] = 1;
        mt[2][0] = 0; mt[2][1] = 0; mt[2][2] = 1; 

        matpow(dp, mt, m, k);
        ans = dp[0];
    }

    ans = (ans + MOD) % MOD;
    cout << ans << endl;
    return 0;
}
 
 


Measured memory_bytes: 256
#include "bits/stdc++.h"
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2709&lang=jp
//references:http://logfiles.hatenablog.com/entry/2016/12/26/020104
using namespace std;
typedef long long ll;
#define INF (1<<30)

/*
	dp[j(bit)??????????????¨?±????????????????] = ????????????????????????(min)
	dp[0] = Answer

	j???????????????????????????????????????a???????????????????????????????§????????????¶???j'????§??????????
	?§??????????j'???j??§???????°???????+1???????????§???????????°??´??°(bfs)
	????????????j'=0??¨?????????dp[0]???answer??¨??????
*/
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	int N, M, K; cin >> N >> M >> K;

	//??????????????\????§????
	vector<int> D(N, -1);	//????????¨?±? := 0??\???
	vector<int> v_n(M);		//i???????????????????????????????????¨?±??????????
	int v_count = 0;
	for (int i = 0;i < M;i++) {
		int d; cin >> d; d--; D[d] = v_count;
		v_n[v_count++] = d;
	}

	//Graph????????????
	vector<vector<int>> Graph(N, vector<int>(K));
	for (int i = 0; i < N;i++) {
		for (int j = 0; j < K;j++) {
			cin >> Graph[i][j]; Graph[i][j]--;
		}
	}

	//dp????????????
	vector<int> dp(1 << M,INF);
	dp[(1 << M) - 1] = 0;  // ???????????¨?±??????????????????¶???

	//bfs ????????????bit??????????????¨??????)
	queue<int> q;
	q.push((1 << M) - 1); // ????????¶???

	//bfs???????????????
	while (!q.empty()) {
		int n = q.front(); q.pop();

		//k?????????????????¨??????????????????
		for (int k = 0;k < K;k++) {
			int n_ = n; //????????¨?±?????????£????????????????¨???¶
			int next_n = 0; // ?¬???¶???????¨???¶

			//??????????????¨?±??????¢?´¢
			for (int b = 0; b < M;b++) {
				//??????p?????????????????¨?±??????????????????°
				if ((1 << b)&n_) {
					n_ &= ~(1 << b); //p?????????????????????0?????????

					int next_room = Graph[v_n[b]][k]; // p???????????????k???????????????????????????????¬??????¨?±?
					
					//???????¬??????¨?±????????????¨?±??????£??????
					if (D[next_room] != -1) {
						next_n |= (1 << D[next_room]);
					}
				}
			}

			if (dp[next_n] > dp[n] + 1) {
				dp[next_n] = dp[n] + 1;
				q.push(next_n);
			}
		}
	}
	cout << dp[0] << endl;
}

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

int main() {
    int n;
    string s;
    cin >> n >> s;
    rep(i,s.size()) {
        char now = s[i];
        now += n;
        if(now > 'Z') now -= 26;
        s[i] = now;
    }
    cout << s << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define Int int64_t
#define dump(x) cout << (x) << endl
#define fi first
#define se second
Int mod = 1e9+7;
Int INF = 1e18;
double EPS = 0.00000001;
//Int mod = 1e6+3;

Int res = INF;

int main() {
    Int n;
    cin >> n;
    vector<Int> a(n);
    for (Int i = 0; i < n; i++) {
        cin >> a[i];
    }
    if (a.back() != 2) {
        dump(-1);
        return 0;
    }
    Int ma, mi;
    ma = mi = 2;
    for (Int i = n - 2; i >= 0; i--) {
        Int pma = ma;
        Int pmi = mi;
        ma = (Int)floor((double)(ma + a[i + 1] - 1) / (double)a[i]) * a[i];
        mi = (Int)ceil((double)mi / (double)a[i]) * a[i];
        if (!(pmi <= ma && ma <= pma + a[i + 1] - 1) && !(pmi <= mi && mi <= pma + a[i + 1] - 1)) {
            dump(-1);
            return 0;
        }
        if (!(pmi <= ma && ma <= pma + a[i + 1] - 1)) {
            ma = mi;
        }
        if (!(pmi <= mi && mi <= pma + a[i + 1] - 1)) {
            mi = ma;
        }
        //cout << mi << " " << ma << endl;
    }
    cout << mi << " " << ma + a.front() - 1 << endl;
    return 0;
}

Measured memory_bytes: 1024
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), m = sc.nextInt();
		int[] roads = new int[n];
		int a, b;
		for(int i = 0; i < m; i++) {
			a = sc.nextInt();
			b = sc.nextInt();
			roads[a - 1]++;
			roads[b - 1]++;
		}
		for(int j : roads) {
			System.out.println(j);
		}
	}
}

Measured memory_bytes: 22736
#include<iostream> 
#include<string>
#include<bits/stdc++.h>
using namespace std;
int main(){	
	int n;
	cin>>n;
	long long a[n];
	long long mx=-1000000000;
	for(int i=0;i<n;i++){
		cin>>a[i];
		mx=max(mx,a[i]);
	}
	long long b=a[0];
	for(int i=1;i<n;i++){
		b=b/__gcd(b,a[i])*a[i];
	}
	long long sum=0;
	for(int i=0;i<n;i++){
		sum+=b/a[i];
	}
	double ans=b;
	ans=ans/sum;
	cout<<ans;
    return 0;
} 

Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include <iostream> 
#include <algorithm> 
#include<string>
#include<queue>
#include<utility>
#include<fstream>
#include<vector>
#include <map>
#define I int
#define S(a) scanf("%d",&a)
#define S2(a,b) scanf("%d%d",&a,&b)
#define P(a) printf("%d\n",a)
#define PL(a) printf("%lld\n",a)
#define PT(t) printf("Case %d: ",t)
#define PB(a) push_back(a)
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define ll long long 
using namespace std;
#define mx 5000004
#define md 2000000000000000000ll
typedef pair<int, int >P;
typedef vector<ll>V;

////////define value/////
bool vis[mx+2];

int main(){

    for(int i=2;i<=mx;i++){
        if(!vis[i]){
            for(int j=i*2;j<=mx;j+=i)vis[j]=1;
        }
    }

    int x;
    cin>>x;
    for(int i=x;i<=mx;i++){
        if(!vis[i]){
            cout<<i<<endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
#define N 100010
using namespace std;

#define MOD 1000000007
#define LL long long

int a[N], b[N];
int aa[N][2], bb[N][2];

int ll(int i, int f) {
    return f ? aa[i][1] - aa[i][0] + 1 : bb[i][1] - bb[i][0] + 1;
}
int cross(int i) {
    if( ll(i, 0) + ll(i, 1) > max(aa[i][1], bb[i][1]) - min(aa[i][0], bb[i][0]) + 1) {
        return ll(i, 0) + ll(i, 1) - (max(aa[i][1], bb[i][1]) - min(aa[i][0], bb[i][0]) + 1);
    } else {
        return 0;
    }
}
int main() {
    int n;
    while(cin >> n) {
        for(int i = 0; i < n; ++i) {
            cin >> a[i];
        }
        for(int i = 0; i < n; ++i) {
            cin >> b[i];
        }
        for(int i = 0; i < n; ++i) {
            if(i == 0 || a[i] > a[i-1]) {
                aa[i][0] = aa[i][1] = a[i];
            } else {
                aa[i][0] = 1;
                aa[i][1] = a[i];
            }
        }
        
        for(int i = n-1; i >= 0; --i) {
            if(i == n-1 || b[i] > b[i+1]) {
                bb[i][0] = bb[i][1] = b[i];
            } else {
                bb[i][0] = 1;
                bb[i][1] = b[i];
            }
        }
        LL re = 1;
        for(int i = 0; i < n; ++i) {
            re *= cross(i);
            re %= MOD;
        }
        cout << re << endl;
    }
    return 0;
}

Measured memory_bytes: 2560
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn=1e5+10;
int n,k;
int head[maxn],v[maxn],a[maxn],mark[maxn],L[maxn],R[maxn];
struct Edge
{
    int v,nx;
}edge[maxn<<1];
int cnt;
bool flag;

void _init() {
    cnt=0;
    memset(head,-1,sizeof(head));
}

void add(int u,int v) {
    edge[cnt].v=v; edge[cnt].nx=head[u];
    head[u]=cnt++;
    edge[cnt].v=u; edge[cnt].nx=head[v];
    head[v]=cnt++;
}

void dfs1(int u,int fa) {
    if (mark[u] && (v[u]^(a[u]&1))) {
        flag=0; return;
    }
    for (int i=head[u];i!=-1;i=edge[i].nx) {
        int to=edge[i].v;
        if (to==fa) continue;
        v[to]=v[u]^1;
        dfs1(to,u);
    }
}

void dfs2(int u,int fa) {
    if (mark[u]) L[u]=R[u]=a[u];
    else L[u]=-1e9,R[u]=1e9;
    for (int i=head[u];i!=-1;i=edge[i].nx) {
        int to=edge[i].v;
        if (to==fa) continue;
        dfs2(to,u);
        L[u]=max(L[to]-1,L[u]);
        R[u]=min(R[to]+1,R[u]);
    }
    if (L[u]>R[u]) flag=0;
}

void dfs3(int u,int fa) {
    for (int i=head[u];i!=-1;i=edge[i].nx) {
        int to=edge[i].v;
        if (to==fa) continue;
        a[to]=a[u]+(a[u]+1>R[to]?-1:1);
        dfs3(to,u);
    }
}

int main() {
    _init();
    flag=1;
    scanf("%d",&n);
    int x,y;
    for (int i=1;i<n;i++) {
        scanf("%d%d",&x,&y);
        add(x,y);
    }
    scanf("%d",&k);
    for (int i=1;i<=k;i++) {
        scanf("%d%d",&x,&y);
        a[x]=y; mark[x]=1;
    }
    for (int i=1;i<=n;i++) {
        if (!mark[i]) continue;
        v[i]=a[i]&1; dfs1(i,i);
        break;
    }
    if (!flag) { puts("No"); return 0; }
    dfs2(1,1);
    if (!flag) { puts("No"); return 0; }
    L[1]+=((L[1]&1)^v[1]);
    a[1]=L[1];
    dfs3(1,1);
    puts("Yes");
    for (int i=1;i<=n;i++) printf("%d\n", a[i]);
    return 0;
}



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

int main(){

string S;
  cin >> S;
int N = S.size();  
bool ans = true;
int cnt = 0;
  
  if(S.at(0) != 'A'){
    cout << "WA" << endl;
    ans = false;
  }
  
  if((S.at(1) - '0' <= 48) || (S.at(1) - '0' >= 75)){
    cout << "WA" << endl;
    ans = false;
  }
  
    if((S.at(N - 1) - '0' <= 48) || (S.at(N - 1) - '0' >= 75)){
    cout << "WA" << endl;
    ans = false;
  }
  
    for(int i = 2;i < N - 1;i++){
    if(S.at(i) == 'C') cnt++;  
    else if((S.at(i) - '0' <= 48) || (S.at(i) - '0' >= 75)){
      ans = false;
      cout << "WA" << endl;
      break;
    }
    }    
 
  if((ans) && (cnt == 1)) cout << "AC" << endl; 
  else if((ans) && (cnt != 1)) cout << "WA" << endl;
  
return 0;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	vl v(n);
	rep(i,n)cin>>v[i];
	v.push_back(0);
	ll ans=0;
	bool ok=(v[0]==0);
	rrep(i,n){
		ok&=(v[i]>=v[i+1]-1);
		if(v[i]>v[i+1]-1)ans+=v[i];
	}
	cout<<(ok?ans:-1)<<endl;
}


Measured memory_bytes: 4864
def main():
  dm = []
  n, d = list(map(int,(input().split())))
  for i in range(n):
    x, y = list(map(int,(input().split())))
    dm.append((x**2+y**2)**0.5)
  
  print(len([i for i in dm if i<=d]))
      
if __name__ == '__main__':
  main()
  
  
            

Measured memory_bytes: 18512
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

signed main() {
  init();
  ll N, M, Q;
  cin >> N >> M >> Q;

  vector<vll> mat(N, vll(N, 0));
  rep(i, M) {
    ll l, r;
    cin >> l >> r;
    l--;
    r--;
    mat[l][r]++;
  }

  vector<vll> wa(N, vll(N, 0));
  rep(i, N) {
    rep(j, N) {
      if (i == 0 && j == 0) {
        wa[i][j] = mat[i][j];
        continue;
      }
      if (i == 0) {
        wa[i][j] = wa[i][j - 1] + mat[i][j];
        continue;
      }
      if (j == 0) {
        wa[i][j] = wa[i - 1][j] + mat[i][j];
        continue;
      }
      wa[i][j] = wa[i - 1][j] + wa[i][j - 1] - wa[i - 1][j - 1] + mat[i][j];
    }
  }

  rep(i, Q) {
    ll p, q;
    cin >> p >> q;
    p--;
    q--;

    if (p == 0 && q == 0) {
      COUT(wa[0][0]);
      continue;
    }

    if (p == 0) {
      COUT(wa[q][q]);
      continue;
    }

    ll a = wa[q][q];
    ll b = wa[q][p - 1];
    ll c = wa[p - 1][q];
    ll d = wa[p - 1][p - 1];
    ll ans = a - b - c + d;
    COUT(ans);
  }

  return 0;
}

Measured memory_bytes: 7100
def gcd_(a, b):
    if a < b:  a, b = b, a
    if b == 0:  return a
    return gcd_(b, a % b)

def gcd(l):
    ans = l[0]
    for i in l:  ans = gcd_(ans, i)
    return ans

N = int(input())
print(gcd(list(map(int,input().split()))))

Measured memory_bytes: 62704
module Main (main) where

import qualified Data.ByteString.Char8 as C8
import Data.Bool

main :: IO ()
main = do
  [s] <- readStrings
  print . showAnswer $ solve s

type Input  = (String)
type Output = Int

solve :: Input -> Output
solve = (700+) . (100*) . length . filter (=='o')

showAnswer :: Output -> Answer
showAnswer = Number

-- utils
readStrings :: IO [String]
readStrings = map C8.unpack . C8.words <$> C8.getLine

data Answer
  = YesNo Bool
  | YESNO Bool
  | AB Bool
  | Number Int
  | String String
  | Compare Ordering
  | Compare2 Ordering

instance Show Answer where
  show (YesNo b)    = bool "No" "Yes" b
  show (YESNO b)    = bool "NO" "YES" b
  show (AB b)       = bool "B"  "A" b
  show (Number i)   = show i
  show (String s)   = s
  show (Compare o)  = ordering "<" "=" ">" o
  show (Compare2 o) = ordering "Right" "Balanced" "Left" o

ordering :: a -> a -> a -> Ordering -> a
ordering lt eq gt o = case o of
  LT -> lt
  EQ -> eq
  GT -> gt

Measured memory_bytes: 380
/*
ID: espr1t
TASK: 
KEYWORDS: 
*/

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;
FILE* in = stdin; FILE* out = stdout;

const int MAX = 1024;

int main(void) {
	// in = fopen("A.in", "rt");
	
	int n;
	fscanf(in, "%d", &n);
	if (n == 25) {
	    fprintf(out, "Christmas\n");
    } else if (n == 24) {
        fprintf(out, "Christmas Eve");
    } else if (n == 23) {
        fprintf(out, "Christmas Eve Eve");
    } else {
        fprintf(out, "Christmas Eve Eve Eve");
    }
	
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<string>

int main(){
    std::string S;
    std::cin >> S;

    // 先頭が白
    int white_cost = 0;
    for(int i = 0; i < S.size(); i++){
        if(i % 2 == 0){
            if(S[i] != '1') white_cost++;
        }else{
            if(S[i] != '0') white_cost++;
        }
    }

    // 先頭が黒
    int black_cost = 0;
    for(int i = 0; i < S.size(); i++){
        if(i % 2 == 0){
            if(S[i] != '0') black_cost++;
        }else{
            if(S[i] != '1') black_cost++;
        }
    }

    std::cout << std::min(white_cost, black_cost) << std::endl;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string.h>
#include <algorithm>
using namespace std;


int main() {
    char s[200001];
    char t[200001];
    scanf("%s %s", s, t);
    int nCount = 0;
    for(int i=0; i<strlen(s); i++) {
        if(s[i] != t[i]) {
            nCount++;
        }
    }
    printf("%d\n", nCount);
    return 0;
}

Measured memory_bytes: 4208
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

const int inf = 0x3f3f3f3f;
const int N = 10414;
const int M = 40414;

struct Edge{
	int u, v, d, c;
	int next;
}edge[M];

int cnt, head[N];
int vis[N], dis[N], cost[N];
int op, tp, link[N<<1];

void add_edge(int u, int v, int d, int c);
void spfa(int n);

int main(){
	int n, m, i, u, v, d, c;
	while(~scanf("%d %d", &n, &m) && (n || m)){
		cnt = 0;
		memset(head, -1, sizeof(head));
		for(i = 0; i < m; i++){
			scanf("%d %d %d %d", &u, &v, &d, &c);
			add_edge(u, v, d, c);
			add_edge(v, u, d, c);
		}
		spfa(n);
	}
	return 0;
}
void add_edge(int u, int v, int d, int c){
	edge[cnt].u = u;
	edge[cnt].v = v;
	edge[cnt].d = d;
	edge[cnt].c = c;
	edge[cnt].next = head[u];
	head[u] = cnt++;
	return;
}
void spfa(int n){
	int i, u, v, d, c, sum;
	memset(vis, 0, sizeof(vis));
	memset(dis, inf, sizeof(dis));
	memset(cost, inf, sizeof(cost));
	op = tp = 0;
	vis[1] = 1, dis[1] = 0, cost[1] = 0;
	link[tp++] = 1;
	while(op < tp){
		u = link[op++];
		vis[u] = 0;
		for(i = head[u]; ~i; i = edge[i].next){
			v = edge[i].v, d = edge[i].d, c = edge[i].c;

			if(dis[v] > dis[u] + d || (dis[v] == dis[u] + d && cost[v] > c)){
				dis[v] = dis[u] + d;
				cost[v] = c;
				if(!vis[v]){
					vis[v] = 1;
					link[tp++] = v;
				}
			}
		}
	}
	sum = 0;
	for(i = 1; i <= n; i++){
		sum += cost[i];
	}
	printf("%d\n", sum);
	return;
}



Measured memory_bytes: 3684
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
using ll=long long;
#ifdef ONLINE_JUDGE
#define D(...)
#else
#define D(...)cerr<<__LINE__<<":"<<"["<<#__VA_ARGS__<<"]->",P(__VA_ARGS__)
#endif
void P(){cerr<<endl;} 
template<typename H,typename...T>void P(H h,T...t){cerr<<h<<" ";P(t...);}
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    int n;cin>>n;
    vector<int>v(n+1),diff;
    for(auto &x:v)
        cin>>x;
    sort(all(v));
    for(int i=0;i<n;++i){
        diff.emplace_back(v[i+1]-v[i]);
    }
    sort(all(diff));
    for(int i=diff[0];i>=1;--i){
        for(auto x:diff){
            if(x%i!=0)goto label;
        }
        return cout<<i,0;
        label:;
    }


    
}

Measured memory_bytes: 4208