akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(void)
{
	int n,ball[10],b[10]={0},c[10]={0},i,n0;
	scanf("%d",&n);
	for(n0=0;n0<n;n0++){
		int p=0,o=0,j=0;
		for(i=0;i<10;i++){
			scanf("%d",&ball[i]);
		}
		b[0]=ball[0];
		c[0]=0;
		for(i=1;i<10;i++){
			if(b[p]<ball[i]){
				p++;
				b[p]=ball[i];
			}
			else if(c[o-1]<ball[i]&&o>=1||c[o]<ball[i]&&o==0){
				c[o]=ball[i];
				o++;
			}
			else{
				j=1;
				c[o]=ball[i];
				o++;
			}
		}
		if(j==0){
			printf("YES\n");
		}
		else{
			printf("NO\n");
		}
	}
	return 0;
}

Measured memory_bytes: 576
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

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

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef pair<int, int> PI;
const double EPS=1e-9;


bool ok(int v) {
return v == 5 || v == 7;
}
int main(void){
	int x, y, z;
cin >> x >> y >> z;
bool r = x + y + z == 17 && ok(x) && ok(y) && ok(z);
cout << (r ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    // 跳ねる数
    int n = sc.nextInt();
    // 直線の長さ
    int l = sc.nextInt();
    // 直線上を跳ねた数
    int ln = 1;
    // 跳ねる距離の配列
    int bounds[] = new int[n];
    for(int idx=0; idx<n; idx++){
      bounds[idx] = sc.nextInt();
    }
    
    for(int idx=0; idx<n; idx++){
      l -= bounds[idx];
      if(l < 0){
        break;
      }
      ln += 1;
    }
    
    // 出力
    System.out.println(ln);   
  }
}


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

int main ()
{
long  x,y,i,p,t;
cin>>x>>y;
if(y%2!=0)
{
   cout<<"No"<<endl;
   return 0;
}
i=4*x;
t=2*x;
p=i-y;
if(p>=0 && t<=y && (p%2==0||p%4==0)) cout<<"Yes"<<endl;
else cout<<"No"<<endl;


  return 0;
}


Measured memory_bytes: 3636
using System;
using System.Collections.Generic;
using System.Linq;
using static AtCoder.Io;

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            var n = ReadInt();
            var a = ReadIntArray();

            var count = new long[] { 0, 0 };

            for (int i = 0; i < count.Length; i++)
            {
                long sum = 0;
                var isPositive = i == 0;

                for (int j = 0; j < a.Length; j++)
                {
                    isPositive = !isPositive;
                    if (sum + a[j] >= 0 && !isPositive)
                    {
                        var diff = -1 - (sum + a[j]);
                        count[i] += Math.Abs(diff);
                        sum += a[j] + diff;
                    }
                    else if (sum + a[j] <= 0 && isPositive)
                    {
                        var diff = 1 - (sum + a[j]);
                        count[i] += Math.Abs(diff);
                        sum += a[j] + diff;
                        
                    }
                    else
                    {
                        sum += a[j];
                    }
                }
            }

            Console.WriteLine($"{count.Min()}");
        }
    }

    public static class Io
    {
        public static string ReadString() => Console.ReadLine();
        public static string[] ReadStringArray() => ReadString().Split(' ');
        public static int ReadInt() => int.Parse(ReadString());
        public static long ReadLong() => long.Parse(ReadString());
        public static int[] ReadIntArray() => ReadStringArray().ParseInt().ToArray();
        public static long[] ReadLongArray() => ReadStringArray().ParseLong().ToArray();
        public static IEnumerable<int> ParseInt(this IEnumerable<string> source) => source.Select(int.Parse);
        public static IEnumerable<long> ParseLong(this IEnumerable<string> source) => source.Select(long.Parse);
    }
}


Measured memory_bytes: 30172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int v[1000];
int w[1000];

int dp[1010][1010];

int main() {
	int W, N;
	int cnt = 1;
	while(scanf("%d", &W), W) {
		scanf("%d", &N);
		for(int i = 0; i < N; i++) {
			scanf("%d,%d", v + i, w + i);
		}

		fill((int*)begin(dp), (int*)end(dp), 0);
		for(int i = 0; i < N; i++) {
			for(int j = 0; j <= W; j++) {
				dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
				if(j + w[i] > W) continue;
				dp[i + 1][j + w[i]] = max(dp[i + 1][j + w[i]], dp[i][j] + v[i]);
			}
		}

		printf("Case %d:\n", cnt);
		int max_v = *max_element(dp[N], dp[N] + W + 1);
		for(int j = 0; j <= W; j++) {
			if(dp[N][j] == max_v) {
				printf("%d\n%d\n", max_v, j);
				break;
			}
		}
		cnt++;
	}
}

Measured memory_bytes: 7148
#include <iostream>
#include <string>
#include <vector>
#include <queue>
using namespace std;
using ll = long long;

int main() {
    ll n;
    cin>>n;
    ll min=n+2;
    for(ll i=1;i*i<n*10;i++){
        ll x=n%i;
        ll y=n/i;
        if(x==0){
            if(min>y+i)min=y+i;
        }
        
    }
    cout<<min-2;
}

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

