akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
import sys

YES = "YES"  # type: str
NO = "NO"  # type: str


def solve(X: int):
    if X==3 or X==5 or X==7:
        print(YES)
    else:
        print(NO)
    return


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

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pf(n) printf("%d\n",n)
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1001001001;
const double PI = acos(-1);

int main() {
	int r, d, x;
	cin >> r >> d >> x;

	rep(i, 10) {
		x = r * x - d;
		cout << x << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3604
class Card():
    def __init__(self, card):
        self.card = card
        self.mark = card[0]
        self.number = card[1]
        
    def __lt__(self, other):
        if not isinstance(other, Card):
            return NotImplemented
        return self.number < other.number
    
    def __eq__(self, other):
        if not isinstance(other, Card):
            return NotImplemented
        return self.mark == other.mark and self.number == other.number
        
    def __repr__(self):
        return '{}{}'.format(self.mark, self.number)

    def ls_sort(self):
        return


def BubbleSort(target):
    ls = target.copy()
    flag = 1
    while flag:
        flag = 0
        for i in range(len(ls)-1, 0, -1):
            if ls[i] < ls[i-1]:
                ls[i], ls[i-1] = ls[i-1], ls[i]
                flag = 1
    print(' '.join(map(str, ls)))
    return sorted(ls)


def SelectSort(target):
    ls = target.copy()
    for i in range(len(ls)):
        minj = i
        for j in range(i+1, len(ls)):
            if ls[j] < ls[minj]:
                minj = j
        if ls[i] != ls[minj]:
            ls[i], ls[minj] = ls[minj], ls[i]
    
    print(' '.join(map(str, ls)))
    return sorted(ls)

def judge(original, sorted_list):
    if original == sorted_list:
        print('Stable')
    else:
        print('Not stable')


_ = int(input())
l2 =  [Card(i) for i in input().split()]
l2_sort = sorted(l2)

bubble = BubbleSort(l2)
judge(l2_sort, bubble)

select = SelectSort(l2)
judge(l2_sort, select)


Measured memory_bytes: 5608
def _main(s, t):
    if s == t:
        print(0)
        return
    change = 0
    for i in range(len(s)):
        if s[i] != t[i]:
            change += 1
    print(change)


if __name__ == "__main__":
    S = str(input())
    T = str(input())
    _main(S, T)


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

using namespace std;

const int M = 1e5 + 5;
int seg[M * 4], arr[M], o[M], n;

int build(int l, int r, int i) {
    if (l == r)
        seg[i] = arr[l];
    else
        seg[i] = max(build(l, (l + r) / 2, i * 2 + 1), build((l + r) / 2 + 1, r, i * 2 + 2));
    return seg[i];
}

int q(int l, int r, int L, int R, int i) {
    if (L >= l && R <= r)
        return seg[i];
    if (L > r || R < l)
        return -1;
    return max(q(l, r, L, (L + R) / 2, i * 2 + 1), q(l, r, (L + R) / 2 + 1, R, i * 2 + 2));
}

int firstGreater(int l, int r, int x) {
    if (l == r)
        return (arr[l] > x ? arr[l] : -1);

    int mid = (l + r) / 2;

    if (q(l, mid, 0, n + 3, 0) > x)
        return firstGreater(l, mid, x);
    return firstGreater(mid + 1, r, x);
}

int lastGreater(int l, int r, int x) {
    if (l == r)
        return (arr[l] > x ? arr[l] : -1);

    int mid = (l + r) / 2;

    if (q(mid + 1, r, 0, n + 3, 0) > x)
        return lastGreater(mid + 1, r, x);
    return lastGreater(l, mid, x);
}

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

    cin >> n;

    long long ans = 0;

    arr[0] = n + 1;
    arr[1] = n + 2;
    arr[n + 2] = n + 3;
    arr[n + 3] = n + 4;

    o[n + 1] = 0;
    o[n + 2] = 1;
    o[n + 3] = n + 2;
    o[n + 4] = n + 3;

    for (int i = 2; i <= n + 1; i++)
        cin >> arr[i], o[arr[i]] = i;
    build(0, n + 3, 0);

    for (int i = 2; i <= n + 1; i++) {
        int j, r, l;
        j = o[firstGreater(i + 1, n + 3, arr[i])];
        r = o[firstGreater(j + 1, n + 3, arr[i])];
        l = o[lastGreater(0, i - 1, arr[i])];

        if (j <= n + 1)
            ans += 1ll * (r - j) * (i - l) * arr[i];

        j = o[lastGreater(0, i - 1, arr[i])];
        l = o[lastGreater(0, j - 1, arr[i])];
        r = o[firstGreater(i + 1, n + 3, arr[i])];

        if (j > 1)
            ans += 1ll * (r - i) * (j - l) * arr[i];
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 2048
r, c = map(int, input().split())
args = []

for i in range(r):
    args.append(list(map(int, input().split())))
    r_sum = 0
    for j in args[i]:
        r_sum += j
    args[i].append(r_sum)

l_row = []

for k in range(c + 1):
    c_sum = 0
    for l in range(r):
        c_sum += args[l][k]
    l_row.append(c_sum)        

for m in range(r):
    print(' '.join(map(str, args[m])))

print(' '.join(map(str, l_row)))

    



Measured memory_bytes: 5696
#if __has_include("debug.h")
    #include "debug.h"
#else  
#include <bits/stdc++.h>
using namespace std;
#define d(...) 2;
#endif

#define int long long int

#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"      

#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define ff first
#define ss second
#define eps 1e-10

#define gcd(a,b)            __gcd((a),(b))
#define lcm(a,b)            ((a*b)/gcd(a,b))

void solve();

int32_t main()
{
    #ifdef DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
    #endif 

    fast
    
    int t = 1;
	// cin>>t;
	
	while(t--)
	    solve();
	return 0;  
}

void solve()
{
	int i,j;
	cin>>i;
	if(i<30)
	{
		cout<<"No"<<endl;
	}
	else
	{
		cout<<"Yes"<<endl;
	}

}

Measured memory_bytes: 3648
C[51];
#define min(a,b) ((a)<(b)?(a):(b))
D(c,m,u,p){
	int i;
	for(i=u;i<=u;i++)
		if(m-i>=0&&m-i!=1)c=min(c,C[m-i]+p);
	return c;
}
main(i,c){
	for(i=2;i<=50;i++){
		c=9999;
		c=D(c,i,2,380);
		c=D(c,i,3,550);
		c=D(c,i,5,850);
		c=D(c,i,2*5,380*5*(100-20)/100);
		c=D(c,i,3*4,550*4*(100-15)/100);
		c=D(c,i,5*3,850*3*(100-12)/100);
		C[i]=c;
	}
	for(;~scanf("%d",&i);)
		i&&printf("%d\n",C[i/100]);
}

Measured memory_bytes: 0
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <sstream>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <iterator>
#include <stack>
#include <list>
using namespace std;
#define INF 100000000
typedef long long int lli;
typedef pair<int,int> P;

double g[101][101];
double dp[101][101];

int main(){
	int n,m;
	while(cin>>n>>m){
		if(n==0&&m==0)  break;
		for(int i=0; i<=m; ++i){
			for(int j=0; j<n; ++j){
				dp[i][j]=0;
			}
		}
		for(int i=0; i<n; ++i){
			for(int j=0; j<n; ++j){
				cin >> g[i][j];
			}
		}
		for(int i=0; i<n; ++i){
			dp[1][i]=1.00;
		}
		for(int i=2; i<=m; ++i){
			for(int j=0; j<n; ++j){
				double tmp=dp[i][j];
				for(int k=0; k<n; ++k){
					tmp=max(tmp,dp[i-1][k]*g[k][j]);
				}
				dp[i][j]=tmp;
			}
		}
		double ans=0;
		for(int i=0; i<n; ++i){
			ans=max(ans,dp[m][i]);
		}
		//ans=((int)(ans*100+0.5))/100;
		//ans=int(ans*100+0.5);
		//ans/=100;
		printf("%.2f\n",ans);
	}
	return 0;
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

int n;
int dp[200010];
vector<vector<int>> G;
vector<int> a;
vector<int> res;
stack<pii> st;

void dfs(int v, int p) {
    auto itr = lower_bound(dp, dp+n, a[v]);
    int x = *itr;
    int id = itr - dp;
    st.push(pii(x, id));

    *itr = a[v];
    res[v] = lower_bound(dp, dp+n, INF) - dp;

    for (auto nv : G[v]) {
        if (nv == p) continue;
        dfs(nv, v);
    }

    tie(x, id) = st.top();
    st.pop();

    dp[id] = x;
}

int main(){
    cin >> n;
    a.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    G.resize(n);
    for (int i = 0; i < n-1; ++i) {
        int u, v;
        cin >> u >> v;
        u--; v--;
        G[u].push_back(v);
        G[v].push_back(u);
    }

    for (int i = 0; i < 200010; ++i) {
        dp[i] = INF;
    }
    res.resize(n);
    dfs(0, -1);

    for (int i = 0; i < n; ++i) {
        cout << res[i] << endl;
    }
}

Measured memory_bytes: 37956
n,m=map(int,input().split())

x=[]
y=[]

for i in range(m):
    l,r=map(int,input().split())
    x.append(l)
    y.append(r)

if min(y)-max(x)+1 > 0:
    print((min(y)-max(x)+1))
else:
    print("0")

Measured memory_bytes: 10996
n, k = map(int, input().split())
mod = 10 ** 9 + 7

def comb(n, r):
    tmp = 1
    for i in range(r):
        tmp *= n - i
    for i in range(r):
        tmp //= r - i
    return tmp

for i in range(1, k + 1):
    if i > n - k + 1:
        print(0)
    else:
        print(comb(k - 1, i - 1) * comb(n - k + 1, i) % mod)


Measured memory_bytes: 45148
from collections import deque

s = input()
q = int(input())
ans = deque(s)
cnt = 0
for i in range(q):
    f = [i for i in input().split()]
    if f[0] == '1':
        cnt += 1
    else:
        if f[1] == '1':
            if cnt % 2 == 0:
                ans.appendleft(f[2])
            else:
                ans.append(f[2])
        else:
            if cnt % 2 == 0:
                ans.append(f[2])
            else:
                ans.appendleft(f[2])
if cnt % 2 != 0:
    ans.reverse()
print(''.join(map(str,ans)))

Measured memory_bytes: 8688
#include<cstdio>
#include<cstring>
#include<iostream>
const int MAXN=1010;
const int MOD=1e9+7;
 
bool p[MAXN][MAXN];
int n,m;
int f[MAXN][MAXN];
 
int main(){
	scanf("%d%d",&n,&m);
	f[1][1]=1;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++){
			char c;std::cin>>c;
			p[i][j]=(c=='.');
			if(i==1&&j==1)
				continue;
			if(p[i][j])
				f[i][j]=(f[i-1][j]*p[i-1][j]+f[i][j-1]*p[i][j-1])%MOD;
		}
	printf("%d\n",f[n][m]);
	return 0;
}

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

int main() {
	int N, X;
	cin >> N >> X;

	vector<int> D;
	D.push_back(0);
	for (int i = 1; i < N + 1; i++) {
		int l;
		cin >> l;
		int d = D[i - 1] + l;
		D.push_back(d);
	}

	int count = 0;
	for (int i = 0; i<N + 1; i++) {
		if (D[i] <= X) {
			count++;
		}
	}

	cout << count << endl;


}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(long long i = 0;i < n;++i)
#define FOR(i,a,b) for(long long i = a;i < b;++i)
using namespace std;
using ll = long long;
using point = pair< int,int >;

int main(){
    int n;
    scanf("%d",&n);
    if (n < 1000) cout<<"ABC"<<endl;
    else cout<<"ABD"<<endl;
    return 0;
}



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

int main()
{
    int n;
    cin >> n;
    int m;
    cin >> m;
    int c;
    cin >> c;
    int b[m];
    for(int i=0;i<m;++i)
    {
        cin >> b[i];
    }
    int cnt = 0;
    for(int i=0;i<n;++i)
    {
        int res = 0;
        for(int j=0;j<m;++j)
        {
            int x;
            cin >> x;
            res += (x*b[j]);
        }
        //cout << res << " " << endl;
        if(res+c>0)cnt++;
    }
    cout << cnt;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**6)
INF = 10 ** 9 + 1  # sys.maxsize # float("inf")
MOD = 10 ** 9 + 7


def debug(*x):
    print(*x, file=sys.stderr)


def solve(A, B, C, K):
    while A >= B:
        K -= 1
        B *= 2
    while B >= C:
        K -= 1
        C *= 2
    if K >= 0:
        return "Yes"
    return "No"


def main():
    # parse input
    A, B, C = map(int, input().split())
    K = int(input())
    print(solve(A, B, C, K))


# tests
T1 = """
7 2 5
3
"""
TEST_T1 = """
>>> as_input(T1)
>>> main()
Yes
"""

T2 = """
7 4 2
3
"""
TEST_T2 = """
>>> as_input(T2)
>>> main()
No
"""


def _test():
    import doctest
    doctest.testmod()
    g = globals()
    for k in sorted(g):
        if k.startswith("TEST_"):
            doctest.run_docstring_examples(g[k], g)


def as_input(s):
    "use in test, use given string as input file"
    import io
    f = io.StringIO(s.strip())
    g = globals()
    g["input"] = lambda: bytes(f.readline(), "ascii")
    g["read"] = lambda: bytes(f.read(), "ascii")


input = sys.stdin.buffer.readline
read = sys.stdin.buffer.read

if sys.argv[-1] == "-t":
    print("testing")
    _test()
    sys.exit()

main()


Measured memory_bytes: 62164
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

int main(){
	int n;
	int x[502];
	scanf("%d",&n);
	rep1(i,n)scanf("%d",&x[i]);
	
	vector<P> vec;
	rep1(i,n){
		vec.pb(P(x[i],i));
	}
	sor(vec);
	
	static int a[500*500+2];
	rep(i,500*500+2)a[i] = -1;
	queue<int> que[2];
	for(P p: vec){
		a[p.fr] = p.sc;
		rep(i,p.sc-1)que[0].push(p.sc);
		rep(i,n-p.sc)que[1].push(p.sc);
	}
	
	int k = 1;
	rep(i,2){
		while(!que[i].empty()){
			while(a[k] != -1)k ++;
			a[k] = que[i].front(); que[i].pop();
		}
	}
	
	vector<int> v[502];
	rep1(i,n*n){
		v[a[i]].pb(i);
	}
	rep1(i,n){
		sor(v[i]);
		if(v[i][i-1] != x[i]){
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	rep1(i,n*n){
		printf("%d%c",a[i],(i==n*n)?'\n':' ');
	}
}


Measured memory_bytes: 3200
# -*- coding: utf-8 -*-

n = int(input())
a = list(map(int, input().split()))

x = a[0]
y = sum(a) - a[0]
ans = abs(x - y)

for i in range(1, n-2):
    x += a[i]
    y -= a[i]
    score = abs(x - y)
    ans = min(ans, score)

print(ans)


Measured memory_bytes: 24812
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;

const int N = 5e5 + 5, B = 700;

struct Query {
  int l, r, i, b;
  bool operator<(const Query& q) const {
    if (b != q.b) return b < q.b;
    return r < q.r;
  }
};

int c[N], ans[N];
int f[N], cur = 0;

void add(int i) {
  if (!f[c[i]]) cur++;
  f[c[i]]++;
}
void rem(int i) {
  f[c[i]]--;
  if (!f[c[i]]) cur--;
}

int main() {
#ifdef LOCAL_EXEC
//	freopen("sample.in", "r", stdin);
//	freopen("sample.out", "w", stdout);
#else
  ios_base::sync_with_stdio(false); cin.tie(NULL);
#endif

  int n, q; cin >> n >> q;
  for (int i = 1; i <= n; i++) {
    cin >> c[i];
  }
  vector<Query> qs(q);
  for (int i = 0; i < q; i++) {
    cin >> qs[i].l >> qs[i].r;
    qs[i].i = i;
    qs[i].b = qs[i].l / B;
  }
  sort(qs.begin(), qs.end());

  int l = 1, r = 0;
  for (auto& q: qs) {
    while (l > q.l) add(--l);
    while (l < q.l) rem(l++);
    while (r > q.r) rem(r--);
    while (r < q.r) add(++r);

    ans[q.i] = cur;
  }

  for (int i = 0; i < q; i++) {
    cout << ans[i] << '\n';
  }

  return 0;
}


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

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

using namespace std;

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

int main(){
	int h,w; cin>>h>>w;
	string B[50];
	rep(i,h) cin>>B[i];

	rep(i,h) rep(j,w) if(B[i][j]=='#') {
		bool ok=false;
		rep(k,4){
			int y=i+dy[k],x=j+dx[k];
			if(0<=y && y<h && 0<=x && x<w && B[y][x]=='#') ok=true;
		}
		if(!ok){ cout<<"No"<<endl; return 0; }
	}
	cout<<"Yes"<<endl;

	return 0;
}


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

int main() {
	//input
	int N;
	cin >> N;

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

	//calculation
	int64_t output = 0;
	int64_t max = A[0];

	for (int i = 1; i < N; i++) {
		if (max > A[i]) {
			output += max - A[i];
		} else {
			max = A[i];
		}
	}

	//output
	cout << output << endl;


	return 0;
}


Measured memory_bytes: 4032
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int[] dice = new int[6];
        for(int i = 0; i < 6; i++){
            dice[i] = sc.nextInt();
        }
        String order = sc.next();
        for(int i = 0; i < order.length(); i++){
            char c = order.charAt(i);
            int[] temp = new int[6];
            if(c == 'E'){
                temp[0] = dice[3];
                temp[1] = dice[1];
                temp[2] = dice[0];
                temp[3] = dice[5];
                temp[4] = dice[4];
                temp[5] = dice[2];
            }else if(c == 'W'){
                temp[0] = dice[2];
                temp[1] = dice[1];
                temp[2] = dice[5];
                temp[3] = dice[0];
                temp[4] = dice[4];
                temp[5] = dice[3];
            }else if(c == 'N'){
                temp[0] = dice[1];
                temp[1] = dice[5];
                temp[2] = dice[2];
                temp[3] = dice[3];
                temp[4] = dice[0];
                temp[5] = dice[4];
            }else if(c == 'S'){
                temp[0] = dice[4];
                temp[1] = dice[0];
                temp[2] = dice[2];
                temp[3] = dice[3];
                temp[4] = dice[5];
                temp[5] = dice[1];
            }
            dice = temp;
        }
        System.out.println(dice[0]);
    }
}



Measured memory_bytes: 26336
a=int(input())
N=list(map(int,input().split(" ")))
b=int(input())
M=list(map(int,input().split(" ")))

#a=2
#N=[1,2016]
#b=4
#M=[2,2,2,2]

for index,i in enumerate(M):
#    print(i)
    if N[i-1]+1 in N or N[i-1]==2019:
#        print(N[i-1])
        continue
    else:
        N[i-1]+=1
    
for i in N:
    print(i)
    
    


Measured memory_bytes: 5600
#include<iostream>
using namespace std;
int main(void)
{
  	int a,b,sum=0;
  	cin >> a >> b;
  	if(a>=2) sum+=a*(a-1)/2;
 	if(b>=2) sum+=b*(b-1)/2;
  	cout << sum;
  	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <functional>
#include <iterator>
#include <numeric>
#include <cstdint>
#include <cmath>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>

#define N_TIMES(i, n)     for ( uint64_t i = 0;     i <  n; ++i )
#define N_TIMES_REV(i, n) for (  int64_t i = n - 1; i >= 0; --i )

using namespace std;

uint64_t calc(uint64_t H, uint64_t W, uint64_t K, const vector<vector<uint64_t>> &C, const bitset<16> &bs)
{
  uint64_t T = 0;

  // comporess vector
  vector<vector<uint64_t>> D;
  D.push_back(C[0]);
  N_TIMES(y, H - 1) {
    if (bs[y]) {
      D.push_back(C[y + 1]);
    } else {
      N_TIMES(x, W + 1) {
        D[D.size() - 1][x] += C[y + 1][x];
      }
    }
  }

  auto binary_search = [&](uint64_t left) {
    auto judge = [&](uint64_t x) {
      N_TIMES(i, D.size()) { 
        if ((D[i][x] - D[i][left]) > K) { return false ; }
      }
      return true;
    };

    uint64_t lo = left, hi = W + 1;
    while (hi - lo > 1) {
      uint64_t mid = (hi + lo) >> 1;
      if (judge(mid)) {
        lo = mid;
      } else {
        hi = mid;
      }
    }
    return lo;
  };

  uint64_t L = 0;
  while (L < W) {
    uint64_t new_L = binary_search(L);
    if (L == new_L) { return 1e+9; }
    L = new_L;
    ++T;
  }

  return T - 1;
}

int main()
{
  uint64_t H, W, K;
  cin >> H >> W >> K;

  vector<string> S(H);
  N_TIMES(y, H) { cin >> S[y]; }

  vector<vector<uint64_t>> C(H);
  N_TIMES(y, H) {
    C[y] = vector<uint64_t>(W + 1, 0);
    N_TIMES(x, W) {
      C[y][x + 1] = (S[y][x] - '0') + C[y][x];
    }
  }

  uint64_t ans = 1e+9;
  N_TIMES(i, 1 << (H - 1)) {
    bitset<16> bs(i);
    
    uint64_t num_of_edge = bs.count() + calc(H, W, K, C, bs);
    ans = min(ans, num_of_edge);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
using namespace std;
typedef long long ll;
ll k;
ll now=0,x=1;
double f(ll x){
    double sum=0,t=x;
    while(x){
        sum+=x%10;
        x/=10;
    }
    return (double)t*1.0/sum*1.0;
}
int main(){
    scanf("%lld",&k);
    while(k--){
        if((now/x)%10!=9){
            now+=x;
            printf("%lld\n",now);
        }
        else{
            if(f(now+x)>f(now+10*x))
                x*=10;
            now+=x;
            printf("%lld\n",now);
        }
    }
    return 0;
}

Measured memory_bytes: 256
//#############################################################################
//----------------------------Karma is Real------------------------------------
#include "bits/stdc++.h"
//#############################################################################
//Macros 
#define MOD 1000000007
#define eb emplace_back
#define mp make_pair
#define fr first
#define sc second
#define len(x) x.size()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define all(v) v.begin(), v.end()
#define alla(a, n) a, a + n
//Type Defs
typedef long long ll;
typedef unsigned long long ull;
//#############################################################################
using namespace std;
//#############################################################################
//Helpers
void io_handler()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
void print_matrix(vector<vector<ll>> mat){
    for(auto row: mat){
        for(auto e : row){cout << e << " ";}
        cout << endl;
    }
}
void print_vector(vector<ll> vec){
    for(auto e : vec){cout<< e <<" ";}
    cout<<endl;
}
map<int,int> get_count(vector<ll> vec){
    map<int,int> count;
    for(auto e: vec){
        if(count.find(e)!=count.end()){count[e]++;}
        else{count[e] = 1;}}
    return count;
}
//#############################################################################
//Solution
void solve(){
    ll n,k; cin>>n>>k;
    vector<ll> arr(n);
    for(ll i = 0; i<n; i++){
        cin>>arr[i];
    }
    vector<ll> dp(n,1e11);
    dp[0] = 0; dp[1] = abs(arr[0]-arr[1]);
    for(ll i = 2; i<n; i++){
        for(ll j = max(i-k,0LL); j<i; j++){
            dp[i] = min(dp[i],abs(arr[i]-arr[j])+dp[j]);
        }
    }
    //print_vector(dp);
    cout<<dp[n-1]<<endl;
}
//#############################################################################
//Driver
int main()
{
    io_handler();
    int t = 1;
    //cin>>t;
    for (int i = 0; i < t; i++){
        solve();
    }
    return 0;
}
//#############################################################################

Measured memory_bytes: 1792
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    ll ans = 0;
    vll a(n);
    REP(i,n){
        cin >> a[i];
        ll t = a[i]%mod;
        ans += t*(n-1);
        ans%=mod;
    }
    ll now = 2;
    REP(i,61){
        ll cnt = 0;
        REP(j,n){
            if(a[j]%2==1){
                cnt++;
            }
            a[j] /= 2;
        }
        if(cnt>=2){
            cnt = cnt*(cnt-1)/2;
            cnt %= mod;
            cnt *= now;
            cnt %= mod;
            ans = (ans+mod-cnt)%mod;
        }
        
        now *= 2LL;
        now %= mod;
    }
    cout << ans << endl;

    return 0;
}

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

using namespace std;

int n;

int cek(int x, int k) {
  if (x < k) return 0;
  int r = x % k;
  while (r) {
    int z = x/k+1;
    int y = (r + z - 1)/z;
    x -= z * y;
    r = x % k;
  }
  return x/k;
}

int main() {
  scanf("%d", &n);
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    int a, k;
    scanf("%d %d", &a, &k);
    ans ^= cek(a, k);
  }
  puts(ans ? "Takahashi" : "Aoki");
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e3+5;
vector<pair<ll,int>> V;
int n;
ll dp[maxn][maxn];
int main() {
    cin>>n;
    for(int i=1;i<=n;i++){ll a;cin>>a;V.push_back({a,i});}
    sort(V.begin(),V.end(),greater<pair<ll,int>>());
    for(int i=0;i<n;i++){
        dp[0][i+1]=dp[0][i]+abs(n-i-V[i].second)*V[i].first;
        dp[i+1][0]=dp[i][0]+abs(i+1-V[i].second)*V[i].first;
        for(int j=1;j<=i;j++){
            dp[j][i+1-j]=max(dp[j-1][i+1-j]+abs(j-V[i].second)*V[i].first,
                            dp[j][i-j]+abs(n-(i-j)-V[i].second)*V[i].first);
        }
    }
    ll mx=0;
    for(int i=0;i<=n;i++) mx=max(mx,dp[i][n-i]);
    cout<<mx<<endl;
    return 0;
}

Measured memory_bytes: 26340
import sys
def fastio():
    from io import StringIO
    from atexit import register
    global input
    sys.stdin = StringIO(sys.stdin.read())
    input = lambda : sys.stdin.readline().rstrip('\r\n')
    sys.stdout = StringIO()
    register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()

INF = 10**20
MOD = 10**9 + 7
I = lambda:list(map(int,input().split()))
# from math import gcd
from math import ceil
from collections import defaultdict as dd, Counter
from bisect import bisect_left as bl, bisect_right as br

n, = I()
print(1000 * (n // 500) + 5 * ((n % 500) // 5))

Measured memory_bytes: 3428
from operator import itemgetter
N, M = map(int, input().split())
ab = []
for i in range(M):
    ab.append([int(xi) for xi in input().split()])
ab = sorted(ab, key=itemgetter(0, 1))
x, y = ab[0]
count = 1
for ai, bi in ab[1:]:
    if bi < x or y <= ai:
        count += 1
        x, y = ai, bi
    else:
        x = max(x, ai)
        y = min(y, bi)
print(count)


Measured memory_bytes: 30068
//This code was made by Chinese_zjc_.
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#define int long long
#define INF 0x3fffffffffffffff
#define pi 3.14159265358979323
using namespace std;
double a,b,x,y,v;
signed main()
{
	cin>>a>>b>>x;
	v=a*a*b/2;
	if(x<v)
	{
		y=2*x/a/b;
		printf("%.10lf",atan(b/y)/pi*180);
	}
	else
	{
		y=2*b-x/a/a*2;
		printf("%.10lf",atan(y/a)/pi*180);
	}
	return 0;
}


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


int main(){
    char banmen[12][12]={};
    int H,W;
    string answer={};

    cin >> H >> W;
    for(int i=1;i<=H;i++){
        for(int t=1;t<=W;t++){
            cin >> banmen[i][t];
        }
    }
  
    for(int i=1;i<=H;i++){
        for(int t=1;t<=W;t++){
            if(banmen[i][t]=='#'){
                //cout << i << "," << t << endl;
                if(banmen[i-1][t+1]=='#'){
                    answer="Impossible";
                    goto end;
                }else {answer="Possible";

                }
            }else{}
        }
    }
    
    
    end:
    cout << answer << endl;
    
    
    return 0;
}


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

int main() {
    int n;
    int fh[100];
    int ch[100] = {0};
    int l, r;
    int ans = 0;
    
    cin >> n;
    
    for (int i = 0; i < n; i++) {
        cin >> fh[i];
    }
    
    while (true) {
        l = -1;
        r = -1;
        
        for (int i = 0; i < n; i++) {
            if (ch[i] < fh[i]) {
                if (l == -1) {
                    l = i;
                }
                
                ch[i]++;
            }
            else {
                if (l != -1) {
                    r = i - 1;
                    break;
                }
            }
        }
        
        if ((l == -1) && (r == -1)) {
            break;
        }
        
        ans++;
    }
    
    cout << ans << endl;
    return 0;
}

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

long long modnum = 1e9 + 7;

long long modpow(long long a, long long n) {
    long long res = 1;
    while(n > 0) {
        if(n & 1){
            res = res * a % modnum;
        }
        a = a * a % modnum;
        n >>= 1;
    }
    return res;
}

int main(){
    int N, K;
    std::cin >> N >> K;
    
    std::vector< int > num(K);
    long long ans = 0;
    for(int i=K; i>0; i--){
        long long tmp;
        int pat = K / i;
        tmp = modpow(pat, N);
        for(int j=i+i; j<=K; j=j+i){
            if(tmp < num[j]){
                tmp = modnum + tmp - num[j];
            }else{
                tmp = tmp - num[j];
            }
        }
        num[i] = tmp;
        tmp = (tmp * i) % modnum;
        ans = ( ans + tmp) % modnum;
    }
    
    std::cout << ans << std::endl;
    return 0;
}



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

#define REP(i, n) for(decltype(n) i = 0; i < n; i++)

#define ALL(c)   c.begin(), c.end()
#define SORT(c)  std::sort(ALL(c))
#define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>())

using namespace std;
using ll = long long;

const int MOD  = (int)1e9 + 7;
const int INF  = (int)1e9 + 1;
const ll  LINF = (ll)1e18 + 1;

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

    vector<int> map{0, 2, 5, 5, 4, 5, 6, 3, 7, 6};

    int N, M;
    std::cin >> N >> M;

    vector<int> usable(M);
    REP(i, M) {
        std::cin >> usable[i];
    }

    vector<int> dp(N + 1, -INF);
    dp[0] = 0;
    for(int i = 1; i <= N; i++) {
        auto max_digit = -INF;
        for(const auto& v : usable) {
            if(0 <= i - map[v]) {
                max_digit = max(max_digit, dp[i - map[v]] + 1);
            }
        }
        dp[i] = max_digit;
    }

    RSORT(usable);

    auto dpi = N;
    while(true) {
        for(const auto& v : usable) {
            if(0 <= dpi - map[v] && dp[dpi - map[v]] == dp[dpi] - 1) {
                std::cout << v;
                dpi -= map[v];
                break;
            }
        }
        if(dpi <= 0) {
            std::cout << std::endl;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#define N 100005
using namespace std;

typedef long long ll;
ll n, q, k, c[N];
vector<ll> a[N], b[N];

void f(ll p, ll q) {
	ll i;
	if (c[p] < q) return;
	c[p] = q;
	for (i = 0; i < a[p].size(); i++) {
		f(a[p][i], q + b[p][i]);
	}
}

int main()
{
	ll i, t1, t2, t3;
	cin >> n;
	for (i = 1; i <= n; i++) c[i] = 1e18;
	n--;
	while (n--) {
		scanf("%lld %lld %lld", &t1, &t2, &t3);
		a[t1].push_back(t2); b[t1].push_back(t3);
		a[t2].push_back(t1); b[t2].push_back(t3);
	}
	cin >> q >> k;
	f(k, 0);
	while (q--) {
		scanf("%lld %lld", &t1, &t2);
		printf("%lld\n", c[t1] + c[t2]);
	}
    return 0;
}

Measured memory_bytes: 18176
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;


int main() {

	string S, T;
	cin >> S;
	cin >> T;
	
	int count = 0;
	for(int i = 0; i < 3; i++){
		if(S[i] == T[i]) count++;
		
	}
	
	cout << count << endl;


    return 0;
}


Measured memory_bytes: 256
I = input()
for param in range(2**(len(I)-1)):
    ans = ""
    for i in range(len(I)):
        ans += I[i] + ["+","-",""][((param >> i) & 1) if i != len(I) - 1 else 2]
    if eval(ans) == 7:
        print(ans+"=7")
        break


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<algorithm>
#include<string>
#include<iostream>
using namespace std;
#define int long long
#define double long double
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define th third
#define sz size()
#define bgn begin()
#define en end()
#define pb push_back
#define pp() pop_back()
#define V vector
#define P pair
#define yuko(a) setprecision(a)
#define uni(a) a.erase(unique(a.begin(),a.end()),a.end())
#define Q queue
#define pri priority_queue
#define Pri priority_queue<int,vector<int>,greater<int>>
#define PriP priority_queue<P<int,int>,vector<P<int,int>>,greater<P<int,int>>>
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
#define all(a)  (a).begin(),(a).end()
#define elif else if


int inf=10000000000000007;
int dp[10000000];

signed main(){
  int n,k;
  cin>>n>>k;
  V<int> h(n);
  fo(i,n){
    cin>>h[i];
  }
  fo(i,10000000){
    dp[i]=inf;
  }
  dp[0]=0;
  fo(i,n){
    for(int j=1; j<=k; j++){
      dp[i+j]=min(dp[i+j],dp[i]+abs(h[i]-h[i+j]));

    }
  }
  cout<<dp[n-1]<<endl;
}

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

using namespace std;

#define INF 1<<30
#define LINF 1ll<<60ll
#define MOD 1000000007
#define pb(a) push_back(a)
#define vi vector<int>
#define vl vector<long long>
#define vvi vector<vi>
#define P pair<int,int>
#define all(vec) (vec.begin()),(vec.end())
typedef long long ll;
typedef unsigned long long ull;
#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define bit(n) (1<<(n))

#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REP3(i, m, n) for(int i = m, i##_len=(n);i < i##_len;++i)
#define FORVEC(i, v) for(int i = 0;i < sz(v);++i)

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

#define fil0(i,n) cout<<swet(n)<<setfill('0')<<i<<resetiosflags(ios_base::floatfield)
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define possible(n) cout<<((n)?"possible":"impossible")<<endl
#define Possible(n) cout<<((n)?"Possible":"Impossible")<<endl


int main(){
    int n;
    string s;
    cin>>n>>s;
    int x=0;
    REP(i,n){
        if(s[i]=='E')++x;
    }
    int min=INF;

    REP(i,n){ // リーダーの位置
        chmin(min,x-(s[i]=='E'));
        x+=(s[i]=='E')?-1:1;
    }
    cout<<min<<endl;
    return 0;
}


Measured memory_bytes: 900
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>
#include<stack>
#include<iomanip>
#include<cstdint>
#include<bits/stdc++.h>
using namespace std;

#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPL(i,a,n) for(ll i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define SORTVG(v) sort(v.begin(),v.end(),greater<>())
#define SORTV(v) sort(v.begin(),v.end())
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define INF LLONG_MAX/2

typedef long long ll;
typedef tuple<int,int,bool> Tb;
typedef pair<int,int> Pii;
typedef vector<int> Vi;

template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}
template<class T> void YesNo(T& a) {if(a){cout << "Yes" << ENT;}else{cout << "No" << ENT;}}
template<class T> void YESNO(T& a) {if(a){cout << "YES" << ENT;}else{cout << "NO" << ENT;}}
template<class T> void AorB(T& a, string A,string B) {if(a){cout << A << ENT;}else{cout << B << ENT;}}


int atcoder(){
    int n,h,w,t1,t2,ans=0;
    cin>>n>>h>>w;
    REP(i,0,n){
        cin>>t1>>t2;
        if(t1>=h && t2>=w)ans++;
    }
    cout<<ans<<ENT;
    return 0;
}


signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    atcoder();
    return 0;
}

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

using namespace std;

int main() {
    string s;
    cin >> s;
    int n = s.size();
    string s1(n, '0'), s2(n, '0');
    for (int i=0;i<n;++i) {
        if (i%2==0) s1[i] = '1';
        else s2[i] = '1';
    }
    int cost1 = 0, cost2 = 0;
    for (int i=0;i<n;++i) {
        if (s[i] != s1[i]) ++cost1;
        if (s[i] != s2[i]) ++cost2;
    }
    cout << min(cost1, cost2);
    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

int main(void) {
 
    long double w,h,x,y;
    long double a;
    scanf("%llf %llf %llf %llf",&w,&h,&x,&y);
    a = w*h/2;
    int b = 0;
    if(w/2==x&&h/2==y)b=1;
    else b=0;
    printf("%.9llf %d",a,b);
    return 0;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector <int> a (M);
  vector <int> b (M);
  vector <int> c (N);
  
  for (int i=0; i<M; i++){
    cin >> a.at(i) >> b.at(i);
  }
    
    for (int j=0; j<M; j++){     
      c.at(a.at(j)-1)++;
      c.at(b.at(j)-1)++;    
    } 
  
  for (int j=0; j<N; j++){     
     cout << c.at(j) << endl;
  }
 
}


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

int main(void) {
	int n, b[100001][2] = { 0 }, next = 1,r;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &b[i][0]);
	}
	for (r = 0;; r++) {
		if (next == 2)break;
		b[next][1]++;
		if (b[next][1] > 1) {
			printf("-1\n");
			return 0;
		}
		next = b[next][0];
	}
	printf("%d", r);
}

Measured memory_bytes: 896
import sys
import math

l = raw_input().split()
l[0] = int(l[0])
l[1] = int(l[1])
l[2] = int(l[2])

sum = l[0]+l[1]+l[2]
min = sum

for i in range(3):
    s = sum - l[i]
    if s < min:
        min = s

print min


Measured memory_bytes: 2568
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <map>

#define MAX_V 600000
#define LL long long
using namespace std;

const int INF = 1000000000;

struct edge { int to, cost; };
typedef pair<int, int> P;

int V;
vector<edge> G[MAX_V];
int d[MAX_V];

void dijkstra(int s){
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d,d+V, INF);
    d[s] = 0;
    que.push(P(0,s));
    while(!que.empty()){
        P p = que.top(); que.pop();
        int v = p.second;
        if(d[v]<p.first) continue;
        for(int i=0;i<G[v].size();i++){
            edge e = G[v][i];
            if(d[e.to]>d[v]+e.cost){
                d[e.to] = d[v]+e.cost;
                que.push(P(d[e.to],e.to));
            }
        }
    }
}

map<P, int> m;
int cnt2 = 0;
int N, M;
void f(P x, P y, int c){
    edge *e = new edge;
    e->to = m[y]; e->cost = c;
    G[m[x]].push_back(*e);
}

int main()
{
    
    cin >> N >> M;
    int cnt1 = 1;
    
    for(int i=0;i<N;i++){
        m[P(i,-1)]= cnt1++;
    }
    for(int i=0;i<M;i++){
        int a,b,c;
        scanf(" %d %d %d", &a, &b, &c);
        a--; b--;
        P eg0 = P(a,c), eg1 = P(b,c); 
        P ng0 = P(a,-1), ng1 = P(b,-1);
        if(m[eg0]==0){
            m[eg0] = cnt1;
            cnt1++;
            f(eg0,ng0,0); f(ng0,eg0,1);
        }
        if(m[eg1]==0){
            m[eg1] = cnt1;
            cnt1++;
            f(eg1,ng1,0); f(ng1,eg1,1);
        }
        f(eg0,eg1,0);
        f(eg1,eg0,0);
    }
    int end = m[P(N-1,-1)];
    V = cnt1;
    dijkstra(1);
    cout << (d[end]==INF?-1:d[end]) << endl;
    return 0;
}


Measured memory_bytes: 105332
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
typedef long long  ll;

#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

int main()
{
	ll A, B; cin >> A >> B;
	char S[12]; cin >> S;

	rep(i, 0, A + B + 1) {
		if ((i == A && S[i] != '-') || (i != A &&(S[i] < '0' || S[i] > '9'))) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2147483647
#define LINF 9223372036854775807
#define MOD 1000000007
//#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i,n) for(int i=n-1;i>=0;i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef pair<int,int> P;
//typedef long long int ll;

double ans;

signed main(){

    double n,k;
    cin>>n>>k;
    rep(i,n){
        int co=0;
        for(int j=i+1;j<k;co++){
            j*=2;
        }
        //DEB(co)END
        ans+=(1.0/n)*pow(0.5,double(co));
    }
    printf("%13.12lf",ans);
}


Measured memory_bytes: 256
X = int(input())
if X==1:
    print(1)
else:
    cmax = 0
    for i in range(2,int(X**0.5)+1):
        k = 2
        while i**k<=X:
            k += 1
        cmax = max(cmax,i**(k-1))
    print(cmax)

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

int main(){
    int A,N,x;

    cin >> N >> A;
    x = N % 500 - A;
    if(x<=0)
    {
        cout << "Yes" << endl;
    }else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
import collections

N = int(input())
l = []
for i in range(0, N):
  l.append(input())
c = collections.Counter(l)

print("AC x {0}".format(c["AC"]))
print("WA x {0}".format(c["WA"]))
print("TLE x {0}".format(c["TLE"]))
print("RE x {0}".format(c["RE"]))


Measured memory_bytes: 16644
import java.util.Scanner;
class Main {
	double[][] dp;
	int[] v;
	int[][] event;
	int x,y,z;
	
	public static void main(String args[]){
		Main app = new Main();
		Scanner scan = new Scanner(System.in);
		while(true){
			app.x = scan.nextInt();
			app.y = scan.nextInt();
			app.z = scan.nextInt();
			if(app.x==0 && app.y==0 && app.z==0){
				break;
			}
			app.v = new int[app.x];
			for(int i=0;i<app.x;i++){
				app.v[i] = scan.nextInt();
			}	
			app.event = new int[app.y+1][2];
			for(int i=0;i<app.z;i++){
				int tmp = scan.nextInt();
				app.event[tmp][0] = scan.nextInt();
				app.event[tmp][1] = scan.nextInt();
			}
			app.dp = new double[app.y+1][5001];
			System.out.println(app.LifeGame());
		}
	}
	
	public int LifeGame(){
		dp[0][0] = 1;
		
		for(int i=0;i<y+1;i++){
			for(int j=0;j<5001;j++){
				if(dp[i][j]>0){
					for(int k=0;k<x;k++){
						if(i!=y){
							int num = i+v[k];
							if(num>y){
								num = y;
							}
							int money = j;
							switch(event[num][0]){
							case 1:
								num+=event[num][1];
								if(num>y){
									num = y;
								}
								break;
							case 2:
								money = j+event[num][1];
								break;
							case 3:
								money = j-event[num][1];
								if(money<0){
									money = 0;
								}
								break;
							}
							dp[num][money] += dp[i][j]/x;
						}
					}
				}
			}
		}
		double exp=0;
		for(int i=0;i<5001;i++){
			exp += dp[y][i]*i;
		}
		
		return (int)exp;
	}
}

Measured memory_bytes: 62040
#include<bits/stdc++.h>
using namespace std;
int main()
{
   vector<int>a;
    int i,j,b,c,n,p,q,r,t,x,k;

    cin>>n;


for(i=0;i<n;i++)
{
    cin>>x;
    a.push_back(x);
}
if(!is_sorted(a.begin(),a.end()))
   {
       prev_permutation(a.begin(),a.end());

for(i=0;i<n;i++)
{
    if(i!=n-1)
    {
         cout<<a[i]<<" ";
    }
 else
 {
     cout<<a[i];
 }
}
    cout<<endl;
}
else
{
    prev_permutation(a.begin(),a.end());
}

next_permutation(a.begin(),a.end());
for(i=0;i<n;i++)
{
       if(i!=n-1)
    {
         cout<<a[i]<<" ";
    }
 else
 {
     cout<<a[i];
 }
}
cout<<endl;
if(!is_sorted(a.begin(),a.end(),greater<int>()))
   {
       next_permutation(a.begin(),a.end());

for(i=0;i<n;i++)
{
     if(i!=n-1)
    {
         cout<<a[i]<<" ";
    }
 else
 {
     cout<<a[i];
 }
}
    cout<<endl;
   }


return 0;

}








Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
const ll M = 1e9 + 7;

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

  int r = x % 100;
  if (r % 5 == 0) r = r/5;
  else r = r/5 + 1;

  int k = x / 100;
  if (k >= r) cout << 1 << endl;
  else cout << 0 << endl;
   
  return 0;
}

Measured memory_bytes: 3624
from itertools import combinations

n = int(input())
lst = list(map(int, input().split()))
comb = combinations(lst, 3)
count = 0

for i in comb:
  if i[0] != i[1] and i[1] != i[2] and i[0] != i[2]:
    if i[0] + i[1] > i[2] and i[1] + i[2] > i[0] and i[0] + i[2] > i[1]:
      count += 1
    
print(count)

Measured memory_bytes: 9216
<?php

fscanf(STDIN, "%d", $n);
fscanf(STDIN, "%d", $a);
fscanf(STDIN, "%d", $b);
fscanf(STDIN, "%d", $c);
fscanf(STDIN, "%d", $d);
fscanf(STDIN, "%d", $e);
 
$min = min($a, $b, $c, $d, $e);
 
echo (int) (4 + ceil($n / $min)), PHP_EOL;
 


Measured memory_bytes: 4728
import java.io.BufferedReader;
import java.io.InputStreamReader;

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

		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		String line = reader.readLine();
		String[] str = line.split(" ");
		int L = Integer.parseInt(str[0]);
		int R = Integer.parseInt(str[1]);
		int ans = Integer.MAX_VALUE;

		if (L / 2019 != 0 && R / 2019 != 0 && R / 2019 - L / 2019 >= 2) {
			ans = 0;
		}
		else if (L / 2019 == 0 && R / 2019 != 0 && R / 2019 - L / 2019 >= 2) {
			ans = 0;
		}
		else if (L / 2019 != 0 && R / 2019 == 0 && R / 2019 - L / 2019 >= 2) {
			ans = 0;
		}
		else if (L / 2019 == 0 && R / 2019 == 0 && R / 2019 - L / 2019 >= 1) {
			ans = 0;
		}
		else {
			for (int i = L; i < R; i++) {
				for (int k = i+1; k <= R; k++) {
					int keep = (i % 2019) * (k % 2019);
					keep %= 2019;
					if (keep < ans) {
						ans = keep;
					}
				}
			}
		}
		System.out.println(ans);
	}
}


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

using namespace std;
typedef long long int lli;
string s,t;
lli n,m;
lli dp[3004][3004];
lli lcs(lli i,lli j);

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>s>>t;
	n=s.size();
	m=t.size();
	for (int i=0;i<=n;i++){
		for (int j=0;j<=m;j++) dp[i][j]=-1;
	}
	lcs(0,0);
	lli i=0,j=0;
	string ans;
	while (i<n && j<m){
		if (s[i]==t[j]){
			ans+=s[i];
			i++;
			j++;
		}
		else{
			if (dp[i+1][j]>dp[i][j+1]) i++;
			else j++;
		}
	}
	cout<<ans<<endl;
	
	return 0;
}

lli lcs(lli i,lli j){
	if (i==n || j==m) return 0;
	if (dp[i][j]!=-1) return dp[i][j];
	if (s[i]==t[j]) dp[i][j]=lcs(i+1,j+1)+1;
	else  dp[i][j]=max(lcs(i+1,j),lcs(i,j+1));
	return dp[i][j];
}

Measured memory_bytes: 70912