akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=55;
const int mod=1e9+7;
int n,c[N][N],f[N][N];
void Inc(int &x,int y){
	x+=y;x>=mod?x-=mod:x;
}
int main(){
	scanf("%d",&n);
	for(int i=c[0][0]=1;i<=n;++i)
		for(int j=c[i][0]=1;j<=i;++j)
			c[i][j]=(c[i-1][j]+c[i-1][j-1])%mod;
	f[1][0]=f[1][1]=1;
	for(int i=1;i<n;++i)
		for(int j=0;j<=i;++j)
			if(f[i][j])
				for(int x=0;i+x<=n;++x)
					for(int y=0;i+x+y<=n;++y)
						if(x+y&&x+y>=j&&(~x+y-j&1))
							Inc(f[i+x+y][abs(j+(x+y-j)/2-x)],1ll*f[i][j]*c[i+x+y][x+y]%mod*c[x+y][x]%mod);
	printf("%d\n",f[n][0]);
	return 0;
}


Measured memory_bytes: 128
from collections import defaultdict
N=int(input())
d=defaultdict(int)
for i in range(N):
  x=input()
  d[x]+=1
print('AC x '+str(d['AC']))
print('WA x '+str(d['WA']))
print('TLE x '+str(d['TLE']))
print('RE x '+str(d['RE']))

Measured memory_bytes: 9480
/*
   AUTHOR :- Gaurang_Kothiya
   
   Quote:-" Great things never come from comfort zones."                                                                                                                
*/
 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>  
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
#include <bitset>
#include <cstdint>
#include <initializer_list>
 
using namespace std;
using namespace __gnu_pbds;  
 
typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> data_set; 
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long  
#define ld long double
#define f(i,x,n) for(ll i=x;i<=n;i++)
#define fe(x,v)   for(auto &x :v)
#define nf(i,x,n) for(ll i=n;i>=x;i--)
#define all(a)   a.begin(),a.end()
#define b_s(a,b)   binary_search( all(a),b)
#define lb(v,n)  lower_bound(all(v) ,n )
#define ub(v,n)  upper_bound( all(v) , n)
#define gcd(a,b) __gcd(a,b)
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define B begin()
#define E end()
#define acc(v, x) accumulate(all(v), x)
#define p(a,b) pair<a,b>
#define F first
#define S second
#define sz size()
#define v(x) vector<x>
#define m(a,b) map<a,b>
#define u_m(a,b) unordered_map<a,b>
#define mm(a,b) multimap<a,b>
#define s(a) set<a>
#define us(a) unordered_set<a>
#define ms(a) multiset<a>
#define maxy __LONG_LONG_MAX__
#define miny INT_MIN
#define PI 3.14159265358979323846
#define MOD 1000000007


void Solve()
{
	ll n;
	cin>>n;
	
	ll tn=n%500;
	
	cout<< 1000*(n/500) + 5*(tn/5);
	
	
}


signed main() 
{
	speed	
		
	ll q=1;	
	//cin>>q;	
	
	while(q--)	
	Solve();	
	
	//cout << "\n\n"<<"Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " seconds.\n";
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    long a, b, r, lcm, x, y;
    while (scanf("%ld %ld",&a,&b) != EOF) {
        x=a;
        y=b;
        for (;;) {
            r=x%y;
            if (r==0)
                break;
            x=y;
            y=r;
        }
        lcm=a*b/y;
        printf("%-ld %-ld\n",y,lcm);
    }
    
    return 0;
}

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

int main() {
    
    long long N, P;
    cin >> N >> P;
    
    if(N >= 60)
        cout << 1 << "\n";
    else
    {
        long long ans = 1;
        
        for(long long i=2; i*i <= P; i++)
        {
            int f = 0;
            
            while(P % i == 0)
                P /= i, f++;
            
            for(int j=0; j<f/N; j++)
                ans *= i;
        }
        
        if(P > 1 && 1 / N)
            ans *= P;
        
        cout << ans << "\n";
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
main() {
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    lli N;
    cin >> N;
    lli *H = new lli[N];
    for(lli i = 0; i < N; i++) {
    	cin >> H[i];
	}
	int maxSteps = 0, currentSteps = 0;
	for(lli i = N - 2; i >= 0; i--) {
		if(H[i] >= H[i + 1]) {
			currentSteps++;
		}
		else {
			currentSteps = 0;
		}
		maxSteps = max(currentSteps, maxSteps);
	}
	cout << maxSteps << "\n";
}

Measured memory_bytes: 1152
import sys
input = sys.stdin.readline

import bisect

s = input().split() 
s = list(s[0])
t = input().split() 
t = list(t[0])
f = [[] for _ in range(26)]

for i in range(len(s)):
    f[ord(s[i])-97].append(i)

g = [-1 for _ in range(len(t))]
if len(f[ord(t[0])-97]) == 0:
    print(-1)
    sys.exit()
g[0] = f[ord(t[0])-97][0]
cnt = 0
for i in range(1,len(t)):
    if len(f[ord(t[i])-97]) == 0:
        print(-1)
        sys.exit()

    if f[ord(t[i])-97][-1] > g[i-1]:
        index = bisect.bisect_right(f[ord(t[i])-97], g[i-1])
        g[i] = f[ord(t[i])-97][index]
    else:
        g[i] = f[ord(t[i])-97][0]
    if g[i] <= g[i-1]:
        cnt += 1

print(cnt*len(s)+g[-1]+1)
    




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

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a>b){
        swap(a,b);
    }
    if(b>c){
        swap(b,c);
    }
    if(a>b){
        swap(a,b);
    }
    cout<<a<<" "<<b<<" "<<c<<endl;
}


Measured memory_bytes: 3096
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ctime>

using namespace std;
using ll = long long;

