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

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;}


struct Precision{
  Precision(){
    cout<<fixed<<setprecision(12);
  }
}precision_beet;

//INSERT ABOVE HERE
signed main(){
  auto calc=[](vector<Int> v){
    Int n=v.size();
    const double PI = acos(-1);
    double res=0;
    sort(v.begin(),v.end());
    do{      
      v.emplace_back(v[0]);
      auto calc2=[&](double x){
	double res=0,tmp=0;
	Int p=0;
	for(Int i=0;i<n;i++)
	  if(v[p]*v[p+1]>v[i]*v[i+1]) p=i;
	for(Int i=0;i<n;i++){
	  double y=acos(v[p]*v[p+1]*cos(x)/(v[i]*v[i+1]));
	  res+=y;
	  tmp+=v[i]*v[i+1]*sin(y)/2;
	}
	return make_pair(res,tmp);
      };
      double l=0,r=PI;
      for(Int i=0;i<100;i++){
	double m=(l+r)/2;
	if(calc2(m).first<=2*PI) l=m;
	else r=m;
      }
      const double EPS = 1e-6;
      if(abs(2*PI-calc2(l).first)<EPS)
	chmax(res,calc2(l).second);
      v.pop_back();
    }while(next_permutation(v.begin(),v.end()));
    return res;
  };
  
  Int n;
  cin>>n;
  vector<Int> r(n);
  for(Int i=0;i<n;i++) cin>>r[i];
  double ans=0;
  for(Int b=1;b<(1<<n);b++){
    vector<Int> v;
    for(Int i=0;i<n;i++)
      if((b>>i)&1) v.emplace_back(r[i]);
    if(v.size()<3u) continue;
    chmax(ans,calc(v));
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 3684
#include<deque>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<cmath>
#include<cstdio>
#include<cstring>
using namespace std;
int fi(int c[][500],int x,int y,int n){
  int i;
  int d[500]={};
  priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > > e;
  e.push(make_pair(0,x));
  for(;;){
    int p,q;
    p=e.top().first;
    q=e.top().second;
    if(q==y)
      break;
    e.pop();
    if(d[q])
      continue;
    d[q]=-1;
    for(i=0;i<n;++i){
      if(c[q][i]&&!d[i])
	e.push(make_pair(p+c[q][i],i));
    }
  }
  return e.top().first;
}
int main(){
  int i;
  int n,m;
  while(scanf("%d%d",&n,&m),n||m){
    char s[3][21];
    scanf("%s%s%s",s[0],s[1],s[2]);
    char t[5000][2][21];
    int a[5000];
    set<string> u;
    for(i=0;i<m;++i){
      int p,q;
      scanf("%s%s%d%d",t[i][0],t[i][1],&p,&q);
      a[i]=p/40+q;
      u.insert(t[i][0]);
      u.insert(t[i][1]);
    }
    int b[3];
    for(i=0;i<3;++i)
      b[i]=distance(u.begin(),u.find(s[i]));
    int c[500][500]={};
    for(i=0;i<m;++i){
      int p,q;
      p=distance(u.begin(),u.find(t[i][0]));
      q=distance(u.begin(),u.find(t[i][1]));
      c[p][q]=c[q][p]=a[i];
    }
    printf("%d\n",fi(c,b[0],b[1],n)+fi(c,b[1],b[2],n));
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main() {
    int k,s,z=0,t=0;
    cin>>k>>s;
    for (int x = 0; x <=k ; ++x) {
        for (int y = 0; y <=k ; ++y) {
             z=s-(x+y);
             if(z>=0){
           if(z<=k){
               t++;
           }
             }
        }
    }
    printf("%d",t);
    return 0;
}


Measured memory_bytes: 256
parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1})=map(parseInt,x)

function main()
	n = readline() |> parseInt
	r = 0
	while 2^r<n
		r += 1
	end
	if 2^r == n
		println("No")
	else
		println("Yes")
		println("1 2")
		for i in 2:2:n-1
			println(i, " ", i+1)
			println(i+1, " ",n+1)
			println(n+1, " ", n+i)
			println(n+i, " ", n+i+1)
		end
		if n%2 == 0
			println(n+1-2^(r-1), " ", n)
			println(n+2^(r-1), " ", 2*n)
		end
	end
end

main()

Measured memory_bytes: 155032
#include<stdio.h>
#include<vector>
#include<deque>
using namespace std;

#define FOR(i,l,r) for(int i = (int) (l);i < (int) (r);i++)
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

ll N;

int main()
{
	scanf("%lld",&N);
	N++;

	vector<int> ans;
	deque<bool> d;
	{
		ll c = N;
		while(c > 1){
			if(c & 1){
				d.push_back(true);
				ans.push_back(int(ans.size()) + 1);
			}
			d.push_back(false);
			ans.push_back(int(ans.size()) + 1);
			c >>= 1;
		}
	}

	FOR(i,0,d.size()) if(d [i] == false){
		ans.push_back(i + 1);
	}
	for(int i = int(d.size()) - 1;i >= 0;i--) if(d [i]){
		ans.push_back(i + 1);
	}

	printf("%lu\n",ans.size());
	FOR(i,0,ans.size()){
		printf("%d%s",ans [i],i == ans.size() - 1 ? "\n" : " ");
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int a[n+1];
    int b[n+1];
    int c[n];
    for(int i = 1; i <= n; i++)cin >> a[i];
    for(int i = 1; i <= n; i++)cin >> b[i];
    for(int i = 1; i < n; i++)cin >> c[i];

    int curr = a[1],tot = b[a[1]];

    for(int i = 2; i <= n; i++){
          //  cout << tot << "  loop" << endl;
        if(a[i] - curr == 1){
            tot += b[a[i]];
            tot += c[a[i]-1];
            curr = a[i];
        }
        else{
            tot += b[a[i]];
            curr = a[i];
        }
    }
    cout << tot << endl;

    return 0;
}



Measured memory_bytes: 256
h, w = gets.split.map(&:to_i)
a = (1..h).map{ gets.chomp.split("").map{|c| c == 'c' ? 0 : -1} }
(0..h-1).each{|i|
    (1..w-1).each{|j|
        a[i][j] = a[i][j-1] + 1 if a[i][j] < 0 && a[i][j-1] >= 0
    }
}
a.each{|row| puts row.join(" ")}

Measured memory_bytes: 6132
def abs(a):
	if a<0:
		return -a
	return a
x,k,d=map(int,input().split())
if x==0:
	if k%2==1:
		print(d)
	else:
		print(0)
if x>0:
	if k*d<=x:
		print(x-k*d)
		exit(0)
	r=x%d
	steps=(x-r)//d
	l=abs(r-d)

	if((k-steps)%2==0):
		print(r)
	else:
		print(l)
if x<0:
	if k*d<=abs(x):
		print(abs(x+k*d))
		exit(0)
	l=abs(x)%d
	steps=(abs(x)-abs(l))/d
	r=-l+d

	if (k-steps)%2==0:
		print(l)
	else:
		print(r)

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

int main()
{
    int m,f,r;
    while(cin>>m>>f>>r)
    {
        if(m==-1&&f==-1&&r==-1)break;
        else if(m==-1||f==-1)cout<<'F'<<endl;
        else if(m+f>=80)cout<<'A'<<endl;
        else if(m+f>=65)cout<<'B'<<endl;
        else if(m+f>=50)cout<<'C'<<endl;
        else if(m+f>=30&&r>=50)cout<<'C'<<endl;
        else if(m+f>=30&&r<50)cout<<'D'<<endl;
        else cout<<'F'<<endl;
    }
}




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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	string a, b;
	cin >> a >> b;
	int sz_a = a.size();
	int sz_b = b.size();
	int dp[sz_a + 1][sz_b + 1];
	for (int i = 0; i <= sz_a; i++) dp[i][0] = 0;
	for (int i = 0; i <= sz_b; i++) dp[0][i] = 0;
	for (int i = 1; i <= sz_a; i++) {
		for (int j = 1; j <= sz_b; j++) {
			if (a[i - 1] == b[j - 1]) {
				dp[i][j] = 1 + dp[i - 1][j - 1];
			} else {
				dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
			}
		}
	}
	string answer = "";
	int i = sz_a;
	int j = sz_b;
	while (dp[i][j] != 0) {
		if (dp[i][j] == dp[i][j - 1]) {
			j--;
		} else {
			if (dp[i][j] == dp[i - 1][j]) {
				i--;
			} else {
				answer += a[i - 1];
				i--;
				j--;
			}
		}
	}
	reverse(answer.begin(), answer.end());
	cout << answer << endl;
	return 0;
}

Measured memory_bytes: 35456
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

using ll = long long;
using namespace std;
ll mod = 1'000'000'007;

const int INF = 1'050'000'000;

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    cout << min(A, B) + min(C, D) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int64_t> xs(n);
    for (auto& x : xs)
    {
        cin >> x;
    }

    vector<pair<int64_t, int64_t>> ps;
    for (int i = 0; i < n; i++)
    {
        ps.emplace_back(xs[i], i);
    }
    sort(ps.begin(), ps.end());

    vector<int64_t> is(n);
    for (int i = 0; i < n; i++)
    {
        is[ps[i].second] = i;
    }

    for (int i = 0; i < n; i++)
    {
        if (is[i] < n / 2)
        {
            cout << ps[n / 2].first << endl;
        }
        else
        {
            cout << ps[n / 2 - 1].first << endl;
        }
    }
}


Measured memory_bytes: 9196
n = int(input())
dD = input().split()
m = int(input())
dT = input().split()
d = dict()

for di in dD:
    if di in d:
        d[di] += 1
    else:
        d[di] = 1

ans = 'YES'
for ti in dT:
    if ti not in d or d[ti]==0:
        ans = 'NO'
        break
    else:
        d[ti] -= 1
print(ans)

Measured memory_bytes: 53604
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN = 40000;

typedef struct L { int a, b, c; } L;
bool operator<(const L &p, const L &q) { return -p.a *q.b < -q.a *p.b; }

int n;
L lines[MAXN];

// if slope[i]<slope[j] and y[i]<=y[j] they have already crossed

pair<double, int> lst[MAXN];
int bit[MAXN + 1];
int bget(int idx) { ++idx; int ret = 0;  while (idx <= n) { ret += bit[idx]; idx += idx&-idx; } return ret; }
void bmod(int idx) { ++idx; while (idx > 0) { bit[idx]++; idx -= idx&-idx; } }

int calc(double x) {
	REP(i, n) lst[i] = MP((lines[i].c - x*lines[i].a) / lines[i].b, i);
	sort(lst, lst + n);
	FORE(i, 1, n) bit[i] = 0;
	int ret = 0;
	for (int i = n - 1; i >= 0; --i) {
		ret += bget(lst[i].second);
		bmod(lst[i].second);
	}
	//printf("%lf=%d\n", x, ret);
	return ret;
}

double solve() {
	REP(i, n) if (lines[i].b < 0) lines[i].a = -lines[i].a, lines[i].b = -lines[i].b, lines[i].c = -lines[i].c;
	sort(lines, lines + n);
	//REP(i, n) printf("%d*x+%d*y=%d\n", lines[i].a, lines[i].b, lines[i].c);
	int ntot = n*(n - 1) / 2, nlft = (ntot + 1) / 2;
	double lx = -1; while (calc(lx) >= nlft) lx *= 2;
	double hx = +1; while (calc(hx) < nlft) hx *= 2;
	REP(rep, 100) {
		double mx = (lx + hx) / 2;
		if (calc(mx) < nlft) lx = mx; else hx = mx;
	}
	return (lx + hx) / 2;
}

void run() {
	scanf("%d", &n);
	REP(i, n) scanf("%d%d%d", &lines[i].a, &lines[i].b, &lines[i].c);
	double x = solve();
	REP(i, n) swap(lines[i].a, lines[i].b);
	double y = solve();
	printf("%.15lf %.15lf\n", x, y);
}

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


Measured memory_bytes: 1536
import java.util.Scanner;
import java.util.Arrays;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int[] v=new int[n];
		for(int i=0; i<n; i++){
			v[i]=sc.nextInt();
		}
		int[] zero=new int[100001];
		int[] one=new int[100001];
		for(int i=0; i<n; i++){
			if(i%2==0){
				zero[v[i]]++;
			}else{
				one[v[i]]++;
			}
		}
		int zerom=0;
		int z=0;
		int onem=0;
		int o=0;
		for(int i=0; i<100001; i++){
			if(zerom<zero[i]){
				z=i;
				zerom=zero[i];
			}
			if(onem<one[i]){
				o=i;
				onem=one[i];
			}
		}
		if(z==o){
			int z2=0;
			int o2=0;
			for(int i=0; i<100001; i++){
				if(i!=z && z2<zero[i]){
					z2=zero[i];
				}
				if(i!=o && o2<one[i]){
					o2=one[i];
				}
			}
			int k=Math.max(z2,o2);
			System.out.println(n-zerom-k);
		}else{
			System.out.println(n-zerom-onem);
		}
	}
}


