akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)



typedef long long ll;
#define MOD 1000000007
const int NUM_FAC = 2000001;
ll modfact(ll x) {
	static ll _fact[NUM_FAC + 1];
	if (_fact[0] == 0) {
		_fact[0] = 1;
		for (int i = 1; i <= NUM_FAC; ++i) _fact[i] = _fact[i - 1] * i%MOD;
	}
	return _fact[x];
}
//-----------------------------------------------------------------
int N, K;
int A[100];
ll dp[105][256][105];
//-----------------------------------------------------------------
int main() {
	cin >> N >> K;
	rep(i, 0, N) cin >> A[i];

	dp[0][0][0] = 1;
	rep(i, 0, N) rep(j, 0, 256) rep(k, 0, N) {
		dp[i + 1][j][k] = (dp[i + 1][j][k] + dp[i][j][k]) % MOD;
		dp[i + 1][j ^ A[i]][k + 1] = (dp[i + 1][j ^ A[i]][k + 1] + dp[i][j][k]) % MOD;
		//if (0 < dp[i][j]) printf("dp[%d][%d] = %lld\n", i, j, dp[i][j]);
	}

	ll ans = 0;
	rep(k, 0, N + 1) {
		ans = (ans + dp[N][K][k] * modfact(k)) % MOD;
	}
	cout << ans << endl;
}

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

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }


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

  ll N;
  queue<int> q;
  vector<ll> v;
  int cnt = 0;
  cin >> N;
  q.push(3);
  q.push(5);
  q.push(7);
  while(q.front() <= N) {
    int p = q.front();
    v.pb(p);
    q.pop();
    q.push(p*10+3);
    q.push(p*10+5);
    q.push(p*10+7);
  }
  rep(i, v.size()) {
    bool flag3 = false;
    bool flag5 = false;
    bool flag7 = false;
    while (v[i] != 0) {
      if (v[i] % 10 == 3)
        flag3 = true;
      else if (v[i] % 10 == 5)
        flag5 = true;
      else
        flag7 = true;
      v[i] /= 10;
    }
    if (flag3 && flag5 && flag7)
      cnt++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 1020
def main():
    from sys import stdin

    readline = stdin.readline

    N=int(readline().rstrip())
  
    count=0
    
    for i in range(N):
        x,y = list(map(int,readline().rstrip().split()))
        if ( x == y ):
            count += 1
            if ( count >= 3):
                break
        else:
            count = 0


    if ( count >= 3 ):
        print('Yes')
    else:
        print('No')

main()

Measured memory_bytes: 9188
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<cstring>
#include<cmath>
#include<cstdlib>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
typedef long long LL;
typedef pair<int,int> PII;
#define X first
#define Y second
inline int read()
{
	int x=0,f=1;char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=x*10+c-'0';c=getchar();}
	return x*f;
}
const int maxn=3010;
int n,m,dis[maxn][maxn],dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
bool vis[maxn][maxn];
PII s,t; 
char pic[maxn][maxn];
bool legal(int x,int y)
{
	return x>=0 && x<n && y>=0 && y<m && pic[x][y]=='.';
}
void bfs(int x,int y)
{
	dis[x][y]=0;
	vis[x][y]=1;
	queue <PII> Q;
	vector <PII> V;
	Q.push(make_pair(x,y));
	while(Q.size())
	{
		PII now=Q.front();Q.pop();
		int nx=now.X,ny=now.Y;
		int ok=0;
		for(int i=0;i<4;i++)
			if(legal(nx+dx[i],ny+dy[i]))
			{
				ok++;
				if(!vis[nx+dx[i]][ny+dy[i]])
					vis[nx+dx[i]][ny+dy[i]]=1,dis[nx+dx[i]][ny+dy[i]]=dis[nx][ny],Q.push(make_pair(nx+dx[i],ny+dy[i]));
			}
		if(ok<4)V.push_back(make_pair(nx,ny));
		if(Q.empty())
		{
			for(int k=0;k<V.size();k++)
			{
				int nx=V[k].X,ny=V[k].Y;
				for(int i=-2;i<=2;i++)
					for(int j=-2;j<=2;j++)
						if(legal(nx+i,ny+j))
						{
							if(dis[nx+i][ny+j]>dis[nx][ny]+1)
							{
								dis[nx+i][ny+j]=dis[nx][ny]+1;
								vis[nx+i][ny+j]=1;
								Q.push(make_pair(nx+i,ny+j));
							}
						}
			}
			V.clear();
		}
	}
	return;
}
int main()
{
	mem(dis,42);
	n=read();m=read();
	s.X=read()-1,s.Y=read()-1;
	t.X=read()-1,t.Y=read()-1;
	for(int i=0;i<n;i++)scanf("%s",pic[i]);
	bfs(s.X,s.Y);
//	for(int i=0;i<n;i++)
//	{
//		for(int j=0;j<n;j++)printf("%d ",dis[i][j]);
//		puts("");
//	}
	if(!vis[t.X][t.Y])puts("-1");
	else printf("%d\n",dis[t.X][t.Y]);
	return 0;
}
/*

*/