int main()
{
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	int res = 0;
	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j < N; j++) {
			res = max(res, abs(A[i] - A[j]));
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
// Author : ZERO_IQ
// Practice is the only shortcut to improve

#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define debug(x, y) cerr << (#x) << " " << (#y) <<" is " << (x) <<" "<< (y) << endl
#define debug2(x, y, z) cerr << (#x) << " " <<(#y) << " " << (#z) << " is " << (x) << " " << (y) << " " << (z) << endl
#define endl '\n'

ll const N = 1e7 + 1;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    /*#ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif*/
    long long n, m;
    cin >> n >> m;
    vector<pair<long long, long long >> input;
    long long summ = 0;
    for (int i = 0; i < n; ++i) {
        long long q, qq;
        cin >> q >> qq;
        input.push_back({q, qq});
        summ += qq;
    }
    vector<vector<long long>> dp(n, vector<long long>(summ + 2, 1e18));
    for (int var = 0; var < n; ++var) {
        dp[var][0] = 0;
    }
    ll maxx = 0;
    for (int i = 1; i <= summ; ++i) {
        for (int j = 0; j < n; ++j) {
            if (!j) {
                if (i == input[j].second)
                    dp[j][i] = input[j].first;
            } else if (input[j].second > i) {
                dp[j][i] = dp[j - 1][i];
            } else {
                dp[j][i] = min(dp[j - 1][i], dp[j - 1][i - input[j].second]
                               + input[j].first);
            }
        }
    }
    for (int i = 0; i <= summ; i++) {
        if (dp[n - 1][i] <= m) {
            maxx = i;
        }
    }
    cout << maxx << endl;
    return 0;
}

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

#define forn(i,n) for(ll i = 0;i<n;i++)
#define forne(i,j,n) for(ll i = j;i<n;i++)
const ll mod = 1e9+7;
const ll mod2 = 998244353;
const ll INF = 1000000001;
const ll N = 100001;
const lld PI = 3.141593;
#define F first
#define pb(a) push_back(a)
#define S second
#define pii pair<int,int>
typedef pair<ll,ll> pll;

lld powm(ll base,ll exp) {
	ll ans=1;
	while(exp){
		if(exp&1) ans=(ans*base)%mod;
		exp>>=1,base=(base*base)%mod;
	}
	return ans;
}

// ll dir[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
// bool valid(ll i, ll j) {
// 	return i >= 1 && i <= n && j >= 1 && j <= m; 
// }
// int maxdepth = INT_MAX;
// vector<int> edgeVector[100000];
// ll minans = 1;
// printf("1 %d D\n",abs(r));
// priority_queue<ll,vector<ll>,greater<ll>> pq;
// ll a[N],b[N];
// vector<vector<ll>> adj(N);
// vector<set<ll>> adjs(N);
// ll adj[1001][1001];
// vector<vector<ll>> ans(1001);
// bool visited[N];
// ll cnt[1001];
// ll h,c,t;
// vector<pair<int, pair<int, int> > > g[300043];

int main(){
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output1.txt", "w", stdout);
#endif
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

ll n,m,k;
cin>>n>>m>>k;
ll a[n+1],b[m+1];
forn(i,n) cin>>a[i+1];
forn(i,m) cin>>b[i+1];
ll A[n+1] = {0},B[m+1] = {0};
forne(i,1,n+1){
	A[i] = A[i-1];
	A[i]+=a[i];
}
forne(i,1,m+1){
	B[i] = B[i-1];
	B[i]+=b[i];
}
ll fa = 0;

// forn(i,m+1) cout<<B[i]<<" ";cout<<endl;

for(ll i = n;i>=0;i--){
	ll cur_fa = i;
	// cout<<cur_fa<<endl;
	if(A[i] > k) continue;
	ll lo = 0,hi = m;
	ll cur_k = k-A[i];
	if(cur_k < 0) continue;
	// cout<<A[i]<<" "<<cur_k<<endl;
	while(lo < hi){
		ll mid = (lo+hi+1)/2;
		if(B[mid] <= cur_k){
			lo = mid;
		}
		else hi = mid-1;
	}
	cur_fa+=lo;
	fa = max(fa,cur_fa);
}
cout<<fa<<endl;
}

Measured memory_bytes: 9876
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define forn(i,n)for(ll i=0;i<(n);i++)
#define forn_rev(i,n)for(ll i=(n)-1;i>=0;i--)
#define for1n(i,n) for(ll i=1;i<=(n);i++)
#define ARRAY_SIZE(a) sizeof(a)/sizeof(*a)
#define INF 1e9+5
using namespace std;


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);cout.tie(NULL);
    ll N,K;
    cin>>N>>K;
    vector<ll> height(N+1);
    forn(i,N) cin>>height[i];
    vector<ll> dp(N+1,INF);
    dp[0]=0;
    //dp[1]=abs(height[0]-height[1]);
    for(ll i=0;i<N;i++){
        for(ll j=i+1;j<=i+K && j<N;j++)
            dp[j]=min(dp[j],dp[i]+abs(height[i]-height[j]));
    }
    cout<<dp[N-1];
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <fstream>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <algorithm>
#include <stack>
using namespace std;
int main() {
    long long n, w;
    cin >> n >> w;
    long long ws[n];
    long long vs[n];
    long long maxe = 0;
    for (long long i = 0; i < n; i ++) {
        cin >> ws[i] >> vs[i];
        maxe += vs[i];
    }
    long long dp[maxe+1];
    for (long long i = 0; i <= maxe; i ++) {
        dp[i] = 1000000000000000000;
    }
    dp[0] = 0;
    for (long long i = 0; i < n; i ++) {
        for (long long j = maxe; j >= 0; j --) {
            if (j + vs[i] <= maxe && dp[j] != 1000000000000000000) {
                dp[j + vs[i]] = min(dp[j + vs[i]], dp[j] + ws[i]);
            }
        }
    }
    long long ans = 0;
    for (long long i = maxe; i >= 0; i --) {
        //cout << dp[i] << " ";
        if (dp[i] <= w)
            ans = max(ans, i);
    }
    //cout << endl;
    cout << ans << endl;
}