Measured memory_bytes: 50176
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<vector>
#include<string>
using namespace std;
typedef long long llong;
typedef unsigned long long ullong;

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

llong lcm(llong a, llong b) {
	llong g = gcd(a, b);
	return a * b / g;
}

int N, M, k[10], s[10][10], p[10], ans = 0;

int main() {
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		cin >> k[i];
		for (int j = 0; j < k[i]; j++) {
			cin >> s[i][j];
		}
	}
	for (int i = 0; i < M; i++) {
		cin >> p[i];
	}

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

		bool switchAllOn = true;

		for (int i = 0; i < M; i++) {

			int numOfOnSwitch = 0;

			for (int j = 0; j < k[i]; j++) {
				
				if (bit & 1 << (s[i][j] - 1)) {
					numOfOnSwitch++;
				}
			}

			if (numOfOnSwitch % 2 != p[i]) {
				switchAllOn = false;
				break;
			}
		}

		if (switchAllOn) {
			ans++;
		}
	}

	cout << ans;
	
	return 0;
}

Measured memory_bytes: 256
s = int(input())
def f(n):
    if n % 2 == 0: return n//2
    else: return 3*n+1

a = []
a.append(s)
i = 1
while True:
    now = f(a[i-1])
    if now in a:
        print(i+1)
        break
    else:
        a.append(now)
        i += 1

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

