akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

typedef vector<char> Array;
typedef vector<Array> Matrix;

struct Water {
  char x;
  char y;
  char dir;
  Water() {;}
  Water(int x, int y, int dir) : x(x), y(y), dir(dir) {;}
};

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

int maxDepth;
int calc(int depth, const Matrix &field);
int NextState(int depth, Matrix field, int sx, int sy) {
  if (field[sy][sx] != 4) {
    field[sy][sx]++;
  } else {
    field[sy][sx] = 0;
    vector<Water> waters;
    REP(dir, 4) {
      waters.push_back(Water(sx, sy, dir));
    }
    while (!waters.empty()) {
      vector<Water> nwaters;
      vector<char> end;
      FORIT(it, waters) {
        int nx = it->x + dx[(int)it->dir];
        int ny = it->y + dy[(int)it->dir];
        if (nx < 0 || nx >= 4 || ny < 0 || ny >= 4) { continue; }
        if (field[ny][nx] != 0) {
          field[ny][nx]++;
          if (field[ny][nx] == 5) {
            end.push_back((ny << 4) + nx);
          }
        } else {
          nwaters.push_back(Water(nx, ny, it->dir));
        }
      }
      FORIT(it, end) {
        int x = *it & 3;
        int y = *it >> 4;
        field[y][x] = 0;
        REP(dir, 4) {
          nwaters.push_back(Water(x, y, dir));
        }
      }
      waters = nwaters;
    }
  }
  return calc(depth + 1, field);
}

int calc(int depth, const Matrix &field) {
  {
    int sum = 0;
    REP(y, 4) REP(x, 4) { sum += field[y][x]; }
    if (sum == 0) { return depth; }
  }
  if (depth == maxDepth) { return 1 << 30; }
  int ret = 1 << 30;
  REP(y, 4) {
    REP(x, 4) {
      if (field[y][x] != 0) {
        ret = min(ret, NextState(depth, field, x, y));
        if (ret == maxDepth) { return ret; }
      }
    }
  }
  return ret;
}

int main() {
  while (true) {
    Matrix field(4, Array(4, 0));
    REP(y, 4) {
      REP(x, 4) {
        int v;
        if (scanf("%d", &v) <= 0) { return 0; }
        field[y][x] = v;
      }
    }
    int ans = -1;
    REP(iter, 6) {
      maxDepth = iter;
      if (calc(0, field) == maxDepth) {
        ans = maxDepth;
        break;
      }
    }
    printf("%d\n", ans);
  }
}

Measured memory_bytes: 884
x, k, d = map(int, input().split())

x = -x if x <= 0 else x

if x - d * k >= 0:
    print(x - d * k)
else:
    a = x // d
    b = a + 1
    rest_cnt = k - a
    if rest_cnt % 2 == 0:
        print(abs(x - d * a))
    else:
        print(abs(x - d * b))


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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

using ll  = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rep1r(i, n) for (int i = ((int)(n)); i > 0; --i)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

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

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

#define MAX 2000001
#define VMAX 10000

// 教科書のをc++に
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    // cout << fixed << setprecision(5);

    int n;
    cin >> n;
    // a入力用 b出力用配列
    int a[n + 1], b[n + 1];
    // カウンター用配列
    int c[VMAX + 1] = {};

    // 	入力はアルゴリズムの都合上1-indexから始める。
    rep1(i, n) {
        cin >> a[i];
        // aの中身をカウントに使う
        c[a[i]]++;
    }

    // カウントを累計していく
    rep1(i, VMAX) { c[i] = c[i] + c[i - 1]; }
    rep1(i, n) {
        // 出力用配列に移動 a=>b
        b[c[a[i]]] = a[i];
        // 出ていった分カウントを減らす
        c[a[i]]--;
    }

    // 出力処理
    rep1(i, n) {
        if (i > 1) cout << " ";
        cout << b[i];
    }
    cout << endl;

    return 0;
}



Measured memory_bytes: 18764
#include<bits/stdc++.h>
#define ll long long
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define MOD 1000000000
#define inf -100000
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main()
{
    fast;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ll int n,m;
    cin>>n>>m;
    ll int a[m];
    ll int i,z,s=0;
    for(i=0;i<m;i++)
    {
    	cin>>a[i];
    	s=s+a[i];
    }

    z=n-s;
    if(z<0)
    	cout<<"-1\n";
    else
    	cout<<z<<endl;
}	

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

struct PotentializedUnionFind{
    vector<int> par,rank,diff_weight;

    //はじめに全てが根であるとしておく
    PotentializedUnionFind(int N):par(N),rank(N,1),diff_weight(N,0){iota(par.begin(),par.end(),0);}

    int root(int x){//根に当たるまで再帰で探す
        if(par[x] == x) return x;
        else{
          	int r = root(par[x]);//これいる？
            diff_weight[x] += diff_weight[par[x]];
            return par[x] = root(par[x]);//根の更新と値を返すのを同時に？
                                        //あんま必要なさそう
        }
    }

    bool unite(int x, int y,int w){//根が同じでなかったらつなげる
        w += weight(x); w -= weight(y);
        x = root(x); y = root(y);
        if(x == y) return false; //同じ根なので変動なし(uniteの必要なし)
        if(rank[x] < rank[y]){
            diff_weight[x] -= w;
            par[x] = y;
        }
        else{
            //多分根を0としたときの差分
            //問題で(y - x)の値がwであるとしているのでyにwを足している
            diff_weight[y] += w;//各点ごとに値が存在して、そこに差分を足している
            par[y] = x; //ここで根を変更している
            //ここで結合したと同時に下の行でrank(sizeとも)をインクリメントしている
            if(rank[x] == rank[y]) ++rank[x];
            //少なくともsizeをはかりたいならこうではない。
            //rank[根]にrank[他]を足していく
        }
        return true;
    }

