akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<math.h>
#include<map>
#include<queue> 
#include<algorithm>
using namespace std;
const int inf = 0x3f3f3f3f;
typedef pair<int,int> pii;
typedef long long ll;
const double eps=1e-8;

struct node {
	ll val;
	double w;
	bool operator <(const node& t)const{
		return val*1.0/w<t.val*1.0/t.w;
	}
}p[10];
double n;
int main ()
{
	
	while (cin>>p[0].val>>p[1].val>>p[2].val>>p[3].val){
		p[0].w=0.25;p[1].w=0.5;p[2].w=1.0;p[3].w=2.0;
		sort(p,p+4);
//		for (int i=0;i<4;i++){
//			printf ("%f %f\n",p[i].val,p[i].w);
//		}
		cin>>n;
		ll t=1e18;
//		for (int i=0;i<4;i++){
//			ll tmp=(ll)(n/p[i].w+0.5);
//			t=min(t,(ll)tmp*p[i].val);
//		}
		ll ans=0;
		for (int i=0;i<4;i++){
			double cnt=n/p[i].w;
			ll tmp=(ll)cnt;
			//if (fabs(cnt-tmp)<eps){
			ans+=(ll)tmp*p[i].val;
				//break;
			//}
			n=n-tmp*p[i].w;
			if (fabs(n)<=eps)break;
		}
		ans=min(ans,t);
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,i,j,d,f;
  scanf("%d",&n);
  int a[n][n];
  int p[n],u[n];
  for(i=0;i<n;i++){
    for(j=0;j<n-1;j++){
      scanf("%d",&a[i][j]);
      a[i][j]--;}
    p[i]=0;}
  for(d=0;;d++){
    for(f=i=0;i<n;i++){
      if(p[i]<n-1)
        u[i]=f=1;
      else
        u[i]=0;}
    if(!f) break;
    for(f=i=0;i<n;i++){
      if(!u[i]) continue;
      j=a[i][p[i]];
      if(u[j]&&a[j][p[j]]==i){
        u[i]=u[j]=0;
        p[i]++;p[j]++;
        f=1;}}
    if(!f){
      d=-1;
      break;
    }}
  printf("%d\n",d);
  return 0;}


Measured memory_bytes: 4096
x = str(input())
l = [x[0], x[1], x[2], x[3]]
m = [int(s) for s in l]
N = 2 ** 3
for i in range(N):
  n = [m[0], 0, 0, 0]
  o = [] # +か-かを記憶
  for j in range(3):
    if (i >> j) & 1:
      n[-j-1] = -m[-j-1]
      o.append('-')
    else:
      n[-j-1] = m[-j-1]
      o.append('+')
  if sum(n) == 7:
    print(str(m[0]) + o[2] + str(m[1]) + o[1] + str(m[2]) + o[0] + str(m[3]) + '=7')
    exit()

Measured memory_bytes: 3064
// import chie template :) {{{
import std.stdio,
       std.algorithm,
       std.array,
       std.string,
       std.math,
       std.conv,
       std.range,
       std.container,
       std.bigint,
       std.ascii;
// }}}
// tbh.scanner {{{
class Scanner {
  import std.stdio;
  import std.conv : to;
  import std.array : split;
  import std.string : chomp;

  private File file;
  private dchar[][] str;
  private uint idx;

  this(File file = stdin) {
    this.file = file;
    this.idx = 0;
  }

  private dchar[] next() {
    if (idx < str.length) {
      return str[idx++];
    }

    dchar[] s;
    while (s.length == 0) {
      s = file.readln.chomp.to!(dchar[]);
    }

    str = s.split;
    idx = 0;

    return str[idx++];
  }

  T next(T)() {
    return next.to!(T);
  }

  T[] nextArray(T)(uint len) {
    T[] ret = new T[len];

    foreach (ref c; ret) {
      c = next!(T);
    }

    return ret;
  }
}
// }}}

void main() {
  auto cin = new Scanner;
  int N = cin.next!int;
  int K = cin.next!int;
  
  int[int] chie;

  foreach (i; 0 .. N) {
    int t = cin.next!int;
    ++chie[t];
  }
  int[] arr;
  foreach (key, value; chie) {
    arr ~= value;
  }
  sort(arr);
  int res;
  foreach (i; 0 .. max(0, arr.length.to!int - K)) {
    res += arr[i];
  }
  writeln(res);
}


Measured memory_bytes: 34320
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define forn(i,a,b) for(int i =a;i<b;i++)
#define fi first
#define se second
#define fast ios_base::sync_with_stdio(false);
#define endl '\n'
using namespace std;

//for debugging 
/*
g++ -D_GLIBCXX_ASSERTIONS -DDEBUG -ggdb3 -std=c++14 
*/
int recur_depth = 0;
#ifdef DEBUG
#define dbg(x) {++recur_depth; auto x_=x; --recur_depth; cerr<<string(recur_depth, '\t')<<"\e[91m"<<__func__<<":"<<__LINE__<<"\t"<<#x<<" = "<<x_<<"\e[39m"<<endl;}
#else
#define dbg(x)
#endif
template<typename Ostream, typename Cont>
typename enable_if<is_same<Ostream,ostream>::value, Ostream&>::type operator<<(Ostream& os,  const Cont& v){
	os<<"[";
	for(auto& x:v){os<<x<<", ";}
	return os<<"]";
}
template<typename Ostream, typename ...Ts>
Ostream& operator<<(Ostream& os,  const pair<Ts...>& p){
	return os<<"{"<<p.first<<", "<<p.second<<"}";
}
// debugging ends here

typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;


void solve(){
	string s,t;
	cin >> s >> t;
	int n = s.length();
	int m = t.length();
	int ans  = n+m;
	for(int i =0;i+m<=n;i++){
		int cnt = 0;
		for(int j = 0;j<m;j++){
			if(s[i+j]!=t[j])
				cnt++;
		}
		ans =  min(ans,cnt);
	}
	cout << ans << endl;
}

int main(){
	fast;
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif

	// int t;cin >> t;while(t--)
		solve();
}


Measured memory_bytes: 3620
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;



void main() {
    int n, k;
    scan(n, k);

    auto m = (n - 1) * (n - 2) / 2;
    if (m < k) {
        writeln(-1);
        return;
    }
    auto t = m - k;

    int[][] es;

    foreach (i ; 1 .. n) {
        es ~= [0, i];
    }

    foreach (i ; 1 .. n) {
        foreach (j ; i + 1 .. n) {
            if (!t) goto L;
            es ~= [i, j];
            t--;
        }
    }

    L:
    writeln(es.length.to!int);
    foreach (e ; es) {
        writefln("%d %d", e[0] + 1, e[1] + 1);
    }
}











void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 508
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<complex>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int ans=-1,ans2=-1,ans3=-1;
bool flag=false;
void dfs(int a,int b,int c,int d,int e,int f,int g){
  if(flag)return;
  if(a==d){
    if(b==c){flag=true;ans=e;ans2=f;ans3=g;}
    return;
  }
  if(c+(a-d)>b)return;
  dfs(a,b,c+10,d+1,e+1,f,g);
  dfs(a,b,c+5,d+1,e,f+1,g);
  dfs(a,b,c+1,d+1,e,f,g+1);
}
int main(){
  int a,b;cin>>a>>b;
  b/=1000;
  //dfs(a,b,0,0,0,0,0);
  for(int i=0;i<=a;i++){
    for(int j=0;j<=a-i;j++){
      if(i*10+j*5+(a-i-j)==b){
	ans=i;ans2=j;ans3=a-i-j;
	flag=true;
	break;
      }
    }
    if(flag)break;
  }
  cout<<ans<<" "<<ans2<<" "<<ans3<<endl;
  return 0;
}


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

int main() {
	ll N;
	cin >> N;
  map<string,ll> mp;
	for(int i=1;i<=N;i++){
		string S = to_string(i);
		string m = {S[0],S[S.size()-1]};
		mp[m]++;
	}
	ll ans = 0;
	for(auto e:mp){
		string e1 = e.first;
		string e2 = {e.first[1],e.first[0]};
		ans+=(mp[e1]*mp[e2]);
	}
	cout << ans << endl;
}

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


/* エイリアス */
#define ll long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define endl '\n'

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define em emplace
#define mp make_pair


/* 関数マクロ */
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n, m) for (ll i = n; i <= m; ++i)
#define rep3(i, n, m) for (ll i = n; i >= m; --i)
#define all(v) v.begin(), v.end()
#define si(v) int(v.size())
#define UNIQUE(v) sort(all(v)), v.erase(unique(all(v)),v.end())


