akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b){return *(char*)a - *(char*)b;} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b){return strcmp(*(const char **)a, *(const char **)b);} /* aaa,aab.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

int main(void) {
  int H, W;
  scanf("%d %d", &H, &W);
  char a[101][101];
  rep(hi, 0, H) {
    scanf("%s", a[hi]);
  }

  // 1行空白のものを見つける
  rep(hi, 0, H) {
    int judge = 1;
    rep(wi, 0, W) {
      if (a[hi][wi] == '.') continue;
      judge = 0;
      break;
    }
    if (judge) {
      rep(wi, 0, W) {
        a[hi][wi] = ' ';
      }
    }
  }
  // 1列空白のものを見つける
  rep(wi, 0, W) {
    int judge = 1;
    rep(hi, 0, H) {
      if (a[hi][wi] == '.' || a[hi][wi] == ' ') continue;
      judge = 0;
      break;
    }
    if (judge) {
      rep(hi, 0, H) {
        a[hi][wi] = ' ';
      }
    }
  }

  // 答えを出力
  rep(hi, 0, H) {
    int judge = 0;
    rep(wi, 0, W) {
      if (a[hi][wi] == ' ') continue;
      judge = 1;
      printf("%c", a[hi][wi]);
    }
    if ( judge ) printf("\n");
  }
  return 0;
}


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

int main()
{
    int a, b, c, d, e;

    cin >> a >> b >> c >> d >> e;

    if (a == 0)
    {
        cout << 1;
    }
    else if (b == 0)
    {
        cout << 2;
    }
    else if (c == 0)
    {
        cout << 3;
    }
    else if (d == 0)
    {
        cout << 4;
    }
    else if (e == 0)
    {
        cout << 5;
    }

    return 0;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int cnt1 = 0,cnt2 = 0;
	int res1 = 0,res2 = 0;
	int minl = 0x7fffffff;
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		int x;
		scanf("%d",&x);
		if(x%10)
		{
			cnt1 ++;
			minl = min (minl,x);
			res1 = res1 + x;
		}
		else res2 = res2 + x;
	}
	if(cnt1)
	{
		if(res1%10==0) res1 -= minl;
		printf("%d\n",res1 + res2);
	}
	else printf("%d\n",0);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define vv vector
#define pp pair
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define fastio                    \
	ios_base::sync_with_stdio(0); \
	cin.tie(0);
typedef pair<ll, ll> pll;
typedef vv<ll> vll;
typedef vv<pll> vpll;
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
//adds two more functions to set
//(1)*(set.find_by_order(k))[kth element in the sorted set]
//(2)set.order_of_key(k)[count of elements strictly less than k]
#define LG(args...)                               \
	{                                             \
		string _s = #args;                        \
		replace(_s.begin(), _s.end(), ',', ' ');  \
		stringstream _ss(_s);                     \
		err(istream_iterator<string>(_ss), args); \
		cerr << endl;                             \
	}
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << "(" << *it << ":" << a << ") ";
	err(++it, args...);
}
//:::::::::::::::::::::::::::::::::::::::::::::
const ll INF = 9e18;
const ll MOD = 1e9 + 7;
// #define dbg

int main(){
	fastio;
	ll a,b,k;
	cin>>a>>b>>k;
	if(a >= k){
		a-=k;
	}
	else{
		b-= k-a;
		a=0;
		// LG(a,b)
		if(b<0)
			b=0;
	}

	cout<<a<<" "<<b<<endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))

def main():
	N = inputInt()
	A = inputList()

	ans = 0
	tmp = 1
	for i,val in enumerate(A):
		if val == tmp:
			tmp += 1
		else:
			ans += 1

	if tmp == 1:
		print(-1)
	else:
		print(ans)

if __name__ == "__main__":
	main()


Measured memory_bytes: 72688
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef long double ld;

#define llset tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define en '\n'
#define S second
#define F first
#define pll pair<ll,ll>
#define PB push_back

const ll N = 1e6+7;
ll mod = 1e9+7;
#define calncr for(int i=1  ;i<=1e6;i++) fac[i] = (fac[i-1]*i)%mod;
ll fac[N] = {0};

ll gen_base(const ll before, const ll after) {
    auto seed = std::chrono::high_resolution_clock::now().time_since_epoch().count();
    std::mt19937 mt_rand(seed);
    int base = std::uniform_int_distribution<ll>(before+1, after)(mt_rand);
    return base % 2 == 0 ? base-1 : base;
}

ll pow(ll a,ll b)
{
    if(!b)
        return 1;
    ll p = pow(a,b/2);
    if(b%2)
        return (a*((p*p)%mod))%mod;
    else
        return (p*p)%mod;
}

ll modInv(ll a)
{
    //cout<<a<<" "<<mod<<en;
    return pow(a%mod,mod-2);
}

ll nCr(ll n,ll r)
{
    return (fac[n]*modInv((fac[r]*fac[n-r])%mod))%mod;
}

ll hashf(ll r,ll x,ll mod)
{
    return (x+r)%mod;
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    fac[0] = 1;
    calncr;
    ll n;
    cin>>n;
    ll arr[n],sm=0;
    for(ll i=0;i<n;i++){
        cin>>arr[i];
        sm = (sm+arr[i])%mod;
    }
    ll ans=0;
    for(ll i=1;i<n;i++){
        sm = (sm-arr[i-1]+mod)%mod;
        ans = (ans+(sm*arr[i-1])%mod)%mod;
    }
    cout<<ans;
}


Measured memory_bytes: 13032
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i=0;i < (int)(n);i++)

int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    rep(i,n) cin >> v[i];
    sort(v.begin(),v.end());
    auto itr = unique(v.begin(),v.end());
    v.erase(itr,v.end());
    cout << v.size() << endl;
    return 0;
    
}

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

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;

fn main() {
    input!{
      n: usize,
      aa: [usize; n],
    }
    if n == 1 {
        return println!("{}", 1)
    }

    let mut mode = 0;
    let mut ans = 0;
    for i in 1..n {
        if aa[i] != aa[i-1] {
            if mode == 0 {
                mode = if aa[i] > aa[i-1] { 1 } else { 2  }
            } else if mode == 1 {
                if aa[i] < aa[i-1] {
                    mode = 0;
                    ans += 1;
                }
            } else {
                if aa[i] > aa[i-1] {
                    mode = 0;
                    ans += 1;
                }
            }
        }
    }
    println!("{}", ans+1);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int x1,x2,x3,x4,x5;
    scanf("%d %d %d %d %d", &x1, &x2 ,&x3 ,&x4, &x5);
    if(x1==0){
        printf("1\n");
    }
    else if(x2==0){
        printf("2\n");
    }
    else if(x3==0){
        printf("3\n");
    }
    else if(x4==0){
        printf("4\n");
    }
    else if(x5==0){
        printf("5\n");
    }
}

Measured memory_bytes: 3656
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(1000000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


def gcd(n, m):
    if n % m == 0:
        return m
    else:
        return gcd(m, n % m)


def gcd_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = gcd(v, L[i])

    return v


def lcm(n, m):
    return (n * m) // gcd(n, m)


def lcm_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = lcm(v, L[i])

    return v


# Width First Search (+ Distance)
def wfs_d(D, N, K):
    """
    D: 隣接行列(距離付き)
    N: ノード数
    K: 始点ノード
    """

    dfk = [-1] * (N + 1)
    dfk[K] = 0

    cps = [(K, 0)]
    r = [False] * (N + 1)
    r[K] = True
    while len(cps) != 0:
        n_cps = []
        for cp, cd in cps:
            for i, dfcp in enumerate(D[cp]):
                if dfcp != -1 and not r[i]:
                    dfk[i] = cd + dfcp
                    n_cps.append((i, cd + dfcp))
                    r[i] = True

        cps = n_cps[:]

    return dfk


# Depth First Search (+Distance)
def dfs_d(v, pre, dist):
    """
    v:  現在のノード
    pre: １つ前のノード
    dist: 現在の距離

    以下は別途用意する
    D: 隣接リスト(行列ではない)
    D_dfs_d: dfs_d関数で用いる，始点ノードから見た距離リスト
    """

    global D
    global D_dfs_d

    D_dfs_d[v] = dist

    for next_v, d in D[v]:
        if next_v != pre:
            dfs_d(next_v, v, dist + d)

    return


def sigma(N):
    ans = 0
    for i in range(1, N + 1):
        ans += i
    return ans


def comb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def bisearch(L, target):
    low = 0
    high = len(L) - 1
    
    while low <= high:
        mid = (low + high) // 2
        guess = L[mid]
        if guess == target:
            return True
        elif guess < target:
            low = mid + 1
        elif guess > target:
            high = mid - 1
    if guess != target:
        return False

# --------------------------------------------

dp = None


def main():
    A, B, C = li_input()
    print("Yes") if B >= C >= A else print("No")


main()


Measured memory_bytes: 5152
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
def pri(x): print('\n'.join(map(str, x)))

N, M = map(int, input().split())
C = list(map(int, input().split()))
MAX = 20

dp = [list(range(N+1)) for _ in range(M+1)]

for i in range(1, M+1):
    c = C[i-1]
    for j in range(N+1):
        if j-c>=0:
            dp[i][j] = min(dp[i-1][j-c]+1, dp[i-1][j], dp[i][j-c]+1)
        else:
            dp[i][j] = dp[i-1][j]
#    pri(dp)
print(dp[M][N])



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

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    int a, b;
    vector<int> c(n, 0);
    for (int i = 0; i < m; i++) {
        cin >> a >> b;
        c[a - 1]++;
        c[b - 1]++;
    }

    for (int i = 0; i < n; i++) {
        if (c[i] % 2 == 1) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define what_is(x) cerr << #x <<" is " << x << endl;
typedef long long ll;
const int MOD = 998244353;
const double PI = 3.141592653589793;
const ll INF =  1e18 + 7;
const int nax = 200005;


double power(double a, ll b) {
	double ans = 1;
	while (b) {
		if (b & 1) {
			ans = (ans * a);
		}
		a = (a * a);
		b = b >> 1;
	}
	return ans;
}


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int tc = 1;
	// cin >> tc;
	while (tc--) {
		ll x;
		cin >> x;
		ll tt = 0;
		ll ans = 100;
		while (ans < x) {
			ans = ans * power(1.0100000000000, 1);
			ans = (ll)ans;
			what_is(ans);
			tt++;
		}
		cout << tt;
	}
	return 0;
}




















Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 200005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	   c = getchar();
    }
    while(c >= '0' && c <= '9') {
    	res = res * 10 +c - '0';
    	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
    	out(x / 10);
    }
    putchar('0' + x % 10);
}
int D,N,a[MAXN],cnt[MAXN];
void Solve() {
    read(N);
    for(int i = 1 ; i <= N ; ++i) {read(a[i]);cnt[a[i]]++;}
    for(int i = 1 ; i <= N ; ++i) D = max(D,a[i]);
    if(D & 1) {
        if(cnt[D / 2 + 1] != 2) {puts("Impossible");return;}
        int res = 0;
        for(int i = D / 2 + 1 ; i <= D ; ++i) {
            res += cnt[i];
            if(cnt[i] < 2) {puts("Impossible");return;}
        }
        if(res != N) {puts("Impossible");return;}
    }
    else {
        if(cnt[D / 2] != 1) {puts("Impossible");return;}
        int res = 1;
        for(int i = D / 2 + 1 ; i <= D ; ++i) {
            res += cnt[i];
            if(cnt[i] < 2) {puts("Impossible");return;}
        }
        if(res != N) {puts("Impossible");return;}
    }
    puts("Possible");return;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int gcd(long int a, long int b){
    long int min_ = min(a, b);
    long int max_ = max(a, b);
    if (min_ == 0)
        return max_;
    else
        return gcd(min_, max_%min_);
}
int main(void){
    long int A, B, C, D;
    cin >> A >> B >> C >> D;
    long int lcm;
    lcm = C / gcd(C, D) * D;
    long int c, d, cd;
    c = B / C - (A-1) / C;
    d = B / D - (A-1) / D;
    cd = B / lcm - (A-1) / lcm;
    cout << B - A - c - d + cd + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())

data = []
for i in range(N):
    name, point = input().split()
    data.append({'id': i + 1, 'name': name, 'point': 100 - int(point)})

data.sort(key=lambda x: [x['name'], x['point']])

res = [d['id'] for d in data]

print(*res, sep='\n')

Measured memory_bytes: 3064
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline
S = input()

l = S.split("/")

ans = "Heisei"
if int(l[0]) > 2019:
    ans = "TBD"
elif l[0] == "2019":
    if int(l[1]) > 4:
        ans = "TBD"
print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int N,cnt;
vector<int>A;
void bubbleSort(){
  bool flag=true;
  while(flag){
    flag=false;
    for(int i=N-1;i>0;i--){
      if(A[i]<A[i-1]){
        swap(A[i],A[i-1]);
        flag=true;
        cnt++;
      }
    }
  }
}
int main(void){
  cin>>N;
  A.resize(N);
  for(int i=0;i<N;i++)cin>>A[i];
  bubbleSort();
  for(int i=0;i<N;i++)cout<<A[i]<<(i==N-1?'\n':' ');
  cout<<cnt<<endl;
  return 0;
}



Measured memory_bytes: 3120
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        
        final int N = Integer.parseInt(sc.next());
        final int M = Integer.parseInt(sc.next());
        int maxStart = 0;
        int minEnd = 1000000;
        for (int i = 0; i < M; i++) {
            int start = Integer.parseInt(sc.next());
            int end = Integer.parseInt(sc.next());
            maxStart = Math.max(maxStart, start);
            minEnd = Math.min(minEnd, end);
        }
        
        out.println(minEnd >= maxStart ? minEnd - maxStart + 1 : "0");
        
        out.flush();
    }
}

Measured memory_bytes: 48024
import java.util.Scanner;

public class Main {

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

	public static void main(String[] args) {
		int a = sc.nextInt(), b = sc.nextInt();
		if (a * b == 15) {
			System.out.println("*");
		} else if (a + b == 15) {
			System.out.println("+");
		} else {
			System.out.println("x");
		}
	}
}

Measured memory_bytes: 21716
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int max,a,b,c,d,i,j;
        int answer = 0;;
        while(sc.hasNext()) {
            max = sc.nextInt();
            for(i = 0; i <= 18; i++) {
                for(j = 0; j <= 18; j++) {
                    if (i + j == max) {
                        for(a = i,b = 0; 0 <= a & b <= 9; a--,b++) {
                            for(c = j,d = 0; 0 <= c & d <= 9; c--,d++) {
                                if( a <= 9 & b <= 9 & c <=9 & d <= 9) {
                                	
                                    answer++;
                                }
                            }
                        }
                    }   
                }
            }
            System.out.println(answer);
            answer = 0;
        }
                     
    }
}

Measured memory_bytes: 18700
#define M 99999
T[M],t[M];main(i,j,m,a,b,p,q){
for(i=2;i<M;i++)if(!T[i])for(j=i*2;j<M;j+=i)T[j]=1;
for(i=2,j=0;i<M;i++)if(!T[i])t[j++]=i;
for(;scanf("%d%d%d",&m,&a,&b),m;printf("%d %d\n",p,q))for(i=0;;i++)if(t[i]*t[i]>m)i=-1,m--;else if(p=t[i],q=m/t[i],p*q==m&&!T[q]&&a*q<=b*p)break;
exit(0);}

Measured memory_bytes: 1028
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;
typedef string::const_iterator State;
class ParseError {};

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

constexpr ll INF = 1e16;
constexpr ll INM = 114514;
constexpr ll MOD = 1e9 + 7;
constexpr ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll powm(ll a, ll b, ll c) {
	if (b == 0)
		return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	} else
		return (a * powm(a, b - 1, c)) % c;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll dx[4] = {1, 0, -1, 0};
ll dy[4] = {0, 1, 0, -1};

constexpr int MAXN = 1000;
constexpr int MAXV = MAXN * (MAXN - 1) / 2;
vector<int> g[MAXV];
int a[MAXN][MAXN - 1];
int id[MAXN][MAXN - 1];
bool used[MAXV] = {};
bool ok			= true;
int dp[MAXV]	= {};

int dfs(int i) {
	if (dp[i]) {
		if (!used[i]) {
			return -1;
		}
		return dp[i];
	}
	dp[i] = 1;
	for (auto j : g[i]) {
		int v = dfs(j);
		if (v == -1) return -1;
		dp[i] = max(dp[i], dfs(j) + 1);
	}
	used[i] = true;
	return dp[i];
}

int main() {
	IOS();
	ll n, v = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n - 1; j++) {
			cin >> a[i][j];
			a[i][j]--;
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (i < j) {
				id[i][j] = v++;
			}
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n - 2; j++) {
			int x = i, y1 = a[i][j], y2 = a[i][j + 1];
			int id1 = id[min(x, y1)][max(x, y1)];
			int id2 = id[min(x, y2)][max(x, y2)];
			if (id1 != id2) {
				g[id1].push_back(id2);
				//cout << id1 << " " << id2 << endl;
			}
		}
	}
	int ans = 0;
	for (int i = 0; i < v; i++) {
		int x = dfs(i);
		if (x == -1) {
			dump(-1);
			return 0;
		}
		ans = max(ans, x);
	}
	dump(ans);
	return 0;
}


Measured memory_bytes: 37888
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main(){
    int n;
    cin >> n;
    string res = "No";
    int seq=0;
    rep(i, n){
        int d[2];
        cin >> d[0] >> d[1];
        if(d[0]==d[1]){
            seq++;
            if(seq>=3){
                res = "Yes";
            }
        }else{
            seq=0;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    reverse(all(S));
    vector<ll> cnt(2019, 0);
    cnt[0] = 1;
    ll ans = 0;
    ll cumsum = 0;
    ll pow = 1;
    for (auto& d : S) {
        int val = d - '0';
        cumsum = (cumsum + val * pow) % 2019;
        ans += cnt[cumsum];
        ++cnt[cumsum];
        pow = (pow * 10) % 2019;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3792
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define rep(i,n) for(int i = 0; i < (n); ++i)
 
typedef long long ll;
typedef char str255[256];

#define BIG_PRIME 1'000'000'007
#define BP_remainder(x) ((x) % BIG_PRIME)

const int INF = 1 << 30;
const int INF_NEG = INF * -1;
const ll INF_LONG = 1LL << 62;
const ll INF_LONG_NEG = INF_LONG * -1;

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

    double ans = 0.0;
    rep(i, N){
        ans += 1.0 / (double)A[i];
    }
    printf("%.6f\n", 1.0 / ans);

    return 0;
}


Measured memory_bytes: 256
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE TypeFamilies #-}
import           Data.Maybe
import           Data.Int
import           Data.List
import           Data.Char
  -- import qualified Data.Vector.Unboxing as VU
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.ByteString.Char8 as BS
import           Data.List (scanl')
import           Data.IORef
import           Control.Monad
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Control.Applicative
import           Debug.Trace
import           Text.Printf


readInt = BS.readInt . BS.dropWhile isSpace
getVector f = VU.unfoldr f <$> BS.getLine
getIntVector = getVector readInt
getBSVector = getVector BS.uncons

main = do
  x <- readLn :: IO Int
  let primeTable = sieve $ 10^6+3
  print $ ans x primeTable

type PrimeTable = VU.Vector Bool

primeTableToList :: PrimeTable -> [Int]
primeTableToList t = [i | i <- [0..VU.length t-1], t VU.! i]

isInPrimeTable :: PrimeTable -> Int -> Bool
isInPrimeTable t n
              | 0 <= n && n < VU.length t = t VU.! n
              | otherwise = error "out of range"

sieve :: Int -> PrimeTable
sieve n = VU.create $ do
  vec <- VUM.replicate (n+1) True
  VUM.write vec 0 False
  VUM.write vec 1 False
  forM_ [2..n] $ \i -> do
    b <- VUM.read vec i
    when b $ do
      forM_ [2*i,3*i..n] $ \j -> do
        VUM.write vec j False
  return vec

ans x primeTable = loop x
  where
    loop n = if isInPrimeTable primeTable n
             then n
             else loop (n+1)


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

#define int long long
#define forn(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int) (x).size())


int32_t main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	string s;
	cin >> s;
	int ans = 0;
	for (int i = 0; i < n;) {
		string sub = s.substr(i, 3);
		if (sub == "ABC") {
			i += 3;
			ans++;
		}
		else {
			i++;
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
import math
import fractions
import copy
import numpy as np
def j(q):
    if q==1: print("Yes")
    elif q == 0:print("No")
    exit(0)
rem = pow(10,9)+7
"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def iprow():
    return [int(i) for i in input().split()]
def ips():
    return (int(i) for i in input().split())
def printrow(a):
    for i in a:
        print(i)
"""
#decomment when needed
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
"""
n,s,e = ips()
a = []
for i in range(n):
    a.append(ip())
p = 0
a.sort()
while s > a[p]:
    p+=1
start = p
while a[p] < e:
    p+=1
    if p==n:break
end = p
print(n - end + start)



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

typedef long long ll;



int main()
{
    
    string s;
    cin>>s;
    int i;
    ll sum=0;
    for(i=0;i<s.length();++i){
        sum+= (int)(s[i]-'0');
    }
    if(sum%9==0){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
}

Measured memory_bytes: 3712
#include<vector>
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<map>
#include<functional>
#include<queue>
#include<stack>
#include<string.h>
#include<list>
#include<limits>
#include<bitset>
#define MOD 10007LL
#define INF 100000000LL
#define MAX 41
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
int main() {    
    int n,ma,mb;
    cin>>n>>ma>>mb;
    int a[MAX],b[MAX],c[MAX];
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i]>>c[i];
    }
    int dp[MAX][1000][1000];
    for(int i=0;i<=n;i++){
        for(int j=0;j<401;j++){
            for(int k=0;k<401;k++){
                dp[i][j][k]=INF;
            }
        }
    }
    dp[0][0][0]=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<401;j++){
            for(int k=0;k<401;k++){
                dp[i+1][j][k]=min(dp[i][j][k],dp[i+1][j][k]);
                dp[i+1][j+a[i]][k+b[i]]=min(dp[i+1][j+a[i]][k+b[i]],dp[i][j][k]+c[i]);
            }
        }
    }
    int ans=INF;
    for(int i=1;i<401;i++){
        for(int j=1;j<401;j++){
            if(i*mb==j*ma){
                ans=min(ans,dp[n][i][j]);
            }
        }
    }
  	if(ans==INF){
		cout<<-1<<endl;
      	return 0;
    }
    cout<<ans<<endl;
}

                           


Measured memory_bytes: 150016
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    int n; cin >> n;
    int ans = 0;
    REP(i, n){
        int r, k;
        cin >> r >> k;
        ans += abs(r - k) + 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
from heapq import heappush, heappop
H, W = map(int, input().split())
A = [list(map(int, input().split())) for i in range(H)]

INF = 10**18
D = [[[INF]*W for i in range(H)] for k in range(H*W+1)]

dd = ((-1, 0), (0, -1), (1, 0), (0, 1))

que = [(0, 0, 0, 0)]
while que:
    cost, d, x, y = heappop(que)
    if D[d][y][x] < cost or d == H*W:
        continue
    for dx, dy in dd:
        nx = x + dx; ny = y + dy
        if not 0 <= nx < W or not 0 <= ny < H:
            continue
        nd = cost + A[ny][nx]*(d*2+1)
        if nd < D[d+1][ny][nx]:
            D[d+1][ny][nx] = nd
            heappush(que, (nd, d+1, nx, ny))
ans = INF
for i in range(H*W+1):
    ans = min(ans, D[i][H-1][W-1])
print(ans)



Measured memory_bytes: 40960
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();

    int c = a-2*b;
    if(c>0){
      System.out.println(c);
    }else{
      System.out.println(0);
    }
  }
}


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

using namespace std;

int const N = 1e5 + 10;

int n;

long long a[N];

void solve ()
{
	long long ans = 0;

	if (n == 1)
	{
		printf ("%lld\n", a[1] / 2LL);
		return;
	}

	for (int i = 2; i <= n; i++)
	{
		if ((a[i] % 2LL) == (a[i - 1] % 2LL))
		{
			ans += ((a[i] + a[i - 1]) / 2LL);
			a[i] = a[i - 1] = 0LL;
		}
		else
		{
			ans += (a[i - 1] / 2LL);

			a[i - 1] %= 2LL;

			if (a[i - 1] == 1 && a[i] > 0)
			{
				a[i]--;
				a[i - 1]--;
				ans++;
			}

			ans += (a[i] / 2LL);

			a[i] %= 2LL;
		}
	}


	printf ("%lld\n", ans);
}

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

		for (int i = 1; i <= n; i++)
			scanf ("%lld", &a[i]);

		solve ();

		return 0;
}

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

int main()
{
  int n;
  cin >> n;
  map<int, int> cnt;
  int maxi = 0;
  for (int i = 0; i < (1 << n); i++) {
    int val;
    cin >> val;
    cnt[val]++;
    maxi = max(maxi, val);
  }
  queue<int> q;
  if (cnt[maxi] != 1) {
    cout << "No\n";
    return 0;
  }
  cnt.erase(maxi);
  q.push(maxi);
  while (!cnt.empty()) {
    int x = q.front();
    q.pop();
    auto it = cnt.lower_bound(x);
    if (it == cnt.begin()) {
      cout << "No\n";
      return 0;
    }
    it = prev(it);
    q.push(it->first);
    it->second--;
    if (it->second == 0) {
      cnt.erase(it);
    }
    q.push(x);
  }
  cout << "Yes\n";
  return 0;
}


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

typedef long long ll;

using namespace std;

const int inf=1000000007;

int main()
{
    ll n, d, ans=0;
    scanf("%lld%lld",&n,&d);
    for(int i=0;i<n;i++)
    {
        ll x, y;
        scanf("%lld%lld",&x,&y);
        if(x*x+y*y<=d*d)
        {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
 
    int64_t n,a,b;
    cin>>n>>a>>b;

    if(abs(a-b)%2==0)
        cout<<abs(a-b)/2<<endl;
    else if(min(a,b)-1<=n-max(a,b)){
        cout<<min(a,b)+1+max(max(a,b)-(min(a,b)+1),(int64_t)0)/2-1<<endl;
    }else{
        cout<<n-max(a,b)+1+(n-(min(a,b)+(n-max(a,b)+1)))/2<<endl;
    }
    return 0;
}  


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**3
eps = 1.0 / 10**10
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []
    n = I()
    a = [S() for _ in range(n)]
    d = {}
    d[1] = '.,!? '
    d[2] = 'abc'
    d[3] = 'def'
    d[4] = 'ghi'
    d[5] = 'jkl'
    d[6] = 'mno'
    d[7] = 'pqrs'
    d[8] = 'tuv'
    d[9] = 'wxyz'
    for s in a:
        r = ''
        i = -1
        c = 0
        for t in s:
            tc = int(t)
            if tc == 0:
                if c > 0:
                    r += d[c][i%len(d[c])]
                i = -1
                c = 0
            else:
                c = tc
                i += 1
        rr.append(r)

    return '\n'.join(map(str, rr))


print(main())




Measured memory_bytes: 9128
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int k = sc.nextInt();
			List<Integer> list = new ArrayList<>();
			for (int i = 0; i < n; i++) {
				list.add(sc.nextInt());
			}
			int sum = 0;
			for (int i = 0; i < k; i++) {
				sum += list.get(i);
			}
			int tmp = sum;
			for (int i = k; i < n; i++) {
				tmp -= list.get(i - k);
				tmp += list.get(i);
				if (sum < tmp) {
					sum = tmp;
				}
			}
			System.out.println((0.0 + sum + k) / 2);
		}
	}

}


Measured memory_bytes: 86512
r,g,b,n = map(int,input().split())

res=0
tmp=n
tmp1=0
re=n//r+1
ge=n//g+1

for i in range(re):
	tmp = tmp - i*r
	tmp1 = tmp
	for j in range(ge):
		tmp1 = tmp - j*g
		if tmp1 < 0:
			break
		elif tmp1%b==0:
			res = res + 1
		tmp1 = tmp
	tmp=n

print(res)

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

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

#ifdef LOCAL
  #define eprintf(...) fprintf(stdout, __VA_ARGS__)
#else
  #define eprintf(...) 0
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;

int ctoi(char c) {
  return c - '0';
}

template <class C>
void printContainer(C &container, const char *delim=",") {
  for(const auto &e : container) {
    std::cout << e << delim;
  }
  std::cout << "\n";
}

// Greatest common divisor
template<class T>
T gcd(T x, T y) {
  if(x < y) {
    std::swap(x, y);
  }
  T r = x % y;
  while(r != 0) {
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

// Least common multiple
template<class T>
T lcm(T x, T y) {
  return (x*y)/gcd(x,y);
}

int main() {
  char a, b, c;
  cin >> a >> b >> c;
  string str {a, b, c};
  int num = atoi(str.c_str());
  string ans = num % 4 ? "NO" : "YES";
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
def main():
    result = []
    counter = 0

    primes = [2]
    nominee = 3
    while counter < 55:
        is_prime = True
        for prime in primes:
            if nominee % prime == 0:
                is_prime = False
        if is_prime:
            primes.append(nominee)
            if nominee % 5 == 1:
                result.append(nominee)
                counter += 1
        nominee += 2
    
    print(*result[:int(input())])
    

main()


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

using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); ++i)
double const PI = 3.1415926535897932384626433;

int main() {
    int a, b;
    int ans = 0;
    cin >> a >> b;
    for (int i = 1; i <= 1000; ++i) {
        int tmp = i * 0.08;
        if (floor(i * 0.08) == a && floor(i * 0.1) == b) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

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

using namespace std;

int main(){
  
  long long int N, K;
  cin>>N>>K;

  long long int A[N];

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

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

  
}


Measured memory_bytes: 5196
n=int(input())
s=[int(input()) for _ in range(n)]
num=sum(s)
ans=0
if num%10!=0:
    ans=num
else:
    for i in range(n):
        num2=num-s[i]
        if num2%10!=0 and ans<num2:
            ans=num2
print(ans)


Measured memory_bytes: 2940
#include <stdio.h>
int main(void)
{
    int i,n,a,b;
    scanf("%d",&n);
    scanf("%d",&a);
    scanf("%d",&b);

    int p[n];

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

    int x=0,y=0,z=0;
    for(i=0;i<n;i++){
        if(p[i]<=a){x=x+1;}
        if(a<p[i]&&p[i]<=b){y=y+1;}
        if(b<p[i]){z=z+1;}
    }
    
    int min;
    min=x;
    if(min>y){min=y;}
    if(min>z){min=z;}

    printf("%d\n",min);

    return 0;
}

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

int main()
{
    int n, k, i=0,j=0,ans=0;
    string s;
    cin >> n >> k >> s;
    while(j < n){
        while(j < n && s[j] == '1')j++;
        ans = max(ans, j - i);
        while(j < n && s[j] == '0')j++;
        if(--k < 0) {
            while(i < n && s[i] == '1')i++;
            while(i < n && s[i] == '0')i++;
        }
    }
    ans = max(ans, j - i);
    cout<<ans<<endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;


int main(){
    int n; cin >> n;
    vector<int> x(n);
    vector<int> y(n);
    vector<int> h(n);
    tuple<int, int, int> t = make_tuple(-1,-1,-1);
    rep(i,n){
        cin >> x[i] >> y[i] >> h[i];
        if(h[i]>=1)  t = make_tuple(x[i], y[i], h[i]); 
    }
    for(int i = 0; i <= 100; i++){
        for(int j = 0; j <= 100; j++){
            int H = get<2>(t) + abs(get<0>(t) - i) + abs(get<1>(t) - j);
            bool isOK = true;
            rep(k,n){
                int tmp = H - abs(x[k] - i) - abs(y[k] - j);
                tmp = max(tmp, 0);
                if(tmp != h[k])isOK = false;
            }
            if(isOK) cout << i << " " << j << " " << H << endl; 
        }
    }
    return 0;
}

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

int main()
{
    int x,y;
    cin>>x>>y;

    if(y%2!=0)
        cout<<"No";
    else if(y<2*x || y>4*x)
        cout<<"No";
    else
        cout<<"Yes";

    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC omodtimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<long long,long long> ii; 	
typedef complex<long double> com;

ll mod = 1e9+7;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,m;
	cin >> n >> m;
	vector <ll> arr(n);
	ll s= 0;
	for (int z=0;z<n;z++){
		cin >> arr[z];
		s += arr[z];
	}
	sort(arr.rbegin(),arr.rend());
	ll ans = 0;
	for (int z=0;z<n;z++){
		if (arr[z]*4*m >= s){
			ans++;
		}
	}
	if (ans >= m){
		cout << "Yes" << endl;
	} else cout << "No" << endl; 
}

Measured memory_bytes: 256
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <math.h>
#include <bits/stdc++.h>

#define INF (1ll<<60)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;

#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)

template<class T>bool umax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool umin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using namespace std;

// gcd
template<typename T>
T gcd(T a, T b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}
// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);

    return result;
}
template<typename T>
T lcm( T m, T n )
{
    // 引数に0がある場合は0を返す
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;

    return ((m/gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

// sort big to small
// sort(A,A+N, greater<int>());

// v.front() = -BOUND;
// v.back() = BOUND;

// Iterator
// v.begin
// v.end

int main() {
    long long N;
    long long ans=1<<30;
    long long digit=0;
    int report[100001]={0};
    cin >> N;

    for(long long i=1; i<= sqrt(( long double)N); i++){
        long long bigger;
        if(N%i==0){
            bigger=max(N/i,i);
            ans=min(bigger,ans);
        }
    }

    while(ans>0){
        ans/=10;
        digit++;
    }

    cout << digit << endl;
    return 0;
}



Measured memory_bytes: 256
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 06/17/20 20:48:52
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int n,m; cin>>n>>m;
  struct Data {
    int i;
    int a,b;
  };
  vector<Data> abr(m), abl(m);
  for (int i = 0; i < m; i++) {
    abr[i].i=i;
    cin >> abr[i].a >> abr[i].b;
  }
  copy(abr.begin(), abr.end(), abl.begin());
  sort(abr.begin(), abr.end(), [&](auto l, auto r) {return l.b < r.b;});
  sort(abl.begin(), abl.end(), [&](auto l, auto r) {return l.a < r.a;});
  int ans = 0;
  vector<int> vis(m, false);
  int li = 0;
  for (int i = 0; i < m; i++) {
    if (vis[abr[i].i]) continue;
    ans++;
    vis[abr[i].i] = true;
    while (li < m and abl[li].a < abr[i].b) {
      vis[abl[li++].i] = true;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2944
H, W, K = map(int, input().split())
L = []
for i in range(H):
    L.append(list(input()))

counter_pattern = 0
for i in range(2 ** H):# 000~111
    for j in range(2 ** W):# 000~111
        counter_black = 0
        for h in range(H):
            for w in range(W):
                if L[h][w] == "#" and ((i >> h) & 1) == 0 and ((j >> w) & 1) == 0:
                    counter_black += 1
        if counter_black == K:
            counter_pattern += 1

print(counter_pattern)

Measured memory_bytes: 9208
#include<bits/stdc++.h>
using namespace std; 
int main()
{
	int x,y,z;
	cin>>x>>y>>z;
	int ans=0;
	for (int i = 0; i < 10; ++i)
	{
		ans= (x*z)-y;
		cout<<ans<<endl;
		z = ans;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#pragma GCC optimize(2)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rep(i,a,b) for(int i = (a);i <= (b);i++)
#define pii pair<int,int>
#define pll pair<long long, long long>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 1e6 + 5;
const double eps = 1e-8;
const double pi = acos(-1.0);	
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a * b / gcd(a,b);}
ll qw(ll x,ll y){ll res = 1;while(y){if(y & 1) res *= x;x = x * x;y >>= 1;}return res;}
ll poww(ll x,ll y,ll p){ll ans = 1;while(y){if(y & 1) ans = ans * x % p;x = x * x % p;y >>= 1;}return ans % p;}
bool isp(ll x){if(x < 2) return 0; for(ll i = 2;i * i <= x;i++){if(x % i == 0) return 0;}return 1;}
int a,b,c,d;
void solve(){
	while(a > 0 || c > 0){
		c -= b;
		if(c <= 0) break;
		a -= d;
	}
	if(a <= 0) cout << "No" << endl;
	else cout << "Yes" << endl;
	return;
}
int main(){
//	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> a >> b >> c >> d;
	solve();
	return 0;
}
//do smt instead of nothing! never give up!


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
#define vi vector<int>
#define vvi vector<vector<int>>
#define FASTIO ios_base::sync_with_stdio(NULL); cin.tie(NULL);
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORE(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define MOD 1000000007

using namespace std;

void init(){
  #ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin) ;
  freopen("output.txt", "w", stdout) ;
  #endif
}

// code from below

void solve(){
    int n,k;
    cin>>n>>k;
    vi arr(n);
    vector<bool> dp(k+1);
    // dp[i] means who will win if k stones are remaining , true if first player wins
    // we have formulazid the problem in a better way
    // we dont care how we reached a particular state and then we have to calculate which player can win with this state
    // who win if we have 0 stones, who win if we have 1 stones, if we have 2 stones,....   ... k stones
    FOR(i,n)
        cin>>arr[i];
    for(int i=0;i<=k;i++){
        for(int x:arr){
            // if first player has not won with i-x stones then it will win by i stones, because players would win 
            // alternatively, because they are playing alternatively
            if(i>=x and !dp[i-x])
                dp[i]=true;
        }
    }
    dp[k]? cout<<"First\n":cout<<"Second\n";
}

int main(){
    int t=1;
    // cin>>t;
    // cin.ignore(numeric_limits<streamsize>::max(),'\n'); 
    while(t--)
        solve();
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#include <unordered_map> 
using namespace std; 
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define PI1 3.14159265358979311599796346854418516159057617187500

typedef long long int ll;  


int main() 
{ 
    FIO
    int t;
    t=1;

    while(t--)
    {
        int a,b,c,k;
        cin >> a >> b >> c >> k;

        int ans = 0;
        int mn = min(a,k);
        k -= mn;
        ans += mn;

        mn = min(b,k);
        k -= mn;
        
        mn = min(c,k);
        k -= mn;
        ans -= mn;

        cout << ans << endl;
    }

    return 0; 
} 


Measured memory_bytes: 3592