Measured memory_bytes: 44592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
bool cmp(pair<ll,ll> &a,pair<ll,ll> &b)
{
	if (a.second==b.second)
		return a.first>b.first;
	return a.second>b.second;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n,m;
	cin>>n>>m;
	ll a[n];
	for(ll i=0;i<n;i++)
		cin>>a[i];
	pair<ll,ll> p[m];
	for(ll i=0;i<m;i++)
		cin>>p[i].first>>p[i].second;
	sort(p,p+m,cmp);
	sort(a,a+n);
	ll j=0;
	for(ll i=0;i<n;i++)
	{
		ll b=p[j].first;
		ll c=p[j].second;
		//cout<<b<<" "<<c<<endl;
		if (a[i]<c)
		{
			a[i]=c;
			p[j].first--;
			if (p[j].first==0)
			{
				j++;
				if (j==m)
					break;
			}
		}
	}
	ll ans=0;
	for(ll i=0;i<n;i++)
		ans+=a[i];
	cout<<ans;
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{

	ll N;
	cin >> N;

	if (N%2==1) {
		ce(0)
	}
	else {
		ll ans = 0;
		ll tenth = 10;
		while (N/tenth>0) {
			ans += N / tenth;
			tenth *= 5;
		}
		ce(ans)
	}
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=998244353,MAX=1<<17;
const ll INF=1LL<<60;

int par[MAX],size[MAX];

void init(int n){
    for(int i=0;i<n;i++){
        par[i]=i;
        size[i]=1;
    }
}

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

void unite(int a,int b){
    if(root(a)!=root(b)){
        size[root(a)]+=size[root(b)];
        par[root(b)]=root(a);
    }
}

bool check(int a,int b){
    return root(a)==root(b);
}


int main(){
    
    int N;cin>>N;
    vector<int> A(N),B(N),copyA(N),copyB(N);
    for(int i=0;i<N;i++){
        cin>>A[i];
        copyA[i]=A[i];
    }
    for(int i=0;i<N;i++){
        cin>>B[i];
        copyB[i]=B[i];
    }
    
    sort(all(A));
    sort(all(B));
    
    bool ok=true;
    
    for(int i=0;i<N;i++){
        if(A[i]>B[i]) ok=false;
    }
    
    if(!ok){
        cout<<"No"<<endl;
        return 0;
    }
    
    bool ans=false;
    
    for(int i=0;i<N-1;i++){
        if(A[i]<=B[i+1]&&A[i+1]<=B[i]) ans=true;
    }
    
    if(ans){
        cout<<"Yes"<<endl;
        return 0;
    }
    
    init(N);
    
    map<int,int> whereA,whereB,pair;
    
    for(int i=0;i<N;i++){
        whereA[copyA[i]]=i+1;
        whereB[copyB[i]]=i+1;
        pair[A[i]]=B[i];
    }
    
    for(int i=0;i<N;i++){
        int a=whereA[A[i]],b=whereB[B[i]];
        unite(a-1,b-1);
    }
    
    if(size[root(0)]==N) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    
    
}





Measured memory_bytes: 16640
#include<stdio.h>

int main()
{
  int n[2];
  int ansPt;
  int ans;
  ansPt = 0;
  for(int i = 0;i < 2;i++){
    scanf("%d",&n[i]);
    if(n[i] >= 10){
      ansPt = 1;
    }
  }
  
  if(ansPt == 0){
    ans = n[0] * n[1];
    printf("%d\n",ans);
  }else{
    printf("%d\n",-1);
  }
  
  return 0;
}


Measured memory_bytes: 128
import math
import heapq
import bisect
import collections

S = input()
T = input()
lenS = len(S)
lenT = len(T)
F1 = [False]*26
F2 = [False]*26
alpha = 'abcdefghijklmnopqrstuvwxyz'
for i in range(lenS):
    F1[alpha.index(S[i])] = True
for i in range(lenT):
    F2[alpha.index(T[i])] = True
for i in range(26):
    if not F1[i] and F2[i]:
        print(-1)
        exit()

ind = S.index(T[0])
ans = ind+1
for i in range(1,lenT):
    S = S[ind+1:] + S[:ind+1]
    ind = S.index(T[i])
    ans += ind+1

print(ans)

Measured memory_bytes: 3976
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOREACH(x, a) for(auto x : a)

/* exchange */
#define CHMIN(a, b) (a) = min((ll)(a), (ll)(b))
#define CHMAX(a, b) (a) = max((ll)(a), (ll)(b))

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define LN() cerr << "\n"
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
ll t;
ll ret = 0;
string s;

void input() {
  IN(s);
}

void solve() {
  if (s == "Sunny") {
    PRINT("Cloudy");
  } else if (s == "Cloudy") {
    PRINT("Rainy");
  } else {
    PRINT("Sunny");
  }
}

int main(void){
  input();
  solve();
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from sys import stdin
# import numpy as np
# import sys
# sys.setrecursionlimit(10**4)

def _li(): return list(map(int, stdin.readline().split()))
def _li_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def _lf(): return list(map(float, stdin.readline().split()))
def _ls(): return stdin.readline().split()
def _i(): return int(stdin.readline())
def _f(): return float(stdin.readline())
def _s(): return stdin.readline()[:-1]


P, Q, R = _li()
print(min(P+Q, Q+R, R+P))


Measured memory_bytes: 3316
#include <iostream>
#include <vector>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    int mod = 1000000007;
    long long sum = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        sum += A[i];
        sum %= mod;
    }
 
    long ans = 0;
 
    //Search for all i
    for (int i = 0; i < N; i++)
    {
        //Update the values of A[i+1] ... A[N]
        sum -= A[i];
        if (sum < 0) sum += mod;
 
        ans += A[i] * sum;
        ans %= mod;
    }
 
    cout << ans << endl;
}

Measured memory_bytes: 4032
#include <bits/stdc++.h>  // clang-format off
using Int = long long;
#define REP_(i, a_, b_, a, b, ...) for (Int i = (a), lim##i = (b); i < lim##i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false), std::cout << std::fixed << std::setprecision(13); } } setup_io;
#ifndef dump
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sat May  2 21:48:12 JST 2020
 **/

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

signed main() {
    Int n, m, Q;
    std::cin >> n >> m >> Q;
    std::vector<Int> a(Q), b(Q), c(Q), d(Q);
    REP(i, Q) std::cin >> a[i] >> b[i] >> c[i] >> d[i], a[i]--, b[i]--;
    Int ans = 0;
    auto dfs = [&](auto f, std::vector<Int>& acc) -> void {
        if (acc.size() == n) {
            Int cnt = 0;
            REP(i, Q) {
                cnt += (acc[b[i]] - acc[a[i]] == c[i]) * d[i];
            }
            chmax(ans, cnt);
            return;
        }
        REP(x, (acc.size() ? acc.back() : 1), m + 1) {
            auto nxt = acc;
            nxt.push_back(x);
            f(f, nxt);
        }
    };
    std::vector<Int> init(0);
    dfs(dfs, init);
    std::cout << ans << std::endl;
}


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

int main() {
    int order[5];
    int sum = 0;
    for (int i = 0; i < 5; i++) {
        cin >> order[i];
        if (order[i] % 10 != 0) {
            sum += order[i] + (10 - order[i] % 10);
        } else {
            sum += order[i];
        }
    }
    int minv = 10;
    for (int i = 0; i < 5; i++) {
        int rest = order[i] % 10;
        if (rest != 0 && rest <= minv) {
            minv = rest;
        }
    }
    sum -= (10 - minv);
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <vector>
#include <numeric>
#include <math.h>
#include <set>

#define inf 1e15
#define sz 1e5
using ll = long long int;
using namespace std;

int main() {
string a;
cin>>a;
if (a[a.size()-1]!='s')a+='s';
else a+="es";
cout<<a<<endl;

    return 0;
}

Measured memory_bytes: 3600
#include <stdio.h>
int main(void)
{
	int n, e[1001], p[1001], q[1001], d[1001];
	int i, ii, m;

	for (;;)
	{
		m=0;
		

		scanf("%d", &n);
		if (n==0)
			{
				break ;
			}
		for (i=0;i<n;i++)
		{
			scanf("%d%d%d", &e[i], &p[i], &q[i]);
			d[i]=p[i]*q[i];
		}
		for (i=0;i<n;i++)
		{
			for (ii=i+1;ii<n;ii++)
			{
				if (e[i]==e[ii])
				{
					d[i]=d[i]+d[ii];
					d[ii]=0;
				}
			}
		}
		for (i=0;i<n;i++)
		{
			if (d[i]>=1000000)
			{
				printf("%d\n", e[i]);
				m++;
			}
		}
		if (m==0)
		{
			printf("NA\n");
		}
	}	
	return 0;
}

Measured memory_bytes: 628
#include<stdio.h>
#define N 100
#define O 0
#define I 1

int main(){
  int i,j,n,u,v,k,V[N][N];
  scanf("%d",&n);
  for(i=O;i<n;i++){
    for(j=0;j<n;j++){
      V[i][j]=O;
    }
  }
  for(i=O;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=O;j<k;j++){
      scanf("%d",&v);
      V[u-I][v-I]=I;
    }
  }
  for(i=O;i<n;i++){
    for(j=O;j<n;j++){
      if(j){
	printf(" ");
      }
      printf("%d",V[i][j]);
    }
    printf("\n");
  }
  return O;
}



Measured memory_bytes: 2040
def solve(str):
  alphabet_count = [0]*26
  for s in str:
    idx = ord(s) - ord('a')
    alphabet_count[idx] += 1
  for i in alphabet_count:
    if i % 2 != 0:
      return False
  return True

if __name__ == "__main__":
  w = input()
  if solve(w):
    print('Yes')
  else:
    print('No')


Measured memory_bytes: 2940
S = input().split(" ")
N = int(S[0])
K = int(S[1])
S = list(input())

num = 0
for index in range(len(S)-1):
    if S[index] == 'L' and S[index+1] == 'L':
        num = num + 1
    if S[index] == 'R' and S[index+1] == 'R':
        num = num + 1

result = min(num + 2*K,N-1)

print(result)


Measured memory_bytes: 4084
n = int(input())
mb = str(input())

cnt = 0
g = 0

for c in mb:
  if c == "O":
    if g == -1:
      cnt = cnt + 1
      g = 0
    else:
      g = 1
  else:
    if g == 1:
      cnt = cnt + 1
      g = 0
    else:
      g = -1

print(cnt)


Measured memory_bytes: 5784
using System;
using System.Linq;

namespace ConsoleApp2
{
    class Program
    {
        static void ReadInt2(out int first, out int second)
        {
            var array = Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
            first = array[0];
            second = array[1];
        }

        static void Main(string[] args)
        {
            int n, m;
            ReadInt2(out n, out m);

            int[] liked = new int[m];
            for (int _ = 0; _ < n; _++)
            {
                var array = Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
                foreach (var item in array.Skip(1))
                {
                    liked[item - 1]++;
                }
            }

            Console.WriteLine(liked.Count(x => x == n));
        }
    }
}

Measured memory_bytes: 13396
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 Debug = System.Diagnostics.Debug;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
using LayoutKind = System.Runtime.InteropServices.LayoutKind;
using StructLayoutAttribute = System.Runtime.InteropServices.StructLayoutAttribute;
using FieldOffsetAttribute = System.Runtime.InteropServices.FieldOffsetAttribute;

static class P
{
    static void Main()
    {
        var nm = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var a = Console.ReadLine().Split().Select(long.Parse).OrderBy(x => x).ToArray();
        var queries = Enumerable.Repeat(0, nm[1]).Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).OrderByDescending(x => x[1]).ToArray();

        var aptr = 0;
        foreach (var query in queries)
        {
            var count = query[0];
            var num = query[1];
            for (int i = 0; i < count && aptr < a.Length && a[aptr] < num; i++, aptr++) a[aptr] = num;
        }
        Console.WriteLine(a.Sum());
    }
}


