akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<map>
typedef unsigned long long ll;
typedef double dd;
typedef __int128 I;
#define For(i,j,k) for (int i=(int)j;i<=(int)k;++i)
#define Forr(i,j,k) for (int i=(int)j;i>=(int)k;--i)
#define Set(a,p) memset(a,p,sizeof(a))
using namespace std;

template<typename T>bool chkmax(T &a,T b) { return a<b?a=b,1:0; }
template<typename T>bool chkmin(T &a,T b) { return a>b?a=b,1:0; }

const int maxn=250000+100;
const ll modd=1000000000000000031ll;
const ll p1=1000000000000000003ll;
const ll p2=821428571428571454ll;
int n;
ll Ans;
ll p[maxn],a[maxn];
char s[maxn];
map<ll,int>ma;

inline void file() {
	freopen("ARC099F.in","r",stdin);
	freopen("ARC099F.out","w",stdout);
}

inline ll quick(ll a,ll b) {
	ll s=1;
	while (b) {
		if (b%2==1) s=(I)s*a%modd;
		a=(I)a*a%modd; b/=2;
	}
	return s;
}

int main() {
//	file();
	scanf("%d",&n);
	scanf("%s",s+1);
	p[0]=1;
	For (i,1,n) {
		p[i]=p[i-1]; a[i]=a[i-1];
		if (s[i]=='+') a[i]=((I)a[i]+p[i])%modd;
		if (s[i]=='-') a[i]=((I)a[i]+modd-p[i])%modd;
		if (s[i]=='>') p[i]=(I)p[i]*p1%modd;
		if (s[i]=='<') p[i]=(I)p[i]*p2%modd;
	}
	Forr (i,n,1) {
		++ma[a[i]];
		Ans+=ma[((I)a[n]*p[i-1]%modd+a[i-1])%modd];
	}
	printf("%lld",Ans);
	return 0;
}

Measured memory_bytes: 35584
#include <bits/stdc++.h>
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 1405;

int a[MAX_N][MAX_N];
int t[MAX_N][MAX_N];
deque<P> deq;

