akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>

#define MAPSIZE 1048576

int cmpmin(int a, int b) {
	return a-b;
}

int cmpmax(int a, int b) {
	return b-a;
}

typedef struct {
	int n, arr[200000];
	int (*cmp)(int, int);
} heap;

void hpush(heap *h, int x) {
	int i = h->n++;
	h->arr[i] = x;

	while (i > 0) {
		int p = (i-1)/2;
		if (h->cmp(h->arr[p], h->arr[i]) > 0) {
			int t = h->arr[p];
			h->arr[p] = h->arr[i];
			h->arr[i] = t;
			i = p;
		} else break;
	}
}

int hpop(heap *h) {
	int ret = h->arr[0];
	h->arr[0] = h->arr[--h->n];

	int i = 0, c;
	while ((c = i*2 + 1) < h->n) {
		if (c+1 < h->n && h->cmp(h->arr[c], h->arr[c+1]) > 0) {
			c++;
		}

		if (h->cmp(h->arr[i], h->arr[c]) > 0) {
			int t = h->arr[c];
			h->arr[c] = h->arr[i];
			h->arr[i] = t;
			i = c;
		} else break;
	}

	return ret;
}

int hpeek(const heap *h) {
	return h->arr[0];
}

heap left = {.cmp = cmpmax}, right = {.cmp = cmpmin};

int main(void) {
	int q;
	scanf("%d", &q);

	long long int y = 0, d = 0;

	while (q--) {
		int t;
		scanf("%d", &t);
		if (t == 1) {
			int a, b;
			scanf("%d%d", &a, &b);
			int px = hpeek(&left);
			y += abs(px-a);
			d += b;

			if (a < px) hpush(&left, a);
			else hpush(&right, a);

			int diff = left.n - right.n;
			if (diff == 2) {
				hpush(&right, hpop(&left));
				diff = 0;
			} else if (diff == -1) {
				hpush(&left, hpop(&right));
				diff = 1;
			}

			int x = hpeek(&left);
			if (x != px) {
				if (x > px) diff -= 2;
				y += (x-px) * diff;
			}
		} else {
			printf("%d %lld\n", hpeek(&left), y+d);
		}
	}
}


Measured memory_bytes: 3200
(defun main ()
  (let* ((n (read))
         (k (read))
         (buff (make-array (1+ n) :initial-element 0))
         (x 0))
    (dotimes (i k)
      (dotimes (d (read))
        (setf (aref buff (read)) 1)))
    (dotimes (i n)
      (setf x (+ x (aref buff (1+ i)))))
    (format t "~d~%" (- n x))))

(main)
             


Measured memory_bytes: 29600
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
    string s, t;
    cin >> s >> t;

    int n = s.size();
    
    int a = 0;

    for (int i = 0; i < n; i++)
    {
        if (s.at(i) != t.at(i))
        {
            a++;
        }
        
    }
    
  
    int m = t.size();

    if (a == 0)
    {
        if (m == n + 1 )
        {
            cout << "Yes" << endl;
        }
    }
    else
    {
        cout << "No" << endl;
    }
    
}


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int N;
    cin >> N;
    ll A, B, S, X = 0;
    cin >> A >> B;
    S = A + B;
    REP(i, N - 2) {
        ll tmp; cin >> tmp;
        X ^= tmp;
    }

    ll dp[43][2][2] = {};
    REP(i, 43) REP(j, 2) REP(k, 2) dp[i][j][k] = -1;
    dp[0][0][0] = 0;
    REP(i, 42) {
        int cx = (X >> i) & 1;
        int cs = (S >> i) & 1;
        int ca = (A >> i) & 1;

        REP(j, 2) REP(k, 2) {
            if (dp[i][j][k] == -1) continue;

            REP(na, 2) {
                int nb = cx ^ na;
                int ns = na + nb + j;
                if ((ns & 1) != cs) continue;

                int ni = i + 1, nj, nk;
                if (ns >= 2) nj = 1;
                else nj = 0;

                if (na > ca) nk = 1;
                else if (na == ca) nk = k;
                else nk = 0;

                dp[ni][nj][nk] = max(dp[ni][nj][nk], dp[i][j][k] | ((ll)na << i));
            }
        }
    }

    ll a = dp[42][0][0];
    if (a == -1 || a == 0) cout << -1 << endl;
    else cout << A - a << endl;
    return 0;
}

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

int main(void){
    ll h, w;
    cin >> h >> w;
    if (h == 1 || w == 1){
        cout << 1 << endl;
    } else{
        cout << (h * w + 1) / 2 << endl;
    }
    return 0;
}

