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


#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define F .first
#define S .second 
#define endl "\n"
using ll=long long;
using ld=long double;
using namespace std;
const ll mod=1e9+7;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll a[110000];

main(){
  ll n,k,ans=0,cnt=0;
  //cin>>n;
  // rep(i,0,n)cin>>a[i];
  char x;
  cin>>x;
  cout<<char(x+1);
 // cout<<ans;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main{

     public static void main(String []args){
        Scanner scanner = new Scanner(System.in);
         long n = (long) scanner.nextInt();
         long w = (long) scanner.nextInt(); 
         long t = (long) scanner.nextInt();
            
        long sum=0;
        
        long prev =scanner.nextInt();
        
        for(int i=1;i<n;i++)
        {
            long temp = (long) scanner.nextInt();
            sum = sum + Math.min(w*(temp - prev),t);
            prev = temp;
        }
         
         
         System.out.println(sum);
       
}
}

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

using namespace std;
typedef long long ll;
#define REP(i,n) for (ll i = 0; i < (n); ++i)

int main(){
    ll n, x;
    cin >> n >> x;
    vector<ll> a(n);
    REP(i, n){
        cin >> a.at(i);
    }
    sort(a.begin(), a.end());
    ll ans = 0;
    REP(i, n){
        if(a.at(i) <= x && i != n - 1){
            ans++;
            x -= a.at(i);
        }else if(i == n - 1 && a.at(i) == x){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,a=0,b=0 ; cin>>n ;
    string s ; cin>>s ;
    for(int i = 0 ; i < n ; i++)
    {
        if(s[i]=='W') a++ ;
        else b++ ;
    }
    if(a==0 || b==0) cout<<"0"<<endl ;
    else
    {
        int as=0 ;
        for(int i = 0 ; i < b ; i++)
        {
            if(s[i]!='R') as++ ;
        }
        cout<<as<<endl ;
    }
}


Measured memory_bytes: 3752
import java.util.*;
 
public class Main {
	public static void main (String[] args) {
		Scanner in = new Scanner(System.in);
		
		 int a = in.nextInt();
		 int b = in.nextInt();
		 
		 if(a < b){
		    for(int i = 0 ;i < b ;i++){
		     System.out.print(a);
		 }
		 }else{
		     for(int i = 0 ;i < a ;i++){
		     System.out.print(b);
		 }
		 }

      
	}
}

Measured memory_bytes: 22996
use proconio::input;
fn main() {
    input! {
        a: usize,
        b: usize,
        c: usize
    }
    let A = [a, b, c];
    let test1 = [7, 5, 5];
    let test2 = [5, 7, 5];
    let test3 = [5, 5, 7];
    if A == test1 {
        println!("YES");
    } else if A == test2 {
        println!("YES");
    } else if A == test3 {
        println!("YES");
    } else {
        println!("NO");
    }
}


Measured memory_bytes: 2140
#include<bits/stdc++.h>
using namespace std;
int N, A;
int x[50];
long long dp[51][51][3010];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N >> A;
  for(int i = 0; i < N; i++) cin >> x[i];
  dp[0][0][0] = 1;
  for(int i = 0; i < N; i++){
    for(int j = 0; j < N; j++){
      for(int k = 0; k < 2500; k++){
        if(dp[i][j][k]){
          dp[i+1][j][k] += dp[i][j][k];
          dp[i+1][j+1][k+x[i]] += dp[i][j][k];
        }
      }
    }
  }
  long long ans = 0;
  for(int i = 1; i < N+1; i++) ans += dp[N][i][i*A];
  cout << ans << endl;
  return 0;
}

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

using namespace std;
using ll = long long;

int main() {
	int N, K;
	string s;
	cin >> N >> s >> K;

	for (int i = 0; i < N; ++i) {
		if (s[i] != s[K - 1]) { s[i] = '*'; }
	}

	cout << s << endl;

	return 0;
}


Measured memory_bytes: 256
n, m = map(int,input().split())
max_l = 0
min_r = 100000
for i in range(m):
  l,r = map(int,input().split())
  max_l = max(l, max_l)
  min_r = min(r, min_r)
print(max(0, min_r-max_l+1))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
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; }

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

