akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <iterator>
#include <ext/pb_ds/assoc_container.hpp>

#define x first
#define y second
#define mp make_pair
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)x.size()
#define bit __builtin_popcount
#define all(x) x.begin(),x.end()

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

const ll INF=1e18+123;
const ld EPS=1e-9;
const int inf=1e9+123;
const int MOD=1e9+7;
const int N=1e5+123;
const int dx[]={0,0,1,-1};
const int dy[]={1,-1,0,0};

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n,k;
    cin>>n>>k;
    cout<<bool(n%k);
    return 0;
}


Measured memory_bytes: 256
x,y = map(int, input().split())

risuto1 = [1,3,5,7,8,10,12]
risuto2 = [4,6,9,11]
risuto3 = [2]

if x in risuto1 and y in risuto1:
    print("Yes")
elif x in risuto2 and y in risuto2:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <stdio.h>
 
int main(){
   long s;
   int n;
    
   scanf("%ld",&s);
   for (n=1;s!=1 && s!=2 && s!=4;n++)
     if (s%2==0) s=s/2;
     else        s=3*s+1;
   printf("%d\n",n+3);
   return 0;
}


Measured memory_bytes: 128
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

N = get_int
A = get_ints

minus_count = A.count { |a| a < 0 }

min = A.map(&:abs).min
sum = A.sum { |x| x.abs }

if minus_count % 2 == 0
  puts sum
else
  puts sum - min * 2
end


Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=1000000007,MAX=300005;
const ll INF=1LL<<60;
int N,M;
int dis[MAX],P[MAX],ok[MAX];

vector<int> dh={0,1,0,-1},dw={1,0,-1,0};

void update(int x){
    queue<int> Q;
    Q.push(x);
    while(!Q.empty()){
        int u=Q.front();Q.pop();
        for(int k=0;k<4;k++){
            int fromh=u/N+dh[k],fromw=u%N+dw[k];
            if(fromh<0||fromh>=N||fromw<0||fromw>=N) continue;
            
            if(ok[u]){
                if(dis[fromh*N+fromw]>dis[u]){
                    dis[fromh*N+fromw]=dis[u];
                    Q.push(fromh*N+fromw);
                }
            }else{
                if(dis[fromh*N+fromw]>dis[u]+1){
                    dis[fromh*N+fromw]=dis[u]+1;
                    Q.push(fromh*N+fromw);
                }
            }
        }
    }
}

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>N;
    M=N*N;
    for(int i=0;i<M;i++){
        cin>>P[i];
        P[i]--;
    }
    
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            int now=i*N+j;
            dis[now]=min({i,j,N-1-i,N-1-j});
        }
    }
    
    ll ans=0;
    
    for(int i=0;i<M;i++){
        ans+=dis[P[i]];
        ok[P[i]]=1;
        update(P[i]);
    }
    
    cout<<ans<<endl;
}