    bool same(int x,int y){//つながっているかどうか判定
        return root(x) == root(y);
    }

    int weight(int x){
        root(x);//xが根ではなかったとき値が更新される？
        return diff_weight[x];
    }

    int diff(int x,int y){
        return weight(y) - weight(x);
    }

    int size(int x){//たぶんこう
        return rank[root(x)];
    }
};

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

    int N,M,L,R,D;
    cin >> N >> M;
    PotentializedUnionFind PUF(N);
    for(int i = 0;i < M;++i){
        cin >> L >> R >> D;
        --L,--R;
        if(PUF.same(L,R)){
            int diff = PUF.diff(L,R);
            if(diff != D){
                cout << "No" << endl;
                return 0;
            }
        }
        else{
            PUF.unite(L,R,D);
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define el endl
#define INF LONG_LONG_MAX
#define NINF LONG_LONG_MIN
#define sz size()
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
#define nn " " 
#define bg begin()
#define en end()
#define mod 1000000007
using namespace std;

int main()
{
    ll n,k;
    cin>>n>>k;
    ll h[n],i,j,dp[n],x;
    for(i=0;i<n;i++)
        cin>>h[i];
    dp[0]=0;
    for(i=1;i<n;i++)
    {
        x=INF;
        for(j=max((ll)0,i-k);j<i;j++)
        {
            x=min(x,dp[j]+abs(h[i]-h[j]));
        }
        dp[i]=x;
    }
    cout<<dp[n-1];
}

Measured memory_bytes: 1792
<?php

$N = trim(fgets(STDIN));
$V = explode(" ",trim(fgets(STDIN)));
$C = explode(" ",trim(fgets(STDIN)));

$sum = 0;
for ($i=0; $i < $N; $i++) { 
    if ( $V[$i] - $C[$i] > 0 ) {
        $sum += $V[$i] - $C[$i];
    }
}

echo $sum;

Measured memory_bytes: 4856
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <time.h>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}


int main(){
    long long N,a,b; cin >> N >> a >> b;
    if (a > b) cout << 0 << endl;
    else cout << max((b*(N-1) + a) - (b + a*(N-1)) + 1, 0LL ) << endl;
}




Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC057_C_2
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = long.Parse(Console.ReadLine());
            var ans = F(N);
            Console.WriteLine(ans);
        }

        static int F(long n)
        {
            int res;
            var sqrt_n = Math.Sqrt(n);
            var dividAble = new List<long>();
            if (sqrt_n == (int)sqrt_n)
            {
                res = (int)Math.Log10(sqrt_n) + 1;
                return res;
            }


            for (long i = 1; i < sqrt_n; i++)
            {
                double A = i;
                double B = n / A;
                if (B == (long)B)
                {
                    dividAble.Add(Math.Max((long)A, (long)B));
                }
            }
            return (int)Math.Log10(dividAble.Min()) + 1;
        }
    }
}


Measured memory_bytes: 11220
from math import gcd
from collections import defaultdict

N = int(input())
d = {}
MOD = 10**9+7
zall = 0

for _ in range(N):
    A, B = map(int, input().split())

    if A==0 and B==0:
        zall += 1
    else:
        if A and B:
            if A<0 and B<0:
                A *= -1
                B *= -1
            elif A<0 and B>0:
                A *= -1
                B *= -1

            g = gcd(A, B)
            A //= g
            B //= g
        elif A==0:
            B = 1
        elif B==0:
            A = 1
        
        if (A, B) in d:
            d[(A, B)] += 1
        else:
            d[(A, B)] = 1

ans = 1
used = defaultdict(int)

for (i, j), v in d.items():
    if used[(i, j)]:continue
    used[(i, j)] = 1
    buf = 0

    if j>0:
        if (j, -i) in d:
            used[(j, -i)] = 1
            buf = d[(j, -i)]
        else:
            buf = 0
    else:
        if (-j, i) in d:
            used[(-j, i)] = 1
            buf = d[(-j, i)]
        else:
            buf = 0

    ans *= (pow(2, buf, MOD)+pow(2, v, MOD)-1)
    ans %= MOD

print((ans+zall-1)%MOD)


Measured memory_bytes: 77748
#include <iostream>
#include <cstdio>
#include <cstring>
#include <stack>
#include <iomanip>
#include <sstream>
#include <cctype>
#include <cstdlib>
#include <string>
using namespace std;

double calc(double a, double b, string op){
  if(op == "+") return a + b;
  if(op == "-") return a - b;
  if(op == "*") return a * b;
  if(op == "/") return a / b;
}

int main(){
  string str;
  double a, b;
  while(getline(cin, str)){
    stack<double> st;
    stringstream ss;
    ss << str;
    while(ss >> str){
      if(str == "+" || str == "-" || str == "*" || str == "/"){
	a = st.top(); st.pop();
	b = st.top(); st.pop();
	st.push(calc(b, a, str));
	
      }
      else{
	st.push(atoi(str.c_str()));
      }
    }
    double ans = st.top(); st.pop();
    printf("%0.6f\n", ans);
  }
  return 0;
}

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

char s[10000];

int main() {
    int n;
    cin >> n;
    scanf("%s", s + 1);
    int a = 0, b = 0;
    for (int i = 1; i <= n; ++i)
        if (s[i] == 'R') ++a;
        else ++b;
    puts(a > b ? "Yes" : "No");
    return 0;
}


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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long

const int MOD =  1000000007;
const int IINF = INT_MAX;
const ll INF = 1LL << 60;


int main() {
    int n; cin >> n;
    V<int> a(4);
    for(int i = 0; i < n; i++){
        string s; cin >> s;
        if(s == "AC") a[0]++;
        if(s == "WA") a[1]++;
        if(s == "TLE") a[2]++;
        if(s == "RE") a[3]++;
    }

    for(int i = 0; i < 4; i++){
        if(i == 0) cout << "AC x " << a[0] << endl;
        if(i == 1) cout << "WA x " << a[1] << endl;
        if(i == 2) cout << "TLE x " << a[2] << endl;
        if(i == 3) cout << "RE x " << a[3] << endl;
    }

    return 0;
}


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