int main(){
  int n, k;
  string s;
  
  cin >> n >> k >> s;
  k -= 1;
  if(s[k] == 'A') s[k] = 'a';
  if(s[k] == 'B') s[k] = 'b';
  if(s[k] == 'C') s[k] = 'c';
  
  cout << s << endl;
}

Measured memory_bytes: 256
def ceil(i):
    if int(i) == i:
        return i
    else:
        return int(i)+1


N = int(input())
D, X = map(int, input().split())
L = []
ans = 0
for _ in range(N):
    x = int(input())
    ans += ceil(D / x)
print(int(ans+X))


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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define ALL(v) v.begin(), v.end()
#define CHMIN(x,y) x = min(x, y)
#define CHMAX(x,y) x = max(x, y)

template<int mod> struct ModInt {
    int64_t x;
    ModInt() : x(0) {}
    ModInt(int64_t y) : x(y >= 0 ? y % mod : (y % mod + mod) % mod) {}

    ModInt &operator+=(const ModInt &a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }

    ModInt &operator-=(const ModInt &a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }

    ModInt &operator*=(const ModInt &a) {
        x = 1LL * x * a.x % mod;
        return *this;
    }

    ModInt &operator/=(const ModInt &a) {
        *this *= a.inverse();
        return *this;
    }

    ModInt operator-() const {
        return ModInt(-x);
    }

    ModInt operator+(const ModInt a) const {
        return ModInt(*this) += a;
    }

    ModInt operator-(const ModInt a) const {
        return ModInt(*this) -= a;
    }

    ModInt operator*(const ModInt a) const {
        return ModInt(*this) *= a;
    }

    ModInt operator/(const ModInt a) const {
        return ModInt(*this) /= a;
    }

    bool operator==(const ModInt a) const {
        return x == a.x;
    }

    bool operator!=(const ModInt a) const {
        return x != a.x;
    }

    ModInt pow(int64_t k) const {
        ModInt ret(1), mul(x);
        while (k > 0) {
            if (k & 1) ret *= mul;
            mul *= mul;
            k >>= 1;
        }
        return ret;
    }

    ModInt inverse() const {
        return pow(mod - 2);
    }

    friend ostream &operator<<(ostream &os, const ModInt &p) {
        return os << p.x;
    }

    friend istream &operator>>(istream &is, ModInt &a) {
        int64_t t;
        is >> t;
        a = ModInt<mod>(t);
        return (is);
    }
};

