akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, s, e) for (ll i = s; i < e; i++)
#define Forr(i, s, e) for (ll i = s; i > e; i--)
#define pb push_back
#define ll long long
#define mp make_pair
unordered_map<ll, ll> m;
bool pairwise = 1;
void primeFactors(int n)
{
    set<ll> v;
    while (n % 2 == 0)
    {
        v.insert(2);
        if (m[2] > 0)
        {
            pairwise = 0;
            return;
        }
        n = n / 2;
    }
    for (int i = 3; i <= sqrt(n); i = i + 2)
    {
        while (n % i == 0)
        {
            if (m[i] > 0)
            {
                pairwise = 0;
                return;
            }
            v.insert(i);
            n = n / i;
        }
    }
    if (n > 2)
    {
        if (m[n] > 0)
        {
            pairwise = 0;
            return;
        }
        v.insert(n);
    }
    for (auto itr : v)
    {
        m[itr] = 1;
    }
}
int main()
{
    ll n;
    cin >> n;
    ll a[n];
    pairwise = 1;
    m.clear();
    For(i, 0, n)
    {
        cin >> a[i];
    }
    Forr(i, n - 1, -1)
    {
        if (pairwise)
            primeFactors(a[i]);
        else
            break;
    }
    if (pairwise)
        cout << "pairwise coprime\n";
    else
    {
        ll gcd = a[n - 1];
        Forr(i, n - 2, -1)
        {
            gcd = __gcd(gcd, a[i]);
        }
        if (gcd == 1)
            cout << "setwise coprime\n";
        else
            cout << "not coprime\n";
    }
    return 0;
}

Measured memory_bytes: 11420
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n;
  R n;
  vector<int> a(n+1);
  ll sum=0;
  REP(i,1,n+1) sum+=i;
  REP(k,2,n+1) {
    if(sum%k) continue;
    ll c[n+1];
    memset(c,-1,sizeof(c));
    vector<P> v;
    rep(j,k) {
      ll s=0;
      rrep(i,n+1) {
        if(c[i]!=-1) continue;
        if(s<sum/k&&s+i<=sum/k) {
          s+=i;
          c[i]=j;
        }
      }
      if(s!=sum/k) goto next;
    }
    REP(i,1,n+1) {
      REP(j,i+1,n+1) {
        if(c[i]!=c[j]) v.pb(P(i,j));
      }
    }
    pr(v.size());
    rep(i,v.size()) pr(v[i].F,v[i].S);
    return;
  next:;
  }
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 384
#pragma GCC optimize ("-O3")
#include <bits/stdc++.h>  
#include <complex>
#include <queue>
#include <set>
#include <unordered_set>
#include <list>
#include <chrono>
#include <random>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>
#include <fstream>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<ll> v32;
typedef vector<vector<ll> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<vector<p64> > vvp64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 1e9+7;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF 1e18
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
 

void solve()
{
	int n;
	cin>>n;
	v64 arr(n+1);
	v64 count(61,0);
	for (int i=1; i<=n; i++)
	{
		cin>>arr[i];
		for (int j=0; j<=60; j++)
		{
			if (arr[i] & 1LL<<j)
				count[j]++;
		}
	}
	ll ans=0;
	for (int i=0; i<60; i++)
	{
		ll temp=(count[i] * (n-count[i]));
		temp%=MOD;
		ll b=1LL<<i;
		b=b%MOD;
		ans=(ans + ((b*temp)%MOD) ) % MOD;
	}
	cout<<ans<<endl;
}
int32_t main()
{
    fast_cin();
    int t;
    t=1;
    while (t--)
    {
    	solve();
    }
    return 0;
} 

Measured memory_bytes: 2560
while True:
    n,x = map(int,input().split())
    
    if n == 0 and x == 0:
        break
    
    ans = 0
    for i in range(1,n+1):
        for j in range(i+1,n+1):
            for k in range(j+1,n+1):
                if i + j + k == x:
                    ans += 1
                
    
    print(ans)


Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
int main() {
  string S,T;cin>>S>>T;int U=0;
  for(int X=0;X<=S.size()-T.size();X++){
    string F=S.substr(X,T.size());int H=0;
    for(int Y=0;Y<T.size();Y++){
      if(T[Y]==F[Y]){
        H++;
      }
    }
    if(H>U){
      U=H;
    }
  }
  cout<<T.size()-U<<endl;
}

Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>

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

using namespace std;
typedef long long ll;

int main()
{
    int n;
    while(cin >> n && n) {
        int ans = 0;
        
        int m = sqrt(n) + 1;
        REP(i,1,m) {
            int a = i*i;
            if(a == n) ans++;
            REP(j,i,m) {
                int b = j*j;
                if(a + b == n) ans++;
                REP(k,j,m) {
                    int c = k*k;
                    if(a + b + c == n) ans++;
                    REP(l,k,m) {
                        int d = l*l;

                        if(a + b + c + d == n) ans++;
                    }
                }
            }
        }

        cout << ans << endl;
    }

    return 0;
}

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