Measured memory_bytes: 4380
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(int argc, char** argv){
    string S;
    long long int K;
    cin >> S >> K;

    vector<int> v(0);
    char tmp = S[0];
    bool flag = false;
    int succ = 1;
    if (S.length() == 1) {
        cout << K/2 << "\n";
        return 0;
    }
    for (size_t i=1; i<S.length(); i++){
        if (S[i] == tmp){
            if (flag == false){
                flag = true;
                succ = 2;
            } else {
                succ++;
            }
        } else {
            if (flag == false){
                v.push_back(1);
            } else {
                flag = false;
                v.push_back(succ);
                succ = 1;
            }
        }
        tmp = S[i];
    }
    v.push_back(succ);

    //for (size_t i=0; i<v.size(); i++) cerr << v[i] << "\n";

    long long unsigned int ans = 0;
    for (size_t i=0; i<v.size(); i++) ans += v[i]/2;
    ans *= K;
    if (S[0] == S[S.length()-1] && v[0]%2 == 1 && v[v.size()-1]%2 == 1)
        ans += K-1;
    if (v.size() == 1) ans = (v[0]*K)/2;
    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    int[] visited;
    List<Integer>[] lists;
    PriorityQueue<Integer> q;
    void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        lists = new ArrayList[n];
        visited = new int[n];
        q = new PriorityQueue<>((a, b) -> b - a);

        for (int i = 0; i < n; i++) {
            lists[i] = new ArrayList<>();
        }

        for (int i = 0; i < n - 1; i++) {
            int a = sc.nextInt() - 1;
            int b = sc.nextInt() - 1;
            lists[a].add(b);
            lists[b].add(a);
        }

        for (int i = 0; i < n; i++) {
            q.add(sc.nextInt());
        }

        visited[0] = q.remove();
        dfs(0);

        long sum = 0;
        for (int i = 1; i < n; i++) {
            sum += visited[i];
        }
        System.out.println(sum);


        StringBuffer sb = new StringBuffer();
        for (int i : visited) {
            sb.append(i);
            sb.append(' ');
        }
        System.out.println(sb.substring(0, sb.length() - 1));
    }

    void dfs(int current) {
        for (int next: lists[current]) {
            if (visited[next] == 0) {
                visited[next] = q.remove();
                dfs(next);
            }
        }
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 45052
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long a,b;
	char op;
	cin>>a>>op>>b;
	if(op=='+'){

		cout<<a+b;}
	
	else if(op=='-'){
	
	cout<<a-b;}
		return 0;
		
}

Measured memory_bytes: 256
//libraries
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//namespace
using namespace std;
using namespace __gnu_pbds;

//typedef
//typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<long long> vll;

//define
#define i(X) cin>>X;
#define ol(X) cout<<X<<endl;
#define os(X) cout<<X<<" ";
#define inpv(a,n) vector<ll> a(n); for(ll i=0;i<n;i++){cin>>a[i];}
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define line cout<<"\n";
#define pbp(a,b) push_back(make_pair(a,b));
#define iniv(A,n,p) vector<ll> A(n,p);
#define vst(A) sort(A.begin(),A.end());
#define rvst(A) sort(A.rbegin(),A.rend());
#define forin(i,a,b) for(ll i=a;i<=b;i++)
#define forde(i,a,b) for(ll i=a;i>=b;i--)
#define fio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const long long inf=(long long)1e18;
long long MOD=(long long)(1e9+7);
ll mod=MOD;

ll power(ll x,ll y)
{
    if (y == 0)
        return 1;
    ll p = power(x, y/2) % MOD;
    p = (p * p) % MOD;

    return (y%2 == 0)? p : (x * p) % MOD;
}

int main() 
{
	// #ifndef ONLINE_JUDGE
    //    freopen ("input.txt" , "r" , stdin);
	// 	// freopen ("OUTPUT.txt" , "w" , stdout);
	// #endif
	fio;
	ll testcase=1;
	//cin>>testcase;
	while(testcase--)
	{
		ll n;
		cin>>n;
		inpv(a,n);
		ll i=0;
		ll ans=0;
		while(i<n-1)
		{
			if(a[i+1]<a[i])
			{
				ans+=a[i]-a[i+1];
				a[i+1]=a[i];
			}
			i++;
		}
		ol(ans);
	}
}

Measured memory_bytes: 4784
n = int(input())
s = [input() for i in range(n)]

c0 = 0
c1 = 0
c2 = 0
c3 = 0

for i in range(n):
    if s[i] == 'AC':
        c0 += 1
    if s[i] == 'WA':
        c1 += 1
    if s[i] == 'TLE':
        c2 += 1
    if s[i] == 'RE':
        c3 += 1