int main()
{
	int h,w;
	cin >> h >> w;
	int ans=0;
	rep(i,h){
		rep(j,w){
			scanf("%d",&a[i][j]);
		}
	}
	rep(i,h){
		t[i][w] = 0;
	}
	rep(j,w){
		t[0][j] = 1^a[0][j];
	}
	for(int i=1;i<h;i++){
		rep(j,w){
			if(a[i][j]==0){
				t[i][j] = t[i-1][j] + 1;
			}else{
				t[i][j] = 0;
			}
		}
	}
	int pos;
	rep(i,h){
		rep(j,w+1){
			if(deq.empty()){
				deq.push_back(P(t[i][j],j));
				continue;
			}
			deque<P>::iterator it = deq.end()-1;
			if((*it).first < t[i][j]){
				deq.push_back(P(t[i][j],j));
			}else if((*it).first > t[i][j]){
				while(!deq.empty() && (*it).first > t[i][j]){
					int S = (*it).first*(j-(*it).second);
					pos = (*it).second;
					ans = max(S,ans);
					deq.pop_back();
					it = deq.end()-1;
				}
				deq.push_back(P(t[i][j],pos));
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 18548
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef unsigned long ul;
typedef unsigned int ui;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
#define All(v) (v).begin(),(v).end()
#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 For(i,m,n) for(int i = m; i < n; i++)
#define Fors(i,m,n) for(int i = m; i <= n; i++)
#define Inf 2e9
#define F first
#define S second
#define pb push_back
#define mp make_pair
struct speed{speed(){cin.tie(); ios::sync_with_stdio(false); cout << fixed << setprecision(18);}}speed;

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

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



int main (){
    int n;
    cin >> n;
    vector<int> a;
    Rep(i,n){
        int tmp;
        cin >> tmp;
        if(tmp % 2 == 0) a.pb(tmp);
    }
    ll ans = 0;
    Rep(i,a.size()){
        int tmp = a[i];
        int cnt = 0;
        while(tmp%2 == 0){
            tmp = tmp / 2;
            cnt++;
        }
        ans += cnt;
    }
    cout << ans << "\n";
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
const ll INF = 1ll<<30;
const ll MOD = 1000000007;
const double EPS = 1e-10;
const bool debug = 0;
//------------------------------//

int X, K;
int R[112345];
int Q;
int t[112345], a[112345];
int ans[112345];

int main() {
	cin >> X >> K;
	
	R[0] = 0;
	REP(i, K) scanf("%d", R + i + 1);
	R[K + 1] = INF;
	
	cin >> Q;
	REP(i, Q) scanf("%d %d", t + i, a + i);
	
	int pos = 0;
	ll l = 0, lsum = 0, r = X, rsum = X, sum = 0;
	
	REP(i, K + 1) { // r_i-r_(i+1)[1-indexed]間
		ll tmp;  
	
		while (pos < Q && R[i + 1] >= t[pos]) {
			tmp = t[pos] - R[i];
			if (i % 2 == 0) tmp = -tmp;
			
			ll res;
			if (l >= a[pos]) res = lsum + tmp;
			else if (r <= a[pos]) res = rsum + tmp;
			else res = a[pos] + sum + tmp;
			
			chmax(res, 0); chmin(res, X);
			ans[pos++] = res;
		}
		
		if (i == K) break;
		
		tmp = R[i + 1] - R[i];
		if (i % 2 == 0) tmp = -tmp;
		
		lsum += tmp;
		rsum += tmp;
		sum += tmp;
		
		chmax(l, -sum);
		chmin(r, X - sum);
		
		chmax(lsum, 0); chmin(lsum, X);
		chmax(rsum, 0); chmin(rsum, X);
	}
	
	REP(i, Q) printf("%d\n", ans[i]);
	
	return 0;
}

Measured memory_bytes: 2816
# import numpy as np
# import scipy as sp
# import sys
# input = sys.stdin.readline
# print(a,b,c,sep="") # 半角スペースなしで出力(abc)
# n=int(input())  #数値入力 「N」だけの入力のとき
# a,b=map(int, input().split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき
# a=list(map(int, input().split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき
# a=[int(input()) for _ in range (n)]  #リスト入力  改行でa1 ... anのとき
# s=[list(map(str,list(input()))) for i in range(h)]  # 文字列の二次元配列入力
# s = [list(map(int, input().split())) for i in range(n)] # 数値の二次元配列入力
# a = b[:], a = [x[:] for x in b] # deepcopy
# chr(ord('a') + 1) # chrのインクリメント
# s.sort(key=lambda x: x[1], reverse=False) # 2番目の要素で昇順にソート（Trueなら降順）
#　

n = int(input())
a = int(input())

if n % 500 <= a:
    print('Yes')
else:
    print('No')


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

#define debug(n) cerr << #n << ':' << n << endl;

using namespace std;

using  ll = long long;

template<class T,class U>
using umap = unordered_map<T,U>;

template<class T>
using uset = unordered_set<T>;

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

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


int main(){
  int h,w,a,b; cin >> h >> w >> a >> b;
  for(int i = 0; i < h; ++i){
    for(int j = 0; j < w; ++j){
      if(i < b){
	if(j < a) cout << 1;
	else cout << 0;
      } else {
	if(j < a)cout << 0;
	else cout << 1;
      }
    }
    cout << endl;
  }
  return 0;
}


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

using namespace std;
const int nmax = 3e5 + 100;
char str[nmax];
int l[nmax],r[nmax];
int n;
int main() {
//    freopen("in.txt","r",stdin);
    scanf("%d",&n);
    scanf("%s",str+1);
    for(int i = 1;i<=n;++i){
        if(str[i] == 'E') l[i] = l[i-1] +1;
        else l[i] = l[i-1];
    }
    for(int i = n;i>=1;--i){
        if(str[i] == 'W') r[i] = r[i+1] +1;
        else r[i] = r[i+1];
    }
    int nowpos = -1,tot = 0;
    for(int i = 1;i<=n;++i){
        if(l[i] + r[i] > tot){
            tot = l[i] + r[i];
            nowpos  = i;
        }
    }
    printf("%d\n",n - tot);
    return 0;
}


Measured memory_bytes: 2944
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_mut)]
#[allow(non_snake_case)]
fn main() {
    input! {
        N: usize,
        K: usize,
        h: [usize; N],
    }

    h.sort();

    let mut min = h[K-1] - h[0];
    for ind in 0..N-K+1 {
        let candidate = h[ind + K - 1]  - h[ind];
        if min > candidate {
            min = candidate;
        }
    }

    println!("{}", min);
}


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

using namespace std;

#define pb push_back
#define ff first
#define ss second

typedef long long ll;
const ll MAXN = 2e6 + 10, inf = 1e18, mod = 1e9 + 7;

struct pair_hash {
	template <class T1, class T2>
		std::size_t operator () (const std::pair<T1,T2> &p) const {
			auto h1 = std::hash<T1>{}(p.first);
			auto h2 = std::hash<T2>{}(p.second);

			return h1 ^ h2;  
		}
};

ll pw(ll te, ll tee) {
	if (tee == 0)	return 1;
	ll res = pw(te, tee / 2);
	return (tee % 2 ? te * res * res : res * res);
}

ll n, a[MAXN], gc[MAXN], gd[MAXN], ans;

void Read_input() {
	cin >> n;
	for (ll i = 1; i <= n; i++)	cin >> a[i];
}

void Solve() {
	gc[1] = a[1];
	for (ll i = 2; i <= n; i++)	gc[i] = __gcd(a[i], gc[i - 1]);
	gd[n] = a[n];
	for (ll i = n - 1; i > 0; i--)	gd[i] = __gcd(a[i], gd[i + 1]);
	for (ll i = 1; i <= n; i++) {
		if (i == 1) {
			ans = max(ans, gd[2]);
		}
		else if (i == n) {
			ans = max(ans, gc[n - 1]);
		}
		else {
			ans = max(ans, __gcd(gc[i - 1], gd[i + 1]));
		}
	}
	cout << max(ans, gc[n]);
}

int main() {

	ios_base::sync_with_stdio(false);	cin.tie(0);	cout.tie(0);
	//freopen("input.txt", "r", stdin),	freopen("output.txt", "w", stdout);

	Read_input(),	Solve();
	return 0;
}


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

int main()
{
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;
    int xp = x + r;
    int xm = x - r;
    int yp = y + r;
    int ym = y - r;
    bool xb = (xp <= W) && (xm >= 0);
    bool yb = (yp <= H) && (ym >= 0);
    if (xb && yb)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 3112
"use strict";
function main(input) {
    var line = input.split("\n");
    let str = line[0];
    let str1 = line[1];
    str1 = str1.substring(0, str1.length-1);
    if(str === str1) console.log("Yes");
    else console.log("No");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

int main() {
	int X, Y;
	cin >> X >> Y;

	for (int crane = 0; crane <= X; crane++) {
		int turtle = X - crane;
		if (crane * 2 + turtle * 4 == Y) {
			cout << "Yes";
			return 0;
		}
	}
	cout << "No";
	return 0;
}

Measured memory_bytes: 3104
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

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

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 1e5 + 10;

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	string s;
	cin >> s;
	int ans = 0, carry = 0;
	for(int i = (int)s.length() - 1; i >= 0; i--) {
		int cur = (s[i] - '0') + carry;
		if(cur < 5) {
			ans += cur;
			carry = 0;
		}
		else if(cur == 5) {
			ans += cur;
			if((i - 1 >= 0 && s[i - 1] <= '4') || (i == 0)) {
				carry = 0;
			}
			else {
				carry = 1;
			}
		}
		else {
			ans += (10 - cur);
			carry = 1;
		}
	}
	if(carry) {
		ans++;
	}
	cout << ans;

	return 0;
}

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

using namespace std;

#define sz(x) ((int) ((x).size()))
typedef long long ll;
typedef long double ld;

int h, w, x, y, sw, sh, bw, bh, psw[200][200], psh[200][200], dp[200][200];
bool r[200][200];

void swapWidth() {
  x = w - x - 1;
  for (int i = 0; i < h; i++)
    for (int j = 0; j < w - 1 - j; j++)
      swap(r[i][j], r[i][w - 1 - j]);
}

void swapHeight() {
  y = h - y - 1;
  for (int i = 0; i < h - 1 - i; i++)
    for (int j = 0; j < w; j++)
      swap(r[i][j], r[h - 1 - i][j]);
}

int solve(int si, int sj) {
  // cout << si << " " << sj << "\n";
  dp[si + bh][sj + bw] = 0;
  for (int j = sj; j <= sj + bw; j++)
    dp[si + bh][sj + bw] += psh[si + bh][j];
  for (int i = si + bh + 1; i < si + sh; i++)
    dp[i][sj + bw] = dp[i - 1][sj + bw] + psw[i][sj + bw];
  for (int j = sj + bw + 1; j < sj + sw; j++)
    dp[si + bh][j] = dp[si + bh][j - 1] + psh[si + bh][j];
  for (int i = si + bh + 1; i < si + sh; i++)
    for (int j = sj + bw + 1; j < sj + sw; j++)
      dp[i][j] = max(dp[i - 1][j] + psw[i][j], dp[i][j - 1] + psh[i][j]);
  // for (int i = si + bh; i < si + sh; i++)
  //   for (int j = sj + bw; j < sj + sw; j++)
  //     cerr << dp[i][j] << (j < sj + sw - 1 ? " " : "\n");
  return dp[si + sh - 1][sj + sw - 1];
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(10);
  cin >> h >> w;
  char c;
  for (int i = 0; i < h; i++)
    for (int j = 0; j < w; j++) {
      cin >> c;
      r[i][j] = c == 'o';
      if (c == 'E')
        y = i, x = j;
    }
  if (x > w - x - 1)
    swapWidth();
  if (y > h - y - 1)
    swapHeight();
  sw = w - x;
  sh = h - y;
  bw = x;
  bh = y;
  // cerr << sh << " " << sw << " " << bh << " " << bw << "\n";
  for (int i = 0; i < h; i++)
    for (int j = 0; j < w; j++) {
      psh[i][j] = r[i][j] + (i > 0 ? psh[i - 1][j] : 0) - (i - bh > 0 ? r[i - bh - 1][j] : 0);
      psw[i][j] = r[i][j] + (j > 0 ? psw[i][j - 1] : 0) - (j - bw > 0 ? r[i][j - bw - 1] : 0);
      // cout << psh[i][j] << (j < w - 1 ? " " : "\n");
    }
  int r = 0;
  for (int i = 0; i <= y; i++)
    for (int j = 0; j <= x; j++)
      r = max(r, solve(i, j));//, cerr << i << " " << j << ": " << solve(i, j) << "\n";
  cout << r << "\n";
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int GYH,ZZW,m,cnt[300005],cnt2[300005];
struct P{
	int x,y;
	bool operator <(const P p) const {
		return x^p.x?x<p.x:y<p.y;
	}
}a[300005];
map<P,int> mp;
vector<int> m1,m2;
bool Judge(){
	for(int i:m1){
		for(int j:m2){
			if(!mp[{i,j}])return 1;
		}
	}
	return 0;
}
int main() {
	cin>>GYH>>ZZW>>m;
	for(int i=1,x,y;i<=m;i++)cin>>x>>y,cnt[x]++,cnt2[y]++,a[i]={x,y},mp[a[i]]=1;
	int mx1=0,mx2=0;
	for(int i=1;i<=300000;i++){
		mx1=max(mx1,cnt[i]);
		mx2=max(mx2,cnt2[i]);
	}
	for(int i=1;i<=300000;i++)if(cnt[i]==mx1)m1.push_back(i);
	for(int i=1;i<=300000;i++)if(cnt2[i]==mx2)m2.push_back(i);
	if(Judge())cout<<mx1+mx2;
	else cout<<mx1+mx2-1;
}

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

int main(){
  int A,B,C;
  
  cin>>A>>B>>C;
  
  int tmp = B;
  
  B = A;
  
  A = tmp;
  
  tmp = C;
  
  C = A;
  
  A = tmp;
  
  cout<<A<<" "<<B<<" "<<C;
  
  return 0;


}

Measured memory_bytes: 3600
//#include "bits/stdc++.h"

#include <iostream>
#include <vector>
// #include <map>
// #include <string>
// #include <algorithm>
// #include <numeric>
// #include <limits>

using namespace std;

const int num_types = 8;

using Color = short;

Color paint(int rate) {
	int unit = 400;
	int color = 0;
	int i = 1;
	if (rate < i * unit) {
		return color; // as ash
	}
	color++;
	i++;
	if (rate < i * unit) {
		return color; // as brown
	}
	color++;
	i++;
	if (rate < i * unit) {
		return color; // as green
	}
	color++;
	i++;
	if (rate < i * unit) {
		return color; // as water
	}
	color++;
	i++;
	if (rate < i * unit) {
		return color; // as blue
	}
	color++;
	i++;
	if (rate < i * unit) {
		return color; // as yellow
	}
	color++;
	i++;
	if (rate < i * unit) {
		return color; // as orange
	}
	color++;
	i++;
	if (rate < i * unit) {
		return color; // as red
	}
	return -1; // as super color
}

int countColor(const vector<bool>& palette) {
	int count = 0;
	for (auto v : palette) {
		if (v) {
			count++;
		}
	}
	return count;
}

int main() {
	int n;
	cin >> n;
	int count_super = 0;
	vector<bool> palette(num_types, false);
	for (int i = 0; i < n; i++) {
		int tmp_rate;
		cin >> tmp_rate;
		auto res = paint(tmp_rate);
		if (res == -1) {
			count_super++;
		} else {
			palette[res] = true;
		}
	}
	
	auto count = countColor(palette);
	int ans_min;
	int ans_max;
	ans_min = std::max(1, count);
	ans_max = count + count_super;
	cout << ans_min << " " << ans_max << endl;

	// std::cout << "\e[38;5;0m\e[48;5;40m --- end ---  \e[m" << std::endl; // debug
	return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  for (int i = 0; i < n; i++) cin >> p[i];
  int ans = 0;
  for (int i = 0; i < n - 1; i++) {
    if (p[i] == i + 1) {
      swap(p[i], p[i + 1]);
      ans++;
    }
  }
  if (p[n - 1] == n) ans++;
  cout << ans << "\n";
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
//int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
//int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//const ll MOD = 1000000007;
const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'

vl a;
vii G;

bool dfs(int now, int par) {
    bool res = false;
    for (int ch: G[now]) {
        if (ch == par) continue;

        if (a[ch] < a[now]) res |= !dfs(ch, now);
    }
    return res;
}

signed main() {
    int n;
    cin >> n;
    a.resize(n);
    G.resize(n);
    rep (i, n) cin >> a[i];
    rep (i, n - 1) {
        int u, v;
        cin >> u >> v;
        u--; v--;
        G[u].push_back(v);
        G[v].push_back(u);
    }

    rep (i, n) {
        if (dfs(i, -1)) cout << i + 1 << " ";
    }
    cout << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, min, max;
  cin>>a>>b;
  max = (a>b)?a:b;
  min = (a<b)?a:b;
  for(int i=0;i<max;i++)
    cout<<min;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define N 105
using namespace std;
inline int read(){
  int x = 0, f = 0;char ch = getchar();
  for (; ch <'0' || ch>'9'; ch = getchar()) if (ch == '-') f = 1;
  for (; ch >= '0'&& ch<='9'; ch = getchar()) x = (x<<1) + (x<<3) + ch - 48;
  return f ?-x :x;
}
int n, m, a[N];
int main() {
	n = read();
	m = read();
	for (int i = 1; i <= n; i++) a[i] = read();
	sort(a+1,a+1+n);
	int i;
	for (i = 1; i <= n; i++) {
		if (m >= a[i]) m -= a[i];
		else {
			printf("%d\n", i - 1);
			return 0;
		}
	}
	if (m > 0) n--;
	printf("%d\n", n);
	return 0;
}

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


int main() {
    ll n,k; cin >> n >> k;
    vector<double> p(n);
    rep(i,n) cin >> p[i];
    vector<double> q(n-k+1,0);
    rep(j,k){
        q[0]+=p[j];
    }
    rep2(i,n-k+1){
        q[i]=q[i-1]-p[i-1]+p[i+k-1];
    }
    double ans=0;
    rep(i,n-k+1){
        ans=max(ans,q[i]);
    }
    cout << fixed << setprecision(8) << (ans+k)/2 << endl;
}

Measured memory_bytes: 3328
#include <iostream>
using namespace std;
int main()
{
    int n, m;
    cin >> n >> m;
    int ll = 0, rr = 1001001001;
    for (int i = 0; i < m; ++i)
    {
        int l, r;
        cin >> l >> r;
        ll = max(l, ll);
        rr = min(r, rr);
    }
    cout << max(rr - ll + 1, 0) << endl;
}

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

int main() {
    int n;
    std::cin >> n;

    int succesion = 0;

    int answer = 0;

    uint64_t prev_h;
    std::cin >> prev_h;

    for(int i = 0; i < n - 1; ++i) {
        uint64_t h;
        std::cin >> h;

        if(h <= prev_h) {
            ++succesion;
        } else {
            answer = std::max(answer, succesion);
            succesion = 0;
        }

        prev_h = h;
    }

    answer = std::max(answer, succesion);

    std::cout << answer << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<bitset>
#include<vector>
#include<cstdlib>
using namespace std;
const int N=1145;
int n,fa[N],X[N],a[N];
vector<int>G[N];
bitset<5001>b;
void dfs(int now){
	int sum=0;
	for(int to:G[now])dfs(to),sum+=a[to];
	b.reset();
	b.set(0);
	for(int to:G[now])b=(b<<X[to])|(b<<(a[to]-X[to]));
	int x=-1;
	for(int i=X[now];~i&&x==-1;--i)if(b.test(i))x=i;
	if(x==-1)exit(puts("IMPOSSIBLE")*0);
	a[now]=sum+X[now]-x;
}
int main(){
	scanf("%d",&n);
	for(int i=2;i<=n;++i)
		scanf("%d",fa+i),G[fa[i]].push_back(i);
	for(int i=1;i<=n;++i)scanf("%d",X+i);
	dfs(1);
	puts("POSSIBLE");
	return 0;
}

Measured memory_bytes: 1408
#include <iostream>
using namespace std;
int main () {
    int t;
    cin >> t;
    if ( t == 1 ) {
        cout << "Hello World\n";
        return 0;
    }
    int a, b;
    cin >> a >> b;
    cout << (a+b) << "\n";
    return 0;
}


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


int main() {
    long long N,K;
    cin >> N >> K;
    vector<pair<int,int>> V(N);
    for(int i=0;i<N;i++){
        cin >> V[i].first;
        cin >> V[i].second;
    }
    sort(V.begin(),V.end());
    int srch=0;
    long long count=0;
    for(int i=0;i<N;i++){
        if(count < K){
            srch=V[i].first;
            count+=V[i].second;
        } else break;
    }
    cout << srch << endl;
}

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

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

template<typename T> bool chmin(T& a, T b) {return a > b ? a = b, true : false;}

template<typename T> bool chmax(T& a, T b) {return a < b ? a = b, true : false;}

int main() {
  while (true) {
    int d, e;
    cin >> d >> e;
    if (d == 0 && e == 0) break;
    double res = numeric_limits<double>::max();
    for (int i = 0; i <= d; ++i) chmin(res, abs(hypot(i, d - i) - e));
    cout << res << endl;
  }
}

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




int main(){

	long long x;
	cin>>x;
	long long ans = 0;
	ans += (x/500)*1000;
	x = (x%500);
	ans += 5*(x/5);
	cout<<ans<<endl;
	
	
	
	
	return 0;
  
}

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

using namespace std;

int main(){
    string s, t;
    cin >> s >> t;

    int sz_s = s.size();
    int sz_t = t.size();

    for(int i=sz_s - sz_t;i>=0;i--){
        bool ok = true;
        for(int j=0;j<sz_t;j++){
            if(s[i+j] != t[j] && s[i+j] != '?'){
                ok = false;
                break;
            }
        }
        if(ok){
            for(int j=0;j<sz_t;j++){
                s[i+j] = t[j];
            }

            for(int j=0;j<sz_s;j++){
                if(s[j] == '?')
                    s[j] = 'a';
            }
            cout << s << endl;
            return 0;
        }
    }
    cout << "UNRESTORABLE" << endl;


    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

        cin>>n;

        for(int i=1; i<=n; i+=2){
                int count=0;
                for(int j=1; j<=i; j++){
                        if(i%j==0) count++;
                }

                if(count==8) ans++;
        }

        cout<<ans<<endl;

        return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vct vector<ll>
#define umap unordered_map<ll,ll>
#define mpp map<ll,ll>
#define stt set<ll>
#define pir pair<ll,ll>
#define vpp vector<pair<ll,ll> >

ll poww(ll x,ll y,ll m){   
    ll res=1;
    while(y){if(y%2==0){x=(x*x)%m;y=y/2;}else{res=(res*x)%m;y--;}}
    return res;
}
void prt(vct v)
{
    for(ll i=0;i<v.size();i++)cout<<v[i]<<"\n";
    // cout<<"\n";
}
vct siev(ll n)
{
    vct ans;ll ar[n+1];
    memset(ar,-1,sizeof(ar));ar[0]=0;ar[1]=0;
    for(ll i=2;i<=n;i++)
    {if(ar[i]==-1){ans.push_back(i);ar[i]=1;for(ll j=2*i;j<=n;j=j+i)ar[j]=0;}}
    return ans;
}
ll isprime(ll n)
{
    if(n==1||n==0)return 0;
    for(ll i=2;i<=sqrt(n);i++)if(n%i==0)return 0;
    return 1;
}
ll etf(ll n) 
{
    ll result = n;
    for (ll i = 2; i * i <= n; i++) {
        if(n % i == 0) {
            while(n % i == 0)n /= i;
            result -= result / i;
        }
    }
    if(n > 1)result -= result / n;
    return result;
}
vct divsors(ll n)
{
    vct ans;//ans.push_back(1);
    for(ll i=1;i<=sqrt(n);i++)
    {if(n%i==0){ans.push_back(i);if(i!=(n/i))ans.push_back(n/i);}}
    // sort(ans.begin(),ans.end());
    return ans;
}
ll cnd(ll n){ll cnt=0;while(n){cnt++;n=n/10;}return cnt;}
ll t,m,n;
ll t1,t2,k;
ll mod=1000000007;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n>>m;
    n=max(1LL*0,n-2*m);
    cout<<n;
    
    
    
    
}

Measured memory_bytes: 256
s = input()
count = [0]*(len(s)+1)
total = 0
for i in range(len(s)):
  if s[i] == 'S':
    count[i] += 1
  else:
    if count[i] > 0:
      count[i] -= 1
      total += 1
  count[i+1] += count[i]
print(len(s)-2*total)

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

using ll = long long;
using P = pair<ll, ll>;

const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

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

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

template<class T>
bool chmax(T &a, initializer_list<T> l)
{
	return chmax(a, *max_element(l.begin(), l.end()));
}

template<class T>
bool chmin(T &a, initializer_list<T> l)
{
	return chmin(a, *min_element(l.begin(), l.end));
}

int main(int argc, char **argv)
{
	ll N, C; cin >> N >> C;
	vector<ll> X(N), V(N);
	REP(i, N) cin >> X[i] >> V[i];

	vector<ll> sumr(N+1, 0), suml(N+1, 0);
	REP(i, N)
	{
		sumr[i+1] = sumr[i] + V[i];
	}
	for (ll i = N-1; i >= 0; --i)
	{
		suml[i] = suml[i+1] + V[i];
	}

	vector<ll> dpr(N+1, 0);
	REP(i, N)
		chmax(dpr[i+1], {dpr[i], sumr[i+1]-X[i]});
	vector<ll> dpl(N+1, 0);
	for (ll i = N; i > 0; --i)
		chmax(dpl[i-1], {dpl[i], suml[i-1]-(C-X[i-1])});

	ll res{max(dpr[N], dpl[0])};
	REP(i, N)
	{
		ll tmp{0};

		// left -> right
		tmp -= (C-X[i]);
		tmp += suml[i];
		chmax(res, tmp);

		tmp -= (C-X[i]);
		tmp += dpr[i];
		chmax(res, tmp);

		tmp = 0;
		// right -> left
		tmp -= X[i];
		tmp += sumr[i+1];
		chmax(res, tmp);

		tmp -= X[i];
		tmp += dpl[i+1];
		chmax(res, tmp);
	}

	std::cout << res << std::endl;
}


Measured memory_bytes: 4992
M=parse(split(readline())[2])
C=zeros(Int,10^5)
for x=split(readline())
C[parse(Int,x)]+=1end
k=2*10^5
s=0
C=reverse(conv(C,C))
for c=C
M-=t=min(M,c)
s+=t*k
k-=1end
show(s)

Measured memory_bytes: 230820
import copy 
n = int(input())
#*L, = map(str, input().split())
#L = [int(i) for i in input().split()]
*L, = input().split()

A1 = copy.copy(L)
A2 = copy.copy(L)

def bubble_sort(A,N):
	for i in range(N):
		for j in reversed(range(i+1,N)):
			if int(A[j][1]) < int(A[j-1][1]):
				key = A[j]
				A[j] = A[j-1]
				A[j-1] = key
				#print("b",A)

"""
for i in range(N):
	for j in reversed(range(i+1,N)):
		if int(A[j][1]) < int(A[j-1][1]):
			key = A
			A[j] = A[j][0] + A[j-1][1]
			A[j-1] = key[j-1][0] + key[j][1]
			print(A)
"""


def selection_sort(A,N):
	for i in range(N):
		minj = i
		for j in range(i,N):
			if A[j][1] < A[minj][1]:
				minj = j
		if A[i][1] > A[minj][1]:
			key = A[i]
			A[i] = A[minj]
			A[minj] = key
			#print(A)

"""
def isStable(input,output):
	for i in range(len(inp)):
		if inp[i][1] == oup[i][1] and inp[i][0] != oup[i][0]:
			#print("False")
			return False
		else:
			True
"""



"""
if inp[i][1] == oup[i][1] and inp[i][0] != oup[i][0]:
	print("False")

print(inp[i][1])
print(oup[i][1])
print(inp[i][0])
print(oup[i][0])
"""

bubble_sort(A1,n)
selection_sort(A2,n)

print(*A1)
print("Stable")
print(*A2)
if A1 == A2:
	print("Stable")
else:
	print("Not stable")






Measured memory_bytes: 6348
#include<iostream>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF=2e18;
string S;
ll N;


int main(){
    cin>>N;
    cout<<N*(N-1)/2;
    return 0;
}

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

class Program{
    public static void Main(){
        string[] S = ReadLine().Split(' ');
        int N = int.Parse(S[0]);
        int K = int.Parse(S[1]);
        int Sa_min = 0;

        Sa_min = N % K;
        if(Sa_min > 1){
            Sa_min = 1;
        }

        WriteLine(Sa_min);
    } 
}

Measured memory_bytes: 11092
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

long long f[2010][2010], p[2010], a[2010], ji[2010];
struct Node {
    long long v, p;
}b[2010];

bool cmp(const Node &t1, const Node &t2) {
    return t1.v > t2.v;
}

int main() {
    int n, m = 1;
    scanf("%d", &n);
    for(int i = 1; i <= n; i++) {
        int x;
        scanf("%d", &x);
        b[i].v = x;
        b[i].p = i;
    }
    sort(b + 1, b + n + 1, cmp);
    f[1][n] = 0;
    for(int i = 1; i <= n; i++) {
        for(int j = 0; j <= i; j++) {
            int l = j + 1;
            int r = n - i + j;
            if(r + 1 <= n) f[l][r] = max(f[l][r], f[l][r + 1] + b[i].v * abs(r + 1 - b[i].p));
            if(l - 1 >= 1) f[l][r] = max(f[l][r], f[l - 1][r] + b[i].v * abs(l - 1 - b[i].p));
        }
    }
    long long ans = 0;
    for(int i = 1; i <= n; i++) {
        ans = max(ans, f[i][i] + b[n].v * abs(i - b[n].p));
    }
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 24424
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s="",sub,sub_prev,alpha;
    int alphabet[26]={},count;
    for(int i=0;i<1200;i++){
        cin>>sub;
        if(sub==sub_prev)
            break;
		s+=sub;
        sub_prev=sub;
    }
    transform(s.begin(),s.end(),s.begin(),::tolower);
    sort(s.begin(),s.end());
    for(int i=0;(int)i<s.size();i++){
        count=1;
        while(s[i]==s[i+1]){
            i++;
            count++;
        }
        alphabet[s[i]-'a']=count;
    }
    for(int i=0;i<26;i++){
        alpha = 'a'+i;
        cout<<alpha<<" : "<<alphabet[i]<<endl;
    }
}


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

const double PI = 3.14159265358979323846;
//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 1e15;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;

struct RangeCount {
    int upper, r_equal, between, l_equal, lower;

    friend std::ostream &operator<<(std::ostream &out, const RangeCount &o) {
        cout << endl;
        cout << "upper" << ' ' << o.upper << endl;
        cout << "r_equal" << ' ' << o.r_equal << endl;
        cout << "between" << ' ' << o.between << endl;
        cout << "l_equal" << ' ' << o.l_equal << endl;
        cout << "lower" << ' ' << o.lower << endl;
        return out;
    }
};


// startは含む
// endは含まない
RangeCount range_count(vector<ll>::iterator begin, vector<ll>::iterator end, ll l, ll r) {
    if (l > r) return RangeCount{0, 0, 0, 0, 0};
    if (begin >= end) return RangeCount{0, 0, 0, 0, 0};

    if (l == r) {
        RangeCount rc;
        auto it_u = upper_bound(begin, end, r);
        auto it_l = lower_bound(begin, end, r);

        rc.upper = distance(it_u, end);
        rc.r_equal = distance(it_l, it_u);
        rc.between = 0;
        rc.l_equal = rc.r_equal;
        rc.lower = distance(begin, it_l);

        return rc;
    }

    RangeCount rc;
    auto it_ru = upper_bound(begin, end, r);
    auto it_rl = lower_bound(begin, end, r);
    rc.upper = distance(it_ru, end);
    rc.r_equal = distance(it_rl, it_ru);
    auto it_lu = upper_bound(begin, end, l);
    auto it_ll = lower_bound(begin, end, l);
    rc.between = distance(it_lu, it_rl);
    rc.l_equal = distance(it_ll, it_lu);
    rc.lower = distance(begin, it_ll);

    return rc;

}


int main() {
    int n;
    cin >> n;
    vector<vector<ll>> piece(3, vector<ll>(n));
    rep(i, 3) rep(j, n) cin >> piece[i][j];
    rep(i, 3) sort(piece[i].begin(), piece[i].end());


    ll ans = 0;
    for (ll b : piece[1]) {
        RangeCount arc = range_count(piece[0].begin(), piece[0].end(), b, b);
        RangeCount crc = range_count(piece[2].begin(), piece[2].end(), b, b);

        ll l = arc.lower;
        ll u = crc.upper;

        ans += l * u;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3328
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cstring>
#include <map>
#include <cctype>
#include <string>
#include <cstdlib>
#include <math.h>
using namespace std;

int main()
{
  cout << setprecision(6);
  cout << setiosflags(ios::scientific);
  cout.flags(ios::fixed);

  int a, b, C;
  cin >> a >> b >> C;

  double rad = C * M_PI / 180.0;

  double S = 0.5 * a * b * sin(rad);
  double c = sqrt( b*b + a*a - 2 * b * a * cos(rad));
  double L = a + b + c;
  double h = 2 * S / a;

  cout << S << endl;
  cout << L << endl;
  cout << h << endl;
  
}

Measured memory_bytes: 1244
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
lint gcd( lint m, lint n )
{
	lint a=max(m,n),b=min(m,n);
	if(m==0) return n;if(n==0) return m;
	if(a%b==0) return b;
	return gcd(b,a-b*(a/b));
}
bool cal(lint a,lint b,lint c,lint d){
	if(a<b) return false;
	if(d<b) return false;
	if(c>=b+1) return true;
	lint x=gcd(d,b),y=a%x;
	//cout<<x<<' '<<y<<' '<<
	if((c+x-y)/x<(b-1+x-y)/x) return false;
	return true;
}
int main()
{
	int t;lint a,b,c,d;
	cin>>t;
	rep(i,t){
		cin>>a>>b>>c>>d;
		if(cal(a,b,c,d)) cout<<"Yes"<<endl;else cout<<"No"<<endl;
	}
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	
	int i,A[5],max=10,saigo,time=0,count=0;
	
	for(i=0;i<5;i++){
	scanf("%d",&A[i]);
	}
	
	for(i=0;i<5;i++){
		if(A[i]%10<max&&A[i]%10!=0){
			max=A[i]%10;
			saigo=A[i];
		}
		
	}
	
	for(i=0;i<5;i++){
		if(A[i]==saigo){
			count++;
		}
		
	}
	
	
	
	
	for(i=0;i<5;i++){
		if(A[i]!=saigo){
			if(A[i]%10==0){
			time+=A[i];
			}else{
				time+=A[i]+10-A[i]%10;
			}
		}else{
			time+=saigo;
		}
		
	}
	
	printf("\n%d\n\n",time+(count-1)*(10-saigo%10));
	
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>

using namespace std;
#define rep(i,N) for(int (i)=0;(i)<(N);(i)++)


int main() {
	int N, D; cin >> N >> D;
	int ans;
	if (N % (2 * D + 1) == 0) {
		ans = N / (2 * D + 1);
		cout << ans << endl;
	}
	else {
		ans = N / (2 * D + 1)+1;
		cout << ans << endl;
	}


}

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

long long f(long long b, long long n){
    if(n<b) return n;
    return f(b, n/b) + n%b;
}

int main(void){
    long long n, s, m;
    cin >> n >> s;
    m = n-s;
    if(m < 0){
        cout << -1 << endl;
        return 0;
    }else if(m == 0){
        cout << n+1 << endl;
        return 0;
    }
    long long ans = -1;
    for(long long i = 1; i*i <= m; i++){
        long long b = i+1;
        if(f(b, n) == s && (ans == -1 || ans > b)) ans = b;
        b = m/i+1;
        if(f(b, n) == s && (ans == -1 || ans > b)) ans = b;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int n;
char s[3 * 100000 + 1];

// W -- E

// リーダー位置がnのときのe,wそれぞれの側の振り返る人数(リーダーを含む)
int w_side_memo[3 * 100000 + 1];
int e_side_memo[3 * 100000 + 1];

void make_memo()
{
	w_side_memo[0] = 0;
	e_side_memo[n - 1] = 0;

	for ( int i = 1; i < n; i++ )
	{
		if ( s[i - 1] == 'W' )
		{
			w_side_memo[i] = w_side_memo[i - 1] + 1;
		}
		else
		{
			w_side_memo[i] = w_side_memo[i - 1];
		}

		int e_pos = (n - 1) - i;
		if ( s[e_pos + 1] == 'E' )
		{
			e_side_memo[e_pos] = e_side_memo[e_pos + 1] + 1;
		}
		else
		{
			e_side_memo[e_pos] = e_side_memo[e_pos + 1];
		}
	}
}

int count(int pos)
{
	int ret = 0;

	ret += e_side_memo[pos];


	ret += w_side_memo[pos];

	return ret;
}

int main()
{
	cin >> n >> s;

	make_memo();

	int ans = 3 * 100000 + 1;

	for ( int i = 0; i < n; i++ )
	{
		int c = count(i);
		if ( c < ans ) ans = c;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 2944
import Control.Applicative

main :: IO ()
main = do
  xy <- (map read . words) <$> getLine
  putStrLn (show (area (xy !! 0) (xy !! 1)) ++ " " ++ (show (surroundings (xy !! 0) (xy !! 1))))

area :: Int -> Int -> Int
area x y = x * y

surroundings :: Int -> Int -> Int
surroundings x y = 2 * (x + y)

Measured memory_bytes: 3500
import Control.Arrow
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = readLine >>= printRes . solve 
    where
        printRes b
            | b = putStrLn "Yes"
            | otherwise = putStrLn "No"

solve :: [Int] -> Bool
solve = (== 1) . length . group . sort

readLine :: IO [Int]
readLine = unfoldr (fmap (second (maybe B.empty snd . B.uncons)) . B.readInt) <$> B.getLine

readContents :: Int -> IO [[Int]]
readContents = flip replicateM readLine

Measured memory_bytes: 380
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <stack>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
using namespace std;

int main(){
    int d;
    while (cin >> d){
        int n = 600 / d, ans = 0;
        REP(i, n){
            ans += (i*d)*(i*d)*d;
        }
        cout << ans << endl;
        ans = 0;
    }
}


Measured memory_bytes: 3056
#include <iostream>
#include <vector>
#include <numeric>

using namespace std;

vector<int> sieve(int n) {
	vector<int> res(n);
	iota(res.begin(), res.end(), 0);
	for (int i = 2; i * i < n; ++i) {
		if (res[i] < i) continue;
		for (int j = i * i; j < n; j += i)
			if (res[j] == j) res[j] = i;
	}
	return res;
}

int main() {
	int n; cin >> n;
	vector<int> si = sieve(n);
    long long ans = 1;
	for (int c = 1; c < n - 1; ++c) {
		int t = n - c;
		int res = 1, cnt = 0, prev = -1;
		while (t > 1) {
			if (prev == si[t] || prev == -1) ++cnt;
			else {
				res *= cnt + 1;
				cnt = 1;
			}
			prev = si[t];
			t /= si[t];
		}
		res *= cnt + 1;
		ans += res;
	}
    cout << ans << endl;

	return 0;
}


Measured memory_bytes: 7204
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>

using namespace std;

int num[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

bool isLeapYear(int year){
	if(year % 4 != 0)return false;
	else{
		if(year % 100 == 0){
			if(year%400 == 0)return true;
			else{
				return false;
			}
		}else{
			return true;
		}
	}
}

int main(){

	int year1,month1,day1,year2,month2,day2,sum;

	while(true){
		scanf("%d %d %d %d %d %d",&year1,&month1,&day1,&year2,&month2,&day2);
		if(year1 < 0 || month1 < 0 || day1 < 0 || year2 < 0 || month2 < 0 || day2 < 0)break;

		sum = 0;

		if(year1 == year2 && month1 == month2){
			printf("%d\n",day2-day1);
		}else if(year1 == year2){

			if(month1 == 2 && isLeapYear(year1) == true){
				sum += 29 - day1;
			}else{
				sum += num[month1] - day1;
			}
			for(int i=month1+1; i < month2; i++){
				if(i == 2 && isLeapYear(year1) == true){
					sum += 29;
				}else{
					sum += num[i];
				}
			}
			sum += day2;

			printf("%d\n",sum);
		}else{

			if(month1 == 2 && isLeapYear(year1)){
				sum += 29 - day1;
			}else{
				sum += num[month1] - day1;
			}

			for(int i = month1 + 1; i <=12; i++){
				if(i == 2 && isLeapYear(year1) == true){
					sum += 29;
				}else{
					sum += num[i];
				}
			}

			for(int i = year1+1; i < year2; i++){
				if(isLeapYear(i) == true)sum += 366;
				else{
					sum += 365;
				}
			}

			for(int i=1; i < month2; i++){
				if(i == 2 && isLeapYear(year2) == true)sum += 29;
				else{
					sum += num[i];
				}
			}

			sum += day2;

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

		}


	}

    return 0;
}

Measured memory_bytes: 2668
#include<iostream>
#include<cstring>
#include<queue>
#include<algorithm>
using namespace std;
 
#define MAX_N 5500
bool x[MAX_N][MAX_N];
int y[MAX_N][2];
bool z[MAX_N];
int m[MAX_N];
int s[MAX_N];
int t[MAX_N][MAX_N];
 
queue<int> Q;
 
int main() {
    memset(x, false, sizeof(x));
    for (int i = 0; i<5500; i++) {
        for (int j = 0; j<5500; j++) {
            m[i] = 1000000000;
            s[i] = 0;
            t[i][j] = 0;
        }
    }
    int N, K, a, b;
    cin >> N >> K;
    for (int i = 1; i <= N; i++) {
        cin >> y[i][0] >> y[i][1];
    }
    for (int i = 1; i <= K; i++) {
        cin >> a >> b;
        x[a][b] = true;
        x[b][a] = true;
        t[a][s[a]] = b;
        t[b][s[b]] = a;
        s[a] += 1;
        s[b] += 1;
    }
 
    int p;
    int r;
    int u;
 
    u = N;
    if (K > 6000) {
        u = 20;
    }
 
    m[1] = 0;
 
    for (int i = 0; i < u; i++) {
        for (int j = 1; j <= N; j++) {
            if (m[j] < 100000000) {
                while (!Q.empty()) {
                    Q.pop();
                }
                Q.push(j);
                memset(z, false, sizeof(z));
                for (int k = 0; k < y[j][1]; k++) {
                    r = Q.size();
                    for (int l = 0; l < r; l++) {
                        p = Q.front();
                        for (int o = 0; o < s[p]; o++) {
                            if (x[p][t[p][o]] == true && z[t[p][o]] == false) {
                                Q.push(t[p][o]);
                                z[t[p][o]] = true;
                                m[t[p][o]] = min(m[t[p][o]], m[j] + y[j][0]);
                            }
                        }
                        Q.pop();
                    }
                    if (Q.empty()) {
                        goto Exit;
                    }
                }
            Exit:;
            }
        }
    }
 
    cout << m[N] << endl;
 
    return 0;
}
 

Measured memory_bytes: 149028