Measured memory_bytes: 33212
#include <iostream>
using namespace std;
//↑デフォルト文

int main(){
  int a, b;
  cin >> a >> b;



  if(a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0){
    cout << "Possible" << endl;
  } else {
    cout << "Impossible" << endl;
  }
}


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

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

int N;
int A[100100];
bool used[100100];

signed main() {
    cin >> N;
    int s = 0;
    rep(i, N) {
        cin >> A[i];
        s ^= A[i];
    }
    if (s == 0)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
    sort(A, A + N);
    int first = A[0];
    for (int i = 1; i < N; ++i) {
        if (i == 2)break;
        int second = A[i];
        rep(j, N) {
            int idx = l_b(A, A + N, first ^ second) - A;
            while (1) {
                if (A[idx] != (first ^ second)) {
                    goto ng;
                }
                if (used[idx])idx++;
                else {
                    used[idx] = true;
                    break;
                }
            }
            int third = first ^second;
            first = second;
            second = third;
        }
        cout << "Yes" << endl;
        return 0;
        ng:;
        memset(used, 0, sizeof(used));
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main()
{
    int N,Q;
    long long int K;
    cin>>N>>K>>Q;
    int n[100005];
    for(int i=0;i<N;i++)
    {
        n[i]=K;
    }
    for(int i=0;i<N;i++)
    {
        n[i]=n[i]-Q;
    }
    for(int i=0;i<Q;i++)
    {
        int t;
        cin>>t;
        n[t-1]++;
    }
    for(int i=0;i<N;i++)
    {
        if(n[i]<=0) cout<<"No"<<endl;
        else cout<<"Yes"<<endl;
    }
}


Measured memory_bytes: 1024
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 10000000000000000LL;
constexpr int inf = 1000000000;

int main() {
    ll a, b;
    cin >> a >> b;

    ll l = b - a + 1;

    if (l % 2 == 0) {
        if (a % 2 == 0)
            cout << (l / 2 & 1) << endl;
        else
            cout << ((a ^ b) ^ ((l - 2) / 2 & 1)) << endl;
    } else {
        if (a % 2 == 0)
            cout << (b ^ ((l - 1) / 2 & 1)) << endl;
        else
            cout << (a ^ ((l - 1) / 2 & 1)) << endl;
    }
    return 0;
}

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

#define debug(x) cout <<"DEBUG"<<" "<<#x<<":"<<x<<'\n'

//↓0-originか1-originでn回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-origin昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-origin昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-origin降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-origin降順
//rep2 -> 第二引数 m から n 回繰り返し ex) m=5 n=3 なら i=5,i=6,i=7 まで
#define rep2(i,m,n) for(int i = ((int)(m)); i < ((int)(n))+((int)(m)); i++)
#define SIZE(x) ((int)((x).size()))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;
template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}


/*FUNCs=================================================*/


/*MAIN==================================================*/
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    
    int n, m;
     cin >> n >> m;
     cout << (n<=9&&m<=9 ? n*m : -1) << '\n';
}

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