Measured memory_bytes: 6560
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class EThisMessageWillSelfDestructIn5s {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        int N;
        cin >> N;
        vector<int> A(N);
        REP(i, N) cin >> A[i];

        map<int, int> cnt;
        int res = 0;
        REP(i, N) {
            int val = i - A[i];
            res += cnt[val];
            cnt[i + A[i]]++;
        }
        cout << res << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    EThisMessageWillSelfDestructIn5s solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 27388
i,j,x,y,n,s;
main(t){
  char a[99] ,b[99],c[99];
 scanf("%d",&n);
 while(n>0)
   {
     i=j=x=y=s=t=0;
     scanf("%s%s",a,b);
     while(a[++x]!='\0');
     while(b[++y]!='\0');
     x--;y--;t=0;
     //     printf("a[%d]= %c\n",x,a[x]);
     // printf("b[%d]= %c\n",y,b[y]);
     while(x>=0 || y>=0 || t!=0)
       {
	 if(x<0)
	   i=0;
	 else
	   i=(int)a[x]-'0';
	 if(y<0)
	   j=0;
	 else
	   j=(int)b[y]-'0';
	 t=i+j+t;
	 if(t>9)
	   {
	     c[s]=t%10+'0';
	     t=t/10;
	   }
	 else
	   {
	     c[s]=t+'0';
	     t=0;
	   }
	 if(x>=0)
	   x--;
	 if(y>=0)
	   y--;
	 s++;
	 if(s>80)
	   break;
	 //     printf("%d\n",t);
	 
       }
     //   printf("%s\n",b);
 if(s>80)     
   puts("overflow");
 else
   {
     while(s-->0)
       printf("%c",c[s]);
     puts("");
   }
 n--;
   }

 exit(0);
}

Measured memory_bytes: 0
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def SI(): return input().split()

def printlist(lst, k='\n'): print(k.join(list(map(str, lst))))
INF = float('inf')

from math import ceil, floor, log2
from collections import deque
from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product
from heapq import heapify, heappop, heappush
from decimal import Decimal

def solve():
    a, b = input().split()
    a = int(a)
    b = int(b.replace('.', ''))

    print(int(a * b // 100))


if __name__ == '__main__':
    solve()


Measured memory_bytes: 9840
n = int(input())
a = list(map(int, input().split()))
nums = []
nums.append(a[0])
for i in range(1, n):
    if a[i] != a[i-1]:
        nums.append(a[i])
    else:
        continue
val = nums[0]
maxs = []
for j in range(1, len(nums)):
    if nums[j] > val:
        maxs.append(j)
    else:
        pass
    val = nums[j]
pos = 0
money = 1000
for idx in maxs:
    minVal = min(nums[pos:idx])
    stocks = money // minVal
    money = money - minVal * stocks + nums[idx] * stocks
    pos = idx
print(money)


Measured memory_bytes: 9176
#define DEBUG 0

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

#if DEBUG
// basic debugging macros
int __i__,__j__;
#define printLine(l) for(__i__=0;__i__<l;__i__++){cout<<"-";}cout<<endl
#define printLine2(l,c) for(__i__=0;__i__<l;__i__++){cout<<c;}cout<<endl
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printArr(a,l) cout<<#a<<": ";for(__i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;}
#define print2dArr2(a,r,c,l) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<setw(l)<<setfill(' ')<<a[__i__][__j__]<<" ";}cout<<endl;}

// advanced debugging class
// debug 1,2,'A',"test";
class _Debug {
    public:
        template<typename T>
        _Debug& operator,(T val) {
            cout << val << endl;
            return *this;
        }
};
#define debug _Debug(),
#else
#define printLine(l)
#define printLine2(l,c)
#define printVar(n)
#define printArr(a,l)
#define print2dArr(a,r,c)
#define print2dArr2(a,r,c,l)
#define debug
#endif

// define
#define MAX_VAL 999999999
#define MAX_VAL_2 999999999999999999LL
#define EPS 1e-6
#define mp make_pair
#define pb push_back

// typedef
typedef unsigned int UI;
typedef long long int LLI;
typedef unsigned long long int ULLI;
typedef unsigned short int US;
typedef pair<int,int> pii;
typedef pair<LLI,LLI> plli;
typedef vector<int> vi;
typedef vector<LLI> vlli;
typedef vector<pii> vpii;
typedef vector<plli> vplli;

// ---------- END OF TEMPLATE ----------

string S;
int dp[200000][5];
int check(int a,int la,int b,int lb) {
    if (la != lb) return 1;
    int i;
    for (i = 0; i < la; i++) {
        if (S[a+i] != S[b+i]) return 1;
    }
    return 0;
}
int main() {
    cin >> S;

    int i,j,k,ans = 0;
    for (i = 0; i < S.size(); i++) {
        for (j = 0; j < 5; j++) dp[i][j] = -1e9;
        for (j = 1; j < 5; j++) {
            if (j > i+1) break;
            else if (j == i+1) dp[i][j] = max(dp[i][j],1);
            else {
                for (k = 1; k < 5; k++) {
                    if (dp[i-j][k] == -1e9) continue;
                    if (!check(i-j-k+1,k,i-j+1,j)) continue;
                    dp[i][j] = max(dp[i][j],dp[i-j][k]+1);
                }
            }
            ans = max(ans,dp[i][j]);
        }
        printArr(dp[i],5);
    }
    printf("%d\n",ans);

    return 0;
}



Measured memory_bytes: 4484
#import sys
from heapq import heappop, heappush
import numpy as np

#stdin = sys.stdin


N, M, S, T = list(map(int, input().split()))
graph = [[] for _ in range(N+1)] #0使わず
for _ in range(M):
    u, v, a, b = list(map(int, input().split()))
    graph[u].append((v, a, b))
    graph[v].append((u, a, b))

def dijkstra(start, mode):
    # 各地点への最小コストを返す
    INF = 10 ** 15
    dist = [INF] * (N+1) #0使わず
    dist[start] = 0
    que = [(0, start)]
    while que:
        d, src = heappop(que)
        if dist[src] < d:
            continue
        for next_city, *cost in graph[src]:
            d1 = d + cost[mode]
            if dist[next_city] > d1:
                dist[next_city] = d1
                heappush(que, (d1, next_city))
    return dist

d_en = np.array(dijkstra(S, 0))
d_snuke = np.array(dijkstra(T, 1))
d_cost = d_en + d_snuke
answer = 10 ** 15 - np.minimum.accumulate(d_cost[::-1])[::-1][1:]
print('\n'.join(answer.astype(str)))
# 21


Measured memory_bytes: 82904
n=int(input())
import sys
place=[]
place_0=[]
place_all=[]
for i in range(n):
    x,y,h=map(int,input().split())
    place_all.append((x,y,h))
    if h==0:
        place_0.append((x,y,h))
    else:
        place.append((x,y,h))
for x in range(0,101):
    for y in range(0,101):
        if not place==[]:
            H=abs(place[0][0]-x)+abs(place[0][1]-y)+place[0][2]
        else:
            H=1
        for i in range(0,n):
            d=abs(place_all[i][0]-x)+abs(place_all[i][1]-y)
            if place_all[i][2]>0:
                if H==place_all[i][2]+d:
                    count=1
                else:
                    count=0
                    break
            else:
                if d>=H:
                    count=1
                else:
                    count=0
                    break
        if count==1:
            print(x,y,H)
            sys.exit()
        


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

// Macros
#define F  first
#define S  second
#define PB push_back
#define MP make_pair
#define ALL(container)   container.begin(),container.end()
#define RALL(container)  container.rbegin(),container.rend()
#define MAKE_UNIQUE(vec) vec.erase(unique(ALL(vec)),vec.end())

// Rename Datatypes
using ll  = long long;
using ld  = long double;
using pii = std::pair <int,int>;

// Random
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
/* [a,b] */ template<class T> T rnd_IntType(T a, T b){ return uniform_int_distribution<T>(a, b)(rng); }
/* [a,b) */ template<class T> T rnd_RealType(T a, T b){ return uniform_real_distribution<T>(a,b)(rng); }

// Common Functions
ll fastpow(ll a, ll ex){ ll res = 1; while(ex){ if(ex & 1) res *= a; a *= a; ex >>= 1; } return res; }
ll fastpow(ll a, ll ex, ll m){ a %= m; ll res = 1; while(ex){ if(ex & 1) res = (a*res) % m; a = (a*a) % m; ex >>= 1; } return res; }
ll modinverse(ll a, ll m){ ll m0 = m, y = 0, x = 1; while (a > 1){ ll q = a / m; a %= m; swap(a,m); x -= q*y; swap(x,y); } if(x < 0) x += m0; return x; }

// Output, Common Containers
template <typename T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <typename T> ostream& operator << (ostream &os, const set<T> &v)    { for (T i : v) os << i << ' '; return os; }
template <typename T> ostream& operator << (ostream &os, const deque<T> &v)  { for (T i : v) os << i << ' '; return os; }
template <typename T, typename S> ostream& operator << (ostream &os, const pair<T,S> &v) { os << "(" << v.F << "=>" << v.S << ") "; return os; }
template <typename T, typename S> ostream& operator << (ostream &os, const map<T,S> &v)  { for (auto i : v) os << i << ' '; return os; }

// Debugging
#ifdef LOCAL
	#define trace(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); d__f(_it, args); }
	void d__f(__attribute__((unused)) istream_iterator<string> it) {}
	template<typename Head, typename... Tail> void d__f(istream_iterator<string> it, Head H, Tail... T) { cerr << *it << " <=> [" << H << "]\n"; d__f(++it, T...); }
#else
	#define trace(args...)
#endif


void solve(){
	ll a,b;
	cin >> a >> b;
	cout << a*b << "\n";
}

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

	int tt = 1;
	// cin >> tt;
	while(tt--) solve();
}

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

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

int main() {
    long long int n, k;
    cin >> n >> k;

    long long int cnt = 0;

    if(k%2==0){
        long long int m = n / k;
        cnt += m * m * m;
        m = (n + k / 2) / k ;
        cnt += m * m * m;
    }else{
        long long int m = n / k;
        cnt += m * m * m;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
import itertools

x = int(input())
n = 200
table = [pow(i, 5) for i in range(-n, n+1)]
choices = list(itertools.product([i for i in range(len(table))], repeat=2))

for choice in choices:
    left = choice[0]
    right = choice[1]
    if table[left] - table[right] == x:
        if left == n:
            ans_left = 0
        elif left < n:
            ans_left = left - n
        else:
            ans_left = left % n
            
        if right == n:
            ans_right = 0
        elif right < n:
            ans_right = right - n
        else:
            ans_right = right % n
        break

print(ans_left, ans_right)

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

#define pb push_back
#define mp make_pair
typedef long long LL;

bool comp(int i, int j) {
    return (i > j);
}

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n, k, i, l, ans=0;
    vector<int> ls;

    cin >> n >> k;
    while (n--) {
        cin >> l;
        ls.pb(l);
    }

    sort(ls.begin(), ls.end(), comp);
    for (i=0; i<k; i++)
        ans += ls[i];

    cout << ans;
}



Measured memory_bytes: 256
fun main() {
    val i = readLine()!!.toInt()
    if(i > 1000){
        val j = 1000 - (i%1000)
        if(j == 1000){
            println("0")
        }else{
	        println("$j")            
        }
    }else{
        val k = 1000 - i
        println("$k")
    }
}

Measured memory_bytes: 34380
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;
vector <char> v;
vector<int> num;
char cam[51][51];
int main(){
  int H,W,flag=0;
  string ans = "Yes";
  cin >> H>>W;
  for (int i = 0; i < H;i++ ){
    for (int j =  0; j < W; j++){
      cin >> cam[i][j];
    }
  }
  int dx[] = {0,1,0,-1};
  int dy[] = {1,0,-1,0};
  for (int i = 0; i < H;i++ ){
    for (int j =  0; j < W; j++){
      if(cam[i][j]=='#'){
        for(int k = 0;k<4;k++){
          for(int l = 0; l < 4;l++){
            if(((i+dx[k])>=0)&&((i+dx[k])<=H-1)&&((j+dy[l])>=0)&&((j+dy[l])<=W-1)){
              if(((cam[i][j+1])=='.')&&(cam[i+1][j]=='.')&&(cam[i-1][j]=='.')&&(cam[i][j-1]=='.')){
                flag = 1;
              }
            }
          }
        }
        if(flag)ans = "No";
        else continue;
      }
    }
  }

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


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

int main() {
	long long int X, K, D;
	long long int ans,a,b;

	cin >> X >> K >> D;
	X = abs(X);
	if (X / D >= K)ans = X - D * K;
	else {
		a = X % D;
		b = abs((X % D) - D);

	
		if ((K - X / D)%2 == 1) { ans = b; }
		else ans = a;
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define dd double
#define MOD 1000000007
#define nl cout<<endl
#define rt int Q[100005]={0}
#define mp make_pair
#define test() int t;cin>>t;while(t--)
#define pb push_back
#define ff first    
#define ss second
#define all(v) v.begin(),v.end()
#define s(ar,n) sort(ar,ar+n)
#define rs(ar,n) sort(ar, ar+n, greater<int>()) 
#define oa(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n) for(int i=0;i<n;i++)cin>>a[i];
#define ov(a,n) for(int i=n-1;i>=0;i--)cout<<a[i]<<" ";nl
#define ovp(a,n) for(int i=0;i<n;i++)cout<<a[i].ff<<" "<<a[i].ss<<endl;
#define maxa(ar,N) *max_element(ar,ar+N)
#define mina(ar,N) *min_element(ar,ar+N)
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef pair<int,int> pii;
int powe(int n,int m){if(m==0)return 1;int t=powe(n,m/2);if(m%2==0)return (t*t);return (((t*t))*n);}
int mpowe(int n,int m){if(m==0)return 1;int t=mpowe(n,m/2);t%=MOD;if(m%2==0)return (t*t)%MOD;return (((t*t)%MOD)*n)%MOD;}
int logtwo(int n){if(n==1)return 0;return logtwo(n/2)+1;}
void ceilsearch(ll ar[],ll low,ll high,ll x,ll &y){ll mid=(low+high)/2;if(low>high)return;if(ar[mid]<=x){y=mid;ceilsearch(ar,mid+1,high,x,y);}else{ceilsearch(ar,low,mid-1,x,y);}}
int main()
{
    fastio();
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/
    string s;
    int n;
    cin>>s;
    n = s.size();
    for(int i=0;i<n;i++)
        cout<<'x';

}

Measured memory_bytes: 256
n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))

d = []

def func(x):
    if len(x) == n:
        temp = 0
        for i, t in enumerate(x):
            temp += t * (n ** i)
        d.append(temp)
        return
    for i in range(1, n+1):
        if i not in x:
            func(x + [i])

func([])

d.sort()
p = list(reversed(p))
q = list(reversed(q))
a = 0
b = 0
for i in range(n):
    a += p[i] * (n ** i)
    b += q[i] * (n ** i)

#print(a, b, d)
print(abs(d.index(a) - d.index(b)))

Measured memory_bytes: 4844
#include<iostream>
using namespace std;
static const int MAX_N=10e5;
long A[MAX_N],B[MAX_N-1],ANS[MAX_N+1];
long sum;
int main(void){
	int N;cin >> N;
	for(int i=0;i<N;i++){
		cin >> A[i];
		sum+=A[i];
		A[i]*=2;
	}
	for(int i=0;i<N-1;i++)
		B[i]=A[i+1]-A[i];
	long fa=0,fb=0,cur=0;
	for(int i=0;i<N-1;i++){
		if(i%2==0){
			cur+=fa+B[i];
			fa+=B[i];
		}else{
			cur+=fb-B[N-i-1];
			fb-=B[N-i-1];
		}
	}
	
	ANS[0]=ANS[N]=(sum-cur)/N;
	for(int i=1;i<N;i++){
		if(i%2==0){
			ANS[i]=ANS[i-2]+B[i-2];
		}else{
			ANS[N-i-1]=ANS[N-i+1]-B[N-i-1];
		}
	}
	for(int i=0;i<N;i++){
		cout << ANS[i] << " ";
	}cout << endl;
	return 0;
}


Measured memory_bytes: 10240
N,A,B=map(int,input().split())
S=input()
f=0;p=0 # p:通過の確定した参加者の人数
for s in S:
    if s=='a':
        if p<A+B:
            print('Yes');p+=1
        else:
            print('No')
    elif s=='b':
        f+=1 # f:海外の学生の中での順位
        if p<A+B and f<=B:
            print('Yes');p+=1
        else:
            print('No')
    else:
        print('No')

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

int main() {
  string s;
  cin >> s;
  cout << (s[0]=='M'?6:(s[0]=='W'?4:(s[0]=='F'?2:(s[2]=='N'?7:(s[2]=='T'?1:(s[2]=='E'?5:3)))))) << endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
n = int(input())
a = [(int(input()), i) for i in range(n)]
a.sort(reverse=True)
if a[0][0] == a[1][0]:
    for i in range(n):
        print(a[0][0])
else:
    ans = [0]*n
    for ai, i in a:
        if ai == a[0][0]:
            ans[i] = a[1][0]
        else:
            ans[i] = a[0][0]
    for i in ans:
        print(i)

Measured memory_bytes: 64976
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const ll mo = 1000000007;
const ll INF = 1LL << 59; //MAX 9223372036854775807
ll ans = 0;

int main()
{
ll n;
cin >> n;
ll t[n] = {};
rep(i, n){
    cin >> t[i];
}
ll cnt[32]={};
rep(i,n){
    rep(j,32){
        if(1LL&t[i]>>j)cnt[j]++;
    }
}
ll sum=0;
rep(i,32){
    sum+=cnt[i];
}
if(n%3!=0&&sum!=0){
    cout << "No" << endl;
    return 0;
}
rep(i,32){
    if(cnt[i]==0||cnt[i]==n*2/3);
    else{
        cout << "No" << endl;
        return 0;
    }
}
cout << "Yes" << endl;
return 0;
}


Measured memory_bytes: 1024
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, k = map(int, input().split())
    X, Y = [], []
    for _ in range(n):
        x, y = map(int, input().split())
        X.append(x)
        Y.append(y)
    X_s = sorted(X)
    Y_s = sorted(Y)
    
    res = f_inf
    for x1 in range(n):
        for x2 in range(x1 + 1, n):
            for y1 in range(n):
                for y2 in range(y1 + 1, n):
                    lx, rx = X_s[x1], X_s[x2]
                    by, uy = Y_s[y1], Y_s[y2]
                    cnt = 0
                    for i in range(n):
                        if lx <= X[i] <= rx and by <= Y[i] <= uy:
                            cnt += 1
                    if cnt >= k:
                        res = min(res, (rx - lx) * (uy - by))
    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 74348
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n,k;
    cin>>n>>k;
    int a[n+1], dp[n+1] = {0};
    for(int i = 1; i <= n; i++)
        cin>>a[i];
    dp[1] = 0;
    for(int i = 2; i <= n; i++) {
        int s = INT_MAX;
        for(int j = 1; j < min(i,k+1); j++) 
            s = min(s,dp[i-j] + abs(a[i] - a[i-j]));
        dp[i] = s;
    }
    cout<<dp[n]<<endl;
}

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


signed main(){
   string s,t;
   cin>>s>>t;
   int a,b;
   cin>>a>>b;
   string u;
   cin>>u;
   if(u==s){
      cout<<a-1 << " "<< b<<endl;
   }
   else if(u==t){
      cout<<a << " " <<b-1<<endl;
   }
   return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i < (int)(n); i++)
using ll = long long;
using namespace std;
const ll INF = 1LL << 60;

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


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

int main() {
    string s;
    cin >> s;
    set<char> st;
    for (int i = 0; i < s.size(); i++) {
        if (st.count(s[i]) == 0) {
            st.insert(s[i]);
        } else {
            cout << "no" << endl;
            return 0;
        }
    }
    cout << "yes" << endl;
}

Measured memory_bytes: 256
// 2011/05/04 Tazoe

#include <iostream>
#include <string>
#include <sstream>
using namespace std;

int main()
{
	while(!cin.eof()){
		string str;
		getline(cin, str);
		if(str.empty())
			continue;

		istringstream ist(str);
		int C1, C2, C3;
		ist >> C1 >> C2 >> C3;

		int cnt = 0;
		for(int i=1; i<=10; i++){
			if(i==C1||i==C2||i==C3)
				continue;
			if(C1+C2+i<=20)
				cnt++;
		}

		if(cnt>=4)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}

	return 0;
}

Measured memory_bytes: 0
if __name__ == '__main__':
	
    num = input()
    n = 0
    count = 1
    for v in list(num):
        if n == v:
            count += 1
            if count >= 3:
                break
        else:
            count = 1
        n = v
    if count >= 3:
        print('Yes')
    else:
        print('No')

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define Rep(i,n) for(int i = 1; i <= n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
template<class T> using V = vector<T>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
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; }

int p(int x) { return x/2; }
int l(int x) { return 2*x; }
int r(int x) { return 2*x+1; }

int main(){
    int n;
    cin >> n;
    V<int> a(n+1);
    Rep(i,n) cin >> a[i];
    Rep(i,n) {
        printf("node %d: key = %d, ", i, a[i]);
        if(p(i) > 0) printf("parent key = %d, ", a[p(i)]);
        if(l(i) <= n) printf("left key = %d, ", a[l(i)]);
        if(r(i) <= n) printf("right key = %d, ", a[r(i)]);
        printf("\n");
    }
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e16+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

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

    ll n,k;
    cin>>n>>k;
    Vec a(n);
    rep(i,n)cin>>a[i];

    VV dp(61,Vec(2,0));
    ll x = 0;
    per(i,60){
        rep(j,n){
            dp[i][a[j]>>i&1]++;
        }
        if(dp[i][0]>dp[i][1] && (x|(1LL<<i))<=k){
            x |= (1LL<<i);
        }
    }
    ll ans=0;
    rep(i,n){
        ans += x^a[i];
    }
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
#define inf 0x3f3f3f3f
struct node
{
	int a;
	int id;
}s[200050];
bool cmp(node a,node b)
{
	return a.a<b.a;
}
int ans[200050];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%d",&s[i].a);
		s[i].id=i;
	}
	sort(s,s+n,cmp);
	for(int i=0;i<n;i++)
	{
		if(i<n/2)
		ans[s[i].id]=s[n/2].a;
		else
		ans[s[i].id]=s[n/2-1].a;
	}
	for(int i=0;i<n;i++)
	printf("%d\n",ans[i]);
	
	return 0;
}

Measured memory_bytes: 4480
import math

def Eratos(n):
	primes = [2]
	num = [2*i+1 for i in range(1,n//2)]
	tmp = []

	top = 1
	while top < math.sqrt(n):
		top = num[0]
		for i in range(1,len(num)):
			if num[i] % top != 0:
				tmp.append(num[i])
		num = tmp
		tmp = []
		primes.append(top)
	for i in range(len(num)):
		primes.append(num[i])
	return primes

n = int(input())
cont = 0
primes = Eratos(10010)
for i in range(n):
	a = int(input())
	if a<10000:
		if primes.count(a)!=0:
			cont += 1
	else:
		for j in range(len(primes)):
			if a%primes[j]==0:
				break
			else:
				if math.sqrt(a)<primes[j]:
					cont += 1
					break
print(cont)


Measured memory_bytes: 5752
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>
#include <stdio.h>
#include <queue>
#include <cmath>
#include <utility>
#include <map>

using namespace std;
typedef long long ll;
#define rep(i,a,b) for(int i=(a);i<(b);++i)

int i, j, k;
int main() {
	int N;
	cin >> N;
	int ans = 1;
	for (i = 2; i < N; i++) {
		j = 2;
		while (pow(i, j) <= N) {
			if (pow(i, j) <= N) {
				ans = (ans > pow(i,j) ?ans : pow(i, j));
			}


			j++;
		}
	}

	cout << ans;
	return 0;
}


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

int ara[1000007],tra[1000007];

int main()
{


       int n,m,a,b,c,i,j,sz=0,ans=0,flg; vector<int>v;

       scanf("%d",&n);

       for(i=1;i<=n;i++)
       {
           scanf("%d",&a);  tra[a]++;
           if(tra[a]==1)
           {
               v.push_back(a); sz++;
           }
       }

       sort(v.begin(),v.end());

       for(i=0;i<sz;i++)
       {
           a=v[i];

           if(tra[a]==1)
           {
               flg=1;

               for(j=1;j*j<=a;j++)
               {
                   if((a%j)==0)
                   {
                       if(ara[j]==1 || ara[a/j]==1){ flg=0; break; }
                   }
               }

               if(flg==1)ans++;

           }

           ara[a]=1;

       }


       printf("%d\n",ans);




    return 0;
}





Measured memory_bytes: 11876
#include <stdio.h>

int main(void){
	int N;
	scanf("%d" ,&N);
	int list[100]={};
	int a;

	for(int i=0; i<N; i++){
		scanf("%d" ,&a);
		list[i]=a;
	}
	for(int j=0; j<N; j++){
		printf("%d",list[N-j-1]);
		if(j!=N-1){
			printf("%s"," ");
		}
	}
	printf("%s\n", "");

	return 0;
}


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

#define ll long long
#define FASTIO std::ios::sync_with_stdio(false)

#define loop(i, begin, end)                            \
  for (__typeof(end) i = (begin) - ((begin) > (end)); \
       i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

using namespace std;

int main() {
    FASTIO;

    ll n, k, q, v[100100], a;

    memset(v, 0, sizeof(v));
    cin >> n >> k >> q;

    loop(i, 0, q) {
        cin >> a;
        v[a]++;
    }

    loop(i, 1, n + 1) {
        cout << (k - q + v[i] > 0LL ? "Yes" : "No") << endl;
    }
}

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

const int maxn = 100000;
const int infly = (1<<29);

vector <int> G[maxn+5];
list <int> out;
bool c[maxn];
int N;
int indge[maxn];

void bfs(int s)
{
    queue <int> q;
    q.push(s);
    c[s] = true;

    while( !q.empty() )
    {
        int u = q.front();
        q.pop();
        out.push_back(u);

        for(int i = 0 ; i < G[u].size() ; i++)
        {
            int v = G[u][i];
            indge[v]--;
            if(indge[v] == 0 && !c[v])
            {
                c[v] = true;
                q.push(v);
            }
        }
    }
}

void tsort()
{
    for(int i = 0 ;i < N ;i++)
    {
        indge[i] = 0;
    }

    for(int u = 0; u < N ; u++)
    {
        for(int i = 0 ;i < G[u].size(); i++)
        {
            int v = G[u][i];
            indge[v]++;
        }
    }

    for(int u = 0; u < N ;u++)
    {
        if( indge[u] == 0 && !c[u])
        {
            bfs(u);
        }
    }

    for(list<int> ::iterator it = out.begin(); it != out.end() ;it++)
    {
        cout << *it << endl;
    }
}

int main()
{
    int s, t, M;

    scanf("%d%d",&N,&M);

    for(int i = 0; i < N; i++) c[i] = false;

    for(int i = 0; i < M; i++)
    {
        scanf("%d%d",&s,&t);
        G[s].push_back(t);
    }

    tsort();

    return 0;
}

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

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#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 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--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))   //最大値を求める
#define MIN(x) *min_element(ALL(x))   //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 10000007      //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素

//for (auto& e : array) 

bool judge(string s){
    for(auto& e : s){
        if(e != 'A' && e != 'C' && e != 'G' && e != 'T')
            return false;
    }
    return true;
}

signed main()
{
    string S, T;
    cin >> S >> T;

    if(S == T.erase(T.size()-1))
        cout << "Yes" << endl;
    else
    {
        cout << "No" << endl;
    }
    


}



Measured memory_bytes: 3628
h, w, n  = map(int, input().split())
sr, sc = map(int, input().split())
S = list(str(input()))
T = list(str(input()))

y = sr
for s,t in zip(S, T):
    if s == 'U':
        y -= 1
        if y < 1:
            print('NO')
            exit()
    if t == 'D':
        if y < h:
            y += 1

y = sr
for s, t in zip(S, T):
    if s == 'D':
        y += 1
        if y > h:
            print('NO')
            exit()
    if t == 'U':
        if y > 1:
            y -= 1

x = sc
for s, t in zip(S, T):
    if s == 'R':
        x += 1
        if x > w:
            print('NO')
            exit()
    if t == 'L':
        if x > 1:
            x -= 1

x = sc
for s, t in zip(S, T):
    if s == 'L':
        x -= 1
        if x < 1:
            print('NO')
            exit()
    if t == 'R':
        if x < w:
            x += 1

print('YES')

Measured memory_bytes: 8312
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef pair<int, int> P;

char f(char c){
    return c + 'A' - 'a';
} 

signed main(){
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;
    cout << f(s1[0]) << f(s2[0]) << f(s3[0]) << endl;
}

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

namespace _0565
{
    public class Program

    {
        public static void Main(string[] args)
        {
            int[] pasta = new int[3];
            int[] juice = new int[2];

            for (int i = 0 ; i < pasta.Length ; i++)
            {
                pasta[i] = ReadInt();
            }

            for (int i = 0 ; i < juice.Length ; i++)
            {
                juice[i] = ReadInt();
            }
            Console.WriteLine(pasta.Min() + juice.Min() - 50);
        }

        static string ReadSt() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Console.ReadLine()); }
        static long ReadLong() { return long.Parse(Console.ReadLine()); }
        static double ReadDouble() { return double.Parse(Console.ReadLine()); }
        static string[] ReadStAr(char sep = ' ') { return Console.ReadLine().Split(sep); }
        static int[] ReadIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e)); }
        static long[] ReadLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e)); }
        static double[] ReadDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => double.Parse(e)); }
        static string WriteAr(int[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }
        static string WriteAr(double[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }
        static string WriteAr(long[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }

    }

}



Measured memory_bytes: 16252
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define in(x, l, r) (ll)(l) <= (x) && (x) < (ll)(r)

int main() {
    ll N, D;
    cin >> N >> D;
    vector<ll> x(N), y(N);
    rep(i,0,N) cin >> x[i] >> y[i];
    ll ans = 0;
    rep(i,0,N) {
        if (D * D >= x[i] * x[i] + y[i] * y[i]) ans++;
    }
    cout << ans << endl;
}

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

using namespace std;

int main() {
	int K;
	cin >> K;
	
	long long A[K],mx = 0;
	for (int i = 0; i < K; ++i) {
		cin >> A[i];
		mx = max(A[i],mx);
	}
	long long alow = mx, ahi = 1e17+10,a,temp,z = 0,blow = mx, bhi = 1e17+10,b;
	bool can = false;
	while (alow < ahi) {
		a = (alow + ahi) / 2;
		temp = a;
		
		for (int i = 0; i < K; ++i) {
			temp = max(z,temp - (temp % A[i]));
		}
		
		if (temp == 2) can = true;
		if (temp < 2) {
			alow = a + 1;			
		} else {
			ahi = a;
		}
	}
	
	while (blow < bhi) {
		b = (blow + bhi) / 2;
		temp = b;
		
		for (int i = 0; i < K; ++i) {
			temp = max(z,temp - (temp % A[i]));
		}
		
		if (temp <= 2) {
			blow = b + 1;
		} else {
			bhi = b;
		}
	}
	
	if (can) {
		printf("%lld %lld",alow,blow - 1);
	} else {
		cout << -1;
	}
	
	return 0;
}

Measured memory_bytes: 1024
/// sultanov

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
     
#define x first
#define y second
#define pb push_back
#define sz(x) (int) x.size()
 
using namespace std;
using namespace __gnu_pbds;

template<typename T> 
using ordered_set = tree<T, null_type,   
less<T>, rb_tree_tag,
tree_order_statistics_node_update>;

using ll = long long;
using pii = pair<int, int>;                                   

const int INF32 = INT_MAX;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int& x : a)
        cin >> x, x--;
    vector<int> b(n);
    for (int& x : b)
        cin >> x;
    vector<int> c(n - 1);
    for (int& x : c)
        cin >> x;
    ll sum = 0;
    for (int i = 0; i < n; i++) {
        sum += b[a[i]];
        if (i && ++a[i - 1] == a[i])
            sum += c[--a[i - 1]];
    }
    cout << sum;
    return false;                                                       
}