const int MOD = 1e9+7;
const int MAX = 1e5+10;

using modint = ModInt<MOD>;

modint fact[MAX];

int N;
int X[MAX];

int solve() {
    fact[0] = modint(1);
    FOR (i, 1, MAX) fact[i] = fact[i-1] * modint(i);

    modint ans(0), s(0);
    FOR (k, 1, N) {
        modint d(X[k] - X[k-1]);
        s += modint(k).inverse();
        ans += d * s;
    }
    ans *= fact[N-1];
    return ans.x;
}

int main() {
    cin >> N;
    REP (i, N) cin >> X[i];
    cout << solve() << endl;
}

Measured memory_bytes: 1408
h, w = map(int, input().split())
grid = [['x'] + [str(c) for c in str(input())] + ['x'] for i in range(h)]
grid = [['x'] * (w+2)] + grid + [['x'] * (w+2)]
#print(grid)
ans = [[None for j in range(w+2)] for i in range(h+2)]
#print(ans)
for i in range(1, h+1):
  for j in range(1, w+1):
    if grid[i][j] == '#':
      ans[i][j] = '#'
      continue
    else:
      tmp = 0
      for k in range(i-1, i+2):
        tmp += grid[k][j-1:j+2].count('#')
      ans[i][j] = tmp
#print(ans)
for i in range(1, h+1):
  print(''.join([str(a) for a in ans[i][1:w+1]]))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 100005
#define tc printf("Case %d: ", cs)
#define tcn printf("Case %d:\n", cs);
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);

#define dbg1(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;
#define dbg4(w,x, y, z) cerr << #w << " = " << w << ", " <<#x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;

template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
  return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
  os << "{";
  for (auto it = v.begin(); it != v.end(); ++it) {
    if ( it != v.begin() ) os << ", ";
    os << *it;
  }
  return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
  os << "[";
  for (auto it = v.begin(); it != v.end(); ++it) {
    if ( it != v.begin()) os << ", ";
    os << *it;
  }
  return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
  os << "[";
  for (auto it = v.begin(); it != v.end(); ++it) {
    if ( it != v.begin() ) os << ", ";
    os << it -> first << " = " << it -> second ;
  }
  return os << "]";
}

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)

clock_t tStart = clock();
#define timeStamp dbg("Execution Time: ", (double)(clock() - tStart)/CLOCKS_PER_SEC)

void faltu () { cerr << endl; }

template <typename T>
void faltu( T a[], int n ) {
  for (int i = 0; i < n; ++i) cerr << a[i] << ' ';
  cerr << endl;
}

template <typename T, typename ... hello>
void faltu( T arg, const hello &... rest) { cerr << arg << ' '; faltu(rest...); }
// Program showing a policy-based data structure.
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less 
#include <iostream>
using namespace __gnu_pbds;
using namespace std;
// GNU link : https://goo.gl/WVDL6g
typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;

/**___________________________________________________**/

typedef long double ld;

int main()
{
  FASTIO
  /*
#ifndef ONLINE_JUDGE
  freopen("in.txt", "r", stdin);
  freopen("out.txt", "w", stdout);
  freopen("error.txt", "w", stderr);
#endif
//*/
  long double a, b, x;
  cin >> a >> b >> x;
  if (x * 2 > a * a * b) {
    x = a * a * b - x;
    cout << setprecision(20) << (long double) 90 / (long double) asin(1) * atan(x / a / a / a * 2) << endl;
  }
  else {
    ld val = x / a / b / b; val *= 2;
    val = atan(val);
    ld PI = asin(1) * 2;
    val *= 90;
    val /= PI / 2;
    val = 90 - val;
    cout << setprecision(20) << val;
  }
}

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

using namespace std;
#define all(a)a.begin(),a.end()
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod = int(1e9)+7;
using V = vector<int>;
using P = pair<int,int>;

int main()
{
    int k,s;cin >>k>>s;
    int ans=0;
    rep(x,k+1)rep(y,k+1){
        int z=s-(x+y);
        if(z<0||z>k)continue;
        ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>
#include<utility>
#include<numeric>

#define PB push_back
#define all(a)  (a).begin(),(a).end()
#define ALL(v) begin(v), end(v)
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)
#define V vector<int>
#define VV vector<V>
#define VVV vector<VV>

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int inf = (int)1e9;
const ll INF = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };
const long double EPS = 1e-10;

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

	cout << max(a * 10 + b + c, max(a + b * 10 + c, a + b + c * 10)) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    int n;
    cin >> n;
    int a[n],b[n];
    REP(i,n){
        cin >> a[i];
    }
    REP(i,n){
        cin >> b[i];
    }
    int ans = 0;
    ll sum = 0;
    vector<int> vec;
    REP(i,n){
        if(a[i] < b[i]){
            ans++;
            sum += b[i] - a[i];
        }else{
            vec.push_back(a[i] - b[i]);
        }
    }
    if(sum == 0){
        cout << 0 << endl;
        return 0;
    }
    sort(ALL(vec));
    reverse(ALL(vec));
    REP(i,vec.size()){
        sum -= vec[i];
        ans++;
        if(sum <= 0){
            break;
        }
    }
    if(sum > 0){
        cout << -1 << endl;
    }else{
        cout << ans << endl;
    }
}