Measured memory_bytes: 3612
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderE
{
    static void Main()
    {
        var sc = new Scanner();

        int n = sc.NextInt();
        int k = sc.NextInt();
        int c = sc.NextInt();
        string s = sc.Next();

        bool[] canWork = new bool[n];
        for (int i = 0; i < n; i++)
        {
            char ch = s[i];
            canWork[i] = ch == 'o';
        }

        int[] left = new int[k];
        {
            int index = 0;
            int count = 0;
            while (true)
            {
                if (canWork[index])
                {
                    left[count] = index;
                    count++;
                    index += c + 1;
                    if (count >= k)
                    {
                        break;
                    }
                }
                else
                {
                    index++;
                }
            }
        }

        int[] right = new int[k];
        {
            int index = n - 1;
            int count = k - 1;
            while (true)
            {
                if (canWork[index])
                {
                    right[count] = index;
                    count--;
                    index -= c + 1;
                    if (count < 0)
                    {
                        break;
                    }
                }
                else
                {
                    index--;
                }
            }
        }

        for (int i = 0; i < k; i++)
        {
            if (left[i] == right[i])
            {
                Console.WriteLine(left[i] + 1);
            }
        }
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 19548
a[5],i;
main(f){
	for(;~scanf("%d",a+i);){
		if(i){
			a[i]=(a[i]+3-*a)%3;
			f|=1<<a[i];
		}
		if(++i==5){
			*a=0;
			for(i=0;i<5;i++)
				printf("%d\n",f==1||f==7?3:f==3?a[i]+1:2-a[i]/2);
			i=0;
			f=1;
		}
	}
}

Measured memory_bytes: 0
#include<cstdio>
#include<algorithm>
using namespace std;

bool hate[10];
int main(){
	int n, k; scanf("%d%d", &n, &k);
	for (int i = 0; i < k; i++){
		int t; scanf("%d", &t); hate[t] = true;
	}

	while (1){
		bool ok = true;
		int m = n;
		while (m > 0){
			int here = m % 10;
			if (hate[here]) ok = false;
			m /= 10;
		}
		if (ok){
			printf("%d", n);
			return 0;
		}
		n++;
	}
}

Measured memory_bytes: 128
#include<iostream>
#include<iomanip>
#include<cmath>
#include<algorithm>
#include<vector>

using namespace std;
bool IsPrime(int a){
    if(a == 2) return true;
    if(a % 2 == 0){
        return false;
    }
    for(int i = 3; i <= sqrt(a) ; i += 2){
        if(a % i == 0){
            return false;
        }
    }
    return true;
}
int main(){
    int n;cin >> n;
    int a = 0;
    int cnt = 0;
    for(int i = 0; i < n; i++){
        cin >> a;
        if(IsPrime(a)) cnt++;
    }
    cout << cnt  << endl;
    return 0;
}   
           
    

Measured memory_bytes: 3084
from collections import defaultdict
import sys
input = sys.stdin.buffer.readline
mod = 10**9+7

N = int(input())
dp = [0] * (N+1)
dp[0] = 1
prev = defaultdict(lambda: -1)
for i in range(1, N+1):
    c = int(input())
    dp[i] = dp[i-1]
    if prev[c] >= 0:
        if prev[c] != i-1:
            dp[i] = (dp[i] + dp[prev[c]]) % mod
    prev[c] = i

print(dp[-1])


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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}



int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, t;
	cin >>n >>t;
	VI a(n), df(n);
	rep(i, n) cin >>a[i];
	
	int mn=MD;
	int mx = 0, ans = 0;
	rep(i, n){
		mn = min(mn, a[i]);
		df[i] = a[i] - mn;
		mx = max(mx, df[i]);
	}
	rep(i, n){
		if(df[i] == mx) ans++;
	}
	cout <<ans <<"\n";
	return 0;
}


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

using namespace std;