Measured memory_bytes: 256
open Batteries

let () =
  let w, h, n = Scanf.scanf " %d %d %d " (fun w h n -> (w, h, n)) in
  let arr = Array.make_matrix w h 1 in
  let filter_arr f =
    1 -- w
    |> Enum.iter (fun x ->
           1 -- h |> Enum.iter (fun y -> if f x y then arr.(x - 1).(y - 1) <- 0)
       )
  in
  1 -- n
  |> Enum.iter (fun _ ->
         Scanf.scanf " %d %d %d" (fun xi yi ai ->
             match ai with
             | 1 -> filter_arr (fun x _ -> x <= xi)
             | 2 -> filter_arr (fun x _ -> x > xi)
             | 3 -> filter_arr (fun _ y -> y <= yi)
             | 4 -> filter_arr (fun _ y -> y > yi)
             | _ -> failwith "" ) ) ;
  Array.map (Array.fold_left ( + ) 0) arr
  |> Array.fold_left ( + ) 0 |> Printf.printf "%d\n"


Measured memory_bytes: 3200
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>

typedef unsigned short ushort;
typedef unsigned int   uint;

class Poll
{
public:
    Poll( ushort n ) : nVote(n) {}
    friend std::istream & operator>>( std::istream & ist, Poll & poll );
    bool CanSelectPopulars( ushort m ) const;
private:
    std::vector<ushort> nVote;
};

