akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;

typedef pair<int, int> P;
int n, l;

void move_right(vector<int> &tunnel) {
    for (int i = l; i >= 1; --i) {
        if (tunnel[i] != -1) {
            tunnel[i+1] = tunnel[i];
            tunnel[i] = -1;
        }
    }
}

void move_left(vector<int> &tunnel) {
    for (int i = 1; i < l; ++i) {
        if (tunnel[i] != -1) {
            tunnel[i-1] = tunnel[i];
            tunnel[i] = -1;
        }
    }
}

void check_turn(vector<int> &rt, vector<int> &lt) {
    for (int i = 1; i < l; ++i) {
        if (rt[i] != -1 && lt[i] != -1) {
            swap(rt[i], lt[i]);
        }
    }
}

void check_end(vector<int> &rt, vector<int> &lt, vector<P> &leaved, int cnt) {
    if (rt[l] != -1) {
        leaved.push_back({cnt, rt[l]});
        rt[l] = -1;
    }

    if (lt[0] != -1) {
        leaved.push_back({cnt, lt[0]});
        lt[0] = -1;
    }
}

int main(int argc, char const *argv[]) {
    while (cin >> n >> l, n) {
        vector<char> d(n);
        vector<int> p(n), rtunnel(l+1, -1), ltunnel(l+1, -1);
        // 出たかどうか
        vector<P> leaved;
        
        // input
        REP(i,n) {
            cin >> d[i] >> p[i];
            if (d[i] == 'R') rtunnel[p[i]] = i;
            else ltunnel[p[i]] = i;
        }

        int cnt = 1;
        while (leaved.size() < n) {
            move_right(rtunnel);
            move_left(ltunnel);
            check_turn(rtunnel, ltunnel);
            check_end(rtunnel, ltunnel, leaved, cnt);
            ++cnt;
        }
        
        P last = leaved.back();

        cout << last.first << " " << last.second+1 << endl;

    }
    
    return 0;
}


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

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