int f_dir[2][4] = {{-1, 0, 0, 1}, {0, -1, 1, 0}};
int e_dir[2][8] = {{-1, -1, -1, 0, 0, 1, 1, 1}, {-1, 0, 1, -1, 1, -1, 0, 1}};
bool is_in_field(int y, int x, int h, int w){
  return (y >= 0 && y < h && x >= 0 && x < w);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  vector<int> a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k; cin >> k;
  cout << a[k-1] << endl;
  // end-----------------------------------------------
  // cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}


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

using namespace std;

int v[4];

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

for (int i=0; i<4; i++)
{
    scanf ("%d", &v[i]);
    if (i > 0 && v[i] > 2 * v[i - 1])
        v[i] = 2 * v[i - 1];
}
long long N;
scanf ("%lld", &N), N *= 4LL;
long long ans = 0;
for (int i=3; i>=0; i--)
{
    int curr = 1 << i;
    ans += 1LL * (N / curr) * v[i];
    N %= curr;
}
printf ("%lld\n", ans);
return 0;
}


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

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";
		int sum = 0;

		while ((line = br.readLine()) != null) {
			if (line.length() == 1) {
				sum++;
				continue;
			}
			int len, mid;
			len = line.length();
			mid = len / 2;
			for (int i = 0; i < mid; i++) {
				if (line.charAt(i) != line.charAt(len - 1 - i))
					break;
				if (i == mid - 1)
					sum++;
			}
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 16860
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
from fractions import gcd

class SegmentTree:
    def __init__(self, N, func, I):
        self.sz = N
        self.func = func
        self.I = I
        self.seg = [I]*(N*2)
 
    def assign(self, k, x):
        self.seg[k + self.sz] = x
 
    def build(self):
        for i in range(self.sz - 1, 0, -1):
            self.seg[i] = self.func(self.seg[2 * i], self.seg[2 * i + 1])
 
    def update(self, k, x):
        k += self.sz
        self.seg[k] = x
        while k > 1:
            k //= 2
            self.seg[k] = self.func(self.seg[2 * k], self.seg[2 * k + 1])
 
    def query(self, a, b):
        R = self.I
        a += self.sz
        b += self.sz
        while a < b:
            if a % 2 == 1:
                R = self.func(R, self.seg[a])
                a += 1
            if b % 2 == 1:
                b -= 1
                R = self.func(self.seg[b], R)
            a //= 2
            b //= 2
        return R

def main():
    N = int(readline())
    m = map(int,read().split())
    seg = SegmentTree(N , gcd , 0)
    for i in range(N):
        seg.assign(i , next(m))
    seg.build()
    ans = 1
    for i in range(N):
        ans = max(ans,gcd(seg.query(0,i) , seg.query(i+1,N)))
    print(ans)

main()


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

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

    int len_s = S.length();
    int len_t = T.length();
    int min = len_t;
    for (int i = 0; i <= len_s - len_t; i++) {
        int count = 0;
        for (int j = 0; j < len_t; j++) {
            if (S[i + j] != T[j]) {
                count++;
            }
        }
        min = std::min(min, count);
    }
    std::cout << min << std::endl;
}


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

using namespace std;

using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main() {
    ll n, m, i, j, k, T;
    cin >> n >> T;
    vector<pair<ll, ll>> v(n);
    for(i = 0; i < n; i++) {
        cin >> v[i].first >> v[i].second;
    }
    sort(v.begin(), v.end());

    vector<vector<ll>> dp(T, vector<ll>(n + 1, 0));
    for(j = 0; j < n; j++) {
        for(i = 0; i < T; i++) {
            if(i + v[j].first < T) dp[i + v[j].first][j + 1] = max(dp[i + v[j].first][j + 1], dp[i][j] + v[j].second);
            dp[i][j + 1] = max(dp[i][j + 1], dp[i][j]);
        }
    }
    // dp[i][j] := j個目までを使って時刻iまでに得られる利益の最大
    ll ret = 0, t = 0,dp2[n+1]={};
    for(i=n-1;i>=0;i--){
        dp2[i] = max(dp2[i],v[i].second);
    }
    for(i=1;i<=n;i++){
        ret = max(ret,dp[T-1][i]+dp2[i]);
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 70784
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int s, d, m;
int main() {
	while (cin >> s >> d >> m) {
		vector<vector<pair<int, int> > > v(s);
		for (int i = 0; i < s; i++) {
			int z; cin >> z; v[i].resize(z);
			for (int j = 0; j < z; j++) cin >> v[i][j].first >> v[i][j].second;
		}
		vector<pair<int, int> > x;
		for (int i = 0; i < d; i++) {
			int f; cin >> f;
			x.insert(x.end(), v[f].begin(), v[f].end());
		}
		int n = x.size();
		vector<vector<int> > dp(n + 1, vector<int>(m + 1, -99999999));
		dp[0][0] = 0;
		for (int i = 1; i <= n; i++) {
			for (int j = 0; j <= m; j++) {
				dp[i][j] = dp[i - 1][j];
				if (j >= x[i - 1].second) dp[i][j] = max(dp[i][j], dp[i - 1][j - x[i - 1].second] + x[i - 1].first);
			}
		}
		int ret1 = 0, ret2 = 0;
		for (int i = 0; i <= m; i++) {
			if (dp[n][i] > ret1) ret1 = dp[n][i], ret2 = i;
		}
		cout << ret1 << ' ' << ret2 << endl;
	}
	return 0;
}

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

#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) rep2(i, 0, n)
#define all(a) a.begin(), a.end()
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::fixed << std::setprecision(15);

    int n, q;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    cin >> q;
    vi t(q);
    rep(i, q) cin >> t[i];
    int ans = 0;
    rep(i, q)
    {
        int l = -1, r = n; // l，ｒとも条件を満たなさいことが確定した左端，右端．可能性があるのは，(l, r)の開区間
        bool f = false;
        while (l + 1 < r)
        {
            int m = (l + r) >> 1;
            if (a[m] == t[i])
            {
                f = true;
                break;
            }
            else if (a[m] < t[i])
                l = m;
            else
                r = m;
        }
        if (f)
            ans++;
    }
    cout << ans << endl;

    return 0;
}


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

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

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

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

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

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

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

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
        a: usize,
        b: usize,
        s: chars,
    }
    for i in 0..a {
        if !s[i].is_numeric() {
            println!("No");
            return;
        }
    }
    if !(s[a] == '-') {
        println!("No");
        return;
    }
    for i in a+1..a + b {
        if !s[i].is_numeric() {
            println!("No");
            return;
        }
    }
    println!("Yes");
}