using namespace std;

typedef long long ll;

struct interval {
    int l, r;
    ll a;

    interval(int l, int r, ll a) : l(l), r(r), a(a) {}
};

struct segtree {
    int n;
    vector<ll> t, d;

    segtree(int n) : n(n) {
        t.resize(4 * n);
        d.resize(4 * n);
    }

    void push(int i) {
        t[2 * i + 1] += d[i];
        t[2 * i + 2] += d[i];
        d[2 * i + 1] += d[i];
        d[2 * i + 2] += d[i];
        d[i] = 0;
    }

    void inc(int i, int L, int R, int l, int r, ll x) {
        if (l <= L && R <= r) {
            t[i] += x;
            d[i] += x;
        } else {
            push(i);
            int M = (L + R) / 2;
            if (l <= M)
                inc(2 * i + 1, L, M, l, r, x);
            if (r > M)
                inc(2 * i + 2, M + 1, R, l, r, x);
            t[i] = max(t[2 * i + 1], t[2 * i + 2]);
        }
    }

    void inc(int l, int r, ll x) {
        inc(0, 0, n - 1, l, r, x);
    }

    ll rmq(int i, int L, int R, int l, int r) {
        if (l <= L && R <= r)
            return t[i];
        push(i);
        int M = (L + R) / 2;
        ll result = LLONG_MIN;
        if (l <= M)
            result = max(result, rmq(2 * i + 1, L, M, l, r));
        if (r > M)
            result = max(result, rmq(2 * i + 2, M + 1, R, l, r));
        return result;
    }

    ll rmq(int l, int r) {
        return rmq(0, 0, n - 1, l, r);
    }
};

int N, M;
vector<vector<interval>> on, off;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> N >> M;
    int n = N + 2;
    on.resize(n);
    off.resize(n);
    segtree dp(n), score(n);
    while (M--) {
        int l, r;
        ll a;
        cin >> l >> r >> a;
        on[l].push_back(interval(l, r, a));
        off[r + 1].push_back(interval(l, r, a));
        score.inc(l, r, a);
    }
    for (int i = 1; i <= N; i++) {
        for (interval e : off[i])
            dp.inc(e.l, e.r, e.a);
        dp.inc(i, i, score.rmq(i, i) + dp.rmq(0, i - 1));
        for (interval e : on[i])
            dp.inc(e.l, e.r, -e.a);
    }
    for (interval e : off[N + 1])
        dp.inc(e.l, e.r, e.a);
    cout << dp.rmq(0, N) << endl;
}


Measured memory_bytes: 47104
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    int r, t, i, k;
    double x, y;
    char[] ch;
    String str;

    t = 90; x = 0; y = 0; k = 0;
    for(;sc.hasNext();){
      str = sc.next();
      ch = new char[str.length()];
      for(i = 0;i < str.length();i++){
        ch[i] = str.charAt(i);
        if(ch[i] == ',')k = i;
      }
      r = readint(ch, 0, k);
      x += r * Math.cos(Math.toRadians(t));
      y += r * Math.sin(Math.toRadians(t));
      t -= readint(ch, k + 1, str.length()) % 360;
    }
    out.println((int)x);
    out.println((int)y);

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
  private static int readint(char[] ch, int l, int r){
    int i, d, res, sign;
    d = 1; res = 0; sign = 1;
    if(ch[l] == '-'){
      sign = -1; l++;
    }
    for(i = r - 1;i >= l;i--){
      res += d * (int)(ch[i] - '0');
      d *= 10;
    }
    return res * sign;
  }
}

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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
#define endl        "\n"
#define repp(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a,b) 	for(int i=a;i<=b;i++)
#define IOS         ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int N=1e5 + 5;
const int M=1e9 + 7;

string inttos(int num)
{
    return to_string(num);
}

int stoint(string sss)
{
    return stoi(sss);
}

int32_t main()
{
	IOS;
	//memset(dp,-1,sizeof(dp));	
	int T;
	T=1;
	while(T--)
	{
		int n;
		cin >> n;
		int sum=0;
		rep(i,1,n)
		{
			if(i%3==0 || i%5==0)
			{
				
			}
			else
			{
				sum += i;
			}
		}
		cout << sum << endl;
	}
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
ll a[3003];
ll dp[3003][3003];
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n; 
	cin>>n; 
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=1;i<=n;i++)dp[i][i] = (n%2 ? a[i]:-a[i]);
	for(int l=n;l>=1;l--){
		for(int r=l+1;r<=n;r++){
			int len = r-l+1;
			if(len%2==n%2){
				dp[l][r] = max(dp[l+1][r]+a[l],dp[l][r-1]+a[r]);
			}
			else{
				dp[l][r] = min(dp[l+1][r]-a[l],dp[l][r-1]-a[r]);
			}
		}
	}
	cout<<dp[1][n]<<endl;
	return 0;
}


Measured memory_bytes: 70016
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;