int main(){
  int n;
  cin >> n;
  vector<int> X(n);
  rep(i,n)cin >> X[i];
  int MIN = INF;
  for(int j = 1; j<101;j++){
    int cnt = 0;
    rep(i,n){
      cnt += pow(X[i]-j,2);
    }
    MIN = min(MIN,cnt);
  }
  cout << MIN << endl;
}


Measured memory_bytes: 3596
#include <iostream>
using namespace std;
typedef long long ll;

double sunuke(ll n){
    double ds = 0.0;
    ll nn = n;
    while(nn > 0){
        ds += nn % 10;
        nn /= 10;
    }
    return n * 1.0 / ds;
}

int main()
{
    int k;
    cin >> k;
    ll pl = 1;
    ll now = 1;
    for(int i = 0; i < k; i++){
        if(sunuke(now) > sunuke(now + pl)){
            now -= pl;
            pl *= 10;
            now += pl;
        }
        cout << now << endl;
        now += pl;
    }
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

n = int(input())
T = [[] for _ in range(n+1)]
for _ in range(n-1):
  a, b = map(int, input().split())
  T[a].append(b)
  T[b].append(a)
def dfs(v):
  dist = [-1]*(n+1)
  dist[v] = 0
  stack = [v]
  depth = 0
  while stack:
    nv = stack.pop()
    for i in T[nv]:
      if dist[i] != -1:
        continue
      dist[i] = dist[nv] + 1
      stack.append(i)
  return dist

D = dfs(1)
m = D.index(max(D))
dia = max(dfs(m))
if dia%3 == 1:
  print("Second")
else:
  print("First")

Measured memory_bytes: 95232
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define answer cout << ans << endl;
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}