int main()
{
    int N;
    cin >> N;
    double ans = 0;
    for(int i = 0; i < N; ++i) {
        double tmp;
        cin >> tmp;
        ans += (1.0/tmp);
    }
    cout << fixed << setprecision(10) << 1.0/ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <list>
#include <iostream>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using P = pair<int, int>;

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

  string s;
  cin >> s;
  if (s[2] == s[3] && s[4] == s[5]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

}

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

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

    int A[N];
    for(int i=0; i<N; i++){
        cin >> A[i];
    }
    double sum=0;
    for(int i=0; i<N; i++){
        sum+= A[i];
    }

    int count=0;
    for(int i=0; i<N; i++){
        if(sum/(4.0*M)<=A[i]){
            count++;
        }
    }

    if(count>=M){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(" ").map(String::toLong)
    val result = a.sorted()
            .asReversed()
            .subList(0, n * 2)
            .filterIndexed { index, n -> index % 2 == 1 }
            .sum()
    println(result)
}


Measured memory_bytes: 81724
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#define ll long long
#define rep(i, a, b) for(int i = a; i <= b; i++)
void read(int &x) {
    x = 0; int flag = 1; char ch = ' ';
    while(ch < '0' || ch > '9') { if(ch == '-') flag = -1; ch = getchar(); }
    while(ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
    x *= flag;
}
void read(ll &x) {
    x = 0; int flag = 1; char ch = ' ';
    while(ch < '0' || ch > '9') { if(ch == '-') flag = -1; ch = getchar(); }
    while(ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
    x *= flag;
}
using namespace std;
const int maxn = 410;
int n, a[maxn];
ll dp[maxn][maxn], sum[maxn];
int main()
{
    read(n);
    rep(i, 1, n) read(a[i]), sum[i] = sum[i - 1] + a[i];
    memset(dp, 0x3f3f, sizeof(dp));
    rep(i, 1, n) dp[i][i] = 0;
    rep(i, 2, n)
        rep(l, 1, n - i + 1) {
            int r = l + i - 1;
            rep(k, 1, i - 1)
                dp[l][r] = min(dp[l][r], dp[l][l + k - 1] + dp[l + k][r] + sum[r] - sum[l - 1]);
        }
    printf("%lld\n", dp[1][n]);
    return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
#define invrep(i,n) for(int64_t i=n-1;i >= 0;i--)
#define _GLIBCXX_DEBUG
using namespace std;
struct ssss{
  int64_t s1;
  int64_t s2;
  int64_t s3;
  int64_t s4;
};

int main(){
  int64_t h,w;
  cin >> h >> w;
  vector<vector<int64_t>> mtx(h,vector<int64_t>(w));
  rep(i,h){
    rep(j,w){
      cin >> mtx[i][j];
    }
  }
  int64_t cury=0,curx=0;
  bool having = false;
  vector<ssss> ss;
  for(int64_t y=0;y < h;y++){
    if(y % 2 == 0){
      for(int64_t x=0;x < w;x++){
        having = (having && (mtx[y][x] % 2 == 0))
          || (!having && (mtx[y][x] % 2 == 1));
        if(having){
          if(x == w-1){
            if(y != h-1){
              //printf("%ld %ld %ld %ld\n",y+1,x+1,y+2,x+1);
              ssss s;
              s.s1 = y+1; s.s2 = x+1; s.s3 = y+2; s.s4 = x+1;
              ss.push_back(s);
            }
          }else{
            //printf("%ld %ld %ld %ld\n",y+1,x+1,y+1,x+2);
            ssss s;
            s.s1 = y+1; s.s2 = x+1; s.s3 = y+1; s.s4 = x+2;
            ss.push_back(s);
          }
        }
      }
    }else{
      for(int64_t x=w-1;x >= 0;x--){
        having = (having && (mtx[y][x] % 2 == 0))
          || (!having && (mtx[y][x] % 2 == 1));
        if(having){
          if(x == 0){
            if(y != h-1){
              //printf("%ld %ld %ld %ld\n",y+1,x+1,y+2,x+1);
              ssss s;
              s.s1 = y+1; s.s2 = x+1; s.s3 = y+2; s.s4 = x+1;
              ss.push_back(s);              
            }
          }else{
            //printf("%ld %ld %ld %ld\n",y+1,x+1,y+1,x);
              ssss s;
              s.s1 = y+1; s.s2 = x+1; s.s3 = y+1; s.s4 = x;
              ss.push_back(s);            
          }
        }
      }  
    }
  }
  cout << ss.size() << endl;
   rep(i,ss.size()){
     printf("%ld %ld %ld %ld\n",ss[i].s1,ss[i].s2,ss[i].s3,ss[i].s4);
   }
  
          
        
}

Measured memory_bytes: 8432
#include "bits/stdc++.h"
 
using namespace std;
 
#define sp(x) cout<<setprecision(x);
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define yes "Yes"
#define no "No"
#define divs 1000000007
#define dive 1000000009
#define pi 3.141592653589793238
 
typedef pair<int, int> P;

// 座標 corrdinate と深さを保持するための構造体
struct cont {
    int dist, x, y;
};

signed main(){
    int H,W; cin>>H>>W;
    vector<string> s(H);
    int sx,sy;
    REP(i,H) cin>>s[i];
    int ans = 0;
	int dir[5]={0,1,0,-1,0};//4方向を見るのに使う、少しトリッキーだが多分見ればわかる
    REP(i,H){
        REP(j,W){            
            sx = j; sy = i; 
            if(s[i][j]=='#') continue;
            vector<vector<int>> seen(H, vector<int>(W, -1));
            queue<cont> q; q.push({0,sx,sy});//このキューにつまれているものはcont, つまりcとxとyのセット
            //最初の座標と、そこまでの距離が0が開始
            while(q.size()){//qに何か物が入っている間
                int dist=q.front().dist, x=q.front().x, y=q.front().y;
                q.pop();			//上に積まれているものを変数に移動する
                if(seen[y][x]!=-1) continue;
                ans = max(ans,dist);
                seen[y][x]=dist;
                REP(k,4){
                    if(y+dir[k+1]>=H||y+dir[k+1]<0||x+dir[k]>=W||x+dir[k]<0) continue;
                    if(s[y+dir[k+1]][x+dir[k]]=='#') continue;
                    else if(s[y+dir[k+1]][x+dir[k]]=='.'){//上下左右の今見てるマスが'.'だったら
                        q.push({dist+1,x+dir[k],y+dir[k+1]});//そのマスを次みると覚えとく(距離は+1)
                    }
                }
            }
        }
    }
    cout<<ans<<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++)

int main()
{
	int n,flag=0;
    cin >> n;
    int a[n],b[n],ans[n];
    
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    rep(i,n){
        ans[i]=b[n-1-i];  
    }
    int l=0,r=n-1;
    rep(i,n){
        if(a[i]==ans[i]){
            if(a[i]!=ans[l] && a[l]!=ans[i]){
                swap(ans[i],ans[l]);
                l++;
            }
            else if(a[i]!=ans[r] && a[r]!=ans[i]){
                swap(ans[i],ans[r]);
                r--;
            }
            else
                flag=1;
               
            
        }
    }
    if(flag==1) cout << "No" << endl;
    else{
    cout << "Yes" << endl;
    rep(i,n) cout << ans[i] << " ";
    cout << "" << endl;}
}

Measured memory_bytes: 5944
#include <iostream>
#include <string>
typedef long long ll;
//#include <algorithm>
using namespace std;

int main() {
  int num [2];
  int K;
  cin >> num[0] >> num[1] >> K;

  int index = 0;
  int oppIndex = 1;
  for(int i = 0; i < K; i++){
    if(num[index] % 2 != 0){
      num[index]--;
    }
    num[index] /= 2;
    num[oppIndex] += num[index];

    index = (index + 1) % 2;
    oppIndex = (oppIndex + 1) % 2;
  }

  cout << num[0] << " " << num[1] << endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#define MAX 2000
int A[MAX], M[MAX];
int a,b,i,j,k,f=0;

int solve(int p, int t){
	if (t - A[p] == 0){
		return 1;
	}
	if (p>=a){
		return 0;
	}
	if (solve(p + 1, t - A[p]) || solve(p + 1, t) ){
		return 1;
	}
	return 0;
}


int main(){
	

	scanf("%d",&a);
	for (i = 0; i < a;i++){
		scanf("%d",&A[i]);
	}
	scanf("%d",&b);

	for (i = 0; i < b;i++){
		scanf("%d",&M[i]);
	}

	for (i = 0; i < b; i++){
		if (solve(0, M[i])){
			printf("yes\n");
		}else{
			printf("no\n");
		}
	}

	return 0;

}

Measured memory_bytes: 588
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            long Q = long.Parse(Console.ReadLine());

            int max = 100000;
            int[] is2017 = new int[max + 1];
            bool[] isPrime = new bool[max + 1];
            
            for (var i = 1; i <= max; i++)
            {
                is2017[i] = is2017[i - 1];
                isPrime[i] = IsPrime(i);
                if (isPrime[i] && isPrime[(i+1)/2])
                {
                    is2017[i]++;
                }
            }

            for (var i = 0; i < Q; i++)
            {
                var line = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

                Console.WriteLine(is2017[line[1]] - is2017[line[0]-1]);
            }
        }

        private static bool IsPrime(int num)
        {
            // 1 以下は素数ではない
            if (num <= 1)
            {
                return false;
            }

            // 2 は素数である
            if (num == 2)
            {
                return true;
            }

            // 2 以外の偶数は素数ではない
            if (num % 2 == 0)
            {
                return false;
            }

            for (var i = 3; i < num; i += 2)
            {
                if (num % i == 0)
                {
                    return false;
                }
            }

            return true;
        }
    }
}

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

template<typename T, T F(T, T)>
struct BIT {
    T init;
    vector<T> x;
    BIT(ll n, ll init) : init(init), x(n, init) {}

    // i より小さな位置の要素の最大値を取得する
    T get(ll i){
        ll s = init;
        while(i > 0){
            s = F(s, x.at(i - 1));
            i -= i & (-i);
        }
        return s;
    }

    // i 番目に v を設定する
    void set(ll i, T v){
        i += 1;
        while(i <= x.size()){
            x.at(i - 1) = F(x.at(i - 1), v);
            i += i & (-i);
        }
    }
};

ll max_op(ll a, ll b){ return max(a, b); }
ll min_op(ll a, ll b){ return min(a, b); }

void solve(long long N, std::vector<long long> a){
    REP(i, N){ a.at(i)--; }

    vector<ll> left(N);
    BIT<ll, max_op> maxbit(N, -1);
    REP(i, N){
        left.at(i) = maxbit.get(a.at(i)) + 1;
        maxbit.set(a.at(i), i);
    }

    vector<ll> right(N);
    BIT<ll, min_op> minbit(N, N);
    for(ll i = N - 1; i >= 0; --i){
        right.at(i) = minbit.get(a.at(i)) - 1;
        minbit.set(a.at(i), i);
    }

    ll ans = 0;
    REP(i, N){
        ans += (a.at(i) + 1) * (i - left.at(i) + 1) * (right.at(i) - i + 1);
    }
    cout << ans << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
    }
    solve(N, std::move(a));
    return 0;
}


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

int main() {
    int a,b;
    cin >> a >> b;
    int cnt = 0;
    for (int i =0;i<2;i++){
        if (a>b){
            cnt += a;
            a--;
        }
        else{
            cnt += b;
            b--;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 1000007
#define INF63 1061109567
#define INF127 9187201950435737471
#define UINF 18446744073709551615
#define F first
#define S second
#define ll long long
using namespace std;
ll n,k,ans=0;
int main(){
	ll i,l,r;
	cin>>n>>k;
	for(i=k;i<=n+1;i++)
	{
		l=i*(i-1)/2;
		r=(n-i+1+n)*i/2;
		ans=(ans+r-l+1)%MOD;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3620
using System;
	class Program
	{
		public static void Main(string[] args)
		{
			
			int seconds=int.Parse(Console.ReadLine());
			
			int h=seconds/3600;
			int m=(seconds%3600)/60;
			int s=(seconds%3600)%60;
			
			Console.WriteLine(h+":"+m+":"+s);
			
			
			
		}
	}

Measured memory_bytes: 9088
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;
import java.util.PriorityQueue;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    String[] l = br.readLine().split(" ");
    int N = Integer.parseInt(l[0]);
    int Q = Integer.parseInt(l[1]);
    Point[] a = new Point[N * 2 + Q];
    for (int i = 0; i < N; i++) {
      String[] line = br.readLine().split(" ");
      int s = Integer.parseInt(line[0]);
      int t = Integer.parseInt(line[1]);
      int x = Integer.parseInt(line[2]);
      a[i * 2] = new End(s - x, i, x, true);
      a[i * 2 + 1] = new End(t - x, i, x, false);
    }
    for (int i = 0; i < Q; i++) {
      int d = Integer.parseInt(br.readLine());
      a[N * 2 + i] = new Query(d, i);
    }
    Arrays.sort(a, Comparator.comparingInt(point -> point.x));

    int[] result = new int[Q];
    Arrays.fill(result, -1);

    PriorityQueue<End> pq = new PriorityQueue<>(Comparator.comparingInt(end -> end.xx));
    boolean[] removed = new boolean[N];
    for (int i = 0; i < N * 2 + Q; i++) {
      Point p = a[i];
      if (p instanceof End) {
        End e = (End) p;
        if (e.start) pq.add(e);
        else removed[e.id] = true;
      } else {
        Query q = (Query) p;
        while (!pq.isEmpty() && removed[pq.peek().id]) {
          pq.poll();
        }
        if (!pq.isEmpty()) result[q.id] = pq.peek().xx;
      }
    }

    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < Q; i++) {
      sb.append(result[i]).append('\n');
    }
    System.out.print(sb.toString());
  }

  private static class Point {
    protected final int x;

    private Point(int x) {
      this.x = x;
    }
  }

  private static class End extends Point {
    private final int id;
    private final int xx;
    private final boolean start;

    private End(int x, int id, int xx, boolean start) {
      super(x);
      this.id = id;
      this.xx = xx;
      this.start = start;
    }
  }

  private static class Query extends Point {
    private final int id;
    private Query(int x, int id) {
      super(x);
      this.id = id;
    }
  }
}


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

int main() {
    int n, m, c=0;
    int p[100002], y[100002];
    cin>>n>>m;
    for(int i=0;i<100002;i++){
        p[i]=y[i]=0;
    }
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        p[x%m]++;
        y[x]++;
    }
    c+=p[0]/2;
    p[0]%=2;
    if(m%2==0){
        c+=p[m/2]/2;
        p[m/2]%=2;
    }
    for(int i=1;i<m-i;i++){
        int z=min(p[i], p[m-i]);
        c+=z;
        p[i]-=z;
        p[m-i]-=z;
    }
    for(int i=1;i<=100000;i++){
        int z=min(p[i%m], y[i]);
        z-=z%2;
        if(z>=2){
            p[i%m]-=z;
            c+=z/2;
        }
    }
    cout<<c<<endl;
	return 0;
}

Measured memory_bytes: 1024
n=int(input())
R=[]
for i in range(n) :
    x,l=map(int,input().split())
    R.append([x+l,x-l])          #[右,左]
R.sort()                         #右側で小さい順からソート

def solve() :
    t,ans=-1000000000,0
    for i in range(n) :
        if R[i][1]>=t :
            ans+=1
            t=R[i][0]
    return ans

print(solve())

Measured memory_bytes: 24428
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string a, b;
    cin >> a >> b;
    string s = "";
    for(int i = 0; i < stoi(b); i++) {
        s += a;
    }
    string t = "";
    for(int i = 0; i < stoi(a); i++) {
        t += b;
    }
    vector<string> hoge;
    hoge.push_back(s);
    hoge.push_back(t);
    sort(ALL(hoge));
    cout << hoge[0] << endl;
}

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

class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = Integer.parseInt(sc.next());
		int K = Integer.parseInt(sc.next());

		List<Integer> s = new ArrayList();

		for(int i = 0; i < N;i++) {
			s.add(0);
		}

		for(int i = 0;i < K;i++) {
			int ii = Integer.parseInt(sc.next());
			for(int r = 0;r < ii; r++) {
				int c = Integer.parseInt(sc.next()) -1;
				int b = s.get(c);
				s.set(c, ++b);
			}
		}

		int aa = 0;
		for(Integer a : s) {
			if(a == 0) aa++;

		}

		System.out.println(aa);


	}
}

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