/* 定数 */
const ll mod = 1e9 + 7;
const ll infll = (1LL << 62) - 1;
const ll inf = (1LL << 30) - 1;


/* その他 */
template<class S, class T> inline bool chmax(S &a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class S, class T> inline bool chmin(S &a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> using pq = priority_queue<T>;
template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>;


signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  int n; cin >> n;
  vll a(n);

  rep(i, n) {
    cin >> a[i];
    a[i] -= (i + 1);
  }

  sort(all(a));
  
  ll mid = a[n / 2];
  if (n % 2 == 0) mid = (a[n/2] + a[n/2-1]) / 2;

  ll ans = 0;
  rep(i, n) ans += abs(a[i] - mid);

  cout << ans << endl;
}


Measured memory_bytes: 4740
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << '\n';
#else
	#define DBG(X)
#endif

using std::cin;
using std::cout;
using std::vector;
using std::string;
using std::pair;
using std::swap;
using std::sort;
using std::lower_bound;
using std::unique;

using int64 = long long int;
using pii   = pair<int, int>;
using pii64 = pair<int64, int64>;

const int NIL = -1;
const int INF = (int)2e9;
const int64 INF64 = (int64)2e18;

void init_IO() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
}


void solve() {
	int n;
	int64 Z, W;
	cin >> n >> Z >> W;

	vector<int64> a = {W};

	for(int i = 0; i < n - 1; ++i) {
		int64 val;
		cin >> val;

		a.push_back(val);
	}

	int64 last;
	cin >> last;

	for(auto& elem: a) {
		elem -= last;

		if(elem < 0)
			elem = -elem;
	}

	int64 answ = a[0];

	for(int i = 1; i < n; ++i) {
		int good = 1;

		for(int j = i; j < n; ++j) {
			if(a[j] < a[i]) {
				good = 0;
				break;
			}
		}

		if(good) {
			answ = std::max(answ, a[i]);
		}
	}

	cout << answ << '\n';
}

int main() {
	init_IO();
	solve();

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<deque>
#include<cmath>
#include<cstring>
#include<map>
#include<algorithm>
#include<vector>
#include<ios>
#include<sstream>
#include<locale>
using namespace std;
#define ive(cris) int long long 
#define in(out) long double
#define INF 100000007
int main(){
  string a,b,c;
  int x,y;
  cin>>a>>b>>c;
  x=a.size();
  y=b.size();
  if(a[x-1]==b[0] && b[y-1]==c[0]){
    cout<<"YES"<<'\n';
  }
  else{
    cout<<"NO"<<'\n';
  }
  return 0;
}
    


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#define lowbit(x) ((x)&(-x))
#define sc scanf
#define debug1(x) cout<<x<<" "
#define debug2(x) cout<<x<<"\n"
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
typedef long long ll;
const ll inf=1e18;
const int N=2e5+10;
using namespace std;
int gcd(int a,int  b)
{
	return b==0?a:gcd(b,a%b);
}

int main()
{
	ll k,n;
	cin>>n>>k;
	ll ans=k;
	ans*=pow((k-1),(n-1));
	cout<<ans<<"\n";
	return 0;
}

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

#define fi first
#define se second
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> ii;

const int len = 2e5+5;
int arr[len], l[len], r[len];
vector<ii> vec;

int main(){
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
        scanf("%d", &arr[i]);

    vec.pb(mp(0, 0));
    for (int i = 1; i <= n; i++){
        while (arr[i] < vec.back().fi) vec.pop_back();
        l[i] = i-vec.back().se;
        vec.pb(mp(arr[i], i));
    }
    vec.clear();
    vec.pb(mp(0, n+1));
    for (int i = n; i >= 1; i--){
        while (arr[i] < vec.back().fi) vec.pop_back();
        r[i] = vec.back().se-i;
        vec.pb(mp(arr[i], i));
    }

    ll ans = 0;
    for (int i = 1; i <= n; i++)
        ans += l[i]*1LL*r[i]*1LL*arr[i];
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 4468
#include <bits/stdc++.h>
using namespace std;
using ll= long long ;
using P = pair<ll,ll>;
#define rep(i,n) for (ll i = 1; i<=(ll)(n); i++)
#define mod 1000000007
#define pi 3.141592653589793
typedef vector<ll> vcl;

ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a, ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t =rep_jijo(n,x/2);
        return t*t%mod;
  }
  return n*rep_jijo(n,x-1)%mod;
}
ll c2(ll n){
    return n*(n-1)/2;
}