Measured memory_bytes: 1660
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#define INF 10000000000000000
#define ll long long

using namespace std;



int main(){
  ll n,q;
  cin >> n >> q;
  ll i = n;
  for(ll k = 0; k < 5; k++){
    i |= (i >> (1 << k));
  }
  i++;

  ll tree[i+1];

  for(ll k = 0; k <= i; k++){
    tree[k] = 0;
  }
  
  for(ll k = 0; k < q; k++){
    ll com,x,y;
    cin >> com >> x >> y;
    if(com == 0){
      while(x <= i){
	tree[x] += y;
	x += (x & -x);
      }
    }else{
      ll ret = 0;
      x--;
      while(x){
	ret += tree[x];
	x -= (x & -x);
      }

      while(y){
	ret -= tree[y];
	y -= (y & -y);
      }
      cout << -ret << endl;
    }

  }

}

Measured memory_bytes: 4124
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
#define DEBUG(x) cout<<#x<<"="<<x<<endl
#define DEBUG2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
typedef long long ll;
// #define LOCAL
const ll MOD=1e9+7;
const int MAXN=2e5+10;
int N,K;
ll pre[MAXN];
void solve()
{
    cin>>N>>K;
    if(K==N+1){
        cout<<1;
        return;
    }
    for(int u=1;u<=N;u++)pre[u]=pre[u-1]+u;
    ll ans=1;
    for(int v=K;v<=N;v++){
        ans=(ans+pre[N]-pre[N-v]-pre[v-1]+1)%MOD;
    }
    cout<<ans;
}
int main()
{
#ifdef LOCAL
    freopen("in.txt","r",stdin);
#endif
    solve();
}

Measured memory_bytes: 5116
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n,m;
    cin >> n >> m;
    pair<int, int> pary[n];
    rep(i,n)
    {
        int a,b;
        cin >> a >> b;
        pary[i].first = a;
        pary[i].second = b;
    }

    priority_queue<int> que;
    sort(pary, pary+n);
    int j = m;
    int i = 0;
    ll ans = 0;
    while (true)
    {
        // j_nitime
        // cout << j << "nitime" << endl;
        while(true)
        {
            if (pary[i].first + j > m) {
                // cout << "break" << endl;
                // cout << "now i is " << i << endl;
                break;
            }
            else
            {
                que.push(pary[i].second);
                i++;
                // cout << "push" << endl;
            }
        }
        if (!que.empty())
        {
            ans += que.top();
            que.pop();
        }
        j--;
        if (j < 0) break;
        // cout << "now ans is " << ans << endl;
    }
    cout << ans << endl;
}


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

int main() {
  const string SHARP = "#";
  const string DOT = ".";
  vector <vector<int>> datas;
  while (true) {
    int H, W;
    cin >> H >> W;
    if (H == 0 && W == 0) {
      break;
    }
    vector<int> hw = { H, W };
    datas.push_back(hw);
  }

  for (int i = 0; i < (int)datas.size(); i++) {
    for (int j = 0; j < datas[i][0]; j++) {
      for (int k = 0; k < datas[i][1]; k++) {
        bool is_edge_row = j == 0 || j == datas[i][0] - 1;
        bool is_edge_column = k == 0 || k == datas[i][1] - 1;
        if (is_edge_row || is_edge_column) {
          cout << SHARP;
        } else {
          cout << DOT;
        }
      }
      cout << endl;
    }
    cout << endl;
  }
}


Measured memory_bytes: 3184
n,d=map(int,input().split())
x=[list(map(int,input().split())) for i in range(n)]
def l1(a,b,d):
    s=0
    for i in range(d):
        s+=(a[i]-b[i])**2
    return s**0.5
cnt=0
for i in range(n):
    for j in range(i,n):
        #print(i,j)
        if l1(x[i],x[j],d)!=0 and l1(x[i],x[j],d)%1==0:
            cnt+=1
print(cnt)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