std::istream & operator>>( std::istream & ist, Poll & poll )
{
    for ( auto & vote : poll.nVote )
    {
        ist >> vote;
    }
    
    return ist;
}

bool Poll::CanSelectPopulars( ushort m ) const
{
    uint sumVotes = std::accumulate( nVote.begin(), nVote.end(), 0 );
    
    std::vector<ushort> copyVote = nVote;
    std::nth_element( copyVote.begin(), copyVote.end() -m, copyVote.end() );
    
    return ( copyVote[ copyVote.size() -m ] * 4*m >= sumVotes );
}

int main( void )
{
    ushort M, N;
    std::cin >> N >> M;
    
    Poll poll(N);
    std::cin >> poll;
    std::cout << ( poll.CanSelectPopulars(M) ? "Yes" : "No" ) << std::endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define f first
#define s second
#define PI 3.14159265358979
vector<int> g[100005];
bool visited[100005];
int ans=0;
int val[100005];
void bfs(int src)
{
   queue<int>q;
   q.push(src);
   while(!q.empty())
   {
       int k=q.front();
       visited[k]=true;
       ans++;
       q.pop(); 
       for(int x: g[k])
       {
           if(!visited[x])
           {
               q.push(x);
               val[x]=k;
               visited[x]=true;
           }
       }
   }
}
signed main()
{
      int n,m;
      cin>>n>>m;
      for(int i=1;i<=m;i++)
      {
          int u,v;
          cin>>u>>v;
          g[u].pb(v);
          g[v].pb(u);
      }
       bfs(1);
       if(ans==n)
       {
            cout<<"Yes"<<endl;
            for(int i=2;i<=n;i++)
                cout<<val[i]<<endl;
       }
       else
        cout<<"No"<<endl;
}


Measured memory_bytes: 13064
import sys
import bisect
sys.setrecursionlimit(10**7)

n,m=map(int,input().split())
a=list(map(int,input().split()))

a.sort()

def hantei(t):
    global n,m,a
    ret = 0
    for sa in a:
        ret += n - bisect.bisect_left(a,t-sa)
    if ret<=m:return True
    else:return False

def nibun(l,r):
    if r == l:
        return l
    f = (l+r)//2
    if hantei(f):
        return nibun(l,f)
    else:
        return nibun(f+1,r)


p=nibun(0,3*(10**5))

a.reverse()
na=[]
sna = 0
for sa in a:
    sna += sa
    na.append(sna)
na.reverse()
na.append(0)
a.reverse()

res = 0
f=0
for sa in a:
    q = bisect.bisect_left(a,p-sa)
    f += n-q
    res += na[q]+sa*(n-q)
res += (p-1)*(m-f)

print(res)

Measured memory_bytes: 58048
from sys import stdin
import math
from operator import itemgetter
from bisect import bisect_left, bisect_right
readline = stdin.readline
 
def main():
    n = int(readline())
    xy = [tuple(map(int, readline().split())) + (i,) for i in range(n)]
    xy.sort()
 
    root = int(math.sqrt(len(xy)))
 
    low = [x for x, y, i in xy[::root]]
    high = [x for x, y, i in xy[root - 1::root]] + [float('inf')]
 
    xy = [sorted(xy[i:i + root], key=itemgetter(1)) for i in range(0, len(xy), root)]
    xy = [([y for x, y, i in xyi], xyi) for xyi in xy]
    A = []
    for sx, tx, sy, ty in (map(int, readline().split()) for _ in range(int(readline()))):
        ret = []
        for i in range(bisect_left(high, sx), bisect_right(low, tx)):
            k, v = xy[i]
            for i in range(bisect_left(k, sy), bisect_right(k, ty)):
                if sx <= v[i][0] <=tx:
                    ret.append(v[i][2])
        if ret:
            ret.sort()
            A.extend(ret)
        A.append('')
    print('\n'.join(map(str, A)))
 
main()

Measured memory_bytes: 149536
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007LL



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

    int n,temp =0;
    cin>>n;
    bool b = true;
    int a[n][2];

    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < 2; j++)
        {
            cin>>a[i][j];
        }    
    }
    for (int i = 0; i < n; i++)
    {
        if (a[i][0]==a[i][1])
        {
            temp++;
            if (temp == 3)
            {
                b = false;
                break;
            }    
        }
        else
        {
            temp = 0;
        }    
    }
    if (!b)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    
    
}

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