void newarray(int *n, int length)
{
	for(int i=0; i<length; i++){
		n[i] = (n[i] + n[i+1]) % 10;
	}
}


int main()
{
	int n[10];
	long long int in;

	while( scanf("%Ld" ,&in) != EOF){
		long long int now = in;
		for(int i=9; i>0; i--){
			n[i] = now % 10;
			now = now / 10;
			if(i==1)	n[0] = now;
		}
		//分解end.
	
		for(int i=0; i<9; i++){
			newarray( n , (sizeof(n) / sizeof(n[0])));
		}
	
		cout << n[0] << endl;
	}
	return 0;
}

Measured memory_bytes: 1204
class Queue:
    def __init__(self, data=[]):
        self.data = data

    def enqueue(self, x):
        self.data.append(x)

    def dequeue(self):
        return self.data.pop(0)

    def is_Empty(self):
        if len(self.data) == 0:
            return True
        else:
            return False


n, q = map(int, input().split())  # プロセスの数n, 各界の処理能力q
queue = Queue()
for _ in range(n):
    name, t = map(str, input().split())
    queue.enqueue([name, int(t)])

done_process = {}

now_time = 0
while not queue.is_Empty():
    name, t = queue.dequeue()
    if t > q:
        t -= q
        now_time += q
        queue.enqueue([name, t])
    else:
        now_time += t
        done_process[name] = now_time