print('AC x', c0)
print('WA x', c1)
print('TLE x', c2)
print('RE x', c3)

Measured memory_bytes: 16288
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector <int> vec(N);
  for(int i=0;i<N;i++){
    cin >> vec[i];
  }
  sort(vec.begin(),vec.end());
  cout << vec[N-1] - vec[0] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAX (1 << 15)
using namespace std;

int main()
{
	vector<vector<int>> dp(5, vector<int>(MAX + 1, 0));
	dp[0][0] = dp[1][0] = dp[2][0] = dp[3][0] = dp[4][0] = 1;
	for (int i = 1; i * i <= MAX; i++) {
		for (int j = 0; j < 4; j++) {
			for (int k = 0; k + i * i <= MAX; k++) {
				if (dp[j][k]) {
					dp[j + 1][k + i * i] += dp[j][k];
				}
			}
		}
	}
	int n;
	while (cin >> n, n) {
		cout << dp[4][n] << endl;
	}
	return 0;
}

Measured memory_bytes: 3584
S=input()
N=len(S)
l=S[0]
i=1
ans=1
while i<N:
  if len(l)==2:
    l=S[i]
    i+=1
    ans+=1
  else:
    if i<N-1:
      if S[i]==l:
        l=S[i:i+2]
        i+=2
        ans+=1
      else:
        l=S[i]
        i+=1
        ans+=1
    else:
      if S[i]!=l:
        ans+=1
        
      i+=1
      
print(ans)

Measured memory_bytes: 3500
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int k;
	cin>>k;
	cout<<(k/2)*((k+1)/2)<<endl;
}

Measured memory_bytes: 256
N,W = map(int,input().split())
WV = [list(map(int,input().split())) for _ in range(N)]

dp = [[0 for _ in range(W+1)] for _ in range(N+1)]
for i in range(1,N+1):
  for j in range(W+1):
    #print(i,j,WV[i-1][0],WV[i-1][1])
    if j - WV[i-1][0] >= 0:
      dp[i][j] = max(dp[i-1][j],dp[i-1][j-WV[i-1][0]] + WV[i-1][1])
    else:
      dp[i][j] = dp[i-1][j]
#print(dp)
print(dp[N][W])

Measured memory_bytes: 173192
#include <iostream>
#include<string>
#include <cstring>
#include <algorithm>

using namespace std;

#define MAX 2000000
#define INFTY (1<<30)

int H;
int A[MAX+1];

int parent(int i) {return i/2;}
int left(int i) {return 2*i;}
int right(int i) {return 2*i + 1;}

void maxHeapify(int i){
    int l = left(i);
    int r = right(i);
    int largest;

    if(l <= H && A[l] > A[i]) largest = l;
    else largest  = i;
    if(r <= H && A[r] > A[largest]) largest = r;

    if(largest != i){
        swap(A[i], A[largest]);
        maxHeapify(largest);
    }
}

int extract(){
    int maxv;
    if(H<1) return -INFTY;
    maxv = A[1];
    A[1] = A[H--];
    maxHeapify(1);
    return maxv;
}

void increaseKey(int i, int key){
    if(key < A[i]) return;
    A[i] = key;
    while(i > 1 && A[parent(i)] < A[i]){
        swap(A[i], A[parent(i)]);
        i = parent(i);
    }
}

void insert(int key){
    H++;
    A[H] = -INFTY;
    increaseKey(H, key);
}

int main(){
    int key;
    string com;

    while(1){
        cin >> com;
        if(com == "end" ) break;
        else if( com == "insert") {
            cin >> key;
            insert(key);
        }
        else if(com == "extract") cout << extract() << endl;
    }

    return 0;
}


Measured memory_bytes: 7012
#include <iostream>
#include <vector>

using namespace std;


unsigned int getDiff(unsigned int time) {
    if(time % 10 == 0)
        return 0;
        
    return 10 - (time % 10);
}

unsigned int nextOrder(unsigned int time) {
    while(time % 10 != 0)
        time++;
        
    return time;
}

int getMin(std::vector<unsigned int> v) {
    int ret, min = 100000000;
    
    for(int i=0; i<v.size(); i++) {
        if(getDiff(v[i]) < min) {
            min = getDiff(v[i]);
            ret = i;
        }
    }
    return ret;
}