int main(){
  string s,s1,s2;
  cin >> s1;
  cin >> s;
  s2 = s1+s1;
  //cout << s2.find(s);
  if(s2.find(s) < 100000000){
    cout << "Yes";
  }else{
    cout << "No";
  }
  cout << endl;
}


Measured memory_bytes: 3204
N, K, Q = map(int, input().split())
P = [K] * N

P = list(map(lambda x:x-Q, P))
for _ in range(Q):
	A = int(input()) -1
	P[A] += 1
			
for i in P:
	if i > 0:
		print('Yes')
	else:
		print('No')

Measured memory_bytes: 7844
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int T = sc.nextInt();
		int A = sc.nextInt();
		
		int palaceElevations[] = new int[N];
		
		for (int i = 0; i < N; i++) {
			palaceElevations[i] = sc.nextInt();
		}
		
		int ans = 1;
		double bestPalaceTemperature = T - (palaceElevations[0] * 0.006);
		
		for (int i = 0; i < N; i++) {
			double palaceTemperature = T - (palaceElevations[i] * 0.006);
			
			if (Math.abs(A - palaceTemperature) < Math.abs(A - bestPalaceTemperature)) {
				bestPalaceTemperature = palaceTemperature;
				ans = i + 1;
			}
		}
		
		System.out.println(ans);
	}
}


Measured memory_bytes: 22740
/*
Hanit Banga
*/

#include <iostream>
#include <vector>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false)

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

const int N = 1e5 + 5;

ll a[N], b[N];

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

	ll ans = 0;
	for (int i = 0; i < n; ++i)
		cin >> a[i] >> b[i];

	for (int i = n-1; i >= 0; --i)
	{
		a[i] += ans;
		if (a[i] % b[i] == 0)
			continue;

		ll p = a[i]/b[i] + 1;
		p *= b[i];
		ans += p - a[i];
	}

	cout << ans;
}

Measured memory_bytes: 1792
def solve():
    x, y = map(int, input().split())
    n = (2*y-x) / 3
    m = (2*x-y) / 3

    mod = 10**9+7

    if n < 0 or m < 0 or (x+y)% 3 != 0:
        return 0
    cmb = 1
    n = int(n)
    m = int(m)
    
    cnt = 0
    for i in range(n):
        cnt += 1
        cmb *= n+m-i
        cmb *= pow(i+1, mod-2, mod)
        cmb %= mod
    return cmb

print(solve())

Measured memory_bytes: 40172