Measured memory_bytes: 4352
#define _CRT_SECURE_NO_DEPRECATE
#define _USE_MATH_DEFINES
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <memory.h>
#include <set>
#include <ctime>
#include <map>
#include <cstring>
#include <iterator>
#include <queue>
#include <assert.h>
#include <bitset>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include<random>

//#pragma comment(linker, "/STACK:512000000")

using namespace std;

#define pb emplace_back
#define mp make_pair
#define all(a) (a).begin(), (a).end()
#define forn(i, n) for (int i = 0; i < (n); ++i)
#define forab(i, a, b) for (int i = (a); i < (b); ++i)

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int infi = 1e9 + 7;
const ll infl = (ll)1e18 + (ll)7;


int32_t main() {
    cin.sync_with_stdio(false);
    cin.tie(0);
    //srand(time(NULL));
   // freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int n;
    string s;
    cin >> n >> s;
    int a = 0, b = 0;
    forn(i, n)
        if (s[i] == '#')
            ++a;
    int ans = infi;
    for (int i = n - 1; i >= 0; --i) {
        ans = min(ans, a + b);
        if (s[i] == '#')
            --a;
        else
            ++b;
    }
    ans = min(ans, b);
    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
#define mp(a,b) make_pair(a,b)
#define ff first
#define setp(a) setprecision(a)<<fixed
#define ss second
#define fori(v) for(ll i=0; i<v; i++)
#define forj(v) for(ll j=0; j<v; j++)
#define fork(v) for(ll k=0; k<v; k++)
#define forl(v) for(ll l=0; l<v; l++)
#define fort(v) for(ll t=0; t<v; t++)
#define forz(v) for(ll z=0; z<v; z++)
#define forx(v) for(ll x=0; x<v; x++)
#define fory(v) for(ll y=0; y<v; y++)
#define ll long long
#define double long double
#define pb(a) push_back(a)
const ll INF = 0x3f3f3f3f;
const ll inf = pow(10,18);
ll modulo = 998244353 ;
#define MAX 300100
ll arr[MAX];


void deal(){
	ll n ;
	cin>>n;
	fori(n)
		cin>>arr[i];
	ll s = 0;
	fori(n){
		(i & 1) ? (s-=arr[i]) : (s+=arr[i]);
	}
	fori(n){
		cout<<s<<' ';
		s = 2*(arr[i]-s/2);
	}
	cout<<'\n';
}


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

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
int main()
{
    set<long long> Q;
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        long long s;
        cin >> s;
        Q.insert(s);
    }
    cout << ((Q.size() == n) ? "YES" : "NO");
    return 0;
}

