akhauriyash/Code-Regression huggingface dataset:
#include<iostream>

using namespace std;

int nlist[20];

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  nlist[a]++;
  nlist[b]++;
  nlist[c]++;
  if(nlist[5] == 2 && nlist[7] == 1){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
  return 0;
}


Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main(){
    int A;
    //数字
    string op;
    //記号
    int B;
    //数字
    cin >> A >> op >> B;
    if (op == "+"){
        cout << A + B << endl;
    } else if (op == "-"){
        cout << A - B << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int N;
  cin >> N;
  vector<pair<int,int>> red(N);
  vector<pair<int,int>> blue(N);
  rep(i,N) cin >> red[i].second >> red[i].first;
  rep(i,N) cin >> blue[i].first >> blue[i].second;
  sort(rall(red));
  sort(all(blue));
  vector<bool> okR(N,true);
  int ans = 0;
  for(int b=0;b<N;b++){
    for(int r=0;r<N;r++){
      if(blue[b].first > red[r].second && blue[b].second > red[r].first && okR[r]){
        okR[r] = false;
        ans++;
        r = 1e9;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
  os << p.first << " " << p.second;
  return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
  cerr << endl;
  rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
    if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
      cerr << "INF";
    } else
      cerr << v[i][j];
    cerr << (j == v[i].size() - 1 ? '\n' : ' ');
  }
  cerr << endl;
}
/*
   typedef __int128_t Int;
   std::ostream &operator<<(std::ostream &dest, __int128_t value) {
   std::ostream::sentry s(dest);
   if (s) {
   __uint128_t tmp = value < 0 ? -value : value;
   char buffer[128];
   char *d = std::end(buffer);
   do {
   --d;
 *d = "0123456789"[tmp % 10];
 tmp /= 10;
 } while (tmp != 0);
 if (value < 0) {
 --d;
 *d = '-';
 }
 int len = std::end(buffer) - d;
 if (dest.rdbuf()->sputn(d, len) != len) {
 dest.setstate(std::ios_base::badbit);
 }
 }
 return dest;
 }

 __int128 parse(string &s) {
 __int128 ret = 0;
 for (int i = 0; i < s.length(); i++)
 if ('0' <= s[i] && s[i] <= '9')
 ret = 10 * ret + s[i] - '0';
 return ret;
 }
 */

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

signed main(signed argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  int N;
  cin >> N;
  vector<double> p(N);
  rep(i, 0, N) { cin >> p[i]; }
  vector<vector<double>> dp(N + 1, vector<double>(N + 1));
  dp[0][0] = 1;
  rep(i, 0, N) {
    rep(j, 0, i + 1) {
      dp[i + 1][j + 1] += dp[i][j] * p[i];
      dp[i + 1][j] += dp[i][j] * (1 - p[i]);
    }
  }
  dump(dp);
  double ans = 0;
  rep(i, 0, N + 1) {
    if (i > N - i)
      ans += dp[N][i];
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 70784
#include <iostream>
using namespace std;
int main(){
  long long k,a,b;cin>>k>>a>>b;
  if(!(a < b-1))cout << k+1 << endl;
  else cout << (long long)(k-(a-1))/2*b + (k-(a-1))%2 - ((k-(a-1))/2-1)*a << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int n; cin >> n;
	vi v(n, inf);
	rep(i, n){
		int a; cin >> a;
		*upper_bound(all(v), -a) = -a;
	}
	cout << lower_bound(all(v), inf) - v.begin() << endl;
	
	return 0;
}

Measured memory_bytes: 640
def main():
    # import sys
    # readline = sys.stdin.buffer.readline
    # readlines = sys.stdin.buffer.readlines
    N = int(input())
    MOD = 10 ** 9 + 7
    cnt = 1
    for i in range(1, N + 1):
        cnt *= i
        cnt %= MOD
    print(cnt)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef uintptr_t ll;
const int mod = (int)1e9 + 7;
const int INF = (int)100100100;

int main() {
    ll N; cin >> N;
    //ll N,M; cin >> N >> M;
    //string S; cin >> S;
    //ll H,W; cin >> H >> W;
    vector<ll> num(N);
  	ll sos[26]={1,2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
    for(int i=0;i<N;i++){
        string s;
        cin >> s;
        ll sum=1;
        for(int j=0;j<10;j++){
            sum=sum*sos[s[j]-'a'];
        }
        num[i]=sum;
    }
    sort(num.begin(),num.end());
    ll ans=0;
    ll cou=0;
    for(int i=1;i<N;i++){
        if(num[i]==num[i-1])cou++;
        if(num[i]!=num[i-1] || i==N-1){
            ans+=cou*(cou+1)/2;
            cou=0;
        }
    }
    cout << ans;


}

/*



 */



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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,j,N) for(int i = (N-1);i >= (j);i--)
#define ALL(x) x.begin(),x.end()
#define PB push_back
#define LL long long

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {
    _for(i,0,v.size()) os << v[i] << " ";
    return os;
}

template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){
    for(typename set<T>::iterator it = v.begin();it != v.end();it++)
    os << *it <<" ";
    return os;
}

const int mod = 998244353;
const int maxn = 4005;
int f[maxn];
int inv[maxn];
int take[maxn];
int N,K;

int mult(int a,int b){
    LL ans = a;
    ans *= b;
    ans %= mod;
    return (int)ans;
}
int add(int a,int b){
    LL ans = (LL)a + mod;
    ans += b;
    ans %= mod;
    return (int)ans;
}


int fpow(int a,int p){
    if(p == 0) return 1;
    int ret = fpow(a,p/2);
    ret = mult(ret,ret);
    if(p&1) ret = mult(ret,a);
    return ret;
}

void init(){
    f[0] = (f[1] = 1);
    _for(i,2,maxn){
        f[i] = mult(f[i-1],i);
    }
    _for(i,0,maxn){
        inv[i] = fpow(f[i],mod-2);
    }
    _rep(i,1,K) _rep(j,i,K){
        ++take[i+j];
    }
}

int com(int a,int b){
    if(a < b) return 0;
    if(a == b) return 1;
    int ret = f[a];
    ret = mult(mult(ret,inv[a-b]),inv[b]);
    return ret;
}


int main()
{
    cin >> K >> N;
    init();
    int all_p = com(N+K-1,K-1);

    //cout << all_p << endl;

    _rep(i,2,2*K){
        int k = take[i];
        int p = -1;
        int cnt = 0;
        int ans = add(cnt,all_p);
        _for(j,0,k){
            //if(j == 2) break;
            int adds = p*mult(com(k,j+1),com(K+N-1-2*(j+1),K-1));
            //if(i == 6) cout << "adds:"<<adds << "a:"<<K+N-1-2*(j+1)<<"b:"<<K-1<<endl;
            if(adds == 0) break;
            ans = add(adds,ans);
            p *= -1;
        }
        printf("%d\n",ans);
    }

    return 0;
}


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

int main() {
	ios_base::sync_with_stdio( false );

	int K;
	cin >> K;

	int result = 0;
	for( int i = 1; i <= K; ++i ) {
		for( int j = i+1; j <= K; j += 2 ) {
			result += 1;
		}
	}

	cout << result << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>

#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007

using namespace std;

struct UnionFind{
  vector<int> par,num;

  UnionFind(int N) : par(N),num(N){
    for(int i=0;i<N;i++){
      par[i] = i;
      num[i] = 1;
    }
  }

  int root(int x){
    if(par[x] == x) return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y){
    int rx = root(x);
    int ry = root(y);
    if(rx == ry) return;
    par[rx] = ry;
    num[ry] = num[ry]+num[rx]; 
  }

  int get_num(int x){
    int rx = root(x);
    return num[rx];
  }

  bool same(int x, int y){
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};


int main(void){
  ll a,b,c,k;
  cin >> a >> b >> c >> k;
  if(k <= a+b){
    if(k <= a)cout << k << endl;
    else cout << a << endl;
  }
  else{
    cout << a-(k-(a+b)) << endl;
  }
  return 0;
}


Measured memory_bytes: 3636
A, B, C, X, Y = map(int, input().split())
sum = 0

while X > 0 or Y > 0:
    if X > 0 and Y > 0:
        if A + B > 2 * C:
            sum += 2 * C
            X -= 1
            Y -= 1
        else:
            sum += A + B
            X -= 1
            Y -= 1
    else:
        if X > 0:
            if A > 2 * C:
                sum += 2 * C
                X -= 1
                Y -= 1
            else:
                sum += A
                X -= 1
        else:
            if B > 2 * C:
                sum += 2 * C
                X -= 1
                Y -= 1
            else:
                sum += B
                Y -= 1

print(sum)


Measured memory_bytes: 3064
#include<iostream>
#include<cmath>
#include<complex>

#define EPS (1e-10)
#define EQ(a,b) (abs((a)-(b)) < EPS)

using namespace std;

typedef complex<double> P;

double dot(P,P);
int is_orthogonal(P,P,P,P);
 
int main(void){

  P a,b,c,d;

  while(~scanf("%lf %lf %lf %lf %lf %lf %lf %lf"
	       ,&a.real(),&a.imag(),&b.real(),&b.imag()
	       ,&c.real(),&c.imag(),&d.real(),&d.imag())){

    if(is_orthogonal(a,b,c,d))cout << "YES" << endl;
    else cout << "NO" << endl;
  }

  return 0;
}

double dot(P a,P b) {
  return (a.real() * b.real() + a.imag() * b.imag());
}

int is_orthogonal(P a1,P a2,P b1,P b2) {
  return EQ( dot(a1-a2, b1-b2), 0.0 );
}

Measured memory_bytes: 0
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)

  val n = sc.nextInt

  val al = List.fill(n)(sc.nextInt)

  val res = al.map(v2(_)).min

  println(res)


  def v2(n: Int, cnt: Int = 0) :Int ={
    if(n % 2 != 0 ) cnt
    else v2(n / 2, cnt + 1)
  }
}

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

#define FOR(i,a,b) for(size_t i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

typedef pair<ll, ll> pll;
// const ll INF = (ll)1e18;

signed main() {
	long n, z, w;
	cin >> n >> z >> w;
	long a[n];
	REP (i, n) {
		cin >> a[i];
	}
	long d1 = abs(w - a[n - 1]);
	long d2 =  n > 1 ? abs(a[n - 1] - a[n - 2]) : 0;
	// cout << d1 << ", " << d2 << endl;
	long res = max(d1, d2);
	cout << res << endl;
}


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

const int max_N = 1e5 + 21;

int n,a[max_N];

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i)scanf("%d",a+i);
	std::sort(a+1,a+1+n,[&](int x,int y){return x>y;});
	int i=1;
	while(i<=n&&i<a[i]&&i<a[i+1])++i;
	--i;
	int x=a[i+1]-i-1;
	int r=i; while(r<n&&a[r+1]>i)++r;
	int y=r-i-1;
	if(x&1||y&1)puts("First");
	else puts("Second");
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL


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

    s64 a, b, k;
    cin >> a >> b >> k;

    cout << MAX(a - k, 0) << " " << MAX(b - MAX(k - a, 0), 0) << "\n";

    return 0;
}



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

int main(){
	int x, y, z;
	cin >> x >> y >> z;
	if(x < y + 2 * z) {
		cout << 0;
		return 0;
	}
	cout << 1 + (x - y - 2*z) / (y + z);
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
int main()
{
	long long a = 0, b = 0, c = 0, tower[1000] = {0}, last = 0, k = 0, ansa = 0, ansb = 0, x = 0, y = 0, mi[1000] = {};
	
	int snow=0;
		int one = 0, ten = 0, hun = 0, thou = 0,man=0;
	std::cin >>a;
	
	bool okada = true;
	if (a % 2 == 0) {
		std::cout << a << std::endl;
	}
	else {
		std::cout << a * 2 << std::endl;
	}
	

}







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

int main ()
{
    long long n;
    cin >> n;
    long long sum = 0;
    long long i = 1;
    while (n != 0) {
        sum += i;
        n/=2;
        i*=2;
    }
    cout << sum << endl;
}


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

int main() {
int A, B;
cin >> A >> B;
if(A > 2*B)
cout << A-2*B << endl;
else
cout << 0 << endl;
}

Measured memory_bytes: 256
#include <iostream>

uint32_t myRead(void)
{
  uint32_t x;
  std::cin >> x;
  return x;
}

int main(int argc, char *argv[])
{
  uint32_t n, a, x;
  std::cin >> n >> a;
  for (uint32_t i=1; i<n; ++i) {
    a ^= myRead();
  }
  if (a == 0) {
    std::cout << "Yes" << std::endl;
  } else {
    std::cout << "No" << std::endl;
  }
  return 0;
}


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

#ifdef local
#define debug(var) cerr << #var << " = " << var;
#else
#define debug(var)
#endif

void init() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

void solve() {
	string s;
	cin >> s; cout << s[0];
	cin >> s; cout << s[0];
	cin >> s; cout << s[0];
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <utility>
#include <algorithm>
#include <set>
#include <queue>
#include <climits>
#include <limits>
#include <map>
#define inf 1000000000000000000

#define ll long long
#define max(A, B) ((A) > (B) ? (A) : (B))
#define min(A, B) ((A) < (B) ? (A) : (B))
#define pair(A, B) make_pair(A, B)
#define fu(a, b, c) for(ll a = b; a < c; a++)
#define fd(a, b, c) for(ll a = b; a > c; a--)

using namespace std;

typedef pair<ll, ll> pi;
typedef pair<pair<ll, ll>, ll> pii;

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

void perform() {
  ll n; cin >> n;
  ll ans = 0;
  fu(i, 1, n + 1)
  fu(j, 1, n + 1)
  fu(k, 1, n + 1)
  ans += gcd(gcd(i, j), k);
  cout << ans << endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll t = 1; //cin >> t;
  while (t--) {perform();}
}


Measured memory_bytes: 3196
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PGC
{
	class Program
	{
		static void Main(string[] args)
		{
			var header = Console.ReadLine().Split().Select(long.Parse).ToArray();
			var N = header[0];
			var M = header[1];
			var A = Console.ReadLine().Split().Select(long.Parse).ToArray();

			var fixA = A.OrderBy(a => a).Reverse().ToArray();

			var b = new long[N + 1];
			for (var i = 0; i < N; i++)
			{
				b[i + 1] = b[i] + fixA[i];
			}

			var aMax = 2 * 100000 + 1;
			var d = new int[aMax];

			for (var i = 0; i < N; i++)
			{
				d[fixA[i]]++;
			}
			for (var i = aMax - 1; 1 <= i; i--)
			{
				d[i - 1] += d[i];
			}

			var left = -1;
			var right = aMax;
			while (1 < right - left)
			{
				var mid = (right + left) / 2;
				var s = 0L;
				for (var i = 0; i < N; i++)
				{
					s += d[Math.Max(1, mid - fixA[i])];
				}
				if (M <= s)
				{
					left = mid;
				}
				else
				{
					right = mid;
				}
			}

			var ans = 0L;
			var ss = 0L;

			for (var i = 0; i < N; i++)
			{
				var v = Math.Max(0, right - fixA[i]);
				var t = Math.Max(0, Math.Min(d[v], M - ss));
				ans += b[t] + t * fixA[i];
				ss += t;
			}

			ans += left * (M - ss);
			System.Console.WriteLine(ans);
		}
	}
}


Measured memory_bytes: 29536
import java.util.*;
import java.math.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int k = sc.nextInt();

    int count = 0;
    long ans = 0;

    Deque<Long> q = new ArrayDeque<Long>();

    for (int i = 1; i <= 9; i++) {
      q.add((long)i);
    }

    while (true) {
      ans = q.poll();
      if (ans%10!=0) {
        q.add(ans*10+ans%10-1);
      }
      q.add(ans*10+ans%10);
      if (ans%10!=9) {
        q.add(ans*10+ans%10+1);
      }
      count++;

      if (count == k) {
        break;
      }

    }

    System.out.println(ans);
    
  }

}


Measured memory_bytes: 31828
# -*- coding: utf-8 -*-
from heapq import heappush, heappop

qn = int(input())

low = []
high = []
ans = 0

for i in range(qn):
    q = [int(i) for i in input().split()]
    if q[0] == 1:
        ans += q[2]
        a = q[1]

        # lowは降順に並べたいので-aを入れる
        heappush(low, -a)
        heappush(high, a)
        if -low[0] > high[0]:
            low0 = heappop(low)
            high0 = heappop(high)
            # lowとhighで正負が逆なので注意する
            heappush(low, -high0)
            heappush(high, -low0)
            ans += - low0 - high0

    elif q[0] == 2:
        print(-low[0], ans)


Measured memory_bytes: 19048
#include <bits/stdc++.h>
using namespace std;
//NOT TO SUBMIT IN WRONG PLACE OR BY WRONG COMPILER
//ABC 139, task c, 2020/08/29
//ms,
/*
*/

int main(void){
  int N;
  int64_t h_left, h_right;
  int ans=0;
  int tmp_ans=0;

  cin >>N;
  cin >>h_left;
  for(int i=1;i<N;i++){
    cin >>h_right;
    if(h_left >= h_right) tmp_ans++;
    else {
      ans = max(ans, tmp_ans);
      tmp_ans=0;
    }
    h_left = h_right;
  }
  ans = max(ans, tmp_ans);
  cout <<ans <<endl;
  return 0;
}
/*
*/


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
 ll K,X;
  cin>>K>>X;
  ll x=X-(K-1);
  while(x<=X+(K-1)) {
cout<<" "<<x;
  x++;
  }
  cout<<endl;
}
 