ll binomialCoeff(ll n, ll k) 
{ 
    ll C[k+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1;  // nC0 is 1 
  
    for (ll i = 1; i <= n; i++) 
    { 
        // Compute next row of pascal triangle using 
        // the previous row 
        for (ll j = min(i, k); j > 0; j--) 
            C[j] = C[j] + C[j-1]; 
    } 
    return C[k]; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=nxt();
    int x=sqrt(n);
    cout<<x*x<<endl;
    
    
    return 0;   
}




 
 


Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n')
var [N, M] = input[0].split(' ').map(Number)
var H = input[1].split(' ').map(Number)
var isHighest = new Array(N).fill(true)

for (var i=0; i<M; i++) {
  var [A, B] = input[i+2].split(' ').map(v => Number(v-1))
  if (H[A] < H[B]) {
    isHighest[A] = false
  }
  else if (H[B] < H[A]) {
    isHighest[B] = false
  }
  else {
    isHighest[A] = isHighest[B] = false
  }
}
console.log(isHighest.filter(v => v).length)


Measured memory_bytes: 61476
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
void READ()
{
#define R READ();
#define INFI 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define mem0(x) memset(x,0,sizeof(x))
#define prln(x) cout<<#x<<"="<<x<<endl;
#ifndef ONLINE_JUDGE
    freopen("A.in","r",stdin);
#endif
    std::ios::sync_with_stdio(0);
    cin.tie(0);
    cout<<fixed<<setprecision(11);
}
///////////////////////////
const int N=5+    1e6;

long long  n,k,ans,ans1,ans2,num;
int main()
{
    
    cin>>n>>k;
    if(k==0){cout<<n*n;return 0;}
    for(int b=k+1;b<=n;b++)
    {
       // prln(b);
        num=(n+1)/b;
        ans1=(b-k)*(num);
        ans2=max(0ll,n+1-(k+(num)*b));
        ans+=ans1+ans2;
       // prln(ans1);prln(ans2);
    }
    cout<<ans;

    return 0;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
main()
{ int  s=0;
  int x[10]={0,0,0,0,0,0,0,0,0,0};
  int t[3]={0,0,0};
  for(int i=0;i<10;i++){
    cin>>x[i];
  }

  for(int k=0;k<3;k++){
    for(int j=0;j<10;j++){
      if(t[k]<x[j]){
        s=t[k];
        t[k]=x[j];
        x[j]=s;
       }
     }
  }
  for(int e=0;e<3;e++){
    cout<<t[e]<<endl;
  }
return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;

int main(){
    ll n;
    cin>>n;
    vector<ll> l(n);
    for(ll i=0;i<n;i++){
        cin>>l[i];
    }
    ll ans=0;
    for(ll i=0;i<n-2;i++){
        for(ll j=i+1;j<n-1;j++){
            for(ll k=j+1;k<n;k++){
                if(l[i]<l[j]+l[k] && l[i]>abs(l[k]-l[j]) && l[i]!=l[j] && l[j]!=l[k] && l[k]!=l[i]){
                    ans++;
                    //cout<<i<<j<<k<<endl;
                }
            }
        }
    }
    cout<<ans<<endl;
}

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

int main() {
	int a, b, c;
	cin >> a >> b >>c;
	string ans;
	if (a + b + c >= 22){
		ans = "bust";
	}
	else{
		ans = "win";
	}
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3596
nm = gets.chomp.to_i#split(" ").map(&:to_i)
a = gets.chomp.split("")#.reverse
#s = a.reverse
t = gets.chomp.split("")#.reverse

match = 0

for i in 0..t.size
  break if a[i..-1] == t[0..-1-i]
  match += 1
end

#if a==t
#p [nm, a.size].min
#else
p [nm ,a.size + t.size - (nm -match)].max
#end


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=100009;
ll cost[N],h[N];

int main(){

    ll n,i,a,b,k,mn;
    scanf("%lld %lld",&n,&k);
    for(int i=1; i<=n; i++){
        scanf("%lld",&h[i]);
    }

    for(i=n-1; i>=1; i--){
        mn=1e18;
        for(int j=1; j<=k; j++)
        {
            if(i+j<=n){
                a=fabs(h[i]-h[i+j])+cost[i+j];
                mn=min(a,mn);
            }
        }
        cost[i]=mn;
    }
    printf("%lld\n",cost[1]);
}

Measured memory_bytes: 5336
double M[12][4096],r,t;D[12],n;
double dfs(p,f){if(M[p][f]<0){
int i=0;
for(M[p][f]=0;i<n;i++)if(!(f&1<<i)&&(t=dfs(i,f|1<<i)+D[p]+D[i]-2*sqrt(D[p]*D[i]),M[p][f]<t))M[p][f]=t;
}return M[p][f];}
main(l,i,j,d){for(;~scanf("%d",&l);puts(d-r<=l?"OK":"NA")){
for(d=n=0;getchar()!='\n';d+=D[n++]*2)scanf("%d",D+n);
for(i=0;i<n;i++)for(j=0;j<1<<n;j++)M[i][j]=-1;
for(r=i=0;i<n;i++)if(t=dfs(i,1<<i),r<t)r=t;
}exit(0);}

Measured memory_bytes: 968
//Same Integers

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define irep(i,a) for(auto i = a.begin(); i != a.end(); ++i)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
template<class T>inline bool chmin(T& a,T b,bool f){
if(f==1){if(a>b){a=b;return true;}return false;}
else if(f==0){if(a<b){a=b;return true;}return false;}return false;}
typedef pair<int,string> p;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

int main (){
    vector<int>t(3);cin>>t[0]>>t[1]>>t[2];
    sort(range(t));
    if((t[1]-t[0])%2==0){
        cout<<(t[2]-t[1]+t[2]-t[0])/2<<nnn;
    }else{
        cout<<(t[2]-t[1]+t[2]-t[0])/2+2<<nnn;
    }
    
}

Measured memory_bytes: 256
def getlist():
	return list(map(int, input().split()))

N, K, Q = getlist()

point = [(K - Q) for i in range(N)]
for i in range(Q):
	A = int(input())
	point[A - 1] += 1

for i in range(N):
	if point[i] > 0:
		print("Yes")
	else:
		print("No")

Measured memory_bytes: 7856
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int main() {
    ll n;
    cin>>n;
    vector<ll> a(n);
    ll k=0;

    rep(i,n){cin>>a[i];if(a[i]<0)k++;}
    if(k%2==0){
        ll ans=0;
        rep(i,n){ans+=abs(a[i]);}
        cout<<ans<<endl;
    }else{
        ll ans=0;
        ll c=MOD;
        rep(i,n){if(abs(a[i])<c)c=abs(a[i]);}
        rep(i,n){
            ans+=abs(a[i]);
        }
        ans-=2*c;
        cout<<ans<<endl;
    }




    return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        long A = sc.nextLong();
        long B = sc.nextLong();
        long K = sc.nextLong();
        if(A-K>=0){
            System.out.println(A-K + " " + B);
        }else if(A+B-K<0){
            System.out.println("0 0");
        }else{
            System.out.println("0 " + (A+B-K));
        }

    }

}


Measured memory_bytes: 24020
c11,c12,c13=map(int,input().split(' '))
c21,c22,c23=map(int,input().split(' '))
c31,c32,c33=map(int,input().split(' '))
print('Yes') if c21-c11 == c22-c12 == c23-c13 and c31-c21 == c32-c22 == c33-c23 else print('No')


Measured memory_bytes: 2940
N = int(input())
a = []

for i in range(N):
    s,p = input().split()
    a.append([s,int(p),i+1])

b = sorted(a,key=lambda x: x[1], reverse=True)
c = sorted(b,key=lambda x: x[0])

for i in c:
    print(i[2])

Measured memory_bytes: 38256
#include <bits/stdc++.h>
typedef long long ll;
#define MOD 1000000007
#define INF -99999999 
using namespace std;
 
int main()
{
    int H,W; cin >> H >> W;
    char S[H][W];
    for (int i = 0; i < H; i++)
    {
        string s; cin >> s;
        for (int j = 0; j < W; j++)
        {
            S[i][j] = s[j];
        }
        
    }
    
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            if(S[i][j] == '#') continue;
            int cnt = 0;
            for (int dy = -1; dy < 2; dy++)
            {   
                for (int dx = -1; dx < 2; dx++)
                {
                    if(i+dy < 0 or i+dy >= H or j+dx < 0 or j+dx >= W) continue;
                    else if(S[i+dy][j+dx] == '#') cnt++;
                }
            }
            S[i][j] = char(cnt + '0');
        }
    }
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            cout << S[i][j];
        }
        cout << endl;
    }
    
}

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