Measured memory_bytes: 9600
from itertools import groupby as gb
l=[(a,len(list(b))) for a,b in gb(list(input()))]
ret=[]
for q,w in zip(l[::2],l[1::2]):
    a,b=q[1],w[1]
    ret+=[0]*(a-1)+[b//2-(-a//2),a//2-(-b//2)]+[0]*(b-1)
print(*ret,sep=" ")

Measured memory_bytes: 13496
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair

const int N = 2020;
int a[N][N];
int m, n;
int ans = 0;

int getSum(int x1, int y1, int x2, int y2) {
	return a[x2][y2] + a[x1][y1] - a[x2][y1] - a[x1][y2];
}

int solve(int x, int y) {
	if (x <= n)
		return getSum(x, y, x + n, n) + getSum(0, 0, x, y) + getSum(x + n, 0, 2 * n, y);
	else
		return getSum(0, y, x - n, n) + getSum(x - n, 0, x, y) + getSum(x, y, 2 * n, n);
}

int main()
{
	//freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	scanf("%d%d", &m, &n);
	while(m--) {
		int x, y;
		char c;
		scanf("%d%d %c", &x, &y, &c);
		if (c == 'W')
			x += n;
		x %= 2 * n;
		y %= 2 * n;
		if (y >= n) {
			x += n;
			y -= n;
		}
		x %= 2 * n;
		a[x + 1][y + 1]++;
	}

	for (int x = 1; x < N; x++)
		for (int y = 1; y < N; y++)
			a[x][y] += a[x - 1][y] + a[x][y - 1] - a[x - 1][y - 1];

	for (int x = 1; x <= 2 * n; x++)
		for (int y = 1; y <= n; y++) {
			ans = max(ans, solve(x, y));
		}
	printf("%d\n", ans);

	return 0;
}


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

using namespace std;

int main() {
	int h, w;
	char picture[105][105];
	cin >> h >> w;
	for (int i = 1; i <= h; ++i)
		for (int j = 1; j <= w; ++j)
			cin >> picture[i][j];
	
	for (int i = 0; i <= w + 1; ++ i)
		cout <<"#";
	cout << '\n';
		for (int i = 1; i <= h; ++i){
			for (int j = 0; j <= w + 1; ++j)
				if (j == 0 || j == w + 1)
					cout << "#";
				else
					cout << picture[i][j];
			cout << '\n';
		}
	for (int i = 0; i <= w + 1; ++ i)
		cout <<"#";
	
	return 0;
}

Measured memory_bytes: 256
// 簡易競プロテンプレ
#include <bits/stdc++.h>
using namespace std;

int main(void){
 int n; string s1, s2; cin >> n >> s1 >> s2;
 int ok = 0;
 for(int i=0;i<=n;i++){
  if (s1.substr(n-i)==s2.substr(0,i)) ok = i;
 }
 cout << n + n - ok << endl;
 return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  int arr[m];
  long sum = 0;
  for(int i=0;i<m;i++){
    cin>>arr[i];
  }
  for(int i = 0;i<m;i++){
    sum+=arr[i];
}
  int diff = n - sum;
  if(diff>0)
    cout<<diff;
  else if(diff==0)
    cout<<0;
  else
    cout<<-1;
  return 0;
}


Measured memory_bytes: 3644
def check(A,a,b,c):
  if A[a] == 0:
    if A[b] == 0:
      if A[c] == 0:
        return 1
  return 0

A1 = list(map(int,input().split()))
A2 = list(map(int,input().split()))
A3 = list(map(int,input().split()))
N = int(input())
A = A1+A2+A3
for i in range(N):
  b = int(input())
  if b in A:
    A[A.index(b)] = 0
ans = "No"
anslist = []
#bingo check
anslist.append(check(A,0,1,2))
anslist.append(check(A,3,4,5))
anslist.append(check(A,6,7,8))
anslist.append(check(A,0,3,6))
anslist.append(check(A,1,4,7))
anslist.append(check(A,2,5,8))
anslist.append(check(A,0,4,8))
anslist.append(check(A,2,4,6))

if 1 in anslist:
  ans = "Yes"
print(ans)

Measured memory_bytes: 9168
package main

import (
	"fmt"
)

func Solve(a, b, t int) int {
	var n int
	for i := 1; ; i++ {
		if a*i > t {
			break
		}
		n += b
	}
	return n
}

func main() {
	var a, b, t int
	fmt.Scanf("%d %d %d", &a, &b, &t)
	result := Solve(a, b, t)
	fmt.Println(result)
}


Measured memory_bytes: 512
open System

// prelude
let readStr () = stdin.ReadLine()

let readInt () = stdin.ReadLine() |> int
let readInts () = stdin.ReadLine().Split() |> Array.map int

let pair = function
| [|a; b|] -> (a, b)
| _ -> failwith "owatta"

let triple = function
| [|a; b; c|] -> (a, b, c)
| _ -> failwith "owatta"

let inc n = n + 1
let dec n = n - 1

let inline flip f a b = f b a
let rec fix f = fun x -> (f (fix f)) x

module Option =
  let getOr defaultValue = function
  | Some x -> x
  | None -> defaultValue

module Array =
  let modify (arr: _ []) i f =
    arr.[i] <- f arr.[i]

module Array2D =
  let modify (arr: _ [,]) i j f =
    arr.[i, j] <- f arr.[i, j]

// start
let N=readInt()
let S=readStr().ToCharArray()

let sumW =
  let s=
    S
    |> Array.scan (fun sum c -> sum + if c='.' then 1 else 0) 0
  fun i j -> s.[j] - s.[i]

let sumB=
  let s=
    S |> Array.scan (fun sum c -> sum + if c='#' then 1 else 0) 0
  fun i j -> s.[j] - s.[i]

seq { for i in 0..N -> (sumB 0 i)+(sumW i N) }
|> Seq.min
|> printfn "%d"

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

int pow(int i, int n){
  int ans = 1;
  for(int j=0; j<n;j++){
    ans *=i;
  }
  return ans;
}

int main(){
  int N;
  cin >> N;
  
  int count = 0;
  for(int i=0; i<N; i++){
    if(N >= pow(2,i)){
      count = i;
    }else{
      break;
    }
  }
  
  cout << pow(2,count) << endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std ;
const int N = 1234567;
vector <pair<int,int> > G[N] ;
vector <int> newg[N] ;
queue <int> q ;
int f[N],son[N],id[N],dp[N] ;
bool use[N] ;
int n,m ;
inline void init(int i){
	f[i]=i;son[i]=0;id[i]=-1;use[i]=false ;
}
int find(int x){
	return (x==f[x])?x:f[x]=find(f[x]) ; 
}
inline void merge(int x,int y){
	int X=find(x),Y=find(y) ;
	if (X==Y) return ;
	if (son[X]<son[Y]) f[X]=Y ;//避免被hack 
	else {
		f[Y]=X ;
		if (son[X]==son[Y]) son[X]++ ;
	}
} 
inline int read(){
	char c;int f=1 ;
	while ((c=getchar())<'0' || c>'9') if (c=='-') f=-1 ;
	int res=c-'0' ;
	while ((c=getchar())>='0' && c<='9') res=res*10+c-'0' ;
	return res*f ; 
}
int main(){
	n=read();m=read() ;
	for (int i=1;i<=m;i++){
		int a,b,c ;
		a=read();b=read();c=read() ;
		G[c].push_back(make_pair(a,b)) ;
	}
	int cnt=n; 
	for (int i=1;i<=N;i++){
		if (G[i].empty()) continue ; //无该公司 
		for (int j=0;j<G[i].size();j++){ //初始 
			init(G[i][j].first) ;
			init(G[i][j].second) ;
		}
		for (int j=0;j<G[i].size();j++) merge(G[i][j].first,G[i][j].second) ;
		for (int j=0;j<G[i].size();j++){
			if (!use[G[i][j].first]){
				use[G[i][j].first]=true ;
				int X=find(G[i][j].first) ;
				if (id[X]==-1) id[X]=++cnt ;
				newg[G[i][j].first].push_back(id[X]) ;//该站点与公司建无向边 
				newg[id[X]].push_back(G[i][j].first) ;
			}
			if (!use[G[i][j].second]){ //同样的工作在second上再做一遍 
				use[G[i][j].second]=true ;
				int X=find(G[i][j].second) ;
				if (id[X]==-1) id[X]=++cnt ;
				newg[G[i][j].second].push_back(id[X]) ;
				newg[id[X]].push_back(G[i][j].second) ;
			}
		}
 	}
 	q.push(1) ;
 	memset(dp,-1,sizeof(dp)) ;
 	dp[1]=0; //初始在0号节点
	while(!q.empty()){ //BFS 
		int v=q.front();q.pop() ;
		for (int i=0;i<newg[v].size();i++){
			int to=newg[v][i] ;
			if (dp[to]==-1){ //还没访问 
				dp[to]=dp[v]+1 ;
				q.push(to) ;
			}
		}
	}
	if (dp[n]==-1) cout<<-1 ;
	else cout<<dp[n]/2 ;
}

Measured memory_bytes: 85376
#include <iostream>

using namespace std;

int main() {
    int n;
    cin >> n;
    int count = 0;
    for (int i = 0; i < n; ++i) {
        int p;
        cin >> p;
        if (p != i + 1) ++count;
    }
    cout << (count <= 2 ? "YES" : "NO") << endl;
}


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

int main(void){
int a,b,c;
scanf("%d %d %d",&a,&b,&c);
if((c>a&&c>b)||(c<a&&c<b)){printf("No");}
else{printf("Yes");}
return 0;
}


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

int main(){
  int n,t,f=0;
  string s;
  ll ans;
  cin>>n>>t;
  cin>>s;
  for(int i=0;i<s.size();i++){
    if(!('0'<=s[i]&&s[i]<='9'))continue;
    ll cnt=1;
    for(int j=0;j<s[i]-'0';j++){
      if(cnt*n>T){
	f=1;
	break;
      }else cnt*=n;
    }
    if(f)break;
    if(ans+cnt>T){
      f=1;
      break;
    }else ans+=cnt;
  }
  if(ans*t>T)f=1;
  else ans*=t;
  if(!f)cout<<ans<<endl;
  else cout<<"TLE"<<endl;
  return 0;
}

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

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

    cin >> a >> b >> c >> d;
    if(a + b > c + d)
    {
        cout << "Left" << endl;
    }
    else if(a+ b == c + d)
    {
        cout << "Balanced" << endl;
    }
    else
    {
        cout << "Right" << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		char s[] = sc.next().toCharArray();
		int x = sc.nextInt(), y = sc.nextInt();
		
		int dpx[] = new int[16010];
		int dpy[] = new int[16010];
		
		int cnt = 0;
		int p = 0;
		while(p<s.length && s[p] == 'F'){
			cnt++;
			p++;
		}
		dpx[cnt+8000] = 1;
		dpy[8000] = 1;
		
		cnt = 0;
		p++;
		int dir = 1;
		for(;p<s.length;p++){
			if(s[p]=='F')
				cnt++;
			else{
				if(dir==1)
					update(dpy, cnt);
				else
					update(dpx, cnt);
				
				cnt=0;
				dir = 1-dir;
			}
		}
		if(cnt!=0){
			if(dir==1)
				update(dpy, cnt);
			else
				update(dpx, cnt);
		}
		
		if(dpx[x+8000]==1 && dpy[y+8000]==1){
			System.out.println("Yes");
		}
		else{
			System.out.println("No");
		}
	}
	
	static void update(int dp[], int n){
		int arr[] = new int[dp.length];
		
		for(int i=0;i<arr.length;i++){
			if(dp[i] == 1){
				arr[i-n] = 1;
				arr[i+n] = 1;
			}
		}
		
		for(int i=0;i<dp.length;i++){
			dp[i] = arr[i];
		}
	}

}


Measured memory_bytes: 145236
#include <iostream>
#include <cmath>

using namespace std;

typedef long long ll;

int main(int argc, char *argv[])
{
	int N, D;
	int X[20][20];

	cin >> N >> D;

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < D; j++) {
			cin >> X[i][j];
		}
	}
	int ans = 0;
	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j < N; j++) {
			int d = 0;
			for (int k = 0; k < D; k++) {
				d += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]);
			}
			double rd = sqrt(d);
			int ird = (int) rd;
			if (ird * ird == d) {
				ans++;
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  cout<<max(0,min(B,D)-max(A,C))<<endl;
  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;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) 
{
    os << "{ ";
    for(auto& y : x) 
    {
        os << y << " ";
    }
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) 
{
    return os << "[" << p.ff << ", " << p.ss << "]";
}

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

    return gcd(b, a%b);
}