Measured memory_bytes: 3608
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
#define REP(i,a,b) for(int i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
#define ll long long
#define ull unsigned ll
typedef long double ld;
#define ALL(a) begin(a),end(a)
#define ifnot(a) if(not (a))
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;

// #define int ll
#ifdef _MSC_VER
const bool test = true;
#else 
const bool test = false;
#endif

int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
#define INF (1 << 28)
ull mod = (int)1e9 + 7;
//.....................
#define MAX (int)1e5 + 5

signed main() {
	string s;
	string s2 = "CODEFESTIVAL2016";
	cin >> s;
	int cnt = 0;
	rep(i, s.size()) if (s[i] != s2[i]) cnt++;
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
using LP=pair<ll,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353;

struct SegSum{
    //const ll INF=1e18;
    int n;
    vector<ll> dat;
    SegSum(int n_):n(),dat(n_*4,0){
        int x=1;
        while(n_>x){
            x*=2;
        }
        n=x;
    }

    void update(int i,ll x){//index iをxに更新する
        i+=n-1;
        dat[i]=x;
        while(i>0){
            i=(i-1)/2;
            dat[i]=dat[i*2+1]+dat[i*2+2];
        }
    }
    void upplu(int i,ll x){//index iにxをたす
        i+=n-1;
        dat[i]+=x;
        while(i>0){
            i=(i-1)/2;
            dat[i]=dat[i*2+1]+dat[i*2+2];
        }
    }

    ll query(int a,int b){//a以上b未満の区間の和を求める
        return query_sub(a,b,0,0,n);
    }
    ll query_sub(int a,int b,int k,int l,int r){
        if(r<=a || b<=l){
            return 0;
        }
        else if(a<=l && r<=b){
            return dat[k];
        }
        else{
            ll vl=query_sub(a,b,k*2+1,l,(l+r)/2);
            ll vr=query_sub(a,b,k*2+2,(l+r)/2,r);
            return vl+vr;
        }
    }
};

int main() {
    int N;
    cin>>N;
    vector<string> A(N);
    rep(i,N){
        cin>>A.at(i);
    }
    vector<int> sma(N);
    rep(i,N){
        int l=A.at(i).size();
        rep(j,l){
            if(A.at(i).at(j)=='.')sma.at(i)=l-1-j;
        }
    }
    vector<ll> se(N);
    rep(i,N){
        int l=A.at(i).size();
        rep(j,l){
            if(A.at(i).at(j)!='.'){
                se.at(i)*=10;
                se.at(i)+=A.at(i).at(j)-'0';
            }
        }
    }
    //rep(i,N)cout<<se.at(i)<<endl;
    vector<int> two(N),five(N);
    rep(i,N){
        while(se.at(i)%2==0){
            se.at(i)/=2;
            two.at(i)++;
        }
    }
    rep(i,N){
        while(se.at(i)%5==0){
            se.at(i)/=5;
            five.at(i)++;
        }
    }
    rep(i,N){
        two.at(i)-=sma.at(i);
        five.at(i)-=sma.at(i);
    }
    vector<P> tf(N);
    rep(i,N){
        tf.at(i).first=two.at(i);
        tf.at(i).second=five.at(i);
    }
    //rep(i,N)cout<<two.at(i)<<" "<<five.at(i)<<" "<<sma.at(i)<<endl;
    ll ans=0;
    SegSum ss(200);//+100
    sort(tf.begin(),tf.end());
    int p=N-1;
    rep(i,N){
        while(p>=0 && tf.at(p).first>=-tf.at(i).first){
            ss.upplu(tf.at(p).second+100,1);
            p--;
        }
        ans+=ss.query(-tf.at(i).second+100,200);
    }
    rep(i,N){
        if(tf.at(i).first>=0 && tf.at(i).second>=0)ans--;
    }
    cout<<ans/2<<endl;
}

Measured memory_bytes: 14676
import sys
from bisect import bisect_left
def input(): return sys.stdin.readline().strip()


def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort()
    if N == 2:
        print(A[1], A[0])
        return
    idx = bisect_left(A, A[-1] // 2)
    a = A[idx]
    if idx > 0 and (A[idx] - A[-1] / 2) > (A[-1] // 2 - A[idx - 1]):
        a = A[idx - 1]
    print(A[-1], a)


if __name__ == "__main__":
    main()


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

int main(){
    string str1, str2;
    int flag = -1;

    cin >> str1 >> str2;

    if(str1.size() == str2.size()){
        int i = 0;
        while(str1[i] != '\0'){
            if(str1[i] > str2[i]){
                flag = 0;
                break;
            }
            else if(str1[i] < str2[i]){
                flag = 1;
                break;
            }
            i++;
        }
        if(flag == -1){
            flag = 2;
        }
    }
    else if(str1.size() > str2.size()){
        flag = 0;
    }
    else{
        flag = 1;
    }

    if(flag == 0){
        cout << "GREATER" << endl;
    }
    else if(flag == 1){
        cout << "LESS" << endl;
    }
    else{
        cout << "EQUAL" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
S = input()
#奇数文字目がすべて R, U, D のいずれか。
#偶数文字目がすべて L, U, D のいずれか。
ans ="Yes"
for i in range(len(S)):
  if i%2==1:
    if S[i] != "L" and S[i] != "U" and S[i] != "D" :
      ans ="No"
  else:
    if S[i] != "R" and S[i] != "U" and S[i] != "D":
      ans ="No"
print(ans)

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

int main(){
    ll h; cin >> h;
    int cnt = 0;
    while(h) {
        h /= 2;
        cnt++;
    }
    ll ans = pow(2,cnt)-1;
    cout << ans << endl;
}

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

int a,b,c,ans,k,id,max1;

int main()
{
	cin>>a>>b>>c>>k;
    if(a>=b&&a>=c)
    {
    	id=1;
    	max1=a;
	}
	if(b>=a&&b>=c)
    {
    	id=2;
    	max1=b;
	}
	if(c>=a&&c>=b)
    {
    	id=3;
    	max1=c;
	}
	for(int i=1;i<=k;i++)
	{
		max1*=2; 
	}
	if(id==1)
	{
		cout<<max1+b+c<<endl;
	}
	else
	{
		if(id==2)
		{
			cout<<max1+a+c<<endl; 
		}
		else
		{
			cout<<max1+b+a<<endl;
		}
	}
}

Measured memory_bytes: 256
//ALDS1_12C
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
 
static const int MAX=10000;
static const int INF=(1<<21);
static const int WHITE=0;
static const int GRAY=1;
static const int BLACK=2;
 
int n;
vector<pair<int,int> > adj[MAX];
 
int dijkstra(){
 priority_queue<pair<int,int> > PQ;
 int d[MAX],color[MAX];
 for(int i=0;i<n;i++){
  d[i]=INF;
  color[i]=WHITE;
 }
 d[0]=0;
 PQ.push(make_pair(0,0));
 color[0]=GRAY;
 while(!PQ.empty()){
  pair<int,int> f=PQ.top(); PQ.pop();
  int u=f.second;
  color[u]=BLACK;
  if(d[u]<f.first*(-1)) continue;
  for(int j=0;j<adj[u].size();j++){
   int v=adj[u][j].first;
   if(color[v]==BLACK) continue;
   if(d[v]>d[u]+adj[u][j].second){
    d[v]=d[u]+adj[u][j].second;
    PQ.push(make_pair(d[v]*(-1),v));
    color[v]=GRAY;
   }
  }
 }
 for(int i=0;i<n;i++){
  cout<<i<<" "<<(d[i]==INF ? -1:d[i])<<endl;
 }
} 
 
int main(){
 int k,c,u,v;
 cin>>n;
 for(int i=0;i<n;i++){
  cin>>u>>k;
  for(int j=0;j<k;j++){
   cin>>v>>c;
   adj[u].push_back(make_pair(v,c));
  }
 }
 dijkstra();
 return 0;
}

Measured memory_bytes: 6308
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int sum=0;
	string s;
	cin >> s;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='+')sum++;
		else sum--;
	}
	cout<<sum<<endl;
	return 0;
 } 

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace  std;
static const int MAX=101;
int n,m;
int main(){
	int i,j,c=1;
	while(cin>>n>>m&&n&&m){
	//添加外圈
	int b[MAX][MAX]={0};
	char a[n+2][m+2];
	memset(a,'.',sizeof(a));
    //输入
	for(i=1;i<=n;i++){
		for(j=1;j<=m;j++){
			cin>>a[i][j];
		}
	}
	for(i=1;i<=n;i++)
    {
		for(j=1;j<=m;j++)
		{
          if(a[i][j]=='.')
          {
			if(a[i-1][j-1]=='#')  b[i][j]++;
			if(a[i-1][j]=='#')    b[i][j]++;
			if(a[i-1][j+1]=='#')  b[i][j]++;
			if(a[i+1][j-1]=='#')  b[i][j]++;
			if(a[i+1][j]=='#')    b[i][j]++;
			if(a[i+1][j+1]=='#')  b[i][j]++;
			if(a[i][j-1]=='#')    b[i][j]++;
			if(a[i][j+1]=='#')    b[i][j]++;
		  }
          else continue;
	   }
	}
    for(i=1;i<=n;i++){
    	for(j=1;j<=m;j++)
        {
    		if(a[i][j]=='.')
    		cout<<b[i][j];
        else
            cout<<a[i][j];
    	}
    	cout<<endl;
    }
    c++;
    cout<<endl;
}
}


Measured memory_bytes: 256
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
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; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int n;
double d[1010];

int main(){
    cin >> n;
    REP(i, n)cin >> d[i];
    sort(d, d + n);
    for(int i = 1;i < n;i++){
        d[i] = (d[i - 1] + d[i])/2;
    }
    cout << fixed << setprecision(13) << d[n - 1] << endl;
}

Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {
        var nk = Console.ReadLine().Split(' ');
        var n = int.Parse(nk[0]);
        var k = int.Parse(nk[1]);
        var l = new int[n];

        var s = Console.ReadLine().Split(' ');
        for (int i = 0; i < n; i++)
        {
            l[i] = int.Parse(s[i]);
        }

        Array.Sort(l, (x, y) => y - x);

        var ans = 0;
        for (int i = 0; i < k; i++)
        {
            ans += l[i];
        }

        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 11220
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		try {
			int n = sc.nextInt();
			int m = sc.nextInt();
			sc.nextLine();

			List<int[]> student = new ArrayList<int[]>();
			for (int i = 0; i < n; i++) {
				student.add(new int[] {sc.nextInt(), sc.nextInt(), Integer.MAX_VALUE, 0});
				sc.nextLine();
			}

			int manhattan = 0;
			for (int j = 0; j < m; j++) {
				int cj = sc.nextInt();
				int dj = sc.nextInt();
				for (int i = 0; i < n; i++) {
					int[] si = student.get(i);
					manhattan = Math.abs(si[0] - cj) + Math.abs(si[1] - dj);
					if (manhattan < si[2]) {
						si[2] = manhattan;
						si[3] = j;
					}
				}
				sc.nextLine();
			}

			student.stream().forEach(e -> System.out.println(e[3] + 1));

		} finally {
			sc.close();
		}
	}
}

Measured memory_bytes: 27348
#include <bits/stdc++.h>
#include <algorithm>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(), (x).end()
#define PB(x) push_back(x)
#define MP(x,y) make_pair(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;


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

    int memo;
    int amari;
    rep(i,10000001) {
        if(i%2 == 0) {
            if((i/2)*(1+i) >= n) {
                memo = i;
                amari = (i/2)*(i+1) - n;
                break; 
            }
        }
        else {
            if(i*((i+1)/2) >= n) {
                memo = i;
                amari = i*((i+1)/2) - n;
                break;
            }
        }
    }

    for(int i=1;i<memo+1;i++) {
        if(i != amari) {
            cout<<i<<'\n';
        }
    }

 return 0;
}


Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using Debug = System.Diagnostics.Debug;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;