signed _main() {
  int n; cin >> n;
  int N=n;
  v<int> ans;
  while(n>1){
    if(isPrime(n)){
      ans.push_back(n);
      break;
    }
    for(int i=2;i*i<=N;i++){
      if(n%i==0){
        ans.push_back(i);
        n/=i;
        break;
      }
    }
  }
  sort(ans.begin(),ans.end());
  cout << N << ": ";
  rep(i,ans.size()-1) cout << ans[i] << " ";
  cout << ans[ans.size()-1] << endl;
}



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

int main(){
  
  string S;
  cin >> S;
  
  if ((S == "AAA") || (S == "BBB")){
    
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a,b,d,r;
  double f;

  scanf("%d %d",&a,&b);
  d=a/b;
  r=a%b;
  f=(double)a/(double)b;

  printf("%d %d %f",d,r,f);

  return 0;

}


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

int main(){
    ll N;  cin >> N;
    ll left = 0, right = N+1;
    ll m = left + (right-left)/2;
    while(right-left>1){
        ll sum = m*(m+1)/2;
        if(sum>=N) right = m;
        else left = m;
        m = left + (right-left)/2;
    }
    
    int M = right;
    while(N>0){
        if(N>=M){
            cout << M << endl;
            N-=M;
        }
        M--;
    }
}



Measured memory_bytes: 256
/*キュー*/
#include <stdio.h>
#define N 1000000

typedef struct{
  char name[10];
  int time, n, q;
} process;

int main(){
  process a[N], temp;
  int n, q, i, j;
  int alltime=0;
  
  scanf("%d %d", &n, &q);
  
  for (i=0; i<n; i++){
    scanf("%s %d", a[i].name, &a[i].time);
  }
  
  /*
    printf("\n");
    for (i=0; i<n; i++){
    printf("%s %d \n", a[i].name, a[i].time);
    }
    確認用*/

  i=0;
  while(1){
    
    if (n==1){
      alltime += a[i].time;
      printf("%s %d\n", a[i].name, alltime);
      break;
    }

    /*１つのプロセスが終わらない場合*/
    else if(a[i].time > q){
      a[i].time -= q;
      alltime += q;
      
      a[n+i] = a[i];
    }
    
    /*１つのプロセスが終わる場合*/
    else{
      alltime += a[i].time;
      a[i].time = 0;
      printf("%s %d\n", a[i].name, alltime);
      
      n--;
    }
    
    i++;

    if (i == N){
      i=0;
    }
    
  }
  
  return 0;
}



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

typedef long long ll;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    string a,b;
    cin>>a>>b;
    string con=a+b;
    stringstream num(con);
    int n=0;
    num>>n;
    int sq=sqrt(n);
    if((sq*sq)==n)
    {
       cout<<"Yes"<<endl; 
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<stack>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

int dist[101][101];
map<vector<int>,int> mp;

int main()
{
	int n,m;cin >> n >> m;
	
	queue<pair<vector<int>,vector<int> > > q;
	
	int ans = 0;
	
	REP(i,m)
	{
		int a,b,c;cin >> a >> b >> c;
		dist[a][b] = dist[b][a] = c;
		if(a > b)swap(a,b);
		vector<int> A = {a,b};
		vector<int> B = {c,c};
		q.push(MP(A,B));
		mp[A] = 2*c;
		ans = max(ans,2*c);
	}
	
	while(!q.empty())
	{
		pair<vector<int>,vector<int> > now = q.front();q.pop();
		vector<int> list = now.FI;
		vector<int> score = now.SE;
		for(int i = list[list.size()-1]+1;i <= n;i++)
		{
			vector<int> tmp = list;
			tmp.PB(i);
			if(mp.find(tmp) != mp.end())continue;
			vector<int> tmpscore;
			int nowscore = 0;
			int sa = 0;
			int plus = 100000000;
			
			REP(j,list.size())
			{
				int AA =  min(score[j],dist[list[j]][i]);
				nowscore += AA;
				tmpscore.PB(AA);
				sa += score[j];
				plus = min(plus,dist[list[j]][i]);
			}
			
			nowscore += plus;
			tmpscore.PB(plus);

			//cout << ' ' << nowscore << endl;
			//SHOW1d(tmp,tmp.size());
			//SHOW1d(tmpscore,tmp.size());
						
			if(plus != 0)
			{
				mp[tmp] = nowscore;
				ans = max(ans,nowscore);
				q.push(MP(tmp,tmpscore));
			}
		}
	}
	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 5480
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const int inf = 1 << 20;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using namespace std;

int a[100005];
int b[100005];

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    for(int i = 0; i < 100005; i++){
        if(i%2!=0){
            if(IsPrime(i) && IsPrime((i+1)/2)){
                a[i] = 1;
            }
        }
    }
    for(int i = 1; i < 100005; i++){
        b[i] = b[i-1] + a[i];
    }
    int q;
    cin >> q;
    for(int i = 0; i < q; i++){
        int l,r;
        cin >> l >> r;
        cout << b[r] - b[l-1] << endl;
    }
}

Measured memory_bytes: 1408
#include "bits/stdc++.h"

using namespace std;

void solve(void)
{
	int a, b;
	cin >> a >> b;
	cout << max({a + b, a - b, a * b}) << endl;
}

int main()
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<set>
#include<queue>
#include<string>
#include<sstream>
#include<iostream>
#include<sstream>
#include<stack>
#include<map>
#include<vector>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<math.h>
#include <cassert>
using namespace std;
typedef long long ll;
#define mod 9999973
#define MAXN 3100
int n,  A, b, c, d;
char a[210000];
int main()
{
	scanf("%d %d %d %d %d", &n, &A, &b, &c, &d);
	scanf("%s", a+1);
	if (d > c)
	{
		int flag = 0;
		for (int i = b; i <= d; i++)
		{
			if (a[i] == '#')
			{
				if (flag == 1) { printf("No"); return 0; }
				flag = 1;
			}
			else flag = 0;
		}
		flag = 0;
		for (int i = A; i <= c; i++)
		{
			if (a[i] == '#')
			{
				if (flag == 1) { printf("No"); return 0; }
				flag = 1;
			}
			else flag = 0;
		}
	}
	if (c > d)
	{
		int flag = 0;
		int wz = b;
		for (int i = b; i <= d+1; i++)
		{
			if (a[i] == '.')flag++;
			else flag = 0;
			if (flag == 3)
			{
				wz = i - 1;
				break;
			}
			
		}
		a[wz] = '#';
		flag = 0;
		for (int i = A; i <= c; i++)
		{
			if (a[i] == '#')
			{
				if (flag == 1) { printf("No"); return 0; }
				flag = 1;
			}
			else flag = 0;
		}
	}
	printf("Yes");
	return 0;
}

Measured memory_bytes: 384
n, w = map(int, input().split())
item = [list(map(int, input().split())) for i in range(n)]

dp = [[0 for i in range(w + 1)] for j in range(n + 1)]

for i in range(n):
    for sum_w in range(w + 1):
        if sum_w - item[i][0] >= 0:
            dp[i + 1][sum_w] = max(dp[i + 1][sum_w], dp[i][sum_w - item[i][0]] + item[i][1])
        dp[i + 1][sum_w] = max((dp[i + 1][sum_w], dp[i][sum_w]))
print(dp[n][w])

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

import sys
from collections import Counter

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

S = input()
N = len(S)
mod = 2019

acc = [0] * (N+1)
mul = 1
for i in range(N-1, -1, -1):
    x = int(S[i]) * mul
    acc[i] = (acc[i+1] + x) % mod
    mul *= 10
    mul %= mod

C = Counter(acc)
ans = 0
for v in C.values():
    ans += v*(v-1) // 2
print(ans)


Measured memory_bytes: 16656
#include <bits/stdc++.h>
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main()
{
    string N,n,m,l;
    cin >> N;
    n = N.substr(0, 1);
    m = N.substr(1, 1);
    l = N.substr(2, 1);
    if(n=="7"){
        cout << "Yes";
    }else if(m=="7"){
        cout << "Yes";
    }else if(l=="7"){
        cout << "Yes";
    }else{
        cout << "No";
    }
}

Measured memory_bytes: 3632
#include<cstdio>
#include<queue>
#include<iostream>
#include<algorithm>
#include<list>
using namespace std;
list<int>li[1000];
list<int>::iterator it;
int main() {
	int r,t;
	scanf("%d%d", &r, &t);
	while (t--) {
		int a, b, c;
		scanf("%d", &a);
		switch (a) {
		case 0:
			scanf("%d%d", &b, &c);
			//li[b].insert(li[b].end(), c);
			li[b].push_back(c);
			break;
		case 1:
			scanf("%d", &b);
			for (list<int>::iterator i = li[b].begin(); i != li[b].end(); i++){
				if (i != li[b].begin())cout << ' ';
				cout << *i;
			}
			cout << endl;
			break;
		case 2:
			scanf("%d%d", &b, &c);
			li[c].splice(li[c].end(), li[b]);
			li[b].clear();
			break;
		}
	}
}




Measured memory_bytes: 18776
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		long n = Long.parseLong(sc.next());

		int f = 100;
		for (int i = 1; i <= Math.sqrt(n); i++) {

			if (n % i == 0) {
				int tmpA = i;
				int fa = 0;
				while (tmpA != 0) {
					tmpA /= 10;
					fa++;
				}
				int tmpB = (int) (n / i);
				int fb = 0;
				while (tmpB != 0) {
					tmpB /= 10;
					fb++;
				}

				f = Math.min(f, Math.max(fa, fb));
			}
		}

		System.out.println(f);
		sc.close();
	}
}