int main(void){

    std::vector<unsigned int> v;
    unsigned int tmp,time = 0;
    
    for(int i=0; i<5; i++) {
        std::cin >> tmp;
        v.push_back(tmp);
    }
    

    for(int i=0; i<5; i++) {
        if(time % 10 != 0)
            time = nextOrder(time);
        int index = getMin(v);
        time += v[index];
        v.erase(v.begin() + index);
    }
    
    std::cout << time << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
  #include "_DEBUG.hpp"
#endif
#define int long long
const int INF = 1LL << 60;

signed main(){

  int n; cin >> n;
  vector<int> c(n), s(n), f(n);
  for(int i = 0; i < n-1; i++){
    cin >> c[i] >> s[i] >> f[i];
  }

  for(int i = 0; i < n; i++){
    int pos = i, t = 0;
    while(pos != n-1){
      if(t > s[pos]){
        //mul = (t - s[pos]) / f[pos];
        int left = -1, right = 1e10;
        while(right - left > 1){
          int mid = (left + right) / 2;
          (t <= s[pos] + f[pos] * mid ? right : left) = mid;
        }
        t = s[pos] + f[pos] * right + c[pos];
      }else{
        t = s[pos] + c[pos];
      }
      pos++;
      //cout << i << " -> " << pos << " " << t << endl;
    }
    cout << t << endl;
  }

  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
bool D[10];
int N;
bool meetConstraint(int x){
    while(x){
        if(D[x%10]) return false;
        x /=10;
    }
    return true;
}
int main(){
    int K, d;
    for(cin >> N>> K; K--;){
        cin >> d;
        D[d]=true;
    }
    while(!meetConstraint(N)) N++;
    cout << N << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    void solve() throws IOException {
        long n = nl();
        long x = nl();

        out.println(n + f(n - x, x));
    }

    long f(long a, long b) {
        if (a == 0) return -b;
        return 2 * (b / a) * a + f(b % a, a);
    }

    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }

    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }

    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

Measured memory_bytes: 8276
import java.util.*;
import java.io.*;
public class Main {
   static class pair implements Comparable<pair>{
        int a;
        int b;
        public pair(int a, int b){
            this.a=a;
            this.b=b;
        }
        public int compareTo(pair p){
            return (a-p.a==0)?Integer.compare(b,p.b):a-p.a;
        }
          
   }
  public static void main(String[] args) throws IOException,InterruptedException{
	BufferedReader	 br = new BufferedReader(new InputStreamReader(System.in));
	PrintWriter out = new PrintWriter(System.out);
     	// String s = br.readLine();
        // char[] arr=s.toCharArray();
        // ArrayList<Integer> arrl = new ArrayList<Integer>(); 
        // TreeSet<Integer> ts1 = new TreeSet<Integer>(); 
        // HashSet<Integer> h = new HashSet<Integer>(); 
        // HashMap<Integer, Integer> map= new HashMap<>(); 
        // PriorityQueue<String> pQueue = new PriorityQueue<String>(); 
        // LinkedList<String> object = new LinkedList<String>(); 
        // StringBuilder str = new StringBuilder();
        
        //*******************************************************//
 	   //  StringTokenizer   st = new StringTokenizer(br.readLine());
 	   // 	  int t = Integer.parseInt(st.nextToken());
 	   //    while(t-->0){
 	   //        st = new StringTokenizer(br.readLine());
 	   // 	  int n = Integer.parseInt(st.nextToken());
 	   // 	  int[] arr = new int[n];
 	   // 	  st = new StringTokenizer(br.readLine());
 	   // 	  for(int i=0; i<n; i++){
 	   // 	      arr[i] =Integer.parseInt(st.nextToken());
 	   // 	  }
 	   // 	  int ans =0;
 	   // 	  out.println(ans);
 	   //    }
 	          arr = br.readLine().toCharArray();
 	           arr2 = br.readLine().toCharArray();
 	           n1 = arr.length;
 	           n2 = arr2.length;
 	          dp = new int[n1+1][n2+1];
 	          for(int i=0; i<=n1; i++) Arrays.fill(dp[i],-1);
 	          int ans = solve(0,0);
 	          out.println(trace(0,0));
 	          
              out.flush();
 	    	  }
 	    	  static int n1;
 	    	  static int n2;
 	    	  static char [] arr;
 	    	  static char [] arr2;
 	    	  static int[][] dp;
              public static int solve(int i, int j){
                  if(i>=n1||j>=n2) return 0;
                  if(dp[i][j]!=-1) return dp[i][j];
                  if(arr[i]==arr2[j]) return dp[i][j]= 1+ solve(i+1,j+1);
                  else return dp[i][j]= Math.max(solve(i+1,j),solve(i,j+1));

              }
               public static String trace(int i, int j){
                  if(i>=n1||j>=n2) return "";
                  if(solve(i,j)==1+solve(i+1,j+1)&&arr[i]==arr2[j]) return arr[i]+""+trace(i+1,j+1);
                 else if(solve(i+1,j)>solve(i,j+1)) return trace(i+1,j);
                  else return trace(i,j+1);
              }
	}
	
	


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

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

  int n, m; cin >> n >> m;
  vector<vector<int>> s(m);
  rep(i, m) {
    int k; cin >> k;
    rep(j, k) {
      int t; cin >> t;
      s[i].push_back(--t);
    }
  }
  vector<int> p(n);
  rep(i, m) cin >> p[i];

  int ans = 0;
  rep(i, 1<<n) {
    bool flag = true;
    rep(j, m) {
      int cnt = 0;
      rep(k, s[j].size()) {
        if(i & 1<<s[j][k]) cnt++;
      }
      if(cnt%2 != p[j]) flag = false;
    }
    if(flag) ans++;
  }

  cout << ans << '\n';
  return 0;
}


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

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

int main() {
  int N, X;
	cin >> N >> X;
	vector<int> L(N);
	rep(i, N) {
		cin >> L[i];
	}

	int cnt = 1;
	int D = 0;
	rep(i, N) {
		D += L[i];
		if(D>X) break;
		cnt++;
	}

	cout << cnt << endl;
  return 0;
}


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

using ll = long long;

template <typename T>
using Matrix = vector<vector<T>>;

template <typename T>
Matrix<T> matrix(int R, int C, T x = T()) { return Matrix<T>(R, vector<T>(C, x)); }