int main() {
  int N, ans;
  cin >> N;
  vector<int> p(N);
  for (int i=0; i<N; i++) {
    cin >> p.at(i);
  }
  sort(p.begin(),p.end());
  ans=(p.at(N-1))/2;
  for (int j=0; j<N-1; j++) {
    ans=ans+p.at(j);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3560
S = input()
Q = int(input())
rev = False
head = []
tail = []
for i in range(Q):
    q = input()
    if q == '1':
        rev = not rev
    else:
        F, C = q.split()[1:]
        if (F == '1' and not rev) or (F == '2' and rev):
            head.append(C)
        else:
            tail.append(C)

head = ''.join(head)
tail = ''.join(tail)
S = head[::-1] + S + tail
if rev:
    S = S[::-1]
print(S)

Measured memory_bytes: 4988
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int min = Integer.MAX_VALUE;
        int[][] p = new int[n][2];
        for (int i = 0; i < n; i++) {
            p[i][0] = sc.nextInt();
            p[i][1] = sc.nextInt();
        }

        for (int i = 0; i < 2; i++) {
            sort(p,i);
            for (int j = 1; j < n; j++) {
                min = Math.min(min, (p[j][0] - p[j - 1][0]) * (p[j][0] - p[j - 1][0]) + (p[j][1] - p[j - 1][1]) * (p[j][1] - p[j - 1][1]));
            }
        }
        System.out.println(min);
    }

    static void sort(int[][] p, int n) {
        if (n == 0) {
            Arrays.sort(p, new Comparator<int[]>() {
                public int compare(int[] a, int[] b) {
                    return a[0] - b[0];
                }
            });
        } else {
            Arrays.sort(p, new Comparator<int[]>() {
                public int compare(int[] a, int[] b) {
                    return a[1] - b[1];
                }
            });
        }
    }
}


Measured memory_bytes: 285976
#!/usr/bin/env python3
import sys


def solve(D: int, N: int):
    if N == 100:
        print((100**D)*101)
    else:
        print((100**D)*N)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    D = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    solve(D, N)

if __name__ == '__main__':
    main()


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

int main(){
    long long N, T;
    cin>> N >> T;
    vector<long long> t(N);
    rep(i,N)cin>>t[i];

    long long sum = 0;
    long long stop_t = 0;
    rep(i,N){
        if(stop_t <= t[i]){
            sum += T;
        }else{
            sum -= stop_t - t[i];
            sum += T;
        }
        stop_t = t[i] + T;
    }

    cout << sum << endl;
    return 0;
    
}