Measured memory_bytes: 21972
import sys
input()
a = list(map(int, input().split()))
ans = 1
flag = False
for i in a:
    if i==0:
        print(0)
        sys.exit()
for i in a:
    ans *= i
    if ans>1000000000000000001:
        print(-1)
        sys.exit()
if ans<1000000000000000001:
    print(ans)
else:
    print(-1)


Measured memory_bytes: 21472
import itertools
import math
n = int(input())
x = [0]*n
y = [0]*n
distance = [0]*math.factorial(n)
j = 0
for i in range(n):
    x[i],y[i] = map(int,input().split())

n_list = list(itertools.permutations(list(range(n))))

for l in n_list:

    for j in range(n-1):
        distance[j] = distance[j] + math.sqrt((x[l[j]]-x[l[j+1]])**2 + (y[l[j]]-y[l[j+1]])**2)

    j += 1
print(sum(distance)/math.factorial(n))

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

if N == 1:
    print(1)
else:
    pq_conbination = {}
    for a in coodinates:
        for b in coodinates:
            if a == b:
                continue
            else:
                p, q = a[0]-b[0], a[1]-b[1]
                if (p, q) in pq_conbination:
                    pq_conbination[(p, q)] += 1
                else:
                    pq_conbination[(p, q)] = 1

    pq_conbination = sorted(pq_conbination.items(), key=lambda x: x[1], reverse=True)

    print(N - pq_conbination[0][1])


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

