akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

#define rep(i,b,e) for(int i=b;i<e;i++)

int main(){

    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int count = 0;
    for(int i = 0; i <= 100; i++) {
        if((a < i && b >= i) && (c < i && d >= i)) count++;
    }

    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
A,B,M=map(int,input().split())
Rcost=list(map(int,input().split()))
Lcost=list(map(int,input().split()))
ans=min(Rcost)+min(Lcost)
for i in range(M):
    x,y,c=map(int,input().split())
    tmp=Rcost[x-1]+Lcost[y-1]-c
    ans=min(tmp,ans)
print(ans)

Measured memory_bytes: 18736
def ninebeki(n):
    cnt=0
    while n>=9**cnt:
        cnt+=1
    return cnt-1
def sixbeki(n):
    cnt=0
    while n>=6**cnt:
        cnt+=1
    return cnt-1

def resolve():
    n=int(input())
    cnt=0
    q=ninebeki(n)
    r=sixbeki(n)
    l=[9**i for i in range(1,q+1)]
    l+=[6**i for i in range(1,r+1)]
    l.append(1)
    l.sort()
    d=[n for i in range(n+1)]
    d[0]=0
    for c in l:
        for i in range(c,n+1):
            d[i]=min(d[i],d[i-c]+1)
    print(d[n])
resolve()

Measured memory_bytes: 44912
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

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

int n, t, ans;
map<string, int> mp;
vi power;
vector<vi> es;
vi sum;

void solve(int i, ll team, int sumpow)
{
	if (i == t)
	{
		chmax(ans, sumpow);
		return;
	}
	if (sumpow + sum[t] - sum[i] <= ans) return;
	bool f = true;
	for (auto k:es[i])
	{
		if ((team >> k) & 1)
		{
			f = false;
			break;
		}
	}
	if (f) solve(i + 1, team | (1ll << i), sumpow + power[i]);
	solve(i + 1, team, sumpow);
}

int main()
{
	cin.sync_with_stdio(false);
	while (cin >> n, n)
	{
		ans = 0;
		mp.clear(); 
		power.clear(); power.resize(n);
		es.clear(); es.resize(n);
		sum.clear(); sum.resize(n + 1);
		t = 0;
		REP(i, n)
		{
			string s; cin >> s;
			if (!mp.count(s)) mp[s] = t++;
			int tmp = mp[s];
			int p; cin >> p;
			power[tmp] = p;
			int m; cin >> m;
			REP(j, m)
			{
				string a; cin >> a;			
				if (!mp.count(a)) mp[a] = t++;
				int op = mp[a];
				es[tmp].push_back(op);
			}
		}
		REP(i, n) sum[i + 1] = sum[i] + power[i];
		solve(1, 1, power[0]);
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3152
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int a,z;
  for(int i=0;i<s.size();i++){
    if(s.at(i)=='A'){
      a=i;
      break;
    }
  }
  for(int i=s.size()-1;i>=0;i--){
    if(s.at(i)=='Z'){
      z=i;
      break;
    }
  }
  cout<<z-a+1<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
using ll = long long;
using ld = long double;
#define repd(i,a,b) for (int i=a;i<int(b);i++)
#define rep(i,n) repd(i,0,n)
#define VARNAME(v) #v
using P = pair<int,int>;


int main() {
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int BEAM = 900;
  int d;vector<int> c(26);cin>>d;rep(i,26)cin>>c[i];
  vector<array<int, 26>> s(d);
  rep(i,d)rep(j,26)cin>>s[i][j];
  vector<int> curs = {0};
  vector<array<int, 26>> curl(1);
  vector<vector<int>> cura(1);
  rep(i,d){
    int len = int(curs.size()) * 26, ind = 0;
    vector<P> nxs(len);
    vector<array<int, 26>> nxl(len);
    vector<vector<int>> nxa(len);
    rep(j, curs.size()){
      rep(t, 26){
        int score = curs[j];
        array<int, 26> last = curl[j];
        vector<int> ans = cura[j];
        score += s[i][t];
        last[t] = i+1;
        rep(k,26)score -= c[k]*(i+1 - last[k]);
        ans.emplace_back(t);
        nxs[ind] = P(score, ind);
        nxl[ind] = last;
        nxa[ind] = ans;
        ind++;
      }
    }
    sort(nxs.rbegin(), nxs.rend());
    len = min(len, BEAM);
    curs.resize(len);curl.resize(len);cura.resize(len);
    rep(j,len){
      curs[j] = nxs[j].first;
      curl[j] = nxl[nxs[j].second];
      cura[j] = nxa[nxs[j].second];
    }
    if(i % 73 == 0)BEAM -= 100;
  }
  int ans = 0;
  rep(i,min(int(curs.size()), BEAM)){
    if(curs[ans] < curs[i])ans = i;
  }

  for(auto x : cura[ans]){
    cout << x+1 << endl;
  }
}


Measured memory_bytes: 21476
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define SUM(x) accumulate(rng(x),0)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

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

  int ans = INF;
  // iは最初に使う色(0 or 1)
  rep(i,2) {
    // iを最初に使ったときに変えなければならないタイルの数
    int cnt = 0;
    rep(j,s.size()) {
      // (j%2,i) = (0,0), (1,1)のときtrue
      if ((j%2 == 0) ^ (s[j] == (char)(i+'0'))) cnt++;
    }
    ans = min(ans, cnt);
  }
  cout << ans << endl;
  return 0;
}


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

using ll = long long;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}

int main()
{
    int K; cin >> K;
    string S; cin >> S;

    if (S.size() <= K) {
        cout << S << endl;
    } else {
        cout << S.substr(0, K) << "..." << endl;
    }
}


Measured memory_bytes: 3628
#!/usr/bin/env python3
#エクサウィザーズ2019 B

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
s = input()
c = s.count('R')
if c > n - c:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
int main()
{
  int N;
  cin >> N;
  vector<vector<int>>x(N,vector<int>()),y(N,vector<int>());
  rep(i,N){
    int a;cin >> a;
    rep(j,a){
      int xx,yy;
      cin >> xx >> yy;
      xx--;
      x[i].push_back(xx);
      y[i].push_back(yy);
    }
  }
  int ans=0;
  for(int i=0;i<(1<<N);i++){
    bool ok=true;
    int cur=0;
    rep(j,N){
      if(((1<<j)&i)!=0){
        cur++;
        rep(k,x[j].size()){
          if(y[j][k]==1){
            ok&=(((1<<x[j][k])&i)!=0);
          }
          else{
            ok&=!((((1<<x[j][k])&i)!=0));
          }
        }
      }
    }
    if(ok)ans=max(ans,cur);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;

int main() {
  int N,M;
  cin >> N >> M;
  int S[N];
  int T[M];
  for (int i = 0; i < N; i++) cin >> S[i];
  for (int i = 0; i < M; i++) cin >> T[i];
  ll DP[N+1][M+1];
  vector<ll> sum(M+1);
  
  ll ans = 1;
  for (int i = 0; i <= N; i++) {
    for (int j = 0; j <= M; j++) {
      DP[i][j] = 0;
    }
  }
  for (int i = 0; i <= M; i++) {
    sum[i] = 1; 
  }
  DP[0][0] = 1;

  for (int i = 1; i <= N; i++) {
    vector<ll> newsum(M+1);
    for (int j = 0; j <= M; j++) {
      newsum[j] = 0; 
    }
    for (int j = 1; j <= M; j++) {
      if (S[i-1] == T[j-1]) {
        ll r = sum[j-1];
        r %= Mod;
        DP[i][j] = r;
      }
      newsum[j] = newsum[j-1] + DP[i][j];
      newsum[j] %= Mod; 
      ans += DP[i][j];
      ans %= Mod;
    }
    for (int j = 0; j <= M; j++) {
      sum[j] += newsum[j];
      sum[j] %= Mod;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 34792
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#define li long long int
#define ld long long double
#define PI 3.1415926535897932384626
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
typedef pair<int, int> P;

string str;

int main()
{
  double x=0,y=0;
  int a=0,b=0;
  double arg=90;
  while(1){
    scanf("%d,%d",&a,&b);
    if(a==0 && b==0)break;
    double radian=arg*PI/180.0;
    x+=a*cos(radian);
    y+=a*sin(radian);
    arg-=b;
  }
  a=x;
  b=y;
  cout<<a<<endl;
  cout<<b<<endl;
}

Measured memory_bytes: 1216
#include<iostream>
#include<string>
using namespace std;
int main(){
  string str;
  while(cin>>str){
    for(int i=0;i<str.size();i++){
      if((char)str[i]=='A')
	cout<<'X';
      else if((char)str[i]=='B')
	cout<<'Y';
      else if((char)str[i]=='C')
	cout<<'Z';
      else cout<<(char)(str[i]-3);
    }
    cout<<endl;
  }
  return 0;
}

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

const int maxn=3010;
int dp[maxn][maxn<<1][2];
int n,m,mod=1e9+7;

void add(int& x,int y){
	x+=y; if(x>=mod) x-=mod;
}

int main(){

	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) dp[0][i][0]=1;
	dp[0][0][1]=1;
	for(int i=0;i<m;i++){
		for(int j=0;j<=n;j++) for(int k=0;k<=1;k++){
			if(j){
				add(dp[i+1][j][k | (j==1)], dp[i][j][k]);
				add(dp[i+1][j-1][k | (j==1)], dp[i][j][k]);
			}
			if(n-j){
				add(dp[i+1][j+1][k], dp[i][j][k]);
				add(dp[i+1][j][k], dp[i][j][k]);
			}
		}
	}
	int ans=0;
	for(int i=0;i<=n;i++) add(ans, dp[m][i][1]);
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 140672
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;

public class Main{
	public static void main(String[] args) {
		SC sc = new SC(System.in);
		int N=sc.nextInt();
		long[][] sigoto=new long[N][2];
		for(int i=0; i<N; i++) {
			for(int j=1; j>=0; j--) {
				sigoto[i][j]=sc.nextLong();
			}
		}
		quick_sort(sigoto,0,N-1);
		for(int i=1; i<N; i++) {
			sigoto[i][1]=sigoto[i][1]+sigoto[i-1][1];
		}
		for(int i=0; i<N; i++) {
			if(sigoto[i][0]<sigoto[i][1]) {
				pl("No");
				System.exit(0);
			}
		}
		pl("Yes");
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
	static void quick_sort(long[][] d, int left, int right) {
		if (left>=right) {
			return;
		}
		long p = d[(left+right)/2][0];
		int l = left, r = right;
		long tmp,tmp1,tmp2;
		while(l<=r) {
			while(d[l][0] < p) { l++; }
			while(d[r][0] > p) { r--; }
			if (l<=r) {
				tmp = d[l][0]; d[l][0] = d[r][0]; d[r][0] = tmp;
				tmp1=d[l][1]; tmp2=d[r][1]; d[l][1]=tmp2; d[r][1]=tmp1;
				l++; r--;
			}
		}
		quick_sort(d, left, r);
		quick_sort(d, l, right);
	}
}

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

#define DEBUG(x) cerr << #x << ": " << x << endl;
#define ll long long

int main() {
    ll x;
    cin >> x;

    ll sum = 0;
    for (ll i = 1; ; i++) {
        sum += i;
        if (sum >= x) {
            cout << i << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (in i = 0; i < (in)(n); i++)
#define REP(i,a,b) for(in i=(in)(a);i<(in)(b);i++)
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const in inf=1e9+7;
using P=pair<in,in>;
vector<in> dx={0,1,-1,0};
vector<in> dy={1,0,0,-1};

//全2点間の距離をO(V^3)で求める、V:辺の数
//負の辺があっても大丈夫
//d[i][i]<0となったら負の閉路
in MAX_dist=INF;
in V=0;
vector<vector<in>> d(0,vector<in>(0,MAX_dist));//d[x][y]:=x->yのcost,枝が無ければMAX_dist,d[i][i]=0

void init(in n){
    d=vector<vector<in>>(n,vector<in>(n,MAX_dist));
    rep(i,n) d[i][i]=0;
    V=n;
}

void warshall(){
    rep(k,V){
        rep(i,V){
            if(d[i][k]==MAX_dist) continue;
            rep(j,V){
                if(d[k][j]==MAX_dist) continue;
                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
            }
        }
    }
}

int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    in v,e;
    cin>>v>>e;
    in s,t,dist;
    init(v);
    rep(i,e){
        cin>>s>>t>>dist;
        d[s][t]=dist;
    }
    warshall();
    rep(i,v){
        if(d[i][i]<0){
            cout<<"NEGATIVE CYCLE"<<endl;
            return 0;
        }
    }
    rep(i,v){
        rep(j,v-1){
            if(d[i][j]==MAX_dist) cout<<"INF ";
            else cout<<d[i][j]<<" ";
        }
        if(d[i][v-1]==MAX_dist) cout<<"INF"<<endl;
        else cout<<d[i][v-1]<<endl;
    }
}


Measured memory_bytes: 3244
def main():
  n = int(input())
  ps = list(map(int, input().split(' ')))
  ans = 0
  for i in range(0, n-2):
    t = ps[i+1]
    s = sorted(ps[i:i+3])
    ans += 1 if t == s[1] else 0
  print(ans)


if __name__ == '__main__':
  main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int n,a[105],cnt;
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n);
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			for(int k=j+1;k<n;k++)
			{
				if(a[i]==a[j]||a[i]==a[k]||a[j]==a[k])
					continue;
				if(a[i]+a[j]>a[k])
					cnt++;
			}
		}
	}
	cout<<cnt;

	return 0;
}

Measured memory_bytes: 3636
#include <iostream>

using namespace std;

long long f(long long b, long long n) {
    return b <= n ? f(b, n / b) + n % b : n;
}

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

    long long res = -1;

    long long b = 2;
    for (; (b - 1) * (b - 1) <= n; b++) {
        if (f(b, n) == s) {
            res = b;
            goto out;
        }
    }

    for (; b > 0; b--) {
        if ((n - s + b) % b == 0
                && b < (n - s + b) / b
                && 0 <= s - b
                && s - b < (n - s + b) / b) {
            res = (n - s + b) / b;
            goto out;
        }
    }

    if (n == s) {
        res = n + 1;
    }

out:
    cout << res << endl;
}


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

#define REPI(x) for(int i=0;i<x;i++)
#define REPJ(x) for(int j=0;j<x;j++)

#define REPISE (s,e) for(int i=s,i<e;i++)
#define REPJSE (s,e) for(int j=s,j<e;j++)

typedef long long ll;

using namespace std;

int main ()
{
  int N,b;
  int A[3][3],linenum[8];
  vector<int> lines[8];

  REPI(3)
    REPJ(3)
      cin >> A[i][j];
  
  REPI(3)
  {
    lines[0].push_back (A[i][0]);
    lines[1].push_back (A[i][1]);
    lines[2].push_back (A[i][2]);
    lines[3].push_back (A[0][i]);
    lines[4].push_back (A[1][i]);
    lines[5].push_back (A[2][i]);
    lines[6].push_back (A[i][i]);
    lines[7].push_back (A[i][2-i]);
  }
  REPI(8)
    linenum[i] = 0;

  cin >> N;

  REPI(N)
  {
    cin >> b;
    REPJ(8)
    {
      if (find(lines[j].begin (),lines[j].end (), b) != lines[j].end ())
        linenum[j]++;
    }
  }

  REPI(8)
  {
    if (linenum[i]==3)
    {
        cout << "Yes" << endl;
        return 0;
    }    
  }
  cout << "No" << endl;

  return 0;
}

 

Measured memory_bytes: 3556
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
using namespace std;

int main() {
    int A, B;
    cin >> A >> B;
    cout << ((A + B) / 2) + (((A + B) % 2 == 0) ? 0 : 1) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
#define pb push_back
#define ll long long int
# define pll pair<ll,ll>
# define pii pair<int,int>
# define fio ios_base::sync_with_stdio(false); cin.tie(NULL)
int main()
{   ll a,b,c,k;
    cin>>a>>b>>c>>k;
    for(int i=0;i<=k;i++)
    {
        ll x=b,y=c;
        for(int j=1;j<=i;j++) x=x*2;
        for(int j=i+1;j<=k;j++) y=y*2;
        if(x>a and y>x){ cout<<"Yes"; return 0;}
            
    }
    cout<<"No";
}


Measured memory_bytes: 3048
#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 F first
#define S second
#define mp make_pair
#define pb push_back
#define pf push_front
#define eb emplace_back
#define f(i,x,n) for(ll i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define int ll

template < typename T > using indexed_set = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;
 
const double PI = acos(-1);
const ll LINF = LLONG_MAX;
const int MOD = 1e9+7, INF = INT_MAX, N = 1e5 + 10;
 
int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int r;
   cin >> r;
   db ans = 2*PI*r;
   cout << setprecision(14) << fixed << ans << '\n';
   return 0;
}


Measured memory_bytes: 3800
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<utility>
#include<functional>
#include<stack>
#include<queue>
#include<cmath>
# define MOD 1000000000+7
# define INF 1e9
# define LINF 1e18
typedef long long ll;

using namespace std;
int gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int n = 1, d[100000] = {};
int abc = 0, arc = 0, ans = 0;

int main() {

	double w, h, x, y;
	cin >> w >> h >> x >> y;
	cout << (w * h) / 2 << " ";
	if (x * 2 == w && y * 2 == h) {
		cout << 1 << endl;
	}
	else {
		cout << 0 << endl;
	}

}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

const int INF = 1e9;
const int di[] = {-1, 1, 0, 0}, dj[] = {0, 0, -1, 1};

int main(void){
    int h, w, si, sj, gi, gj;
    cin >> h >> w >> si >> sj >> gi >> gj;
    si--;
    sj--;
    gi--;
    gj--;
    vector<string> s(h);
    REP(i,h) cin >> s[i];
    deque<P> deq;
    VVI dist(h, VI(w, INF));
    dist[si][sj] = 0;
    deq.push_back(P(si, sj));
    while (!deq.empty()){
        P p = deq.front();
        deq.pop_front();
        int i = p.first, j = p.second;
        REP(k,4){
            int ii = i + di[k], jj = j + dj[k];
            if (ii < 0 || ii >= h || jj < 0 || jj >= w || s[ii][jj] == '#') continue;
            if (dist[ii][jj] > dist[i][j]){
                dist[ii][jj] = dist[i][j];
                deq.push_front(P(ii, jj));
            }
        }
        FOR(ii,i-2,i+2) FOR(jj,j-2,j+2){
            if (ii < 0 || ii >= h || jj < 0 || jj >= w || s[ii][jj] == '#') continue;
            if (dist[ii][jj] > dist[i][j] + 1){
                dist[ii][jj] = dist[i][j] + 1;
                deq.push_back(P(ii, jj));
            }
        }
    }
    int ans = dist[gi][gj];
    if (ans == INF) ans = -1;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 9448
n=int(input())
ans=0
for i in range(2,int(n**0.5)+1):
    t=n
    if t%i!=0:
        continue
    while t%i==0:
        t//=i
    if t%i==1:
            ans+=1
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
import collections
c=collections.Counter(prime_factorize(n-1))
t=1
for i in c.values():
    t*=i+1
print(ans+t)

Measured memory_bytes: 40172
import copy
N = int(input())
C = input()

first_r = -1
rcount = C.count('R')
wcount = C.count('W')
rcount_org = copy.deepcopy(rcount)
rlen = 0
ans = 0

if rcount == 0 or wcount == 0:
  print(0)
  exit()
  
for i, c in enumerate(C):
  if c == 'R':
    rcount -= 1
    rlen += 1
  
  if c == 'W':
    rcount -= 1
    rlen += 1
    ans += 1
    
  if rlen == rcount_org:
    print(ans)
    exit()
    
  #print(i, rcount, rlen)

  

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

// 定義
typedef long long         ll;
typedef pair<ll, ll>      P;
#define ALL(x)            (x).begin(),(x).end()
#define REP(i, n)         for(ll i = 0 ; i < (ll)n ; ++i)
#define REPN(i, m, n)     for(ll i = m ; i < (ll)n ; ++i)
#define REVREP(i, n)      for(ll i = n - 1; i >= 0 ; i--)
#define VL                vector<ll>
#define VVL               vector<vector<ll>>
#define VVVL              vector<vector<vector<ll>>>
#define VC                vector<char>
#define VVC               vector<vector<char>>
#define INF               (ll)2e9
#define INF_LL            1LL<<60
//#define MOD             998244353
#define MOD               1000000007

ll Ceil(ll val, ll div)   { return (val + div - 1) / div; }
ll CeilN(ll val, ll div)  { return Ceil(val, div) * div; }
ll FloorN(ll x, ll n)     { return (x - x % n); }
bool IsOdd(ll x)          { return ((x & 1) == 1); }
bool IsEven(ll x)         { return ((x & 1) == 0); }
template<class T> bool chmax(T& a, T b) { if (a <= b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, T b) { if (a >= b) { a = b; return 1; } return 0; }

void Solve()
{
	ll N;
	cin >> N;
	VL A(N);
	REP(i, N) cin >> A[i];

	bool isUp;
	REP(i, N - 1) {
		if (A[i] < A[i + 1]) {
			isUp = true;
			break;
		} else if (A[i] > A[i + 1]) {
			isUp = false;
			break;
		}
	}

	ll kabuNum = 0;
	ll nowMoney = 1000;
	ll minIdx = 0;
	REP(i, N - 1) {
		if (isUp) {
			if (A[i] > A[i + 1]) {
				isUp = false;
				kabuNum = nowMoney / A[minIdx];
				nowMoney += kabuNum * (A[i] - A[minIdx]);
			}
		} else {
			if (A[i] < A[i + 1]) {
				isUp = true;
				minIdx = i;
			}
		}
	}

	if (isUp) {
		kabuNum = nowMoney / A[minIdx];
		nowMoney += kabuNum * (A[N - 1] - A[minIdx]);
	}

	cout << nowMoney << endl;
}

// メイン
int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Solve();
	return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <string>

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

using namespace std;

typedef pair<int,int> P;
#define P_NUM 4

void Move2Zero(P p0,P &p1) {
    p1.first -= p0.first;
    p1.second -= p0.second;
}

void MoveFromZero(P p0,P &p1,P &p2,P &p3){
    p1.first += p0.first;
    p1.second += p0.second;

    p2.first += p0.first;
    p2.second += p0.second;

    p3.first += p0.first;
    p3.second += p0.second;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    //[[0,-1],[1,0]]

    P p0;
    P p1;
    P p2;
    P p3;

    cin >> p0.first;
    cin >> p0.second;

    cin >> p1.first;
    cin >> p1.second;

    Move2Zero(p0,p1);

    //p1のベクトルを45度回転
    p2.first = p1.first - p1.second;
    p2.second = p1.first + p1.second;

    //p1のベクトルを90度回転
    p3.first = -p1.second;
    p3.second = p1.first;

    MoveFromZero(p0,p1,p2,p3);

    printf("%d %d %d %d", p2.first,p2.second,p3.first,p3.second);


    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<ctype.h>
#include<string>
using namespace std;
int main(){
	int A, B, C;
	cin >> A >> B >> C;
	if(A + B >= C){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n;
	ll c;
	cin >> n >> c;
	vector<pair<ll, ll>> x(n);
	rep(i, n) cin >> x[i].fi >> x[i].se;
	ll res = 0;
	rep(i, 2){
		vector<ll> opt(n + 1, -1e18);
		//rep(i, n) cout << x[i].fi << " " << x[i].se << endl;
		if(i){
			rep(i, n) x[i].fi = c - x[i].fi;
			sort(all(x));
		}
		ll dist = 0;
		ll tot = 0;
		ll best = 0;
		for(int i = n - 1; i >= 0; i--){
			dist = c - x[i].fi;
			tot += x[i].se;
			ll now = max(0LL, tot - dist);
			opt[i] = max(now, opt[i + 1]);
			best = max(best, opt[i]);
		}
		ll maxDist = 0;
		ll sum = 0;
		rep(i, n){
			maxDist = x[i].fi;
			sum += x[i].se;
			ll cur = max(0LL, sum - maxDist);	
			//debug(i);
			//debug(cur);
			if(i != (n - 1)){
				ll gd = opt[i + 1];
				//debug(gd);
				//debug(maxDist);
				cur += max(0LL, gd - maxDist); //don't have to
			}
			best = max(best, cur);
		}	
		res = max(best, res);
	}
	cout << res << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 2672
#include <cstdio>
#include <algorithm>

using namespace std;


int main(){
    int N,M;
    scanf("%d%d",&N,&M);

    int sum=0;
    for(int i=0;i<M;i++){
        int temp;
        scanf("%d",&temp);
        sum+=temp;
    }

    printf("%d\n",max(-1,N-sum));

    return 0;
}

Measured memory_bytes: 1732
#include <stdio.h>

int main(void){

    int n,ans=0 ;
    char s[120][2] ;
    scanf ("%d",&n) ;
    
    for (int i=0; i<n; i++ ){
        
        scanf ("%s",s[i]) ;
        
        if ( s[i][0]=='Y' ){
            
            ans = 1;
        } 
    }
    
    if ( ans==1 ){
        
        printf ("Four\n") ;
        
    } else {
        
        printf ("Three\n") ;
    }

    return 0 ;
}

Measured memory_bytes: 128
/**
SXR0aXAkI0JwbXptI3FhI3Z3I293bCNqY2IjUG0jMCNicG0jVHFkcXZvLyNCcG0jQW10bjBhY2phcWFicXZvLyNNYm16dml0MSNWdyNhdGN1am16I2tpdiNhbXF9bSNQcXUjVnd6I0F0bW14MSNQcWEjaXptI2l0dCNicHF2b2EjUXYjYnBtI3BtaWRtdmEjaXZsI3d2I21pemJwMSNFcHcjcWEjYnBtem0ja2l2I3F2Ym16a21sbSNRdiNQcWEjeHptYW12a20jbXtrbXhiI0lhI3BtI3htenVxYmJtYnBHI1BtI3N2d2VtYnAjRXBpYiMraXh4bWl6bWJwI2J3I1BxYSNrem1pYmN6bWEjSWEsI0ptbnd6bSN3eiNJbmJteiN3eiNKbXBxdmwjYnBtdTEjVnd6I2FwaXR0I2JwbXwja3d1eGlhYSNJY29wYiN3biNwcWEjc3Z3ZXRtbG9tI017a214YiNpYSNQbSNlcXR0bWJwMSNQcWEjYnB6d3ZtI2x3YnAjbXtibXZsI1dkbXojYnBtI3BtaWRtdmEjSXZsI3d2I21pemJwLyNpdmwjUG0jbm1tdG1icCNWdyNuaWJxb2NtI3F2I29jaXpscXZvI0l2bCN4em1hbXpkcXZvI2JwbXUvI053eiNQbSNxYSNicG0jVXdhYiNQcW9wMSNCcG0jQWN4em11bSMrcXYjb3R3enwsMQ==
*/
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>

#define F first
#define S second
#define endl '\n'
#define deb(x) cout<<#x<<' '<<x<<endl;
#define pb push_back

/*
#ifdef IZI_KATKA
#define int __int64_t
#else
#define int __int64
#endif
*/

const long long MOD = 1e9 + 7;
const long long MAXN = 1e6 + 1;
using namespace std;

typedef long long ll;

long long readInt() {
    bool minus1 = false;
    long long result = 0;
    char ch;
    ch = getchar();
    while (true) {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus1 = true; else result = ch-'0';
    while (true) {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus1)
        return -result;
    else
        return result;
}

int cnt[MAXN];

int main() {
	#ifdef IZI_KATKA
	assert(freopen("input", "r", stdin));
    assert(freopen("output", "w", stdout));
    #endif
    int n = readInt(), m = readInt();
    for (int i = 1; i <= m; i++) {
		cnt[readInt()]++;
		cnt[readInt()]++;
    }
    for (int i = 1; i <= n; i++) {
    	if (cnt[i] % 2) {
    		cout << "NO";
    		return 0;
    	}
    }
    cout << "YES";
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define PI acos(-1.0)
#define eps 1e-67
#define pf printf
#define sf scanf
#define sd(n) scanf("%d",&n)
#define sd2(n1,n2) scanf("%d %d",&n1,&n2)
#define slf(n) scanf("%lf",&n)
#define slf2(n1,n2) scanf("%lf %lf",&n1,&n2)
#define sLf(n1) scanf("%Lf",&n1)
#define sLf2(n1,n2) scanf("%Lf %Lf",&n1,&n2)
#define sl(n) scanf("%lld",&n)
#define sl2(n1,n2) scanf("%lld %lld",&n1,&n2)
#define rep(i,a,b) for(long long int i=a;i<b;i++)
#define repb(i,a,b) for(long long int i=a;i>=b;i--)
#define repa(i,a,b,c) for(long long int i=a;i<b;i=i+c)
#define reps(i,a,b,c) for(long long int i=a;i>b;i=i-c)
#define asort(a) sort(a.begin(),a.end())
#define asortb(a,comp) sort(a.begin(),a.end(),comp)
#define arev(a) reverse(a.begin(),a.end())
#define all(v) (v).begin(),(v).end()
#define allc(v,comp) (v).begin(),(v).end(),comp
#define allrc(v,a,b,comp) (v).begin()+a,(v).end()-b,comp
#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define pbb pop_back
#define mp make_pair
#define mt make_tuple
#define bs(v,x) binary_search(v.begin(),v.end(),x)
#define lb(v,x) lower_bound(v.begin(),v.end(),x)
#define ub(v,x) upper_bound(v.begin(),v.end(),x)
#define tl(c) towlower(c)
#define root(x) sqrt(x)
#define power(a,n) pow(a,n)
#define tu(c) towupper(c)
#define sq(a) ((a)*(a))
#define cube(a) ((a)*(a)*(a))
#define mx 1000
#define MX 100000
#define mod 1000000007
using namespace std;
typedef string str;
typedef long long int ll;
typedef double lf;
typedef long double llf;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef char ch;
typedef map<ll,ll> mp;
void Solve()
{
   int i,j,k,x1,y1,x2,y2,dify,difx;
   cin>>x1>>y1>>x2>>y2;
   string s1,s2,s3,s4,temp1,temp2,temp3,temp4,ans;
   dify=y2-y1;
   difx=x2-x1;
   rep(i,0,dify)
   {
       char c='U';
       temp1.pb(c);

   }
   rep(i,0,difx)
   {
       char d='R';
       temp2.pb(d);
   }
   s1=temp1+temp2;
   rep(i,0,dify)
   {
       char e='D';
       temp3.pb(e);
   }
      rep(i,0,difx)
   {
       char f='L';
       temp4.pb(f);
   }
   s2=temp3+temp4;
   s3='L'+temp1+'U'+temp2+'R'+'D';
   s4='R'+temp3+'D'+temp4+'L'+'U';
   ans=s1+s2+s3+s4;
   cout<<ans<<endl;

}

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

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
ll a,b,c,k;
cin>>a>>b>>c>>k;
int ans=0;
if(a<k)
{
ans+=a;
k-=a;
}
else
{
ans+=k;
k=0;
}
if(k<b)
{
k=0;
}
else
{
k-=b;
}
if(k<c)
{
ans-=k;
}
else
{
ans-=c;
}
cout<<ans<<endl;
}


Measured memory_bytes: 3636
import math
a,b,x=map(int, input().split())
max = a*a*b
if(x > max/2):
    k = (max - x)/(a*a)*2
    ans = math.degrees(math.atan(k/a))
    print(ans)
else:
    k = x/(a*b)*2
    ans =   90 - math.degrees(math.atan(k/b))
    print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e8;

signed main() {
	int N;
	cin >> N;
	map<int, int>m;
	rep(i, N) {
		int num;
		cin >> num;
		m[num]++;
		m[num + 1]++;
		m[num - 1]++;
	}
	int mx = -INF;
	for (auto i : m)mx = max(mx, i.second);
	cout << mx;
}

Measured memory_bytes: 6144
#include <iostream>

using namespace std;

int main() {
    int a,b;
    cin >> a >> b;
    int s = a + b;
    if (s % 3 == 0 && s > 0)
        cout << "Possible";
    else if (a % 3 == 0 && a > 0)
        cout << "Possible";
    else if (b % 3 == 0 && b > 0)
        cout << "Possible";
    else
        cout << "Impossible";
    return 0;
}


Measured memory_bytes: 256
import sys
from bisect import *
from heapq import *
from collections import *
from itertools import *
from functools import *
from math import *
from fractions import *

sys.setrecursionlimit(100000000)
input = lambda: sys.stdin.readline().rstrip()

def main():
    S = input()
    print(min(abs(int(S[i:i + 3]) - 753) for i in range(len(S) - 2)))

main()


Measured memory_bytes: 63980
import java.math.*;
import java.io.*;
import java.util.*;

public class Main {
	
    public static void main(String[] args) throws Exception{
    	Scanner sc = new Scanner(System.in);
    	int n =  sc.nextInt();
    	int s_500 = n/500;
    	n = n % 500;
    	int s_5 = n / 5;
    	System.out.println((s_500 * 1000) + (s_5 * 5));
    }
}

Measured memory_bytes: 21844
def binary_search(A, key):
    left = 0
    right = len(A)

    while left < right:
        mid = (left + right) // 2
        if (A[mid] == key):
            return 1
        elif (key < A[mid]):
            right = mid
        else:
            left = mid + 1
    return 0

def main():
    n = int(input())
    s = list(map(int, input().split()))
    q = int(input())
    t = list(map(int, input().split()))

    res = 0
    for i in t:
        a = binary_search(s, i)
        res += a

    print(res)

if __name__ == "__main__":
    main()

Measured memory_bytes: 18664
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


class Dijkstra():
    def __init__(self):
        self.e = collections.defaultdict(list)

    def add(self, u, v, d):
        self.e[u].append([v,d])
        self.e[v].append([u,d])

    def delete(self, u, v):
        self.e[u] = [_ for _ in self.e[u] if _[0] != v]
        self.e[v] = [_ for _ in self.e[v] if _[0] != u]

    def search(self, s, t):
        d = collections.defaultdict(lambda: inf)
        d[s] = 0
        q = []
        heapq.heappush(q, (0, s))
        v = collections.defaultdict(bool)
        while len(q):
            k, u = heapq.heappop(q)
            if v[u]:
                continue
            if u == t:
                return d[t]
            v[u] = True

            for uv, ud in self.e[u]:
                if v[uv]:
                    continue
                vd = k + ud
                if d[uv] > vd:
                    d[uv] = vd
                    heapq.heappush(q, (vd, uv))

        return None

def main():
    rr = []

    while True:
        w,h = LI()
        if h == 0 and w == 0:
            break

        a = [LI() for _ in range(h*2-1)]

        dk = Dijkstra()
        for i in range(h):
            for j in range(w-1):
                if a[i*2][j] == 0:
                    dk.add((i,j), (i,j+1), 1)
        for i in range(h-1):
            for j in range(w):
                if a[i*2+1][j] == 0:
                    dk.add((i,j), (i+1,j), 1)
        r = dk.search((0,0),(h-1,w-1))
        if r:
            rr.append(r+1)
        else:
            rr.append(0)

    return '\n'.join(map(str, rr))


print(main())




Measured memory_bytes: 9692
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORD(i, a, b) for (ll i = a ; i > b ; i--)
#define hahashad ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
typedef long long ll;
#define VL vector<ll> 
#define what(A) cout<<#A<<" is "<<A<<endl;
int main()
{
	ll n,cnt=0;
    cin>>n;
    FOR(i,0,n)
    {
        ll in;
        cin>>in;
        if(i%2==0 && in%2!=0)
            cnt++;
    }
    cout<<cnt<<endl;
    
}

Measured memory_bytes: 3588
from collections import deque

s = input().split(' ')
n = int(s[0])
q = int(s[1])

p = deque([])

for _ in range(n):
    s = input().split(' ')
    p_name = s[0]
    p_num = int(s[1])
    p.append([p_name,p_num])

time = 0

while len(p) > 0:
    top = p.popleft()
    time_use = min(q,top[1])
    top[1] -= time_use
    time += time_use
    if top[1] == 0:
        print(top[0], time)
    else:
        p.append(top)


Measured memory_bytes: 13272
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using Edge = pair<int, ll>;
using Graph = vector<vector<int>>;
using WeightedGraph = vector<vector<Edge>>;
const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

const int CASES = 3;

void solve() {
    ll n; cin >> n;
    vector<pll> x(n);
    for(int i = 0; i < n; ++i){
        ll c, l;
        cin >> c >> l;
        x[i].first = c + l;
        x[i].second = c - l;
    }
    sort(x.begin(), x.end());
    ll ans = 0;
    ll r = -INF64;
    for (int i = 0; i < n; ++i) {
        if(r <= x[i].second){
            r = x[i].first;
            ++ans;
        }
    }
    cout << ans << endl;
}

int main() {
#ifdef MYLOCAL
    vector<string> filenames {"input1.txt", "input2.txt", "input3.txt", "input4.txt"};
    cout << "------------\n";
    for(int i = 0; i < CASES; ++i){
        ifstream in(filenames[i]);
        cin.rdbuf(in.rdbuf());
        solve();
        cout << "------------\n";
    }
#else

    solve();

#endif
    return 0;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------


int T;
ll N,A,B,C,D;
map<ll,__int128> M;

__int128 hoge(__int128 v) {
	if(v==0) return 0;
	if(M.count(v)) {
		if(M[v]==-1) return 1LL<<60;
		return M[v];
	}
	M[v]=-1;
	
	__int128 ret=1LL<<60;
	
	if(ret/v>D) ret=D*v;
	if(v%2==0) {
		ret=min(ret,A+hoge(v/2));
	}
	else {
		ret=min(ret,D+A+hoge((v+1)/2));
		ret=min(ret,D+A+hoge((v-1)/2));
	}
	if(v%3==0) {
		ret=min(ret,B+hoge(v/3));
	}
	else {
		ret=min(ret,(v%3)*D+B+hoge(v/3));
		ret=min(ret,(3-v%3)*D+B+hoge(v/3+1));
	}
	if(v%5==0) {
		ret=min(ret,C+hoge(v/5));
	}
	else {
		ret=min(ret,(v%5)*D+C+hoge(v/5));
		ret=min(ret,(5-v%5)*D+C+hoge(v/5+1));
	}
	
	return M[v]=ret;
	
}


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>T;
	while(T--) {
		cin>>N>>A>>B>>C>>D;
		M.clear();
		cout<<(ll)hoge(N)<<endl;
	}
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 4692
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define mp make_pair
#define IP pair<int,int>
#define enld endl

int main() {
	lint W, H, N;
	cin >> W >> H >> N;
	vector<lint>X(N);
	vector<lint>Y(N);
	rep(i, N) {
		cin >> X[i] >> Y[i];
	}
	lint ans = 0;
	lint dx = 0;
	lint dy = 0;
	rep(i, N - 1) {
		dx = X[i + 1] - X[i];
		dy = Y[i + 1] - Y[i];
		if (dx * dy >= 0) {
			ans += max(abs(dx), abs(dy));
		}
		else {
			ans += abs(dx) + abs(dy);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3088
#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>;
using vi = vector<int>;
using vc = vector<char>;
using vs = vector<string>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

vvi to;
vi d;

void dfs(int v) {
    for (int nv : to[v]) {
        if (d[nv] >= 0) continue;
        d[nv] = d[v] + 1;
        dfs(nv);
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    to.resize(n);
    d.resize(n, -1);
    rep(i, n) {
        int a;
        cin >> a;
        a--;
        to[i].push_back(a);
    }
    d[0] = 0;
    dfs(0);
    cout << d[1] << endl;
}

Measured memory_bytes: 9216
#include <iostream>
#include <vector>
#include <cmath>
#define rep(i, n) for (int i = 0; (i) < (int)(n); i++)
using namespace std;

int main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	while (1) {
		C = C - B;
		if (C <= 0) {
			cout << "Yes" << endl;
			return 0;
		}
		A = A - D;
		if (A <= 0) {
			cout << "No" << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3636
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)

template<class T, class E>
struct SegTree{
  typedef function<T(T,T)> F;
  typedef function<T(T,E)> G;
  typedef function<E(E,E)> H;
  typedef function<E(E,int)> P;
  int n;
  F f;
  G g;
  H h;
  P p;
  T d1;
  E d0;
  vector<T> dat;
  vector<E> lazy;
  SegTree(int n_, F f, G g, H h, T d1, E d0, P p=[](E a, int b){ return a; })
    : f(f), g(g), h(h), d1(d1), d0(d0), p(p) {
    n = 1;
    while (n < n_) n *= 2;
    dat.resize(2 * n - 1, 0);
    lazy.resize(2 * n - 1, d0);
  }
  void eval(int k, int l, int r) {
    if (lazy[k] == d0) return;
    dat[k] = g(dat[k], p(lazy[k], r - l));
    if (k < n - 1) {
      lazy[2 * k + 1] = h(lazy[2 * k + 1], lazy[k]);
      lazy[2 * k + 2] = h(lazy[2 * k + 2], lazy[k]);
    }
    lazy[k] = d0;
  }
  void update(int a, int b, E x, int k = 0, int l = 0, int r = -1) {
    if (r == -1) r = n;
    // cerr << "update: a = " << a << ", b = " << b << ", x = " << x << ", k = " << k << ", l = " << l << ", r = " << r << endl;
    eval(k, l, r);
    if (b <= l || r <= a) return;
    if (a <= l && r <= b) {
      lazy[k] = h(lazy[k], x);
      eval(k, l, r);
    }
    else {
      update(a, b, x, 2 * k + 1, l, (l + r) / 2);
      update(a, b, x, 2 * k + 2, (l + r) / 2, r);
      dat[k] = f(dat[2 * k + 1], dat[2 * k + 2]);
    }
  }
  // return op[a..b)
  // k: node id, [l, r): node interval
  E query(int a, int b, int k = 0, int l = 0, int r = -1) {
    if (r == -1) r = n;
    // cerr << "query: a = " << a << ", b = " << b << ", k = " << k << ", l = " << l << ", r = " << r << endl;
    eval(k, l, r);
    if (r <= a || b <= l) return d1;
    if (a <= l && r <= b) return dat[k];
    E vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
    E vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
    return f(vl, vr);
  }
  void print() {
   int j = 2;
   for (int i = 0; i < 2 * n - 1; i++) {
     cerr << "(" << dat[i] << ", " << lazy[i] << ")";
     if (i == j - 2) { cerr << endl; j *= 2;}
     else { cerr << " "; }
   }
 }
};

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

  int n, q;
  cin >> n >> q;
  SegTree<ll, ll> seg(
    n,
    [](ll a, ll b){ return min(a, b); },
    [](ll a, ll b){ return a + b; },
    [](ll a, ll b){ return a + b; },
    INT_MAX,
    0
  );

  // seg.print();

  rep(i, q) {
    int t;
    cin >> t;
    if (t == 0) {
      int a, b;
      ll v;
      cin >> a >> b >> v;
      seg.update(a, b + 1, v);
    }
    else {
      int a, b;
      cin >> a >> b;
      cout << seg.query(a, b + 1) << endl;
    }

    // cerr << "i = " << i << endl;
    // seg.print();
  }

  return 0;
}



Measured memory_bytes: 7088
n,m=map(int,input().split())
x=list(map(int,input().split()))
if n>=m:
  print(0)
else:
  x.sort()
  d=[0]*(m-1)
  for i in range(m-1):
    d[i]=x[i+1]-x[i]
  d.sort(reverse=True)
  print(sum(d[(n-1):]))


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

int main() {
  int N, A, X;
  cin >> N >> A;

  X = N % 500;
  
  if (X <= A * 1) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
from math import sqrt, ceil

N = 10100000
temp = [True]*(N+1)
temp[0] = temp[1] = False
for i in range(2, ceil(sqrt(N+1))):
    if temp[i]:
        temp[i+i::i] = [False]*(len(temp[i+i::i]))

quadruplet = [True, False, True, False, False, False, True, False,True]
while True:
    try: n = int(input())
    except: break
    for i in range(n,9,-1):
        if temp[i] and temp[i-8:i+1] == quadruplet:
            print(i)
            break



Measured memory_bytes: 163152
package main

import (
	"fmt"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	r := 0
	for i := 0; i < n; i++ {
		var s int
		fmt.Scan(&s)
		if s >= k {
			r++
		}
	}
	fmt.Println(r)
}


Measured memory_bytes: 5504