akhauriyash/Code-Regression huggingface dataset:
from sys import stdin, stdout
import math
from itertools import permutations, combinations
from collections import defaultdict
import bisect
import heapq as hq

def main():
    try:
        n,a,b=In()
        temp=a+b
        t=n//temp
        t=(a*t)
        n=n%temp
        if n<=a and n>0:
            t+=(n)
        elif n>a:
            t+=(a)
        print(t)
    except:
        pass
def add(a, b, c):
    res = a + b;
    if (res >= c):return res - c;
    else:return res;
def mod(a, b, c):
    res = a * b
    if (res >= c):return res % c
    else:return res
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
def lcm(a, b):
    w = a // gcd(a, b)
    return w * b
def expo(a, b):
    x, y = 1, a
    while (b > 0):
        if (b & 1):
            x = x * y
        y = y * y
        b >>= 1
    return x
def power(a, b, m):
    x, y = 1,
    while (b > 0):
        if (b & 1):x = mod(x, y, m)
        y = mod(y, y, m)
        b >>= 1
    return x
def L():
    return list(map(int, stdin.readline().split()))
def In():
    return map(int, stdin.readline().split())
def I():
    return int(stdin.readline())
P = 1000000007


if __name__ == '__main__':
    main()




Measured memory_bytes: 3424
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(H, W, S):
    def edges(v):
        i, j = v
        r = []
        if i > 0 and S[i-1][j] == '.':
            r.append((i-1, j))

        if i < H-1 and S[i+1][j] == '.':
            r.append((i+1, j))

        if j > 0 and S[i][j-1] == '.':
            r.append((i, j-1))

        if j < W-1 and S[i][j+1] == '.':
            r.append((i, j+1))

        return r

    def bfs(s):
        q = deque([s])
        d = {s: 0}
        while q:
            u = q.popleft()
            for v in edges(u):
                if v not in d:
                    d[v] = d[u] + 1
                    q.append(v)
        return max(d.values())

    ans = 0
    for i in range(H):
        for j in range(W):
            if S[i][j] == '.':
                l = bfs((i, j))
                ans = max(ans, l)
    return ans


def main():
    H, W = read_int_n()
    S = [read_str() for _ in range(H)]
    print(slv(H, W, S))


if __name__ == '__main__':
    main()


Measured memory_bytes: 72408
#include <iostream>
#include <cstdlib> //abs(int x)
using namespace std;

int n, k;
     
long long solve(long long* H){
  long long C[n];
  C[0] = 0;
  C[1] = abs(H[1]-H[0]);
  for (int i=2; i<n; i++){
    long long m = 1LL<<60;
    for (int j=i-k; j<i; j++){
      if (j>=0){
        m = min(m, C[j]+abs(H[i]-H[j]));
      } 
    }
    C[i] = m;
  }
  return C[n-1];
}
     