// TYPEDEF
// ----------------------------------------
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> Pair;
typedef vector<ll> vll;
typedef vector<vector<ll>> Graph;
typedef vector<string> vs;
typedef vector<pair<ll, ll>> Pll;
typedef queue<ll> qll;

// REPEAT
// ----------------------------------------
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REPA(i,a) for(ll i=0;i<(ll)(a.size());i++);
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define COUT(a) cout << (a) << endl;
#define ENDL(a) cout << endl;
#define COUTA(i,a) for(ll i=0;i<(ll)(a.size());i++) {cout << (a)[i] << " ";} cout << endl;

// UTIL
// ----------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())

// DEBUG
// ----------------------------------------
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

// BIT FLAG
// ----------------------------------------
const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000
const unsigned int BIT_FLAG_8 = (1 << 8); // 0000 0001 0000 0000
const unsigned int BIT_FLAG_9 = (1 << 9); // 0000 0010 0000 0000
const unsigned int BIT_FLAG_10 = (1 << 10); // 0000 0100 0000 0000
const unsigned int BIT_FLAG_11 = (1 << 11); // 0000 1000 0000 0000

// CONST
// ----------------------------------------
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI=3.14159265358979323846; // or M_PI
constexpr int MOD = 1000000007;


void Main() {
  ll n;
  cin >> n;

  vll count(100000, 0);
  ll total=0;

  REP(i, n) {
    ll a_in;
    cin >> a_in;
    count[a_in]++;
    total += a_in;
  }

  //COUT(total);

  ll q;
  cin >> q;
  REP(i, q) {
    ll b, c;
    cin >> b >> c;
    ll before_count = count[b];
    // COUT(before_count);
    count[b] = 0;
    count[c] += before_count;
    total = total + before_count * (c - b);
    COUT(total);
  }

}

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

/*
4
1 1 1 1
3
1 2
2 1
3 5
*/


Measured memory_bytes: 3968
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define INF (2 << 28)
#define fr first
#define sc second
using namespace std;

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

int main(){

  int n;
  iP bug[311111]; //first: release, second: capacity
  priority_queue<iP, vector<iP>, greater<iP> > que; 

  cin >> n;
  for(int i = 0; i < n; i++) cin >> bug[i].fr >> bug[i].sc;
  
  sort(bug, bug + n);
  int maxi = 0, cap = INF;
  ll sum = 0;
  for(int i = 0; i < n; i++){
    cap = min(bug[i].sc, cap);
    sum += bug[i].fr;
    que.push(iP(bug[i].sc, bug[i].fr));
    while(sum > (ll)cap * (int)que.size() && !que.empty()){
      iP p = que.top(); que.pop();
      sum -= p.sc;
      cap = (que.empty() ? INF : que.top().fr);
    }
    maxi = max(maxi, (int)que.size());
  }
  cout << maxi << endl;
}

Measured memory_bytes: 9136
// #pragma GCC optimize("no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma vector temporal
// #pragma simd
// #pragma GCC diagnostic ignored "-W"

#include<cassert>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<sstream>
#include<deque>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<vector>
#include<utility>
#include<functional>
#include<complex>
#include<climits>

// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>

using namespace std;
// using namespace __gnu_pbds;

#define ll long long
#define ld long double
#define X first
#define Y second
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define vint vector<int>
#define SS stringstream
#define PQ priority_queue
#define MS(x,v) memset((x),(v),sizeof(x))
#define RZUNI(x) sort(x.begin(),x.end()), x.resize(unique(x.begin(),x.end())-x.begin())
#define FLH fflush(stdout)
#define CPPinput ios_base::sync_with_stdio(0); cin.tie(0)
#define FIN(fname) freopen(fname,"r",stdin)
#define FOUT(fname) freopen(fname,"w",stdout)

#define tm Ovuvuevuevue
#define y1 Enyetuenwuevue
#define left Ugbemugbem
#define ws Osas
#define dec tetteterette
#define exp expexpexpexp
#define expl explexplexpl

#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl

#ifdef WEAK
#include"/home/edison/Coding/cpp/template/debug.cpp"
#define DEB(...) printf(__VA_ARGS__),fflush(stdout)
#define WHR() printf("%s: Line %d",__PRETTY_FUNCTION__,__LINE__),fflush(stdout)
#define LOG(...) printf("%s: Line %d ",__PRETTY_FUNCTION__,__LINE__),printf(__VA_ARGS__),fflush(stdout)
#define DEBUG 1
#define exit(x) cout<<"exit code "<<x<<endl, exit(0)
#else
#define PDE(...) ;
#define DEB(...) ;
#define WHR() ;
#define LOG(...) ;
#define DEBUG 0
#endif

#define lowbit(x) ((x)&(-(x)))

