akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define re return
#define all(a) a.begin(),a.end()
#define int long long
using namespace std;
const int dx[4]={-1,1,0,0};
const int dy[4]={0,0,-1,1};
signed main()
{
	int a,b,c;
	int k;
	cin>>a>>b>>c>>k;
	while (b<=a)  b*=2,k--;
	while (c<=b)  c*=2,k--;
	if (k>=0)  cout<<"Yes";
	else  cout<<"No";
	re 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
vector<ll> v1, v2;
ll a[1 << 17],c[1<<17];
ll ans[1 << 17];
int main() {
	int n; ll l, t; cin >> n >> l >> t;
	ll r = t % l; ll d = t / l;
	rep(i, n) {
		ll x; int w; cin >> x >> w;
		c[i] = w;
		if (w == 1) {
			v1.push_back(-x);
			v1.push_back(-x + l);
			v1.push_back(-x + 2*l);
			v1.push_back(-x + 3*l);
			a[i] = x;
		}
		else {
			v2.push_back(x);
			v2.push_back(x + l);
			v2.push_back(x + 2*l);
			v2.push_back(x + 3*l);
			a[i] = -x;
		}
	}
	sort(v1.begin(), v1.end());
	sort(v2.begin(), v2.end());
	int l1 = v1.size()/2;
	int l2 = v2.size()/2;
	rep(i, n) {
		ll sum = 0;
		ll loc = 0;
		ll id;
		if (c[i] == 1) {
			sum += d * l2;
			sum += upper_bound(v2.begin(), v2.end(), a[i] + 2*r) - v2.begin();
			sum -= lower_bound(v2.begin(), v2.end(), a[i]) - v2.begin();
			loc = (a[i] + t) % l;
			id = (i + sum) % n;
		}
		else {
			sum += d * l1;
			sum += upper_bound(v1.begin(), v1.end(), a[i] + 2*r) - v1.begin();
			sum -= lower_bound(v1.begin(), v1.end(), a[i]) - v1.begin();
			loc = ((-a[i] - t) % l + l) % l;
			id = ((i - sum) % n + n) % n;
		}
		ans[id] = loc;
	}
	rep(i, n) {
		cout << ans[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 6884
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <list>
using namespace std;
static const int MAX = 100000;
static const int INFTY = (1<<29);

vector<int> G[MAX];
list<int> out;
bool V[MAX];
int N;
int indeg[MAX];

void bfs(int s)
{
    queue<int> q;
    q.push(s);
    V[s] = true;
    while(!q.empty())
    {
        int u = q.front(); q.pop();
        out.push_back(u);
        for(int i=0; i<G[u].size(); i++)
        {
            int v = G[u][i];
            indeg[v]--;
            if(indeg[v]==0 && !V[v])
            {
                V[v] = true;
                q.push(v);
            }
        }
    }
}

void tsort()
{
    for(int i=0; i<N; i++) indeg[i] = 0;
    for(int u=0; u<N; u++)
    {
        for(int i=0; i<G[u].size(); i++)
        {
            int v = G[u][i];
            indeg[v]++;
        }
    }
    for(int u=0; u<N; u++) if(indeg[u]==0 && !V[u]) bfs(u);
    for(list<int>::iterator it=out.begin(); it!=out.end(); it++) cout << *it << endl;
}

int main()
{
    int s, t, M;
    cin >> N >> M;
    for(int i=0; i<N; i++) V[i] = false;
    for(int i=0; i<M; i++)
    {
        cin >> s >> t;
        G[s].push_back(t);
    }
    tsort();
    return 0;
}


Measured memory_bytes: 6276
#include <bits/stdc++.h>
using namespace std;
#define ROUNDUP(divisor,dividend) (divisor + (dividend - 1)) / dividend
string s; int a;
int main(){
  cin >> s;
  for (size_t i = 0; i < s.length(); i++) {
    if(s[i] == 'o')a++;
  }
  cout << (a+(15-s.length()) >= 8 ? "YES":"NO") << endl; 
}


Measured memory_bytes: 256
#include <iostream>
    #include "bits/stdc++.h"
    using namespace std;
    #define print(x) cout<<x<<endl;
    #define rep(i,a,b) for(int i=a;i<b;i++)
    #define REP(i,a) for(int i=0;i<a;i++)
    #define debug int debug = 0;
    #define RREP(i,a) for(int i=a-1;i>=0;i--)
    #define rrep(i,a,b) for(int i=a-1;i>=b;i--)
    #define printall(n,array) {for(int i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
    #define U() cout<<endl;
    typedef long long ll;
    typedef pair<int, int> Pi;
    typedef pair<int, Pi> V;
    typedef vector<ll> VE;
    const ll mod = 1e9 + 7; //10^9+7
     
    int main(){
        string s, t;
        cin >> s >> t;
        bool f;
     
        RREP(i, s.size() - t.size() + 1){
            f = true;
            REP(j, t.size()){
                if(s[i + j] != t[j] && s[i + j] != '?'){
                    f = false;
                    break;
                }
            }
            if(!f)continue;
            REP(k, t.size())s[i + k] = t[k];
            REP(k, s.size())if(s[k] == '?')s[k] = 'a';
            REP(k, s.size())cout << s[k];
            return 0;
        }
     
        print("UNRESTORABLE");
        return 0;
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(i = 0; i < n; i++)
//2D::rep(i,j)rep(j,j)cin>>bin[i][j];
//vector<int> a(n)
#define Graph vector<vector<int>>
#define A1 cout<<"No"<<endl
#define A2 cout<<"Yes"<<endl
#define A3 cout<<ans<<
#define AA(i) cout<<i<<endl;
const int U=2e5+5;
const ll MOD=1000000007;
const int INF = 1001001001;

int main(){
    int L,R,d; cin >> L>>R>>d;
    int l = L%d;
    int r = R%d;
    L = L/d;
    R = R/d;
    if(l==0&&r==0)R+=1;
    AA(R-L);
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;
#define INF 0x3f3f3f
#define ll long long
#define cio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const int N = 1010;

int main()
{
    int x;
    cin >> x;
    if(x>=30) {
        cout << "Yes" << endl;
    }else {
        cout << "No" << endl;
    }
    return 0;
}
     

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int n, h, w; cin >> n >> h >> w;
    int ans = 0;
    rep(i,n) {
        int a, b; cin >> a >> b;
        if (h <= a && w <= b) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3540
readF :: String -> Float
readF = read

main = do
  getLine
  [t, a] <- map readF . words <$> getLine
  xs <- map readF . words <$> getLine
  print $ snd $ minimum $ zipWith (\x i -> (abs $ (t - a) / 0.006 - x, i)) xs [1..]
  

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

n, k = map(int, input().split())
a = list(map(int, input().split()))
a = a + a
#print(a)
l = [0 for _ in range(2*n)]
for j in range(1, 2 * n):
	cnt = 0
	for i in range(j):
		if a[i] > a[j]:
			cnt += 1
	l[j] = cnt
base = sum(l[:n])
inc = sum(l[n:])
inc -= base
if k == 1:
	print(base)
else:
	print((base * k + inc * k * (k - 1) // 2) % (int(1e9 + 7)))


Measured memory_bytes: 41324
#pragma GCC optimize("Ofast,unroll-loops")
#include<bits/stdc++.h>
#define int long long
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB push_back
#define PF push_front
#define FILL(a,b) memset(a,b,sizeof(a))
using namespace std;
bool f[2505],vis[2505];
int n,maxi=1e12,d[2505],cnt[2505];
V<P<int,int> > v[2505];
V<int> fv[2505]; 
void dfs(int p){
	if(f[p])RE;
	f[p]=1;
	for(auto u:fv[p])dfs(u);
}
int spfa(int p){
	if(!f[p])RE -1;
	FOR(i,1,n)d[i]=-maxi;
	d[p]=0;
	vis[p]=1;
	queue<int> q;
	q.push(p);
	int cur;
	while(!q.empty()){
		cur=q.front();q.pop();
		vis[cur]=0;
		for(auto u:v[cur]){
			if(f[u.F]&&d[u.F]<d[cur]+u.S){
				d[u.F]=d[cur]+u.S;
				if(!vis[u.F]){
					vis[u.F]=1;
					q.push(u.F);
					if(++cnt[u.F]>n)RE -1;
				}
			}
		}
	}
	RE max(0ll,d[n]);
}
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int m,p,x,y,z;
	cin>>n>>m>>p;
	FOR(i,1,m){
		cin>>x>>y>>z;
		v[x].PB(MP(y,z-p));
		fv[y].PB(x);
	}
	dfs(n);
	cout<<spfa(1);
	RE 0;
}



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

int main() {
	int n = 0, i = 0, ans = 0;
	string s;
	cin >> s;

	while (s[i] != '\0') {
		if (s[i] == 'g') n++;
		else n--;
		i++;
	}
	ans = n / 2;

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<string>
using namespace std;
// #define MAX 1000003
class Dictionary{
    const int MAX = 10000019;
    vector<int> D;
    int get_key(char c) {
        if (c == 'A') return 1;
        if (c == 'C') return 2;
        if (c == 'G') return 3;
        return 4;
    }
    int keta(int N) {
        int ret = 1;
        for (int i = 0; i < N; i++) {
            ret *= 5;
        }
        return ret;
    }
    int make_key(string s){
        int key = 0;
        for (int i = 0; i < s.size(); i++) {
            key += get_key(s[i]) * keta(i);
        }
        return key;
    }
    int hash1(int key){
        return key % MAX;
    }
    int hash2(int key){
        return key % (MAX - 1);
    }
public:
    Dictionary(){
        D.resize(MAX);
        for (auto& d : D) d = 0;
    }
    void insert(string s){
        int key = make_key(s);
        int h = hash1(key);
        while (D[h]) h = (h + hash2(key)) % MAX;
        D[h] = key;
    }
    bool find(string s){
        int key = make_key(s);
        int h = hash1(key);
        while (D[h]) {
            if (key == D[h]) return true;
            h = (h + hash2(key)) % MAX;
        }
        return false;
    }
};

int main(){
    int n;
    cin >> n;
    Dictionary d;
    for (int i = 0; i < n; i++) {
        string command;
        string content;
        cin >> command >> content;
        if (command == "insert") {
            d.insert(content);
            continue;
        }
        cout << (d.find(content) ? "yes" : "no") << endl;
    }
    return 0;
}

Measured memory_bytes: 41912
#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
#define ALL(vec) ((vec).begin(),(vec).end())
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)),(vec).end())
using namespace std;
int n,k,res;
int main(){
	#ifdef FILIN
		#ifndef DavidDesktop
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>k;
	while(n) n/=k,res++;
	cout<<res<<endl;
	return 0;
}



Measured memory_bytes: 256
def main():
    n, m, l = list(map(int, input().split()))
    A = [[0 for _ in range(m)] for _ in range(n)]
    B = [[0 for _ in range(l)] for _ in range(m)]
    C = [[0 for _ in range(l)] for _ in range(n)]

    for i in range(n):
        A[i] = list(map(int, input().split()))
    for i in range(m):
        B[i] = list(map(int, input().split()))

    for i in range(n):
        for j in range(l):
            for k in range(m):
                C[i][j] += A[i][k] * B[k][j]

    for i in range(n):
        print(" ".join(map(str, C[i])))
    return 0


if __name__ == "__main__":
    main()



Measured memory_bytes: 6896
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
#include <iomanip>
#define M_PI acos(-1)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1000000007;
const int MAX_V = 201;
int now = 0;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
struct edge {
	int t;
	edge(int _t) : t(_t) {}
};

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

void Solve() {
	
	string s;
	cin >> s;
	int len = s.size();
	int hal = len / 2;
	char b = s[hal];
	int c = 0;
	int ad = len % 2;
	for (size_t i = 0; i * 2 < len; i++)
	{
		if (s[hal - i - (1 - ad)] != b || s[hal + i] != b) {
			break;
		}
		c++;
	}
	cout << (hal + c) << endl;
}


int main() {
	Solve();
	return 0;
}



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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.precision(18);
    int L;
    cin >> L;
    double ans = pow(L / 3.0, 3);
    cout << ans << endl;
    return 0;
}


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

int main() {
  #define rep(i,n) for (int i = 0; i <(int)(n);i++)
  int N;
  cin >> N;
  int i = 0;
  int p = 0;
  int q = 0;
  int r = 0;
  rep(i,N){
    string S;
    cin >> S;
    if (S=="Y"){
      p++;
    }
  }
  if(p>0){
    cout << "Four" << endl;
  }
  else{
    cout << "Three" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cassert>
#include <queue>

using namespace std;
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long LL;
typedef pair<int,int> PII;
typedef queue<int> QI;

const LL mod=1000000007;
LL powmod(LL a,LL b) {LL res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// head
int ans,n,k,a[233333],dis[233333],mdis[233333];
VI son[233333];

int dfs(int x){
    if(x==1)return 0;
    if(dis[x]!=0)return dis[x];
    son[a[x]].pb(x);
    int re=1+dfs(a[x]);
    dis[x]=re;
    return re;
}

void dfs2(int x){
    mdis[x]=0;
    int l=son[x].size();
    rep(i,0,l-1){
        int now=son[x][i];
        dfs2(now);
        mdis[x]=max(mdis[x],mdis[now]+1);
    }
    if(mdis[x]==k-1 && a[x]!=1)mdis[x]=-1,ans++;
}


int main(){scanf("%d %d",&n,&k);memset(dis,0,sizeof(dis));
rep(i,1,n)scanf("%d",a+i);ans=0;if(a[1]!=1)ans++,a[1]=1;
    //cout<<"!!!"<<n<<' '<<k<<endl;
    if(k==1){rep(i,2,n)if(a[i]!=1)ans++;}
    else{

        rep(i,1,n)dfs(i);
       // rep(i,1,n)if((dis[i]>k) && (dis[i]%k==1)){ans++;/*cout<<"!!!"<<i<<' '<<dis[i]<<' '<<k<<endl;*/}
       dfs2(1);
    }

   // rep(i,1,n)cout<<mdis[i]<<endl;
    cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 15232
#include<bits/stdc++.h>
#define prArr(Arr,n) for(int _=0;_<n;_++)   cout<<(Arr)[_]<<" ";
#define f first
#define s second
using namespace std;
const int INF=(int)0x3f3f3f3f;
const int MOD=(int)1e9+7;
const double eps=1e-9;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,sum=0,mn=INF;
    cin>>n;
    vector<int> v(n);
    vector<pair<int,int>> ans;
    for(int i=0;i<n;i++)
        cin>>v[i],sum+=abs(v[i]),mn=min(mn,v[i]);
    sort(v.begin(),v.end());
    for(int i=1;i<n-1;i++){
        if(v[i]>=0)
        ans.push_back({v[0],v[i]}),v[0]-=v[i];
        else
        ans.push_back({v[n-1],v[i]}),v[n-1]-=v[i];
    }
    ans.push_back({v[n-1],v[0]}),v[n-1]-=v[0];
    cout<<v[n-1]<<"\n";
    for(int i=0;i<ans.size();i++)
        cout<<ans[i].f<<" "<<ans[i].s<<"\n";
    return 0;
}


Measured memory_bytes: 4652
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  int N, M, X;
  cin >> N >> M >> X;
  vector<int> a(M);
  for(int i = 0; i < M; i++){
    cin >> a[i];
  }
  auto count1 = 0;
  auto count2 = 0;
  for(int i = 0; i < M; i++){
    if(a[i] < X){
      count1 = count1 + 1;
    } else {
      count2 = count2 + 1;
    }
  }
  int Min = min(count1,count2);
  cout << Min << endl;
  return 0;
}

Measured memory_bytes: 256
# AOJ 1159: Next Mayor
# Python3 2018.7.14 bal4u

while True:
	n, p = map(int, input().split())
	if n == 0: break
	ans, m = 0, p
	x = [0]*53
	while True:
		m -= 1
		if m >= 0:
			x[ans] += 1
			if x[ans] == p: break
		else: m = x[ans]; x[ans] = 0
		ans += 1
		if ans == n: ans = 0
	print(ans)



Measured memory_bytes: 5592
#include <stdio.h>
int n;
char h[100005];
int p[100000], q[100000], r[100000];
int main() {
	for (int i = 0; i < 100005; i++) {
		h[i] = 'w';
	}
	scanf("%s", h);
	for (int i = 0; i < 100005; i++) {
		if (h[i] != 'w')n = i;
	}
	for (int i = 1; i < n; i++) {
		if (h[i] == 'R')p[i] = i;
		else p[i] = p[i - 1];
	}
	q[n - 1] = n - 1;
	for (int i = n - 2; i >= 0; i--) {
		if (h[i] == 'L')q[i] = i;
		else q[i] = q[i + 1];
	}
	for (int i = 0; i < n; i++) {
		if (h[i] == 'L') {
			if ((i - p[i]) % 2) {
				r[p[i] + 1]++;
			}
			else r[p[i]]++;
		}
		else {
			if ((q[i] - i) % 2) {
				r[q[i] - 1]++;
			}
			else r[q[i]]++;
		}
	}
	for (int i = 0; i < n; i++) {
		printf("%d\n", r[i]);
	}
}

Measured memory_bytes: 1664
#include<iostream>
using namespace std;
int main()
{
    int a,b;
    a=0;
    string s;
    cin>>s;
    if(s[0]=='o')
    {
        a=a+1;
    }
    if(s[1]=='o')
    {
        a=a+1;
    }
    if(s[2]=='o')
    {
        a=a+1;
    }
    b=(100*a)+700;
    cout<<b;


    return 0;
}


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

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

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

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

int main() {
	IOS();
	string s, t;
	cin >> s >> t;
	dump(t + s);
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        sc.close();

        int tmpMonth = Integer.parseInt(S.substring(0, 2));
        if (tmpMonth <= 0 || tmpMonth > 12) {
            tmpMonth = Integer.parseInt(S.substring(2, 4));
            if (tmpMonth <= 0 || tmpMonth > 12) {
                System.out.println("NA");
            } else {
                System.out.println("YYMM");
            }
        } else {
            tmpMonth = Integer.parseInt(S.substring(2, 4));
            if (tmpMonth <= 0 || tmpMonth > 12) {
                System.out.println("MMYY");
            } else {
                System.out.println("AMBIGUOUS");
            }
        }
    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	--n;
	int a[n];
	for(int i=0;i<n;i++)cin>>a[i];
	int sum=a[0]+a[n-1];
	for(int i=0;i<n;i++){
		sum+=min(a[i-1],a[i]);
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc169/tasks/abc169_d
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>

using namespace std;
#define lli long long int

int main()
{
    lli n,cnt,m,i,j,pw,ar[17],flag;
    cnt=1;
    cin>>n;
    lli b=n;
    i=2;
    while(i*i<=b)
    {
        if(n%i==0)
        {
            pw=0;
            while(n%i==0)
            {
                n/=i;
                pw++;
            }
            j=1;
            while((pw-j)>=0)
            {
                cnt++;
                pw -= j;
                j++;
            }
        }
            i++;
    }
    if(n==1)
        cout<<--cnt<<"\n";
    else
        cout<<cnt<<"\n";
    return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <string>

using namespace std;

void solve()
{
	string s;
	cin >> s;
	for (int i = 0; i < 4; ++i)
	{
		cout << s[i];
	}
	cout << " ";
	for (int i = 4; i < s.size(); ++i)
	{
		cout << s[i];
	}
	cout << endl;
}

int main()
{
	solve();
	return(0);
}

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

int n;
string s[10010],t,r;
int a,b;
signed main(){
	cin>>n;
	rep(i,n)cin>>s[i];
	cin>>t;
	rep(i,n){
		r=s[i];
		rep(j,s[i].size()){
			if(s[i][j]=='?')s[i][j]='a';
		}
		if(s[i]<=t)a++;
		rep(j,r.size()){
			if(r[j]=='?')r[j]='z';
		}
		if(r<t)b++;
	}
	for(int i=b+1;i<=a;i++){
		cout<<i<<" ";
	}
	cout<<a+1<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
#define ll long long
#define MAX 500500
#define lson (now<<1)
#define rson (now<<1|1)
inline int read()
{
	int x=0;bool t=false;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if(ch=='-')t=true,ch=getchar();
	while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
	return t?-x:x;
}
int n,K;
struct Line{int v,next;}e[MAX<<1];
int h[MAX],cnt=1,dg[MAX];
inline void Add(int u,int v){e[cnt]=(Line){v,h[u]};h[u]=cnt++;dg[v]++;}
int a[MAX],P[MAX],ans[MAX],tot;
int t[MAX<<2];
priority_queue<int,vector<int>,greater<int> >Q;
void Modify(int now,int l,int r,int p,int w)
{
	if(l==r){t[now]=w;return;}
	int mid=(l+r)>>1;
	if(p<=mid)Modify(lson,l,mid,p,w);
	else Modify(rson,mid+1,r,p,w);
	t[now]=min(t[lson],t[rson]);
}
int Query(int now,int l,int r,int L,int R)
{
	if(L>R)return t[0];
	if(l==L&&r==R)return t[now];
	int mid=(l+r)>>1;
	if(R<=mid)return Query(lson,l,mid,L,R);
	if(L>mid)return Query(rson,mid+1,r,L,R);
	return min(Query(lson,l,mid,L,mid),Query(rson,mid+1,r,mid+1,R));
}
void Topsort()
{
	for(int i=1;i<=n;++i)if(!dg[i])Q.push(i);
	while(!Q.empty())
	{
		int u=Q.top();Q.pop();ans[u]=++tot;
		for(int i=h[u];i;i=e[i].next)
			if(!--dg[e[i].v])Q.push(e[i].v);
	}
}
int main()
{
	n=read();K=read();
	for(int i=1;i<=n;++i)a[P[i]=read()]=i;
	memset(t,63,sizeof(t));
	for(int i=n;i;--i)
	{
		int x=Query(1,1,n,a[i]+1,min(a[i]+K-1,n));
		if(x<1e9)Add(a[i],a[x]);
		x=Query(1,1,n,max(1,a[i]-K+1),a[i]-1);
		if(x<1e9)Add(a[i],a[x]);
		Modify(1,1,n,a[i],i);
	}
	Topsort();
	for(int i=1;i<=n;++i)printf("%d\n",ans[i]);
	return 0;
}


Measured memory_bytes: 28928
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let s: Vec<char> = read::<String>().chars().collect();
    let l = s.len();
    if l % 2 == 1 {
        println!("No");
        return;
    }
    for i in (0 as usize)..l {
        if i % 2 == 0 && s[i] != 'h' {
            println!("No");
            return;
        } else if i % 2 == 1 && s[i] != 'i' {
            println!("No");
            return;
        }
    }
    println!("Yes");
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;

#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
constexpr int INF = 1e7;
signed main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int n,l; cin >> n >> l;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int res=-1;
    rep(i,n-1){
        if(a[i+1]+a[i]>=l){
            res=i+1;
        }
    }
    if(res==-1){
        cout << "Impossible" << endl;
    }else{
        cout << "Possible" << endl;
        for(int i=1;i<n;i++){
            if(i!=res) cout << i << endl;
            else break;
        }
        for(int i=n-1;i>=0;i--){
            if(i!=res) cout << i << endl;
            else break;
        }
        cout << res << endl;
    }
}


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

int main(){
  long int l, r;
  cin >> l >> r;
  int ma;
  if(r - l + 1 > 2018){
    ma = 2019;
  }else{
    ma = r - l + 1;
  }
  vector<int> amari(ma);
  for(int i = 0; i < ma; i++){
    amari.at(i) = (i + l) % 2019;
  }
  vector<int> out;
  for(int i = 0; i < amari.size(); i++){
    for(int j = 0; j < amari.size(); j++){
      if(i == j){
        continue;
      }else{
        out.push_back((amari.at(i) * amari.at(j)) % 2019);
      }
    }
  }
  sort(out.begin(), out.end());
  cout << out.at(0);
}

Measured memory_bytes: 18540
#include <climits>
#include <iostream>
#include <map>
#include <vector>
using namespace std;

typedef pair<int, int> i_i;

int N, x2, y2, z2;
int ans = INT_MAX;

void dfs(int x, int y, int z, int k, map<vector<int>, int>& memo) {
	vector<int> v(3);
	v[0] = x; v[1] = y; v[2] = z;
	if (memo.count(v) && memo[v] <= k) return;
	memo[v] = k;
	ans = min(ans, abs(x2 - x) + abs(y2 - y) + abs(z2 - z) + k);
	int _x, _y, _z;
	if (x != x2) {
		_x = x; _y = z; _z = N - 1 - y; dfs(_x, _y, _z, k + 1, memo);
		_x = x; _y = N - 1 - z; _z = y; dfs(_x, _y, _z, k + 1, memo);
	}
	if (y != y2) {
		_y = y; _z = x; _x = N - 1 - z; dfs(_x, _y, _z, k + 1, memo);
		_y = y; _z = N - 1 - x; _x = z; dfs(_x, _y, _z, k + 1, memo);
	}
	if (z != z2) {
		_z = z; _x = y; _y = N - 1 - x; dfs(_x, _y, _z, k + 1, memo);
		_z = z; _x = N - 1 - y; _y = x; dfs(_x, _y, _z, k + 1, memo);
	}
}

int main() {
	cin >> N;
	int x1, y1, z1; cin >> x1 >> y1 >> z1;
	cin >> x2 >> y2 >> z2;
	map<vector<int>, int> memo;
	for (int dx = -1; dx <= 1; dx++)
		for (int dy = -1; dy <= 1; dy++)
			for (int dz = -1; dz <= 1; dz++) {
				int x = x1 + dx, y = y1 + dy, z = z1 + dz;
				if (0<=x && x<N && 0<=y && y<N && 0<=z && z<N)
					dfs(x, y, z, abs(dx) + abs(dy) + abs(dz), memo);
			}
	cout << ans << endl;
}

Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
typedef long long ll;
//手数の最小化は求められていないので機械的に処理できる方法を考える
int main(){
    int H,W;
    cin >> H >> W;
    vector<vector<int> > A(H,vector<int>(W));
    rep(i,H)rep(j,W)cin >> A[i][j];
    vector<tuple<int,int,int,int> > res;
    //AのW-1列目にまとめる
    rep(i,H){
        rep(j,W-1){
            if(A[i][j] & 1){
                A[i][j]--;
                A[i][j+1]++;
                res.push_back(make_tuple(i,j,i,j+1));
            }
        }
    }
    //A[H-1][W-1]にまとめる
    //最終的にすべて偶数になるか一つだけ奇数が残る。
    rep(i,H-1){
        if(A[i][W-1]&1){
            A[i][W-1]--;
            A[i+1][W-1]++;
            res.push_back(make_tuple(i,W-1,i+1,W-1));
        }
    }
    int N = res.size();
    cout << N << endl;
    for(auto e : res){
        int a,b,c,d;
        tie(a,b,c,d) = e;
        printf("%d %d %d %d\n",a+1,b+1,c+1,d+1);
    }
    
    return 0;
}

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

int main() {
	int n, d; string x; cin >> n >> x >> d;
	string s = x;
	rep(i, n) {
		if (d&&x[i] == '0') {
			s[i] = '1'; d--;
		}
	}
	for (int i = n - 1; i >= 0; i--) {
		if (d&&x[i] == '1') {
			s[i] = '0'; d--;
		}
	}
	cout << s << endl;
}

Measured memory_bytes: 3216
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
#include <numeric>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
//#define int ll
typedef long long ll;

const int md = 1000000007;
const int INF = 1<<30;
using namespace std;

string yn(bool x){
    return x ? "Yes" : "No";
}

int main(){
    double t,x; cin >> t >> x;

    double ans = t/x;

    printf("%.6f\n" , ans);
}

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

#define rep(i, n) REP(i, 0, n)
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(x) cout << x << endl;
typedef long long ll;

int main() {
    long a, b; cin >> a >> b;
    for(int i = 1; i <= b; i++){
        if((a * i) % b == 0){
            OP(a * i);
            break;
        }
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

double hellon (double a, double b, double c )
{
	double s = (a+b+c)/2.;
	double res = sqrt (s*(s-a)*(s-b)*(s-c) );

	return res;
}

double calc_dis (DD a, DD b )
{
	return sqrt ((a.first - b.first )*(a.first - b.first ) + (a.second - b.second )*(a.second - b.second ) );
}

int main()
{
//	cut here before submit 
//	freopen ("testcase.area_of_polygon", "r", stdin );
	double x, y;
	vector<DD> p; p.clear();
	while (scanf ("%lf,%lf", &x, &y ) != EOF ){
		p.push_back (DD (x, y ) );
	} // end loop
	int n = p.size();
	double S = 0.;
	for (int i = 1; i < n - 1; i++ ){
		S += hellon (calc_dis (p[i], p[0] ), calc_dis (p[i+1], p[i] ), calc_dis (p[0], p[i+1]) );
	} // end for
	printf ("%.7lf\n", S );
		
	return 0;
}

Measured memory_bytes: 1240
#include <stdio.h>

int main(){
	int n;
	scanf("%d",&n);
	char string[n];
	scanf("%s",string);
	
	int flag = 1;
	
	if (n%2 == 1){
		printf("No");
		return 0;
	} else{
	for (int i=0 ; i < n/2 ; i++){
		if (string[i] == string[i+n/2]){
	
		}
		else {
			flag = 0;
		}
	}
}
	(flag==1)?printf("Yes"):printf("No");	
	return 0;
}

Measured memory_bytes: 3208
import math

X = int(input())

def isPrime(num):
    maxCheck = int(math.sqrt(num))
    for i in range(2, maxCheck + 1):
        if (num % i) == 0:
            return False
    return True

while 1:
    if isPrime(X):
        break
    X += 1

print(str(X))


Measured memory_bytes: 2940
import typing
class SegTree:
    def __init__(self,
                 op: typing.Callable[[typing.Any, typing.Any], typing.Any],
                 e: typing.Any,
                 v: typing.Union[int, typing.List[typing.Any]]):
        self._op = op
        self._e = e

        if isinstance(v, int):
            v = [e] * v

        self._n = len(v)
        self._log = self._ceil_pow2(self._n)
        self._size = 1 << self._log
        self._d = [e] * (2 * self._size)

        for i in range(self._n):
            self._d[self._size + i] = v[i]
        for i in range(self._size - 1, 0, -1):
            self._update(i)
    
    def set(self, p: int, x: typing.Any) -> None:
        assert 0 <= p < self._n
        p += self._size
        self._d[p] = x
        for i in range(1, self._log + 1):
            self._update(p >> i)

    def prod(self, left: int, right: int) -> typing.Any:
        assert 0 <= left <= right <= self._n
        sml = self._e
        smr = self._e
        left += self._size
        right += self._size

        while left < right:
            if left & 1:
                sml = self._op(sml, self._d[left])
                left += 1
            if right & 1:
                right -= 1
                smr = self._op(self._d[right], smr)
            left >>= 1
            right >>= 1

        return self._op(sml, smr)

    def all_prod(self) -> typing.Any:
        return self._d[1]

    def _update(self, k: int) -> None:
        self._d[k] = self._op(self._d[2 * k], self._d[2 * k + 1])
    
    def _ceil_pow2(self, n: int) -> int:
        x = 0
        while (1 << x) < n:
            x += 1
        return x

N, K = map(int, input().split())
A = list(int(input()) for _ in range(N))
max_A = max(A)
seg = SegTree(max, -1, [0]*(max_A+1))
for v in A:
    l = max(0, v-K)
    r = min(max_A, v+K)
    seg.set(v, seg.prod(l, r+1)+1)
print(seg.all_prod())

Measured memory_bytes: 130112
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll n, m;

int main(){
	string s;
	cin >> n >> m >> s;
	s[m-1] += 32;
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>

int main(int argc, char* argv[]) {
    std::string line;
    std::getline(std::cin, line);
    size_t text_size = 0;
    size_t q_size = 0;
    std::istringstream iss(line);
    iss >> text_size;
    iss >> q_size;

    std::string text;
    std::getline(std::cin, text);

    size_t count = 0;
    std::vector<size_t> rcount;
    rcount.push_back(0);
    std::vector<size_t> lcount;
    lcount.push_back(0);
    for(size_t i=1; i<text_size; ++i) {
        size_t found = !!(text[i-1] == 'A' && text[i] == 'C');
        count += found;
        rcount.push_back(count);
        lcount.push_back(count);
    }
    lcount.push_back(count);

    for(size_t i=0; i<q_size; ++i) {
        std::getline(std::cin, line);
        std::istringstream iss(line);
        size_t left = 0;
        size_t right = 0;
        iss >> left;
        iss >> right;
        size_t answer = rcount.at(right - 1) - lcount.at(left - 1);
        std::cout << answer << "\n";
    }
    return 0;
}


Measured memory_bytes: 2796
import sys
import math
MAX_INT = int(10e12)
MIN_INT = -MAX_INT
mod = 998244353
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

def init(n):
  for i in range(N+1):
    par[i] = i
    rnk[i] = 0
def find(x):
  if par[x] == x:
    return x
  else:
    par[x] = find(par[x])
    return par[x]
def unite(x, y):
  x = find(x)
  y = find(y)
  if x == y:
    return
  if (rnk[x] < rnk[y]):
    par[x] = y
  else:
    par[y] = x
    if(rnk[x] == rnk[y]):
      rnk[x] += 1
def same(x, y):
  return find(x) == find(y)

N = I()
a = IL()
b = IL()

par = [0 for i in range(N+1)]
rnk = [0 for i in range(N+1)]
init(N)

adata = []
bdata = []
for i in range(N):
  adata.append([a[i], i])
  bdata.append([b[i], i])
adata.sort()
bdata.sort()
#print(adata)
#print(bdata)

a.sort()
b.sort()
f = 0
for i in range(N-1):
  atmp = a[i]
  btmp = b[i]
  atmp2 = a[i + 1]
  btmp2 = b[i + 1]
  if atmp > btmp:
    print("No")
    exit()
  if atmp2 > btmp2:
    print("No")
    exit()
  if atmp2 <= btmp:
    f = 1
else:
  if f == 1:
    print("Yes")
    exit()

for i in range(N-1):
  atmp, aID = adata[i]
  btmp, bID = bdata[i]
  #print("---")
  #print(atmp,aID)
  #print(btmp,bID)
  if aID == bID:
    break
  if same(aID, bID):
    break
  else:
    unite(aID, bID)
else:
  print("No")
  exit()
print("Yes")

Measured memory_bytes: 123112
#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 NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<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 (b < a) { a = b; return 1; } return 0; }

lli GCD(lli x, lli y)
{
    if(x<y)swap(x,y);
    if (y == 0) {
        return x;
    } else {
        return GCD(y, x % y);
    }
}
lli LCM(lli a,lli b)
{
    return a/GCD(a,b)*b;
}

const string YES = "Yes";
const string NO = "No";

void solve(lli a,lli b,lli c,lli d){

    if(a-b < 0){
        cout<<NO<<endl;
        return;
    }
    if(b>d){
        cout<<NO<<endl;
        return;
    }
    if(c>=b){
        cout<<YES<<endl;
        return;
    }
    if(d%b==0){
        if(a%b <= c){
            cout<<YES<<endl;
        }
        else{
            cout<<NO<<endl;
        }
        return;
    }

    lli pl = GCD(b,d);
    lli cnt = b - a%b;
    LOG2(cnt,pl);
    lli maxNum = ((cnt-1)/pl)*pl + a%b;

    LOG4(a,b,c,d);
    LOG2(maxNum,c);
    if(maxNum <= c){
        cout<<YES<<endl;
    }
    else{
        cout<<NO<<endl;
    }

}

int main(){
    // cout << fixed << setprecision(5);

    long long T;
    scanf("%lld",&T);
    for(int i = 0 ; i < T ; i++){
        lli a,b,c,d;
        cin>>a>>b>>c>>d;

        solve(a,b,c,d);
    }
    return 0;
}


Measured memory_bytes: 3568
N = int(input())
l = [0]*5
l1 = [[0,1,2],[0,1,3],[0,1,4],[0,2,3],[0,2,4],[0,3,4],
      [1,2,3],[1,2,4],[1,3,4],[2,3,4]]
ans = 0
for i in range(N):
  s = input()
  if s[0] == "M":
    l[0] += 1
  elif s[0] == "A":
    l[1] += 1
  elif s[0] == "R":
    l[2] += 1
  elif s[0] == "C":
    l[3] += 1
  elif s[0] == "H":
    l[4] += 1
for i in range(len(l1)):
  ans += l[l1[i][0]]*l[l1[i][1]]*l[l1[i][2]]
print(ans)

Measured memory_bytes: 3064
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int T[100050];
int N,C,K;
int main()
{
	scanf("%d%d%d",&N,&C,&K);
	for(int i=0;i<N;++i)
	{
		scanf("%d",&T[i]);
	}
	sort(T,T+N);
	int sum=1;
	int cnt=1;
	int st=T[0];
	for(int i=1;i<N;++i)
	{
		if(st+K<T[i])
		{
			sum++;
			cnt=1;
			st=T[i];
			continue;
		}
		if(st+K>=T[i])
		{
			cnt++;
			if(cnt>C)
			{
				cnt=1;
				sum++;
				st=T[i];
			}
		}
	}
	printf("%d",sum);
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
const int maxx = 1e5 + 7;
typedef long long ll;
const int Inf = 1 << 30;
const ll INF = 1ll << 60;
int n;
int a[105];
int sum;
int ans1, ans2;
int ans;

int main() {
	int ans = Inf;
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
		sum += a[i];
	}
	double aver = sum * 1.0 / n;
	int av1 = floor(aver);
	int av2 = av1 + 1;
	for(int i = 1; i <= n; i++) ans1 += (a[i] - av1) * (a[i] - av1);
	for(int i = 1; i <= n; i++) ans2 += (a[i] - av2) * (a[i] - av2);
	ans = min(ans1, ans2);
	printf("%d\n", ans);
	return 0;
}

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

int main() {
  int a = 0, z = 0, c = 0;
  string s;
  cin >> s;

  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'Z') {
      z = i;
    }
    if (!c) {
      if (s[i] == 'A') {
        a = i;
        c = 1;
      }
    }
  }
  cout<< z + 1 - a;
}


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

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

using namespace std;
using ll = long long;

int main(void)
{
  ll d, t, s;
  cin >> d >> t >> s;
  float res = d * 100 / s;
  cout << (res <= t * 100 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3556
#include"bits/stdc++.h"
using namespace std;

const long long MOD = 1e9 + 7;

void Main() {
  int S;
  cin >> S;

  vector<long long> ans(S + 1, 0);
  ans[0] = 1;
  for (int i = 3; i <= S; i++) {
    ans[i] = (ans[i - 1] + ans[i - 3]) % MOD;
  }
  cout << ans[S] << endl;
}

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


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

typedef long long ll; 
typedef pair<int, int> pii; 
typedef pair<ll, ll> pll; 
typedef pair<string, string> pss; 
typedef vector<int> vi; 
typedef vector<vi> vvi; 
typedef vector<pii> vii; 
typedef vector<ll> vl; 
typedef vector<vl> vvl; 

double EPS=1e-9; 
int INF=1000000005; 
long long INFF=1000000000000000005ll; 
double PI=acos(-1); 
int dirx[8]={ -1, 0, 0, 1, -1, -1, 1, 1 }; 
int diry[8]={ 0, 1, -1, 0, -1, 1, -1, 1 }; 
const ll MOD = 1000000007;

#define DEBUG fprintf(stderr, "====TESTING====\n") 
#define VALUE(x) cerr << "The value of " << #x << " is " << x << endl 
#define OUT(x) cout << x << endl 
#define debug(...) fprintf(stderr, __VA_ARGS__) 
#define READ(x) for(auto &(z):x) cin >> z;
#define FOR(a, b, c) for (int(a)=(b); (a) < (c); ++(a)) 
#define FORN(a, b, c) for (int(a)=(b); (a) <= (c); ++(a)) 
#define FORD(a, b, c) for (int(a)=(b); (a) >= (c); --(a)) 
#define FORSQ(a, b, c) for (int(a)=(b); (a) * (a) <= (c); ++(a)) 
#define FORC(a, b, c) for (char(a)=(b); (a) <= (c); ++(a)) 
#define EACH(a, b) for (auto&(a) : (b)) 
#define REP(i, n) FOR(i, 0, n) 
#define REPN(i, n) FORN(i, 1, n) 
#define Mp(a, b) a=mp(a, b) 
#define MIN(a, b) a=min(a, b) 
#define SQR(x) ((ll)(x) * (x)) 
#define RESET(a, b) memset(a, b, sizeof(a)) 
#define fi first 
#define se second 
#define mp make_pair 
#define pb push_back 
#define ALL(v) v.begin(), v.end() 
#define ALLA(arr, sz) arr, arr + sz 
#define SIZE(v) (int)v.size() 
#define SORT(v) sort(ALL(v)) 
#define REVERSE(v) reverse(ALL(v)) 
#define SORTA(arr, sz) sort(ALLA(arr, sz)) 
#define REVERSEA(arr, sz) reverse(ALLA(arr, sz)) 
#define PERMUTE next_permutation 
#define TC(t) while (t--) 
#define FAST_INP  ios_base::sync_with_stdio(false);cin.tie(NULL)


void solve() {

}

int main()  
{ 
    FAST_INP;
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r", stdin);
    freopen("output.txt","w", stdout);
    #endif
    
    // int tc; cin >> tc;
    // TC(tc) solve();
    ll x,k,d;
    cin >> x >> k >> d;
    ll p = abs(x);
    ll q = p / d;
    if (q < k) {
        ll y = p - q * d;
        k -= q;
        if (k % 2 == 1) {
            OUT(abs(y - d));
        } else {
            OUT(y);
        }
    } else {
        OUT(p - k * d);
    }
    return 0; 
} 

Measured memory_bytes: 3640
// Enjoy your stay.

#include <bits/stdc++.h>

#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(auto it=(X).begin();it!=(X).end();it++)
#define ite iterator
#define mp make_pair
#define mt make_tuple
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define sec second
#define sz(x) ((int)(x).size())

using namespace std;

typedef istringstream iss;
typedef long long ll;
typedef pair<ll,ll> pi;
typedef stringstream sst;
typedef vector<ll> vi;

int H,W;
char c[12][12];
map<int,int> dp[12][12];
int p7[12];
int lastBy=-1,lastBx;

int normalize(int s[12]){
	int conv[12]={};
	rep2(i,1,12)conv[i]=-1;
	int cur=1;
	rep(i,W){
		if(s[i]>0 && conv[s[i]]==-1){
			conv[s[i]]=cur++;
		}
	}
	rep(i,W)s[i]=conv[s[i]];
	return cur-1;
}

int f(int y,int x,int state){
	if(dp[y][x].find(state)!=dp[y][x].end()){
		return dp[y][x][state];
	}
	int& res=dp[y][x][state]=-INF;
	if(x==W){
		return res=f(y+1,0,state);
	}
	int s[12],s_[12];
	rep(i,W){
		s_[i]=state/p7[i]%7;
	}
	int ms = *max_element(s_,s_+W);
	if(y==H){
		return res = ms<=1 ? 0 : -INF;
	}
	
	if(c[y][x]!='.'){
		rep(i,W)s[i]=s_[i];
		if(!(x>=1 && s[x-1]!=0 && s[x-1]==s[x])){
			if((x==0 || s[x-1]==0) && s[x]==0){
				s[x]=ms+1;
			}
			else if((x==0 || s[x-1]==0) || s[x]==0){
				s[x]=max(x==0?0:s[x-1],s[x]);
			}
			else{
				int old1 = s[x-1], old2 = s[x];
				rep(i,W)if(s[i]==old1 || s[i]==old2){
					s[i]=min(old1,old2);
				}
			}
			normalize(s);
			int nstate=0;
			rep(i,W)nstate+=s[i]*p7[i];
			res=max(res,1+f(y,x+1,nstate));
		}
	}
	
	if(c[y][x]!='#'){
		rep(i,W)s[i]=s_[i];
		if(!(x>=1 && s[x-1]==0 || y>0 && s[x]==0)){
			s[x]=0;
			int nms=normalize(s);
			if(ms==1 && nms==0){
				if(y>lastBy || y==lastBy && x>lastBx){
					res=max(res,0);
				}
			}
			else if(ms == nms){
				int nstate=0;
				rep(i,W)nstate+=s[i]*p7[i];
				res=max(res,f(y,x+1,nstate));
			}
		}
	}
	//cout<<y<<" "<<x<<" "<<state<<": "<<res<<endl;
	return res;
}

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	
	cin>>H>>W;
	rep(i,H)rep(j,W){
		cin>>c[i][j];
		if(c[i][j]=='#')lastBy=i,lastBx=j;
	}
	p7[0]=1;
	rep(i,W)p7[i+1]=p7[i]*7;
	int res=f(0,0,0);
	cout<<(res<0 ? -1 : res)<<endl;
}

Measured memory_bytes: 15704
#include<bits/stdc++.h>
using namespace std;
int main() {
	int a,b,c;
	bool ans=0;
	cin>>a>>b>>c;
	if(a-b==b-c) ans=1;
	if(ans==0)cout<<"NO"<<endl;
	else cout<<"YES"<<endl;
	return 0;
}

Measured memory_bytes: 256