static class P
{
    static void Main()
    {
        int a = NextInt, b = NextInt, c = NextInt;
        Console.WriteLine(c - (Min(a, b + c) - b));
    }



    static readonly TextReader In = Console.In;
    static int NextInt
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        get
        {
            int res = 0;
            int next = In.Read();
            int rev = 1;
            while (45 > next || next > 57) next = In.Read();
            if (next == 45) { next = In.Read(); rev = -1; }
            while (48 <= next && next <= 57)
            {
                res = res * 10 + next - 48;
                next = In.Read();
            }
            return res * rev;
        }
    }
}


Measured memory_bytes: 11092
#include<stdio.h>
#include<iostream>
#include <algorithm>

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

    int a[n];

    int num=0;
    for(int i=0;i<n-1;i++){
        if(q[i]>q[i+1]){
            if(num==0){
            a[num]=i;
            }else{
            a[num]=i+1;
            }
            num++; 
        }
    }

    int tmp;
    if(num==2){
    tmp=q[a[0]];
    q[a[0]]=q[a[1]];
    q[a[1]]=tmp;  
    }

    

    bool flag=false;
     for(int i=0;i<n-1;i++){
         //printf("%d\n",flag);
         if(q[i]>q[i+1]){
             flag=true;
         }
     }

    if(flag){
        printf("%s\n","NO");

    }else{
        printf("%s\n","YES");
    }

    return 0;
}

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define ALL(v) (v).begin(), (v).end()
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO  cout << "NO"  << endl
#define No  cout << "No"  << endl

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    string s; cin >> s;
    if((s.length() % 2 == 0) ^ (s[0] == s[s.length()-1])) cout << "Second" << endl;
    else cout << "First" << endl;
}
    