int main() {
ll n,k;
cin>>n>>k;
vector<double>p(n+1),q(n+1),r(n+1),s(n+1);
rep(i,n)cin>>p[i];
rep(i,n) q[i]=0.5+0.5*p[i];
for(ll i=0; i < n; i++) s[i+1] = s[i] + q[i+1];
for(ll j=0; j<=n-k;j++) r[j]=s[j+k]-s[j];
 sort(r.begin(), r.end()); 
 reverse(r.begin(),r.end());
 printf("%.6lf",r[0]);

return 0;
}

Measured memory_bytes: 6528
import sys
 
n, k = map(int, input().split())
c = list(map(int, input().split()))
 
maxNum = sys.maxsize
 
dp = [maxNum] * n
dp[0] = 0
 
for i in range(n):
    for j in range(1, k+1):
        if (0 <= i+j) & (i+j <= n-1):
            dp[i+j] = min(dp[i+j], dp[i] + abs(c[i] - c[i+j]))
 
print(dp[n-1])

Measured memory_bytes: 52592
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1e9+7;
using namespace std;
typedef pair<int,int> pii;
struct BinaryIndexedTree{
    long data[500000];
    int n;
    BinaryIndexedTree(int nn){
        rep(i,nn) data[i+1]=0;
        n = nn;
    }
    //1-indexでaまでの総和を求める
    long sum(int a){
        long ret = 0;
        while(a>0){
            ret+=data[a];
            a-= a&(-a);
        }
        return ret;
    }
    //1-indexでa番目にbだけ足す
    void add(int a,long b){
        while(a<=n){
            data[a]+=b;
            a+= a&(-a);
        }
    }
};

int main(){
    int n;
    cin >> n;
    pii a[2][n];
    rep(i,2) rep(j,n){
        cin >> a[i][j].first;
        a[i][j].second = j;
    }
    pii arr[2][(n+1)/2];
    int ans = 10000;
    rep(i,pow(2,n)){
        int ucnt = 0;
        int dcnt = 0;
        long long tmp = i;
        bool fl = true;
        rep(j,n){
            if(tmp%2==0){
                if(j%2==0) arr[0][ucnt] = a[0][j];
                else arr[0][ucnt] = a[1][j];
                if(ucnt>=(n+1)/2){
                    fl = false;
                    break;
                }
                ucnt++;
            }
            else{
                if(j%2==0) arr[1][dcnt] = a[1][j];
                else arr[1][dcnt] = a[0][j];
                if(dcnt>=(n/2)){
                    fl  = false;
                    break;
                }
                dcnt++;
            }
            tmp/=2;
        }
        /*if(i==10){
            cout << "meu" << endl;
            rep(j,(n+1)/2) cout << arr[0][j].first  << " " << arr[0][j].second  << " ";
            cout << endl;
            rep(j,(n)/2) cout << arr[1][j].first  << " " << arr[1][j].second << " ";
            cout << endl;
        }*/
        if(fl){
            sort(arr[0],arr[0]+((n+1)/2));
            sort(arr[1],arr[1]+(n/2));
            /*rep(j,(n+1)/2) cout << arr[0][j].first  << " " << arr[0][j].second  << " ";
            cout << endl;
            rep(j,(n)/2) cout << arr[1][j].first  << " " << arr[1][j].second << " ";
            cout << endl;*/
            int tmpans = 0;
            BinaryIndexedTree tree(n);
            tmpans+=(0-tree.sum(arr[0][0].second+1));
            //cout << tmpans << endl;
            tree.add(arr[0][0].second+1,1);
            int now = arr[0][0].first;
            bool fl2 = true;
            for(int j = 1;j<n;j++){
                //cout << now << endl;
                if(arr[j%2][j/2].first<now){
                    fl2 = false;
                    break;
                }
                tmpans+=(j-tree.sum(arr[j%2][j/2].second+1));
                tree.add(arr[j%2][j/2].second+1,1);
                now = arr[j%2][j/2].first;
            }
            if(fl2){
                ans = min(ans,tmpans);
                //cout << tmpans << endl;
            }
            //cout << ans << endl;
        }

    }
    if(ans==10000) cout << -1 << endl;
    else cout << ans << endl;
}


Measured memory_bytes: 512
//#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 (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};


int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int n,x,t;
    cin>>n>>x>>t;
    int y =n/x;
    if(n%x !=0) y ++;
    cout<<y*t<<endl;
}/*
./problem.exe
*/

Measured memory_bytes: 3652
//--- pA ---//
import java.util.*;
import java.lang.*;
import java.io.*;
public class Main {
	public static void main (String[] args) throws java.lang.Exception {
		new Solution();
	}
}
class Solution {
	Reader reader;
	PrintWriter out;
	public Solution() {
		reader = new Reader();
		out = new PrintWriter(System.out);
		while (reader.hasNext()) {
			run_case();
		}
		out.flush();
	}

