akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define vll vector<ll>
#define endl "\n"
#define pll pair<ll,ll>
#define all(x) (x).begin() , (x).end()
#define f first
#define s second
#define pr(x) cout<<x<<endl;
#define pr2(x,y) cout<<x<<" "<<y<<endl;
#define pr3(x,y,z) cout<<x<<" "<<y<<endl;
#define prv(v) for(auto x:v) cout<<x<<" ";
#define ffs fflush(stdout);
using namespace std;
 
const ll N =(2e5+5);
const ll MOD = 1e9;
const ll INF = LLONG_MAX;
const ll LOG = 29;
#define PI 3.141592653589793238 
  
double circumference(double r) 
{ 
    double cir = 2.0;
    cir*=PI;
    cir*=r; 
    return cir; 
} 
long long binpow(long long a, long long b) {
    a%=MOD;    
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res * a)%MOD;
        a = (a * a)%MOD;
 
        
        b >>= 1;
    }
    res%=MOD;
    return res;
} 

void solve(){
    double r;
    cin>>r;
    cout<<circumference(r)<<endl;
}
 
 
int main(){
    ios_base::sync_with_stdio(0);
     cin.tie(NULL);
     
    ll t=1;
    //cin>>t;
    while(t--){
        solve();
    }
     
 
 
    return 0;     
    
        
}//42364286 418930126

Measured memory_bytes: 3800
# 同じチャンネルだけ継続できる
# 同じチャンネルが継続しない場合、1秒余分にロス

import sys
input = sys.stdin.readline

N,C = map(int,input().split())
T = [[] for _ in range(C+1)] # cごとに(s,t)
for _ in range(N):
  s,t,c = map(int,input().split())
  T[c].append((s,t))

  
def simplify(times):
  result = []
  times.sort()
  for s,t in times:
    if result and result[-1][1] == s:
      result[-1] = (result[-1][0],t)
    else:
      result.append((s,t))
  return result

T = [simplify(x) for x in T]

# [s-0.5,t)で一つ使う
# [s-0.25,t+0.25]としてよい
# [s,t]としてよい

import numpy as np
A = np.zeros(10**5+10,dtype=np.int32)
for times in T:
  for s,t in times:
    A[s] += 1
    A[t+1] -= 1

    
answer = A.cumsum().max()
print(answer)

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

int main() {
    int n, t, ans=1001;
    cin >> n >> t;
    for (int i = 0; i < n; i++) {
        int ci, ti;
        cin >> ci >> ti;
        if (ti <= t)
            ans = min(ans, ci);
    }
    if (ans < 1001) cout << ans << endl;
    else cout << "TLE" << endl;
}

Measured memory_bytes: 256
a, b = (int(i) for i in input().split())
s = input()

def f():
    if s.count("-") != 1:
        return "No"
    x = s.split("-")
    
    if len(x[0]) == a and len(x[1]) == b:
        return "Yes"
    return "No"

print(f())

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, k, n) for (int i = k; i < (int)(n); i++)
#define repd(i, n) for (int i = n-1; i >= 0; i--)
#define rrepd(i, k, n) for (int i = n-1; i >= (int)(k); i--)
#define all(x) (x).begin(),(x).end()
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
//V,Pは大文字i,l,bは小文字
using ll = long long;
using Vi = vector<int>;
using VVi = vector<Vi>;
using Vl = vector<ll>;
using VVl = vector<Vl>;
using Vb = vector<bool>;
using VVb = vector<Vb>;
using P = pair<int,int>;
using Pll = pair<ll, ll>;
const ll mod = 1000000007;
const ll inf = 1000000000000;//10の12乗

int main() {
  int a,b;
  cin >> a >> b;
  ll ans;
  if(a>=13) ans=b;
  else if(a<6) ans=0;
  else ans=b/2;
  cout << ans << endl;
}


Measured memory_bytes: 3580
from sys import stdin
input = stdin.readline

def accumulate(l, X):
    acclist = [0]*(l+1)
    for i in range(1,l+1):
        acclist[i] = acclist[i-1] + X[i]
    return acclist

N,M,K = map(int, input().split())
A = [0] + list(map(int, input().split()))
B = [0] + list(map(int, input().split()))

X = accumulate(N, A)
Y = accumulate(M, B)

maxbook = 0
j = M
for i in range(N+1):
    x = X[i]
    y = Y[j]
    while x + y > K:
        j -= 1 
        if j < 0:
            break
        y = Y[j]
    if j < 0:
        break

    maxbook = max(maxbook, i + j)

print(maxbook)

Measured memory_bytes: 46772
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        long sum = 0;
        
        for(int a = 1; a <= k; a++)
        {
            for(int b = 1; b <= k; b++)
            {
                for(int c = 1; c <= k; c++)
                {
                    if(a == b && b ==c)
                    {
                        sum += a;
                    }
                    else
                    {
                        //最大公約数を求める
                        int buf = gcd(a,b,c);
                        sum += buf;
                    }
                }
            }
        }
        System.out.println(sum);
    }
    
    public static int gcd(int x,int y, int z) {
        if(x < y)
        {
            int buf = x;
            x = y;
            y = buf;
        }
        int r = 0;
        while(( r = x % y) != 0)
        {
            x = y;
            y = r;
        }
        
        if(y < z)
        {
            int buf = y;
            y = z;
            z = buf;
        }
        while((r = y % z) != 0)
        {
            y = z;
            z = r;
        }
        return z;
    }
}


Measured memory_bytes: 35860
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