typedef long long int ll;

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

  ll n;
  cin >> n;
  vector < ll > a(n + 1);
  for(int i = 1; i <= n; i++) cin >> a[i];
  ll mx = -1e18, mi = 1e18, mx_idx = -1, mi_idx = -1;
  for(int i = 1; i <= n; i++){
    if(a[i] > mx){
      mx = a[i];
      mx_idx = i;
    }
    if(a[i] < mi){
      mi = a[i];
      mi_idx = i;
    }
  }

  cout << 2 * n - 1 << endl;
  if(abs(mx) > abs(mi)){
    for(int i = 1; i <= n; i++){
      cout << mx_idx << " " << i << endl;
    }
    for(int i = 1; i < n; i++){
      cout << i << " " << i + 1 << endl;
    }
  }else{
    for(int i = 1; i <= n; i++){
      cout << mi_idx << " " << i << endl;
    }
    for(int i = n - 1; i >= 1; i--){
      cout << i + 1 << " " << i << endl;
    }
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
typedef long long ll;

//最小公倍数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}
// ここから開始

int main(){
  int n;
  cin>>n;
  double cnt = 0;
  for(int i = 0;i <= n; i++){
    if(i%2==1){
      cnt++;
    }
  }
  cout<<fixed<<setprecision(8);
  cout<<(double)(cnt/(double)n)<<endl;
  return 0;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

const MOD: u64 = 1000000000 + 7;

fn solve(mut s: Vec<char>) -> u64 {
    s.reverse();

    let mut dp = vec![vec![0; 13]; s.len()];
    if s[0] == '?' {
        for i in 0..10 {
            dp[0][i] = 1 as u64;
        }
    } else {
        let n = s[0].to_digit(10).unwrap() as usize;
        dp[0][n] = 1 as u64;
    }

    let mut pow = 1;
    for i in 1..s.len() {
        pow = pow * 10 % 13;
        if s[i] == '?' {
            for j in 0..10 {
                for k in 0..13 {
                    let rem = (k + pow * j) % 13;
                    dp[i][rem] += dp[i-1][k] % MOD;
                }
            }
        } else {
            for k in 0..13 {
                let n = s[i].to_digit(10).unwrap() as usize;
                let rem = (k + pow *  n)  % 13;
                dp[i][rem] += dp[i-1][k] % MOD;
            }
        }
    }

    dp[s.len()-1][5] % MOD
}


fn main() {
    input! {
        s: chars
    };
    println!("{}", solve(s));
}


Measured memory_bytes: 18684
#include<bits/stdc++.h>
using namespace std;
#define maxn 100000+10
int n,l,ans;
int main(){
	ios::sync_with_stdio(0);
	cin>>n>>l;
	for(register int i=1;i<=n;i++){
		int x;
		cin>>x;
		if(x>=l)ans++;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,m,a[2005][2005],b[2005][2005],s[2005],ans;char c[2005][2005];
int main()
{
	scanf("%d%d",&n,&m);ans=max(n,m);
	for(int i=1;i<=n;i++) scanf("%s",c[i]+1);
	for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) a[i][j]=c[i][j]=='.'?0:1;
	for(int i=1;i<n;i++) for(int j=1;j<m;j++) a[i][j]=a[i][j]^a[i+1][j]^a[i][j+1]^a[i+1][j+1];
	for(int i=1;i<n;i++) for(int j=1;j<m;j++) b[i][j]=(b[i-1][j]+(a[i][j]==0))*(a[i][j]==0);
	for(int i=1,t=0;i<n;i++)
	{
		memset(s,0,sizeof(s));
		for(int j=1;j<=m;s[++t]=j,j++) while(t&&b[i][j]<=b[i][s[t]]) ans=max(ans,(j-s[t-1])*(b[i][s[t]]+1)),t--;
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 35584
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	vector<int> a(4);
	for(int i = 0; i < 4; i++) {
		cin>>a[i];
	}
	sort(ALL(a));
	if (a[0] == 1 && a[1] == 4 && a[2] == 7 && a[3] == 9){
		cout << "YES" << endl;
	}
	else{
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
n = gets.to_i
if n == 1
  puts 1
  exit
end
p = []
m = Array.new(n+1,1)
m[0..1] = [0,0]
tmp = 0
Math.sqrt(n).floor.times do
  tmp = m.index(1)
  p << tmp
  for i in 1..n/tmp
    m[i*tmp] = 0
  end
end
m.each do |num|
  if num == 1
    p << m.index(num)
    m[p[-1]] = 0
  end
end
s = p.size
a = Array.new(s,0)
for i in 1..n
  for j in 0..s-1
    while i%p[j] == 0
      i /= p[j]
      a[j] += 1
    end
  end
end
ans = 1
a.each do |num|
  ans *= num+1
end
puts ans%(10**9+7)

Measured memory_bytes: 1788
n = int(input())
uvw = [list(map(int, input().split())) for _ in range(n-1)]

g = [[] for _ in range(n)]

for u, v, w in uvw:
    u -= 1
    v -= 1
    g[u].append([v, w])
    g[v].append([u, w])


WHITE = 0
GRAY = 1
BLACK = 2

ds = [0] * n
colors = [WHITE] * n
ps = [-1] * n


def dfs(s):
    global ds, colors, ps

    stack = []

    ds[s] = 0
    colors[s] = BLACK
    ps[s] = -1
    stack.append(ds[s])

    while stack:
        u = stack[-1]
        colors[u] = GRAY

        for v, w in g[u]:
            if colors[v] == WHITE:
                stack.append(v)
                ds[v] = ds[u] + w
                ps[v] = u
                g[u].remove([v, w])
                g[v].remove([u, w])
                break

        else:
            stack.pop()
            colors[u] = BLACK

    return ds, ps


dfs(0)

for d in ds:
    print(d % 2)


Measured memory_bytes: 69652
#include <iostream>

int main() {
    char a, b, c;
    std::cin >> a >> b;
    if (a == 'H') {
        c = b;
    } else {
        c = ( b == 'H' ) ? 'D' : 'H';
    }
    std::cout << c << std::endl;
    return 0;
}

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

int main() {
    string A, B, C;
    cin >> A >> B >> C;
    cout << 'A' << B[0] << 'C' << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	D_fix_2
# CreatedDate:  2020-06-22 17:32:46 +0900
# LastModified: 2020-06-22 17:39:47 +0900
#


import os
import sys
#import numpy as np
#import pandas as pd


def main():
    n = int(input())
    a = list(map(int, input().split()))
    cnt = [0]*100001
    for a_ in a:
        cnt[a_] += 1

    total = sum(a)
    q = int(input())
    for _ in range(q):
        b, c = map(int, input().split())
        total += (c-b)*cnt[b]
        cnt[c] += cnt[b]
        cnt[b] = 0
        print(total)
        




if __name__ == "__main__":
    main()


Measured memory_bytes: 21124
#include<iostream>
using namespace std;
static const int MAX=100;
static const int INFTY=(1<<21);
static const int WHITE=0;
static const int GRAY=1;
static const int BLACK=2;

int n,M[MAX][MAX];

void dik(){
int min;
int d[MAX],color[MAX];

for(int i=0;i<n;i++){
d[i]=INFTY;
color[i]=WHITE;
}

d[0]=0;
color[0]=GRAY;
while(1){
min=INFTY;
int u=-1;
for(int i=0;i<n;i++){
if(min>d[i]&&color[i]!=BLACK){
u=i;
min=d[i];
}
}
if(u==-1)break;
color[u]=BLACK;
for(int v=0;v<n;v++){
if(color[v]!=BLACK&&M[u][v]!=INFTY){
if(d[v]>d[u]+M[u][v]){
d[v]=d[u]+M[u][v];
color[v]=GRAY;
}
}
}
}
for(int i=0;i<n;i++){
cout << i <<" "<<(d[i]==INFTY ? -1 : d[i])<<endl;
}
}

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

int k,c,u,v;
for(int i=0;i<n;i++){
cin >> u >> k;
for(int j=0;j<k;j++){
cin >> v >> c;
M[u][v]=c;
}
}

dik();

return 0;
}

Measured memory_bytes: 3124
n = int(input())

sa = []
sb = []

for i in range(n):
    a = int(input())
    if a%10 == 0:
        sa.append(a)
    else:
        sb.append(a)
if len(sb) == 0:
    print(0)
else:
    if (sum(sa)+sum(sb)) % 10 == 0:
        sb.sort()
        print(sum(sa)+sum(sb)-sb[0])
    else:
        print(sum(sa)+sum(sb))

Measured memory_bytes: 3064
import java.io.PrintWriter
import kotlin.math.PI
import kotlin.math.max

fun main(args: Array<String>) {
    PrintWriter(System.out).use { out ->
        solve(out)
        out.flush()
    }
}


fun solve(out: PrintWriter) {
    val n = readInteger()
    val aList = readIntegerList()
    val ans = IntArray(n + 1)
    for (a in aList) {
        ans[a]++
    }
    println(ans.drop(1).joinToString("\n"))
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
fun readDoubleList() = readStringList().map(String::toDouble)


Measured memory_bytes: 74684
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cmath>
#include <limits>
typedef long long ll;
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define mod 1000000007
#define fst first
#define pb push_back

//ユークリッドの互除法
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x;}


int main()
{
	int N;
	cin >> N;
	int a = -1;
	for (int i = 0; i < N; i++) {
		int h;
		cin >> h;
		if (h == a) {
			a = h;
		}
		else if (h > a) {
			a = h - 1;
		}
		else {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mem(a,x) memset(a,x,sizeof(a))
#define lp(k,a) for(int k=1;k<=a;k++)
#define lp0(k,a) for(int k=0;k<a;k++)
#define lpn(k,n,a) for(int k=n;k<=a;k++)
#define lpd(k,n,a) for(int k=n;k>=a;k--)
#define sc(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d %d",&a,&b)
#define ll long long
#define MAX 100000

using namespace std;

int x, y;
int ans =0;
int main()
{
    //freopen("in.txt","r",stdin);
    cin>>x>>y;
    if(x == 1 && y==1) {
        cout<<1000000<<endl;

    } else {

        if (x ==1 ) ans +=300000;
        if (x ==2 ) ans +=200000;
        if (x ==3 ) ans +=100000;
        if (y ==1 ) ans +=300000;
        if (y ==2 ) ans +=200000;
        if (y ==3 ) ans +=100000;
        cout<<ans<<endl;
    }

    return 0;
}


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

int main(){
  int N,count=1;
  cin>>N;
  ll ans=0;
  vector<ll> A(N);
  vector<ll> B(N+1);
  B.at(0)=0;
  for(int i=0; i<N; i++){
    cin>>A.at(i);
  }
  for(int i=1; i<N+1; i++){
    B.at(i)=A.at(i-1)+B.at(i-1);
  }
  sort(B.begin(),B.end());
  for(int i=1; i<=N; i++){
    if(B.at(i)==B.at(i-1)){
      ans+=count;
      count++;//連続で同じ数が続いたら、nC2=n(n-1)/2=1+2+…+(n-1)と増えていく
    }
    else{
      count=1;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 6404
#include <bits/stdc++.h>
using namespace std;
string a;
int main()
{
    cin>>a;
    string b=a;
    int l=a.size();
    for(int i=0;i<l;i++)
    {
    if(a[i]=='p')
    {
        a[i]='q';
    }
    else if(a[i]=='q')
    {
        a[i]='p';
    }
    else if(a[i]=='d')
    {
        a[i]='b';
    }
    else
    {
        a[i]='d';
    }
    }
    reverse(a.begin(),a.end());
    if(a==b)
    {
        cout<<"Yes"<<endl;
        return 0;
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define SIZE 1000005


ll fact[SIZE],inv_fact[SIZE];

ll mod_pow(ll x,ll count, ll mod){

	if(count == 0)return 1;
	ll ret = mod_pow((x*x)%mod,count/2,mod);
	if(count%2 == 1){

		ret = (ret*x)%mod;
	}
	return ret;
}

ll extgcd(ll a,ll b,ll &x,ll &y){
	ll d = a;
	if(b != 0){
		d = extgcd(b,a%b,y,x);
		y -= (a/b)*x;
	}else{
		x = 1;
		y = 0;
	}
	return d;
}

ll mod_inverse(ll a,ll m){
    ll x,y;
    extgcd(a,m,x,y);
    return (m+x%m)%m;
}

ll nCk(ll n,ll k){

	ll ret = fact[n]*inv_fact[k];
	ret %= MOD;
	ret *= inv_fact[n-k];

	return ret%MOD;
}



int main(){

	fact[0] = 1;
	for(ll i = 1; i < SIZE; i++){
		fact[i] = i*fact[i-1];
		fact[i] %= MOD;
	}
	inv_fact[SIZE-1] = mod_inverse(fact[SIZE-1],MOD);
	for(ll i = SIZE-1; i >= 1; i--){

		inv_fact[i-1] = inv_fact[i]*i;
		inv_fact[i-1] %= MOD;
	}

	ll M,N;
	scanf("%lld %lld",&M,&N);

	if(M > N){

		swap(M,N);
	}

	if(M == N){

		printf("%lld\n",((fact[M]*fact[N])%MOD*2)%MOD);

	}else if(N == M+1){

		printf("%lld\n",(fact[M]*fact[N])%MOD);

	}else{

		printf("0\n");
	}

	return 0;
}


Measured memory_bytes: 19376
#include <bits/stdc++.h>
#define range(i, l, r) for(long long int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (long long int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint N, K; cin >> N >> K;
    vec<lint> x_list(N);
    range(i, 0, N) {
        cin >> x_list.at(i);
    }
    lint ans = 0;
    for (const auto& x : x_list) {
        ans += 2 * min(x, K - x);
    }
    cout << ans << "\n";
}

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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

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

vector<pair<ll, int>>factorize(ll n){
  vector<pair<ll, int>> res;
  for(ll i = 2; i * i <= n; ++i){
    if(n % i) continue;
    res.emplace_back(i, 0);
    while(n % i == 0){
      n /= i;
      res.back().second++;
    }
  }
if(n != 1) res.emplace_back(n, 1);
return res;

}



int main(){
ll a, b;
cin >> a >> b;
ll g = gcd(a, b);
auto f = factorize(g);
int ans = f.size() + 1;
cout << ans << endl;

}

Measured memory_bytes: 256
/*
 * Author: .-O_O-.
 */
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nx cout<<"\n"
#define int long long
const ll mod = 1000000007;
const ll maxn = 200005;
const ll mm = 1e+18;
void solve()
{
    set<int>s;
    int n;
    cin>>n;
    int k;
    cin>>k;
    vector<int>gr[n+1];
    rep1(i,k){
        int d;
        cin>>d;
        rep0(i,d){
            int x;
            cin>>x;
            gr[x].pb(i);
        }
    }
    int ans=0;
    rep1(i,n){
        if(!(int)(gr[i].si)) ans++;
    }
    pr(ans);
}
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //srand(time(0));
    //freopen("sp.txt","w",stdout);
    //cin>>t;
    rep1(_i,t){
        //cout<<"Case #"<<_i<<": ";
        solve();
        //nx;
    }
    return 0;
}


Measured memory_bytes: 3708
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<cmath>
#include<cstring>
using namespace std;

void dfs(int u);
void rdfs(int u);
bool vis[256],rvis[256];
vector<int>start[256];  
vector<int>goal[256];

int main(){
  int m,n,d[256];

  while(1){

    fill(vis,vis+256,false);
    fill(rvis,rvis+256,false);
    fill(d,d+256,0);
    scanf("%d",&m);
    if(m==0) break;
    scanf("%d",&n);
    for(int i=0;i<=n+1;i++){
      start[i].clear(),goal[i].clear();
    }
    for(int i=1;i<=n;i++){
      scanf("%d",&d[i]);
    }

    for(int i=0;i<=n;i++){
      for(int j=1;j<=m;j++){
	int next=i+j+d[i+j];
	next=min(max(next,0),n+1);
	start[i].push_back(next);
	goal[next].push_back(i);
      }
    }

    dfs(0);
    rdfs(n+1);

    bool judge=true;
    for(int i=0;i<=n;i++){
      if(vis[i]&&!rvis[i]) judge=false;
    } 
    
    if(judge) printf("OK\n");
    else printf("NG\n");
  }

  return 0;
}

void dfs(int u){
  vis[u]=true;

  for(int i=0;i<start[u].size();i++){
    if(!vis[start[u][i]]) dfs(start[u][i]);
  }
}

void rdfs(int u){
  rvis[u]=true;

  for(int i=0;i<goal[u].size();i++){
    if(!rvis[goal[u][i]]) rdfs(goal[u][i]);
  }
}



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

using namespace std;
typedef long long ll;

int main(){
    ll h, w;
    cin >> h >> w;
    vector<string> map(h);
    for(int i = 0; i < h; ++i){
        cin >> map.at(i);
    }

    for(int i = -1; i <= w; ++i){
        cout << '#';
    }
    cout << endl;

    for(int i = 0; i < h; ++i){
        cout << '#';
        cout << map.at(i);
        cout << '#' << endl;
    }

    for(int i = -1; i <= w; ++i){
        cout << '#';
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 760
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n,m;
	pair<long long,long long> p[100010];
	cin>>n>>m;
	for(long long i=0;i<n;i++)
	{
		cin>>p[i].first>>p[i].second;
	}
	sort(p,p+n);
	priority_queue<long long> q;
	long long cnt=0,ans=0;
	for(long long j=1;j<=m;j++)
	{
		while(cnt<n&&p[cnt].first<=j)
		{
			q.push(p[cnt].second);
			cnt++;
		}
		if(!q.empty())
		{
			ans+=q.top();
			q.pop();
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 2936
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define inf (ll)1e9
#define mod (ll)(1e9+7)
#define d(x) cerr<<#x<<"="<<x<<endl;
#define p(x) cout<<(x)<<endl
#define ps(x) cout<<(x);
#define pfix(d,x) cout << fixed << setprecision(d) << x << endl;
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define minel(v) *min_element(all(v))
#define minind(v) distance((v).begin(), min_element(all(v)))
#define maxel(v) *max_element(all(v))
#define maxind(v) distance((v).begin(), max_element(all(v)))
#define fi first
#define se second
ll a,b,d,n,m,x,y,z,k,h,w,sum,mi,ma,ans,s,t,l,r,res,tmp,itr,q;
bool flag;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int dx8[8]={1,1,0,-1,-1,-1,0,1},dy8[8]={0,1,1,1,0,-1,-1,-1};
char cha;
string st;
typedef map<int, int> imap;
typedef pair<ll, ll> P;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<pair<int,int> > VP;

int main(){
    cin>>n>>m;
    p((ll)((1900*m+(n-m)*100)*pow(2,m)));
    return 0;
}


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

#define rep(i, N) for (int i = 0; i < N; i++)

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

    sort(A.rbegin(), A.rend());
    unordered_map<int, set<int>> a_to_indice;
    rep(i, N) a_to_indice[A[i]].insert(i);

    // make pair
    int npair = 0;
    rep(i, N)
    {
        int a = A[i];
        // cout << "--------" << endl;
        // cout << a << endl;
        if (a == 0) // already paired
            continue;
        a_to_indice[a].erase(i);
        A[i] = 0;

        int power_of_two = pow(2, (int)floor(log2(a)) + 1);
        int b = power_of_two - a;
        if (!a_to_indice[b].empty())
        {
            // cout << a << endl;
            int index_b = *a_to_indice[b].begin();
            // cout << index_b << endl;
            a_to_indice[b].erase(index_b);
            A[index_b] = 0;
            npair++;
        }
    }

    cout << npair << endl;
}

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

int main()
{
    long long A, B, C, K;
    cin >> A >> B >> C >> K;
    long long ans;
    int x1 = min(A, K);
    K -= x1;
    int x2 = min(B, K);
    K -= x2;
    int x3 = min(C, K);
    cout << x1 - x3 << endl;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#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++)
const ll MAX = 1001001;
const ll MOD = 1000000007;
int main()
{
    ll a, b, c;
    cin >> a >> b >> c;
    ll l = max({a, b, c});
    ll s = min({a, b, c});
    cout << l - s << endl;
}

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

int main() {
    int N;
    cin >> N;
    int A[N];
    int counter = 0;
    int i;

    for(i = 0; i < N; i++) {
        cin >> A[i];
    }

    while(1) {
        for(i = 0; i < N; i++) {
            if(A[i] % 2 == 1) { break; }
            A[i] /= 2;
        }

        if(i == N) { ++counter; }
        else { break; }
    }
    
    cout << counter << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
import math
import bisect

def solve(B):
    n = len(B) + 1
    A = [-10 ** 18] * n
    for i in range(n):
        min_val = 10 ** 18
        if i < n - 1:
            min_val = min(min_val, B[i])
        if i - 1 >= 0:
            min_val = min(min_val, B[i-1])
        A[i] = min_val
    '''
    print('n: ' + str(n))
    print('A: %s' % str(A))
    print('B: %s' % str(B))
    '''
    return A

def main():
    n = int(input())
    B = list(map(int, input().split()))
    A = solve(B)
    print(sum(A))

if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
import math
while True:
    N = int(input())
    if N == 0:break
    table = list(map(int,input().split()))

    B = sum(table)/N

    squre_table =  [i ** 2 for i in table]
    A = sum(squre_table)/N
    
    print("%.10f"%(math.sqrt(A-B*B)))


Measured memory_bytes: 5700
def main():
    n = int(input())
    dic = {}
    mx = 0
    for i in range(n):
        s = input()
        if s in dic:
            dic[s] += 1
        else:
            dic[s] = 1
        mx = max(mx,dic[s])
    l = []
    for k,v in dic.items():
        if v == mx:
            l.append(k)
    l.sort()
    for i in l:
        print(i)


if __name__ == "__main__":
    main()

Measured memory_bytes: 32148
X, N = map(int, input().split())
p = list(map(int, input().split()))

ans = 101
i = 101

while i != -1:
    a = 0
    for j in range(0,N):
        if i == p[j]:
            a = 1
    if a == 0 and abs(i-X) <= abs(ans-X):
        ans = i
    i -= 1

print(ans)
        


Measured memory_bytes: 9116
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		//?????????????????????
	    Scanner scan = new Scanner(System.in);

        while(scan.hasNext()) {
          	    String num1 = scan.next();
	 	int int1 = Integer.parseInt(num1);

	    String num2 = scan.next();
	    int int2 = Integer.parseInt(num2);

	    int kei = int1 + int2;
	    int keilen = String.valueOf(kei).length();
	    System.out.println(keilen);
        }
	    scan.close();

}
}

Measured memory_bytes: 26320
#include<stdio.h>
#define MAX 10000000
int main(){
    int a,b,c;
    int m=1;
    scanf("%d%d%d",&a,&b,&c);
    for(m=1;m<=MAX;m++){
        if(m*a%b==c){
            printf("YES\n");
            return 0;
        }
    }
    printf("NO\n");
    return 0;
}


Measured memory_bytes: 128
package com.example.alds1.eight

import java.util.*

fun main(args:  Array<String>) {
    try {
        val sc = Scanner(System.`in`)
        val n = sc.nextInt()
        val tree = TreeForI()
        for (i in 0 until n) {
            var key: Int?
            val instruction = sc.next()!!
            if (instruction == "insert") {
                key = sc.nextInt()
                tree.insert(NodeForI(key = key))
            }
            if (instruction == "print") {
                tree.printInorder(tree.root)
                println()
                tree.printPreorder(tree.root)
                println()
            }
        }
    } catch( e: Exception) {
        println(e)
    }
}

class TreeForI(
        var root: NodeForI? = null
) {
    fun insert(newNode: NodeForI) {
        var currentNode: NodeForI? = null
        var nodeParent = root
        while (nodeParent != null) {
            currentNode = nodeParent
            if (newNode.key < nodeParent.key) {
                nodeParent = nodeParent.left
            } else {
                nodeParent = nodeParent.right
            }
        }

        newNode.parent = currentNode
        if (currentNode == null) {
            root = newNode
        } else if (newNode.key < currentNode.key) {
            currentNode.left = newNode
        } else {
            currentNode.right = newNode
        }
    }

    fun printPreorder(node: NodeForI?) {
        if (node == null) return
        print(" ${node.key}")
        printPreorder(node.left)
        printPreorder(node.right)
    }

    fun printInorder(node: NodeForI?) {
        if (node == null) return
        printInorder(node.left)
        print(" ${node.key}")
        printInorder(node.right)
    }
}

class NodeForI(
        var parent: NodeForI? = null,
        var left: NodeForI? = null,
        var right: NodeForI? = null,
        var key: Int = 0
)




Measured memory_bytes: 199116
#include <cstdio>

#include <cmath>
#include <cstring>
#define ll long long
#define f(x,y,z) for(int x=y;x<=z;x++)
using namespace std;
char s[20];
int b[20],a[20],l,sum;
void p(int x)
{
	f(i,0,l-1)b[i]=a[i];
	b[l-1]+=x;
	//printf("b:");
	//f(i,0,l-1)printf(" %d",b[i]);printf("\n");
	int now=l-1,temp=0;
	while(now>=0)
	{
		b[now]+=temp;
		temp=b[now]/10;
		b[now]=(b[now]+10)%10;
		now--;
	}
	bool ok=0;
	if(temp!=0)
	{
		ok=1;
		printf("%d",temp);
	}
	//printf("?");
	f(i,0,l-1)
	{
		if(b[i]!=0)ok=1;
		if(ok)printf("%d",b[i]);
	}
	if(!ok)printf("0");
	printf(" ");
}
int main()
{
	scanf("%s",s);
	l=strlen(s);
	sum=0;
	f(i,0,l-1)
	{
		sum=sum*10+s[i]-'0';
		a[i]=sum/50;
		sum%=50;
	}
	a[l-1]+=49;
	printf("50\n");
	f(i,1,50-sum)p(-sum);
	f(i,1,sum)p(51-sum);
}

Measured memory_bytes: 128
N, K = map(int, input().split())

def cmb(n, r, mod):
  if(r<0 or r>n):
    return 0
  r = min(r, n-r)
  return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9 + 7
Nmax = 2000
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

for i in range(2, Nmax+1):
  g1.append((g1[-1] * i) % mod)
  inverse.append((-inverse[mod%i] * (mod//i)) % mod)
  g2.append((g2[-1] * inverse[-1]) % mod)

# ここまで前処理 --------//

for i in range(1, K+1):
  # 青の位置
  ans1 = cmb(N-K+1, i, mod)
  #print(N-K+1, i, ans1)

  # 青の振分け
  if i == 1:
    ans2 = 1
  else:
    ans2 = cmb(K-1, i-1, mod)
  #print(K-1, i-1, ans2)

  ans = (ans1 * ans2) % mod
  print(ans)

Measured memory_bytes: 3572
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <stack>
#include <deque>
#include <cmath>

#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

using ll = long long;
using namespace std;
constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int MOD = 1000000007;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n;
cin>>n;
vector<int> d(n);
rep(i,n){
    int d1,d2;
    cin>>d1>>d2;
    d[i]=d1-d2;
}
int cnt=0;
rep(i,n){
    if(d[i]==0){
        cnt++;
    }
    else{
        cnt=0;
    }
    if(cnt>=3)break;
}
if(cnt>=3)cout<<"Yes"<<endl;
else cout<<"No"<<endl;
return 0;
}

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

int main() {
  long N, M, HWdaysum = 0;
  cin >> N >> M;
  vector<long> HWday(M);
  
  
  for (int i = 0; i < M; i++) {
    cin >> HWday.at(i);
  }

  for (int i = 0; i < M; i++) {
    HWdaysum += HWday.at(i);
  }
  
  if(N >= HWdaysum){
    cout << N - HWdaysum << endl;
  }else{
    cout << -1 << endl;
  }
}

Measured memory_bytes: 3652
n,q=map(int,input().split())
s=input()
cnt=[0]*n
for i in range(n-1):
    if s[i:i+2]=="AC":
      cnt[i+1]=cnt[i]+1
    else:
      cnt[i+1]=cnt[i]
for i in range(q):
    li,ri=map(int,input().split())
    print(cnt[ri-1]-cnt[li-1])


Measured memory_bytes: 6188
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

#define mod 1000000007
#define limit 200001
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(i = 0; i < n; i++)
#define max(a,b) {if(a>b){return a;}return b;}
#define min(a,b) {if(a<b){return a;}return b;}
int up_int(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_int(const void *a, const void *b){return *(int*)b - *(int*)a;}
int up_char(const void *left, const void *right) {return strcmp((char *)left,(char *)right);}

int main(){
    int n,k,i,j,count=0;
    int d[101];
    int a[101][101];
    int flag[101] = {0};
    
    scanf("%d %d",&n,&k);
    for(i = 1; i <= k; i++){
        scanf("%d",&d[i]);
        for(j = 1; j <= d[i]; j++){
            scanf("%d",&a[i][j]);
        }
    }
    
//    for(i = 1; i <= k; i++){
//        for(j = 1; j <= d[i]; j++){
//            printf("%d ",a[i][j]);
//        }
//        printf("\n");
//    }
    
    for(i = 1; i <= k; i++){
        for(j = 1; j <= d[i]; j++){
            flag[a[i][j]]++;
        }
    }
    
//    for(i = 1; i <= n; i++) printf("%d\n",flag[i]);
    
    for(i = 1; i <= n; i++){
        if(flag[i] == 0) count++;
    }
    printf("%d\n",count);
    return 0;
}


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

int main() {
  int N, K;
  cin >> N >> K;
  string S;
  cin >> S;
  int count = 0;
  for(int i = 0; i < N - 1; i++) {
    if(S.at(i) == 'R' && S.at(i + 1) == 'L') {
      count++;
    }
  }
  int edge = 0;
  if(S.at(0) == 'L') {
    edge++;
  }
  if(S.at(N - 1) == 'R') {
    edge++;
  }
  if(count >= K) {
    cout << N - 2 * count - edge + 2 * K << endl;
  }
  else {
    cout << N - 1 << endl;
  }
}

Measured memory_bytes: 512
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
#pragma warning(disable:4996)
int dp[100001];



int solve(int n)
{
	if (n == 0)
		return 0;	
	int &ret = dp[n];
	if (ret != -1)
		return ret;
	ret = solve(n - 1)+1;
	for (int i = 6; i <= n; i *= 6) {
		if (n >= i)
			ret = min(ret, solve(n - i) + 1);
	}
	for (int i = 9; i <= n; i *= 9) {
		if (n >= i)
			ret = min(ret, solve(n - i) + 1);
	}
	return ret;
}

int main()
{
	int n;
	scanf("%d", &n);
	memset(dp, -1, sizeof(dp));
	printf("%d", solve(n));
	return 0;

}

Measured memory_bytes: 3712
H, W = map(int, input().split())
N = int(input())
*A, = map(int, input().split())

C = []
for i,a in enumerate(A,1):
    C += [i]*a

for i in range(H):
    if i%2==0:
        print(*C[i*W:i*W+W])
    else:
        print(*C[i*W:i*W+W][::-1])

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


int main() {
  
  long H;
  cin>>H;
  
  long sw=0;
  long sw1=0;
  
  while(H!=1){
    sw++;
    H=H/2;
  }
  
  for(int i=0;i<sw;i++){
    sw1=sw1+pow(2,i);
  }
  
  long sw2=pow(2,sw);
  
  long sw3=sw1+sw2;
  
  
  cout<<sw3<<endl;
  
}



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

def SUM(a):
    L=len(a)
    ans=0
    for i in range(L):
        ans+=a[i]
    return ans

def check(a):
    if all(A[i-1]+A[i]<=x for i in range(1,N)):
        return 1
    else:
        return 0

if check(A)==1:
    print(0)
    exit()

SA=SUM(A)
count=0

for i in range(N):
    if A[i]>x:
        A[i]=x

count=SA-SUM(A)

if check(A)==1:
    print(count)
    exit()
else:
    count=0

for j in range(1,N):
    if A[j-1]+A[j]>x:
        s=A[j]+A[j-1]
        A[j]=A[j]+x-s
    else:
        pass

count=SA-SUM(A)

print(count)


Measured memory_bytes: 14436
/**
 *  Hi, I'm Arpan.
 *  Hardwork beats talent if talents doesn't work hard, friend me if you want to. ✌.|•͡˘‿•͡˘|.✌
 *
*/

#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
#define inv(v)         \
    for (auto &it : v) \
        cin >> it;
#define MOD 1000000007
#define pb push_back

ll power(ll x, ll y)
{
    ll temp;
    if( y == 0)
        return 1;
    temp = power(x, y/2);
    if (y%2 == 0)
        return temp*temp;
    else
        return x*temp*temp;
}

void solve()
{
	ll n;
	cin >> n;
	string ans = "";
	while(n > 0){
		ans = (char) (97 + (n-1)%26) + ans;
        n = (n-1)/26;
		}
	cout << ans;

}

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


Measured memory_bytes: 3596
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


n = int(input())
count = len(make_divisors(n-1))
# print(count)
yaku = make_divisors(n)
for e in yaku[1:-1]:
    # print(e)
    if e*e > n:
        break
    num = n
    while num%e == 0:
        num //= e
        if num == 1:
            count += 1
            break
        if num < e:
            break
        if (num-1)%e == 0:
            count += 1
            break

print(count)


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

#define int long long int
#define double long double
#define pb push_back
#define fi first
#define se second
#define vii vector<int>
#define pii pair<int,int>
#define vpii vector<pii>
#define pq priority_queue<int>
#define test int tcase; cin>>tcase; for(int tc = 1; tc <= tcase; tc++)
#define inp(a,n,f) int a[n+f];for(int hh=f;hh<n+f;hh++)cin>>a[hh];
#define prdec(k) cout<<fixed<<setprecision(k);
#define mem(a,k) memset(a,k,sizeof(a))
#define ub upper_bound
#define lb lower_bound
#define mii map<int,int>
#define all(v) v.begin(),v.end()
#define inf LLONG_MAX


signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int x,y;
	cin>>x>>y;
	if(y%2==0)
	{
		int b=y/2-x;
		int a=2*x-y/2;
		if(a>=0&&b>=0)
			cout<<"Yes";
		else
			cout<<"No";
	}	
	else
		cout<<"No";
	return 0;
}


Measured memory_bytes: 3660
program ddd
implicit none

integer(8) :: n, w, i, j
integer(8),allocatable,dimension(:) :: g, v, dp

read*, n, w
allocate(g(n))
allocate(v(n))
allocate(dp(0:w))
do i=1,n
read*, g(i), v(i)
end do
dp=0

do j=1, n
 do i=w,0,-1
 if(i>=g(j)) then
 dp(i)=max(dp(i),dp(i-g(j))+v(j))
 end if
 end do
end do

write(*,'(i0)') dp(w)

end program

Measured memory_bytes: 1024