#if __cplusplus >= 201103L
#include<unordered_map>
#include<unordered_set>
#include<tuple>
#endif

void JIZZ(string output=""){cout<<output; exit(0);}

const ld PI=3.14159265358979323846264338327950288;
const ld eps=1e-13;
const ll mod=1e9+7;

int main(){
    CPPinput;
    string s; cin>>s;
    int w; cin>>w;
    cout<<s[0];
    int now=w;
    while(now<s.size()){
        cout<<s[now];
        now+=w;
    }
    cout<<endl;
}


Measured memory_bytes: 256
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;

public class Main {

	Scanner sc = new Scanner(in);
	
	class Node {
		int pos, time, num, dis;
		Node(int p, int t, int n, int d) {
			pos = p;
			time = t;
			num = n;
			dis = d;
		}
		
		@Override
		public int hashCode() {
			return num+10*pos+1000*dis+time;
		}
		
		@Override
		public boolean equals(Object o) {
			Node n = (Node)o;
			return pos == n.pos && time == n.time && num == n.num && dis == n.dis;
		}
	}
	
	void run() {
		int[] p = new int[40];
		int[] t = new int[40];
		int[][] memo = new int[40][2];
		int INF = Integer.MAX_VALUE/2;
		Queue<Node> que = new LinkedList<Node>();
		W:while (true) {
			int n = sc.nextInt();
			if (n == 0) break;
			for (int i = 0; i < n; i++) {
				p[i] = sc.nextInt();
				t[i] = sc.nextInt();
				memo[i][0] = memo[i][1] = INF;
			}
			
			que.clear();
			que.add(new Node(0, 0, 0, 0));
			
			for (int i = 0; i < n; i++) {
				int z = que.size();
				if (z == 0) {
					out.printf("NG %d\n", i);
					continue W;
				}
				for (int j = 0; j < z; j++) {
					Node node = que.poll();
					if ((1+node.num)*abs(node.pos-p[i])<=t[i]-node.time) {
						if (node.num < 2 && memo[i][node.num] > node.dis+abs(node.pos-p[i])) {
							que.add(new Node(p[i], t[i], node.num+1, node.dis+abs(node.pos-p[i])));
							memo[i][node.num] = node.dis+abs(node.pos-p[i]);
						}
						que.add(new Node(0, t[i]+(2+node.num)*p[i], 0, node.dis+abs(node.pos-p[i])+p[i]));
					}
				}
			}
			
			if (que.size() == 0) {
				out.printf("NG %d\n", n);
				continue W;
			}
			
			int res = INF;
			for (Node node : que) {
				if (node.pos == 0) {
					res = min(res, node.dis);
				}
			}
			
			out.printf("OK %d\n", res);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}

}

Measured memory_bytes: 24248
#include<iostream>
#include<iomanip>
#include<string>
#include<set>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<functional>
using namespace std;
#define LL long long
#define MOD 100000
#define inf 1999999999

//みんなQ-正解問題数点引かれる
//ok <-   K - (Q - correct) > 0
//     =>   correct > Q - K

int main() {
	int N, K, Q, pt[100001] = {};
	cin >> N >> K >> Q;
	for (int i = 0; i < Q; i++) {
		int a;
		cin >> a;
		a--;
		pt[a]++;
	}
	for (int i = 0; i < N; i++) {
		if (pt[i] > Q - K)cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;
}


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

using namespace std;

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

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

    long long ans = 0;
    vector<int> count(1e5+1);
    for (int i = 0; i < N; ++i) {
        ans += A[i];
        count[A[i]]++;
    }

    int Q;
    cin >> Q;
    for (int i = 0; i < Q; ++i) {
        int B, C;
        cin >> B >> C;
        ans -= (long long) B * count[B];
        ans += (long long) C * count[B];
        count[C] += count[B];
        count[B] = 0;
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 3984
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] num = new int[n];
        int flag = 0;
        for (int i = 0; i < m; i++) {
            int s = sc.nextInt();
            int c = sc.nextInt();
            if(s == 1 && c ==0 && n != 1 || num[s - 1] != 0 && num[s - 1] != c){
                flag = 1;
            }else{
                num[s - 1] = c;
            }
        }
        if(flag == 1){
            System.out.println("-1");
        }else{
            if(num[0] == 0 && n != 1){
                num[0] = 1;
            }
            for (int i = 0; i < n; i++) {
                System.out.print(num[i]);
            }
        }
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
 
#define f(i,a,b) for( ll i = a; i < b ; i++ )
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ones(x) (ll) __builtin_popcount(x)
#define fs first
#define sc second
#define pb push_back
#define po pop_back
#define mp make_pair 
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ller ios::sync_with_stdio(false);cin.tsie(nullptr);cout.tie(nullptr)
#define watch(x) cout << (#x) << " is " << (x) <<"\n"
#define PI 3.1415926535
using namespace std;
typedef long long ll;
typedef long double ld; 
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;
const ll mod = 1e9;
const ll MAX = 1e5+10;
const ll inf = 1e18+7;

int main(){
	fastio;
	ll n,a,b,cont=0;
	cin>>n;
	bool go = false;
	f(i,0,n){
		cin>>a>>b;
		if(a==b) cont++;
		else cont = 0;
		if(cont==3) go = true;
	}
	if(go) cout<<"Yes\n";
	else cout<<"No\n";
    return 0; 
}

Measured memory_bytes: 3604