for k, v in done_process.items():
    print(k, v)



Measured memory_bytes: 17232
from bisect import bisect_left

def prime_factorize(n):
    res = []
    for i in range(2, int(n**(1/2))+1):
        if n % i != 0: continue
        num = 0
        while n % i == 0:
            num += 1
            n /= i
        res.append((i, num))
    if n != 1:
        res.append((n, 1))
    
    return res

n = int(input())

prime = prime_factorize(n)

c = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55]

ans = 0
for k, v in prime:
    i = bisect_left(c, v)
    if c[i] == v: i += 1
    ans += i

print(ans)


Measured memory_bytes: 9480
import Control.Monad
import qualified Data.ByteString.Char8 as BS
import Data.List
import Data.Maybe
import Data.Ord
import qualified Data.Vector as VC
import qualified Data.Vector.Mutable as VM

readNums :: IO [Integer]
readNums = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

readNumLists :: Int -> IO [[Integer]]
readNumLists n = replicateM n (map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine)

readStrings :: IO [String]
readStrings = map BS.unpack . BS.words <$> BS.getLine

readStringLists :: Int -> IO [[String]]
readStringLists n = replicateM n (map BS.unpack . BS.words <$> BS.getLine)

toTuple :: [a] -> (a, a)
toTuple (x:y:_) = (x, y)