int main() {
	
	string s; cin >> s;
	string d = "dream";
	string e = "erase";
	string er = "eraser";
	string der = "dreamer";	

	reverse(s.begin(), s.end());
	reverse(d.begin(), d.end());
	reverse(e.begin(), e.end());
	reverse(er.begin(), er.end());
	reverse(der.begin(), der.end());

	int n = s.size();
	int index = 0;
	bool can = true;
	while (s != "") {
		
		string  tmp_s_5;
		string  tmp_s_6;
		string  tmp_s_7;

		if (d.size() <= s.size()) {
			tmp_s_5 = s.substr(index, d.size());
		}
		if (er.size() <= s.size()) {
			tmp_s_6 = s.substr(index, er.size());
		}
		if (der.size() <= s.size()) {
			tmp_s_7 = s.substr(index, der.size());
		}

		if (tmp_s_5 == d || tmp_s_5 == e) {
			s = s.substr(index + d.size());
		}
		else if (tmp_s_6 == er) {
			s = s.substr(index + er.size());
		}
		else if (tmp_s_7 == der) {
			s = s.substr(index + der.size());
		}
		else {
			can = false;
			break;
		}
	}

	if (can) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 512
#!/usr/bin/env python3

s = input()
ans = []

def dfs(i, n, ns):
    if i == 3:
        if n == 7:
            ans.append(ns + '=7')
            return 
        else:
            return

    dfs(i+1, n + int(s[i+1]), ns + '+' + s[i+1])
    dfs(i+1, n - int(s[i+1]), ns + '-' + s[i+1]) 


dfs(0, int(s[0]), s[0])
print(ans[0])

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define M_PI 3.14159265358979323846

using namespace std;

const int ms = 1e5 + 17;
const int mod = 1e9 + 7;

void solve()
{
    long long a, b, c, d;
    cin >> a >> b >> c >> d;


    if(d < b || a < b)
        cout << "No\n";
    else
    {
        if(c + 1 >= b)
            cout << "Yes\n";
        else
        {
            long long v = a % b;

            d %= b;

            long long gcd = __gcd(b, d);

            if(gcd == 1)
                cout << "No\n";
            else
            {
                long long v1 = v % gcd;

                long long ans = b - gcd + v1;

              //  cout << gcd << ' ' << v << ' ' << v1 << ' ' << ans << '\n';

                if(ans > c)
                    cout << "No\n";
                else
                    cout << "Yes\n";
            }
        }


    }
}


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

    int t;
    cin >> t;

    for(int i = 1; i <= t; ++i)
    {
        solve();
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

#define EPS 1e-9
#define INF MOD
#define MOD 1000000007LL
#define fir first
#define iss istringstream
#define sst stringstream
#define ite iterator
#define ll long long
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define pi pair<int,int>
#define pb push_back
#define sec second
#define sh(i) (1LL<<i)
#define sz size()
#define vi vector<int>
#define vc vector
#define vl vector<ll>
#define vs vector<string>

int h,w,c,P[9][9],p[9][9],a,dy[]={0,1,0,-1},dx[]={1,0,-1,0},X;

void f(int y,int x,int b,int C){
	if(p[y][x]==C)return;
	p[y][x]=C;
	rep(i,4){
		int ny=y+dy[i],nx=x+dx[i];
		if(0<=ny&&ny<h&&0<=nx&&nx<w&&p[ny][nx]==b)f(ny,nx,b,C);
	}
}

void g(int y,int x){
	X++;
	p[y][x]=-1;
	rep(i,4){
		int ny=y+dy[i],nx=x+dx[i];
		if(0<=ny&&ny<h&&0<=nx&&nx<w&&p[ny][nx]==c)g(ny,nx);
	}
}

int main(){
	while(cin>>h>>w>>c,h){
		c--;
		rep(i,h)rep(j,w)cin>>P[i][j],P[i][j]--;
		a=0;
		rep(i,6)rep(j,6)rep(k,6)rep(l,6){
			rep(m,h)rep(n,w)p[m][n]=P[m][n];
			f(0,0,p[0][0],i),f(0,0,p[0][0],j),f(0,0,p[0][0],k),f(0,0,p[0][0],l),f(0,0,p[0][0],c);
			X=0;
			g(0,0);
			a=max(a,X);
		}
		cout<<a<<endl;
	}
}

Measured memory_bytes: 868
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  string s;
  cin >> s;
  cout << s.substr(0, 3) << endl;
  return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

#define Endl endl


/*--------------------template--------------------*/


int main()
{
	cin >> n;
	vi v(n), a;
	REP(i, n) cin >> v[i];
	sort(RALL(v));
	REP(i, n - 1)
	{
		if (v[i] == v[i + 1]) {
			a.push_back(v[i]);
			i++;
		}
	}
	if (a.size() == 1 || a.size() == 0) {
		cout << 0 << endl;
	} else {
		cout << a[0] * a[1] << endl;
	}
}

Measured memory_bytes: 1660
#include <iostream>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

const double INF = 1e10;

int main(){
	int n;
	while(cin>>n,n){
		vector<double> x(n),y(n),z(n),r(n);
		for(int i=0;i<n;++i){
			cin>>x[i]>>y[i]>>z[i]>>r[i];
		}
		double edge[100][100];
		for(int i=0;i<n;++i){
			for(int j=0;j<n;++j){
				double distance = sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])+(z[i]-z[j])*(z[i]-z[j]));
				double cost = max(distance - r[i] - r[j] , 0.0);
				edge[i][j] = cost;
			}
		}
		double mincost[100];
		bool used[100];
		for(int i=0;i<n;++i){
			mincost[i]=INF;
			used[i]=false;
		}
		mincost[0]=0.0; double ans=0.0;
		while(1){
			int v = -1;
			for(int i=0;i<n;++i){
				if(!used[i] && (v == -1 || mincost[i] < mincost[v])) v=i;
			}
			if(v == -1) break;
			used[v] = true;
			ans += mincost[v];
			for(int i=0;i<n;++i){
				mincost[i] = min(mincost[i], edge[v][i]);
			}
		}
		printf("%.03f\n",ans);
	}
	return 0;
}