signed main() 
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
int main(){
  int i,j;
  char s[200010]={};
  scanf("%s",s);
  for(i=0;s[i]-'A';i++);
  for(j=200000;s[j]-'Z';j--);
  printf("%d\n",j-i+1);
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;

	ll ans = 0;
	rep(i, 1, N + 1) if (i % 3 != 0 && i % 5 != 0) ans += i;
	cout << ans << endl;
}







Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

ll A[200000];
ll dif[200000];

int main()
{
	int N;
	ll sum = 0, pre_sum = 0;

	cin >> N;
	rep(i, N) {
		cin >> A[i];
		sum += A[i];
	}

	rep(i, N - 1) {
		pre_sum += A[i];
		sum -= A[i];

		dif[i] = abs(pre_sum - sum);
	}

	sort(dif, dif + N - 1);

	cout << dif[0] << endl;

	return 0;
}


Measured memory_bytes: 3328
#include<stdio.h>
int main(){
  int dice[7],q,h,i,j,k,ans,ue,mae;
  int patan[7][4]={{0,0,0,0},{2,3,5,4},{6,3,1,4},{6,5,1,2},{2,1,5,6},{1,3,6,4},{2,4,5,3}};
  for(i=1;i<=6;i++){
    scanf("%d",&dice[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d %d",&ue,&mae);
    for(j=1;j<=6;j++){
      if(ue==dice[j])break;
    }
    for(k=1;k<=6;k++){
      if(mae==dice[k])break;
    }
    for(h=0;h<=3;h++){
      if(k==patan[j][h])break;
    }
    if(h==3){
      ans=dice[patan[j][h-3]];
      printf("%d\n",ans);
    }
    else{
      ans=dice[patan[j][h+1]];
      printf("%d\n",ans);
    }
  }
  return 0;
}

Measured memory_bytes: 596
#!/usr/bin/env python3
L = 10**5 + 2
is_prime = [True] * L
is_prime[0] = is_prime[1] = False
for i in range(2, L):
    if is_prime[i]:
        for j in range(2 * i, L, i):
            is_prime[j] = False

like = [0] * L
is_like = [False] * L
p = 0
for i in range(1, L):
    if is_prime[i] and is_prime[(i + 1) // 2]:
        is_like[i] = True
        p += 1
    like[i] = p

Q = int(input())
for i in range(Q):
    l, r = map(int, input().split())
    print(like[r] - like[l - 1])


Measured memory_bytes: 5748
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

constexpr ll mod = 1e9+7;
struct mint {
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    
    friend ostream &operator<<(ostream& os,const mint& a){
        return os << a.x;
    }

    friend istream &operator>>(istream& is,mint& a){
        ll t;
        is >> t;
        a = mint(t);
        return (is);
    }

    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};

class combination{
private:
    vector<mint> fact,inv,finv;
public:
    combination(int N){
        fact = inv = finv = vector<mint>(N+1);
        fact[0] = fact[1] = 1;
        inv[0] = inv[1] = 1;
        finv[0] = finv[1] = 1;
        for(ll i=2;i<=N;i++){
            fact[i] = fact[i-1]*i;
            inv[i] = (mint) mod - inv[mod%i]*(mod/i);
            finv[i] = finv[i-1]*inv[i];
        }
    }
    mint f(int i){
        return fact[i];
    }
    mint comb(int n,int k){
        if(n<k) return 0;
        if(n<0 || k<0) return 0;
        return fact[n]*finv[k]*finv[n-k];
    }
    mint hcomb(int n,int k){
        if(n==0 && k==0) return 1;
        return comb(n+k-1,k);
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    mint ans = 0;
    int K;
    cin >> K;
    string S;
    cin >> S;
    int N = S.size();
    combination C(N+K);
    for(int i=0;i<=K;i++){
        mint now = C.hcomb(N,K-i);
        now *= ((mint) 25).pow(K-i) * ((mint) 26).pow(i);
        ans += now;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 51256
import sys
str_array = list(map(str,input().split()))

for I in str_array:
    if not I.islower():
        sys.exit()
    if len(I) < 0 or len(I) > 10:
        sys.exit()

result = "YES"
last = ""
first = ""
for J in range(len(str_array)-1):
    first = str_array[J+1][0]
    last = str_array[J][-1]
    if not last == first:
        result = "NO"

print(result)

Measured memory_bytes: 9100
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
#include <numeric>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<ll, ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<P> vp;
#define rep(i, a, n) for (ll i = (a); i < (n); ++i)
#define rrep(i, a, n) for (ll i = (a); i > (n); --i)
#define erep(i, a, n) for (ll i = (a); i <= (n); ++i)
#define rerep(i, a, n) for (ll i = (a); i >= (n); --i)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
#define print(X) cout << (X) << "\n"
#define _ << " " <<
static const int INF = 1e+9+7;


int main(){
  int N;
  int i;
  cin >> N >> i;
  print(N-i+1);
  

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
#define pb push_back
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)

int main(){
  string s;
  ll k;
  cin>>s>>k;
  fr(i,100) if(s[i]!='1'){cout<<(i<k?s[i]-'0':1)<<endl;return 0;}
  cout<<1<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<stack>
#include<set>
#include<map>
#include<stdio.h>

using ll = long long;

using namespace std;

ll mod = 1000000007;

ll n_pow(ll a, ll n) {
	if (n == 0)return 1;
	ll t = n_pow(a, n / 2);
	t *= t;
	t %= mod;
	if (n % 2 == 1)t *= a;
	return t % mod;
}

ll f(ll n) {
	if (n == 0)return 1;
	ll t = f(n / 2);
	t *= t;
	if (n % 2 == 1)t *= 2;
	return t;
}

const int INF = 1001001001;


int main() {
	ll h;
	cin >> h;
	ll i = 0;
	ll ans = 0;
	while (h > 0) {
		h /= 2;
		ans += f(i);
		i++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<set>
#include<vector>
#include<queue>
#include<algorithm>
#define maxn 500005
#define LL long long
using namespace std;
typedef set<int>::iterator siter;
int n,k,p[maxn],ans[maxn],pos[maxn],vis[maxn],pr[maxn],cnt;
set<int> fr,bk;
vector<int> a[maxn];
priority_queue<int> q;
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++) 
	{
		scanf("%d",&p[i]);
		ans[i]=p[i],pos[p[i]]=i;
	}
	for(int i=1;i<=k;i++) bk.insert(p[i]);
	for(int i=1;i<=n;i++)
	{
		siter f=bk.upper_bound(p[i]),g=fr.upper_bound(p[i]);
		if(f!=bk.end())
		{
			a[pos[*f]].push_back(i);
			vis[i]++;
		}
		if(g!=fr.end())
		{
			a[pos[*g]].push_back(i);
			vis[i]++;
		}
		fr.insert(p[i]);
		if(i-k+1>0) fr.erase(p[i-k+1]);
		if(i+k<=n) bk.insert(p[i+k]);
		bk.erase(p[i]);
	}
	for(int i=1;i<=n;i++)
		if(!vis[i]) q.push(i);
	while(!q.empty())
	{
		int x=q.top(); q.pop();
		pr[++cnt]=x;
		for(int i=0,siz=a[x].size();i<siz;i++)
		{
			vis[a[x][i]]--;
			if(!vis[a[x][i]]) q.push(a[x][i]);
		}
	}
	for(int i=1;i<=n;i++) p[pr[i]]=n-i+1;
	for(int i=1;i<=n;i++) printf("%d\n",p[i]);
}

Measured memory_bytes: 64640
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(ALL(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define PI          3.14159265358979323846
#define MP(x, y)    make_pair(x, y)
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ld          long double
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    ll x;
    cin >> x;
    if(x / 11 > 1 && (x % 11 == 2 || x % 11 == 7 || x % 11 == 5)){
        ll k = x / 11;
        ll ans = 11 * (k - 1);
        if(x - ans == 13){
            cout << 2 * (k - 1) + 3;
        }else{
            cout << 2 * (k - 1) + 4;
        }
    }else{  
        ll delta = 0;
        if(x % 11 != 0){
            delta = 1 + (x % 11 > 6);
        }
        ll ans = 2 * (x / 11) + delta;
        cout << ans;
    }
    return 0;
}
/*
    *** Most Impo.. -> check base case always
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

Measured memory_bytes: 256