p s = putStr (show s ++ " ")

main :: IO ()
main = do
  (a:b:_) <- readNums
  putStrLn $ solve (fromIntegral a) (fromIntegral b)

solve a b
  | a > b = concat $ replicate a (show b)
  | otherwise = concat $ replicate b (show a)

Measured memory_bytes: 380
#include<stdio.h>

int main(void)
{
	
	int W,H,x,y,r;
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);

	if(H>=y+r&&W>=x+r&&x-r>=0&&y-r>=0)

{

	printf("Yes\n");
}

	else{
		printf("No\n");

	}
	return 0;
}

Measured memory_bytes: 584
function Main(input) {
    var args = input.trim().split('\n');
    var text = args[1].split(' ');
    var ans = "";
    for(var i = 0;i <= Number(args[0]);i++) {
        ans += text[0].charAt(i);
        ans += text[1].charAt(i);
    }
    console.log(ans);
}
/* 
 var input = `2
aa aa`;
Main(input);
 */  
  Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1e9
#define LINF 1e18
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define MOD 1000000007LL
#define int long long
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
struct edge{int to,cost;};
typedef pair<int,int> P;

bool isupper(char c){if('A'<=c&&c<='Z')return 1;return 0;}
bool islower(char c){if('a'<=c&&c<='z')return 1;return 0;}

bool f(string s){
    rep(i,0,s.size()/2){
        if(s[i]!=s[s.size()-i-1])return false;
        
    }
    return 1;
}

signed main (){
    int d,g;cin>>d>>g;
    vector<int> p(d),c(d);
    rep(i,0,d)cin>>p[i]>>c[i];
    int ans=1e18;
    rep(i,0,1<<d){
        int sum=0;
        int rest=0;
        int num=0;
        rep(j,0,d){
            if(i>>j&1){
                sum+=(j+1)*100*p[j]+c[j];
                num+=p[j];
            }else {
                rest=j;
            }
        }
        if(sum<g){
            int need=(g+(rest+1)*100-sum-1)/((rest+1)*100);
            if(need>=p[rest])continue;
            num+=need;
        }
        ans=min(ans,num);
    }
    cout<<ans<<endl;

    




}
/*
1-2
0.5-2

010
01110
00111
000000111
*/


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>

int main() {
  size_t N, K;
  scanf("%zu %zu", &N, &K);

  std::vector<int> h(N);
  for (size_t i = 0; i < N; ++i) {
    scanf("%d", &h[i]);
  }

  int INF = 2e9;
  std::vector<int> dp(N, INF);
  dp[0] = 0;
  for (size_t i = 0; i < N; ++i)
    for (size_t j = 1; j <= std::min(N-1, K); ++j)
      dp[i+j] = std::min(dp[i+j], dp[i]+std::abs(h[i]-h[i+j]));

  printf("%d\n", dp[N-1]);
}


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

int a, b, c;

int main() {
#ifdef LOCAL
    freopen("xxx.in", "r", stdin);
    freopen("xxx.out", "w", stdout);    
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> a >> b >> c;
    int kk = 0;
    if (a == b && b == c && a % 2 == 0) {
        cout << -1;
        return 0;
    }
    while (true) {
        if (a % 2 == 1 || b % 2 == 1 || c % 2 == 1)
            break;
        int aa = a / 2;
        int bb = b / 2;
        int cc = c / 2;
        a = bb + cc;
        b = aa + cc;
        c = aa + bb;
        ++kk;
    }
    cout << kk;
    return 0;
}

