akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n, k, ans = 0;

  cin >> n >> k;

  vector<int> x;

  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    ans += min(abs(k - tmp), abs(0 - tmp)) * 2;
  }

  cout << ans;

  return 0;
}

Measured memory_bytes: 256
PR = [11, 31, 41, 61, 71, 101, 131, 151, 181, 191, 211, 241, 251, 271, 281, 311, 331, 401, 421, 431, 461, 491, 521, 541, 571, 601, 631, 641, 661, 691, 701, 751, 761, 811, 821, 881, 911, 941, 971, 991, 1021, 1031, 1051, 1061, 1091, 1151, 1171, 1181, 1201, 1231, 1291, 1301, 1321, 1361, 1381, 1451]
N = gets.to_i
puts PR[0...N].join(" ")

Measured memory_bytes: 1788
MOD = 1000000007

def main():
    n,m = map(int,input().split())
    al = [False for _ in range(n+1)]
    for i in range(m):
        a = int(input())
        al[a] = True
    
    dp = [0 for _ in range(n+1)]
    dp[0] = 1
    dp[1] = 1 if al[1] == False else 0

    for i in range(2,n+1):
        if not al[i]:
            dp[i] = (dp[i-2] + dp[i-1]) % MOD

    print(dp[n])


if __name__ == "__main__":
    main()

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

int main()
{
    int a, b;
    char op;
    while (cin >> a >> op >> b) {
        switch (op) {
        case '+':
            cout << a + b << endl;
            break;
        case '-':
            cout << a - b << endl;
            break;
        case '*':
            cout << a*b << endl;
            break;
        case '/':
            cout << a / b << endl;
            break;
        default:
            break;
        }
    }
}

Measured memory_bytes: 1160
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>
#include <bitset>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

#ifdef _DEBUG
#include "../../library/library/debug_template.cpp"
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

struct init {
	init() {
		cin.tie(nullptr); ios::sync_with_stdio(false);
		cout << fixed << setprecision(10);
	}
} init_;

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

inline int popcount(lint n) {
	n = (n & 0x5555555555555555) + (n >> 1 & 0x5555555555555555);
	n = (n & 0x3333333333333333) + (n >> 2 & 0x3333333333333333);
	n = (n & 0x0f0f0f0f0f0f0f0f) + (n >> 4 & 0x0f0f0f0f0f0f0f0f);
	n = (n & 0x00ff00ff00ff00ff) + (n >> 8 & 0x00ff00ff00ff00ff);
	n = (n & 0x0000ffff0000ffff) + (n >> 16 & 0x0000ffff0000ffff);
	n = (n & 0x00000000ffffffff) + (n >> 32 & 0x00000000ffffffff);
	return n;
}

int main() {

	int N;
	cin >> N;

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

	int ans = INF;
	auto check = [&](auto &svec) {

		DMP(svec);
		// buble sort
		int swaps = 0;
		for (int i = 0; i < N - 1; ++i) {
			for (int j = 0; j < N - i - 1; ++j) {
				if (svec[j].second > svec[j + 1].second) {
					swap(svec[j], svec[j + 1]);
					swaps++;
				}
			}
		}
		DMP(svec);

		return swaps;
	};

	for (int bit = 0; bit < (1 << N); bit++) {

		if (popcount(bit) & 1) continue;

		vector<pair<int, int>> odd, even;
		for (int i = 0; i < N; i++) {
			if (((bit >> i) & 1)) {
				if (i & 1) odd.emplace_back(B[i], i);
				else even.emplace_back(B[i], i);
			}
			else {
				if (i & 1) even.emplace_back(A[i], i);
				else odd.emplace_back(A[i], i);
			}
		}

		if (odd.size() == (N + 1) / 2 && even.size() == N / 2) {

			sort(odd.begin(), odd.end());
			sort(even.begin(), even.end());
			vector<pair<int, int>> vec(N);
			for (int i = 0; i < N; i++) {
				if (i & 1) vec[i] = even[i / 2];
				else vec[i] = odd[i / 2];
			}

			if (is_sorted(vec.begin(), vec.end(), [](auto& l, auto& r) { return l.first < r.first; })) {
				chmin(ans, check(vec));
			}
		}
	}

	cout << (ans == INF ? -1 : ans) << "\n";

	return 0;
}