Measured memory_bytes: 4680
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  int x;
  cin >> x;
  int now = 0;
  int i = 0;
  while(1){
    i++;
    now += i;
    if(now >= x){
      cout << i << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()
    a = LI()
    b = LI()

    # 全てのiに対してa[i]<=b[i]にしていく
    tmp = 0
    for i in range(N):
        if a[i] > b[i]:
            tmp += a[i] - b[i]
        else:
            tmp -= (b[i] - a[i]) // 2

    if tmp <= 0:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 11496
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=100010;
const ll mod=1e9+7;


int main(){
  int n,k;
  cin >> n >> k;
  ll ans = 1;
  rep(i,n){
    if(ans>k){
      ans+=k;
    }else{
      ans*=2;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//long long a[100005]={0};
vector<long long>a;
vector<long long>q1;
vector<long long>q2;
vector<long long>q3;
vector<long long>q4;
vector<long long>q5;
int main()
{
	long long n,m,c;
	cin>>n;
	for(int i=0;i<n;i++)
	{int t;
		cin>>t;
		a.push_back(t);
	}
	if(n==1)
	{
		printf("0\n");
		
	}
	
	sort(a.begin(),a.end());
	long long sum=0,mid=n/2;

       
       vector<long long>q;
    
       if(n%2==1)
       {    
	       q.push_back(a[mid]);
	       q2.push_back(a[mid]);
	      //long long dise=a[n-1]-a[mid],disb=a[mid]-a[0];
        	   for(long long i=0;i<n/2;i++)
                {
                	q.push_back(a[n-1-i]);
       	      	    q.push_back(a[i]);	
	            }
             
          
            for(long long i=0;i<n/2;i++)
           { q2.push_back(a[i]);
       	    q2.push_back(a[n-1-i]);
       	    		
	        }
	
	     	   
	   }
	   else
	   { mid--;
	   	   q4.push_back(a[mid]);
	     
        
	           for(long long i=0;i<n/2-1;i++)
                {
                	q4.push_back(a[n-1-i]);
       	      	    q4.push_back(a[i]);	
	            }
	            q4.push_back(a[mid+1]);
             
           q3.push_back(a[mid]);
            for(long long i=0;i<n/2-1;i++)
           { q3.push_back(a[i]);
       	    q3.push_back(a[n-1-i]);
       	    		
	        }
	q3.push_back(a[mid+1]);
	     	
		 mid++;
		    q1.push_back(a[mid]); 
		      q5.push_back(a[mid]);
		     //long long dise1=a[n-1]-a[mid],disb1=a[mid]-a[0];
		     	   for(long long i=0;i<n/2-1;i++)
                {
                	q1.push_back(a[n-1-i]);
       	      	    q1.push_back(a[i]);	
	            }
	            q1.push_back(a[mid-1]);
             
          
            for(long long i=0;i<n/2-1;i++)
           { q5.push_back(a[i]);
       	    q5.push_back(a[n-1-i]);
       	    		
	        }
	q5.push_back(a[mid-1]);
	     //printf(" 11");
	   }
	   
     long long ans[10]={0};
     long long sum1=0;
	   for(long long i=0;i<n-1;i++)
	   {
	   	if(n%2==1)
	   	{
	   		ans[0]+=abs(q[i]-q[i+1]); 
	   		ans[1]+=abs(q2[i]-q2[i+1]); 
		   }
	   	else
	   	{
	   	ans[2]+=abs(q1[i]-q1[i+1]); 
	   	ans[3]+=abs(q3[i]-q3[i+1]); 
	   		sum1+=abs(q4[i]-q4[i+1]); 
	   			ans[5]+=abs(q5[i]-q5[i+1]); 
		   }

		} 
		sort(ans,ans+6);
	//	
	
cout<<ans[5]<<endl;	
 } 


Measured memory_bytes: 4852
#include <cstdio>

int n, tn, hn, turn, card;
bool t[201], h[201];

int main(){
	while(scanf("%d", &n)){
		if(n == 0) break;
		tn = n; hn = n;
		turn = 1; card = 0;
		for(int i = 1; i <= 200; i++){
			t[i] = false;
			h[i] = false;
		}
		for(int i = 1; i <= n; i++){
			int tmp; scanf("%d", &tmp);
			t[tmp] = true;
		}
		for(int i = 1; i <= 2*n; i++) if(!t[i]) h[i] = true;
		while(true){
			bool ok = true;
			if(tn == 0 || hn == 0){
				printf("%d\n%d\n", hn, tn);
				break;
			}
			if(turn == 1){
				for(int i = card+1; i <= 2*n; i++){
					if(t[i]){
						t[i] = false;
						card = i;
						turn = 2;
						tn--;
						ok = false;
						break;
					}
				}
				if(ok){
					turn = 2;
					card = 0;
				}
			} else{
				for(int i = card+1; i <= 2*n; i++){
					if(h[i]){
						h[i] = false;
						card = i;
						turn = 1;
						hn--;
						ok = false;
						break;
					}
				}
				if(ok){
					turn = 1;
					card = 0;
				}
			}
		}
	}
}

Measured memory_bytes: 1028
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>


#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;



int main(){
    int h, w, n;
    cin >> h >> w >> n;
    int m = max(h, w);

    int res = n / m;
    if(n % m != 0)res++;
    cout << res;
}

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

int main() {
  unsigned int n;
  scanf("%d", &n);
  int result;
  result = n % 1000;
  
  if (result == 0) {
    printf("%d", result);
    return 0;
  }
  else {
    result = abs(result - 1000);
    printf("%d", result);
    return 0;
  } 
  return 0;
}

Measured memory_bytes: 3824
# input
N = int(input())
p = list(map(float, input().split()))

# dp[i][j] = i回目にコインを投げたとき、面がj個になっている確率
dp = [[0] * (N + 1) for i in range(N + 1)]

dp[0][0] = 1
for i in range(1, N + 1):
  for j in range(N + 1):
    if j - 1 < 0:
      dp[i][j] = dp[i - 1][j] * (1 - p[i - 1])
    else:
      dp[i][j] = dp[i - 1][j - 1] * p[i - 1] + dp[i - 1][j] * (1 - p[i - 1]) # 裏が出てj+1個になる確率と表が出てj+1個になる確率

ans = 0
for i in range(int(N / 2) + 1, N + 1):
  ans += dp[N][i]

print(ans)

Measured memory_bytes: 259720
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import static java.lang.Integer.parseInt;

/**
 * Tennis
 * PCK2013 ??¬???1
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			int j, y;
			j = parseInt(line.substring(0, line.indexOf(' ')));
			y = parseInt(line.substring(line.indexOf(' ') + 1));

			play(0, 0, "", j, y);

		}//end while
	}//end main

	static void play(int _j, int _y, String r, int j, int y) {

		if (_j == j && _y == y) {
			System.out.println(r);
			return;
		}

		if (_j > j || _y > y) return;
		if ((_j >= 5 && _y < 4) || (_j < 4 && _y >= 5)) return;

		play(_j + 1, _y, r + "A", j, y);
		play(_j, _y + 1, r + "B", j, y);
	}
}

Measured memory_bytes: 24444
#include<iostream>
#include<vector>
using namespace std;
#define MAX_N 20
#define MAX_K 1355
long long dp[MAX_N + 1][MAX_K][220];
long long sum[MAX_N + 1][MAX_K];
int prime[MAX_K];
int main() {
	prime[0] = 1; prime[1] = 1;
	for (int i = 2; i*i < MAX_K; i++) {
		for (int j = i*i; j < MAX_K; j += i) {
			prime[j] = 1;
		}
	}
	for (int i = 0; i < MAX_K; i++)prime[i] = 1 - prime[i];
	vector<int>p; p.push_back(0);
	for (int i = 0; i < MAX_K; i++) {
		if (prime[i] == 1) { p.push_back(i); }
	}
	dp[0][0][0] = 1;
	for (int i = 0; i < MAX_N; i++) {
		for (int j = 0; j < MAX_K; j++) {
			for (int k = 0; k < p.size(); k++) {
				for (int l = k + 1; l < p.size(); l++) {
					if (j + p[l] >= MAX_K) { continue; }
					dp[i + 1][j + p[l]][l] += dp[i][j][k];
				}
			}
		}
	}
	for (int i = 0; i < MAX_N; i++) {
		for (int j = 0; j < MAX_K; j++) {
			for (int k = 0; k < p.size(); k++) {
				sum[i][j] += dp[i][j][k];
			}
		}
	}
	int n, k;
	while (true) {
		cin >> n >> k;
		if (n == 0 && k == 0) { break; }
		cout << sum[k][n] << endl;
	}
	return 0;
}

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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;


int main(){

    int n;
    cin >> n;
    int ans = 0;
    for(int i = 0; i < n; i++){
        ans += i+1;
    }
    cout << ans << endl;

    return 0;
}

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

#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define allof(a) (a).begin(),(a).end()

int N;
double p[111];
vector< vector< int > > adj, r_adj, dag;
vector< int > rev_order, topol;
vector< bool > used;

void dfs(int v) {
	used[v] = true;
	for (int u : adj[v]) if (!used[u]) dfs(u);
	rev_order.push_back(v);
}

void revDFS(int v, int k) {
	used[v] = true;
	topol[v] = k;
	for (int u : r_adj[v]) if (!used[u]) revDFS(u, k);
}

void scc() {
	rev_order.clear();
	topol.assign(N, -1);
	used.assign(N, false);
	
	for_(v,0,N) if (!used[v]) dfs(v);
	
	fill(allof(used), false);
	int k = 0;
	reverse(allof(rev_order));
	for (int v : rev_order) if (!used[v]) revDFS(v, k++);
	
	dag.assign(k, vector< int >());
	for_(v,0,N) {
		int top_v = topol[v];
		for (int u : adj[v]) if (top_v != topol[u]) dag[top_v].push_back(topol[u]);
	}
	
	for_(i,0,k) {
		sort(allof(dag[i]));
		dag[i].erase(unique(allof(dag[i])), dag[i].end());
	}
}

void solve() {
	scc();
	
	int n = dag.size();
	vector< int > in_deg(n, 0);
	for_(i,0,n) for (int x : dag[i]) ++in_deg[x];
	
	double ans = 1.0;
	for_(i,0,n) {
		if (in_deg[i] == 0) {
			double rate = 1.0;
			for_(v,0,N) if (topol[v] == i) rate *= p[v];
			ans *= (1.0 - rate);
		}
	}
	printf("%.9lf\n", ans);
}

int main() {
	while (cin >> N, N) {
		adj.assign(N, vector< int >());
		r_adj.assign(N, vector< int >());
		for_(v,0,N) {
			int m; cin >> p[v] >> m;
			for_(i,0,m) {
				int a; cin >> a; --a;
				adj[v].push_back(a);
				r_adj[a].push_back(v);
			}
		}		
		solve();
	}
}

Measured memory_bytes: 3480
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    double W,H,x,y;
    cin >> W >> H >> x >> y;
    cout << fixed << setprecision(6);
    cout << W * H / 2 << " ";
    cout << (W/2 == x && H/2 == y) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MAXN 19
#define INF 9223372036854775807
using namespace std;

inline long long read()
{
	long long x=0,f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-') f=-f;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

long long n,m;
long long a[MAXN];
long long dfs(long long l,long long r,long long x,long long y)
{
	if(l==r-1) return a[l]*x+a[r]*y;
	long long ans=INF;
	for(register long long m=l+1;m<r;++m) ans=min(ans,dfs(l,m,x,x+y)+dfs(m,r,x+y,y)-a[m]*(x+y));
	return ans;
}

int main()
{
	n=read();
	for(register long long i=1;i<=n;++i) a[i]=read();
	printf("%lld",dfs(1,n,1,1));
	return 0;
}

Measured memory_bytes: 384
a,b,c,x=[int(input()) for _ in range(4)]
ans=0
if x<=500*a+100*b+50*c:
    r1=min(x//500,a)
    for i in range(r1+1):
        x0=x-500*i
        if x0<=100*b+50*c:
            r2=min(x0//100,b)
            for j in range(r2+1):
                x1=x0-100*j
                if x1%50==0 and 0<=x1//50<=c:
                    ans+=1
print(ans)

Measured memory_bytes: 3064
//BELIEVE IN YOURSELF
//next_permutation

#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define pob pop_back
#define vi vector<ll>
#define mp make_pair
#define sz size()
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define rep(i,n) for(ll i=0;i<n;i++)
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define maxx 100005
#define se second
#define fi first
#define be begin()
#define en end()
#define sortv(v) sort(v.begin(),v.end());
#define sortr(v) sort(v.rbegin(),v.rend());
#define w() ll _;cin>>_;while(_--)
#define edge pair<ll,ll>
#define pq priority_queue<ll>
#define mod 1000000007
#define Endl "\n"
#define cy cout<<"YES"<<endl;
#define cn cout<<"NO"<<endl;
#define lb(v,x) std::lower_bound(v.begin(),v.end(),x)
#define ub(v,x) std::upper_bound(v.begin(),v.end(),x)

using namespace std;


int main()
{
	fast;
	
	ll n;
	cin>>n;
	ll x,y;
	
	ll i;
	ll f=0;
	ll z=0;
	ll ans=0;
	for(i=0;i<n;i++)
	{
		cin>>x>>y;
		if(x==y)
		{
			f++;
		}
		else
		{
			z++;
		}
		if(f>=3)
		{
			ans++;
		}
		if(z>0)
		{
			z=0;
			f=0;
		}
	}
	if(ans)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3636
#include <cstdio>
#include <vector>

std::vector<int> edge[200000];
bool visit[200000];
long long val[200000];

void dfs(int index, long long add)
{
  if (index > 0)
  {
    val[index] += add;
  }
  visit[index] = true;
  for (auto i : edge[index])
  {
    if (visit[i]) continue;
    dfs(i, val[index]);
  }
}

int main()
{
  int n, q;
  scanf("%d%d", &n, &q);
  for (int i = 0; i < n - 1; ++i)
  {
    int a, b;
    scanf("%d%d", &a, &b);
    --a, --b;
    edge[a].emplace_back(b);
    edge[b].emplace_back(a);
  }
  for (int i = 0; i < q; ++i)
  {
    long long p, x;
    scanf("%lld%lld", &p, &x);
    val[p - 1] += x;
  }
  
  dfs(0, val[0]);
  
  for (int i = 0; i < n; ++i)
  {
    printf("%lld ", val[i]);
  }
  putchar('\n');
  return 0;
}

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

int main() {
  int N; cin >> N;
  deque<int> d;
  for (int i{}; i < N; ++i) {
    int a;
    cin >> a;
    int p = lower_bound(d.begin(), d.end(), a) - d.begin();
    if (!p) {
      d.push_front(a);
    } else {
      d[p-1] = a;
    }
  }

  cout << d.size() << endl;
  return 0;
}


Measured memory_bytes: 640
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {
	int n;
	long[] x;
	long[] y;
	long[] a;
	double[][] dist;
	double[] weight;
	long[] water;

	class Edge implements Comparable<Edge> {
		int u;
		int v;
		double cost;

		public Edge(int u_, int v_, double dist) {
			u = u_;
			v = v_;
			cost = dist;
		}

		@Override
		public int compareTo(Edge o) {
			return Double.compare(cost, o.cost);
		}
	}

	class UnionFind {
		int n;
		int[] upper;

		public UnionFind(int n_) {
			n = n_;
			upper = new int[n];
			Arrays.fill(upper, -1);
		}

		int root(int x) {
			return upper[x] < 0 ? x : (upper[x] = root(upper[x]));
		}

		boolean equiv(int x, int y) {
			return root(x) == root(y);
		}

		void setUnion(int x, int y) {
			x = root(x);
			y = root(y);
			if (x == y)
				return;
			if (upper[x] < upper[y]) {
				x ^= y;
				y ^= x;
				x ^= y;
			}
			upper[y] += upper[x];
			upper[x] = y;
		}
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		x = new long[n];
		y = new long[n];
		a = new long[n];
		dist = new double[n][n];
		weight = new double[1 << n];
		water = new long[1 << n];
		for (int i = 0; i < n; ++i) {
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
			a[i] = sc.nextInt();
		}
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < n; ++j) {
				if (i == j)
					continue;
				dist[i][j] = Math.sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]));
			}
		}
		for (int s = 1; s < 1 << n; ++s) {
			UnionFind uf = new UnionFind(n);
			PriorityQueue<Edge> pq = new PriorityQueue<>();
			for (int i = 0; i < n; ++i) {
				if ((s >> i) % 2 == 0)
					continue;
				water[s] += a[i];
				for (int j = i + 1; j < n; ++j) {
					if ((s >> j) % 2 == 0)
						continue;
					pq.add(new Edge(i, j, dist[i][j]));
				}
			}
			while (!pq.isEmpty()) {
				Edge e = pq.poll();
				if (uf.equiv(e.u, e.v))
					continue;
				weight[s] += e.cost;
				uf.setUnion(e.u, e.v);
			}
		}
		double[] a = new double[1 << n];
		a[0] = 1 << 30;
		for (int s = 0; s < 1 << n; ++s) {
			for (int s2 = ((1 << n) - 1) & ~s; s2 > 0; s2 = (s2 - 1) & ~s) {
				int m = Integer.bitCount(s2);
				int ns = s | s2;
				a[ns] = Math.max(a[ns], Math.min(a[s], ((water[s2] - weight[s2]) / m)));
			}
		}
		System.out.printf("%.20f", a[(1 << n) - 1]);
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 48456
import sys
sys.setrecursionlimit(10**9)

N = int(input())
MOD = 10**9+7
G = [[] for _ in range(N)]
for i in range(N-1):
    x, y = map(lambda x: int(x)-1, input().split())
    G[x].append(y)
    G[y].append(x)

def dfs(v, r):
    w, b = 1, 1
    for u in G[v]:
        if u == r: continue
        c_w, c_b = dfs(u, v)
        w *= c_w + c_b
        b *= c_w
    w %= MOD
    b %= MOD
    return w, b

print(sum(dfs(0, None))%MOD)

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

int main() {
  int N;
  cin >> N;
  vector<int> L(N);
  for(int i = 0; i < N; i++) {
    cin >> L.at(i);
  }
  sort(L.begin(), L.end());
  int count = 0;
  for(int i = 0; i < N; i++) {
    for(int j = i + 1; j < N; j++) {
      for(int k = j + 1; k < N; k++) {
        if(L.at(i) != L.at(j) && L.at(j) != L.at(k) && L.at(i) + L.at(j) > L.at(k)) {
          count++;
        }
      }
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 3624
n = int(input())
x = list(map(float,input().split()))
y = list(map(float,input().split()))
xy = [0 for i in range(n)]; xy2 = [0 for i in range(n)]; xy3 = [0 for i in range(n)]

for  i in range(n):
    xy[i] = x[i]-y[i]
    if xy[i]<0:
        xy[i] *= -1
    xy2[i] = xy[i]**2
    xy3[i] = xy[i]**3
    
print("{0:.6f}\n{1:.6f}\n{2:.6f}\n{3:.6f}".format(sum(xy),(sum(xy2)**(1/2)),(sum(xy3)**(1/3)),max(xy)))



Measured memory_bytes: 5680
#include<bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll MOD=10000000;
const ll INF=1000000001;
const ll LINF=4000000000000000010;
const double EPS=1e-9;
int dx[5]={0,1,0,-1,0};
int dy[5]={1,0,-1,0,0};
int d[300010];
int ma[300010],mi[300010];
int main(){
    int n;cin>>n;
    for(int i=0;i<n;i++){
        cin>>d[i];
        d[i]/=10;
        if(i){
            ma[i]=max(ma[i-1],i+d[i]);
        }else{
            ma[i]=i+d[i];
        }
    }
    fill(mi,mi+n,INF);
    for(int i=n-1;i>=0;i--){
        if(i<n-1){
            mi[i]=min(mi[i+1],i-d[i]);
        }else{
            mi[i]=i-d[i];
        }
    }
    int pos=0;
    while(pos<n-1){
        if(pos==ma[pos]){
            cout<<"no"<<endl;
            return 0;
        }
        pos=ma[pos];
    }
    pos=n-1;
    while(pos>0){
        if(pos==mi[pos]){
            cout<<"no"<<endl;
            return 0;
        }
        pos=mi[pos];
    }
    cout<<"yes"<<endl;
}


Measured memory_bytes: 6620
c = []
d = {}
while True:
    a,b = map(int, input().split(','))
    c += [b]
    d[a] = b
    if a == 0 : break
c = sorted(set(c))[::-1]
while True:
    try:print(c.index(d[int(input())])+1)
    except: break




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

#define F first
#define S second
#define int long long
#define ull unsigned long long
#define pb push_back

using namespace std;
const int N = 210000;
vector < int > g[N];
int used[N], col[N];
int n, m, c, k, s, z, b;
void dfs(int v, int cc = 1){
    if (used[v]) return;
    used[v] = 1;
    col[v] = cc;
    c++;
    for (auto u: g[v]){
        if (!used[u])
        dfs(u, cc ^ 1); else
        if (col[u] != cc ^ 1) z = 1;
    }
}
main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> n >> m;
    for (int i = 0; i < m; i++){
        int u, v;
        cin >> u >> v;
        g[u].pb(v);
        g[v].pb(u);
    }
    for (int i = 1; i <= n; i++)
        if (!used[i]){
            c = 0;
            z = 2;
            dfs(i);
            if (c == 1) s++; else{
                k++;
                if (z == 2) b++;
            }
        }
   // cout << b << endl;
    cout << k * k + b * b + (n + n) * s - s * s;
}


Measured memory_bytes: 16640
#include <queue>
#include <cstdio>
#include <iostream>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <time.h>
using namespace std;
typedef long long int ll;

#define EPS (1e-9)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,n) for(int i=0;i<n;i++)

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

ll beki(ll a, ll b) {
	ll tmp = 1;
	REP(i, b) tmp *= a;
	return tmp;
}

string S;

int main() {
	cin >> S;
	S += 'R';
//	bool first = true;
	string Stmp;
	int k = 0;
	REP(i, S.size()) {
		Stmp += S[i];
		k++;
		if (i == 0) continue;
		
		if ((S[i - 1] == 'L' && S[i] == 'R') || i == S.size() - 1) {
			if (S[i - 1] == 'L' && S[i] == 'R') k--;
			//各点を計算
			for (int j = 0; j < k; j++) {

				if (j != 0 && (Stmp[j - 1] == 'R' && Stmp[j] == 'L') ||
					(j != k - 1 && (Stmp[j] == 'R' && Stmp[j + 1] == 'L'))) {
					if (j % 2 == 1) {
						//奇数のとき小さい
						cout << k / 2 << " ";
					}
					else {
						cout << k - (k / 2) << " ";
					}
				}
				else {
					cout << 0 << " ";
				}
			}
//			cout << endl;
//			cout << Stmp << endl;
			Stmp = S[i];
			k = 1;
		}
	}
}

Measured memory_bytes: 768
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1LL<<55;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }


/*
<url:https://onlinejudge.u-aizu.ac.jp/services/room.html#RitsCamp18Day1/problems/D>
問題文============================================================
 AORイカちゃんは縦 1 横 N の大きさの水槽をもらった。水槽は水を入れるのに十分な高さがある。
 水槽には N−1 個の仕切りがあり N 個の区画に等間隔に区切られている。
 ここに水を注いだところ、各区画の水の高さは ai になった。
 
 AORイカちゃんはいくつか仕切りを取り除き、区画の数を M 個以下にすることにした。
 仕切りを取り除き終わった時、各区画の水の高さの総和の最大値を求めよ。
 
 なお、仕切りの厚さは無視できるものとする。
=================================================================

解説=============================================================

================================================================
*/

#define MAX_N 550
ll N,M;
double a[MAX_N],cusum[MAX_N];
double mem[MAX_N][MAX_N]; // mem[i][j] := [0,i]で区間の個数がj個の時
bool checked[MAX_N][MAX_N];

double rec(int p,int cnt){
    if(p == N) return cnt == M ? 0:-LINF;
    if(checked[p][cnt]) return mem[p][cnt];
    checked[p][cnt] = true;
    
    double res = -LINF;
    for(int i = p; i < N;i++){
        double t = (cusum[i+1]-cusum[p])/(i+1-p);
        res = max(res,t+rec(i+1,cnt+1));
    }
    
    return mem[p][cnt] = res;
}
double solve(){
    cin >> N >> M;
    for(int i = 0; i < N;i++) cin >> a[i];
    for(int i = 0; i < N;i++){ cusum[i+1] = cusum[i] + a[i]; }
    return rec(0,0);
}
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(10) << solve() << endl;
	return 0;
}



Measured memory_bytes: 5772
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int N=5e5+9;
int main()
{
    FASTINOUT;
    int x,k;
    cin>>x>>k;
    int a[x];
    for (int i=0; i<x; i++)
        cin>>a[i];
    int l=1,r=2e9,mid;
    while (l<=r)
    {
        mid=(l+r)/2;
        int cnt=0;
        for (int i=0; i<x; i++)
        {
            cnt+=((a[i]+mid-1)/mid-1);
            if (cnt>k)
                break;
        }
        if (cnt<=k)
            r=mid-1;
        else
            l=mid+1;
    }
    cout<<l;
    return 0;
}


Measured memory_bytes: 4360
#include <stdio.h>
int main(){
int a,b;
char c;
while(1){
scanf("%d %c %d",&a,&c,&b);
if(c=='?')return 0;
if(c=='+')printf("%d\n",a+b);
if(c=='-')printf("%d\n",a-b);
if(c=='*')printf("%d\n",a*b);
if(c=='/')printf("%d\n",a/b);
}
}

Measured memory_bytes: 2712
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define each(a,x) for(auto a : (x))
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) ((a) = min((a),(b)))
#define chmax(a,b) ((a) = max((a),(b)))
#define in_range(x,l,r) ((l)<=(x) && (x)<(r))
#define printvec(a) rep(i,a) cout << a[i] << " \n"[i+1==(a).size()];
#define fs first
#define sc second
#define em emplace
#define eb emplace_back
#define sz size()
#define MP make_pair
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;

const ll INF = 1e8;
const D EPS = 1e-8;
const ll MOD = 1e9+7;

bool check(const string& x, char c) {
  for (char cx : x) {
    if(cx != c) return false;
  }
  return true;
}

void transform(string& x, char c) {
  rep(i, x.size()-1) {
    if (x[i] == c) {
      if (i>0) x[i-1] = c;
    }
  }
  x.pop_back();
}

int main(){
  string s;
  cin >> s;

  int ans = INF;
  for (char c : s) {
    string x = s;
    for (int t=0; ; ++t) {
      if (check(x, c)) {
	chmin(ans, t); break;
      }

      transform(x, c);
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256