void solve() {
    int N;
    cin >> N;
    vi H(N);
    rep(i, N)cin >> H[i];
    const int INF = INT_MAX / 3;
    vi dp(N + 1, INF);
    dp[0] = 0;
    rep(i, N-1) {
        if (i < N - 1)smin(dp[i + 2], dp[i] + abs(H[i + 2] - H[i]));
        smin(dp[i + 1], dp[i] + abs(H[i + 1] - H[i]));
    }
    cout << dp[N - 1] << endl;
}

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


Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>

const int INF = 1000000009;
const long LINF = 1123456789012345678;

int h, w;
char s[55][55];
bool field[55][55];

int dx[] = {-1, 0, 0, 1};
int dy[] = {0, -1, 1, 0};
int main(){
	scanf("%d%d", &h, &w);
	for(int i = 0; i < h; i++){
		scanf("%s", s[i]);
	}
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			if(s[i][j] == '#'){
				field[i+1][j+1] = true;
			}
		}
	}
	for(int i = 1; i <= h; i++){
		for(int j = 1; j <= w; j++){
			if(field[i][j]){
				bool flag = false;
				for(int k = 0; k < 4; k++){
					if(field[i+dx[k]][j+dy[k]]){
						flag = true;
					}
				}
				if(!flag){
					printf("No\n");
					
					return 0;
				}
			}
		}
	}
	printf("Yes\n");
	return 0;
}


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

int n;
struct point{
	int x;
	int y;
	int idx;
} p[100004];

bool cmp1(point a, point b){
	return a.x<b.x;
}
bool cmp2(point a, point b){
	return a.y<b.y;
}
pair<int,pair<int,int>> e[200004];
int parent[100004], size[100004], r[100004]; 
void init(){ 
	for (int i=1; i<=n; i++) { 
		parent[i] = i; 
		size[i] = 1; 
		r[i] = 0; 
	} 
}

int find(int p){ 
	if(parent[p] == p) return p; 
	else return parent[p] = find(parent[p]); 
} 
void uni(int p, int q){ 
	p = find(p); 
	q = find(q); 
	if(r[p] < r[q]) parent[p] = q, size[q] += size[p]; 
	else parent[q] = p, size[p] += size[q]; 
	if(r[p] == r[q]) r[p]++; 
}


int main() {
	ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	cin>>n;
	for(int i = 1; i <= n;i++){
		cin>>p[i].x>>p[i].y;
		p[i].idx = i;
	}
	sort(p+1,p+n+1,cmp1);
	for(int i = 1;i<n;i++){
		e[i].first = abs(p[i].x-p[i+1].x);
		e[i].second = {p[i].idx,p[i+1].idx};
	}
	sort(p+1,p+n+1,cmp2);
	for(int i = 0;i<n-1;i++){
		e[i+n].first = abs(p[i+1].y-p[i+2].y);
		e[i+n].second = {p[i+1].idx,p[i+2].idx};
	}
	sort(e+1,e+2*n-1);
	init();
	long long ans = 0;
	for(int i = 1;i<=2*n-2;i++){
		int a = e[i].second.first;
		int b = e[i].second.second;
		if(find(a) == find(b))	continue;
		uni(a,b);
		ans += e[i].first;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 4992
#include <iostream>


int main(void)
{
int a,b;
std::cin >> a >> b;

if (a > b)
{
std::cout << "a > b";
}
else if (a < b)
{
std::cout << "a < b";
}
else
{
std::cout << "a == b";
}

std::cout << std::endl;

return 0;
}

Measured memory_bytes: 3088
def gcd_core(a, b):
    if b == 0:
        return a
    else:
        return gcd_core(b, a % b)


def gcd(arr):
    g = gcd_core(arr[0], arr[1])
    for i in range(2, len(arr)):
        g = gcd_core(g, arr[i])
    return g


n,m = map(int,input().split())
arr = list(map(int,input().split()))
arr.sort()
temp = []
for i in range(m-1):
    temp.append(arr[i+1]-arr[i])
temp.sort()
temp[::-1]
ans = 0

for i in range(m-n):
    ans += temp[i]
print(ans)







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

# define F first    
# define S second
# define mp make_pair
// everything go according to my plan      
# define pb push_back
# define sz(a) (int)(a.size())
# define vec vector
// shimkenttin kyzdary, dzyn, dzyn, dzyn...
# define y1    Y_U_NO_y1
# define left  Y_U_NO_left
# define right Y_U_NO_right  

using namespace std;

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

const int Mod = (int)1e9 + 7;
const int MX = 1073741822;
const ll MXLL = 4e18;
const int Sz = 1110111;
// a pinch of soul
inline void Read_rap () {
  ios_base :: sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}
inline void randomizer3000 () {
  unsigned int seed;
  asm ("rdtsc" : "=A"(seed));
  srand (seed);
}
void files (string problem) {   
  if (fopen ((problem + ".in").c_str(),"r")) {
    freopen ((problem + ".in").c_str(),"r",stdin);
    freopen ((problem + ".out").c_str(),"w",stdout);
  }
}
int n;

int a[Sz];  

int dir[Sz];

int main()
{ 
  Read_rap();
  cin >> n;         
  for (int i = 1; i <= n; i++)
    cin >> a[i];
  int cnt = 1;
  int dir = 0;
  for (int i = 2; i <= n; i++) {
    int d = 0;
    if (a[i] == a[i - 1])
      d = dir;
    if (a[i] > a[i - 1])  
      d = 1;
    else  if (a[i] < a[i - 1])
      d = -1;
           
    if (!dir)
      dir = d;
    else  if (dir != d)
      cnt++, dir = 0;
  }
  cout << cnt;
  
  return 0;
}






// Coded by Z..


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

int main(void){
    int n, m;
    cin >> n >> m;
    vector<vector<vector<int>>> vec(n);
    //vec = (n, vector<vector<int>>(, vector<int>(2)));

    for(int i=0; i<m; i++){
        int p, y;
        cin >> p >> y;
        vector<int> v = {y,i+1};
        vec.at(p-1).push_back(v);
    }

    map<int, vector<int>> mp;

    for(int i=0; i<n; i++){
        sort(vec.at(i).begin(), vec.at(i).end());
        for(int j=0; j<vec.at(i).size(); j++){
            vector<int> v = {i+1, j+1};
            mp[vec.at(i).at(j).at(1)] = v;
        }
    }

    auto itr = mp.begin();
    while(itr != mp.end()){
        printf("%06d%06d\n", itr->second.at(0), itr->second.at(1));
        itr++;
    }


    return 0;
}

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

int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if (a % 2 == 0 && a % 3 != 0 && a % 5 != 0) {
            cout << "DENIED" << endl;
            return 0;
        }
    }
    cout << "APPROVED" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
signed main()
{

  ll n,m,x,y,ans=0;
 
  cin>>n>>m;
 pair<ll,ll> a[n];
 for(ll i=0 ;i<n;i++)
 {
   cin>>x>>y; 
   a[i] = {x,y};
 }
 sort(a,a+n);
 for(ll i=0;i<n;i++)
 {
   ans +=min(m,a[i].second)*a[i].first;
   m  -=a[i].second;
   if(m<=0)
     break;
 }
 cout<<ans<<"\n";
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 

vll dp(100100);

ll sum(ll n) {
ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    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;
    }
}
 
 
#define comuse Comuse()
 
ll combi(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;
}
 
 
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}


 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n,k;
    ci(n>>k);
  st s;
    ci(s);

  ll count=1;
  FOR(i,1,n-1){
    if(s[i]!=s[i-1]){
      count++;
    }
  }

  if(s[n-1]!=s[n-2]){
    count++;
  }

  ll ans=n-count+2*k;

  co(min(n-1,ans))
  }