int main(){
    ll n; cin>>n;
    if(n==2){
        ll a,b; cin>>a>>b;
        ll x=gcd(a,b);
        rep(i,x+1){
            if(i==0)continue;
            if(x%i==0) cout<<i<<endl;
        }
    }else{
        ll a,b,c; cin>>a>>b>>c;
        ll x=gcd(a,b);
        ll y=gcd(c,x);
        rep(i,y+1){
            if(i==0)continue;
            if(y%i==0) cout<<i<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3124
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>

#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>

#include <algorithm>

using namespace std;



int main(int argc, char *argv[]) {


	int r, d, x;
	cin >> r >> d >> x;
	for (int i = 0; i < 10; i++) {
		x = r * x - d;
		cout << x << endl;
	}
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  map < char , int > count;
  string str;
  while(cin >> str){
    for(int i=0;i<(int)str.size();i++){
	if(isupper(str[i])){
	  str[i]=tolower(str[i]);
	}
    }
    for(int i=0; i<(int)str.size();i++){
	count[str[i]]++;
	if(i==(int)str.size()-1) break;
    }
  }
  for(char ch='a';ch<='z';ch++){
    cout << ch <<" : "  << count[ch] << endl;
  }
  return 0;
}


Measured memory_bytes: 3152
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
 
void c_p_c()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 
}
 
int32_t main()
{
    c_p_c();
    int n;
    cin>>n;
    set<string> st;
    for(int i=1;i<=n;i++)
    { string s;
        cin>>s;
        st.insert(s);
    }
     
    cout<<st.size();
    return 0;
}

Measured memory_bytes: 19248
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("avx") 
#include <bits/stdc++.h>

using namespace std;

#define mp make_pair
#define pb push_back
#define makeunique(x) sort(all(x)), (x).resize(unique(all(x)) - (x).begin())
#define re return
#define fi first
#define se second
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define sqrt(x) sqrt(abs(x))
#define y0 y3487465
#define y1 y8687969
#define j0 j5743892
#define j1 j542893
                         
typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double D;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef vector<vi> vvi;

template<class T> T abs(T x) { re x > 0 ? x : -x; }
template<class T> T gcd(T a, T b) { re a ? gcd (b % a, a) : b; }
template<class T> T sqr(T a) { re a * a; }
template<class T> T sgn(T a) { re a > 0 ? 1 : (a < 0 ? -1 : 0); }

const double pi = acos(-1.0);

#define filename ""

int n;
int m;

int main () {
//  freopen (filename".in", "r", stdin);
//  freopen (filename".out", "w", stdout);
    const int mod = 1000000007;
    cin >> n;
    vector <ll> pw2(n + 1);
    pw2[0] = 1;
    for (int i = 1; i <= n; i++) pw2[i] = (pw2[i - 1] * 2ll) % mod;
    map<pair<ll, ll>, pair<int, int>> w;
    ll add = 0;
    for (int i = 0; i < n; i++) {
        ll a, b;
        cin >> a >> b;
        ll d = gcd(abs(a), abs(b));
        if (d > 0) {
            a /= d;
            b /= d;
        }
        if (b < 0) a *= -1, b *= -1;
        if (a == 0 || b == 0) {
            if (a == 0 && b == 0) add++;
            else if (a == 0) w[mp(0, 1)].fi++;
            else if (b == 0) w[mp(0, 1)].se++;
            
        } else {
            if (a < 0) w[mp(abs(b), abs(a))].fi++;
            else w[mp(abs(a), abs(b))].se++;
        }
    }
    ll ans = 1;
    for (auto x : w) {
        ans = (ans * (pw2[x.se.fi] + pw2[x.se.se] - 1 + mod) % mod) % mod;
    }
    cout << (ans + mod - 1 + add) % mod << endl;
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<vector<vector<int> > > data(4, vector<vector<int> >(3, vector<int>(10)));
  for (int i=0; i<N; i++) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    data.at(a-1).at(b-1).at(c-1) += d;
  }
  
  for (int i=0; i<4; i++) {
    if (i != 0) cout << "####################" << endl;
    for (int j=0; j<3; j++) {
      for (int k=0; k<10; k++) {
        if (k != 9)
        cout << " " << data.at(i).at(j).at(k);
        if (k == 9)
        cout << " " << data.at(i).at(j).at(k) << endl;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 3132
n=int(input())
a=[int(i) for i in input().split()]
sum=0
ans=[0 for i in range(n)]
for i in range(n):
    if i%2==0:
        sum+=a[i]
    else:
        sum-=a[i]
ans[0]=int(sum/2*2)
ans[n-1]=int(a[n-1]*2-ans[0])
for j in range(n-2,0,-1):
    ans[j]=int(a[j]*2-ans[j+1])
print(*ans)

Measured memory_bytes: 65380
import heapq

q = int(input())
l = []
r = []
ans = 0

for i in range(q):
    a = list(map(int,input().split()))
    if a[0] == 1:
        ans += a[2]
        if l == []:
            heapq.heappush(r,a[1])
            heapq.heappush(l,-a[1])
        else: 
            ll = -heapq.heappop(l)
            rr = heapq.heappop(r)
            if ll <= a[1] <= rr:
                heapq.heappush(r,rr)
                heapq.heappush(l,-ll) 
                heapq.heappush(r,a[1])
                heapq.heappush(l,-a[1]) 

            elif ll > a[1]:
                ans += ll-a[1]
                heapq.heappush(r,rr)
                heapq.heappush(r,ll) 
                heapq.heappush(l,-a[1])
                heapq.heappush(l,-a[1]) 
            else:
                ans += a[1] -rr
                heapq.heappush(l,-rr)
                heapq.heappush(l,-ll) 
                heapq.heappush(r,a[1])
                heapq.heappush(r,a[1]) 
        
    else:
        a = heapq.heappop(l)
        print(-a,ans)
        heapq.heappush(l,a)

Measured memory_bytes: 19068
import heapq

n, k = map(int, input().split())
vs = list(map(int, input().split()))

max_v = -float('inf')
for a in range(min(k, n)+1):
    total = 0
    minus = []
    for i in range(a):
        total += vs[i]
        if vs[i] < 0:
            heapq.heappush(minus, vs[i])
    max_v = max(max_v, total)
    for b in range(min(k-a, n-a)+1):
        c = k - a - b
        if c < 0:
            break
        h = minus[:]
        t = total
        for i in range(b):
            t += vs[n-1-i]
            if vs[n-1-i] < 0:
                heapq.heappush(h, vs[n-1-i])
        for i in range(c):
            if h:
                v = heapq.heappop(h)
                t -= v
            else:
                break
        max_v = max(max_v, t)

print(max_v)


Measured memory_bytes: 3188
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <valarray>
#include <vector>

#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(__typeof((X).begin()) it=(X).begin();it!=(X).end();it++)
#define ite iterator
#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 pb push_back
#define sec second
#define sz(x) ((int)(x).size())

using namespace std;

struct timer{
	time_t start;
	timer(){start=clock();}
	~timer(){cerr<<1.*(clock()-start)/CLOCKS_PER_SEC<<" secs"<<endl;}
};

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

int s,n,t,p,m;
string w,T;

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	
	while(cin>>s>>n>>t>>w>>T>>p>>m && s){
		int ok,cycle;
		if(w=="All"){
			if(T=="All")ok=1,cycle=1;
			else ok=720,cycle=1440;
		}else{
			if(T=="All")ok=1440,cycle=10080;
			else if(T=="Day")ok=720,cycle=10080;
			else ok=-1,cycle=10080;
		}
		int maxchance=0;
		if(ok==1 && cycle==1){
			maxchance=m;
		}
		else rep(i,cycle){
			int cur=i,chance=0;
			rep(j,m){
				int hatch=cur+s;
				if(ok!=-1){
					if(hatch<ok)chance++;
				}else{
					if(hatch<360 || 1080<=cur && hatch<1440)chance++;
				}
				cur=(cur+t)%cycle;
			}
			maxchance=max(maxchance,chance);
		}
		cout<<fixed<<setprecision(16)<<1-pow(1-1./p,maxchance*n)<<endl;
	}
}

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

using namespace std;
typedef long long int ll;

int main()
{
    ll N;
    cin >> N;
    ll ans = 0;
    for(ll i = 1; i <= N; i++)
    {
        ll k = N / i;
        ans += i * k * (k+1) / 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pa;
typedef unsigned int uint;
typedef unsigned long long ull;
#define w1 first
#define ls son[x][0]
#define w2 second
#define rs son[x][1]
#define mp make_pair
#define pb push_back
#define mid ((l+r)>>1)
#define SZ(x) (int((x).size()))
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define rep2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define per(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
#define Rep(p,x) for(int (p)=head[(x)];(p);(p)=nxt[(p)])
#define Rep2(p,x) for(int (p)=cur[(x)];(p);(p)=nxt[(p)])
template<class T>void read(T&num){
	num=0;T f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')num=num*10+ch-'0',ch=getchar();
	num*=f;
}
const int maxn=2e5+5;
int n;
int fa[maxn],leaf[maxn],cnt[maxn],son[maxn][2];
ll v[maxn];
vector<pair<ll,ll> >S[maxn];
bool check(ll lim){
	rep(i,1,n)S[i].clear();
	rep(i,1,n)if(leaf[i])S[i].pb(mp(v[i],v[i]));
	per(x,n,1)if(cnt[x]){
		int j=0;
		rep2(i,0,SZ(S[ls])){
			while(j<SZ(S[rs])&&S[ls][i].w2+S[rs][j].w1<=lim)j++;
			if(j)S[x].pb(mp(S[ls][i].w1,S[rs][j-1].w2));
		}
		j=0;
		rep2(i,0,SZ(S[rs])){
			while(j<SZ(S[ls])&&S[rs][i].w2+S[ls][j].w1<=lim)j++;
			if(j)S[x].pb(mp(S[rs][i].w1,S[ls][j-1].w2));
		}
		if(!SZ(S[x]))continue;
		sort(S[x].begin(),S[x].end());
		int cnt=0;
		rep2(i,1,SZ(S[x]))if(S[x][i].w2<S[x][cnt].w2)S[x][++cnt]=S[x][i];
		S[x].resize(cnt+1);
		rep2(i,0,SZ(S[x]))S[x][i].w1+=v[x],S[x][i].w2+=v[x];
	}
	return SZ(S[1])>0;
}
int main(){
	read(n);
	rep(i,1,n)leaf[i]=1;
	rep(i,2,n)read(fa[i]),read(v[i]),leaf[fa[i]]=0,son[fa[i]][cnt[fa[i]]++]=i;
	ll l=0,r=1e10,ans=r;
	while(l<=r){
		if(check(mid))ans=mid,r=mid-1;
		else l=mid+1;
	}
	printf("%lld\n",ans);
	return 0;
}

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

const int inf = 1e9;
const ll linf = 1e18;
const ll mod = 1e9 + 7;

vector<ll> memo(200000, 0);

ll fib(int n)
{
    if (n == 0) return 0;
    if (n == 1) return 1;
    if (memo[n]) return memo[n];
    return memo[n] = (fib(n - 1) % mod + fib(n - 2) % mod) % mod;
}

int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> a(M + 2);
    a[0] = -1;
    for (int i = 1; i <= M; i++) cin >> a[i];
    a[M + 1] = N + 1;

    ll cnt = 1;
    for (int i = 1; i <= M + 1; i++)
    {
        if (a[i] == a[i - 1]) continue;
        int step = a[i] - a[i - 1] - 1;
        ll cnt_tmp = fib(step);
        cnt = (cnt * cnt_tmp) % mod;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 4992
#include<iostream>
#include<cmath>
#include<vector>

using namespace std;

bool isPrime(int v){
  int i=3; 
  if(v==2) return true;
  if(v%2==0 or v==1) return false;
  while(i<=sqrt(v)){
    if(v%i==0) return false;
    i+=2;
  }
  return true;
}

int main(int argc,char* argv[]){
  int n,value;
  vector<int> values;
  int count=0;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> value;
    values.push_back(value);
  }
  for(int v: values){  
    if(isPrime(v)==true){
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 3160
import java.io.*;
import java.util.*;

class Main{
	public void run(){
		int n = ni();
        long ts = 1;
        long as = 1;
        for(int i=0;i<n;i++){
            long t = nl();
            long a = nl();
            long tm = (ts % t == 0) ? (ts / t) : (ts / t + 1);
            long am = (as % a == 0) ? (as / a) : (as / a + 1);
            long m = Math.max(tm, am);
            ts = t * m;
            as = a * m;
        }
        out.println(ts + as);
	}

	private static PrintWriter out;
	public static void main(String[] args){
		out = new PrintWriter(System.out);
		new Main().run();
		out.flush();
	}

	public Main(){
	}

	int ni(){
		int num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10 + (c - '0');
		}
		return minus ? -num : num;	}

	long nl(){
		long num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10l + (c - '0');
		}
		return minus ? -num : num;
	}

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

	String next(){
		int c;
		while(!isAlNum(c = read()));
		StringBuilder build = new StringBuilder();
		build.append((char)c);
		while(isAlNum(c = read())){
			build.append((char)c);
		}
		return build.toString();
	}
	String nextLine(){
		int c;
		while(!isAlNumOrSpace(c = read()));
		StringBuilder build = new StringBuilder();
		build.append((char)c);
		while(isAlNumOrSpace(c = read())){
			build.append((char)c);
		}
		return build.toString();
	}
	private static byte[] inputBuffer = new byte[1024];
	private static int bufferLength = 0;
	private static int bufferIndex = 0;
	
	private static int read(){
		if(bufferLength < 0) throw new RuntimeException();
		if(bufferIndex >= bufferLength){
			try{
				bufferLength = System.in.read(inputBuffer);
				bufferIndex = 0;
			}catch(IOException e){
				throw new RuntimeException(e);
			}
			if(bufferLength <= 0) return (bufferLength = -1);
		}
		return inputBuffer[bufferIndex++];
	}
	
	private static boolean isAlNum(int c){
		return '!' <= c && c <= '~';
	}
	private static boolean isAlNumOrSpace(int c){
		return isAlNum(c) || c == ' ' || c == '\t';
	}
	void debug(Object... os){
		out.println(Arrays.deepToString(os));
	}
}

Measured memory_bytes: 8656
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <cmath>
#include <complex>
#include <map>
using namespace std;

#define rep(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second

static const double PI=6*asin(0.5);
typedef long long ll;
typedef complex<double> CP;
typedef pair<int,int> P;
static const int INF=1<<24;

int main(){
	double a,b,c,d,e,f;
	while(cin>>a>>b>>c>>d>>e>>f){
		double x,y;
		if(a==0){
			y=c/b;
			x=(f-e*y)/d;
		}
		else if(b==0){
			x=c/a;
			y=(f-d*x)/e;
		}
		else if(d==0){
			y=f/e;
			x=(c-b*y)/a;
		}
		else if(e==0){
			x=f/d;
			y=(c-a*x)/b;
		}
		else{
			double td=d,te=e,tf=f;
			//(f-e*y)/d=(c-b*y)/a
			y=(f/d-c/a)/(e/d-b/a);
			x=(c-b*y)/a;
		}
		printf("%.3f %.3f\n",x,y);
	}
	return 0;
}

Measured memory_bytes: 1236
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

void main()
{
    long X = lread();
    long n = 1;
    foreach (i; 2 .. 32)
    {
        long j = 2;
        while (i ^^ j <= X)
        {
            n.maxAssign(i ^^ j);
            j++;
        }
    }
    writeln(n);
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cassert>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<list>
#include <cstring>
#include <functional>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF ((Int)1<<60)
#define EPS (1e-10)
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define RREP(i,n) for(int i=1; i<=(int)(n); ++i)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
typedef long long Int;
typedef pair<Int, Int> PI;
typedef pair<int, int> P;
typedef vector<double> vec;
typedef vector<vec> mat;
const int N = 100005;
//////////////////////////////

int dp[1003][5003];

void solve()
{
	int n, m; cin >> n >> m;
	vector<int> a(m), b(m), c(m, 0);
	REP(i, m) {
		cin >> a[i] >> b[i];
		REP(j, b[i]) {
			int t; cin >> t; t--;
			c[i] += (1 << t);
		}
	}
	REP(i, 1003) REP(j, 5003) dp[i][j] = INF;
	dp[0][0] = 0;

	REP(i, m) REP(s, (1 << n)) {
		dp[i + 1][s] = min(dp[i + 1][s], dp[i][s]);
		dp[i + 1][s | c[i]] = min(dp[i + 1][s | c[i]], dp[i][s] + a[i]);
	}

	cout << (dp[m][(1 << n) - 1] < INF ? dp[m][(1 << n) - 1] : -1) << endl;
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(13);
	solve();
	return 0;
}


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

#define ld long double
#define ll long long int
#define ull unsigned long long int

using namespace std;

int main() {

    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;


    char s = S[K - 1];
    if (s == 'A') {
        S[K - 1] = 'a';
    }

    if (s == 'B') {
        S[K - 1] = 'b';
    }
    if (s == 'C') {
        S[K - 1] = 'c';
    }


    cout << S << endl;

}

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

using namespace std;
int main(){
 int n;
 cin>>n;
 vector<int> v(n);
 set<int> st;
 int res=0;
 for(int i=0;i<n;++i){
  int a;
  cin>>a;
  if(st.insert(a).second) res++;
}
 if((n-res)%2==0) cout<<res<<endl;
 else cout<<res-1<<endl;
}

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

const ll INF = 1000000007;

int main() {
  ll N, M;
  cin >> N >> M;
  vector<ll> a(M);
  rep(i, M) cin >> a[i];
  a.push_back(N+1);
  vector<ll> dp(100010);
  for (ll i = 0; i < M; i++) {
    if (a[i] == a[i+1]-1) {
      cout << 0 << endl;
      return 0;
    }
  }
  for (ll i = 0; i < 100010; i++) {
    if (i == 0 || i == 1) {
      dp[i] = 1;
    }
    else {
      dp[i] = dp[i-1] + dp[i-2];
      dp[i] %= INF;
    }
  }
  ll ans = 1;
  for (ll i = 0; i <= M; i++) {
    if (i == 0) {
      ans *= dp[a[i]-1];
      ans %= INF;
    }
    else {
      ans *= dp[a[i] - a[i-1] -2];
      ans %= INF;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const S = arg[0].split("");
    
    let answer = "Yes";
    
    for(let i in S) {
        if(i % 2 === 0 && S[i] === "L") {
            answer = "No";
            break;
        }
        
        if(i % 2 !== 0 && S[i] === "R") {
            answer = "No";
            break;
        }
    }

    console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<ll, ll> pll;

const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;

#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = ll(b)-1; i >= (a); i--)
#define MAPIT(i,c,k) for (auto i = (c).equal_range((k)).first; i!= (c).equal_range((k)).second; i++)

#define sz(c) ll((c).size())
#define all(c) (c).begin(), (c).end()
#define mp make_pair
#define pb push_back
#define xx first
#define yy second
#define has(c, i) ((c).find(i) != (c).end())
#define DBG(X) ({ if(1) cerr << "DBGDO: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(nullptr);

	int N;
	cin >> N;
	int none = 0, one = 0, more = 0;

	FOR(i, 0, N){
		int x;
		cin >> x;
		int c = 0;
		while(x % 2 == 0){
			c++;
			x /= 2;
		}
		if(c == 0){
			none++;
		} else if (c == 1){
			one++;
		} else {
			more++;
		}
	}

	if(one == 0 && more+1 >= none){
		cout << "Yes" << endl;
		return 0;
	}

	//one != 0
	if(none <= more){
		cout << "Yes" << endl;
		return 0;
	}

	cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

#define num_max(p,q)((p)>(q)?(p):(q))
#define num_min(p,q)((p)<(q)?(p):(q))
int cmp(const void *a, const void *b)
{
	return *(int*)a - *(int*)b;//昇順
	 //降順ならreturn *(int*)b - *(int*)a;
}
int main()
{
	int a, b;
	scanf("%d%d", &a, &b);
	if (1<=a&&a<=9&&1<=b&&b<=9)printf("%d\n", a*b);
	else printf("-1\n");
	return 0;
}

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

void dfs(vector<vector<int> > &G, vector<int> &ans, vector<int> &d, int par, int node){
    //cout << "debug: " << node + 1 << " " << par + 1 << endl;
    
    ans[node] = par;
    for(int i = 0; i < G[node].size(); i++){
        d[G[node][i]]--;
    }

    for(int i = 0; i < G[node].size(); i++){
        if(d[G[node][i]] == 0) dfs(G, ans, d, node, G[node][i]);
    }

    for(int i = 0; i < G[node].size(); i++){
        d[G[node][i]]++;
    }
}

signed main(){

    int n, m; cin >> n >> m;
    vector<vector<int> > G(n);
    vector<int> d(n);
    for(int i = 0; i < n + m - 1; i++){
        int a, b; cin >> a >> b;
        // a -> b
        a--;
        b--;
        d[b]++;
        G[a].push_back(b);
    }

    vector<int> ans(n, 0);
    for(int i = 0; i < n; i++){
        if(d[i] == 0){
            dfs(G, ans, d, -1, i);
            break;
        }
    }

    for(int i = 0; i < n; i++){
        cout << ans[i] + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 14080
using System;
using System.Collections.Generic;
using System.Linq;

public class Prog
{
    public void run()
    {
        int N = int.Parse(Console.ReadLine());
        int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int[] srt = new int[N];
        input.CopyTo(srt, 0);
        Array.Sort(srt);
        int bef = srt[srt.Length / 2 - 1];
        int aft = srt[srt.Length / 2];
        for(int i=0;i<N;i++)
        {
            if(input[i] <= bef)
            {
                Console.WriteLine(aft);
            }else
            {
                Console.WriteLine(bef);
            }
        }
    }
    public static void Main()
    {
        var prog = new Prog();
        prog.run();
    }

    /*
    最小公倍数
    public static long Lcm(long a, long b)
    {
        return a * b / Gcd(a, b);
    }

    // ユークリッドの互除法 
    public static long Gcd(long a, long b)
    {
        if (a < b)
            // 引数を入替えて自分を呼び出す
            return Gcd(b, a);
        while (b != 0)
        {
            var remainder = a % b;
            a = b;
            b = remainder;
        }
        return a;
    }
    */
    //a<=c, b<=d;
}

//Split().Select(int.Parse).ToArray()
//Array.ConvertAll(int.Parse)
//str.IndexOf("Stage",System.StringComparison.CurrentCulture)


Measured memory_bytes: 38236
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric>

#define ull unsigned long long
#define ul unsigned long
#define ll long long
#define size_t unsigned long long

using namespace std;

// std::sort(&a[0], &a[4], [](auto& x, auto& y){return x[0] < y[0];});
int main() {

  cin.tie(0);
  ios::sync_with_stdio(false);

  int64_t n,k;
  std::cin >> n >> k;
  // int64_t td[n][2];
  vector<vector<int64_t>> td(n, vector<int64_t>(2,0));
  for (int64_t i = 0; i < n; i++) {
    std::cin >> td[i][0];
    std::cin >> td[i][1];
  }

  sort(td.begin(), td.end(), [](auto& x, auto& y){return x[0] > y[0];});
  sort(td.begin(), td.end(), [](auto& x, auto& y){return x[1] > y[1];});

  vector<int64_t> chofuku;
  int64_t dp[100001] = {};
  int64_t ans = 0;
  for (size_t i = 0; i < k; i++) {
    ans += td[i][1];
    dp[td[i][0]]++;
    if(dp[td[i][0]] > 1){
      chofuku.push_back(i);
    }
  }

  int64_t x = (k - chofuku.size());
  ans = ans + x * x;
  int64_t temp = ans;
  for(int64_t i = k; i < n; i++){
    if(chofuku.size() == 0){
      break;
    }
    if(dp[td[i][0]] == 0){
      temp = temp - td[chofuku[chofuku.size() - 1]][1] + td[i][1] - x*x +(x+1)*(x+1) ;
      dp[td[i][0]]++;
      dp[td[chofuku[chofuku.size() - 1]][0]]--;
      chofuku.pop_back();
      x += 1;
      if(ans < temp){
        ans = temp;
      }
    }
  }

  std::cout << ans << '\n';


  return 0;
}


Measured memory_bytes: 7164
using System.Collections.Generic;
using System.Linq;
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var p = new List<int>();
        GeneratePrime(p, 55555);
        Console.Write(11);
        var count = 1;
        for (int i = 5; i < p.Count(); i++)
        {
            if (p[i] % 5 == 1)
            {
                Console.Write(" {0}", p[i]);
                count++;
                if (count == n) break;
            }
        }
        Console.WriteLine();
    }
    public static void GeneratePrime(List<int> primeList, int m)
    {
        int prime;
        var sqrtMax = Math.Sqrt(m);
        var searchList = Enumerable.Range(2, m - 1).ToList();
        do
        {
            prime = searchList.First();
            primeList.Add(prime);
            searchList.RemoveAll(n => n % prime == 0);
        }
        while (prime < sqrtMax);
        primeList.AddRange(searchList);
    }
}


Measured memory_bytes: 11616
//#include<iostream>
#include<stdio.h>
#include <utility>
#include<algorithm>

using namespace std;

int main(void){

	int k, m, n, l;

	int x[100001];
	int sa[100002];
	int ans;

	scanf("%d %d",&n,&m);

	for (k = 0; k < m; k++) {
		if (k != m-1) {
			scanf("%d ", &x[k]);
		}
		else {
			scanf("%d", &x[k]);
		}
	}
	
	if (n >= m) {
		printf("0");
	}
	else {
		sort(x, x + m);

		for (k = 0; k < m-1; k++) {

			sa[k] = x[k+1] - x[k];
		}
		sort(sa, sa + m );

		//	printf("%d %d\n%d %d\n\n",n,m, x[m], x[1]);

		ans = x[m - 1] - x[0];

		for (k = 0; k < n - 1 ; k++) {
			ans = ans - sa[m - 1 - k];
		}

		printf("%d\n", ans);

/*		for (k = 0; k < m; k++) {
				printf("%d\n", x[k]);
			}

			for (k = 1; k < m; k++) {
				printf("%d\n",sa[k]);
			}*/

	}
	return 0;
}

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

int main(){

    int N,K;
    cin >> N >> K;

    int ans=0;
    for (size_t i = 0; i < N; i++)
    {
        int a;
        cin >> a;
        if(a>=K)ans++;
    }

    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);

int main()
{
	// fast
	ll k;
	ll p[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	cin>>k;
	// if(k)
	cout<<p[k-1];
	return 0;
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
flag=0
count=1


for i in range(N-1):

    if flag==1 and A[i+1]<A[i] or flag==-1 and A[i+1]>A[i] or flag=="st":
        count+=1
        flag=0
    elif flag==0:
        if A[i+1]==A[i]:
            pass
        elif A[i+1]>A[i]:
            flag=1
        else:
            flag=-1


print(count)


Measured memory_bytes: 62704
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
#define ll long long
#define MAX 100100
inline int read()
{
    int x=0;bool t=false;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
    if(ch=='-')t=true,ch=getchar();
    while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
    return t?-x:x;
}
int n,x[MAX],m,d[MAX],ans[MAX],tmp[MAX];ll K;
double a[MAX];
int main()
{
    n=read();
    for(int i=1;i<=n;++i)x[i]=read();
    m=read();cin>>K;
    for(int i=1;i<=n;++i)d[i]=i,ans[i]=i;
    for(int i=1;i<=m;++i)
    {
        int x=read();
        swap(d[x],d[x+1]);
    }
    while(K)
    {
        if(K&1)
        {
            for(int i=1;i<=n;++i)tmp[i]=ans[d[i]];
            for(int i=1;i<=n;++i)ans[i]=tmp[i];
        }
        for(int i=1;i<=n;++i)tmp[i]=d[d[i]];
        for(int i=1;i<=n;++i)d[i]=tmp[i];
        K>>=1;
    }
    for(int i=1;i<=n;++i)a[i]=x[ans[i]]-x[ans[i]-1];
    for(int i=1;i<=n;++i)printf("%.1lf\n",a[i]+=a[i-1]);
    return 0;
}

Measured memory_bytes: 3840
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
//increase stack size
#pragma comment(linker, "/STACK:16777216")

ll mxm() {return LLONG_MIN;}
template<typename... Args>
ll mxm(ll a, Args... args) { return max(a,mxm(args...)); }

ll mnm() {return LLONG_MAX;}
template<typename... Args>
ll mnm(ll a, Args... args) { return min(a,mnm(args...)); }

template<class T> ostream& operator<<(ostream& os,vector<T> V){
	os<<"[ ";for(auto v:V)os<<v<<" ";return os<<"]";
}
template<class L,class R> ostream& operator<<(ostream& os,pair<L,R> P){
	return os<<"("<<P.first<<","<<P.second<<")";
}

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__,__VA_ARGS__)
template<typename Arg1>
void __f(const char* name,Arg1&& arg1){
	cout<<name<<" : "<<arg1<<endl;
}
template <typename Arg1,typename... Args>
void __f(const char* names,Arg1&& arg1,Args&&... args){
	const char* comma=strchr(names+1,',');cout.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1,args...);
}
#else
#define trace(...) 1
#endif

#define ld long double
#define pll pair<ll,ll>
#define ii pair<int,int>
#define vll vector<ll>
#define vii vector<ii>
#define vi vector<int>
#define vpll vector<pll>
#define vld vector<ld>
#define vvld vector<vld>
#define vvi vector<vi>
#define vvll vector<vll>
#define vvpll vector<vpll>
#define vvii vector<vii>
#define I insert
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define all(x)	x.begin(),x.end()

const int mod=1e9+7;
// 128 bit: __int128
inline int add(int a,int b){a+=b;if(a>=mod)a-=mod;return a;}
inline int sub(int a,int b){a-=b;if(a<0)a+=mod;return a;}
inline int mul(int a,int b){return (a*1ll*b)%mod;}
inline int power(int a,int b){int rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
inline int inv(int a){return power(a,mod-2);}

struct compare{
	bool operator() (const int &a,const int &b) const{
		return a>b;
	}
};

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout<<setprecision(25);
	int n, k;
	cin >> n >> k;
	int ans = 0;
	vll pref(n + 1);
	for(int i = 1; i <= n; i++)
		pref[i] = pref[i - 1] + i;
	for(int i = k; i <= n + 1; i++){
		ll x = pref[n] - (i == n + 1 ? 0 : pref[n - i]) - pref[i - 1] + 1;
		ans = add(ans, x % mod);
	}
	cout << ans << endl;
}

Measured memory_bytes: 4716
#include <iostream>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <typeinfo>
#define PI 3.14159265359
#define INF 99999999
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(n) rep(i, n)
#define EPS 1e-10
#define pb push_back
#define mp make_pair
typedef long long ll;
using namespace std;
typedef pair<int, int> P;

bool isLeap(int y);
ll gcd(ll a, ll b);
ll lcm(ll a, ll b);
double distanceAB(double xa, double ya, double xb, double yb);
void trace(int A[], int N);

/*
class Target
{
public:
	vector <string> draw(int n)
	{

	}
};
*/


int w, h, c[50][50];
int dx[] = {-1, -1, -1, 0, 0, 1, 1, 1};
int dy[] = {-1, 0, 1, -1, 1, -1, 0, 1};

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


int main()
{
	while (cin >> w >> h, w || h)
	{
		int ans = 0;
		
		rep(i, h) rep(j, w) cin >> c[i][j];
		
		rep(i, h) rep(j, w)
		{
			if (c[i][j] == 1)
			{
				ans++;
				dfs(j, i);
			}
		}
		
		cout << ans << endl;
	}
	
	return 0;
}


bool isLeap(int y)
{
	return y % 400 == 0
						? true : y % 100 == 0
						? false : y % 4 == 0
						? true : false;
}

ll gcd(ll a, ll b)
{
	return (b > 0) ? gcd(b, a % b) : a;
}

ll lcm(ll a, ll b)
{
	return a / gcd(a, b) * b;
}

void trace(int A[], int N)
{
	REP(N)
	{
		if (i > 0) cout << " ";
		cout << A[i];
	}
	cout << endl;
}

double distanceAB(double xa, double ya, double xb, double yb)
{
	return sqrt((xb-xa)*(xb-xa) + (yb-ya)*(yb-ya));
}

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

main()
{
  ll int n,i;
  cin>>n;
  ll int a[n],b[n];
  for (i=0;i<n;i++)
  {
    cin>>a[i];
    b[i]=a[i];
  }
  sort(b,b+n);
  for (i=0;i<n;i++)
  {
    if (a[i]==b[n-1])
      cout<<b[n-2]<<endl;
   	else
      cout<<b[n-1]<<endl;
  }
}


Measured memory_bytes: 4736
// D - String Equivalence
// BFS version
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

int main(){
	int N; cin>>N;
	queue<pair<char,string>> q;
	q.push({'a',"a"});
	char mx; string pre;
	while(!q.empty()){
		tie(mx,pre)= q.front(); q.pop();
		if(pre.size() >= N) break;
		for(char c='a'; c<=mx+1; ++c) q.push({max(mx, c), pre + c});
	}
	cout<< pre <<endl;
	while(!q.empty()){ cout<< q.front().second <<endl; q.pop(); }
}

Measured memory_bytes: 8832
#include<bits/stdc++.h>
#define int long long
inline int read(){
	char c=getchar();while (c!='-'&&(c<'0'||c>'9'))c=getchar();
	int k=1,kk=0;if (c=='-')c=getchar(),k=-1;
	while (c>='0'&&c<='9')kk=kk*10+c-'0',c=getchar();return kk*k;
}using namespace std;
void write(int x){if (x<0)putchar('-'),x=-x;if (x/10)write(x/10);putchar(x%10+'0');}
void writeln(int x){write(x);puts("");}
int n,a,b,c,d,dd,kk;
int gcd(int x,int y){return !y?x:gcd(y,x%y);}
signed main(){
	n=read();for (int i=1;i<=n;i++){
		a=read();b=read();c=read();d=read();
		if (b>d){puts("No");continue;}
		if (a<b){puts("No");continue;}
		if (c>=b){puts("Yes");continue;}
		dd=(d-b)%b;kk=gcd(dd,b);a%=kk;//禁止区间是c+1..b-1 
		if ((b-1-a)/kk*kk+a>=c+1)puts("No");else puts("Yes"); 
	}
}


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

int main(void){
    ll n,a,b;
    cin >> n >> a >> b;
    if((a-b)%2==0){
        cout << abs(a-b)/2 << endl;
    }else{
        ll s,l;
        s=min(a,b);
        l=max(a,b);
        cout << min({l-1, n-s, (l-s-1)/2+s, ((l-s-1))/2+n-l+1}) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+7;
int n,tot,t[3],w[N],dp[N],f[N][3];
inline int read(){
	int num=0; char g=getchar(); while(g<48||57<g) g=getchar();
	while(47<g&&g<58) num=(num<<1)+(num<<3)+g-48,g=getchar(); return num;
}
int main(){
	n=read(); int ans,ansa=1,ansb=1; bool fl=0;
	for(int i=1;i<=n;i++) w[i]=read();
	for(int i=1;i<=n;i++) if(w[i]) fl=1;
	if(!fl) {cout<<0<<endl; return 0;}
	for(int i=2;i<=n;i++) if(w[i-1]>w[i]) ansa++;
	for(int i=2;i<=n;i++) if(w[i-1]<w[i]) ansb++;
	ans=min(ansa,ansb),dp[1]=0,f[1][0]=0,f[1][1]=w[1];
	for(int i=2;i<=n;i++){
		tot=0; int z=10086;
		for(int x=0;x<=2;x++)
			z=min(z,x+(w[i-1]-f[i-1][x]>w[i]));
		dp[i]=dp[i-1]+z,f[i][2]=w[i];
		for(int x=0;x<=2;x++){
			int h=f[i-1][x],g=w[i-1]-f[i-1][x];
			int ch[2]={h,w[i]-g}; if(ch[0]>ch[1]) swap(ch[0],ch[1]);
			for(int c=0;c<=1;c++){
				if(ch[c]<0) continue; ch[c]=min(ch[c],w[i]);
				if(c+x-z<=1) f[i][c+x-z]=max(f[i][c+x-z],ch[c]);
			}
		}
		f[i][2]=w[i];
	}
	if(f[n][0]!=w[n]) dp[n]++;
	cout<<min(dp[n],ans)<<endl;
	return 0;
}

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

int main() {
	int n, k;
	cin >> n;
	cin >> k;
	int ans = 1;
	for (size_t i = 0; i < n; i++){
		ans = min(ans + k, ans * 2);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
class Main{
    int dx[]={-1,0,1,0};
    int dy[]={0,1,0,-1};
    boolean[][][] map;
    class P{
	int y,x;
	P(int y,int x){
	    this.y=y;this.x=x;
	}
    }
    void run(){
	Scanner sc=new Scanner(System.in);
	while(true){
	    int w=sc.nextInt();
	    int h=sc.nextInt();
	    map=new boolean[h][w][4];
	    if((w|h)==0)break;
	    for(int i=0;i<h+h-1;i++){
		if(i%2==0){
		    for(int j=0;j<w-1;j++){
			if(sc.nextInt()==0)setWidth(i/2,j);
		    }
		}
		else{
		    for(int j=0;j<w;j++){
			if(sc.nextInt()==0)setHeight(i/2,j);
		    }
		}
	    }
	    System.out.println(BFS(w,h)+1);
	}
    }
    int BFS(int w,int h){
	LinkedList<P> queue=new LinkedList<P>();
	int[][] visited=new int[h][w];
	queue.offer(new P(0,0));
	while(!queue.isEmpty()){
	    P p=queue.poll();
	    int y=p.y;int x=p.x;
	    for(int i=0;i<4;i++){
		int ny=y+dy[i];int nx=x+dx[i];
		if(map[y][x][i]&&visited[ny][nx]==0){
		    queue.offer(new P(ny,nx));
		    visited[ny][nx]=visited[y][x]+1;
		    if(ny==h-1&&nx==w-1)return visited[ny][nx];
		}
	    }
	}
	return -1;
    }
    void setWidth(int a,int b){
	map[a][b][2]=true;
	map[a][b+1][0]=true;
    }
    void setHeight(int a,int b){
	map[a][b][1]=true;
	map[a+1][b][3]=true;
    }
    public static void main(String[] args){
	new Main().run();
    }
}

Measured memory_bytes: 12000
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<stack>
#include<map>
#include<list>
#include<string>
#include<algorithm>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back

#define ll __int64
#define P pair<ll,ll>
#define __int64 long long

int n,a;
int x[100];
ll dp[51][5100];
const int Z=2500;
const int M=100;
int main(){	
	cin>>n>>a;
	rep(i,n)cin>>x[i];
	rep(i,n)x[i]-=a;

	//rep(i,M)rep(j,M)dp[i][j]=-1;
	dp[0][Z]=1;

	rep(i,n){
		for(int j=-Z;j<=Z;j++){
				dp[i+1][j+x[i]+Z]+=dp[i][j+Z];
				dp[i+1][j+Z]+=dp[i][j+Z];
		}
	}

	cout<<dp[n][Z]-1<<endl;
	return 0;
}


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

int main()
{
    double W, H, x, y;
    cin >> W >> H >> x >> y;

    cout << W * H / 2 << " ";
    if (x == W / 2 && y == H / 2)
        cout << 1;
    else
        cout << 0;
}

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

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }





int main() {
  string str[3];
  for (int i = 0; i < 3; ++i) cin >> str[i];
  if (str[0].back() == str[1][0] && str[1].back() == str[2][0]) puts("YES");
  else puts("NO");
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
    int i, j;
    int n, m;
    int tmp1, tmp2;
    int a[50], b[50];
    int c[50], d[50];
    int ans;
    scanf ("%d %d", &n, &m);
    for (i = 0; i < n; i++) scanf("%d %d", &a[i], &b[i]);
    for (i = 0; i < m; i++) scanf("%d %d", &c[i], &d[i]);
    for (j = 0; j < n; j++) {
        tmp1 = abs(a[j] - c[0]) + abs(b[j] - d[0]);
        // printf("i = 0, ans[%d] = %d\n", j, tmp1);
        for (i = 1, ans = i; i < m; i++) {
            tmp2 = abs(a[j] - c[i]) + abs(b[j] - d[i]);
            // printf("i = %d, ans[%d] = %d\n", i, j, tmp2);
            if (tmp2 < tmp1) {
                // puts("発見");
                tmp1 = tmp2;
                ans = i + 1;
            }
        }
        printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 128
n = int(input())
v = list(map(int,input().split()))

a = [v[2*i] for i in range(int(n/2))]
b = [v[2*i+1] for i in range(int(n/2))]

from collections import Counter

x = Counter(a)
y = Counter(b)
x = list(x.items())
y = list(y.items())
x.sort(reverse=1,key=lambda p: p[1])
y.sort(reverse=1,key=lambda p: p[1])

if x[0][0] != y[0][0]:
    print(n-x[0][1]-y[0][1])
else:
    if x[0][0] == y[0][0]:
        if min(len(x),len(y))>=2:
            print(n-max(x[0][1]+y[1][1],y[0][1]+x[1][1]))
        elif len(x)==2:
            print(n-x[1][1]-y[0][1])
        elif len(y)==2:
            print(n-y[1][1]-x[0][1])
        else:
            print(int(n/2))

Measured memory_bytes: 66028
import bisect
def get_LIS(seq):
    LIS = [seq[0]]
    for i in range(1,len(seq)):
        if seq[i] >= LIS[-1]:
            LIS.append(seq[i])
        else:
            LIS[bisect.bisect_right(LIS, seq[i])] = seq[i]

    print(len(LIS))


N = int(input())
A = [int(input()) for _ in range(N)]
A = A[::-1]
get_LIS(A)

Measured memory_bytes: 99904