Measured memory_bytes: 1336
a,b,c,k = [int(x) for x in input().split()]

ans = 0
if k > a:
	k -= a
	ans += a
else:
	ans += k
	k = 0

if k > b:
	k -= b
else:
	k = 0

if k > c:
	k -= c
	ans += -1*c
else:
	ans += -1*k
	k = 0

print(ans)

Measured memory_bytes: 9140
#include <iostream>
using namespace std;
typedef long long ll;

int main()
{
    ll n, k;
    cin >> n >> k;
    ll a[100001], b[100001];
    ll c[100001] {0};
    for(int i = 0; i < n; i ++){
        cin >> a[i] >> b[i];
        c[a[i]] += b[i];
    }
    ll s = 0;
    for(int i = 0; i <= 100001; i++){
        s += c[i];
        if(s >= k){
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 2560
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int S[] = new int[N];

		int goukei = 0;
		int min = 1000;
		for(int i=0;i<N;i++) {
			S[i]= sc.nextInt();
			goukei += S[i];
			if(S[i]%10!=0 && S[i]<min) {
				min = S[i];
			}
		}

		if(min == 1000) {
			System.out.println(0);
		}else if(goukei%10!=0){
			System.out.println(goukei);
		}else {
			System.out.println(goukei-min);
		}


		List<Integer> foo = new ArrayList<Integer>();
	}

}


Measured memory_bytes: 21844
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;

public class Main {
  public static void main(String[] args) {
	FastReader sc = new FastReader();
	int n = sc.nextInt();
	int x = sc.nextInt();
	
	System.out.println(Math.max(n -x, 0));
  }
  
  static class FastReader {
    BufferedReader br;
    StringTokenizer st;

    public FastReader() {
      br = new BufferedReader(new InputStreamReader(System.in));
    }
  
    String next() { 
      while (st == null || !st.hasMoreElements()) {
        try {
          st = new StringTokenizer(br.readLine());
        } catch (IOException  e) {
          e.printStackTrace();
        }
      }
      return st.nextToken();
    }

    int nextInt() {
      return Integer.parseInt(next());
    }

    long nextLong() {
      return Long.parseLong(next());
    }

    double nextDouble() { 
      return Double.parseDouble(next());
    }

    String nextLine() {
      String str = "";
        try{
            str = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return str;
      }
  }
}


Measured memory_bytes: 21204
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vl vector<LL>
#define vii vector<vi>
#define vll vector<vl>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	string s,t="";
    cin>>s;
    int ln=s.length();
    FOR(i,0,ln/2){
        t+="hi";
    }
    if(s==t){
        cout<<"Yes";
    }else{
        cout<<"No";
    }
}


Measured memory_bytes: 256