Measured memory_bytes: 1280
from fractions import gcd

MOD = 10**9+7
N = int(input())
A = list(map(int,input().split()))
lcm = 1
for i in A:
    lcm = (lcm*i)//gcd(lcm,i)
lcm %= MOD
ans = 0
for i in A:
    ans += lcm*pow(i,MOD-2,MOD)
    ans %= MOD
print(ans)


Measured memory_bytes: 6112
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) a.begin(),a.end()
#define print(A,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i];}cout<<endl;
#define pprint(A,m,n) rep(j,0,m){print(A[j],n);}
const long mod=1e9+7;
const int size=1e6;
const int INF=1e9;
int main(){
	int X,A;cin>>X>>A;
	if(X<A) cout<<0<<endl;
	else cout<<10<<endl;
}

Measured memory_bytes: 256
#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

#include <stdio.h>
#include <bits/stdc++.h>

using namespace std;

#include <x86intrin.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define all(x) x.begin(), x.end()

#define mp make_pair
#define in insert
#define er erase
#define con continue
#define pb push_back
#define sc scanf
#define pr printf
#define ub upper_bound
#define lb lower_bound
#define s second
#define f first
#define int long long

const long long infl = 1e18; 
const int N = 3e5 + 300, N2 = 2e3, inf = 1e9 + 200;

set <int> S;
vector <int> g;
int n, m, k;
int a[N];
string ss;

main (){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> ss;
	if (ss[2] == ss[3] && ss[4] == ss[5]) cout << "Yes";
	else cout << "No";
	
	return 0;
}












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

const int64_t MOD = 1e9+7;
void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}
void mul(int64_t& a, int64_t b){
    a = a*b % MOD;
}