ll modexp(ll a, ll b, ll c)
{   
    a%=c;

    ll ans = 1;

    while(b)
    {
        if(b&1)
        {
            ans = (ans*a)%c;
        }

        a = (a*a)%c;
        b >>= 1;
    }

    return ans;
}

const ll L = 1e5+5;

vector <pll> adj[L];
ll ans[L];

void dfs(ll src, ll par, ll given)
{
    ll cur = 0;

    for(auto i: adj[src])
    {
        if(i.ff == par)
        {
            continue;
        }

        cur++;

        if(cur == given)
        {
            cur++;
        }

        ans[i.ss] = cur;

        dfs(i.ff, src, cur);
    }
}

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

    ll N;
    cin >> N;

    for(ll i=0; i<N - 1; i++)
    {
        ll a, b;
        cin >> a >> b;

        adj[a].pb(mp(b, i));
        adj[b].pb(mp(a, i));
    }

    ll K = 0;

    for(ll i=1; i<=N; i++)
    {
        K = max(K, sz(adj[i]));
    }

    dfs(1, -1, -1);

    cout << K << endl;

    for(ll i=0; i<N-1; i++)
    {
        cout << ans[i] << endl;
    }
    // cout << endl;

    return 0;
}

Measured memory_bytes: 9856
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 = sc.nextInt();
		if ( b - a == c - b ) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}


Measured memory_bytes: 22356
h, w = map(int, input().split())
a = [list(map(int, input().split())) for i in range(h)]

cnt = 0

res = []

for i in range(h):
    for j in range(w):
        if i == h - 1 and j == w - 1:
            break

        if a[i][j] % 2 == 1:
            cnt += 1
            a[i][j] -= 1
            if j < w - 1:
                a[i][j + 1] += 1
                res.append((i, j, i, j + 1))
            elif j == w - 1:
                a[i + 1][j] += 1
                res.append((i, j, i + 1, j))

print(cnt)
for tpl in res:
    o, p, q, r = tpl
    print(o + 1, p + 1, q + 1, r + 1)

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

int main(){
	int h,w,n; cin>>h>>w>>n;
	int mx=max(h,w);
	cout<<(n+(mx-1))/mx<<endl;
}

Measured memory_bytes: 3616
#include<iostream>
#include<string>
#include<math.h>

using namespace std;