int main(){
  cin >> n >> k;
  long long H[n];
  for (int i=0; i<n; i++){
    cin >> H[i];
  }
  cout << solve(H) << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <stack>
#ifdef DEBUG
#include <cassert>
#define debug(a) a
#else
#define debug(a)
#endif
using namespace std;
#define repeat(i,n) for (int i = 0; i < (n); ++i)
#define foreach(typ, it, cont) for (typ::iterator it = cont.begin(); it != cont.end(); ++it)

short kind(char c) {
    if (c == '(' or c == ')') return 1;
    if (c == '[' or c == ']') return 2;
    debug(assert(false));
}

bool is_balanced(string & s) {
    stack<short> stk;
    foreach (string, it, s) {
        if (*it == '(' or *it == '[') stk.push(kind(*it));
        if (*it == ']' or *it == ')') {
            if (stk.empty() or stk.top() != kind(*it)) return false;
            stk.pop();
        }
    }
    return stk.empty();
}

int main() {
    while (true) {
        string s; getline(cin,s);
        if (s == ".") break;
        cout << (is_balanced(s) ? "yes" : "no") << endl;
    }
    return 0;
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
#define REP(i,n)   for(int i=0;i<(n);++i)
#define ALL(v)     (v).begin(),(v).end()
#define debug(x)   cerr<<#x<<": "<<(x)<<endl
using namespace std;
using llong = long long;
using vi    = vector<int>;
using vvi   = vector<vi >;
using vvvi  = vector<vvi >;
using pii   = pair<int,int>;
constexpr int    INF=1e9;
constexpr double EPS=1e-9;
constexpr int    MOD=1e9+7;
template<class Type>
void line(const Type &a){int cnt=0;for(const auto &elem:a){cerr<<(cnt++?' ':'>');cerr<<elem;}cerr<<endl;}

struct UnionFind{
	vi par;		//par[i]:=(0以上の場合iの親, 0未満の場合はiを含むグループのサイズ).
	int num;	//num:=(グループの数).
	
	UnionFind(int n):par(n,-1),num(n){}//constructor.
	
	void init(){fill(ALL(par),-1), num=par.size();}
	int root(int x){return (par[x]<0)?x:par[x]=root(par[x]);}//recrusion.
	int size(int x){return -par[root(x)];}
	bool same(int x,int y){return root(x)==root(y);}
	bool unite(int x,int y){
		x=root(x), y=root(y);
		if(x==y) return false;//Do nothing.
		if(size(x)<size(y)) swap(x,y);//merge technique(y to x).
		par[x]+=par[y];
		par[y]=x;
		num--;
		return true;
	}
};

int main(){//Refering other editorials.
	int n;
	cin>>n;
	
	vector<pii> xi(n),yi(n);
	REP(i,n){
		int x,y;
		cin>>x>>y;
		xi[i]=pii(x,i);
		yi[i]=pii(y,i);
	}
	sort(ALL(xi)), sort(ALL(yi));
	
	using type=tuple<int,int,int>;
	priority_queue<type,vector<type >,greater<type > > pque;
	REP(i,n-1){
		int x,xx,p,pp;
		tie(x,p)=xi[i], tie(xx,pp)=xi[i+1];
		pque.push(type(xx-x,p,pp));
	}
	REP(i,n-1){
		int y,yy,p,pp;
		tie(y,p)=yi[i], tie(yy,pp)=yi[i+1];
		pque.push(type(yy-y,p,pp));
	}
	
	llong ans=0LL;
	UnionFind tree(n);
	while(!pque.empty()){
		int cost,u,v;
		tie(cost,u,v)=pque.top();
		pque.pop();
		
		if(!tree.same(u,v)){
			ans+=cost;
			tree.unite(u,v);
		}
	}
	
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 7988
S = input()
K = int(input())
A = None
C = 1
D = []
E = False
if S[-1]==S[0]:
    E = True
for i in range(len(S)-1):
  if S[i]==S[i+1]:
    C += 1
  else:
    D.append(C)
    C = 1
D.append(C)
if len(D)==1:
  A = int(D[0]*K/2)
else:
  F = int(D[0]/2)+int(D[-1]/2)
  I = 0
  for j in range(1,len(D)-1):
    I += int(D[j]/2)
  if E:
    G = int((D[0]+D[-1])/2)
    A = F + G*(K-1) + I*K
  else:
    A = (F + I)*K
print(A)

Measured memory_bytes: 3064
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

s = input()
n = len(s)
w = int(input())
ans = ""
for i in range(0,n,w):
  ans += s[i]
print(ans)

Measured memory_bytes: 38256
#include <stdio.h>
#include <stdbool.h>

#define ARRAY_MAX 5

void solve(int a, int b);
bool isPalindromicNumber(int n);


int main()
{
  int a, b;

  scanf("%d %d", &a, &b);
  
  solve(a, b);

  return 0;
}

void solve(int a, int b)
{
  int counter = 0;
  
  for (int i = a; i <= b; i++)
    {
      if (isPalindromicNumber(i))
	{
	  counter++;
	}
    }
  printf("%d\n", counter);
}


bool isPalindromicNumber(int n)
{
  int tempArray[ARRAY_MAX];
  int rest;
  int index = 0;

  bool flag;
  int len;

  rest = n;
  while (rest > 0)
    {
      tempArray[index] = rest % 10;
      rest = rest / 10;
      index++;
    }

  len = index;
  flag = true;
  for (int i = 0; i < len / 2; i++)
    {
      if (tempArray[i] != tempArray[len - i - 1])
	{
	  flag = false;
	  break;
	}
    }

  return flag;
}


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

int main() {
  string S;
  cin >> S;
  int value = 700;
  
  for(int i = 0; i < 3; i++) {
    if(S.at(i) == 'o') {
      value += 100;
    }
  }
  cout << value << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
using ll=long long;
using namespace std;
//const int INF = 7+(1e+9);
ll GCD(ll x, ll y)
{
    if (y == 0)
    {
        return x;
    }
    else
    {
        return GCD(y, x % y);
    }
}
ll LCM(ll x, ll y)
{
    return x / GCD(x, y) * y;
}
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};
vector<vector<char>> vec(12,vector<char>(12));

int dx[]={0,-1,0,1};
int dy[]={1,0,-1,0};
int dfs(int y,int x){
    vec[y][x]='5';
    for(int i=0;i<4;i++){
        if(x+dx[i]<12&&x+dx[i]>=0&&y+dy[i]<12&&y+dy[i]>=0&&vec[dy[i]+y][dx[i]+x]=='1'){
            dfs(y+dy[i],x+dx[i]);
        }
    }
    return 0;
}
int main(){
    int n;
    cin>>n;
    vector<int> vec(n);
    for(int i=0;i<n;i++){
        cin>>vec[i];
        
    }
    int k;cin>>k;int sum=0;
    for(int i=0;i<k;i++){
        int x;
        cin>>x;
        if(binary_search(vec.begin(),vec.end(),x))sum++;
        
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 3124
#include<stdio.h>

int main() {
long long n, k;
long long a[100000] = {};
long long x, y;
long long i;
long long  count = 0;
  scanf("%lld %lld", &n, &k);
  for (i = 0; i < n; i = i+1) {
    scanf("%lld %lld", &x, &y);
    a[x] = a[x] + y;
  }
  for (i = 1; i < 100000; i = i+1) {
    count = count + a[i];
    if (k <= count) {
      break;
    }
  }
  printf("%lld\n", i);
  return 0;
}
      
    

Measured memory_bytes: 896
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
//if(strcmp(s[i],"AC")==0)
//if(s[l]=='#')
/*小文字判定
if((moji>= 'a') && (moji<='z')){
    printf("a\n");
    return 0;
  }
  */
//文字列中の一文字⇒数字の時は s[i]-'0'
int W_Length(char *str){
	int length = 0;
	while(*str++ != '\0')
		length++;
	return length;
}

void swap(long long int *a, long long int *b){
  int temp;
  temp=*a;
  *a=*b;
  *b=temp;
}
//swap(&a, &b)

double deg(double theta){//deg to theta
return theta*(2*3.14159265359)/360;
}

long long int cmp( const void *p, const void *q ) {
    return *(long long int*)p - *(long long int*)q;
}//ちいさい順
//qsort(a,n,sizeof(long long int),cmp);


int cmp_s(const void * left, const void * right)
{
	char *left_char = (char *)left;
  char *right_char = (char *)right;
  return strcmp(left_char, right_char);
}
//qsort(s,n,sizeof(s[0]),cmp_s);
//char s[n][11]

long long int GCD(long long int a, long long int b){
  long long int L=a,S=b;
  while(1){
    if(S>L){
      L=S+L;
      S=L-S;
      L=L-S;
    }
    if(L%S==0){
      return S;
    }
    L=L%S;
  }
  
}

long long int LCM(long long int a, long long int b){
  return a*b/(GCD(a,b));
}

int main (void)
{
	long long int n,i,min,d,t,s,k,a[210000],max,j=1,count=0;
scanf("%lld%lld%lld",&d,&t,&s);
if(s*t>=d){
  printf("Yes");
  return 0;
}
  
  printf("No");
return 0;
}


Measured memory_bytes: 1736
#include<cstdio>
long long gcd(long long a,long long b)
{
    
    return b==0?a:gcd(b,a%b);
}
int main()
{
    long long a,b;
    while (scanf("%lld%lld",&a,&b)==2)
    {
    	long long sum=gcd(a,b);
    	long long num=a/sum*b;
    	printf("%lld %lld\n",sum,num);
	}
    return 0;
}

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

bool comp_str(string str1, string str2){
  if(str1.length() == str2.length()){
    for(int i=0 ; i< str1.length(); i++){
      if((str1[i]-'A')%('a'-'A') != (str2[i]-'A')%('a'-'A'))
        return false;
    }
    return true;
  }
  else{
  return false;
  }
}

int main(){
  string W, T;
  int count = 0;
  cin >> W;
  cin >> T;
  while(T != "END_OF_TEXT"){
    if(comp_str(W, T))
       count++;
    cin >> T;
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 3212
#include<bits/stdc++.h>
using namespace std;
struct node{
	int location;
	int p,l,r;
	node(){}
};
struct point{
	int id,x,y;
	point(){}
	point(int a,int b,int c):id(a),x(b),y(c){}
	bool operator < (const point &p) const{
		return id<p.id;
	}
};
static const int Max=(int) 1e6;

int n,np;
point p[Max];
node T[Max];

bool cmpx(point a,point b){return a.x<b.x;}
bool cmpy(point a,point b){return a.y<b.y;}

int maketree(int l,int r,int d){
	if (l>=r) return -1;
	int mid=(l+r)/2;
	int t=np++;
	nth_element(p+l,p+mid,p+r,(d%2 ? cmpy : cmpx));
	T[t].location=mid;
	T[t].l=maketree(l,mid,d+1);
	T[t].r=maketree(mid+1,r,d+1);
	return t;
}

void find(int v,int sx,int tx,int sy,int ty,int d,vector<point> &ans){
	int u=T[v].location;
	int x=p[u].x;
	int y=p[u].y;
	if (sx<=x&&x<=tx&&sy<=y&&y<=ty){
		ans.push_back(p[u]);
	}
	if (d%2==0){
		if (T[v].l!=-1){
			if (sx<=x) find(T[v].l,sx,tx,sy,ty,d+1,ans);
		}
		if (T[v].r!=-1){
			if (x<=tx) find(T[v].r,sx,tx,sy,ty,d+1,ans);
		}
	}else{
		if (T[v].l!=-1){
			if (sy<=y) find(T[v].l,sx,tx,sy,ty,d+1,ans);
		}
		if (T[v].r!=-1){
			if(y<=ty) find(T[v].r,sx,tx,sy,ty,d+1,ans);
		}
	}
}

int main(){
	int x,y;cin>>n;
	for(int i=0;i<n;i++){
		scanf("%d%d",&x,&y);
		p[i]=point(i,x,y);
		T[i].l=T[i].r=T[i].p=-1;
	}
	np=0;
	int root=maketree(0,n,0);

	int q;cin>>q;
	int sx,tx,sy,ty;
	vector<point> ans;
	for(int i=1;i<=q;i++){
		scanf("%d%d%d%d",&sx,&tx,&sy,&ty);
		ans.clear();
		find(root,sx,tx,sy,ty,0,ans);
		sort(ans.begin(),ans.end());
		for(int j=0;j<ans.size();j++) printf("%d\n",ans[j].id);
		printf("\n");
	}
}

Measured memory_bytes: 16424
#include<stdio.h>
#define N 100000
int linearSearch(int,int[]);

int q,n;

int main()
{
  int S[N],T[N],i,j,cnt=0;

  scanf("%d",&n);

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

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

  for(i=0;i<q;i++)
    {
      if(linearSearch(T[i],S) == 1)cnt++;
    }

  printf("%d\n",cnt);
  
  return 0;
}

int linearSearch(int key,int S[])
{
  int i=0;

  while(S[i] != key)
    {
      i++;
      if(i == n)return 0;
    }
  return 1;
}



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

int mod = 1000000007;
int64_t large = 9223372036854775807;

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

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<stdio.h>
using namespace std;
#define N 1000
typedef long long ll;


int main(){
    ll a;
    int c=0,i;
    string b;
    cin>>a>>b;
    for(i=0;i<4;i++){
        if(b[i]=='.')
            continue;
        c*=10;
        c+=b[i]-'0';
    }
   
    cout<<a*c/100;
    //printf("%lld\n",a*c+a*d/100);
    
    return 0;
}




Measured memory_bytes: 3592
#import pysnooper
#import numpy
#import os,re,sys,operator
#from collections import Counter,deque
#from operator import itemgetter,mul
#from itertools import accumulate,combinations,groupby,combinations_with_replacement,permutations
from sys import stdin,setrecursionlimit
#from bisect import bisect_left,bisect_right
#from copy import deepcopy
#import heapq
#import math
#import string
#from time import time
#from functools import lru_cache,reduce
#from math import factorial,hypot
#import sys
#from fractions import gcd
setrecursionlimit(10**6)
input=stdin.readline

def main():
    r,g,b,n=map(int,input().split())
    ans=0
    for i in range(n+1):
        for j in range(n+1-i):
            now=(n-i*r-j*g)//b
            if now>=0 and (n-i*r-j*g)%b==0:
                ans+=1
    print(ans)

if __name__=="__main__":
    main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define INF 5000000000
#define INF2 2000000000
using ll=long long;

int main()
{
    ll V,E;cin >> V >>E;
    vector<vector<ll>> dis(V,vector<ll> (V,INF));
    ll u,v,d;
    for (ll i=0;i<E;i++)
    {
        cin >> u >> v >> d;
        dis[u][v]=d;
    }
    bool can=true;
    for (ll i=0;i<V;i++) dis[i][i]=0;
    for (ll k=0;k<V;k++)
    {
        for (ll i=0;i<V;i++)
        {
            for (ll j=0;j<V;j++)
            {
                dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]);
            }
        } 
    }
    for (ll i=0;i<V;i++) if (dis[i][i]<0) can=false;
    if (!can) cout << "NEGATIVE CYCLE" << endl;
    else
    {
        for (ll i=0;i<V;i++)
        {
            for (ll j=0;j<V;j++)
            {
                if (dis[i][j]>=INF2)
                {
                    if (j==V-1) cout << "INF";
                    else cout << "INF ";
                }
                else
                {
                    if (j==V-1) cout << dis[i][j];
                    else  cout << dis[i][j]<< " ";
                }
            }
            cout << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3236
#include <iostream>
#include <string>
using namespace std;
int main() {
    int n, score_t = 0, score_h = 0;
    string taro, hanako;
    cin >> n;
    for(int i = 0; i < n; ++i) {
        cin >> taro >> hanako;
        int jdg = taro.compare(hanako);
        if(jdg > 0) {
            score_t += 3;
        } else if(jdg < 0) {
            score_h += 3;
        } else {
            score_t += 1;
            score_h += 1;
        }
    }
    cout << score_t << " " << score_h << endl;
    return 0;
}


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

using namespace std;
using ll = long long;



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

    for(int i = 0; i < k; i++){
        if(i % 2 == 0){
            a -= (a & 1);
            b += a / 2;
            a /= 2;
        }else{
            b -= (b & 1);
            a += b / 2;
            b /= 2;
        }
    }
    cout << a << " " << b << endl;
}

Measured memory_bytes: 256
import sys


def input():
    return sys.stdin.readline()[:-1]

# N = int(input())
# A = [int(x) for x in input().split()]
# a, b, c = map(int, input().split())
# name1 = str(input())
# alph = {"A": 1, "B": 2, "C": 3, "D": 4, "E": 5}
# b = list(map(lambda x: math.ceil(x/10)*10, a))


s = str(input())
min = 1000
for i in range(len(s)-2):
    num = int(s[i]+s[i+1]+s[i+2])
    if abs(num-753) < min:
        min = abs(num-753)
print(min)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef unsigned long long int ull;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> o_set; 

#define     int                 ll
#define     pb                  push_back
#define     mp                  make_pair
#define     xx                  first
#define     yy                  second    
#define     all(a)              a.begin(),a.end()
#define     vi                  vector<int>
#define     vpi                 vector<pii>
#define     pii                 pair<int, int>
#define     present(DT, val)    (DT.find(val) != DT.end()) //for set and map
#define     cpresent(DT, val)   (find(all(DT),val) != DT.end()) //vectors
#define     input               "/home/pollution/Desktop/WorkSpace/C++/Files/input.txt"
#define     output              "/home/pollution/Desktop/WorkSpace/C++/Files/output1.txt"
#define     error               "/home/pollution/Desktop/WorkSpace/C++/Files/error.txt"
#define     IO()                ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define     INF                 2e18
#define     MOD                 1000000007
#define     clr(x)              memset(x, 0, sizeof(x))
#define     init(x, a)          memset(x, a, sizeof(x))
#define     out(a)              for (auto i: a) cout<<i<<' '; cout<<'\n'
#define     cpy(a,b)            memcpy(a,b,sizeof(b))
#define     is(a)               to_string(a)
#define     ci(a,c)             a-c
#define     debug(i)            cout<<"point :"<<i<<'\n';
#define     setd(val,n)         cout<<fixed<<setprecision(n)<<val<<'\n'


void solve(){
    int n; cin>>n;
    vi a(n);
    for(int i = 0; i < n; ++i) cin>>a[i];
    int ans=1,mn=a[0];
	for(int i = 1; i < n; ++i){
		if(a[i]<=mn){
			mn=a[i];
			ans++;
		}
	}
	cout<<ans<<'\n';
}

signed main() { 
    IO();

    int t=1;
    // cin>>t;
    while(t--) solve();
    return 0; 
} 


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

char s[300009];
int sum[300009];
int change[300009];

int main()
{
	int n, i, j, count = 0, min = 300009;

    scanf("%d", &n);
    getchar();
    scanf("%s", s);
    memset(sum, 0, sizeof(sum));
    memset(change, 0, sizeof(change));
    for (i = 0; i < n; i++)
    {
        if (s[i] == 'E')
            count++;
        sum[i] = count;
    }
    change[0] = sum[n - 1] - sum[0];
    if (min > change[0])
            min = change[0];
    for (i = 1; i < n; i++)
    {
        change[i] =i - sum[i - 1];
        change[i] = change[i] + (sum[n - 1] - sum[i]);
        if (min > change[i])
            min = change[i];
    }
	cout << min;

	return 0;
}

Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int n,m;
	int box[100001];
	int sum;
	int MAX;
	int i;
	while(1){
		cin>>n>>m;
		if(n==0&&m==0)	break;
		sum=0;	
		for(i=0;i<n;i++)	cin>>box[i];
		for(i=0;i<m;i++)	sum+=box[i];
		MAX=sum;
		for(i=m-1;i<n-1;i++){
			// cout<<sum<<" "<<box[i+1]<<" "<<box[i-2]<<endl;
			sum=sum+box[i+1]-box[i-(m-1)];
			// cout<<sum<<endl;
			MAX=max(MAX,sum);
		}
		cout<<MAX<<endl;
	}
	return 0;
}


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

int main() {
	int W, H, x, y, r;
	cin >> W >> H >> x >> y >> r;
	if (x - r >= 0 && x + r <= W && y - r >= 0 && y + r <= H)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <algorithm>

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

	std::vector<int> memos(N, false);
	std::vector<int> digits(N, 0);
	for (int i = 0; i < M; ++i) {
		int s, c;
		std::cin >> s >> c;

		if (memos[s - 1] && (digits[s - 1] != c)) {
			std::cout << "-1" << std::endl;
			return 0;
		}

		digits[s - 1] = c;
		memos[s - 1] = true;
	}

	if ((1 < N) && memos[0] && (digits[0] == 0)) {
		std::cout << "-1" << std::endl;
		return 0;
	}

	if ((1 < N) && !memos[0] && (digits[0] == 0)) {
		digits[0] = 1;
	}

	int ans = 0;
	for (int i = 0; i < N; ++i) {
		ans *= 10;
		ans += digits[i];
	}


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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,a,b;
    scanf("%d",&n);
    if(n==1)
    {
        printf("Hello World");
    }
    else
    {
        scanf("%d%d",&a,&b);
        printf("%d",a+b);
    }
}


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

using namespace std;

int main()
{
   
   string s;
  cin>>s;
  int i;
  for(i=0;i<s.length();++i)
  {
     if(s[i]==',')
         cout<<" ";
    
     else
        cout<<s[i];
  }
  
}

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

#define vi vector<int>
#define vl vector<long>
#define vvi vector<vector<int>>
#define vvl vector<vector<long>>
#define pint pair<int, int>
#define plong pair<long, long>

int main() {
    int N;
    cin>>N;
    vi A(N), B(N), C(N);
    REP(i, 0, N) cin >> A[i];
    REP(i, 0, N) cin >> B[i];
    REP(i, 0, N) cin >> C[i];
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());
    long ans = 0;
    REP(i, 0, N){
        int b = B[i];
        auto a_Itr =lower_bound(A.begin(), A.end(), b);
        auto c_Itr =upper_bound(C.begin(), C.end(), b);
        ans += (long)(a_Itr - A.begin()) * (long)(C.end() - c_Itr);
    }
    cout << ans << endl;
}

Measured memory_bytes: 4556
import java.util.*;

public class Main implements Runnable {

    private static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        // Run with 32MB stack
        Thread thread = new Thread(null, new Main(), "", 32 * 1024 * 1024);
        thread.start();
    }

    @Override
    public void run() {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    static void solve(Scanner scanner) {
        int H = Integer.parseInt(scanner.next());
        int N = Integer.parseInt(scanner.next());
        int[] A = new int[N];
        int[] B = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = Integer.parseInt(scanner.next());
            B[i] = Integer.parseInt(scanner.next());
        }
        
        long dp[][] = new long[N + 1][100_000];
        for (long[] d: dp) {
            Arrays.fill(d, Long.MAX_VALUE / 2);
        }
        dp[0][0] = 0;

        for (int i = 1; i <= N; i++) {
            for (int j = 0; j < 100_000; j++) {
                if (j - A[i - 1] >= 0) {
                    dp[i][j] = Math.min(dp[i - 1][j], dp[i][j - A[i - 1]] + B[i - 1]);
                } else {
                    dp[i][j] = dp[i - 1][j];
                }
            }
        }

        long ans = Integer.MAX_VALUE;
        for (int i = H; i < 100_000; i++) {
            ans = Math.min(ans, dp[N][i]);
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 1006348
#include "bits//stdc++.h"
using namespace std;
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
int wet[100001];
int main() {
	int T, D, L;
	while (cin >> T >> D >> L, T) {
		memset(wet, 0, sizeof(wet));
		for (int i = 1; i <= T; i++) {
			int x;
			cin >> x;
			if (x >= L) {
				wet[i]++;
				if (i + D <= T) wet[i + D]--;
			}
		}
		int ans = 0;
		for (int i = 1; i < T; i++) {
			wet[i] += wet[i - 1];
			if (wet[i] > 0) ans++;
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 3472
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
			String input = s.nextLine();
			if (input.charAt(0) == input.charAt(1) && input.charAt(0) == input.charAt(2)) {
				System.out.println("No");
			} else {
				System.out.println("Yes");
			}


		s.close();

	}

}


Measured memory_bytes: 20564
<?php
fscanf(STDIN, '%d %d', $N, $Y);

$flg=0;
for($i=0;$i<$N+1;$i++){
    for($j=0;$j<$N+1;$j++){
        $k=$N-$i-$j;
        if ((0<=$k) && ($k<=$N) && (10000*$i+5000*$j+1000*$k===$Y)) {
            $flg=1;
            break 2;
        }
    }
}

echo $flg ? sprintf("%d %d %d", $i, $j, $k) : '-1 -1 -1';

Measured memory_bytes: 4604
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n, k;

    cin >> n >> k;
    int t = (n-1)*(n-2)/2;
    if(k > t){
        cout <<"-1\n";
    }
    else {
        vector <pair <int,int> > edges;
        for(int i = 1; i <= n; ++i){
            for(int j = i+1; j <= n; ++j){
                edges.push_back({i,j});
            }
        }
        int w = n - 1 + t - k;
        //cerr << t << ' ' << k << ' ' << t-k << '\n';
        cout << w << '\n';
        for(int i = 0; i < w; ++i){
            cout << edges[i].first << ' ' << edges[i].second << '\n';
        }
    }
}

Measured memory_bytes: 384
#import pysnooper
#import numpy
#import os,re,sys,operator
#from collections import Counter,deque
#from operator import itemgetter,mul
#from itertools import accumulate,combinations,groupby,combinations_with_replacement,permutations
from sys import stdin,setrecursionlimit
#from bisect import bisect_left,bisect_right
#from copy import deepcopy
#import heapq
#import math
#import string
#from time import time
#from functools import lru_cache,reduce
#from math import factorial,hypot
#import sys
#from fractions import gcd
setrecursionlimit(10**6+1)
input=stdin.readline

x=int(input().rstrip())
ans=0
ans+=(x//500)*1000
x%=500
print(ans+(x//5)*5)

Measured memory_bytes: 2940
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,s,f) for(int i=s;i<f;i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int digit(int x) {
	int cnt = 0;
	while (x > 0) {
		cnt += x % 10;
		x /= 10;
	}
	return cnt;
}
int read() {
	int tmp;
	cin >> tmp;
	return tmp;
}
int xor128() {
	static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	int t = (x xor (x << 11));
	x = y; y = z; z = w;
	return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}
map<int, int> factaring(int x) {
	map<int, int>ans;
	int now = 2;
	while (now * now <= x) {
		if (x % now == 0) {
			x /= now;
			ans[now]++;
		}
		else now++;
	}
	if (x != 1) ans[x]++;
	return ans;
}

const int MAX = 510000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int Com(int n, int k) {
	int x=1, y=1;
	rep(i, k) {
		y *= i + 1;
		y %= MOD;
	}
	for (int i = n - k + 1; i <= n; i++) {
		x *= i;
		x %= MOD;
	}
	return x * modinv(y, MOD) % MOD;
}

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

	return 0;
}

Measured memory_bytes: 256
# ARC 134
N = int(input())
a_list = list(map(int, input().split()))
b_list = [0] * N

res_set = set([])
for i in list(range(N))[::-1]:
    if a_list[i] != sum(b_list[i::i+1])%2:
        res_set.add(i+1)
        b_list[i] = 1

print(len(res_set))
if len(res_set) >0:
    print(*res_set)




Measured memory_bytes: 23608
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dd;
void solve()
{
		string s, t;
		cin >> s;
		cin >> t;
		int count = 0;
		if(s[0] == t[0])
		count++;
		if(s[1] == t[1])
		count++;
		if(s[2] == t[2])
		count++;
		
		cout << count;
}

int main()
{
		ios::sync_with_stdio(false);
		cin.tie(nullptr);
		ll t = 1;
	//	cin >> t
		while(t--)
		{
			solve();
		}
	return 0;
}


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

#import numpy as np
import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, functools, random
from collections import deque, defaultdict, Counter
#from heapq import heappush, heappop
from itertools import permutations, combinations, product, accumulate, groupby
from bisect import bisect_left, bisect_right, insort_left, insort_right
#from operator import itemgetter as ig

#sys.setrecursionlimit(10 ** 7)
#nf = 10 ** 20
#INF = float("INF")
#mod = 10 ** 9 + 7

'''
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]
ddn9 = ddn + [(0, 0)]
for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:

def wi(): return list(map(int, sys.stdin.readline().split()))
def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]  # WideIntPoint
def ws(): return sys.stdin.readline().split()
def si(): return int(sys.stdin.readline())  # SingleInt
def ss(): return input()
def hi(n): return [si() for _ in range(n)]
def hs(n): return [ss() for _ in range(n)]  # HeightString
def s_list(): return list(input())
def mi(n): return [wi() for _ in range(n)]  # MatrixInt
def mip(n): return [wip() for _ in range(n)]
def ms(n): return [ws() for _ in range(n)]
def num_grid(n): return [[int(i) for i in sys.stdin.readline().split()[0]] for _ in range(n)]  # NumberGrid
def grid(n): return [s_list() for _ in range(n)]
# 深さ優先探索
def dfs(G, v):
    global time, first_order,seen,last_order
    time += 1
    first_order[v-1] = time   #　行きがけ

    seen[v-1] = True # v を訪問済みにする
    # v から行ける各頂点 next_v について
    for next_v in G[v]:
        if seen[next_v-1]:
            continue
        dfs(G, next_v)

    time += 1
    last_order[v - 1] = time  # 帰りがけ
'''

def main():

    N = int(input())
    a = [0] + list(map(int, input().split()))
    a = list(accumulate(a))
    c = Counter(a)
    ans = 0
    for i in c.values():
        ans += i*(i-1)//2
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 120352
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){
    int n; cin>>n; 
    int a[n+1];
    for (int i=1;i<=n;i++) cin >> a[i]; 
    sort(a+1,a+n+1); 
    ld res=a[1];
    for (int i=2;i<=n;i++){
       res= (res+(ld)a[i])/2.0;
    }
    cout.precision(20);
    cout << res << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3800
n,m,c=map(int,input().split())
b=list(map(int,input().split()))

cnt=0
for _ in range(n):
    sum=c
    a=list(map(int,input().split()))
    for i in range(m):
        sum+=a[i]*b[i]

    if sum>0:
        cnt+=1

print(cnt)


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

int main(){
	string s;
	cin >> s;

	int ans = 0;
	for(int i =0; i < 4; i++){
		if(s[i] == '+') ans++;
		else ans--;
	}

	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

		Scanner in = new Scanner(System.in);
		long n = in.nextLong();
		long x = in.nextLong();

		if (x * 2 > n) {
			x = n - x;
		}

		System.out.println(3 * (n - gcd(n, x)));
		in.close();

	}

	static long gcd(long a, long b) {

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

}

Measured memory_bytes: 9428
#include <bits/stdc++.h>
using namespace std;
typedef vector<int64_t> vi;

vi par(100010), sz(100010);

// 初期化
void init(int64_t n){
  for(int i=0; i<n; i++){
      par[i] = i; sz[i] = 1;
  }
}

// 頂点xに対応する木の根を見つける
int root(int x){
  if (par[x] == x) return x;
  else return par[x] = root(par[x]);
}

// 頂点xの木と頂点yの木を統合
void unite(int x, int y){
  x = root(x); y = root(y);
  
  if (x != y){
    par[x] = y; sz[y] += sz[x];
  }
}

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

    vector<int> A(100010), B(100010);
    for(int i=0; i<M; i++) cin >> A[i] >> B[i];
    reverse(A.begin(), A.begin()+M);
    reverse(B.begin(), B.begin()+M);

    vector<int64_t> ans = { N*(N-1)/2 };
    for(int i=0; i<M; i++){
        int x = root(A[i]), y = root(B[i]);
  
        if(x == y){
          ans.push_back(ans[i]); 
        } else {
          ans.push_back(ans[i]-sz[x]*sz[y]);
          unite(A[i], B[i]);
        }

    }

    reverse(ans.begin(), ans.end());
    for(int i=1; i<ans.size(); i++){
        cout << ans[i] << endl;
    }
}

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

int main()
{
    unsigned long long A, B, K;
    cin >> A >> B >> K;
    if(K <= A)
    {
        cout << (A - K);
        cout << " ";
        cout << B;
    }
    else
    {
        unsigned long long nokori = K - A;
        if(B >= nokori)
        {
            cout << 0;
            cout << " ";
            cout << B - nokori;
        }
        else
        {
            cout << "0 0" << endl;
        }
        
    }
}

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

void init(){
    int p = 0;
    prime.resize(n+1);
    vector<bool> is_prime(n+1,true);
    is_prime[0] = is_prime[1] = false;
    for(int i = 2 ; i <= n ; i++){
        if(is_prime[i]){
            prime[p++] = i;
            for(int j = 2*i; j <= n; j += i){
                is_prime[j] = false;
            }
        }
    }
}

int main(){
  int N;
  cin >> N;
  init();
  for(auto ans : prime) {
    if(N == 0)break;
    if (ans % 5 == 1) {
      cout << ans << " ";
      N--;
    }
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include<string>
#include<cmath>
#include<stack>
#include <vector>
#include<queue>
#include <random>
#include <cstdint>
#include <bitset>
#include <iomanip>
using namespace std;

int main() {
	int n, m, a[100000];
	bool flg[100000];
	fill(flg, flg + 100000, false);
	fill(a, a + 100000, 1);
	flg[0] = true;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int x, y;
		cin >> x >> y;
		x--;
		y--;
		a[x]--;
		a[y]++;
		if (flg[x]) {
			flg[y] = true;
			if (!a[x]) flg[x] = false;
		}
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		
		if (flg[i]) ans++;
	}
	cout << ans << endl;
	return 0;

}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,x,a,sum=0;
    scanf("%d %d",&n,&x);

    vector<int> m(0);
    for(int i=0;i<n;i++){
        cin>>a;
        sum += a;
        m.push_back(a);
    }
    sort(m.begin(),m.end());

    if(x-sum >= m[0])
        printf("%d\n",n+(x-sum)/m[0]);
    else printf("%d\n",n);
}



Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

using namespace std;

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

	int A, B;
	cin >> A >> B;

	cout << max({ A + B, A - B, A * B });

	return 0;
}


Measured memory_bytes: 3608
#include <cstdio>

int n, m, L;

struct Edge {
	int u, v, w;
	Edge(int _u = 0, int _v = 0, int _w = 0) {
		u = _u, v = _v, w = _w;
	}
} e[65];

void add(int u, int v, int w) {
	e[++m] = Edge(u, v, w);
}
int main() {
	scanf("%d", &L);
	for (; (1 << n) <= L; n++);
	for (int i = 1; i < n; i++) {
		add(i, i + 1, 1 << (i - 1));
		add(i, i + 1, 0);
	}
	int v = 1 << (n - 1);
	for (int i = n - 1; i >= 1; i--) {
		if (v + (1 << (i - 1)) - 1 < L) {
			add(i, n, v);
			v += 1 << (i - 1);
		}
	}
	printf("%d %d\n", n, m);
	for (int i = 1; i <= m; i++) {
		printf("%d %d %d\n", e[i].u, e[i].v, e[i].w);
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define int long long
string s;
int a[11],i,len,n,ans,x,t;
main(){
	cin>>s,len=s.size()-1,n=1<<len;
	for (i=0;i^n;++i){
		x=0,t=i<<1;
		for (register int j=0;j<=len;++j){
			x=x*10+(s[j]^48),t>>=1;
			if (t&1) ans+=x,x=0;
		}ans+=x;
	}cout<<ans;
}

Measured memory_bytes: 256
<?php

ini_set('error_reporting', E_ALL & ~E_NOTICE & ~E_WARNING);
ini_set('display_errors', 'Off');

// define('DEBUG', true);
define('DEBUG', false);

fscanf(STDIN, "%d", $N);
$a = explode(" ", trim(fgets(STDIN)));

$odd = $even = $half = 0;

for ($i = 0; $i < $N; $i++) {
    switch ($a[$i] % 4) {
        case 1:
            $odd++;
            break;
        case 0:
            $even++;
            break;
        case 3:
            $odd++;
            break;
        case 2:
            $half++;
            break;
    }
}

if ($half == 0) {
    if ($odd <= $even + 1) {
        echo "Yes\n";
    } else {
        echo "No\n";
    }
} else {
    if ($odd <= $even) {
        echo "Yes\n";
    } else {
        echo "No\n";
    }
}


Measured memory_bytes: 12792
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
typedef long long ll;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define rrep(i,n,a) for(int i=n;i>=a;i--)
#define FOR(i,n) for(int i=0;i<n;i++)
#define all(s) s.begin(),s.end()
#define lla(s) s.rbegin(),s.rend()
#define pcnt(b) __builtin_popcount(b)
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const ll INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,c,k;
    cin>>n>>c>>k;
    vector<int>t(n);
    rep(i,0,n){
        cin>>t[i];
    }
    sort(all(t));
    int tmp = t[0] + k,ans = 1,bus = 0;
    rep(i,0,n){
        if(bus<c&&t[i]<=tmp){bus++;}
        else{
            bus=1;tmp=t[i]+k;ans++;
        }
    }
    cout<<ans<<endl;
}


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

int main()
{
	int w,h,x,y,r;
	cin >>w>>h>>x>>y>>r;

	if (r > x || r > y || r > w - x || r > h - y) {
		cout << "No" << endl;
	}
	else cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 3080
//inlclude before define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
#include<assert.h>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> P1;
typedef long long int ll;

//define
#define INF 1e9
#define NUM 1000000007
#define all(x) begin(x),end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);i++)
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))

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


ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a * (b / g);
}

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

	vector<ll> a(n);
	rep(i, n) cin >> a[i];

	ll rec = 1LL;
	sort(all(a));
	rep(i, n) {
		rec = lcm(rec, a[i]);
		//cout << rec << endl;
	}
	//if (a[n - 1] == 1e18)cout << 1000000000000000000 << endl;
	cout << rec << endl;
}


Measured memory_bytes: 256
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        input_inner!{$s, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($exp_input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                let start = std::time::Instant::now();
                let input = solve($exp_input);
                let end = start.elapsed();
                assert_eq!(input, $output, "{}.{:03}", end.as_secs(), end.subsec_millis());
                assert!(end.as_secs() <= 2, "expected_sec: {}sec, actual_sec: {}sec", 2, end.as_secs());
                assert!(end.as_secs() <= 1, "expected_sec: {}sec, actual_sec: {}sec", 1, end.as_secs());
                assert!(end.subsec_millis() <= 10, "expected_ms: {}ms, actual_ms: {}ms", 10, end.subsec_millis());
                assert!(end.subsec_millis() <= 2, "expected_ms: {}ms, actual_ms: {}ms", 2, end.subsec_millis());
            )*
        }
    };
}

test! {
r#""# => r#""#,
}

fn solve(src: &str) -> String {
    let mut src_iter = src.split_whitespace();
    input! {
        source = src_iter,
        s: String, t: String,
        mut a: usize, mut b: usize,
        u: String,
    }

    if u == s {
        a -= 1;
    } else {
        b -= 1;
    }

    format!("{} {}", a, b)
}

Measured memory_bytes: 4352