int main() {
	int q;
	long long n,i,k,j,sum=0,count=0,ans=0,m,a,b;
	cin>>n>>a>>b;
	k=abs(a-b);
	if(k%2==0)
	{
	    cout<<k/2;
	}
	else
	{
	  
	    ans=a-1+k/2+1;
	    ans=min(ans,n-b+k/2+1);
	   cout<<ans;
	    
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool flag = true;
int n,m,b,c;
struct num{
    int a,b;
}x[50];
int main()
{
    cin>>n>>m;
    while(m--)
    {
        cin>>b>>c;
        if(x[b].b!=0&&x[b].a!=c)
            flag=false;
        else
        {
            x[b].a=c;
            x[b].b=1;
        }
    }
    if(flag==false||(x[1].b==1&&x[1].a==0&&n>1))
    {
        cout<<-1;
    }
    else if(n>1)
    {
        if(x[1].a==0)
            cout<<1;
        else
            cout<<x[1].a;
        for(int i=2;i<=n;i++)
            cout<<x[i].a;
    }
    else
        cout<<x[1].a;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    int K, S;
    cin >> K >> S;
    int ans = 0;
    rep(i, K+1) rep(j, K+1){
        int res = S-i-j;
        if(res >= 0 && res <= K) ans++;
    }
    cout << ans << endl;
}

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

int main() {
    int a, b;
    cin >> a >> b;
    int mini = min(a, b), maxi = max(a, b);
    rep(i, maxi) {
        cout << mini;
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int a,b,c;
    cin >> a >> b >> c;

    if(a <= c && c <= b){
        cout << "Yes" << endl;
    }
    else if(b <= c && c <= a){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int x[100] = {};

int main()
{
	int n, k;
	int ans = 0;
	scanf("%d %d", &n, &k);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &x[i]);
	}
	for (int i = 0; i < n; i++)
	{
		if (x[i] < k - x[i])
		{
			ans = ans + (x[i] * 2);
		}
		else
		{
			ans = ans + ((k - x[i]) * 2);
		}
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstddef>
#include<queue>
#include<math.h>
#include<iomanip>
using namespace std;

int main()
{
    int N, K, d = 0, a = 0, ans = 0;
    cin >> N >> K;
    vector<int> S(N);
    for(int i = 0; i < K; ++i){
        cin >> d;
        for(int j = 0; j < d; ++j){
            cin >> a;
            S.at(a - 1)++;
        }
    }
    for(int i = 0; i < N; ++i){
        if(S.at(i) == 0) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3624
def main():
    import sys
    input = sys.stdin.readline
    N = int(input())
    A = [0]*N
    r = 0
    for i in range(N):
        a = int(input())
        A[i] = (a, i)
    A.sort()
    cnt = 0
    for i in range(0, N, 2):
        a, j = A[i]
        cnt += j & 1
    print(cnt)

main()


Measured memory_bytes: 16944
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define AB_BHI_NI_DEGI                \
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL);                    \
	cout.tie(NULL);
#define int long long
#define pb push_back
#define N 100009
#define inf 1e18
const double PI = 3.141592653589793238462643383279;
//int mod = 1e9 + 7;
int mod = 998244353;
#define P pair<int, int>
#define F first
#define S second
#define ll long long
#define all(v) v.begin(), v.end()
#define vi vector<int>
#define ld long double

#define ordered_set tree<P, null_type, less<P>, rb_tree_tag, tree_order_statistics_node_update>

int32_t main()
{
	AB_BHI_NI_DEGI
	int a;
	cin >> a;
	cout<<a+(a*a)+(a*a*a)<<"\n";

	return 0;
}

Measured memory_bytes: 3644
#define _CRT_SECURE_NO_WARNINGS 1

#include <iostream>
#include <string>
#include <string.h>
#include <limits>
#include <utility>
#include <vector>
#include <algorithm>
#include <functional>
#include <stack>
#include <unordered_set>
#include <unordered_map>
#include <chrono>

using namespace std;

namespace
{
	int n, m;

	struct City
	{
		int pNumber;
		int year;
		int order;

	};

	bool compare(const City* l, const City* r)
	{
		return l->year < r->year;
	}

	vector<City*> cs;

	std::vector<vector<City*>> ps;
}

#if 1
int main()
{
	cin >> n;
	cin >> m;

	ps.resize(n + 1);
	for (int i = 0; i < m; i++)
	{
		City* pC = new City();

		cin >> pC->pNumber;
		cin >> pC->year;

		cs.push_back(pC);
		ps[pC->pNumber].push_back(pC);
	}

	for (int i = 0; i <= n; i++)
	{
		std::sort(ps[i].begin(), ps[i].end(), compare);

		for (int j = 0; j < ps[i].size(); j++)
		{
			ps[i][j]->order = j + 1;
		}
	}

	for (int i = 0; i < cs.size(); i++)
	{
		printf("%06d%06d\n", cs[i]->pNumber, cs[i]->order);
	}
}
#endif


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

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

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

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

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

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

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

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

use std::collections::HashMap;

fn main() {
    input!{
        n: usize,
        v: [usize; n]
    }
    let mut w = v;
    w.sort_by(|a, b| b.cmp(&a));
    let mut map = HashMap::new();
    for i in 0..n {
        let x = map.entry(w[i]).or_insert(0);
        *x += 1;
    }
    let mut p = 1 << 31;
    let mut ans = 0;
    for i in 0..n {
        {
            let x = map.get_mut(&w[i]).unwrap();
            if *x == 0 {
                continue;
            } else {
                *x -= 1;
            }
        }

        while p >> 1 > w[i] {
            p >>= 1;
        }
        if let Some(y) = map.get_mut(&(p - w[i])) {
            if *y > 0 {
                ans += 1;
                *y -= 1;
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 15476
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
 
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define CLR(a) memset((a), 0 ,sizeof(a))
#define MCLR(a) memset((a), -1 ,sizeof(a))
#define SZ(a) (sizeof(a))
#define FILL(a,v) fill((int*)a,(int*)(a+(SZ(a)/SZ(*(a)))),v)
#define dump(x)  cerr << #x << " = " << (x) << endl

bool cheak(int x,int y,int xMax,int yMax)
{return x >= 0 && y >= 0 && xMax > x && yMax > y;}
const int dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
const int INF = 2147483647;
typedef pair<int,int> P;
typedef long long ll;
typedef unsigned long long ull;

//???????????¢?´¢
struct Bfs
{
	set<string> memo;
	set<string> memo2;
	int search(string s)
	{
		queue<string> que;
		queue<int>    time;
		que.push(s);
		time.push(0);
		memo.insert(s);
		memo2.insert(s);
		while(que.size())
		{
			string now = que.front();que.pop();
			int anstime = time.front();time.pop();
			//??????
			
			bool end = true;
			REP(i,now.size()-1)
			if(now[i] != now[i+1])
			end = false;
			if(end)return anstime; 
			//

			REP(i,now.size()-1)
			{
				string ts = now;
				char c0 = now[i];
				char c1 = now[i+1];
				char sc;
				if(c0 != c1)
				{
					if(c0 != 'b' && c1 != 'b')
						sc = 'b';
					if(c0 != 'r' && c1 != 'r')
						sc = 'r';
					if(c0 != 'g' && c1 != 'g')
						sc = 'g';
					
					ts[i] = sc;ts[i+1] = sc;
					if(!memo2.count(ts))
					{
						if(memo.count(ts))
							memo2.insert(ts);
						memo.insert(ts);
						que.push(ts);
						time.push(1+anstime);
					}
				}
			}
		}
		return -1;
	}
};

int main()
{
	string str;
	while(cin >> str && str != "0")
	{
		Bfs bfs;
		int ans = bfs.search(str);
		if(ans == -1)
			cout << "NA" << endl;
		else
			cout <<  ans << endl;
	}
	return 0;
}


//????¬????????????????????????¨?????????
/*
	REP(i,mx)
	{
		REP(j,my)
		cout << n[i][j];
		cout << endl;
	}
	cout << endl;
*/

Measured memory_bytes: 4092
N,M = map(int,input().split())
ps = [input().split() for i in range(M)]
from collections import defaultdict
acs = set()
penas = defaultdict(lambda: 0)
for p,s in ps:
    if p in acs: continue
    if s=='AC':
        acs.add(p)
    else:
        penas[p] += 1

pena = 0
for p in acs:
    pena += penas[p]
print(len(acs), pena)

Measured memory_bytes: 48920
#標準入力
ha,hb = map(int,input().split())
ka,kb = map(int,input().split())
a,b,c,d = map(int,input().split())
ht,kt = 0,0

#得点の計算
ht = ha * a + hb * b + (ha // 10) * c + (hb // 20) * d
kt = ka * a + kb * b + (ka // 10) * c + (kb // 20) * d

#得点が大きいほう、または引き分けを出力する
if ht > kt:print("hiroshi")
elif ht < kt:print("kenjiro")
elif ht == kt:print("even")


Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define ll long long
#define ull unsigned long long
#define ld long double
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rrep(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define pll pair<long long,long long>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vvc vector<vector<char>>
#define vc vector<char>
#define vvb vector<vector<bool>>
#define vb vector<bool>
#define maxe(x) *max_element(all(x))
#define mine(x) *min_element(all(x))
#define Size(x) ((int)(x).size())
#define umap unordered_map
const long long INF = 1LL << 60;
const long double pi = 3.1415926535897932;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

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

//lis,modpow,uf,modncr,soinsubunkai,yakusurekkyo,gyakugen
//mint,dijkstra

    signed main(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        ll n,k;
        string s;
        cin>>n>>k>>s;
        ll res=0;
        rep(i,n){
            if(i>0)if(s[i]=='L'&&s[i-1]=='L'){
                res++;
            }
            if(i<n-1)if(s[i]=='R'&&s[i+1]=='R'){
                res++;
            }
        }
        res+=k*2;
        ll ans=min(res,n-1);
        cout<<ans<<endl;
    }

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int k, n;
  cin >> k >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++)
  {
    cin >> a[i];
  }
  vector<int> ans(n);
  for(int i = 1; i < n; i++)
  {
    ans[i] = a[i] - a[i - 1];
  }
  ans[0] = a[0] + k - a[n - 1];
  int mm = 0;
  for(int i = 0; i < n; i++)
  {
    mm = max(mm, ans[i]);
  }
  cout << k - mm << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}





int main() {
	ll N;
	cin >> N;
	vector<ll> L(2*N);
	rep(i, 2 * N) {
		cin >> L.at(i);
	}
	sort(L.begin(), L.end());
	ll an = 0;
	rep(i, N) {
		an += L.at(2 * i);
	}
	cout << an << endl;
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
int main()
{
    int a,b,n,k,x,y,i,j;
char  s[4];
    scanf("%s",s);
    for(i=0;i<3;i++){
        if(s[i]=='1'){
            s[i]='9';
        }else if(
            s[i]=='9'){
                s[i]='1';
            }
    }
    printf("%s",s);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
typedef long long ll;
int main()
{
	char n1,n2,n3,n4;
	cin >> n1 >> n2 >> n3 >> n4;

	if(n1==n2 || n2==n3 || n3==n4) cout << "Bad" << endl;
	else cout << "Good" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int n, a1, a2, b1, b2, a, b, ans;
  scanf("%d %d %d %d %d", &n, &a1, &b1, &a2, &b2);

  a = a1/a2;
  if(a1%a2 != 0) a++;
  b = b1/b2;
  if(b1%b2 != 0) b++;

  if(a >= b) ans =  n - a;
  else ans = n - b;

  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 596
N, W = map(int, input().split())
W_V = [list(map(int, input().split())) for _ in range(N)]

dp = [[0] * (W+1) for _ in range(N+1)]

for n in range(1, N+1):
  for w in range(W+1):
    dp[n][w] = dp[n-1][w]
    if(w - W_V[n-1][0] >= 0):
      dp[n][w] = max(dp[n][w], dp[n-1][w - W_V[n-1][0]] + W_V[n-1][1])

print(dp[-1][-1])


Measured memory_bytes: 150384
a, b, k = map(int,input().split())
#print(a)
#print(b)
#print(k)
if a-k == 0:
    print(0, b)
elif a-k >= 0:
    print(a-k, b)
else:
    if b+(a-k) >= 0:
        print(0, b+(a-k))
    else:
        print(0,0)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>

using namespace std;

int calc_num(int x){
    int res=0;
    while(x%100 == 0){
        x /= 100;
        res++;
    }
    return res;
}

int main(){

    int d, n; 
    cin >> d >> n;
    int result = 0;
    int val = 0;
    while(result < n){
        val++;
        if(calc_num(val) == d) ++result;
    }

    cout << val << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;

void solve()
{
    int n;
    scanf("%d", &n);
    vector<int> a(n);
    vector<ll> s(n + 1);
    int i;
    for (i = 0; i < n; i++) {
        scanf("%d", &a[i]);
        s[i + 1] = s[i] + a[i];
    }
    ll ans = LINF;
    for (i = 1; i < n; i++) {
        ans=MIN(ans, abs(s[n] - s[i]*2));
    }
    printf("%lld\n", ans);
    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d%d", &T, &B);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}



Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

void qsort(int a[],int left,int right){
   int mid = (left+right)/2;
   int pivot = a[mid];
   int x=left,y=right;
   while(x<y){
      while(a[x] < pivot) x++;
      while(a[y] > pivot) y--;
      if(x<=y){
         swap(a[x],a[y]);
         x++,y--;
      }
   }
   if(right-left > 1){
      qsort(a,left,y);
      qsort(a,x,right);
   }
  

}
int main(){
   int n,k;
   cin >> n >> k;
   int a[n];
   long long sum=0;
   for(int i=0;i<n;i++){
      cin >> a[i];
      sum += a[i];
   }
   qsort(a,0,n-1);
   
   if(n <=k){
      cout << 0 << endl;
      return 0;
   }
   long long attack = 0;
   for(int i=n-1;i >= n-k;i--){
     attack += a[i];
   }
   
   cout << sum-attack<<endl;
   return 0;
}



Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
using namespace std;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define rep(i,n) for(long long i=0;i<n;i++)
#define rp(i,n) for(long long i=1;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define V vector
long long p = 1000000007;
vel rui(19, 1);
vel par;
int root(int ser) {
	if (par[ser] == -1) { return ser; }
	int ans = root(par[ser]);
	par[ser] = ans;
	return ans;
}
bool marge(pin a) {
	int x = root(a.first);
	int y = root(a.second);
	if (x != y) {par[x] = y;}
	return x != y;
}
int gcd(int a, int b) {
	if (a < b) { swap(a, b); }
	if (b == 0) { return a; }
	return gcd(b, a%b);
}
signed main() {
	int t; cin >> t;
	V<string> s(t);
	rep(i, t) {
		int a, b, c, d; cin >> a >> b >> c >> d;
		if (d >= b && a >= b) {
			if (c >= b) { s[i]="Yes"; }
			else {
				int x = a % b;
				int gc = gcd(b, d);
				int pl = (b - 1 - x) / gc;
				x += pl * gc;
				if (x > c) { s[i]="No"; }
				else {s[i]="Yes"; }
			}
		}
		else { s[i]="No"; }
	}
	rep(i, t) { cout << s[i] << endl; }
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
  int m[] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6};
  int N, M, A[9];
  cin >> N >> M;
  for (int i = 0;i < M;++ i) cin >> A[i];
  sort(A, A+M);
  int dp[N + 1];
  for (int i = 1;i <= N;++ i) dp[i] = -1e9;
  dp[0] = 0;
  for (int i = 1;i <= N;++ i) for (int j = 0;j < M;++ j) if(i >= m[A[j]]) dp[i] = max(dp[i], dp[i - m[A[j]]] + 1);
  for (int i = N, j = M - 1;dp[i];i -= m[A[j]]) {
    while(i < m[A[j]] || dp[i - m[A[j]]] + 1 != dp[i]) -- j;
    cout << A[j];
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x,y,z,ans=0;
  cin>>z;
  for(x=0;x<z;x++){
    cin>>y;
    while(y%2==0){
      ans++;
      y/=2;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3648
//Har Har Mahadev
using namespace std;
#include <bits/stdc++.h>
#define booga cout << "booga" << endl
#define ll long long int
#define pb push_back
#define mp make_pair
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " -> " << a << endl;
	err(++it, args...);
}

void testcase(){
	int n,x,t;
	cin >> n >> x >> t;
	cout << t*((n+x-1) / x);
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t = 1;
	while(t--){
		testcase();
	}
	return 0;
}


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

string s;
int n;

int main() {
  cin >> s;
  n = s.size();
  for(int i = 1; i < n; ++i) {
    int x = (n - i) / 2;
    if((n - i) % 2 == 1) continue;
    for(int j = 0; j < x; ++j) {
      if(s[j] != s[j + x]) break;
      if(j == x - 1) {
        cout << n - i << endl;
        return 0;
      }
    }
  }
  return 0;
}

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

ans = 0
tmp = [0 for _ in range(10)]
for i in range(len(S)):
    tmp[int(S[i])] += 1

for i in range(1000):
    flag = True

    if i < 10:
        dic = {"0": 2}
    elif i < 100:
        dic = {"0": 1}
    else:
        dic = {}
    for j in range(len(str(i))):
        if str(i)[j] in dic:
            dic[str(i)[j]] += 1
        else:
            dic[str(i)[j]] = 1

    for k, v in dic.items():
        if dic[k] > tmp[int(k)]:
            flag = False
            break

    if flag:
        if i < 10:
            tmp_i = "00" + str(i)
        elif i < 100:
            tmp_i = "0" + str(i)
        else:
            tmp_i = str(i)
        t = 0
        for j in range(len(S)):
            if tmp_i[t] == S[j]:
                t += 1
            if t == 3:
                ans += 1
                break

print(ans)



Measured memory_bytes: 74176
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O0")
typedef long long int ll;
typedef long double ld;
const ll mod = 1e9+7;
const ll INF = 1e18;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define Rep(i,a,n) for (ll i = (a); i < (n); ++i)
#define All(a) (a).begin(),(a).end()
#define Pi acos(-1)
using Graph = vector<vector<ll>>;
using V = vector<ll>;
using P = pair<ll,ll>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  chrono::system_clock::time_point start,end;
  start = chrono::system_clock::now();

  ll n;
  cin >> n;
  ll ans = 0;
  for (ll a = 1; a <= 1000000; ++a) {
    for (ll b = 1; a*b <= 1000000; ++b) {
      if (n - a*b > 0) ++ans;
    }
  }
  cout << ans << '\n';

  end = chrono::system_clock::now();
  auto elapsed = chrono::duration_cast< chrono::milliseconds >(end - start).count();
  cerr << elapsed << "ms" << '\n';
}

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

int hoge(int x, int y)
{
    if (y > x)
    {
        int t = x;
        x = y;
        y = t;
    }
    if(x%y==0)
        return y;
    else
        hoge(y, x%y);
}
int main(void)
{
    int x,y;
    cin >> x >> y;
    cout << hoge(x,y) << "\n";
}



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

int main(){
    string s, t, u;
    int a, b;
    cin >> s >> t;
    cin >> a >> b;
    cin >> u;
    if (u == s){
        cout << a-1 << ' ' << b << endl;
    }else{
        cout << a << ' ' << b-1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define M 1000000007
#define all(a) (a).begin(),(a).end()
#define rep(i,n) reps(i,0,n)
#define reps(i,m,n) for(int i=(m);i<(n);i++)
int main(){
  int n;cin>>n;
  reps(i,1,n+1){
    if((int)((double)i*1.08)==n){
      cout<<i;return 0;
    }
  }
  cout<<":(";
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <map>
#include <queue>
#include <algorithm>
using namespace std;

typedef pair<int, int> Pi;
typedef pair<Pi, int> Pii;

int w, h;
int ver[64][64], hor[64][64];

int bfs() {
  int dx[] = {1, -1, 0, 0};
  int dy[] = {0, 0, 1, -1};
  bool used[64][64];
  queue<Pii> que;
  que.push(make_pair(make_pair(0, 0), 1)); // ((x, y), step)
  memset(used, false, sizeof(used));

  while (que.size()) {
    Pii p = que.front(); que.pop();
    int x = p.first.first, y = p.first.second, step = p.second;
    if (x == w-1 && y == h-1)
      return step;
    for (int i = 0; i < 4; i++) {
      int nx = x + dx[i], ny = y + dy[i];
      if (nx < 0 || ny < 0 || nx >= w || ny >= h)
        continue;
      if (x != nx && ver[y][min(x, nx)] == 1)
        continue;
      if (y != ny && hor[min(y, ny)][x] == 1)
        continue;
      if (used[ny][nx])
        continue;
      used[ny][nx] = true;
      que.push(make_pair(make_pair(nx, ny), step+1));
    }
  }

  return 0;
}

int main(void) {
  for ( ; ; ) {
    scanf("%d %d", &w, &h);
    if (w + h == 0)
      break;
    for (int i = 0; i < h-1; i++) {
      for (int j = 0; j < w-1; j++)
        scanf("%d", ver[i]+j);
      for (int j = 0; j < w; j++)
        scanf("%d", hor[i]+j);
    }
    for (int j = 0; j < w-1; j++)
      scanf("%d", ver[h-1]+j);

    printf("%d\n", bfs());
  }
}


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

int main(int argc, const char * argv[]) {
    
    int a,b,c,x;
    int counter=0;
    
    cin >> a;
    cin >> b;
    cin >> c;
    cin >> x;
    
    for(int i=0;i<=a;i++){
        for(int j=0;j<=b;j++){
            for(int k=0;k<=c;k++){
                if(500*i+100*j+50*k==x){
                    counter++;
                }
            }
        }
    }
    
    cout << counter << endl;
    
    return 0;
}


Measured memory_bytes: 256
(* O(min {a, b}) *)
let solve a b k =
  let rec find acc n =
    if acc >= k then
      n + 1
    else
      find (if a mod n = 0 && b mod n = 0 then acc + 1 else acc) (n - 1)
  in
    find 0 (min a b)

let _ = Scanf.scanf "%d %d %d" (fun a b k -> solve a b k) |> string_of_int |> print_endline

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N = 2e5 + 10;

signed main() {
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n , m ;cin >> n >> m;
	if(n <= 9 && n >= 1 &&  m<= 9 && m >= 1) cout << n*m;
	else cout << -1;
}
		


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
    int n, k; cin >> n >> k;
    vector<int> h(n);
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }
    
   
    vector<int> dp(n, INT_MAX);
  
   
    dp[0] = 0;
  
    dp[1] = abs(h[1] - h[0]);
    
    
    for(int i = 2; i < n; i++){
      for(int j = i - 1, jump = 0; j  >= 0 && jump < k; j--, jump++){
        dp[i] = min(dp[i], dp[j] + abs(h[j] - h[i]));
      }
    }
   
    cout << dp[n - 1];
    return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
int main(void){
  long long y, m, d;
  int b, ka, t, w, ki;
  unsigned long long _ka, _t, _w, _ki;
  int day[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  unsigned long long s;
  char str[256], *s2;

  _ki = 20; _w = _ki * 18; _t = _w * 20; _ka = _t * 20;
  for( ; ; ){
    scanf("%s", str);
    if(str[0] == '#') break;
    s2 = str;
    for(int i = 0;i < 2; i++){
      s2 = strchr(s2, '.') + 1;
    }
    s = 0;
    if(strchr(s2, '.') == NULL){
      sscanf(str, "%lld.%lld.%lld", &y, &m, &d);
      for(int i = 2012;i < y; i++){
	if(i == 2012) s += 10;
	else s += 365;
	if(i != 2012 && !(i % 4) && i % 100 || !(i % 400)) s++;
      }
      if(y != 2012){
	for(int i = 1;i < m; i++){
	  s += day[i];
	  if(i == 2 && !(y % 4) && y % 100 || i == 2 && !(y % 400)) s++;
	}
	s += d;
      } else
	s += d - 21;

      s = s % (_ka * 13);
      printf("%llu.%llu.%llu.%llu.%llu\n", s / _ka, s / _t % 20, s / _w % 20, s / _ki % 18, s % _ki);
    } else {
      sscanf(str, "%d.%d.%d.%d.%d", &b, &ka, &t, &w, &ki);
      s = ki + w * _ki + t * _w + ka * _t + b * _ka;
      if(s <= 10){
	printf("2012.12.%llu\n", 21 + s);
	continue;
      }
      s -= 10;
      for(y = 2013; ; y++){
	if(!(y % 4) && y % 100 || !(y % 400)){
	  if(s > 366) s -= 366;
	  else break;
	} else {
	  if(s > 365) s -= 365;
	  else break;
	}
      }
      for(m = 1; ; m++){
	if(!(y % 4) && y % 100 && s > 29 && m == 2 || !(y % 400) && s > 29 && m == 2){
	  s -= 29; continue;
	}
	else if(!(y % 4) && y % 100 && s >= 29 && m == 2 || !(y % 400) && s >= 29 && m == 2) break;
	else if(s > day[m]) s -= day[m];
	else break;
      }
      
      printf("%lld.%lld.%llu\n", y, m, s);
    }
  }
}


Measured memory_bytes: 1044
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class CCitySavers {
public:
    static constexpr int kStressIterations = 0;

    static void generateTest(std::ostream& test) {
    }

    void solve(std::istream& cin, std::ostream& cout) {
        int N;
        cin >> N;
        vector<int> A(N + 1), B(N);
        REP(i, N + 1) {
            cin >> A[i];
        }
        REP(i, N) {
            cin >> B[i];
        }

        int res = 0;
        REP(i, N) {
            int v = min(A[i], B[i]);
            res += v;
            B[i] -= v;
            if (B[i] > 0) {
                int vv = min(A[i + 1], B[i]);
                A[i + 1] -= vv;
                res += vv;
            }
        }
        cout << res << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    CCitySavers solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int A[N],n,cnt,q,mx,mn,x,y,z;
bool prime(int l){
    if(l<=1) return 0;
    for(int i=2;i<=l/i;++i)
        if(l%i==0) return 0;
    return 1;
}
int main(){
    for(int i=1;i<N;++i){
     A[i]=(prime(i)&&prime((i+1)/2));
     A[i]+=A[i-1];
    }
    //for(int i=0;i<55;++i)
      //  cout<<i<<":"<<A[i]<<endl;
    scanf("%d",&q);
    while(q--){
        scanf("%d %d",&x,&y);
        printf("%d\n",A[y]-A[x-1]);
    }
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
using namespace std;

struct taxi{
    int C,R;
    taxi(){}
    taxi(int _C,int _R){
        C=_C; R=_R;
    }
};
struct data{
    int cost,n,r;
    data(){}
    data(int _cost,int _n,int _r){
        cost=_cost; n=_n; r=_r;
    }
    bool operator<(const data &a)const{
        return cost>a.cost;
    }
};
bool memo[5001][5001]={};

int main(){
    int N,K,A,B;
    taxi tx[5001];
    vector<int> way[5001];
    cin>>N>>K;
    for(int i=1;i<=N;i++){
        cin>>tx[i].C>>tx[i].R;
    }
    for(int i=0;i<K;i++){
        cin>>A>>B;
        way[A].push_back(B); way[B].push_back(A);
    }

    priority_queue<data> q;
    data q_c;
    q.push(data(0,1,0));
    while(!q.empty()){
        q_c = q.top(); q.pop();
        if(q_c.n==N){
            printf("%d\n",q_c.cost); return 0;
        }
        if(memo[q_c.n][q_c.r]) continue;
        memo[q_c.n][q_c.r]=true;
        for(int i=0;i<way[q_c.n].size();i++){
            if(q_c.r!=0)
                q.push(data(q_c.cost,way[q_c.n][i],q_c.r-1));
            q.push(data(q_c.cost+tx[q_c.n].C,way[q_c.n][i],tx[q_c.n].R-1));
        }
    }
    return 0;
}

Measured memory_bytes: 25612
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define Cout(s) cout << s << endl;
typedef long long ll;
typedef pair<int, int> P;

const ll INF = 1ll << 60;
ll MOD = 1e9 + 7;

int main()
{

    int a, b;
    cin >> a >> b;
    int ans = 0;
    if (a >= 6 && a <= 12)
    {
        ans = b / 2;
    }
    else if (a <= 5)
    {
        ans = 0;
    }
    else
    {
        ans = b;
    }
    Cout(ans);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repb(i, n) for(ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define reprb(i, a, b) for(ll i = (b)-1; i >= (a); i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
const ld EPS = 1e-12L;
const ld PI = 3.1415926535897932385L;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class S, class T>inline bool chmax(S &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class S, class T>inline bool chmin(S &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

void Pr(bool f){
    cout << (f ? "Yes" : "No") << endl;
    exit(0);
}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n;
    cin >> n;
    string s;
    cin >> s;
    if(n%2 != 0) Pr(0);
    ll m = n/2;
    bool f = 1;
    rep(i, m){
        if(s[i] != s[i+m]) f = 0;
    }
    Pr(f);
    return 0;
}

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

template <
    typename TYPE,
    std::size_t SIZE>
std::size_t a_len(const TYPE (&array)[SIZE])
{
    return SIZE;
}

using namespace std;
using ll = long long int;
using vi = vector<ll>;

#define REPS(a, i, n) for (ll(i) = a; (i) < (n); ++(i))
#define REP(i, n) REPS(0, i, n)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 912345678;

int a, b;

int main()
{
    cin >> a >> b;
    cout << max({a + b, a - b, a * b}) << endl;
}

Measured memory_bytes: 256
import heapq
S = []
Q = open(0).read().split()
i = 0
while True:
    it = Q[i]
    if it == 'end':
        break
    elif it == 'insert':
        num = int(Q[i + 1])
        heapq.heappush(S, -num)
        i += 2
    elif it == 'extract':
        ret = heapq.heappop(S)
        print(-ret)
        i += 1
    # print(S)


Measured memory_bytes: 289900
#include <iostream>

#include <vector>

#include <cassert>

#include <algorithm>

#include <functional>

#include <cmath>

#include <iomanip>

#include <limits>
#include <bits/stdc++.h>
#include<queue>
#include<type_traits>
#include<cstdint>
using namespace std;
using ll=long long;
int main(){
    
    while(1){
        int count=0;
    int n,m;
    cin >> n >> m;
    if(n==0){
        break;
    }
    vector<int> vec(n);
    for(int i=0;i<n;i++){
        int x;
        cin >> x;
        vec[i]=x;
    }
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(vec[i]+vec[j]<=m){
                count = max(count,vec[i]+vec[j]);
            }
        }
    }
    if(count==0){
        cout << "NONE"<<endl;
    }else{
    cout << count <<endl;
    }
    }
}


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

int sort(int, int);

int main(){
  int a,b,c, tmp;
  cin >> a >> b >> c;

  if(a>b){
    tmp = a;
    a = b;
    b = tmp;
  }
  if(b>c){
    tmp = b;
    b = c;
    c = tmp;
  }
  if(a>b){
    tmp = a;
    a = b;
    b = tmp;
  }  

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


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
int a[1000];
int f(int st, int end){
    int x=10000;
    // finding minimum
    for(int i=st;i<=end;i++){
        x=min(x,a[i]);
    }
    // storing places of min indices
    vector<int> v;
    for(int i=st;i<=end;i++){
        if(a[i]==x) v.push_back(i);
    }
    int s=0;
    int pre=st;
    int l=0;// l denotes no of subrangescalls
    // just calling on subranges having at least one element
    for(auto k : v){
        if(k-pre >= 1){
            s+=f(pre,k-1); l++;
        }
        pre=k+1;
    }
    // this is also last possible subrange according to this implementation
    if(end-v[v.size()-1] >= 1){
        s+=f(v[v.size()-1]+1,end); l++;
    }
    // final result
    return s-x*l+x;
}
int main() {
    /*
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int n; cin>>n;
    for(int i=0;i<n;i++) cin>>a[i];
    cout<<f(0,n-1);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll a,b,c,n,ans=0;
void Main(){
    ll x;cin>>x;
    ll dp[100010];
    For(i,0,100) dp[i]=0;
    For(i,100,106) dp[i]=1;
    For(i,107,100001){
        dp[i]=0;
        For(j,100,106){
            dp[i]+=dp[i-j];
        }
    }
    if(dp[x]) cout<<1<<endl;
    else cout<<0<<endl;
}
main(){
    Main();
}

Measured memory_bytes: 1024
#include<cstdio>

int main(){
    int n,a,b;
    scanf("%d",&n);
    scanf("%d",&a);
    int min = a;
    int max = a;
    long long sum = a;
    for(int i = 2; i <= n; i++){
        scanf("%d",&b);
        if(min >= b){
            min = b;
        }
        else{
            min = min;
        }
        if(max <= b){
            max = b;
        }
        else{
            max = max;
        }
        sum += b;
    }
    printf("%d %d %lld\n",min,max,sum);
    return 0;
}


Measured memory_bytes: 2756
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define f first
#define s second
#define lint long long
#define mp make_pair
#define pii pair<int, int>
#define pll pair<lint, lint>
#define ld long double
#define inlld(x) scanf("%lld", &x)
#define ind(x) scanf("%d", &x)
#define vi vector<int>

const int N=1e5+5;
const int MOD=1e9+7;
const lint INF=1e18;

typedef long long ll;

lint _add(lint x, lint y)
{
    lint ret=x+y;
    while(ret<0LL)
        ret+=MOD;
    return ret;
}

lint _mult(lint x, lint y)
{
    x%=MOD;
    y%=MOD;
    lint ret=x*y;
    ret%=MOD;
    while(ret<0LL)
        ret+=MOD;
    return ret;
}

using namespace std;
using namespace __gnu_pbds;

template <typename T> 
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int n, X, Y, Z, lol;
lint pow_10[N], dp[45][(2<<19)];

bool check(int mask)
{
    return ( (mask&(1<<Z)) && (mask&(1<<(Y+Z))) && (mask&(1<<(X+Y+Z))));
}

void pr(int x)
{
    for(int a=19; a>=0; a--)
        if((1<<a)&x)
            printf("1");
        else
            printf("0");
    printf("\n");
}

lint solve(int i, int mask)
{
    if(check(mask))
        return pow_10[n-i+1];
    if(i==n+1)
        return 0;
    if(dp[i][mask]!=-1)
        return dp[i][mask];
    lint ret=0;
    for(int a=1; a<=10; a++)
    {
        int here=(mask<<a);
        here+=(1<<a);
        here&=lol;
        // for(int b=18; b<=28; b++)
        //     if((1<<b)&here)
        //         here^=(1<<b);
        ret=(ret+solve(i+1, here))%MOD;
    }
    return dp[i][mask]=ret;
}

int main()
{
    for(int a=0; a<18; a++)
        lol+=(1<<a);
    pow_10[0]=1;
    for(int a=1; a<=40; a++)
        pow_10[a]=(pow_10[a-1]*10LL)%MOD;
    ind(n);ind(X);ind(Y);ind(Z);
    memset(dp, -1, sizeof(dp));
    printf("%lld\n", solve(1, 0));
    // printf("%lld\n", solve(1,0,0,0));
    return 0;
}

Measured memory_bytes: 369024
using System;

namespace ABC053B
{
    class Program
    {
        static void Main(string[] args)
        {
            string str;
            int cursor = 0;
            int res = 0;
            int score = 0;

            str = Console.ReadLine();

            while(cursor < str.Length)
            {
                if (score > 0)
                {
                    score++;
                }
                else if (str[cursor] == 'A')
                {
                    score = 1;
                }

                if(str[cursor] == 'Z')
                {
                    res = score;
                }

                cursor++;
            }

            Console.WriteLine(res);
        }
    }
}


Measured memory_bytes: 13144
#include<stdio.h>

int main()
{
    int i,j,temp,height[15];

    for(i=0;i<10;i++)
    {
        scanf("%d",&height[i]);
    }
    for(i=0;i<10;i++)
    {
        for(j=i+1;j<10;j++)
        {
            if(height[i]>height[j])
            {
                temp=height[j];
                height[j]=height[i];
                height[i]=temp;
            }
        }
    }
    for(i=9;i>6;i--)
    {
        printf("%d\n",height[i]);
    }
    return 0;
}

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

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

   int cnt[10][10] = {};
   for (int a=1; a<=N; a++) {
      ++cnt[to_string(a)[0] - '0'][a%10];
   }
   int ans = 0;

   for (int i=0; i<10; i++){
      for (int j=0; j<10; j++){
         ans += cnt[i][j] * cnt[j][i];
      }
   }
   cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;

#define INF 1e9
#define LLINF 1e18
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

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


int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(a * b, c * d) << endl;
}

Measured memory_bytes: 256
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]
ans = sum(b)
for i in range(n-1):
    if a[i]+1==a[i+1]: ans+=c[a[i]-1]
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;

int main(){

  int n, a, b;

  cin>>n>>a>>b;

  int ans=0;
  for(int i=1;i<=n;i++){
    int sum=0;
    string s=to_string(i);
    for(int j=0;j<s.size();j++) sum+=s[j]-'0';
    if(a<=sum&&sum<=b) ans+=i;
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
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 add = A+B;
    int sub = A-B;
    int mul = A*B;
    int answer=-1000000;
    answer = Math.max(Math.max(add,sub),mul);
    System.out.println(answer);
    
  }
  

  
}

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

int main()
{
    int A, B, K;
    cin >> K >> A >> B;
    int target = K;
    while (target <= 1000) {
        if (target >= A && target <= B) {
            cout << "OK" << endl;
            return 0;
        }
        target += K;
    }
    cout << "NG" << endl;
    return 0;
}

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

typedef long long ll;

struct Section {
    int contents;
    ll start,end;
    Section(int s,int e,int c) : start(s), end(e), contents(c) {;}

    ll size() { return end - start + 1; }
};

class Disk {
private:
    int _size;
    vector<Section> sv;

public:
    Disk () {
        sv.clear();
        sv.push_back(Section(0,1000000000ll,-1));
    }

    typedef vector<Section>::iterator itr;

    int getSize() { return _size; }

    void write(ll file_id,ll size) {
        for(itr it = sv.begin(); it != sv.end(); ++it) {
            if(it->contents == -1) {
                it->contents = file_id;
                if(it->size() > size) {
                    ll e = it->end;
                    it->end = it->start + size -1;
                    ll nexts = (it->end)+1;
                    it++;
                    sv.insert(it, 1, Section( nexts, e, -1));
                    break;
                }else{
                    size -= it->size();
                }
            }
        }
    }

    void dump() {
        for(itr it = sv.begin(); it != sv.end(); ++it) {
            cout<<"from "<<it->start<<" to "<<it->end<<" : file_id "<<it->contents<<endl;
        }
    }

    void delete_file(ll file_id) {
        for(itr it = sv.begin(); it != sv.end(); ++it) {
            if(it->contents == file_id) {
                it->contents = -1;
            }
        }
        return;
    }

    int reference(ll ptr) {
        for(itr it = sv.begin(); it != sv.end(); ++it) {
            if(it->start <= ptr && it->end >= ptr) return it->contents;
        }
        return -1;
    }
};

int main() {
    int N;
    ll rs,rt;
    string op;
    while(cin>>N, N) {
        Disk disk;
        for(int i=0; i<N; ++i) {
            cin>>op;
            if(op == "W") {
                cin>>rs>>rt;
                disk.write(rs,rt);
            }else if(op == "D") {
                cin>>rs;
                disk.delete_file(rs);
            }else{
                cin>>rs;
                cout<<disk.reference(rs)<<endl;
            }
        }
        cout<<endl;
    }
}

Measured memory_bytes: 1152