int main(void){

    string str;
    int ans = 0;

    cin >> str;

    for(int i = 0;str[i] != '\0';i++){
        if(str[i] == '0') ans++;
        if(str[i] == '1') ans--;
    }

    cout << str.length() - abs(ans) << endl;

    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define mk make_pair
#define pb push_back
typedef pair<int, int> pii;
const int mod = 1000000007;
const int INF = 1000000009;
const long long INFL = 1000000000000000018ll;

int N;
double ans;

signed main()
{
    cin >> N;
    for(int i = 0; i < N; i++){
        double x;
        string u;
        cin >> x >> u;
        if(u == "BTC"){
            ans += x * 380000.0;
        }
        else {
            ans += x;
        }
    }
    printf("%.10f\n", ans);


    return 0;
}

/*

*/


Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int[] input = new int[3];
    int fiveCount = 0;
    int sevenCount = 0;

    for(int i = 0; i < 3; i++){
      input[i] = sc.nextInt();
      if(input[i] == 5 && fiveCount < 2){
        fiveCount++;
      }else if(input[i] == 7 && sevenCount < 1){
        sevenCount++;
      }else {
        System.out.println("NO");
        return;
      }
    }
    System.out.println("YES");
  }
}




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

const ll INF = (1LL << 60);

int main(){
    int N;
    cin >> N;
    vector<int>v;
    for (int i = 0; i < N; i++){
        int x;
        cin >> x;
        v.push_back(x);
    }
    vector<ll>dp(100010);
    for (int i = 1; i < 100010; i++){
        dp.at(i) = INF;
    }
    dp.at(1) = max(v.at(1),v.at(0)) - min(v.at(1),v.at(0));
    for (int i = 2; i < N; i++){
        int x = dp.at(i-1) + max(v.at(i),v.at(i-1)) - min(v.at(i),v.at(i-1));
        int y = dp.at(i-2) + max(v.at(i),v.at(i-2)) - min(v.at(i),v.at(i-2));
        dp.at(i) = min(x,y);
    }
    cout << dp.at(N-1) << "\n";
}

Measured memory_bytes: 1528
import sys
input = sys.stdin.buffer.readline

def main():
    N,A = map(int,input().split())
    x = list(map(int,input().split()))
    S = sum(x)
    
    dp = [[[0 for _ in range(S+1)] for _ in range(N+1)] for _ in range(N+1)]
    dp[0][0][0] = 1
    for i in range(N):
        for j in range(N):
            for k in range(S):
                if dp[i][j][k] == 0:
                    continue
                dp[i+1][j][k] += dp[i][j][k]
                dp[i+1][j+1][k+x[i]] += dp[i][j][k]

    M = S//A
    ans = 0
    for i in range(1,N+1):
        if i*A <= S:
            ans += dp[-1][i][i*A]
    
    print(ans)
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 56560
n = int(input())
s = [input() for i in range(n)]
flg = True
for i in range(1,n):
  if s[i-1][-1] != s[i][0]:
    flg = False
    break
if len(set(s)) != n:
  flg = False
if flg:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
tmp = list(map(int, input().split()))
x, y, a, b, c = tmp
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p.sort()
q.sort()
p = p[a-x:]
q = q[b-y:]

p.extend(q)
p.extend(r)
p.sort()
print(sum(p[len(p)-x-y:]))

Measured memory_bytes: 22720
#a, b, c, d = (int(i) for i in input().split())  
#W = [int(i) for i in input().split()] 
import math

N, X = (int(i) for i in input().split())
L_list = [int(i) for i in input().split()] 
#print(L_list)
sum_a = 0
cnt = 1
for l in (L_list):
    sum_a += l
    if sum_a > X:
        break
    cnt += 1
print(cnt)


Measured memory_bytes: 3060
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;

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

    int dist[N];
    for(int i=0;i<N-1;i++){
        dist[i] = A[i+1]-A[i];
    }
    dist[N-1] = K-A[N-1]+A[0];

    int max_dist=0;
    int sum=0;
    for(int i=0;i<N;i++){
        sum += dist[i];
        max_dist = max(max_dist,dist[i]);
    }

    cout << sum - max_dist << endl;

    return 0;
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll n,m,t,p;
ll km[100][100],km2[100][100];
ll i, j, k;
void oru(ll d,ll c){
    ll i, j, k;
    if(d==1){
        
        fornum(i,0,m){
            fornum(j,0,n){
                km2[i][j<c?c-j-1:j-c] += km[i][j];
            }
        }
        n = max(n-c,c);
    }else if(d==2){
        
        fornum(i,0,m){
            fornum(j,0,n){
                km2[i<c?c-i-1:i-c][j] += km[i][j];
            }
        }
        m = max(m-c,c);
    }
    fornum(i,0,m){
        fornum(j,0,n){
            km[i][j] = km2[i][j];
            km2[i][j] = 0;
            //printf("%lld ",km[i][j]);
        }
        //printf("\n");
    }
    //printf("\n");
    //printf("%lld,%lldpp\n", n, m);
}
int main(){
    
    scanf("%lld%lld%lld%lld", &n,&m,&t,&p);
    while(n){
        
        //ll ans = 0;
        fornum(i,0,m){
            fornum(j,0,n){
                km[i][j] = 1;
            }
        }
        //printf("%lldp\n", p);
        fornum(i,0,t){
            ll d, c;
            scanf("%lld%lld", &d, &c);
            oru(d, c);
        }
        //printf("%lldp\n", p);
        fornum(i,0,p){
            ll x, y;
            scanf("%lld%lld", &x, &y);
            //y = m - 1 - y;
            printf("%lld\n",km[y][x]);
        }
        scanf("%lld%lld%lld%lld", &n,&m,&t,&p);
        //printf("%lld%lld%lld%lld\n", n,m,t,p);
    }
    return 0;
}


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