Measured memory_bytes: 384
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   main.cpp                                           :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: monoue <marvin@student.42.fr>              +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/04/22 12:30:15 by monoue            #+#    #+#             */
/*   Updated: 2020/05/06 07:02:32 by monoue           ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include <bits/stdc++.h>

/* #include <boost/multi_array.hpp> */
/* #include <boost/optional.hpp> */
/* #include <boost/range/irange.hpp> */
/* #include <boost/range/algorithm.hpp> */
/* #include <boost/range/adaptors.hpp> */
/* #include <boost/multiprecision/cpp_int.hpp> */
/* #include <boost/algorithm/string/classification.hpp> // is_any_of */
/* #include <boost/algorithm/string/split.hpp> */
/* #include <boost/algorithm/string/join.hpp> */
/* #include <boost/algorithm/string/replace.hpp> */
/* #include <boost/math/tools/minima.hpp> */
/* namespace adaptor = boost::adaptors; */
/* using boost::math::tools::brent_find_minima; */
/* using boost::irange; */
/* using boost::algorithm::join; */
/* using boost::algorithm::split; */
/* using boost::algorithm::replace_all; */
/* using boost::multiprecision::cpp_int; */

using namespace std;

#define	int	long long
#define MOD 1000000007
#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++)
#define rrep(i, n) for (int i = (n); i >= 0; --i)

typedef long long 			ll;
typedef vector<int>			VI;
typedef vector<vector<int>>	VVI;
typedef pair<int, int>		PII;

// TOP
int					n;
vector<vector<PII>>	G;
VI					color;

void	dfs(int v, int cur = 0)
{
	color[v] = cur;
	for (auto next_v : G[v])
	{
		int nv, nw;

		nv = next_v.first;
		nw = next_v.second;
		if (color[nv] != -1)
			continue;
		if (nw)
			dfs(nv, 1 - cur);
		else
			dfs(nv, cur);
	}
}

void	Main()
{
	cin >> n;
	G.resize(n);
	rep(i, n - 1)
	{
		int u, v, w; cin >> u >> v >> w;
		u--;
		v--;
		w &= 1;
		G[u].push_back(PII(v, w));
		G[v].push_back(PII(u, w));
	}
	color.assign(n, -1);
	rep(v, n)
	{
		if (color[v] != -1)
			continue;
		dfs(v);
	}
	rep(i, n)
		cout << color[i] << endl;
}
// END

int32_t	main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 9984
fn main() {
    a();
}


fn a() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    let num: i32 = s.trim().parse().unwrap();
    let ans = if num < 1200 {
        "ABC"
    } else if num < 2800 {
        "ARC"
    } else {
        "AGC"
    };
    println!("{}",ans);
}

fn b() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    let num: i32 = s.trim().parse().unwrap();
    if num < 105 {
        println!("{:?}",0);
    } else if num < 135 {
        println!("{:?}",1);
    } else if num < 165 {
        println!("{:?}",2 );
    } else if num < 189 {
        println!("{:?}",3 );
    } else if num < 195 {
        println!("{:?}",4 );
    } else {
        println!("{:?}",5 );
    }

}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

int main(){
  int n,m;
  string s,t;
  cin>>s;
  cin>>t;
  n=s.size();
  m=t.size();
  int it=-1;
  for(int i=0;i<=n-m;i++){
    for(int j=0;j<m;j++){
      if(s[i+j]!='?'&&s[i+j]!=t[j]){
        break;
      }
      if(j==m-1) it=i;
    }
  }
  if(it==-1){
    cout<<"UNRESTORABLE"<<endl;
  }else{
    for(int i=it;i<it+m;i++){
      s[i]=t[i-it];
    }
    for(int i=0;i<n;i++){
      if(s[i]=='?') s[i]='a';
    }
    cout<<s<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define puts(x) cout << x << "\n"
constexpr int mod = 1000000007;
using namespace std;
int d, c[30], l[30], s[400][30];
signed main() {
	cin >> d;
	for1(i, 26)cin >> c[i];
	for1(i, d)for1(j, 26)cin >> s[i][j];
	for1(i, d) {
		int p = 0, k = -mod;
		for1(j, 26) {
			int kj = s[i][j] + c[j] * (i - l[j]) * 3 + c[j] * 12;
			if (kj > k) { p = j; k = kj; }
			else if (kj == k && c[j] > c[p])p = j;
		}
		puts(p); l[p] = i;
	}
}

Measured memory_bytes: 3728
import bisect
N = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))

res = 0
for j in range(N):
	indA = bisect.bisect_left(A,B[j])
	ansA = indA
	indC = bisect.bisect_right(C,B[j])
	ansC = N - indC
	res += ansA * ansC

print(res)

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


int main(){
  while(true){
    int much;
    int ot=0;
    cin>>much;
    if(much==0){
      break;
    }
    much=1000-much;
    while(true){
      if(much>=500){
	much=much-500;
	ot=ot+1;
      }else{
	break;
      }
    }
    while(true){
      if(much>=100){
	much=much-100;
	ot=ot+1;
      }else{
	break;
      }
    }
    while(true){
      if(much>=50){
	much=much-50;
	ot=ot+1;
      }else{
	break;
      }
    }
    while(true){
      if(much>=10){
	much=much-10;
	ot=ot+1;
      }else{
	break;
      }
    }
    while(true){
      if(much>=5){
	much=much-5;
	ot=ot+1;
      }else{
	break;
      }
    }
    while(true){
      if(much>=1){
	much=much-1;
	ot=ot+1;
      }else{
	break;
      }
    }
    cout<<ot<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <tuple>
#include <unordered_set>
#include <unordered_map>

typedef long long ll;
using namespace std;

int main(void) {
  ll N; cin >> N;
  unordered_set<ll> A;

  for (int i = 0; i < N; i++) {
    ll tmp; cin >> tmp;
    if (A.find(tmp) == A.end()) {
      A.insert(tmp);
    } else {
      A.erase(tmp);
    }
  }
  cout << (A.size()) << endl;
}


Measured memory_bytes: 4388
#include <iostream>
#include <algorithm>
#include <vector>
#define int long long
#define F first
#define S second
using namespace std;
pair<pair<int, int>, int> a[114514];
vector<pair<int, int>>v;
signed main() {
	int n, c; cin >> n >> c;
	for (int i = 0; i < n; i++) cin >> a[i].F.F >> a[i].F.S >> a[i].S;
	sort(a, a + n);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < v.size(); j++) {
			if (v[j].S == a[i].S && v[j].F <= a[i].F.F) {
				v[j] = make_pair(a[i].F.S, a[i].S);
				goto heaven;
			}
			else if (v[j].S != a[i].S && v[j].F < a[i].F.F) {
				v[j] = make_pair(a[i].F.S, a[i].S);
				goto heaven;
			}
		}
		v.push_back(make_pair(a[i].F.S, a[i].S));
	heaven:;
	}
	cout << v.size() << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        std::cin.tie(0);
        ios::sync_with_stdio(false);
        cout.precision(20);
    }
} fast;