ll solve(int N, int A, vector<int> values)
{
    auto max_value = accumulate(begin(values), end(values), 0);

    auto ways = matrix<ll>(N+1, max_value+1);
    ways[0][0] = 1;

    for (auto x : values)
    {
        auto next = matrix<ll>(N+1, max_value+1);
        for (auto k = 0; k <= N; k++) for (auto total = 0; total <= max_value; total++)
        {
            next[k][total] = ways[k][total];
            if (k >= 1 && total-x >= 0) next[k][total] += ways[k-1][total-x];
        }
        ways = next;
    }

    auto result = 0LL;
    for (auto k = 1; k <= N; k++) if (A*k <= max_value)
        result += ways[k][A*k];
    return result;
}

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

    auto values = vector<int>(N);
    for (auto& x : values) cin >> x;

    cout << solve(N, A, values) << endl;
}


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

#define mod (ll) (1e9)
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define pb push_back
//#define make_pair mp
#define pi acos(-1)

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

    string s;
    cin>>s;
    for(int i=0;i<s.size();i++)
    {
        cout<<"x";
    }
    cout<<endl;

}


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

int main() {
  // 入力
  int num;
  int k;
  int q;
  cin >> num;
  cin >> k;
  cin >> q;
  vector<int> ans(q);
  for (int i=0; i<q; i++){
    cin >> ans.at(i);
    ans.at(i)--;
  }
  //処理
  vector<string> isWin (num, "No");
  vector<int> point(num);
  for(int i=0; i<q; i++){
    point.at(ans.at(i))++;
  }
  for (int i=0; i<num; i++){
    if(point.at(i)+k-q<=0){
      cout << "No" <<endl;
    }else{
      cout << "Yes" <<endl;
    }
  }
  
}




Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {

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


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

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

  queue<ll> q;
  rep(i,1,10) q.push(i);

  int k = 0;
  ll ans = 0;
  
  while(true){
    ans = q.front();
    q.pop();
    k++;
    if(k==K) break;

    if(ans%10!=0) q.push((10*ans) + (ans%10) -1);
    q.push((10*ans) + (ans%10));
    if(ans%10!=9) q.push((10*ans) + (ans%10) +1);
  }

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


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

using ll = long long int;
using namespace std;

int main(){

  // read problem
  ll N, K;
  cin >> N >> K;

  // impossible
  if(N < 2*K -1){
    cout << "-1" << endl;
  }
  // possible
  else{
    // odd n
    if(N&1){
      // first loop
      for(ll i = 0; i < (N+1)/2; i++){
        cout << K + 2*i  << " " <<  K -1 + (3*N+1)/2 - i << " " <<  K+2*N+i << endl;
      }
      // second loop
      for(ll i = 0; i < N/2; i++){
        cout << K + 2*i+1 << " " << K-1 + 2*N-i << " " << K+2*N + (N+1)/2 + i << endl;;
      }
    }
    else{// if((N&1) == 0)
      // first loop
      for(ll i = 0; i < N/2; i++){
        cout << K + 2*i << " " << K-1 + (3*N)/2 - i << " " << K+2*N+i << endl;
      }
      // second loop
      for(ll i = 0; i < N/2; i++){
        cout << K + 2*i+1 << " " << K-1 + 2*N-i << " " << K+2*N + N/2 + i << endl;
      }
    }
  }

  return 0;
  
}


Measured memory_bytes: 2304
//clear adj and visited vector declared globally after each test case
//check for long long overflow
//while adding and subs check if mod becomes -ve
//while using an integer directly in a builtin function add ll
//Mod wale question mein last mein if dalo ie. Ans<0 then ans+=mod;
//Dont keep array name as size or any other key word

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);cout.precision(dbl::max_digits10);
#define pb push_back
#define mod 1000000007 //998244353
#define lld long double
#define mii map<int, int>
#define mci map<char, int>
#define msi map<string, int>
#define pii pair<int, int>
#define ff first
#define ss second 
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) for(int i=0;i<=n;i++){for(int j=0;j<=m;j++)cout<<dp[i][j]<<" ";cout<<"\n";}
typedef std::numeric_limits< double > dbl;
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const long long N=200005, INF=2000000000000000000;
lld pi=3.1415926535897932;
int lcm(int a, int b)
{
    int g=__gcd(a, b);
    return a/g*b;
}
int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;
        a%=p;
        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }

int32_t main()
{
    IOS;
    int n,k;
    cin>>n>>k;
    int ar[n];
    for(int i=0;i<n;i++)
    cin>>ar[i];
    int l=1,r=(int)1e9;
    int ans=r;
    while(l<=r)
    {
        int m=(l+r)/2;
        int c=0;
        for(int i=0;i<n;i++)
        c+=(((ar[i]+m-1)/m)-1);
        if(c<=k)
        {
            ans=m;
            r=m-1;
        }
        else
        l=m+1;
    }
    cout<<ans;
}

Measured memory_bytes: 5076
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#define INF 1000000000
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;

#define MAN 200000