	private void run_case() {
		String str = reader.ns();
		if (str.equals("ABC")) {
			out.println("ARC");
		} else if (str.equals("ARC")) {
			out.println("ABC");
		}
		return;
	}
}


class Reader {
	BufferedReader br;
	StringTokenizer st;
	public Reader(){
		try {
			br = new BufferedReader(new InputStreamReader(System.in));
			st = new StringTokenizer(br.readLine());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	public String next() {
		if (st.hasMoreTokens()) return st.nextToken();
		try {
			st = new StringTokenizer(br.readLine());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return st.nextToken();
	}
	public boolean hasNext() {
		try {
			if (!st.hasMoreTokens() && !br.ready()) return false;
			else return true;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return false;
	}
	public int ni() {return Integer.parseInt(this.next());}
	public long nl() {return Long.parseLong(this.next());}
	public String ns() {return this.next();}
}


Measured memory_bytes: 32696
//package Atcoder;
import java.util.*;
import java.io.*;
public class Main
{
	static final int mod=(int)1e9+7;
	static final int inf=(int)1e9;
	static final long INF=(long)1e18;
	public static void main(String[] args)
	{
		FastScanner fs=new FastScanner();
		String s=fs.next();
		if(s.equals("ABC"))
		{
			System.out.println("ARC");
		}
		else
		{
			System.out.println("ABC");
		}
	}
}
class FastScanner 
{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");
		public String next() 
		{
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
			
		}
		
		long pow(long x,long n)
		{
			long res=1;
			while(n>0)
			{
			   	if(n%2!=0)
			   	{
			   		res=(res*x);n--;
			   	}
			   	else
			   	{
			   		x=(x*x);n/=2;
			   	}
			}
			return res;
		}
		int gcd(int a,int b)
		{
			if(b==0)
			{
				return a;
			}
			return gcd(b,a%b);
		}
		long longgcd(long a,long b)
		{
			if(b==0)
			{
				return a;
			}
			return longgcd(b,a%b);
		}
		int[] sort(int arr[])
		{
			ArrayList<Integer> list = new ArrayList<Integer>();
			for(int i:arr)list.add(i);
			Collections.sort(list);
			for(int i=0;i<arr.length;i++)
			{
				arr[i]=list.get(i);
			}
			return arr;
		}
		char[] charsort(char arr[])
	        {
	    	ArrayList<Character> list = new ArrayList<>();
	    	for(char c:arr)list.add(c);
	    	Collections.sort(list);
	    	for(int i=0;i<list.size();i++)
	    	{
	    		arr[i]=list.get(i);
	    	}
	    	return arr;
	        }
		long[] longsort(long arr[])
		{
			ArrayList<Long> list = new ArrayList<Long>();
			for(long i:arr)list.add(i);
			Collections.sort(list);
			for(int i=0;i<arr.length;i++)
			{
				arr[i]=list.get(i);
			}
			return arr;
		}
		public int nextInt() 
		{
			return Integer.parseInt(next());
		}
		public int[] readArray(int n)
		{
			int[] arr=new int[n];
			for (int i=0; i<n; i++) arr[i]=nextInt();
			return arr;
		}	
		public long nextLong()
		{
			return Long.parseLong(next());
		}
		public long[] longreadArray(int n) 
		{
			long[] a=new long[n];
			for (int i=0; i<n; i++) a[i]=nextLong();
			return a;
		}
}

Measured memory_bytes: 32660
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
typedef pair<int, int> P;
vector<P> G[2010];
vector<P> rG[2010];
bool toN[2010];
bool from1[2010];

void dfs(int v, int p) {
    from1[v] = true;
    for(auto u: G[v]) {
        int to = u.first;
        if (from1[to]) continue;
        dfs(to, v);
    }
}

void rdfs(int v, int p) {
    toN[v] = true;
    for(auto u: rG[v]) {
        int to = u.first;
        if (toN[to]) continue;
        rdfs(to, v);
    }
}

int d[2010];
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    int s[2010], t[2010], c[2010];
    rep(i, M) {
        cin >> s[i] >> t[i] >> c[i];
        s[i]--; t[i]--;
        G[s[i]].push_back({t[i], c[i]});
        rG[t[i]].push_back({s[i], c[i]});
    }
    dfs(0, -1);
    rdfs(N - 1, -1);

    int loop = 0;
    rep(i, N) d[i] = -INF2;
    d[0] = 0;
    while(true) {
        bool updated = false;
        rep(i, M) {
            if (from1[s[i]] && toN[t[i]]) {
                if (d[t[i]] < d[s[i]] + c[i]) {
                    d[t[i]] = d[s[i]] + c[i];
                    updated = true;
                }
            }
        }
        if (updated && loop > N) {
            cout << "inf" << endl;
            return 0;
        } else if (!updated && loop > N) {
            break;
        }
        loop++;
    }
    cout << d[N - 1] << endl;


    return 0;
}


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


int main()
{
    int n;string s;
    cin >> n>>s;
    int ans = 0;
    vector<int> c(27,0), d(27,0);
    for(int i = 1; i<= n - 1; i++){
        int sum = 0;
        for(int j  = 0; j <= 'z' - 'a'; j++){
            c[j] = d[j] = 0;
        }
        for(int j = 0; j < i; j++) c[s[j] - 'a']++;
        for(int j = i; j < n; j++) d[s[j] - 'a']++;
        for(int j  = 0; j <= 'z' - 'a'; j++){
            if(c[j] > 0&&d[j] > 0) {
                sum++;

            }
        }

        ans = max(sum, ans);

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using  ll=long long;
using ld=long double;
const int MAX_N=2e5+9,mod=1e9+7;
unsigned  long long pref[MAX_N];
int main(){
  int n; cin>>n;
  for(int i=1;i<=n;i++)
      cin>>pref[i],pref[i]+=pref[i-1];
 unsigned long long ans=0;
  for(int i=1;i<=n;i++){
     ll temp=(((pref[i]-pref[i-1])%mod)*((pref[n]-pref[i])%mod))%mod;
     ans=((ans%mod)+(temp%mod))%mod;
  }
  cout<<ans%mod;
}

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

#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = 1; i <= n; i++)
#define drep(i, n) for(int i = n-1; i >= 0; i--)
#define srep(i, s, t) for (int i = s; i < t; i++)
#define vi vector<int>
#define P pair<ll, ll>
using namespace std;
int mod = 1'000'000'000 + 7;
struct edge {
    int to;
    ll cost;
};

void COME_LET_THE_GAMES_BEGIN() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(20);
}

namespace prime {
    vector<bool> is_not_prime{1, 1, 0};

    void make_is_not_prime(int N) {
        int l = is_not_prime.size();
        if (l >= N + 1) {
            return;
        }
        is_not_prime.resize(N + 1);
        for (int i = 2; i <= N; i++) {
            if (!is_not_prime[i]) {
                for (int j = max(((l + i - 1) / i) * i, i + i); j <= N; j += i) {
                    is_not_prime[j] = 1;
                }
            }
        }
    }

    vector<ll> list(ll a, ll b) {
        //{a, b)
        a = max(2LL, a);
        set<ll> st;
        for (ll i = a; i < b; i++) {
            st.insert(i);
        }
        ll l = sqrt(b);
        make_is_not_prime(l);
        for (ll i = 2; i <= l; i++) {
            if (!is_not_prime[i]) {
                for (ll j = max(((a + i - 1) / i) * i, i + i); j < b; j += i) {
                    st.erase(j);
                }
            }
        }
        vector<ll> res;
        for (auto x:st) {
            res.push_back(x);
        }
        return res;
    }

    bool is_prime(ll N) {
        if (N == 2) return true;
        for (int i = 2, j = sqrt(N) + 1; i <= j; i++) {
            if (N % i == 0)return false;
        }
        return N >= 2;
    }

    vector<pair<ll, ll>> integer_factorization(ll N) {
        vector<pair<ll, ll>> res;
        if (is_prime(N)) {
            res.push_back(make_pair(N, 1));
            return res;
        }
        auto s = list(0, N/2+1);
        for (ll p:s) {
            ll r = 0;
            for (int i = 0;; i++) {
                if (N % p == 0) {
                    N /= p;
                    r++;
                } else {
                    break;
                }
            }
            if (r) {
                res.push_back(make_pair(p, r));
            }
        }
        return res;
    }
}

int main() {
    COME_LET_THE_GAMES_BEGIN();
    ll N;
    cin >> N;
    ll s[1000] = {};
    rrep(i, N) {
        for (auto x:prime::integer_factorization(i)) {
            s[x.first] += x.second;
        }
    }
    ll ans = 1;
    for (int i = 0; i < 1000; i++) {
        ans *= s[i] + 1;
        ans %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	int a, b, c, x;  // 500, 100, 50
	cin >> a >> b >> c >> x;
	int ans = 0;
	for (int ia = 0; ia <= a; ++ia) {
		for (int ib = 0; ib <= b; ++ib) {
			for (int ic = 0; ic <= c; ++ic) {
				if (500 * ia + 100 * ib + 50 * ic == x) ++ans;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>
using namespace std ;

#define M 1000000007
#define MM 998244353 
#define ll long long 
#define pb push_back
#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define memf(a) memset(a,false,sizeof(a))
#define all(v) v.begin(),v.end()
#define F first
#define S second
#define PI 3.1415926536
#define INF 2e18
#define endl "\n"

ll power(ll b,ll e,ll m)
{
	if(e==0)
		return 1;
	if(e%2)
		return b*power(b*b%m,(e-1)/2,m)%m;
	else
		return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
	if(e==0)
		return 1;
	if(e%2)
		return b*power(b*b,(e-1)/2);
	else
		return power(b*b,e/2);
}
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	ll n,i;
	cin>>n;
	string s;
	map<pair<ll,ll>,ll> m;
	for(i=1;i<=n;i++)
	{
		s=to_string(i);
		m[{s[0]-'0',s[s.length()-1]-'0'}]++;
	}
	ll ans=0;
	for(int i=1;i<=9;i++)
	{
		for(int j=1;j<=9;j++)
		{
			ans+=m[{i,j}]*m[{j,i}];
		}
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int n;
    scanf("%d",&n);

    int b,f,r,v;
    int info[4][3][10] = {0};

    while(n--)
    {
        scanf("%d %d %d %d",&b,&f,&r,&v);
        info[b-1][f-1][r-1]+=v;
    }

    int i, j, k;
    for(i=0;i<4;++i)
    {
        for(j=0;j<3;++j)
        {
            for(k=0;k<10;++k)
            {
                printf(" %d%s",info[i][j][k],k!=9?"":"\n");
            }
        }
        
        if(i<3)
        {
            printf("####################\n");
        }
    }

    return 0;
}

Measured memory_bytes: 608
n = int(input())
h = list(map(int,input().split()))
max = -1
move = 0
for i in range(n-1):
    if h[i] >= h[i+1]:
        move += 1
    else:
        if max < move:
            max = move
        move = 0
if max < move:
    print(move)
else:
    print(max)

Measured memory_bytes: 14252
while(True):
    n,x=(int(s) for s in input().split())
    if n==0 and x==0:
        break
    a=0
    for i in range(1,n):
        for j in range(i+1,min(n,x-i+1)):
            if x-i-j>=j+1 and x-i-j<=n:
                a+=1
    print(a)


Measured memory_bytes: 5600
//
//  second.cpp
//  CoderTest
//
//  Created by yuya on 2019/07/25.
//  Copyright © 2019 yuya. All rights reserved.
//

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
#define all(x) (x).begin(), (x).end()
#define rep(i,n) for(int (i) = 0; (i) < (int)(n); i++)
#define rep1(i,n) for(int (i) = 1; (i) <= (int)(n); i++)
#define INF 1000000


int main()
{
    ll N,K;
    cin >> N >> K;
    
    cout << (int)( log(N) / log(K) )  + 1<< endl;
    
    return 0;
}



Measured memory_bytes: 512
#include <stdio.h>
#define MAX_N 100

int main(){
	int i,j,k;
	int n,flag,tmp,cnt=0;
	int A[MAX_N];
	scanf("%d",&n);
	for(i=0; i<n; i++) scanf("%d",&A[i]);

	flag = 1;
	while(flag){
		flag = 0;
		for(j=n-1; j>=1; j--){
			if(A[j] < A[j-1]){
				tmp = A[j];
				A[j] = A[j-1];
				A[j-1] = tmp;
				cnt++;
				flag = 1;
			}
		}
	}

	for(k=0; k<n; k++){
		if(k != n-1) printf("%d ",A[k]);
		else printf("%d\n",A[k]);
	}
	printf("%d\n",cnt);

	return 0;
}

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

// Define
using ll = int64_t;
using ul = uint64_t;
using ld = long double;
const ll MOD = 1e9 + 7;
const ll INF = LONG_MAX;
const ul MAX = ULONG_MAX;
const char nl = '\n';

#define elif else if
#define def inline auto
#define run __attribute__((constructor)) def _

// Debug
#define debug(x) cerr << (x) << " (L:" << __LINE__ << ")" << '\n'

// Loop
#define inc(i, a, n) for (ll i = (a), _##i = (n); i < _##i; ++i)
#define dec(i, a, n) for (ll i = (a), _##i = (n); i > _##i; --i)
#define rep(i, n) inc(i, 0, n)
#define be(c) begin(c), end(c)

// Stream
#define fout(n) cout << fixed << setprecision(n)
#define fasten cin.tie(0), ios::sync_with_stdio(0)

// Speed
run() { fasten, fout(10); }
#pragma GCC optimize("-O3")
#pragma GCC target("avx")

// Math
inline ll gcd(ll a, ll b) {
  for (; a; swap(b %= a, a));
  return b;
}
inline ll lcm(ll a, ll b) {
  return a * (b / gcd(a, b));
}

signed main(){
    int N;
    cin >> N;
    ll ans = 1;
    rep(i, N) {
        ll t;
        cin >> t;
        ans = lcm(ans, t);
    }
    cout << ans << nl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int A,B,C;

  scanf("%d", &A);
  scanf("%d", &B);
  scanf("%d", &C);

  if ((A==5 && B==5 && C==7) || (A==5 && B==7 && C==5) || (A==7 && B==5 && C==5)) {
    printf("YES");
  } else {
    printf("NO");
  }
}


Measured memory_bytes: 1724
#include <bits/stdc++.h>
using namespace std;
#define ref(i,x,y)for(int i=x;i<=y;++i)
#define def(i,x,y)for(int i=x;i>=y;--i)
#define pb push_back
#define SZ(x) ((int)x.size())
#define fi first
#define se second
#define mp make_pair
const int N=100010;
int n,a[N];
void out(int x){
	if(x==1)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	exit(0);
}
int main(){
	scanf("%d",&n);
	ref(i,1,n)scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	vector<pair<int,int> > s;
	int last=1;
	ref(i,2,n+1)if(i>n||a[i]!=a[i-1]){
		s.pb(mp(a[i-1],i-last));
		last=i;
	}
	if(SZ(s)==1){
		out(a[1]==0);
	}else
	if(SZ(s)==2){
		out((a[1]==0)&&s[0].se*2==s[1].se);
	}else
	if(SZ(s)==3){
		out((s[0].se==s[1].se)&&(s[1].se==s[2].se)&&((s[0].fi^s[1].fi)==(s[2].fi)));
	}else out(0);
}

Measured memory_bytes: 1656
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>

#define rep(i, n) REP(i, 0, n)
#define REP(i, a, n) for(int i = a ; i < (int)n ; i++)
#define ALL(v) v.begin(), v.end()
#define pb push_back
#define mp make_pair
#define eps 1e-14
#define INF 1e9
#define m0(x) memset(x, 0, sizeof(x))

using namespace std;

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

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

signed main(){
  int n;
  int max_x = -1, max_y = -1;
  cin >> n;
  vector<int> a(n), b(n), c(n), d(n);
  vector<pair<int, int> > red, blue;

  rep(i, n){
    cin >> a[i] >> b[i];
    red.emplace_back(a[i], b[i]);
  }

  rep(i, n){
    cin >> c[i] >> d[i];
    blue.emplace_back(c[i], d[i]);
  }

  sort(ALL(red));
  sort(ALL(blue));

  vector<int> flag(201, 0);
  int ans = 0;
  rep(i, n){
    int min_d = 1000000;
    int min_idx = -1;
    rep(j, n){
      if(red[j].first < blue[i].first && red[j].second < blue[i].second && !flag[j]){
        if(blue[i].second - red[j].second < min_d){
          min_d = blue[i].second - red[j].second;
          min_idx = j;
        }
      }
    }
    if(min_idx != -1){
      flag[min_idx] = 1;
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            String x = sc.nextLine();
            if (x.equals("0")) {
                break;
            }
            int total = 0;
            for (int i = 0; i < x.length(); i++) {
                total += (x.charAt(i) - '0');
            }
            System.out.println(total);
        }
        sc.close();
    }
}


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

int main() {
  int a,b;

  cin >> a >> b;

  if(a == 0 || b == 0){
    cout << "Zero" << endl;
    return 0;
  }

  if(a > 0){
    cout << "Positive" << endl;
  }else if(b > 0){
    cout << "Zero" << endl;
  }else if((b - a) % 2 == 1){
    cout << "Positive" << endl;
  }else{
    cout << "Negative" << endl;
  }
  return 0;
}


Measured memory_bytes: 3588
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<map>
#include<queue>
#include<iostream>
#include<algorithm>
#define m(a,b) memset(a,b,sizeof(a));
using namespace std;
const int inf = 1 << 30;
const int maxn = 1e5;
typedef long long LL;
int main(){
	int a,b,c;
	cin >> a >> b >> c;
	bool ans = false;
	for(int i = 1;i<b;i++){
		if((a*i)%b == c%b)
			ans = true;
	}
	if(ans)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
	return 0;
}

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

namespace CSharpSample01
{
    class Shape
    {
        public int w;
        public int h;
        public double diag2;
        public Shape(int hh, int ww, double d)
        {
            h = hh;
            w = ww;
            diag2 = d;
        }
    }
    

    class Program
    {

        
        static void Main(string[] args)
        {

            while (true)
            {
                string[] input = Console.ReadLine().Split(' ');
                int h = int.Parse(input[0]);
                int w = int.Parse(input[1]);

                if (h == 0 && w == 0)
                {
                    break;
                }

                int ans_h = 0;
                int ans_w = 0;
                double origin_diag2 = h * h + w * w;

                List<Shape> diag_list = new List<Shape>();

                for(int n_h = 1; n_h <= 148; n_h++)
                {
                    for(int n_w = n_h + 1; n_w <= 149; n_w++)
                    {
                        double n_diag2 = Math.Pow(n_h, 2) + Math.Pow(n_w, 2);
                        if(n_diag2 > origin_diag2)
                        {
                            diag_list.Add(new Shape(n_h, n_w, n_diag2));
                        }      
                        else if(n_diag2 == origin_diag2 && n_h > h)
                        {
                            diag_list.Add(new Shape(n_h, n_w, n_diag2));
                        }
                    }
                }

                var diag_list_sort = diag_list.OrderBy(x => x.diag2).ToList();

                ans_h = diag_list_sort[0].h;
                ans_w = diag_list_sort[0].w;
              
                Console.WriteLine($"{ans_h} {ans_w}");

            }
            
        }
    }
}


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

lint n;

int main() {
    cin >> n;
    lint ans = 0;
    for (lint i = 1; i < n; i++) {
        ans += (n + i - 1) / i - 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3648
(* --------------Encoder-------------- *)
(* -----function----- *)
(*
let encoder = 0
*)

(* -------test------- *)
(* ----------------------------------- *)

(* --------------Decoder-------------- *)
(* -----function----- *)
(*
let decoder ans = ""
*)

(* -------test------- *)
(* ----------------------------------- *)

(* --------------Processor-------------- *)
(* -----function----- *)
(*
let processor dat = 0
*)

(* -------test------- *)
(* ----------------------------------- *)


(* ----------------main---------------- *)
(*
let () = print_endline (decoder (processor encoder))
*)
(* ------------------------------------ *)
let () = Scanf.scanf "%1d %1d %1d" (fun a b c -> 
                        let fil = List.filter (fun x -> x = 1) [a; b; c] in
                        List.fold_right (+) fil 0 
                        |> Printf.printf "%d\n"
)


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

void solve(){
    int n,x,t;
    cin >> n >> x >> t;
    cout << ((n + x-1)/x)*t << "\n";
}

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    while(t--)
        solve();
    return  0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string s;
  cin>>s;
  if(s=="Sunny"){
    cout<<"Cloudy"<<endl;
  }
  else if(s=="Cloudy"){
    cout<<"Rainy"<<endl;
  }
  else{
    cout<<"Sunny"<<endl;
  }
}

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

using namespace std;

int main()
{
    int w, n, a, b;
    char c;
    cin >> w >> n;
    vector<int> v(w);
    for (int i = 0; i < w; i++) {
        v[i] = i+1;
    }
    for (int i = 0; i < n; i++) {
        cin >> a >> c >> b;
        a--; b--;
        swap(v[a], v[b]);
    }
    for (int &x: v) {
        cout << x << endl;
    }
    return 0;
}

Measured memory_bytes: 3040
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String str = scan.nextLine();
		String[] input_str = str.split("");
		if ( (input_str[2].equals(input_str[3])) && (input_str[4].equals(input_str[5]))){
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define IFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define RPT(i,a,b) for(int i=(a);i<((a)+(b));++i)
#define IRPT(i,a,b) for(int i=((a)+(b)-1);i>=(a);--i)
#define BITBOOL(x,a) (((x)>>(a))&1)
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N; ll D, A;
  cin >> N >> D >> A; D*=2;
  vector<pair<ll,ll>> Edata(N);
  RPT(i,0,N){
    ll a, b;
    cin >> a >> b;
    b = (b+A-1)/A;
    Edata[i]={a,b};
  }
  sort(Edata.begin(),Edata.end());
  vector<int> R(N,0);
  {
    int right = 0;
    FOR(left,0,N){
      while(right < N-1 &&  Edata[right+1].first<=Edata[left].first+D ){
        ++right;
      }
      R[left] = right;
    }
  }
  queue<pair<int,ll>> Q;
  ll dm = 0, ans = 0; 
  FOR(i,0,N){
    while(!Q.empty() && Q.front().first < i){
      dm -= Q.front().second;
      Q.pop();
    }
    if(dm >= Edata[i].second) continue;
    ll newdm = Edata[i].second - dm;
    ans += newdm;
    Q.push({R[i],newdm});
    dm += newdm;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5760
A_list = []
A_list.append(list(map(int, input().split())))
A_list.append(list(map(int, input().split())))
A_list.append(list(map(int, input().split())))
N = int(input())

B_list = [[False] * 3 for _ in range(3)]

for _ in range(N):
	b = int(input())
	for i in range(3):
		for j in range(3):
			if b == A_list[i][j]:
				B_list[i][j] = True

def check():
	for i in range(3):
		if all(B_list[i]) or all(map(lambda j: B_list[j][i], range(3))):
			return True
	
	if all(map(lambda i : B_list[i][i], range(3))) or all(map(lambda i : B_list[i][2 - i], range(3))):
		return True
	
	return False

if check():
	print("Yes")
else:
	print("No")



Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdlib>

template<typename T>
void fin(T const& v){ std::cout << v << std::endl; exit(0); }
int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  int N; std::cin >> N;
  std::vector<int> a(N), b(N);
  for(auto& ai: a) std::cin >> ai;
  for(auto& bi: b) std::cin >> bi;

  int ans = 0;
  for(int k = 28; k >= 0; --k) {
    int m = 1<<k;
    // a, b in [0, 2m) , a+b in [0, 4m-1)
    std::sort(a.begin(), a.end(), std::greater<int>());
    std::sort(b.begin(), b.end());
    int sum = 0;
    int jm = 0, j2m = 0;
    for(int i = 0; i < N; ++i) {
      while(jm < N && a[i]+b[jm] < m) ++jm;
      while(j2m < N && a[i]+b[j2m] < m+m) ++j2m;
      sum ^= j2m - jm;
    }
    // count [3m, )
    int j3m = 0;
    for(int i = 0; i < N; ++i) {
      while(j3m < N && a[i]+b[j3m] < m*3) ++j3m;
      sum ^= N - j3m;
    }
    if(sum%2) ans += m;
    for(auto& ai: a) ai &= m-1;
    for(auto& bi: b) bi &= m-1;
  }
  fin(ans);
  return 0;
}


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

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


const long long INF = 1LL << 60;

int N;
long long h[100010];
long long dp[100010];



long long rec(int i) {
	if (dp[i] < INF) return dp[i];
	if (i==0) return 0;
	long long res = INF;
	chmin(res, rec(i-1) + abs(h[i] - h[i-1]));
	if (i>1) {
		chmin(res, rec(i-2) + abs(h[i] - h[i-2]));
	}
	return dp[i] = res;
}

int main() {
	int N;
	cin >> N;
	for (int i = 0; i < N; ++i) cin >> h[i];
	for (int i = 0; i < 100010; ++i) dp[i] = INF;
	cout << rec(N-1) << endl;
}


Measured memory_bytes: 9812
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define PER(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define MOD ((LL)1e9+7) 
#define INF ((LL)1e9+7)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define BIT(x) (1LL << (x))
using namespace std;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

LL modpow(LL x, LL b){
	LL res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

LL modinv(LL x){
	return modpow(x, MOD-2);
}

int main(){
	int a, b;
	cin >> a >> b;
	int sum = 1;
	int ans = 0;
	while(sum < b){
		sum += a - 1;
		++ans;
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = 1e9+7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }



int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int x, y ,z ,k;
	cin >>x >>y >>z >>k;
	VL a(x), b(y), c(z);
	rep(i, x) cin >>a[i];
	rep(i, y) cin >>b[i];
	rep(i, z) cin >>c[i];
	
	VL ab; ab.reserve(x*y+5);
	rep(i, x) rep(j, y) ab.push_back(a[i]+b[j]);
	sort(all(ab), greater<ll>());
	
	VL ans; ans.reserve(min(3005,sz(ab))*z+5);
	rep(i, min(3001, sz(ab))) rep(j, z) ans.push_back(ab[i]+c[j]);
	sort(all(ans), greater<ll>());
	rep(i, k){
		cout << ans[i] <<"\n";
	}
	
	return 0;
}


Measured memory_bytes: 31616
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

// int main() {
//     ll A[4];
//     rep(i,2){
//         cin >> A[i];
//     }
//     //sort(A,A+3);
//     cout << (A[0]*A[1]%2==0 ? "Even" : "Odd" )<< endl;
// }

int main(){
    char A[19];
    cin >> A;
    A[3]='8';
    cout <<  A << endl;
}

Measured memory_bytes: 256
"""TLE
N = int(input())
A_list = list(map(int, input().split()))
i = 0
while(True):
    try:
        if A_list[i] != i+1:
            del A_list[i]
        else:
            i += 1
    except:
        if A_list == []:
            print(-1)
        else:
            print(N-len(A_list))
        exit()
"""

N = int(input())
A_list = list(map(int, input().split()))
iirenga = 1
kudaita = 0
for i in range(N):
    if A_list[i] == iirenga:
        iirenga += 1
    else:
        kudaita += 1
if kudaita == N:
    print(-1)
    exit()
print(kudaita)


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

int main() {
  int N;
  cin >> N;
  vector<int> H(N);
  for (int i=0; i<N; i++) {
    cin >> H.at(i);
  }
  int answer = 1;
  bool view;
  for (int i=1; i<N; i++) {
    for (int j=0; j<i; j++) {
      if (H.at(j)>H.at(i)) {
        view = false;
        break;
      }
      view = true;
    }
    if (view) {
      answer++;
    }
  }
  cout << answer << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0135
WA
"""
import sys
from sys import stdin
from math import sqrt, acos, cos, sin, radians, degrees
input = stdin.readline


def solve(time):
    # 12????????????90???
    short_hand_angle = time[1] * -6 + 90
    x_s = cos(radians(short_hand_angle))
    y_s = sin(radians(short_hand_angle))

    long_hand_angle = (time[0]*60+time[1])/(12*60) * -360 + 90
    x_l = cos(radians(long_hand_angle))
    y_l = sin(radians(long_hand_angle))
    c = (x_s * x_l + y_s * y_l) / (sqrt(x_s**2 + y_s**2) * sqrt(x_l**2 + y_l**2))
    ans = degrees(acos(c))

    if ans < 30:
        return 'alert'
    elif ans >= 90:
        return 'safe'
    else:
        return 'warning'


def main(args):
    n = int(input())
    # n = 1
    for _ in range(n):
        time = [int(x) for x in input().split(':')]
        result = solve(time)
        print(result)


if __name__ == '__main__':
    main(sys.argv[1:])

Measured memory_bytes: 8100