int n;
int a[128];
long long solve(int id, bool f) {
  if (id >= n && f)
    return 1;
  else if (id >= n)
    return 0;
  long long ret = 0;
  for (int j = -1; j <= 1; j++) {
    if ((a[id] + j) % 2 == 0)
      ret += solve(id + 1, true);
    else
      ret += solve(id + 1, f);
  }
  return ret;
}

int main(void) {
  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> a[i];
  cout << solve(0, false) << endl;
}

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

using namespace std;
typedef unsigned long long ull;
ull len[100];

ull N,amt;
int main()
{
    cin>>N;

    for(ull i = 0; i<N; i++){
        cin>>len[i];
    }
    amt = 0;
    sort(len,len+N);
    for(ull i = 0; i<N; i++){
        for(ull j = 0; j<i; j++){
            for(ull k = 0; k<j; k++){
                if((i == j) || (j == k) || (i == k)){
                    continue;
                }

                if(len[k] != len[j] && len[j] != len[i] && len[k] + len[j]>len[i]){
                    amt++;
                }
            }
        }
    }

    cout<<amt<<endl;
    return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#define PTN 11
#define MAX 1001

void conv(char []);

int main(void) {
    int cnt;
    char ptn[PTN], buf[MAX];
    scanf("%s", ptn), conv(ptn);
    for(cnt = 0; ~scanf("%s", buf); cnt += !strcmp(ptn, buf)) {
        conv(buf);
    }
    printf("%d\n", cnt);
    return 0;
}

void conv(char str[]) {
    int i;
    for(i = 0; i < strlen(str); i++) {
        str[i] = tolower(str[i]);
    }
}

Measured memory_bytes: 564
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>	
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE int
#define MEMSET(a) memset(a,0,sizeof(a))
const int mod=(int)1e09+7;

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
double din(void){
	double i;scanf("%lf",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void dprint(double a){
	printf("%.10f\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}
double dmax(double a,double b){
	return a>b?a:b;
}
int cmp(const void *a,const void *b){
	return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
	return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
	return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
	return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
	int t=*a;
	*a=*b;
	*b=t;
}
long long gcd(long long x,long long y){
	return x%y?gcd(y,x%y):y;
}
long long lcm(long long x,long long y){
	return x/gcd(x,y)*y;
}

// konoshita kara kaku

int main(void){
	int h=in(),w=in(),i,j,c=0;
	char a[10];
	rep(i,h){
		chin(a);
		rep(j,w){
			if(a[j]=='#')c++;
		}
	}
	puts(c==h+w-1?"Possible":"Impossible");
	return 0;
}

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

int main()
{
    long long x, ans = 0;
    int count = 0, sum;
    bool flag;
    cin >> x;
    sum = x % 100;
    count = (x - sum) / 100;

    if ((sum % 5) == 0 && (sum / 5) > count)
    {
        flag = 1;
    }
    else if ((sum % 5) != 0 && ((sum - (sum % 5)) / 5) + 1 > count)
    {
        flag = 1;
    }
    else
    {
        flag = 0;
    }

    if (flag)
    {
        ans = 0;
    }
    else
    {
        ans = 1;
    }

    cout << ans << endl;
}

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

bool canmake(int a[], int n, int m);

int main() {
	int i, j, n, q, a[21], m;
	cin >> n;
	for (i = 0; i < n; i++) cin >> a[i];
	cin >> q;
	for (i = 0; i < q; i++) {
		cin >> m;
		if (canmake(a, n, m) == true)cout << "yes\n";
		else cout << "no\n";
	}
	return 0;
}

bool canmake(int a[], int n, int m) {
	if (n == 1) {
		if (a[0] == m || m == 0)return true;
		else return false;
	}
	if (canmake(a, n - 1, m) == true)return true;
	else if (canmake(a, n - 1, m - a[n - 1]) == true)return true;
	else return false;
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    char c;
    cin >> c;
    if(c >= 'a')cout << 'a' << endl;
    else cout << 'A' << endl;
    
}

Measured memory_bytes: 3636
n, k = map(int, input().split())
a = list(map(int, input().split()))

now=1
flg = 0
path = [1]
pathcheck ={1}
for i in range(k):
    now = a[now-1]
    if now in pathcheck:
        flg = -1
        path.append(now)
        break
    path.append(now)
    pathcheck.add(now)


if flg == 0:
    print(now)
    exit()

x1 = path.index(now)
x2 = len(path)-1
x3 = (k-x1)%(x2-x1)
print(path[x1+x3])

Measured memory_bytes: 32360
package main

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

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	N := nextInt()
	key := make([]int, N)
	An := make(map[int]int)
	var ans int
	for i := range key {
		key[i] = nextInt()
	}
	for i := 0; i < N; i++ {
		for j := 1; j*key[i] <= int(1e6); j++ {
			if An[key[i]] >= 2 {
				break
			}
			An[j*key[i]]++
		}
	}
	for i := 0; i < N; i++ {
		if An[key[i]] == 1 {
			ans++
		}
		// ok := true
		// for j := 1; j*j <= key[i]; j++ {
		// 	if An[key[i]]-1 > 0 {
		// 		ok = false
		// 		break
		// 	}
		// 	if key[i]%j == 0 {
		// 		if j == 1 {
		// 			if _, e := An[j]; !e {
		// 				continue
		// 			}
		// 		}
		// 		if _, e := An[j]; e {
		// 			ok = false
		// 			break
		// 		}
		// 		if _, e := An[key[i]/j]; e {
		// 			ok = false
		// 			break
		// 		}
		// 	}
		// }
		// if ok {
		// 	ans++
		// }
		// // fmt.Println("count", ans)
	}
	// fmt.Println(An, key)
	fmt.Println(ans)
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

func pow(p, q int) int {
	res := p
	if q == 0 {
		return 1
	}
	for i := 0; i < q-1; i++ {
		res *= p
	}
	return res
}

func MinOf(vars ...int) int {
	min := vars[0]
	for _, i := range vars {
		if min > i {
			min = i
		}
	}
	return min
}

func MaxOf(vars ...int) int {
	max := vars[0]
	for _, i := range vars {
		if max < i {
			max = i
		}
	}
	return max
}

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

func lcmof2numbers(a int, b int) int {
	return a / gcdof2numbers(a, b) * b
}

// マイナスの場合は考慮していない
func fuctorial(a int) int {
	if a == 1 || a == 0 {
		return 1
	} else {
		return fuctorial(a-1) * a
	}
}

func NextPermutation(x sort.Interface) bool {
	n := x.Len() - 1
	if n < 1 {
		return false
	}
	j := n - 1
	for ; !x.Less(j, j+1); j-- {
		if j == 0 {
			return false
		}
	}
	l := n
	for !x.Less(j, l) {
		l--
	}
	x.Swap(j, l)
	for k, l := j+1, n; k < l; {
		x.Swap(k, l)
		k++
		l--
	}
	return true
}

// 素因数分解したmapを返す
func primeFuctorize(n int) map[int]int {
	pf := map[int]int{}
	for i := 2; i*i <= n; i++ {
		for n%i == 0 {
			pf[i]++
			n /= i
		}
	}
	if n != 1 {
		pf[n]++
	}
	return pf
}


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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)

typedef long long ll;
typedef pair<double,ll> P;

int used[111111];
int mp[111111];
ll dp[222222];
vector<vector<double>> je(111111);

int main(){
	
	REP(i,222222)dp[i] = -1;
	
	ll n,k;cin >> n >> k;
	REP(i,n){
		ll a,b;cin >> a >> b;
		je[a].PB(b);
	}
	
	vector<P> v;
	vector<P> tri;
	REP(i,111111){
		if(je[i].size() == 0)continue;
		sort(ALL(je[i]),greater<double>());
		v.EB((je[i][0] + je[i][1]) / 2.,i);
		v.EB((je[i][0] + je[i][1]) / 2.,i);
		for(int j = 2;j < je[i].size();j++){
			v.EB(je[i][j], i);
		}
		if(je[i].size() >= 3){
			tri.EB(je[i][0] + je[i][1] + je[i][2],i);
		}
	}
	
	
	sort(ALL(v),greater<P>());
	sort(ALL(tri),greater<P>());
	
	//REP(i,n)cout << "v " << v[i].FI << " " << v[i].SE << endl;
	
	vector<double> A;//二個まで
	vector<double> B;//それ以降
	double score = 0;
	int pla = 0;
	priority_queue<P> pq;
	if(tri.size())dp[3] = tri[0].FI;
	REP(i,v.size()){
		double now = v[i].FI;
		int id = v[i].SE;
		if(used[id] <= 1){
			A.PB(now);
		}
		else {
			B.PB(now);
		}
		used[id]++;
		
		if(used[id] == 2){
			//cout << "id is 2 :" << je[id].size() << endl;
			for(int j = 2;j < je[id].size();j++){
				pq.push(MP(je[id][j],id));
			}
			mp[id] = 2;
		}
		score += now;
		
		while(pla < tri.size() && used[tri[pla].SE] > 0)pla++;
		while(!pq.empty() && mp[pq.top().SE] < used[pq.top().SE]){
			mp[pq.top().SE]++;
			pq.pop();
		}
		
		if(used[id] == 1){
			if(B.size()){
			//	cout << "mel " << (ll)(score + v[i+1].FI - B.back()) << endl;
				dp[i + 1] = max(dp[i + 1], (ll)(score + v[i+1].FI - B.back()));
			}
		}
		else {
			dp[i + 1] = max(dp[i + 1], (ll)(score));
			if(pla < tri.size()){
				//cout << "!!!!!! " << (ll)(score + tri[pla].FI) << endl;
				dp[i + 4] = max(dp[i + 4], (ll)(score + tri[pla].FI));
			}
			if(!pq.empty()){
				//cout << "!!!! " << (ll)(score + pq.top().FI) << endl;
				dp[i + 2] = max(dp[i + 2], (ll)(score + pq.top().FI));
			}
			if(pla < tri.size() && !pq.empty()){
				//cout << "!!" << (ll)(score + pq.top().FI + tri[pla].FI) << endl;
				dp[i + 5] = max(dp[i + 5], (ll)(score + pq.top().FI + tri[pla].FI));
			}
		}
		//cout << "i " << i << " vFI " << v[i].FI << " vSE " << v[i].SE << " score " << score << " B " << B.size() << " pq " << pq.size() << endl;
		
	}
	
	REP(i,n)cout << dp[i+1] << endl;
	
	return 0;
}


Measured memory_bytes: 21484
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	string a;
	int b;
	cin>>a;
	for(int i=0;i<a.size();i++)
	{
		if(a[i]=='C')
		{
			b=i;
			break;
		}
	}
	for(int i=b+1;i<a.size();i++) 
	{
		if(a[i]=='F')
		{
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

int N,K;
int l[55];

int main() {
        cin >> N >> K;
        for (int i=0; i<N; i++)
                cin >> l[i];
        sort(l,l+N);
        int ret=0;
        for (int i=N-1; i>=N-K; i--)
                ret += l[i];
        cout << ret << "\n";
}

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

using namespace std;

using ll = long long;

int main(){
    string s;
    cin >> s;
    ll k; cin >> k;
    if(s[0] != '1'){
        cout << s[0];
    }else{
        ll cnt = 0;
        while(s[cnt] == '1')cnt++;
        if(cnt >= k)cout << 1;
        else cout << s[cnt];
    }
    return 0;
}


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

int main(){
    int m, d;
    cin >> m >> d;
    int ans = 0;
    for (int i = 1; i <= m; i++){
        for (int j = 1; j <= d; j++){
            if (j < 10) continue;
            if (j % 10 < 2 || j / 10 < 2) continue;
            if ((j % 10) * (j / 10) == i) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
var n,ans:int64;
var s:ansistring;
var i,j:longint;
begin
  readln(s);
  ans:=((length(s)-1)*9)+ord(s[1])-48;
  for i:=2 to length(s) do if s[i]<>'9' then j:=1;
  if j=1 then dec(ans);
  writeln(ans);
end.

Measured memory_bytes: 128