Measured memory_bytes: 3608
#pragma region RegionDefs
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,l,r) for(int i=(l),i##_len=(r);i<i##_len;++i)
#define repr(i,l,r) for(int i=(r)-1,i##_left=(l);i>=i##_left;--i)
#define all(x) begin(x),end(x)
using namespace std;
typedef long long ll;
const ll INF = 1e9;
template<class T=ll> using V = vector<T>;
template<class T=ll> using PQ = priority_queue<T>;
template<class T=ll> using PQG = priority_queue<T, V<T>, greater<T>>;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail) { cin >> head; in(move(tail)...); }
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define TIN(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
#define VIND(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem,--_elem
#define OUT(x) cout << x;
#define OUTL(x) cout << x << endl;
template<class T>bool chmax(T &a, const T &b) {if (a<b) {a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if (a>b) {a=b; return 1;} return 0;}
template<class T>
string join(vector<T>& v, string delim="") { ostringstream os; rep(i,v.size())i?os<<delim<<v[i]:os<<v[0]; return os.str(); }
#pragma endregion RegionDefs

void solve()
{
    IN(n);
    vector<tuple<ll,ll,ll,ll>> v(n);
    ll maxp[4] = {-INF, -INF, -INF, -INF};
    ll minp[4] = {INF, INF, INF, INF};
    rep(i, n) {
        IN(x, y);
        chmax(maxp[0], x+y);
        chmax(maxp[1], x-y);
        chmax(maxp[2], -x+y);
        chmax(maxp[3], -x-y);
        chmin(minp[0], x+y);
        chmin(minp[1], x-y);
        chmin(minp[2], -x+y);
        chmin(minp[3], -x-y);
    }
    ll ans = -INF;
    chmax(ans, maxp[0] - minp[0]);
    chmax(ans, maxp[1] - minp[1]);
    chmax(ans, maxp[2] - minp[2]);
    chmax(ans, maxp[3] - minp[3]);
    cout << ans << endl;
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

Measured memory_bytes: 9532
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <climits>
#include <cmath>
#include <utility>
#include <iomanip>

using namespace std;



int main(int argc, char *argv[])
{
	int a, b;
	int ans;

	//input
	cin >> a >> b;


	//calc
	if (13 <= a){
		ans = b;
	}
	else if (6 <= a && a <= 12){
		ans = b / 2;
	}
	else{
		ans = 0;
	}

	//ans
	cout << ans << endl;


	return 0;
}


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

using namespace std;

int n, z;
int sT[4*100000];

void u(int v , int l , int r , int x , int val)
{
	if(x < l || x >= r)
	{
		return;
	}
	if( (r - l) == 1)
	{
		sT[v] += val;
		return;
	}else
	{
		int m = (l+r)/2;
		u(2*v,	l,m ,x,val);
		u(2*v+1,m,r,x,val);
		sT[v] += val;
	}
}
int q(int v , int l , int r , int i , int j)
{
	if(j < l || i >= r)
	{
		return 0;
	}
	else if(i <= l && r-1 <= j)
	{
		return sT[v];
	}else
	{
		int m = (l+r)/2;
		return (q(2*v , l , m , i , j) + q(2*v+1 , m , r , i , j));
	}
}

int main (){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> z;
	int a,b,c;
	while(z--)
	{
		cin >> a >> b >> c;
		if(a == 0)
		{
			u(1,1,n+1,b,c);
		}else
		{
			cout << q(1,1,n+1,b,c) << '\n';
		}
	}
	return 0;
}





Measured memory_bytes: 4196
h, n = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(n)]
dp = [1 << 31] * (h + 10**4)
dp[0] = 0
for i in range(h):
    for a, b in AB:
        dp[i + a] = min(dp[i + a], dp[i] + b)
print(min(dp[h:]))

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

using namespace std;

typedef long long ll;

const int MOD = 1e9 + 7;

ll n;

int main() {
  cin >> n;
  ll a = 1, b = 1, c = 1;
  while (n--) {
    a *= 10, b *= 9, c *= 8;
    a %= MOD, b %= MOD, c %= MOD;
  }
  ll ans = a - 2 * b + c;
  ans %= MOD, ans += MOD, ans %= MOD;
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m; i<n; i++)
#define co(n) cout << n << endl
using namespace std;
int main(){
  int n, a, b;
  cin >> n;
  a=n/100;
  b=n%100;
  
  if(a*5>=b) co(1);
  else co(0);
  
  return 0;
  
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int N,a[100],sum=0,ans=1000000,i,j;
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&a[i]);
  }
  for(i=-100;i<=100;i++){
    sum=0;
    for(j=0;j<N;j++){
      sum+=(i-a[j])*(i-a[j]);
    }
    if(sum<ans){
      ans=sum;
    }
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 128
package main

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

func main() {
	var n int
	fmt.Scan(&n)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	ds := make([]int, n)
	for i := range ds {
		sc.Scan()
		ds[i], _ = strconv.Atoi(sc.Text())
	}
	var sum int
	for i := 0; i < n-1; i++ {
		for j := i + 1; j < n; j++ {
			sum += ds[i] * ds[j]
		}
	}
	fmt.Println(sum)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

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


Measured memory_bytes: 1844
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll N,M;
vector<P> connectVec[100010];
ll potential[100010];
bool finish=false;
void SetPot(ll now){
    if(finish)return;
    for(auto p:connectVec[now]){
        ll v=p.first;
        ll d=p.second;
        if(potential[v]==INF){
            potential[v]=potential[now]+d;
            SetPot(v);
        }else if(potential[v]!=potential[now]+d){
            cout<<"No"<<endl;
            finish=true;
        }
        if(finish)break;
    }
}
int main(){
    cin>>N>>M;
    for(ll i=0;i<M;i++){
        ll l,r,d;
        cin>>l>>r>>d;
        l--;r--;
        connectVec[l].push_back(P(r, d));
        connectVec[r].push_back(P(l,-d));
    }
    for(ll i=0;i<N;i++){
        potential[i]=INF;
    }
    for(ll i=0;i<N;i++){
        if(potential[i]!=INF)continue;
        potential[i]=0;
        SetPot(i);
    }
    if(finish)return 0;
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 16512
#include <iostream>
#include <string>
#include <cstring>
#include <sstream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <chrono>
#include <numeric>

using namespace std;

class cBinarySearch
{
	int mn, mq;
	string mS, mT;
	int ans;
	vector<int> vs, vt;

	void decode();

public:
	cBinarySearch(const int &n, const int &q, const string &s, const string &t)
	{
		mn = n;
		mq = q;
		mS = s;
		mT = t;
		ans = 0;

		decode();
	}
	void search();
	void output();
};

void cBinarySearch::search()
{
	int l, r, m;
	int count = 0;
	
	for(int i = 0; i < vt.size(); ++i)
	{
		l = 0;
		r = vs.size();
		m = (l + r) / 2;
		while (l < r)
		{
			m = (l + r) / 2;
			if (vt[i] == vs[m])
			{
				++count;
				break;
			}
			else if (vt[i] < vs[m])
			{
				r = m;
			}
			else
				l = m + 1;
		}
	}
	ans = count;
}

void cBinarySearch::output()
{
	cout << ans << endl;
}

void cBinarySearch::decode()
{
	istringstream iss;
	iss.str(mS);
	int ts;
	for (int i = 0; i < mn; ++i)
	{
		iss >> ts;
		vs.push_back(ts);
	}
	iss.str(mT);
	iss.seekg(0, iss.beg);
	for (int i = 0; i < mq; ++i)
	{
		iss >> ts;
		vt.push_back(ts);
	}
}

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

	int n, q;
	string s, t;
	cin >> n;
	cin.ignore();
	getline(cin, s);
	cin >> q;
	cin.ignore();
	getline(cin, t);

	cBinarySearch cbs(n, q, s, t);
	cbs.search();
	cbs.output();

	return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

bool sortbysec(const P &a, const P &b){
    return (a.second > b.second);
}

void Main() {
    ll N, K; cin >> N >> K;
    map<ll, ll> x;
    rep(i, N){
        ll tmp; cin >> tmp;
        if (x.find(tmp) != x.end()){
            x[tmp] += 1;
        } else {
            x[tmp] = 1;
        }
    }
    vector<P> pairs;
    for (auto v: x){pairs.push_back(make_pair(v.first, v.second));}
    sort(pairs.begin(), pairs.end(), sortbysec);
    ll cnt = 0;
    if (K >= pairs.size()){
        cout << 0 << endl;
    } else {
        rep(i, K){cnt += pairs.at(i).second;}
        cout << N - cnt << endl;
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 18928
/*
在太阳西斜的这个世界里
置身天上之森。
等这场战争结束之后
不归之人与望眼欲穿的众人
人人本着正义之名
长存不灭的过去
逐渐消逝的未来
我回来了
纵使日薄西山
即便看不到未来
此时此刻的光辉
盼君勿忘
*/

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;

int factor[1000010];
int n,ans;

int main(){
    cin>>n;
    for(register int i=1; i<=n; i++)
        for(register int j=1; j<=n/i; j++)
            factor[i*j]++;
    for(register int i=1; i<n; i++) ans+=factor[i];
    cout<<ans;
	return 0;
}

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

int		main(void)
{
	int a, b;
	cin >> a >> b;
	a == 1 ? a = 100 : 0;
	b == 1 ? b = 100 : 0;
	if (a > b)
		cout << "Alice";
	else if (a < b)
		cout << "Bob";
	else
		cout << "Draw";
	cout << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
const int maxn=100000+10;
const int maxm=100000+10;
const int inf=0x3f3f3f3f;
long long int f[maxm*2],v[maxn],c[maxn];
int main(){
	long long n,h,maxv=0;
	long long int ans=inf;
	cin>>h>>n;
	for(long long i=1;i<=n;i++){
		cin>>v[i]>>c[i];
		maxv=max(maxv,v[i]);
	}
	for(long long i=1;i<=h+maxv;i++) f[i]=inf;
	for(long long i=1;i<=n;i++)
		for(long long j=0;j<=h+maxv;j++){
			f[j+v[i]]=min(f[j+v[i]],f[j]+c[i]);
		}
	for(long long i=h;i<=h+maxv;i++) ans=min(ans,f[i]);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
    #include <cstdio>
    #include <cmath>
    #include <vector>
    #include <queue>
     
    #include <map>
    #include <set>
    #include <string>
    #include <algorithm>
    #include <functional>
    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 (int i=0;i<(n);i++)
    #define RREP(i,n) for (int i=(n)-1;i>=0;i--)
    #define INF 1<<29
    #define ALEN(ARR) (sizeof(ARR) / sizeof((ARR)[0]))
    #define MP make_pair
    #define mp make_pair
    #define pb push_back
    #define PB push_back
    #define _DEBUG(x) cout<<#x<<": "<<x<<endl
    #define _DDEBUG(x,y) cout<<#x<<": "<<x<<", "<<#y<<": "<<y<<endl
    #define ll long long
    #define ull unsigned long long
    #define MOD 1000000007
     
    // refer:
    // http://dai1741.github.io/maximum-algo-2012/docs/shortest-path/
    typedef vector<vector<int> > Metrics;
    Metrics d;
     
    void warshall_floyd(int n) { // n:頂点数
    	REP(i, n) {	// 経由する頂点
    		REP(j, n) {	// 開始頂点
    			REP(k, n) {	// 終端
    				d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
    			}
    		}
    	}
    }
     
    void debugprint(int n) {
    	REP(i, n) {
    		REP(j, n) {
    			if (i != j && d[i][j] != INF) {
    				cout << i << "から" << j << "へのコスト: " << d[i][j] << endl;
    			}
    		}
    	}
    }
     
    int main(){
    	cin.tie(0);
    	ios::sync_with_stdio(false);
    	cout.precision(16);
     
    	int n, m, r;
    	cin >> n >> m >> r;
        n++;
     
    	d = Metrics(n, vector<int>(n, INF));
    	REP(i, n) d[i][i] = 0;
     
        vector<int> goal(r);
        REP(i, r) cin >> goal[i];
        
        REP(i, m) {
    		int from, to, cost;
    		cin >> from >> to >> cost;
    		d[from][to] = cost;
    		d[to][from] = cost; // if undirected graph
        }
		sort(goal.begin(), goal.end());
        warshall_floyd(n);
     
        int ans = INF;
        do {
            int t = 0;
             REP(i, r-1) {
                t += d[goal[i]][goal[i+1]];
             }
             ans = min(ans, t);
        } while(next_permutation(goal.begin(), goal.end()));
     
        cout << ans << endl;
     
        return 0;
    }

Measured memory_bytes: 384
def L(str1,str2):
    A = [0 for _ in range(len(str2)+1)]
    for char1 in str1:
        A_copy = A[:]
        for j,char2 in enumerate(str2):
            if(char1==char2):
                A[j+1] = A_copy[j]+1
            elif(A[j] > A[j+1]):
                A[j+1] = A[j]
    return A[-1]


m = int(input())
for i in range(m):
    str1 = input()
    str2 = input()
    print(L(str1,str2))


Measured memory_bytes: 5632
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}
#define trace1(x)			 	 cerr<<#x<<": "<<x<<endl
#define trace2(x, y)		 	 cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)		 	 cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)	 	 cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)	 cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}


int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll a,b,t;
	cin >> a >> b >> t;
	cout << b*(((2*t+1))/(2*a));
	return 0;
}
/* The judge is never wrong! Your code is buggy
   Look for:
 * * Read the problem carefully.
 * * Don't forget to sort(), mod, ll!!!!
 * * Initial value = +/- infinity instead of zero!!!
 * * an easier and alternate approach
 * * read the problem statement carefully
 * * if concept is correct and still WA, try with a different implementation
 * * special cases (n=1?)
 * * if you have no idea just guess the appropriate well-known algorithm instead of doing nothing :/
 */


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

int main(){
	priority_queue<int> a;
	for (int i = 0; i < 10; ++i) {
		int high;
		cin >> high;
		a.push(high);
	}
	for (int i = 0; i < 3; ++i) {
		cout << a.top() << endl;
		a.pop();
	}
	return 0;
}

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

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

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

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

const ll M = 998244353;

int main(){
	string s;
	cin >> s;
	int n = s.size();
	
	static int r[2002] = {};
	static int b[2002] = {};
	rep1(i,n){
		r[i] = 2-(s[i-1]-'0');
		b[i] = s[i-1]-'0';
	}
	rep1(i,n){
		r[i] += r[i-1];
		b[i] += b[i-1];
	}
	
	static ll dp[2][4002] = {};
	static int t = 0, t_ = 1;
	dp[t][0] = 1;
	rep1(i,2*n){
		rep(j,4002)dp[t_][j] = 0;
		int max_r = r[min(n,i)];
		int max_b = b[min(n,i)];
		rep(j,4002){
			if(j+1 <= max_r)dp[t_][j+1] += dp[t][j];
			if(i-j <= max_b)dp[t_][j] += dp[t][j];
		}
		rep(j,4002){
			dp[t_][j] %= M;
		}
		swap(t,t_);
	}
	cout << dp[t][r[n]] << endl;
}


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

int main(){
	int a;
	cin >> a;
	if (a%100 > 0 and a%100 <= 12){
		if (a/100 > 0 and a/100 <= 12) cout << "AMBIGUOUS";
		else cout << "YYMM";
	}
	else if (a/100 > 0 and a/100 <= 12){
		cout << "MMYY";
	}
	else cout << "NA";
}


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

int main(){
  vector<vector<int>> data(3,vector<int>(3));
  REP(i,3){
    REP(j,3){
      cin >> data[i][j];
    }
  }
  vector<int> data_x(3);
  vector<int> data_y(3);
  data_y.at(0) = 0;
  REP(i, 3) data_x.at(i) = data[0][i];
  for(int i=1;i<3;i++) data_y.at(i) = data[i][0] - data_x.at(0);
  bool good = true;
  for (int i = 1; i < 3; i++){
    for (int j = 1; j < 3;j++){
      int ans = data_x.at(j) + data_y.at(i);
      if(ans !=data[i][j]){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}

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

vector<long> p;
vector<long> q;

int main(){
  long A, B;
  cin >> A >> B;
  long tmp = A;
  for(long i=2; i<=ceil(sqrt(A)); i++){
    long itr=0;
    while(tmp%i==0){
      if(itr==0) p.push_back(i);
      tmp/=i;
      itr++;
    }
  }
  if(tmp!=1) p.push_back(tmp);
  tmp=B;
  for(long i=2; i<=ceil(sqrt(B)); i++){
    long itr=0;
    while(tmp%i==0){
      if(itr==0) q.push_back(i);
      tmp/=i;
      itr++;
    }
  }
  if(tmp!=1) q.push_back(tmp);
  long count=1;
  for(long i=0; i<p.size(); i++){
    for(long j=0; j<q.size(); j++){
      if(p[i]==q[j]) count++;
    }
  }
  cout << count << endl;
  return 0;
}

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

H[0] = H[0] - 1

for i in range(N):
    if i == N-1:
        print('Yes')
        break
    else:
        if H[i] < H[i + 1]:
            H[i + 1] = H[i + 1] - 1
        elif H[i] > H[i + 1]:
            print('No')
            break





Measured memory_bytes: 14252
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long LLINF = 1e18;

using namespace std;

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

/*==================================================*/
/*variable*/
int N;
/*==================================================*/
/*function*/

/*==================================================*/

int main() {

    cin>>N;

//    for(int i = 1; i <= N ; i++){
//        if(i % 2 == 0 && i % N == 0){
//            cout<<i<<endl;
//            return 0;
//        }
//    }

    if(N % 2 == 0){
        cout<<N<<endl;
    }else{
        cout<<2 * N<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 5000000000000000
#define endl '\n'
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

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

signed main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    vector<int> a(n);
    rep(i,n)cin>>a.at(i);
    int g=a.front(),f=a.back();
    vector<int> gs(n),fs(n);
    rep(i,n){
        g=gcd(g, a.at(i));
        gs.at(i)=g;
    }
    for(int i=n-1; i>=0; i--){
        f=gcd(f, a.at(i));
        fs.at(i)=f;
    }
    int ans=gs.back();
    chmax(ans, fs.at(1));
    chmax(ans, gs.at(n-2));
    rep(i,n-2){
        chmax(ans, gcd(gs.at(i),fs.at(i+2)));
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 2560
import fractions

A, B, C, D = [int(i) for i in input().split()]

cd = (C * D) // fractions.gcd(C, D)
bc = int(B // C)
bd = int(B // D)
bcd = int(B // cd)
ac = int((A-1) // C)
ad = int((A-1) // D)
acd =int((A-1) // cd)

print((B - bc - bd + bcd) - (A-1 - ac - ad + acd))

Measured memory_bytes: 5076
#include <iostream>
#include <vector>
#include <algorithm>

int main(){
  int n,q;
  std::cin >> n;
  std::vector<int> s(n);
  std::vector<int> res;
  for( int &v : s ){ std::cin >> v; }
  std::cin >> q;
  std::vector<int> t(q);
  for( int &v : t ){ std::cin >> v; }
  std::sort( s.begin(), s.end() );
  std::sort( t.begin(), t.end() );
  int index = 0;
  for( int v1 : t ){
    for( ; index<s.size(); ++index ){
      if ( v1 < s[index] ){ break; }
      if ( v1 == s[index] ){
        res.push_back( v1 );
      }
    }
  }
  std::sort( res.begin(), res.end() );
  res.erase( std::unique( res.begin(), res.end() ), res.end() );
  std::cout << res.size() << std::endl;
}


Measured memory_bytes: 3200
#include <iostream>
#include <iomanip>
#include <stdio.h>
using namespace std;

int main()
{
	int x[10000];
	int i=0;
	
	do{
		cin >> x[i];
	}while(x[i++] != 0);
	
	i = 0;
	
	do{
		printf("Case %d: %d\n", i+1 , x[i]);
	}while(x[++i] != 0);
	
	return 0;
}



Measured memory_bytes: 3232
#include<bits/stdc++.h>
using namespace std;
int a[1005];
int main()
{
	int n,k,ans=0;
	cin>>n>>k;
	for(int i=1;i<=n;i++) cin>>a[i];
	sort(a+1,a+1+n,less<int>());
	for(int i=1;i<=k;i++) ans+=a[i];
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>

typedef long long ll;
typedef long double ld;
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define PRECISION std::cout << std::fixed << std::setprecision(20);
  
using namespace std;
 
const ll inf = 1e18;
const ll N = 2e5+1;
const ll bits = 20;
const ld pi = 3.14159265358979323846;
const ll mod = 1e9+7;
const ll p = 29;

int main(){

    FASTIO;
    PRECISION; 

    ll x;
    cin>>x;
    ll ans = (x/500)*1000;
    x%=500;
    ans+=(x/5)*5;

    cout<<ans<<"\n";
    

}

Measured memory_bytes: 256
_n = gets.strip.to_i
arrays = gets.strip.split.map(&:to_i)

even = arrays.select(&:even?)

flag = true
even.each do |number|
  unless (number % 3 == 0 || number % 5 == 0)
  	flag = false
    break
  end
end

if flag
  puts 'APPROVED'
else
  puts 'DENIED'
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define INF (1LL<<50)

signed main(){

	lli n,k;
	cin>>n>>k;
	vector<lli> a(n);
	REP(i,0,n)cin>>a[i];

	sort(a.rbegin(),a.rend());
	lli sum=0;

	REP(i,0,k)sum+=a[i];

	cout<<sum<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<eps)
int w,h;
int sx,sy,gx,gy;
int n;
int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
bool used[120][120];
int f[120][120];
void set(int c,int d,int x,int y)
{
	if(d==0)
	{
		for(int i=0;i<2;i++)
		{
			for(int j=0;j<4;j++)
			{
				f[x+i][y+j]=c;
			}
		}
	}
	else
	{
		for(int i=0;i<4;i++)
		{
			for(int j=0;j<2;j++)
			{
				f[x+i][y+j]=c;
			}
		}
	}
	return;
}
bool judge()
{
	if(f[sx][sy]!=f[gx][gy])return false;
	memset(used,false,sizeof(used));
	queue<P> q;
	q.push(mp(sx,sy));
	used[sx][sy]=true;
	while(!q.empty())
	{
		P a=q.front();
		q.pop();
		for(int i=0;i<4;i++)
		{
			int nx=a.fi+dx[i],ny=a.sec+dy[i];
			if(nx<=0||nx>w||ny<=0||ny>h)continue;
			if(used[nx][ny]||f[nx][ny]!=f[a.fi][a.sec])continue;
			if(nx==gx&&ny==gy)return true;
			used[nx][ny]=true;
			q.push(mp(nx,ny));
		}
	}
	return false;
}
int main()
{
	while(1)
	{
		memset(f,0,sizeof(f));
		scanf("%d %d",&h,&w);
		if(w==0&&h==0)break;
		scanf("%d %d",&sy,&sx);
		scanf("%d %d",&gy,&gx);
		scanf("%d",&n);
		for(int i=0;i<n;i++)
		{
			int c,d,x,y;
			scanf("%d %d %d %d",&c,&d,&y,&x);
			set(c,d,x,y);
		}
		if(judge())puts("OK");
		else puts("NG");
	}
	return 0;
}

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

using namespace std;

int main()
{
string S;
cin>>S;
set<char>A;
for(int i=0;i<S.size();i++){
    A.insert(S[i]);
}
if(S.size()==A.size())
    cout<<"yes";
else
cout<<"no";
    return 0;
}

Measured memory_bytes: 256
inf = float('inf')

n, w = map(int, input().split())
wv = tuple(tuple(map(int, input().split())) for _ in range(n))

dp = tuple([inf] * (pow(10, 3) * n + 1) for _ in range(n + 1))
dp[0][0] = 0

for ind, (wi, vi) in enumerate(wv, 1):
    for v in range(pow(10, 3) * n + 1):
        if vi <= v:
            dp[ind][v] = min(dp[ind - 1][v], dp[ind - 1][v - vi] + wi)
        else:
            dp[ind][v] = dp[ind - 1][v]

for v in range(pow(10, 3) * n, 0, -1):
    if dp[n][v] <= w:
        print(v)
        exit()


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

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int pow2(int l){
    if(l>0){
        return 2*pow2(l-1);
    }
    return 1;
}

vector<bool> inttobool(int n,int l){
    vector<bool> rep;
    for(int i=0;i<l;i++){
        rep.push_back(n%2);
        n/=2;
    }
    return rep;
}

int main(){
    vector<int> A(4);
    string str;
    cin>>str;
    for(int i=0;i<4;i++){
        A.at(i)=ctoi(str.at(i));
    }
    
    for(int i=0;i<pow2(3);i++){
        vector<bool> plusminus=inttobool(i,3);
        int val=A.at(0);
        string ans;
        ans+=str.at(0);
        for(int j=0;j<3;j++){
            if(plusminus.at(j)){
                val+=A.at(j+1);
                ans+='+';
                ans+=str.at(j+1);
            }
            else{
                val-=A.at(j+1);
                ans+='-';
                ans+=str.at(j+1);
            }
        }
        ans+="=7\n";
        if(val==7){
            cout<<ans<<endl;
            return 0;
        }
    }
}

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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int n,k;cin>>n>>k;
  if(n%k==0){
    cout<<0<<endl;
  }else{
    cout<<1<<endl;
  }

  return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

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();
        int[] array = {a, b, c};
        Arrays.sort(array);
        System.out.println(array[0] + array[1]);
    }

}


Measured memory_bytes: 25044
#include<iostream>
#include<sstream>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;

map<string, int> id;
vector<pi> e[6000];
int n, m, cap, sz;
bool f[6000];
int get(const string &s){
	if(id.count(s)) return id[s];
	return id[s] = sz++;
}

int main(){
	while(cin >> n >> m >> cap, n){
		id.clear(); sz = 0;
		
		string s, t;
		cin >> s >> t;
		int si = get(s), ti = get(t);
		
		rep(i, n){
			int d, a, b;
			cin >> s >> t >> d;
			a = get(s); b = get(t);
			e[a].pb(mp(b, d));
			e[b].pb(mp(a, d));
		}
		f[si] = f[ti] = 1;
		rep(i, m){
			cin >> s;
			f[get(s)] = 1;
		}
		vector<vi> ds;
		vi ss;
		rep(i, sz) if(f[i]) ss.pb(i);
		
		rep(ii, ss.size()){
			int s = ss[ii];
			priority_queue<pi> q;
			q.push(mp(0, s));
			vi dist(sz, inf), d2;
			
			while(!q.empty()){
				int c = q.top().second, co = q.top().first;
				q.pop();
				
				if(dist[c] <= -co) continue;
				dist[c] = -co;
				rep(i, e[c].size()){
					if(dist[e[c][i].first] > -co + e[c][i].second)
					q.push(mp(co - e[c][i].second, e[c][i].first));
				}
			}
			rep(i, ss.size()) d2.pb(dist[ss[i]] <= cap * 10 ? dist[ss[i]] : inf);
			ds.pb(d2);
		}
		
		int l = ds.size();
		rep(k, l) rep(i, l) rep(j, l) ds[i][j] = min(ds[i][j], ds[i][k] + ds[k][j]);
		
		cout << (ds[0][1] >= inf ? -1 : ds[0][1]) << endl;
		
		rep(i, sz) e[i].clear(), f[i] = 0;
	}
	return 0;
}

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

typedef long long ll;

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

  
  if ( K % 2 == 1 ) {
    cout << (N/K)*(N/K)*(N/K) << endl;
  } else {

    cout << (N/K)*(N/K)*(N/K)+
      ((N+K/2)/K)*((N+K/2)/K)*((N+K/2)/K) << endl;    
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int i,N;
    int k[100]={},p[100]={};
    
    scanf("%d",&N);
    
    for(i=0;i<N;i++){
        scanf("%d %d",&k[i],&p[i]);
        printf("%d\n",(k[i]%p[i]) ? k[i]%p[i] : p[i]);
    }
    
    return 0;
}

Measured memory_bytes: 596
#include<stdio.h>
#include<string.h>
int main() {
    char col1[15];
    char col2[15];
    int num1,num2;
    char col[15];
    scanf("%s %s",col1,col2);
    scanf("%d %d",&num1,&num2);
    scanf("%s",col);
    int hasil = strcmp(col1,col);
    int hasil1 = strcmp (col2,col);
    if(hasil==0){
        num1=num1-1;
    }
    if(hasil1==0){
        num2=num2-1;
    }
    printf("%d %d",num1,num2);
    return 0;
}
   

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

int main() {
	long long k, a, b;
	cin>>k>>a>>b;
	long long ans = 1;
	if (b-a > 2 && a-1<k) {
		long long chance = k-(a-1);
		long long cnv = chance/2;
		ans += cnv*(b-a);
		k -= cnv*2;
	}
	ans += k;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int a;
	scanf("%d",&a);
	if(a<1200)
	{
		printf("ABC\n");
	}
	else if(a>=1200&&a<2800)
	{
		printf("ARC\n");
	}
	else
	{
		printf("AGC\n");
	}
	return 0;
}

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

typedef long long LL;

#define INF 1000000000
#define INF_LL_YJ 1145141919810364364

using namespace std;

LL N, M;

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

  LL ans = 0;
  if(N*2 >= M){
    cout << M/2 << endl;
  }
  else{
    ans = N;
    M -= 2*N;
    cout << ans + M/4 << endl;
    return 0;
  }

  return 0;
}


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

a = sorted(a)

re = x
i = 0
ans = 0

for i in range(N):
    if a[i]<=re:
        re -= a[i]
        ans += 1
    else:
        break

if ans==N and re>0:
    ans -= 1

print(ans)    



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

using int64 = long long;
using uint64 = unsigned long long;

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

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

    int T;
    cin >> T;

    for (int i = 0; i < T; i++)
    {
        int64 A, B, C, D;
        cin >> A >> B >> C >> D;

        if (A < B or B > D)
        {
            cout << "No" << endl;
            continue;
        }
        else if (C >= B)
        {
            cout << "Yes" << endl;
            continue;
        }

        // C < A - k * gを満たす最大のkを見つける
        int64 g = gcd(B, D),
              k = (A - C - 1) / g;
        if (A - k * g >= B)
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }

    return 0;
}


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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		var ss = rsa();
		Func<String, String, char, long> f = (s, t, c) =>{
			if(c == '+') return long.Parse(s) + long.Parse(t);
			return long.Parse(s) - long.Parse(t);
		};
		Console.WriteLine(f(ss[0], ss[2], ss[1][0]));
	}

	public Sol(){
		
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 11092
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
#include<cmath>

using namespace std;



int main(){
    int n;
    cin >> n;
    vector<int> ans(n);
    for(int i=0;i<n;i++){
        int p;
        cin >> p;
        ans[p-1] = i+1;
    }
    for(int a:ans){cout << a << " ";} cout << endl;
    return 0;
}


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

using namespace std;

int solve(int P, int Q, int R)
{
    return min({ P + Q, P + R, Q + R});
}

int main()
{
    ios::sync_with_stdio(false);

    int P, Q, R;
    cin >> P >> Q >> R;

    auto ans = solve(P, Q, R);

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
#
#　　　　　　　　　　　　　　,. -─────────‐- .、
#　　　　　　　　　　　　 ／／￣￣＼　　　　　　／￣￣＼＼
#　　　　　　　　　　　／　　　　　　　　　　　　　　　　　　　　 ＼
#　　　　　　　　　 ／　　　　　　　　::::::::::::::::::::::::::::::::　　　　　　　＼
#　　　　　　　　／ 　　／ ／￣＼＼::::;;;;;;;;;;;;;;;;;:::::／／￣＼＼　　＼
#　　　　　　 ／　　　　|　 |.　┃　.|　| ::::;;;;;;;;;;;;;::::｜ |.　┃　.|　|　　　 ＼　　　　　　　　　　　　　　　　　　　　　
#　　　　　／ 　　　　　＼ ＼＿／／　::::::::::::::::::　＼＼＿／／　　　　　 ＼　　　　
#　　　 ／　　　　　..／￣￣＼　／　　　::｜::　　　＼　／￣￣＼..　　　　　＼
#　　 / 　 　 　 　 :::::　　　　　　|　　　　　 |　　　　　 |　　　　　　 :::::　　　　　 ヽ.　　　
#　　| 　　　　　　　　　　　　　　|　　　　　 |　　　　　 |　　　　　　　　　　　　　　|.
#　　| 　　　　　　　　　　　　　　＼＿＿／＼＿＿／ 　　　　　　　　　　　　　　|　　　　　　　　　　　　　　　　　
#　　| 　　　　　　　　　　　　　　　｜　　　　　　　｜　　　　　　　　　　　　　　　|
#　　| 　　　　　　　　　　　　　　　｜r─‐┬──､|　　　　　　　　　　　　　　　 |
#　　ヽ　　　　　　　　　　　　　　　 |/　　　|　　 　｜　　　　　　　　　　　　　　/
#　　　 ＼　　　　　　　　　　　　　 ＼　　　　　　／　　　　　　　　　　　　　／
#　　　　　＼ 　　　　　　　　　　　　　￣￣￣￣　　　　　　　　　　　　　／
#
#
import sys
input=sys.stdin.readline
inf=float('inf')
mod = 10**9+7
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [input() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N, _, W = MI()
    A = LI()

    if N == 1:
        print(abs(W-A[-1]))
    else:
        #初手で前取りか寸止め侍かするのと同じ(２手目で同じことがされてしまうから)
        print(max(abs(W-A[-1]), abs(A[-1]-A[-2]) ))
        
if __name__ == '__main__':
    main()


Measured memory_bytes: 38768
Q = gets.to_i
queries = Q.times.map { gets.split.map(&:to_i) }

require 'prime'
require 'set'
MAX = 10 ** 5
primes = Set.new(Prime.each(MAX).to_a)
cusum = Array.new(MAX + 1)
cusum[0] = 0
(1..MAX).each do |n|
  c = cusum[n - 1]
  c += 1 if primes.include?(n) && n.odd? && primes.include?((n + 1) / 2)
  cusum[n] = c
end
queries.each do |l, r|
  puts(cusum[r] - cusum[l - 1])
end

Measured memory_bytes: 11956
import sys
input = sys.stdin.readline
import numpy as np

H, W = map(int, input().split())
S = np.array([list(input().rstrip()) for _ in range(H)]) == '.'
ups = np.zeros((H,W), dtype=int)
downs = np.zeros((H,W), dtype=int)
lefts = np.zeros((H,W), dtype=int)
rights = np.zeros((H,W), dtype=int)

for h in range(1, H):
    ups[h] = (ups[h-1] + 1) * S[h-1]
    downs[H-h-1] = (downs[H-h] + 1) * S[H-h]
for w in range(1, W):
    lefts[:, w] = (lefts[:, w-1] + 1) * S[:, w-1]
    rights[:, W-w-1] = (rights[:, W-w] + 1) * S[:, W-w]
print(np.amax((ups+downs+lefts+rights)*S)+1)


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

typedef long long ll;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

const int MOD = 1e9 + 7 ;
const double PI = 2 * acos(0.0);

int main()
{
  ll h, n, sum = 0, x ;
  cin >> h >> n ;

  for(int i = 0; i < n; i++) {
    cin >> x ;
    sum += x ;
  }
  if(sum >= h)  cout << "Yes" << endl ;
  else  cout << "No" << endl ;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	int a[101],k,i,j,m,n,x1,x2;
	scanf("%d %d",&n,&m);
	for(i=1;i<=n;i++)	scanf("%d",&a[i]);
	for(i=1;i<=m;i++)	{
		for(j=1;j<n;j++){
			x1=a[j]%i; x2=a[j+1]%i;
				if(x2<x1)	swap(a[j],a[j+1]);
		}
	}
	for(i=1;i<=n;i++)	printf("%d\n",a[i]);
	return 0;
}


Measured memory_bytes: 2700
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
 
using namespace std;
 
#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
 
template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }
 
typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
 
int main(){
  int N;
  while(cin>>N && N){
    int p, q;
    cin>>p>>q;
    assert(p < q && p >= 0 && q <= 2400);
    bool show[2400] = {};
    REP(i, N){
      bool cm[2400] = {};
      int k; cin>>k;
      while(k--){
        int b, e; cin>>b>>e;
        FOR(t, b, e) cm[t] = true;
      }
      REP(t, 2400) if(!cm[t]) show[t] = true;
    }
    int ans = 0;
    int con_t = 0;
    for(int t = p; t < q; t += ((t % 100 == 59) ? 41 : 1) ){
      if(show[t]) con_t++;
      else con_t = 0;
      ans = max(ans, con_t);
    }
    cout<<ans<<endl;
  }
  return 0;
}


Measured memory_bytes: 2992
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef double db;
#define go(u) for(int i = head[u], v = e[i].to; i; i=e[i].lst, v=e[i].to)
#define rep(i, a, b) for(int i = a; i <= b; ++i)
#define pb push_back
#define re(x) memset(x, 0, sizeof x)
inline int gi() {
    int x = 0,f = 1;
    char ch = getchar();
    while(!isdigit(ch)) { if(ch == '-') f = -1; ch = getchar();}
    while(isdigit(ch)) { x = (x << 3) + (x << 1) + ch - 48; ch = getchar();}
    return x * f;
}
template <typename T> inline bool Max(T &a, T b){return a < b ? a = b, 1 : 0;}
template <typename T> inline bool Min(T &a, T b){return a > b ? a = b, 1 : 0;}
const int N = 2007;
int n, x;
int a[N], t[N];
LL ans;
int main() {
#ifndef ONLINE_JUDGE
#endif
	n = gi(), x = gi();
	rep(i, 1, n) t[i] = a[i] = gi(), ans += a[i];
	rep(k, 1, n) {
		LL sum = 0;
		rep(i, 1, n) {
			Min(t[i], a[(i - k + n - 1) % n + 1]);
			sum += t[i];
		}
		Min(ans, sum + (LL) k * x);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//vector<vector<int>> a(5, vector<int>(5, 0)) 5*5-0
int main(){
    int x1, x2, x3, x4, x5;
    cin >> x1 >> x2 >> x3 >> x4 >> x5;
    if(x1 == 0){
        cout << 1 << endl;
    }else if(x2 == 0){
        cout << 2 << endl;
    }else if(x3 == 0){
        cout << 3 << endl;
    }else if(x4 == 0){
        cout << 4 << endl;
    }else if(x5 == 0){
        cout << 5 << endl;
    }
}

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

#define pb push_back
#define rep(i, a, n) for(int (i)=a; (i)<(n); (i)++)
#define FOR(i, n) rep(i, 0, n)
#define F(n) FOR(i, n)
#define FF(n) FOR(j, n)
#define repi(i, a, n) for(int (i)=a; (i)<=(n); (i)++)
#define FORI(i, n) repi(i, 1, n)
#define FI(n) FORI(i, n)
#define FFI(n) FORI(j, n)
#define IN(x) int x; cin>>(x);
#define SIN(x) string x; cin>>x;
#define INN(x, y) int x, y; cin>>(x)>>(y);
#define INFO(a) cout<<"info "<<a<<endl
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int, int>
#define vpii vector<pair<int, int> >
#define sortv(x) sort((x).begin(), (x).end())
#define sortvd(x) sort((x).begin(), (x).end(), greater<int>())
#define lboundv(x,v) lower_bound((x).begin(),(x).end(),(v))-(x).begin();
#define uboundv(x,v) upper_bound((x).begin(),(x).end(),(v))-(x).begin();
#define ite iterator
#define fi first
#define se second
#define mems(a, v) memset((a), (v), sizeof((a)))
#define lmid(l, r) ((l)+(r)-1)/2
#define rmid(l, r) ((l)+(r))/2+1
#define mp make_pair

typedef long long ll;
typedef long double LD;

using namespace std;

#define N 3500
int main() {
	ios::sync_with_stdio(0);
	IN(n);
	int val;
	multiset<int> d;
	F(n) {cin>>val; d.insert(val);}
	IN(m);
	int t;
	bool ans = true;
	F(m) {
		cin>>t;
		auto it = d.find(t);
		if(it==d.end()) {ans = false;}
		else d.erase(it);
	}
	cout<<(ans ? "YES":"NO")<<endl;
	return 0;
}

Measured memory_bytes: 9600
N = int(input())
A = list(map(int, input().split()))
flg = [0 for _ in range(9)]

for i in range(N):
	tmp = A[i] // 400
	if tmp >= 9:
		tmp = 8
	flg[tmp] += 1

if flg[8] == 0:
	n = 9-flg.count(0)
	print(n, end = " ")
	print(n)
else:
	n = 8-flg.count(0)
	if n == 0:
		print(1, end=" ")
		print(flg[8])
	else:
		print(n, end = " ")
		print(n+flg[8])



Measured memory_bytes: 3064