/* define */
#define FOR(I, X, Y) for (long long(I) = (X); (I) < (Y); (I)++)
#define REP(I, X, Y) for (long long(I) = (Y)-1; (I) >= (X); (I)--)
#define ALL(X) (X).begin(), (X).end()
#define pb push_back
#define COUNT(V, X)                           \
    (upper_bound((V).begin(), (V).end(), X) - \
     lower_bound((V).begin(), (V).end(), X))
#define debug(x) cerr << #x << ':' << x << endl;
#define DEBUG(v)                             \
    {                                        \
        cerr << #v << ':';                   \
        for (auto xv : v) cerr << xv << ' '; \
        cerr << endl;                        \
    }
#define Yes(X) cout << (X ? "Yes" : "No") << endl;
#define YES(X) cout << (X ? "YES" : "NO") << endl;
#define ctoi(C) (C - '0')
#define pow2(x) ((long long)((long long)1 << x))

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int, int>;
using pl = pair<long long, long long>;
template <typename T>
using PQ = priority_queue<T>;
template <typename T>
using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1, 0, -1, 0};
const long long dy[] = {0, 1, 0, -1};
const long long dx8[] = {1, 1, 0, -1, -1, -1, 0, 1};
const long long dy8[] = {0, 1, 1, 1, 0, -1, -1, -1};
const long long dx9[] = {1, 1, 0, -1, -1, -1, 0, 1, 0};
const long long dy9[] = {0, 1, 1, 1, 0, -1, -1, -1, 0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T1, typename T2>
inline bool chmin(T1 &a, const T2 &b) {
    if (a > b) a = b;
    return a > b;
}
template <typename T1, typename T2>
inline bool chmax(T1 &a, const T2 &b) {
    if (a < b) a = b;
    return a < b;
}
long long max(long long x, int y) {
    return max(x, (long long)y);
}
long long max(int x, long long y) {
    return max((long long)x, y);
}
long long min(long long x, int y) {
    return min(x, (long long)y);
}
long long min(int x, long long y) {
    return min((long long)x, y);
}

/* liblary */

/* main */

signed main() {
    ll N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    A--;
    B--;
    C--;
    D--;
    string S;
    cin >> S;
    bool su[N] = {0}, fu[N] = {0};
    su[A] = true;
    fu[B] = true;
    su[A + 1] = S[A + 1] == '.';
    fu[B + 1] = S[B + 1] == '.';
    FOR(i, A + 2, N) {
        su[i] = su[i - 1] || su[i - 2];
        if (S[i] == '#') su[i] = false;
        if (C < i) su[i] = false;
    }
    FOR(i, B + 2, N) {
        fu[i] = fu[i - 1] || fu[i - 2];
        if (S[i] == '#') fu[i] = false;
        if (D < i) fu[i] = false;
    }
    if (C < D) {
        Yes(su[C] && fu[D]);
        return 0;
    }
    bool b = false;
    FOR(i, A, C - 1) {
        if (!(0 <= i && i + 2 < N)) continue;
        if (su[i] && fu[i + 1] && su[i + 2]) {
            b = true;
        }
    }
    Yes(su[C] && fu[D] && b);
}

Measured memory_bytes: 976
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7/*998244353*/;
const ll INF = 1LL << 60;
ll mod_pow(ll, ll, ll); ll mod_fact(ll, ll); ll mod_inv(ll, ll); ll gcd(ll, ll); ll lcm(ll, ll);
//
int main(){
    ll n;
    cin >> n;
    vector<ll> nums(n);
    for(int i = 0; i < n; i++) {cin >> nums[i]; if(nums[i] == 0) {cout << 0; return 0;}}

    ll border = pow(10, 18);
    ll a = 1;
    for(int i = 0; i < n; i++){
        double b = a;
        if(border / b < nums[i]) {cout << -1; return 0;}
        a *= nums[i];
        if(a > border) {cout << -1; return 0;}
    }
    cout << a;

}

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

int main() {
  string s;
  cin >> s;
  if(s == "SAT") cout << 1 << endl;
  else if(s == "FRI") cout << 2 << endl;
  else if(s == "THU") cout << 3 << endl;
  else if(s == "WED") cout << 4 << endl;
  else if(s == "TUE") cout << 5 << endl;
  else if(s == "MON") cout << 6 << endl;
  else if(s == "SUN") cout << 7 << endl;
}

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

ll A[101010];

int main(){
  int N; cin>>N;
  ll K; cin>>K;
  int u=0;
  while((1LL<<u)<=K) u++;
  u--;
  rep(i,N) cin>>A[i];
  int cnt[44]={};
  rep(i,N){
    rep(j,u+1) cnt[j]+=((1LL<<j)&A[i])==0;
  }
  rep(i,u+1) if(cnt[i]<=N/2) cnt[i]=0;
  ll X=0;
  while(X<K){
    int ma=0;
    rep(i,u+1){
      if(cnt[i]*(1LL<<i)>cnt[ma]*(1LL<<ma)){
        ma=i;
      }
    }
    if(X+(1LL<<ma)<=K){
      X+=1LL<<ma;
    }
    cnt[ma]=0;
    int flag=1;
    rep(i,u+1) if(cnt[i]!=0) flag=0;
    if(flag) break;
  }
  ll ans=0;
  rep(i,N) ans+=X^A[i];
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main() {
  int a, b;
  char op;
  while (1) {
    scanf("%d %c %d", &a, &op, &b);
    if (op == '?') { break; }
    switch (op) {
      case '+': printf("%d\n", a+b); break;
      case '-': printf("%d\n", a-b); break;
      case '*': printf("%d\n", a*b); break;
      case '/': printf("%d\n", a/b); break;
    }
  }
  return 0;
}



Measured memory_bytes: 2032
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

int main()
{
    long int a,b;
    cin >> a;
    cin >> b;
    
    long int tmp;
    long int x = a * b;
    
    if(a<b){
        tmp = a;
        a = b;
        b = tmp;
    }
    
    long int r;
    r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }

    cout << x/b << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

#define max(a,b) ( a > b ? a : b)

#define N 1001

int lcs(char *x,char *y);

int main() {
    int n, i;
    char x[N], y[N];

    scanf("%d", &n);
    for(i = 0; i < n; i++) {
        scanf("%s %s", x, y);
        printf("%d\n", lcs(x, y));
    }
    return 0;
}

int lcs(char *x,char *y) {
    int i, j;
    int lx = strlen(x);
    int ly = strlen(y);
    int LCS[N][N];

    for(i = 0; i <= lx; i++) {
        LCS[i][0] = 0;
    }
    for(j = 1; j <= ly; j++) {
        LCS[0][j] = 0;
    }
    for(i = 1; i <= lx; i++) {
        for(j = 1; j <= ly; j++) {
            if(x[i-1] == y[j-1]) {
                LCS[i][j] = LCS[i-1][j-1] + 1;
            }
            else {
                LCS[i][j] = max(LCS[i-1][j], LCS[i][j-1]);
            }
        }
    }
    return LCS[lx][ly];
}



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

using namespace std;

int main() {
    int five = 0;
    int seven = 0;
    for (int i = 0; i < 3; i++) {
        int temp;
        cin >> temp;
        if (temp == 5) {
            five++;
        } else if (temp == 7) {
            seven++;
        }
    }
    if (five == 2 && seven == 1) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}

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

using Segment = pair<int, int>;

template <typename T>
struct FenwickTree {
    int n;
    vector<T> dat;

    FenwickTree(vector<T>& d) {
        n = d.size();
        dat.resize(n + 1, 0);
        for (int i = 0; i < n; i++) dat[i + 1] = d[i];
    }

    FenwickTree(int size) {
        n = size;
        dat = vector<T>(n + 1, 0);
    }

    // 0-indexed
    T sum(int i) {
        if (i < 0) return 0;

        i++;
        T res = 0;
        while (i > 0) {
            res += dat[i];
            i -= i & -i;
        }
        return res;
    }

    // [i, j]
    T sum(int i, int j) {
        return sum(j) - sum(i - 1);
    }

    void add(int i, T x) {
        i++;
        while (i <= n) {
            dat[i] += x;
            i += i & -i;
        }
    }
};

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

    int N, M;
    cin >> N >> M;

    map<int, vector<Segment>> manager;

    for (int i = 0; i < N; i++) {
        int l, r;
        cin >> l >> r;
        manager[r - l + 1].emplace_back(l, r);
    }
    
    FenwickTree<int> ft(M + 2);
    int sum = N;
    for (int d = 1; d <= M; d++) {
        int ans = sum;
        for (int i = 1; i * d <= M; i++) {
            ans += ft.sum(0, i * d);
        }
        cout << ans << '\n';

        sum -= manager[d].size();
        for (Segment& s : manager[d]) {
            ft.add(s.first, 1);
            ft.add(s.second + 1, -1);
        }
    }

    return 0;
}

Measured memory_bytes: 13440
#include<iostream>
#include<stdio.h>
#include<string>
#include<string.h>
using namespace std;

int main(){
	int n;
	int taro = 0, hanako = 0;
	cin >> n;
	for (int i = 0; i < n; i++){
		string t, h;
		cin >> t >> h;
		if (t > h){
			taro += 3;
		}
		else if (t < h){
			hanako += 3;
		}
		else{
			taro+=1; 
			hanako+=1;
		}
	}
	cout << taro << " " << hanako << endl;
	return 0;
}


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

int main(){
	int a,b,k;
	cin >> a >> b >> k;
	if(b-a < k*2){
		for(int i=a; i<=b; i++){
			cout << i << endl;
		}
	}else{
		repeat(i, k){
			cout << a+i << endl;
		}
		repeat(i, k){
			cout << b-k+1+i << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int i,N,X,L[101];
	int D[101];
	int cnt=1;
	scanf("%d%d",&N,&X);
	for(i=1;i<=N;i++)
	{
		scanf("%d",&L[i]);
	}
	for(i=2;i<=N+1;i++)
	{
		D[1]=0;
		D[i]=L[i-1]+D[i-1];
		if(X>=D[i])
		{
			cnt++;
		}
		else
		break;
	}
	printf("%d",cnt);
	
	return 0;
}



Measured memory_bytes: 128