int main(){
    int N;
    cin >> N;
    vector<int> A(2*N);
    for(int i=0; i<2*N; i++){
        cin >> A[i];
        if(A[i] > 0) A[i]--;
    }

    bitset<600> dead, fix;
    int F = 0;
    for(int i=0; i<2*N; i+=2){
        if(A[i] >= 0 && A[i+1] >= 0){
            dead[A[i]] = dead[A[i+1]] = 1;
        }else if(A[i] >= 0){
            fix[A[i]] = 1;
        }else if(A[i+1] >= 0){
            fix[A[i+1]] = 1;
        }else{
            F++;
        }
    }

    vector<int> order;
    for(int i=0; i<2*N; i++) if(!dead[i]) order.push_back(i);
    int sz = order.size();

    vector<vector<int64_t>> dp0(601, vector<int64_t>(601));
    auto dp = dp0;
    dp[0][0] = 1;
    for(int i=0; i<sz; i++){
        auto dp2 = dp0;
        for(int j=0; j<sz; j++) for(int k=0; k<sz; k++){
            int64_t v = dp[j][k];
            if(v == 0) continue;
            if(fix[order[i]]){
                add(dp2[j+1][k], v);
                if(k > 0) add(dp2[j][k-1], v * k);
            }else{
                add(dp2[j+1][k], v);
                add(dp2[j][k+1], v);
                if(j > 0) add(dp2[j-1][k], v);
            }
        }
        dp = dp2;
    }
    int64_t ans = dp[0][0];
    for(int i=1; i<=F; i++) mul(ans, i);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 9976
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
//typedef tuple<ll, ll, ll> T;

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

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<int> a(3);
    int k;
    REP(i,3) cin>>a[i];
    cin>>k;
    VSORT(a);
    ll ans=a[0]+a[1]+pow(2,k)*a[2];
    //cout<<a[0]<<a[1]<<a[2]<<endl;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

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

signed main(){
	int t; cin>>t;
	rep(i,t){
		ll a,b,c,d; cin>>a>>b>>c>>d;
		if(a<b||b>d) cout<<"No"<<endl;
		else if(c>=b) cout<<"Yes"<<endl;
		else{
			ll g=gcd(b,d);
			if(b-g+(a%g)>c) cout<<"No"<<endl;
			else cout<<"Yes"<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 256
from collections import deque
import sys
input=sys.stdin.readline
n,m=map(int,input().split())
path=[[] for i in range(n)]
for i in range(m):
  a,b=map(int,input().split())
  path[a-1].append(b-1)
  path[b-1].append(a-1)
l=deque()
s=set()
l.append(0)
s.add(0)
while True:
  for i in path[l[0]]:
    if not i in s:
      l.appendleft(i)
      s.add(i)
      break
  else:break
while True:
  for i in path[l[-1]]:
    if not i in s:
      l.append(i)
      s.add(i)
      break
  else:break
print(len(l))
l=list(map(lambda x:x+1,l))
print(*l)

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

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}

signed main() {
	int n, m, cnt = 0;
	cin >> n >> m;
	int d[114514], ans[114514];
	fill(d, d + n + 1, 0);
	rep(i, m) {
		int l, r;
		cin >> l >> r;
		d[l]++, d[r + 1]--;
	}
	ans[0] = 0;
	for (int i = 1; i <= n; i++) {
		ans[i] = ans[i - 1] + d[i];
		if (ans[i] == m) cnt++;
	}
	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 1792
N, M = gets.chomp.split(" ").map(&:to_i)
W = []
M.times{
  W << gets.chomp.split(" ").map(&:to_i)
}

W.sort_by!{|a, b| b}
ans = 0
until W.empty? do
  l = W[0]
  W.select!{|a, b| a >= l[1]}
  ans += 1
end

puts ans


Measured memory_bytes: 12664
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <queue>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <complex>

int main(){

  long long int H, W;
  std::cin >> H >> W;

  std::cerr << "Answer:" << std::endl;
  if(H == 1 || W == 1){
    std::cout << 1;
  }
  else{
    std::cout << (H*W+1)/2 << std::endl;
  }

  return 0;
  
}


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

int main()
{
  ll n, k;
  cin >> n >> k;
  vector<ll> hs = {};

  for (auto i = 0; i < n; i++)
  {
    ll h;
    cin >> h;
    hs.push_back(h);
  }

  sort(hs.begin(), hs.end());
  reverse(hs.begin(), hs.end());

  ll total = 0;
  for (auto i = 0; i < n; i++)
  {
    if (i < k)
      continue;

    total += hs[i];
  }

  cout << total << endl;

  return 0;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < int(n); ++ (i))
#define REP_R(i, n) for (int i = int(n) - 1; (i) >= 0; -- (i))
using ll = long long;
using namespace std;
template <class T> inline void chmin(T & a, T const & b) { a = min(a, b); }

template <class Weight, class Func>
void generic_dijkstra(int root, vector<Weight> & dist, Func iterate_adjacent_vertices) {
    dist.assign(dist.size(), numeric_limits<Weight>::max());
    priority_queue<pair<Weight, int> > que;
    dist[root] = 0;
    que.emplace(- dist[root], root);
    while (not que.empty()) {
        Weight dist_i; int i; tie(dist_i, i) = que.top(); que.pop();
        if (dist[i] < - dist_i) continue;
        iterate_adjacent_vertices(i, [&](int j, Weight cost) {
            if (- dist_i + cost < dist[j]) {
                dist[j] = - dist_i + cost;
                que.emplace(dist_i - cost, j);
            }
        });
    }
}

int main() {
    // input
    int n, m, s, t;
    cin >> n >> m >> s >> t;
    -- s; -- t;
    vector<vector<tuple<int, int, int> > > g(n);
    REP (i, m) {
        int u, v, a, b;
        cin >> u >> v >> a >> b;
        -- u; -- v;
        g[u].emplace_back(v, a, b);
        g[v].emplace_back(u, a, b);
    }

    // solve
    vector<ll> dist1(n);
    generic_dijkstra<ll>(s, dist1, [&](int i, auto cont) {
        for (auto edge : g[i]) {
            int j, a; tie(j, a, ignore) = edge;
            cont(j, a);
        }
    });

    vector<ll> dist2(n);
    generic_dijkstra<ll>(t, dist2, [&](int i, auto cont) {
        for (auto edge : g[i]) {
            int j, b; tie(j, ignore, b) = edge;
            cont(j, b);
        }
    });

    vector<ll> ans(n);
    REP (i, n) {
        ans[i] = dist1[i] + dist2[i];
    }
    REP_R (i, n - 1) {
        chmin(ans[i], ans[i + 1]);
    }

    // output
    REP (i, n) {
        cout << 1000000000000000ll - ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 11000
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
int main()
{
  int a;
  cin >> a;
  cout << a + a*a + a*a*a << endl;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MOD 1000000007
#define MAX 1000000007
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ub upper_bound
#define lb lower_bound
#define zoom ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define precise cout.precision(8); cout << fixed;
#define seed srand(chrono::steady_clock::now().time_since_epoch().count());
const double PI = acos(-1);
using namespace std;

void solve() {
    ll N, i; cin >> N;
    ll curr = 26, cnt = 1;
    while(true) {
        if(N <= curr) {
            break;
        }
        N -= curr;
        curr *= 26;
        cnt += 1;
    }
    N -= 1;
    string ans = "";
    for(i = 0; i < cnt; i += 1) {
        unsigned char x = (unsigned char)('a' + (N % 26));
        N /= 26;
        ans += ((unsigned char)x);
    }
    reverse(ans.begin(), ans.end());
    cout << ans;
}

int main() {
    int t = 1;
    //cin >> t;
    while(t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3532
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

int N;
int L[51];
int dp[51];

int calc(int d) {
    memset(dp, 0x3f, sizeof(dp));
    dp[0] = 0;
    for (int i = 0; i < N; ++i) {
        int sum = 0;
        for (int j = i; j >= 0; --j) {
            if (i + 1 == N && j == 0) continue;
            sum += L[j];
            if (sum >= d) dp[i + 1] = min(dp[i + 1], max(dp[j], sum));
        }
    }
    return dp[N];
}

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

    cin >> N;
    int sum = 0;
    REP(i, N) cin >> L[i], sum += L[i];
    int ans = 1LL << 30;
    calc(53);
    FOR(i, 1, sum) {
        ans = min(ans, calc(i) - i);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3204
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int a = in.nextInt();
        int[] b = new int[a];
        int x = 0;
        for (int i = 0; i < a; i++) {
            b[i]=in.nextInt();
        }
        Arrays.sort(b);
        int sum = 0;
        long min = 1000000000;
        for (int i = -100; i <= 100; i++) {
            for (int j = 0; j < a; j++) {
                if(i!=b[j]){
                    sum+=((b[j]-i)*(b[j]-i));
                    
                }
            }
            if(sum<min){
                min=sum;
            }
            sum=0;
        }
        System.out.println(min);
    }
}

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

int main(){
  int N;
  string S;
  cin >> N >> S;
  int ans = 1;
  for(int i = 1; i<N; i++){
    if(S.at(i) != S.at(i-1))ans++;
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 3736
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;

int N,Q;
vector<int> x;
vector<bool> visited;
vector<vector<int>> graph;
vector<int> score;

void dfs(int i){
    //cout << i<<":" << graph[i].size()<< endl;
    if(graph[i].size()==0) return;
    visited[i] = true;
    for(int next_i:graph[i]){
        if(visited[next_i]) continue;
        score[next_i] += score[i];
        dfs(next_i);
    }
    visited[i] = false;
    return;
}

int main()
{
    cin>>N>>Q;
    x.resize(N);

    visited.resize(N);
    REP(i,N) visited[i]= false;

    graph.resize(N);
    REP(i, N-1){
        int a,b;
        cin>>a>>b;
        a--;b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    // REP(i, N){
    //     for(int x:graph[i]){
    //         cout << i <<" -> "<< x << endl;
    //     }
    // }

    score.resize(N);
    REP(i,Q){
        int a,b;
        cin>>a>>b;
        a--;
        score[a] += b;
    }

    dfs(0);
    
    REP(i,N) cout <<score[i] << endl;



    return 0;
}

Measured memory_bytes: 27392
//#pragma GCC optimize("trapv")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx,avx2,sse,sse2,fma,tune=native")
#include<bits/stdc++.h>
#define rall(x) x.rbegin(), x.rend()
#define all(x) x.begin(), x.end()
#define pb push_back
#include <x86intrin.h>
#define pb push_back
using namespace std;
using ll = long long;
using pi = pair<int, int>;
using vi = vector<ll>;
using ld = long double;
const int maxn = 2e6 + 55, mod = 1000000007, i2 = (mod+1)/2;
typedef complex<double> cd;
const double PI = acos(-1);
void fft(vector<cd> &f, bool invert){
	int n = int(f.size());
	for(int i = 1, j = 0; i < n; ++ i){
		int bit = n >> 1;
		for(; j & bit; bit >>= 1) j ^= bit;
		j ^= bit;
		if(i < j) swap(f[i], f[j]);
	}
	for(int len = 2; len <= n; len <<= 1){
		double theta = 2 * PI / len * (invert ? -1 : 1);
		cd w(cos(theta), sin(theta));
		for(int i = 0; i < n; i += len){
			cd wj(1);
			for(int j = 0; j < len / 2; ++ j, wj *= w){
				cd u = f[i + j], v = wj * f[i + j + len / 2];
				f[i + j] = u + v, f[i + j + len / 2] = u - v;
			}
		}
	}
	if(invert) for(auto &c: f) c /= n;
}
vector<long long> polymul(const vector<long long> &a, const vector<long long> &b){
	vector<cd> f(a.begin(), a.end()), g(b.begin(), b.end());
	int n = 1;
	while(n < int(a.size() + b.size())) n <<= 1;
	f.resize(n), g.resize(n);
	fft(f, false), fft(g, false);
	for(int i = 0; i < n; ++ i) f[i] *= g[i];
	fft(f, true);
	vector<long long> res(n);
	for(int i = 0; i < n; ++ i) res[i] = round(f[i].real());
	while(!res.empty() && !res.back()) res.pop_back();
	return res;
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll n, k, ans = 0, t;
	cin >> n >> k;
	vi a(1<<17), b(1<<17);
	for(int i = 0; i < n; i++)cin >> t, a[t]++, b[t]++;
	a = polymul(a, b);
	for(int i = a.size(); i--;) {
		t = min(k, a[i]);
		ans += i*t;
		k -= t;
	}
	cout << ans;
}


Measured memory_bytes: 12792
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
using namespace std;

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

  ll n; cin >> n;
  vector<ll> x(n), cp_x(n);
  rep(i, n) cin >> x[i];
  cp_x = x;
  sort(x.begin(), x.end());

  rep(i, n) {
    if(cp_x[i] <= x[n/2-1]) {
      cout << x[n/2] << '\n';
    } else {
      cout << x[n/2-1] << '\n';
    }
  }

  return 0;
}


Measured memory_bytes: 5376
#include<bits/stdc++.h>
#define    ll   long long int
#define    sz   200010
#define    md   1000000007
#define    py   printf("YES\n")
#define    pn   printf("NO\n")

using namespace std;

ll ax[sz];
ll bx[sz];
ll cx[sz];
ll ara[sz];
priority_queue<ll>q;


int main()
{

    ll x,y,z,n,i,j,k,p,s=0,c,a,b,d,o;

    scanf("%lld %lld %lld %lld",&x,&y,&z,&p);

    for(i=1; i<=x; i++)
    {
        cin>>ara[i];
    }
    sort(ara+1,ara+x+1);

    j=1;

    for(i=x; i>=1; i--)
    {
        ax[j]=ara[i];
        j++;
    }


    for(i=1; i<=y; i++)
    {
        cin>>ara[i];
    }
    sort(ara+1,ara+y+1);

    j=1;

    for(i=y; i>=1; i--)
    {
        bx[j]=ara[i];
        j++;
    }



    for(i=1; i<=z; i++)
    {
        cin>>ara[i];
    }
    sort(ara+1,ara+z+1);
    j=1;

    for(i=z; i>=1; i--)
    {
        cx[j]=ara[i];
        j++;
    }



    for(i=1; i<=x; i++)
    {
        for(j=1; j<=y; j++)
        {
            for(k=1; k<=z; k++)
            {
                q.push(ax[i]+bx[j]+cx[k]);
                c=(i)*(j)*(k);

                if(c>p)break;

            }
        }
    }


    while(p--)
    {
        d=q.top();
        cout<<d<<endl;
        q.pop();

    }

    return 0;
}


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

#include <iostream>

class ARegistration {
public:
    void solve(std::istream& in, std::ostream& out) {
        std::string s, t;
        in >> s >> t;
        if(s+t[t.length()-1] == t){
            out << "Yes" << std::endl;
        }else{
            out << "No" << std::endl;
        }
    }
};


int main() {
    ARegistration solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#include<cstdint>

int64_t calc(int64_t H) {
  if(H <= 1) return H;
  return (int64_t)1 + 2*calc(H/2);
}

int main() {
  int64_t H; std::cin >> H;
  std::cout << calc(H) << std::endl;
  return 0;
}


Measured memory_bytes: 256
"""WA"""

import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
from itertools import permutations,  combinations, accumulate
from functools import *
from collections import deque, defaultdict, Counter
from heapq import heapify, heappop, heappush, heappushpop

INF = float('inf')
NIL = - 1

S = input().rstrip()
N = len(S)
ans = [0] * N

counter = 0
for i in range(N):
    if S[i] == 'R':
        counter += 1
    else:
        ans[i] += counter // 2
        ans[i-1] += (counter + 1) // 2
        counter = 0

ans = ans[::-1]
S = S[::-1]

counter = 0
for i in range(N):
    if S[i] == 'L':
        counter += 1
    else:
        ans[i] += counter // 2
        ans[i-1] += (counter + 1) // 2
        counter = 0

print(*ans[::-1])


Measured memory_bytes: 7116
#include <bits/stdc++.h>
#define inf (long long)(1e9)
using namespace std;

// 0-indexed
template <class T>
struct SegmentTree {
  // a,b,c: T, e:T(unit)
  // abc = (ab)c = a(bc)
  // ae = ea = a
  typedef function<T(T, T)> F;
  int n;
  F f;
  T unit;
  vector<T> dat;
  SegmentTree(){};
  SegmentTree(int newn, F f, T t) : f(f), unit(t) {
    init(newn);
  }
  void init(int newn) {
    n = 1;
    while(n < newn) n <<= 1;
    dat.assign(n << 1, unit);
  }

  // "go up" process
  void update(int k, T newdata) {
    dat[k += n] = newdata;
    while(k >>= 1) {
      dat[k] = f(dat[(k << 1) | 0], dat[(k << 1) | 1]);
    }
  }
  // [a,b)
  T query(int a, int b) {
    T vl = unit, vr = unit;
    for(int l = a + n, r = b + n; l < r; l >>= 1, r >>= 1) {
      if(l & 1) vl = f(vl, dat[l++]);
      if(r & 1) vr = f(dat[--r], vr);
    }
    return f(vl, vr);
  }
};
struct data {
  long long dis, num, bf;
};

long long n, m;
string s;
vector<long long> ans;

long long solve();

int main() {
  cin >> n >> m >> s;
  if(solve() == -1)
    cout << -1 << endl;
  else {
    for(int i = 0; i < ans.size(); ++i) {
      if(i != 0) cout << " ";
      cout << ans[i];
    }
    cout << endl;
  }
  return 0;
}

long long solve() {
  auto f = [](data l, data r) {
    if(l.dis < r.dis)
      return l;
    else if(l.dis == r.dis && l.num <= r.num)
      return l;
    return r;
  };
  data dummy = {inf, -1, -1};
  SegmentTree<data> seg(n + 1, f, dummy);
  seg.update(0, {0, 0, -1});
  for(int i = 0; i < n; ++i)
    if(s[i + 1] == '0') {
      data now = seg.query(max(0LL, i - m + 1), i + 1);
      if(now.dis == inf) continue;
      now.bf = now.num;
      now.num = i + 1;
      ++now.dis;
      seg.update(i + 1, now);
    }
  if(seg.query(n, n + 1).dis == inf) return -1;
  data now = seg.query(n, n + 1);
  while(now.num != 0) {
    ans.push_back(now.num - now.bf);
    now = seg.query(now.bf, now.bf + 1);
  }
  reverse(ans.begin(), ans.end());
  return 0;
}

Measured memory_bytes: 7672
#include<stdio.h>
#include <iostream>

int main()
{
	long long X;
	long long kane = 100;
	double k;
	int nen = 0;

	scanf("%lld", &X);

		while (kane < X)
		{
			kane = kane * 1.01;
			//kane = (double)(int)k;
			nen++;
			//		printf("%lf\n", kane);
		}

	printf("%d",nen);

	return 0;
}

Measured memory_bytes: 3828
#include<bits/stdc++.h>
#define REP(i,first,last) for(int i=first;i<=last;++i)
#define DOW(i,first,last) for(int i=first;i>=last;--i)
using namespace std;
inline int Read()
{
	int x(0),f(1);
	char c(getchar());
	while(c<'0'||'9'<c)
	{
		if(c=='-')
		{
			f=-1;
		}
		c=getchar();
	}
	while('0'<=c&&c<='9')
	{
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return f*x;
}
void Write(int x)
{
	if(x<0)
	{
		printf("-");
		x=-x;
	}
	if(9<x)
	{
		Write(x/10);
	}
	putchar(x%10+'0');
}
inline void Writeln(int x)
{
	Write(x);
	puts("");
}
struct Point
{
	double x,y;
	Point(double fx=0,double fy=0)
	{
		x=fx;
		y=fy;
	}
	void Read()
	{
		scanf("%lf%lf",&x,&y);
	}
	void Write(int len=2)
	{
		printf("%.9lf %.9lf",x,y);
	}
	double operator ^(Point const b)const
	{
		return x*b.x+y*b.y;
	}
	double operator |(Point const b)const
	{
		return x*b.y-b.x*y;
	}
	double operator ==(Point const b)const
	{
		return sqrt((x-b.x)*(x-b.x)+(y-b.y)*(y-b.y));
	}
	Point operator *(double const b)const
	{
		return Point(x*b,y*b);
	}
	Point operator +(Point const b)const
	{
		return Point(x+b.x,y+b.y);
	}
	Point operator -(Point const b)const
	{
		return Point(x-b.x,y-b.y);
	}
};
Point Symmetrical(Point a,Point m=Point(0,0))
{
	return Point(m.x*2-a.x,m.y*2-a.y);
}
/**
 *      /
 *   a /
 *    m
 *   / b
 */
struct Vector
{
	Point a,b;
	Vector(Point f=Point(0,0),Point e=Point(0,0))
	{
		a=f;
		b=e;
	}
	double operator ^(Vector const c)const
	{
		return (a.x-b.x)*(c.a.x-c.b.x)+(c.a.y-c.b.y)*(a.y-b.y);
	}
	double operator |(Vector const c)const
	{
		return (a.x-b.x)*(c.a.y-c.b.y)-(c.a.x-c.b.x)*(a.y-b.y);
	}
};
Point p0,p1,p2,p3;
const int MAXN=1e5+5;
void Work()
{
	p0.Read();
	p1.Read();
	p2.Read();
	p3.Read();
	if((Vector(p0,p1)|Vector(p2,p3))==0)
	{
		printf("2\n");
		return;
	}
	if((Vector(p0,p1)^Vector(p2,p3))==0)
	{
		printf("1\n");
		return;
	}
	printf("0\n");
}
int main()
{
	int q;
	scanf("%d",&q);
	REP(i,1,q)
	{
		Work();
	}
	return 0;
}


Measured memory_bytes: 3248
#include <iostream>
#include <stdio.h>

using namespace std;

int main(void) {
    int N = 0;
    int K = 0;

    cin >> N >> K;

    char S[N+1] = {0};

    cin >> S;

    char result[N+1] = {0};

    for (int i=0; i<N; i++) {
        if (i == K-1) { S[i] = tolower(S[i]); }
        result[i] = S[i];
    }

    cout << result;

    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <algorithm>
#include <complex>
#include <cassert>
#include <vector>
#include <iomanip>

using namespace std;

typedef complex<double> P;

#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)

const double eps = 1e-10;

double cross(const P& a, const P& b) {
    return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
    return real(conj(a)*b);
}

struct L : public vector<P> {
    L(const P &a, const P &b) {
        push_back(a); push_back(b);
    }
};

P crosspoint(const L &l, const L &m) {
    double A = cross(l[1] - l[0], m[1] - m[0]);
    double B = cross(l[1] - l[0], l[1] - m[0]);
    if (abs(A) < eps && abs(B) < eps) return m[0]; // same line
    if (abs(A) < eps) assert(false); // !!!PRECONDITION NOT SATISFIED!!!
    return m[0] + B / A * (m[1] - m[0]);
}

typedef vector<int> vi;

int main(){
    int W;
    int c = 1;
    while (cin >> W && W){
        printf("Case %d:\n",c);
        c++;
        int n; cin >> n;
        vi v(n), w(n);
        rep(i, n){
            scanf("%d,%d", &v[i], &w[i]);
        }
        vi dp(W + 1);
        rep(i, n){
            for (int j = W; j >= 0; j--){
                if (j - w[i] >= 0) dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
            }
        }
        int ans = 1e8;
        rep(i, W + 1){
            if (dp[i] == dp.back()){
                ans = min(ans, i);
            }
        }
        cout << dp[W] << endl << ans << endl;
    }
}

Measured memory_bytes: 1276
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")

//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)
#pragma GCC optimize("unroll-loops")
// -------------------</optimizations>--------------------
#include <iostream>
#include <bitset>
#include <algorithm>        // sort()
#include <vector>           // for vectors
#include <map>              // for ordered map
#include <unordered_map>
#include <list>             // for list
#include <iomanip>          // for setprecision()
#include <cmath>            // for pow(), sqrt(), log(), log10(), ....
#include <cstring>          // for memset()
#include <unordered_set>    // for unordered_set
#include <climits>          // for INT_MAX & INT_MIN
#include <set>              // for ordered set

#define C ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
typedef long long ll;
#define INF INT_MAX
#define NINF INT_MIN
#define MOD 1000000007
const double pi=acos(-1); // value of pi


bool isVowel(char ch) {
    if(ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u') {
        return 1;
    }
    return 0;
}

bool compare(pair<ll, ll> a, pair<ll, ll> b) {
    return a.second<b.second;
}


bool isPrime(ll n) {
    for(ll i=3; i*i<=n; i+=2) {
        if(n%i==0) {
            return false;
        }
    }
    return true;
}

map<ll, list<ll>> m;
// map<ll, ll> m;

int main() {
    C
//     freopen("input.txt","r",stdin);
// 	freopen("output.txt","w",stdout);
    int t=1;
    //cin >> t;
    while(t--) {
        ll d, x, res=0;
        cin >> d;
        ll c[26];
        ll arr[d][26];
        ll la[26];
        for(ll i=0; i<26; i++) {
            cin >> c[i];
            la[i]=-1;
        }
        for(ll i=0; i<d; i++) {
            for(ll j=0; j<26; j++) {
                cin >> arr[i][j];
            }
        }
        for(ll i=0; i<d; i++) {
            ll ans, ma=0;
            for(ll j=0; j<26; j++) {
                x=arr[i][j];
                for(ll k=0; k<26; k++) {
                    if(k!=j) {
                        x-=((c[k])*(i-la[k]));
                    }
                }
                if(x>ma) {
                    ma=x;
                    ans=j;
                }
            }
            la[ans]=i;
            cout << ans+1 << endl;
        }
    }
}


Measured memory_bytes: 3272
#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 ld = long double;
using Point =  complex<ld>;
const ld eps = 1e-7;

//円
class Circle {
public:
	Point p;
	ld r;
};

vector<Point> is_cc(Circle c1,Circle c2){
    if(c1.r>c2.r)swap(c1,c2);
    ld d = abs(c1.p-c2.p);
    if(d>c1.r+c2.r){
        return {};
    }
    if(c2.r>d+c1.r)return {};
    ld theta = acosl((c1.r*c1.r+d*d-c2.r*c2.r)/(2*c1.r*d));
    Point mid = c1.p +(c2.p-c1.p)* cosl(theta) * c1.r /d;
    Point h = (c2.p-c1.p) * Point(0,1) * sinl(theta) * c1.r /d;
    vector<Point> ret;
    ret.push_back(mid+h);ret.push_back(mid-h);
    return ret;
}

void solve(){
    int n,K;
    cin>>n>>K;
    vector<Point> p(n);
    vector<ld> a(n);
    rep(i,n){
        int x,y;cin>>x>>y;
        p[i]=Point(x,y);
        cin>>a[i];
    }

    ld ok = 1e6, ng = 0;
    rep(_,100){
        ld mid = (ok+ng)/2;
        vector<Circle> c(n);
        rep(i,n)c[i]={p[i],mid/a[i]};
        int cnt  = 0;
        rep(i,n)rep(j,i){
            auto is = is_cc(c[i],c[j]);
            for(auto e:is){
                int ret = 0;
                rep(k,n)if(abs(e-c[k].p)<=c[k].r || k==i || k==j)++ret;
                cnt = max(cnt,ret);
            }
        }
        rep(i,n){
            int ret = 0;
            rep(j,n)if(abs(c[i].p-c[j].p)<=c[j].r)++ret;
            cnt = max(cnt,ret);
        }
        if(cnt>=K)ok=mid;
        else ng=mid;
    }
    cout<<ok<<endl;
}
int main(){
    cout<<fixed<<setprecision(12);
    solve();
    return 0;
}


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

typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  int W, H, x, y;
  cin >> W >> H >> x >> y;
  double ans = (double) W * H / 2;
  int d = (W == x * 2 && H == y * 2) ? 1 : 0;
  printf("%.10f %d\n", ans, d);
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#define WHITE 0
#define BLACK 2
#define INF 100000000
#define NIL NULL

int n,add=0,w[150][150],d[11000];

void prim();

int main(){
  int i,j,r;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      scanf("%d",&w[i][j]);
    }
  }
  r=0;
  prim();
  for(i=1;i<=n;i++){
    add+=d[i];
  }
  printf("%d\n",add);

  return 0;
}

void prim(){
  int i,u,v,mincost,pi[n],color[n];

  for(u=1;u<=n;u++){
    d[u]=INF;
    pi[u]=NIL;
    color[u]=WHITE;
  }
  d[1]=0;
  while(1){
   
    mincost=INF;
    for(i=1;i<=n;i++){
      if(color[i] != BLACK && d[i] < mincost){
	mincost=d[i];
	u=i;
      }
    }
    if(mincost==INF){
      break;
    }
    color[u]=BLACK;
    for(v=1;v<=n;v++){
      if(color[v] != BLACK && w[u][v]<d[v] &&w[u][v]>=0){
	pi[v]=u;
	d[v]=w[u][v];
      }
    }
  }
}



Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1000000007, INF = 1e9;

int main()
{
    int n, b, c, ans = 0;
    cin >> n >> b >> c;
    vector<int> v(n);
    rep(i, n) cin >> v[i];
    for(int i = 0; i < n; i++){
        int j = 0;
        while(j*v[i]+1 <= b){
            ans++;
            j++;
        }
    }
    cout << ans + c << endl;
}

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

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int n, m;
    cin >> n >> m;

    cout << n*n-m << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <vector>
#include <cmath>
#include <cstdint>
#include <string>

using namespace std;

int main() {
  int n;
  int rooms[4][3][10] = {};
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int b, f, r, v;
    cin >> b >> f >> r >> v;
    rooms[b - 1][f - 1][r - 1] += v;
  }
  for (int b = 0; b < 4; ++b) {
    for (int f = 0; f < 3; ++f) {
      for (int r = 0; r < 10; ++r) {
        cout << " " << rooms[b][f][r];
      }
      cout << endl;
    }
    if (b != 3) {
      cout << string(20, '#') << endl;
    }
  }
}

Measured memory_bytes: 3120