int main(){
  string S;
  cin >> S;
  int min=10000;
  for(int i=0;i<S.length()-2;i++){
    int x = (S[i]-48)*100 + (S[i+1]-48)*10 + (S[i+2]-48)*1;// 48*3 より
    cerr << ":" << i << ":" << x << endl;
    int res = 753 > x?753 - x:x - 753;
    if(res<min)min=res;
  }
  cout << min << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>


int main(){
    char s[100];
    int res;
    scanf("%s", s);
    if(strcmp(s, "SUN") == 0){
        res = 7;
    }else if(strcmp(s, "MON") == 0){
        res = 6;
    }else if(strcmp(s, "TUE") == 0){
        res = 5;
    }else if(strcmp(s, "WED") == 0){
        res = 4;
    }else if(strcmp(s, "THU") == 0){
        res = 3;
    }else if(strcmp(s, "FRI") == 0){
        res = 2;
    }else if(strcmp(s, "SAT") == 0){
        res = 1;
    }
    printf("%d\n", res);
    return 0;
}

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

int main(){
    int n;
    string s;
    cin >> n;
    cout << 800*n-200*(n/15) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

const int maxn = 100;
int p[maxn][maxn];
int vis[maxn];
int edger[maxn],edgec[maxn];
int n;

void dfs(int j)
{
    for(int i = 1; i <= n; i++)
    {
        if(!vis[i] && p[j][i])
        {
            vis[i] = 1;
            dfs(i);
        }
    }
    return;
}
bool ifspecial(int i)
{
    p[edger[i]][edgec[i]] = 0;
    p[edgec[i]][edger[i]] = 0;
    memset(vis,0,sizeof vis);
    int cnt = 0;
    for(int i = 1; i <= n; ++i)
    {
        if(!vis[i])
        {
            dfs(i);
            cnt++;
        }
    }
    p[edger[i]][edgec[i]] = 1;
    p[edgec[i]][edger[i]] = 1;
    if(cnt == 1)
        return false;
    else
        return true;
}

int main()
{
#ifdef local
    freopen("in.txt","r",stdin);
#endif // local
    ios::sync_with_stdio(0),cin.tie(0);
    int m;
    cin >> n >> m;
    for(int i = 0; i < m; ++i)
    {
        int a,b;
        cin >> a >> b;
        p[a][b] = 1;
        p[b][a] = 1;
        edger[i] = a;
        edgec[i] = b;
    }

    int ans = 0;
    for(int i = 0; i < m; ++i)
        if(ifspecial(i))
           ans++;
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <numeric>
using namespace std;
typedef long long ll;
#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 fs first
#define sc second
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<tuple<ll,ll>> vtl;
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
#define pf(a) cout << (a) << endl;
#define be(x) (x).begin(),(x).end()


void solve(){
    int a,b;
    cin>>a>>b;
    if(a==1&&b==2)cout<<3;
    else if(a==1&&b==3)cout<<2;
    else if(a==2&&b==3)cout<<1;
    else if(a==2&&b==1)cout<<3;
    else if(a==3&&b==1)cout<<2;
    else if(a==3&&b==2)cout<<1;
}

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


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

int rally(const vector<int> &sort_vec) {
  int min = INT_MAX;
  int x = INT_MAX;
  for (auto n = sort_vec.front(); n <= sort_vec.back(); ++n) {
    auto tmp = 0;
    for (auto x : sort_vec) {
      tmp += (x - n) * (x - n);
    }
    if (min > tmp) {
      min = tmp;
    }
  }
  return min;
}

int main() {
  int n;
  cin >> n;
  auto vec = vector<int>(n);
  for (auto &x : vec) {
    cin >> x;
  }
  sort(vec.begin(), vec.end());
  cout << rally(vec) << endl;
}


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

using namespace std;

int main()
{
    int dp[31] = {1, 1, 2};
    int n;

    for (int i = 3; i <= 30; i++)
        dp[i] = dp[i - 1] + dp[i - 2] + dp[i - 3];

    while (cin >> n, n) 
        cout << dp[n] / 10 / 365 + 1 << endl;

    return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<set>
#include<vector>
#include<string>
#include<iterator>
#include<iomanip>
#include<cmath>
#include<map>
#include<string.h>
#include<algorithm>

using namespace std;
void ll(){
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(0);
}

int main(){

	ll();


	int x;
	cin >> x;
	cout << 48 - x << endl;
}

Measured memory_bytes: 3560
# -*- coding: utf-8 -*-

import math

while True:
    n = int(input())

    if n == 0:
        break

    s = list(map(float, input().split()))
    mean = sum(s) / len(s)

    for i in range(len(s)):
        s[i] = (s[i] - mean) * (s[i] - mean)

    variance = sum(s) / len(s)
    stdev = math.sqrt(variance)

    print(stdev)


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

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

//put debug temp

using namespace std;

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

const int Mod = (int)1e9 + 7;
const int MX = 1073741822;
const ll MXLL = 4e18;
const int Sz = 1110111;
// a pinch of soul
inline void Read_rap () {
  ios_base :: sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}
inline void randomizer3000 () {
  unsigned int seed;
  asm ("rdtsc" : "=A"(seed));
  srand (seed);
}
void files (string problem) {
  if (fopen ((problem + ".in").c_str(),"r")) {
    freopen ((problem + ".in").c_str(),"r",stdin);
    freopen ((problem + ".out").c_str(),"w",stdout);
  }
}
void localInput(const char in[] = "s") {
  if (fopen (in, "r")) {
    freopen (in, "r", stdin);
  }
  else
    cerr << "Warning: Input file not found" << endl;
}
int pa[Sz], pb[Sz];
int main()
{
  # ifdef Local
    //localInput();
  # endif
  Read_rap();
  string s, t;
  cin >> s >> t;

  int n = s.size();
  for (int i = 1; i <= n; i++) {

  	pa[i] = pa[i - 1] + (s[i-1] == 'A' ? 1 : 2);
  }
  int m = t.size();
  for (int i = 1; i <= m; i++) {
  	pb[i] = pb[i-1] + (t[i-1] == 'A' ? 1 : 2);
  }
  int q;
  cin >> q;
  while (q--) {
  	int a, b, c, d;
  	cin >> a >> b >> c >> d;
  	cout << (((pa[b]-pa[a-1])%3==(pb[d]-pb[c-1])%3) ? "YES" : "NO");
  	cout << endl;
  }

  return 0;
}





// Coded by Z..e

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

long long calc(long long s[100000], int n, bool f)
{
    long long cng = 0;
    long long ans = 0;
    if (f)
    {
        //最初を正の数にする
        if (s[0] <= 0)
        {
            cng = abs(s[0]) + 1;
            ans += cng;
        }
    }
    else
    {
        //最初を負の数にする
        if (s[0] >= 0)
        {
            cng = -abs(s[0]) - 1;
            ans += -cng;
        }
    }
    for (int i = 1; i < n; i++)
    {
        if (((s[i] + cng < 0) && (0 < s[i - 1] + cng)) || ((s[i] + cng > 0) && (0 > s[i - 1] + cng)))
        {
            //ok
            continue;
        }
        assert(s[i - 1] + cng != 0);

        if (s[i] + cng >= 0) //減らさないといけない
        {
            ans += s[i] + cng + 1;

            cng -= s[i] + cng + 1;
        }
        else //増やさないといけない
        {
            ans += -(s[i] + cng) + 1;

            cng += -(s[i] + cng) + 1;
        }
    }
    return ans;
}

int main()
{
    int n;
    cin >> n;
    long long a[n], s[n];
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        if (i == 0)
        {
            s[0] = a[0];
        }
        else
        {
            s[i] = s[i - 1] + a[i];
        }
    }
    cout << min(calc(s, n, true), calc(s, n, false)) << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  vector<pair<int,int>> v(m);
  for(int i=0;i<m;i++) cin>>v[i].first>>v[i].second;
  sort(v.begin(),v.end());
  v.push_back({1e9,1e9});
  set<int> st;
  int ans=0;
  for(auto p:v){
    if(st.size()>0){
      if(*st.begin()<=p.first){
        ans++;
        st={};
      }
    }
    st.insert(p.second);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 4932
n,m=map(int,input().split())
a=list(map(int,input().split()))
bc=[list(map(int,input().split())) for i in range(m)]
a.sort()
bc.sort(key=lambda x:x[1],reverse=True)
t=[]

for b,c in bc:
    a.extend([c]*b)
    if len(a)>2*n:
        break
a.sort(reverse=True)
print(sum(a[:n]))

Measured memory_bytes: 34756
#include <iostream>
#include <cstring>
#include <string>
using namespace std;
int main() {
    string ss;
    int n, cnt = 'A';
    while(cin>>n){
        cin>>ss;
        for(int i=0;i<ss.length();i++){
            int pt = (ss[i] - cnt + n ) % 26;
            char ans = 'A' + pt;
            cout << ans;
        }
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
using namespace std;
 
int main(){
    int n;
    cin >> n;
    pair<int,int> ab[n];
    for(int i = 0; i < n; i++){
        cin >> ab[i].first >> ab[i].second;
        if(ab[i].first > ab[i].second){
            cout << "No\n";
            return 0;
        }
    }
    sort(ab, ab+n, [](const pair<int,int>& i, const pair<int,int>& j){
        return i.second < j.second;
    });
    int t = 0;
    for(int i = 0; i < n; i++){
        // cout << t << ' ' << ab[i].first << ' ' << ab[i].second << '\n';
        if(t + ab[i].first > ab[i].second){
            cout << "No\n";
            return 0;
        }
        t += ab[i].first;
    }
    cout << "Yes\n";
}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<queue>
#include <climits>
const int mod = 1e9 + 7;
const int INF = 1e9;
using namespace std;
typedef long long ll;

ll gcd(ll a, ll 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;
}

int main()
{
    int n;
    cin >> n;
    ll ans = 1;
    for(int i = 0; i < n; i++){
        ll tmp;
        cin >> tmp;
        ans = lcm(ans,tmp);
    }
    cout << ans;
}


Measured memory_bytes: 256
N, M, Q  = map(int, input().split())
count = [[0] * (N+1) for i in range(N)]

for _ in range(M):
  L,R = map(int, input().split())
  count[L-1][R] += 1

for i in range(N):
  for j in range(1,N+1):
    count[i][j] += count[i][j-1]




for _ in range(Q):
  p,q = map(int, input().split())
  ans = 0

  for i in range(p-1,q):
    ans += count[i][q] - count[i][p-1]
  print(ans)

Measured memory_bytes: 53344
package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

var (
	reader = bufio.NewReader(os.Stdin)
	writer = bufio.NewWriter(os.Stdout)
)

func main() {
	defer writer.Flush()
	var s string
	fmt.Fscanf(reader, "%s\n", &s)
	ss := strings.Split(s, "")
	inter := len(ss)-2
	fmt.Fprintf(writer, "%s%d%s\n", ss[0],inter,ss[len(ss)-1])
}


Measured memory_bytes: 640