akhauriyash/Code-Regression huggingface dataset:
/// You just can't beat the person who never gives up
/// ICPC next year

#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include<bits/stdc++.h>
using namespace std ;
const int N = 1e5+5 ;

string s ;
int main(){
    cin >> s ;
    if(s.size()%2) return cout << "No",0;
    for(int i=0;i<s.size();i+=2){
        if(s[i]=='h'&&s[i+1]=='i') continue ;
        return cout << "No",0;
    }
    cout << "Yes";
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100005
#define NIL -1
struct Node_struct{int p, l, r, sib;}; /*p: 親(parent), l: 一番左の子(left child), r:右の兄弟(right sibling)*/
typedef struct Node_struct Node;
Node T[MAX];
int D[MAX];
int H[MAX];

void print(int u){
  int i, c, degree=0;
  if(T[u].l!=NIL) degree++;
  if(T[u].r!=NIL) degree++;
  printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ", u, T[u].p, T[u].sib, degree, D[u], H[u]);

  if(T[u].p==NIL) printf("root\n");
  else if(T[u].l==NIL && T[u].r==NIL) printf("leaf\n");
  else printf("internal node\n");
}

void calcDepth(int u, int p){
  D[u] = p;
  //printf("id=%d left=%d right=%d\n",u,T[u].l,T[u].r);
  if(T[u].l!=NIL) calcDepth(T[u].l, p+1);
  if(T[u].r!=NIL) calcDepth(T[u].r, p+1);
}

int calcHeight(int u, int p){
    int left, right;
    if(T[u].l!=NIL) left = calcHeight(T[u].l, p+1);
    else left = p;
    if(T[u].r!=NIL) right = calcHeight(T[u].r, p+1);
    else right = p;
    if(left>right) return left;
    else return right;
}

int main(){
  int i;
  int n;
  int id, left, right;
  int root = NIL;
  scanf("%d", &n);
  for(i=0; i<n; i++) T[i].p = T[i].l = T[i].r = T[i].sib = NIL;

  for(i=0; i<n; i++){
    scanf("%d", &id);
    scanf("%d%d", &left,&right);
    T[left].p = id;
    T[right].p = id;
    T[id].l = left; //idの一番左の子 (the most left child of id)
    T[id].r = right; //左の兄弟に繋げる (connect to left sibling)
    T[left].sib = right;
    T[right].sib = left;
  }

  //根を求める (find the root)
  for(i=0; i<n; i++){
    if(T[i].p == -1) root = i;
  }

  //それぞれのノードの深さを求める (find depth of each node)
  calcDepth(root, 0);

  //出力 (output)
  for(i=0; i<n; i++){
      H[i] = calcHeight(i, 0);
      print(i);
  }

  return 0;
}



Measured memory_bytes: 2108
package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

var scanner = bufio.NewScanner(os.Stdin)

func scanLine() []string {
	var s []string
	scanner.Scan()
	for _, v := range strings.Split(scanner.Text(), "") {
		s = append(s, v)
	}
	return s
}

func main() {
	s := scanLine()
	t := scanLine()

	result := 0
	for i, v := range s {
		if v == t[i] {
			result++
		}
	}
	fmt.Println(result)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using u64 = uint64_t;

int main() {

	u64 N, A, B;
	cin >> N >> A >> B;
	
	u64 AB = A + B;
	u64 ans = (N / AB) * A;
	
	//cout << ans << endl;
	
	u64 rest = N - (N / AB) * AB;
	//cout << rest << endl;
	
	ans += rest;
	
	if(rest > A) ans -= (rest - A);
	
	cout << ans;
	
	return 0;
}


Measured memory_bytes: 256
class dice:
    def __init__(self,label):
        self.top, self.front, self.right, self.left, self.rear, self.bottom \
                = label
   
    def roll(self,op):
        if   op=='N': self.top, self.front, self.bottom, self.rear = \
                                self.front, self.bottom, self.rear , self.top
        elif op=='E': self.top, self.left , self.bottom, self.right = \
                                self.left , self.bottom, self.right, self.top
        elif op=='W': self.top, self.right, self.bottom, self.left = \
                                self.right, self.bottom, self.left , self.top
        elif op=='S': self.top, self.rear , self.bottom, self.front = \
                                self.rear , self.bottom, self.front, self.top
   
    def print_top(self): print(self.top)
    def print_right(self): print(self.right)
   
    def get_label(self):
        return [self.top, self.front, self.right, self.left, self.rear, self.bottom]
    
label = list(map(int,input().split()))
d0 = dice(label)
d1 = list(map(int,input().split()))
for op in 'EEENEEENEEESEEESEEENEEEN':
    if d0.get_label() == d1:
        print('Yes')
        break
    d0.roll(op)
else:
    print('No')


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


int main()
{
    long long int n, b = 1, ans = 1;
    cin >> n;
    vector<long long int> a(1000,0);
    for(long long int i = 2;i <= n;i++){
        long long int rem = i;
        for(long long int j = 2;1 < rem;j++){
            while(rem % j == 0){
                a[j]++;
                rem /= j;
            }
        }
    }

    long long int p = 1e9 + 7;

    for(long long int i = 0;i < 1000;i++){
        ans = ans * (a[i] + 1) % p;
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 256
import fractions as fr
A,B = map(int,input().split())
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
p = fr.gcd(A,B)

ans = len(set(prime_factorize(p)))+1
print(ans)

Measured memory_bytes: 5304
using System;
using System.Linq;
using System.Collections.Generic;

namespace agc030_a
{
    class Program
    {
        static void Main(string[] args)
        {
            var text = Console.ReadLine();
            var n = int.Parse(text);

            var c = 0;
            for(int i = 1; i <= n; i++){

                var len = i.ToString().Length % 2;
                if (len == 1){
                    c++;
                }
            }

            Console.WriteLine(c);
        }
    }

    class hero
    {
        public int index;
        public int battle;

    }
}


Measured memory_bytes: 13140
//(・ω・)
#include <stdio.h>
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, atoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip> //setprecision
#include <limits>
#include <sstream> //istringstream
#include <stdlib.h>
#include <list>
#include <iterator>//std::advance()
using namespace std;

int main(){
    vector<int> a(3);
    cin >> a[0] >> a[1] >> a[2];
    sort(a.begin(),a.end());
    a[0]=a[2]-a[0];
    a[1]=a[2]-a[1];
    if((a[0]-a[1])%2==0){
        cout << a[1]+(a[0]-a[1])/2 << endl;
    }
    else{
        cout << a[1]+1+(a[0]-a[1]+1)/2 << endl;
    }
   
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

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

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

signed main() {
  ll N;
  cin >> N;
  string P, Q;

  string O;
  rep(i, N) {
    O += to_string(i + 1);
  }

  rep(i, N) {
    string s;
    cin >> s;
    P += s;
  }

  rep(i, N) {
    string s;
    cin >> s;
    Q += s;
  }

  ll numP = 0;
  ll numQ = 0;
  ll count = 1;
  do {
    if (O == P) {
      numP = count;
    }
    if (O == Q) {
      numQ = count;
    }

    count++;
  } while (next_permutation(ALL(O)));
  COUT(abs(numP - numQ));

  return 0;
}

Measured memory_bytes: 256
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b;
  cin >> a >> b;
  if(a % 3 == 0 || b % 3 == 0 || (a+b) % 3 == 0) cout << "Possible" << endl;
  else cout << "Impossible" << endl;
  return 0;
}
//templete by private_yusuke

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

struct Node {
    Node* parent;
    Node* left;
    Node* right;
    int key;
};

Node * NIL = NULL;
Node * ROOT = NIL;

void Inorder (Node* n) {
    if (n == NIL) return;
    Inorder(n->left);
    printf(" %d", n->key);
    Inorder(n->right);
}
void Preorder (Node* n) {
    if (n == NIL) return;
    printf(" %d", n->key);
    Preorder(n->left);
    Preorder(n->right);
}

void insert (Node* n) {
    Node * r = ROOT;
    Node * t;
    while (r != NIL) {
        t = r;
        if (n->key < r->key) {
            r = r->left;
        }
        else {
            r = r->right;
        }
    }
    n->parent = t;

    if (ROOT == NIL) {
        ROOT = n;
    }
    else if(n->key < t->key) {
        t->left = n;
    }
    else {
        t->right = n;
    }
}

int main() {
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        char s[100];
        scanf("%s", s);
        if (s[0] == 'i') {
            int key;
            scanf("%d", &key);
            Node* n = (Node *) malloc(sizeof(Node));
            n->key = key;
            n->parent = n->left = n->right = NIL;
            insert(n);
        }
        else if (s[0] == 'p') {
            Inorder(ROOT);
            printf("\n");
            Preorder(ROOT);
            printf("\n");
        }
    }

}

Measured memory_bytes: 26120
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


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

    string S, T;
    cin >> S;
    cin >> T;

    int n = S.length();
    int m = T.length();

    int res = n;
    for (int i = 0; i + m <= n; ++i) {
        int diffs = 0;
        for (int j = 0; j < m; ++j) {
            if (S[i + j] != T[j]) {
                ++diffs;
            }
        }
        res = min(res, diffs);
    }

    cout << res << '\n';
    return 0;
}

Measured memory_bytes: 3668
#include<bits/stdc++.h>
using namespace std;
int N,A,B;
int main()
{
	while(cin>>N>>A>>B)
	{
		long long int sum=0;
		for(int i=1;i<=N;i++)
		{
			if(i<10)
			{
				if(i>=A&&i<=B)
				{
					sum+=i;
				}
			}
			else
			{
				long long int sum2=0,j=i;
				while(j)
				{
					sum2+=j%10;
					j/=10; 
				}
				if(sum2>=A&&sum2<=B)
				{
					sum+=i;
				}
			}
		}
		cout<<sum<<endl; 
		
	}
















}



Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    s = input()
    ans = s.count("+") - s.count("-")
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 61812
#include <bits/stdc++.h>
#include <algorithm>
#define MIN(a,b)  (a<b?a:b)
#define MAX(a,b)  (a>b?a:b)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230

//BIT operation
#define SET_BIT  (a, x)   (a |= ((1<<x)))
#define CLEAR_BIT(a, x)   (a &= (~(1<<x)))
#define IS_SET   (a, x)   ((a>>x) & 1)
int modifyBit(int n, int p, bool b)
{
    int mask = 1 << p;
    return (n & ~mask) | ((b << p) & mask);
}

using namespace std;
typedef unsigned long long ull;
typedef long double ld;
//TODO : pair , string, priority_queue, set, map, sort, algorithm 

int main(int argc, char* argv[])
{
  int X;
  cin >>X;
 int  max = 360;
 if((360%X)==0)
 {
	 cout << 360/X;
	 return 0;
 }

  do
    {
        if (max % 360 == 0 && max % X == 0)
        {
            
            break;
        }
        else
            ++max;
    } while (true);
	cout <<  max/X;
  return 0;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,M;
set<int> E[101010];
ll sum;
int D[101010],RD,SP[101010];
int U,V;


int dfs(int cur,int pre,int type) {
	int ret=type+SP[cur];
	FORR(r,E[cur]) if(r!=pre) ret += dfs(r,cur,-type);
	sum += abs(ret);
	return ret;
}
void dfs2(int cur,int pre,int d) {
	D[cur]=d;
	FORR(r,E[cur]) if(r!=pre) {
		
		if(D[r]>=0) {
			if(RD==0) U=cur, V=r, RD=d+1-D[r];
		}
		else dfs2(r,cur,d+1);
	}
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M;
	FOR(i,M) {
		cin>>x>>y;
		E[x-1].insert(y-1);
		E[y-1].insert(x-1);
	}
	
	if(M==N-1) {
		x = dfs(0,-1,1);
		if(x!=0) sum=-1;
	}
	else {
		MINUS(D);
		dfs2(0,-1,0);
		E[U].erase(V);
		E[V].erase(U);
		
		if(RD%2==1) {
			x = dfs(U,-1,1);
			if(abs(x)%2==1) return _P("-1\n");
			sum = abs(x)/2;
			SP[U]-=x/2;
			SP[V]-=x/2;
			dfs(U,-1,1);
		}
		else {
			x = dfs(U,-1,1);
			ll tsum=sum;
			if(x) return _P("-1\n");
			
			ll L=-101010,R=101010;
			while(R-L>5) {
				int M1=(2*L+R)/3;
				int M2=(L+R*2)/3;
				sum=abs(M1);
				SP[U]=M1;
				SP[V]=-M1;
				dfs(U,-1,1);
				ll sum1=sum;
				sum=abs(M2);
				SP[U]=M2;
				SP[V]=-M2;
				dfs(U,-1,1);
				ll sum2=sum;
				
				if(sum1<sum2) R=M2;
				if(sum1>sum2) L=M1;
				if(sum1==sum2) L=M1,R=M2;
			}
			for(x=L;x<=R;x++) {
				sum=abs(x);
				SP[U]=x;
				SP[V]=-x;
				dfs(U,-1,1);
				tsum=min(tsum,sum);
			}
			sum=tsum;
		}
		
	}
	cout<<sum<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 20992
s = input()
K = int(input())

s_set = set()

for i in range(len(s)):
    sub_s = s[i]
    s_set.add(sub_s)
    for j in range(i+1, len(s)):
        sub_s += s[j]
        s_set.add(sub_s)
        if len(sub_s) == 5:
            break


print(sorted(s_set)[K-1])

        


Measured memory_bytes: 4556
from itertools import product
import numpy as np


def solve(string):
    n, *fp = map(int, string.split())
    f = np.asarray(fp[:10 * n]).reshape((n, 10))
    p = fp[10 * n:]
    ans = -n * 10**7
    for o in product([0, 1], repeat=10):
        if sum(o) == 0:
            continue
        tmp = np.dot(f, np.asanyarray(o).T)
        ans = max(ans, sum([p[11 * i + t] for i, t in enumerate(tmp)]))
    return str(ans)


if __name__ == '__main__':
    n = int(input())
    print(solve('{}\n'.format(n) + '\n'.join([input() for _ in range(2 * n)])))


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

/*==============変数宣言==============*/
int N;
const int M = 26;
int n;
int m = M;
const int def = 1000000;

int c[30];
int s[400][30];

void input(){
	scanf("%d", &N);
	n = N;

	for(int i = 0;i < M;i++) scanf("%d", &c[i]);

	for(int i = 0;i < N;i++)
		for(int j = 0;j < M;j++)
			scanf("%d", &s[i][j]);
	
	return;
}

/*================関数================*/
struct RandomNumberGenerator {
  mt19937 mt;

  RandomNumberGenerator() : mt(chrono::steady_clock::now().time_since_epoch().count()) {}

  int operator()(int a, int b) { // [a, b)
    uniform_int_distribution< int > dist(a, b - 1);
    return dist(mt);
  }

  int operator()(int b) { // [0, b)
    return (*this)(0, b);
  }
};

struct Timer {
  chrono::high_resolution_clock::time_point st;

  Timer() { reset(); }

  void reset() {
    st = chrono::high_resolution_clock::now();
  }

  chrono::milliseconds::rep get() {
    auto ed = chrono::high_resolution_clock::now();
    return chrono::duration_cast< chrono::milliseconds >(ed - st).count();
  }
};

Timer timer;
RandomNumberGenerator rnd;
/*====================================*/



void init(){
	input();
	return;
}


void output(short ans[]){
	for(int i = 0;i < n;i++){
		printf("%d\n", ans[i]+1);
	}
}

int sum(int i){
	return (i*(i+1))/2;
}

int getScore(short a[]){
	int last[30] = {};
	int ans = 0;
	for(int i = 0;i < n;i++){
		ans += s[i][a[i]]; 
		ans -= c[a[i]] * sum(i-last[a[i]]);
		last[a[i]] = i+1;
	}
	for(int j = 0;j < m;j++){
		ans -= c[j] * sum(n-last[j]);
	}
	return ans;
}

int main(){
	init();

	short now[365];
	short ans[365]; 

	for(int i = 0;i < n;i++){
		ans[i] = now[i] = rnd(26); 
	}

	int ans_score = getScore(ans);

	const int fin = 1990;
	const double C = fin*1000.0;

	int now_time = 0;
	int AS = ans_score;
	short ANS[365];
	while((now_time = timer.get()) < fin){
		int idx = rnd(365);
		int old = now[idx];
		int nxt = rnd(26);
		now[idx] = nxt;
		int now_score = getScore(now);

		double r = rnd(100000)/100000.0;

		double line = (fin-now_time)/C; 

		if(ans_score <= now_score || line > r){
			ans[idx] = nxt;
			ans_score = now_score;
			if(AS < ans_score){
				memcpy(ANS, ans, sizeof(ans));
				AS = ans_score;
				//cerr << AS << endl;
			}
		}else{
			now[idx] = old; 
		}
	}

	output(ANS);

	return 0;
}

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

int main() {
	int n, k;
	cin >> n >> k;
	long long cnt = 0;
	for(int i = 1; i <= n; i++) {
		if(i % k == k / 2) {
			cnt++;
		}
	}
	cnt = cnt * cnt * cnt;
	long long ans = n / k;
	if(k % 2) {
        cout << ans * ans * ans;
	}
	else cout << cnt + ans * ans * ans;
}


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

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
#include <complex>
inline double sq(double x){ return x * x; }
typedef complex<double> Point;
vector<Point> cross(Point p1, double r1, Point p2, double r2){
  vector<Point> res;
  double d = abs(p2 - p1);
  double a = arg(p2 - p1);
  if(d < abs(r1 - r2) || d > r1 + r2) return res;
  double th = acos((sq(d) + sq(r1) - sq(r2)) / (2 * d * r1));
  Point pp(r1 * cos(a + th), r1 * sin(a + th));
  Point pm(r1 * cos(a - th), r1 * sin(a - th));
  res.push_back(pp + p1);
  res.push_back(pm + p1);
  return res;
}

bool ok(vector<Point>& p, vector<double>& r, Point c){
  REP(i, p.size()){
    if(abs(p[i] - c) > r[i] + EPS) return false;
  }
  return true;
}

int main(){
  int N;
  while(cin>>N && N){
    double x[100], y[100], l[100];
    REP(i, N) cin>>x[i]>>y[i]>>l[i];
    vector<Point> p(N);
    REP(i, N) p[i] = Point(x[i], y[i]);
    double lb = 0, ub = 1000000;
    REP(_, 100){
      double mid_is_ok = false;
      double mid = (ub + lb) / 2;
      vector<Point> cand = p;
      vector<double> r(N);
      REP(i, N) r[i] = l[i] * mid;
      REP(i, N) FOR(j, i + 1, N){
        vector<Point> v = cross(p[i], r[i], p[j], r[j]);
        cand.insert(cand.end(), v.begin(), v.end());
      }
      REP(i, cand.size()) if(ok(p, r, cand[i])) mid_is_ok = true;
      if(mid_is_ok){
        ub = mid;
      }else{
        lb = mid;
      }
    }
    printf("%.8lf\n", ub);
  }
  return 0;
}

Measured memory_bytes: 1448
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,q,a,b,tot = 0;
    cin>>n>>m>>q;
    vector<int> v[n+5];
    vector<int> ::iterator it;
    for(int i=0; i<m; i++)
    {
        cin>>a>>b;
        v[b].push_back(a);
    }
    for(int i=1; i<=n; i++)
    {
        sort(v[i].begin(),v[i].end());
    }
    for(int i=0; i<q; i++)
    {
        cin>>a>>b;
        for(int j=a; j<=b; j++)
        {
           it = lower_bound(v[j].begin(), v[j].end(), a);

           //cout<<it-v[j].begin()<<endl;
           tot += v[j].size() - (it-v[j].begin());
        }
        cout<<tot<<endl;
        tot = 0;
    }
    return 0;
}


Measured memory_bytes: 2176
n,m = map(int,input().split())
wa = [0]*n
flag = [False]*n
count = 0
for i in range(m):
  p,s = input().split()
  p = int(p)
  if s=='AC' and flag[p-1]==False:
    count += 1
    flag[p-1] = True
  if s=='WA' and flag[p-1]==False:
    wa[p-1] += 1
for i in range(n):
  if flag[i]==False: wa[i] = 0
print(count,' ',sum(wa))

Measured memory_bytes: 4596
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		long n = sc.nextLong();
		long x = n;
		long y = n;
		
		for(long i=1;i<(long)Math.sqrt(n)+1;i++){
		    if(n%i==0){
		        if(i+(n/i)<x+y){
		            x = i;
		            y = n/x;
		        }
		    }
		}

		long ans = x+y-2;

        System.out.println(ans);
	}
}


Measured memory_bytes: 35764
n=int(input())
x=input()

xre = x[::-1]

cou = x.count('1')

if cou == 0:
    for _ in range(n):
        print(1)
    exit()

if cou == 1:
    for i in range(n):
        if i == n-1 and x[i] == '0':
            print(2)
        elif  x[i] == '0' and x[n-1] == '1':
            print(2)
        elif  x[i] == '0' and x[n-1] == '0':
            print(1)
        else:
            print(0)
    exit()

basepl = int(x, 2) % (cou+1)
basemi = int(x, 2) % (cou-1)

li = [0]*n
pl = 1
mi = 1


for i in range(n):
    if xre[i] == '0':
        li[i] = (basepl + pl)  % (cou+1)
    else:
        li[i] = (basemi - mi)  % (cou-1)
    mi = (mi * 2) % (cou-1)
    pl = (pl * 2) % (cou+1)

def f(n):
    m = n
    k = 1
    while m > 0:
        co = str(bin(m)).count('1')
        m = m % co
        k +=1
    return k


for x in li[::-1]:
    print(f(x))


Measured memory_bytes: 18968
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <iomanip>

using namespace std;

#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL); 
#define endl "\n"

typedef long long int  ll;
typedef unsigned long long int ull;


int main()
{
	FAST;
	string str[101];

	int n,l;
	cin >> n >> l;
	for(int i=0 ; i<n ; i++)
	{
		cin >> str[i];
	}

	sort(str , str+n);
	
	for(int i=0 ; i<n ; i++)
		cout << str[i];

	return 0;
}

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

int main() {
  int n, m; cin >> n >> m;
  
  int min = 0;
  int max = n;
  
  for(int i = 0; i < m; i++) {
  	int l,r; cin >> l >> r;
    if(min < l) min = l;
    if(max > r) max = r;
  }
  int ans = max - min + 1;
  if(max < min) ans = 0;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3600
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

typedef unsigned int ui;

int main()
{
	ui n;
	while (scanf("%d", &n) && n){
		ui sum = 0;
		for (ui i = 0; i < n; i++){
			ui t;
			scanf("%d", &t);
			sum += t;
		}
		vector<ui> j(n - 1);
		for (ui i = 1; i < n; i++){
			scanf("%d", &j[i - 1]);
		}
		
		sort(j.begin(), j.end());
		
		ui ans = sum * n;
		
		for (ui i = n - 1; i >= 1; i--){
			sum += j[i - 1];
			ans = max(ans, sum * i);
		}
		
		printf("%u\n", ans);
	}
	
	return (0);
}

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

using namespace std;
using ll = long long;


int main()
{
	int n, m; cin >> n >> m;
	vector<int> a(m); for(int i = 0; i < m; i++)cin >> a[i];
	if(n >= m) {
		cout << 0 << endl;
		return 0;
	}
	sort(a.begin(), a.end());
	vector<int> dist(m - 1);
	for(int i = 0; i < m - 1; i++)dist.push_back(a[i + 1] - a[i]);
	sort(dist.begin(), dist.end());
	cout << accumulate(dist.begin(), dist.end() - (n - 1), 0) << endl;
}

Measured memory_bytes: 1408
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template<class T> inline bool chmax(T& a, T b) {if (a<b) {a=b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b) {if (a>b) {a=b; return true;} return false;}

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    vll h(n); REP(i, n) cin >> h[i];
    ll ans = 0, tmp=0;
    REP(i, n-1) {
        if (h[i] >= h[i+1]) tmp++;
        else {
            chmax(ans, tmp);
            tmp=0;
        }
    }
    chmax(ans, tmp);
    cout << ans << '\n';
    return 0;
}


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

#define rep(i,n) for(long long (i)=0;(i)<(long long)(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define int long long

#define PI (3.14159265358979323)
#define MOD (1000000007LL)
#define INF (1LL<<60LL)
#define MAX_N (10000001)
#define MAX (1000000000000000000LL)
using namespace std;

signed main() {
	int n; cin >> n;
	vector<int> a(n);
	vector<int> b(n);
	rep(i, n) {
		cin >> a[i] >> b[i];
	}
	sort(all(a));
	sort(b.begin(), b.end());
	int ans = 1;
	ans += b[n / 2] - a[n / 2];
	if(n%2==0) {
		ans += b[(n / 2) - 1] - a[(n / 2) - 1];
	}
	cout << ans << endl;
}

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

using namespace std;

#define ll long long
#define ld long double
#define P pair<ll, ll>

#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

#define all(v) v.begin(), v.end()

#define sortAl(v) sort(all(v))
#define sortAlr(v)          \
  sort(v.begin(), v.end()); \
  reverse(v.begin(), v.end())

#define cout(n) cout << fixed << setprecision(n)

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

template <class T>
inline void chmax(T &a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T &a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
#define INF LLONG_MAX

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

  string s;
  cin >> s;

  map<char, int> cnt;
  FORm(it, s) {
    cnt[*it]++;
  }

  FORm(it, cnt) {
    if (it->second != 2) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 256
function main (s) {
	var a=s.split("\n");
	for(var i=0;i<s.length;i++)a[i]=parseInt(a[i]);
	console.log(Math.min(a[0],a[1])+Math.min(a[2],a[3]));
}
 
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

int main()
{
    int N;
    cin>>N;
    string X;
    cin>>X;

    long long M = 998244353;

    vector<long long> P2(N+1);
    P2[0] = 1;
    for (int i=1; i<=N; i++)
        P2[i] = P2[i-1]*2%M;

    long long ans = 0;

    vector<long long> A(N+1);
    for (int k=1; k<=N; k++)
        if (N%k==0 && N/k%2!=0)
        {
            long long a = 0;
            for (int i=0; i<k; i++)
                if (X[i]=='1')
                    a += P2[k-i-1];
            
            string T;
            for (int i=0; i<N; i++)
                if (i/k%2==0)
                    T += X[i%k];
                else
                    T += X[i%k]^1;
            if (T<=X)
                a++;

            for (int d=1; d<k; d++)
                if (k%d==0)
                    a -= A[d];
            a = (a%M+M)%M;
            A[k] = a;

            ans += 2*k*a;
            ans %= M;
        }

    cout<<ans<<endl; 
}


Measured memory_bytes: 4220
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define rp(i,s,e) for(int i=(int)(s);i<(int)(e);++i)

pair<int, int> dhw[] = { // <h, w>
        { 1, 0},
{ 0,-1},        { 0, 1},
        {-1, 0},
{ 2,-2},{ 2,-1},{ 2, 0},{ 2, 1},{ 2, 2},
{ 1,-2},{ 1,-1},        { 1, 1},{ 1, 2},
{ 0,-2},                        { 0, 2},
{-1,-2},{-1,-1},        {-1, 1},{-1, 2},
{-2,-2},{-2,-1},{-2, 0},{-2, 1},{-2, 2}
};

int main() {
  int h, w; cin>>h>>w;
  int sh, sw, eh, ew; cin>>sh>>sw>>eh>>ew; --sh; --sw; --eh; --ew;
  vector<string> s(h); rp(i,0,h) cin>>s[i];

  const int INF = 1e9;
  // vector<vector<int>> dist(h,vector<int>(w,INF));
	vector<vi> dist(h, vi(w, INF));

  dist[sh][sw] = 0;
  deque<pair<int, int>> q;
  q.emplace_back(sh, sw);

  while (!q.empty()) {
    int i = q.front().first;
    int j = q.front().second;
    int d = dist[i][j];
    q.pop_front();

    rp(v,0,4) {
      int ni = i+dhw[v].first, nj = j+dhw[v].second;
      if (ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
      if (s[ni][nj] == '#') continue;
      if (dist[ni][nj] <= d) continue;
      dist[ni][nj] = d;
      q.emplace_front(ni,nj);
    }

		// for(int v=4; v<24; ++v){
		rp(v,4,24){
      int ni = i+dhw[v].first, nj = j+dhw[v].second;
			if (ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
			if (s[ni][nj] == '#') continue;
			if (dist[ni][nj] <= d+1) continue;
			dist[ni][nj] = d+1;
			q.emplace_back(ni,nj);
    }

  }

	cout<< (dist[eh][ew]==INF? -1:dist[eh][ew]) <<endl;
}


Measured memory_bytes: 9480
def solve(h, w, m, hw_list):
    h_count = [0] * (h + 1)
    w_count = [0] * (w + 1)
    for h_, w_ in hw_list:
        h_count[h_] += 1
        w_count[w_] += 1

    h_max = max(h_count)
    w_max = max(w_count)
    res = h_max + w_max

    h_max_count = 0
    w_max_count = 0
    for i in range(h + 1):
        if h_count[i] == h_max:
            h_max_count += 1
    for j in range(w + 1):
        if w_count[j] == w_max:
            w_max_count += 1

    max_count = h_max_count * w_max_count
    max_count_cross = 0
    for h_, w_ in hw_list:
        if h_count[h_] == h_max and w_count[w_] == w_max:
            max_count_cross += 1

    if max_count_cross == max_count:
        return res - 1
    else:
        return res


def main():
    h, w, m = map(int, input().split())
    hw_list = []
    for _ in range(m):
        hw_list.append(list(map(int, input().split())))
    res = solve(h, w, m, hw_list)
    print(res)


def test():
    assert solve(2, 3, 3, [[2, 2], [1, 1], [1, 3]]) == 3
    assert solve(3, 3, 4, [[3, 3], [3, 1], [1, 1], [1, 2]]) == 3
    assert solve(5, 5, 10, [[2, 5], [4, 3], [2, 3], [5, 5], [2, 2], [5, 4], [5, 3], [5, 1], [3, 5], [1, 4]]) == 6


if __name__ == "__main__":
    test()
    main()


Measured memory_bytes: 68492
use std::io::Read;
use std::cmp::max;

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

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let mut points: Vec<(isize, isize)> = Vec::new();
    for _ in 0..n {
        let xi: isize = iterator.next().unwrap().parse().unwrap();
        let yi: isize = iterator.next().unwrap().parse().unwrap();
        points.push((xi, yi));
    }

    let mx0 = points.iter().map(|p| p.0 - p.1).max().unwrap();
    let mn0 = points.iter().map(|p| p.0 - p.1).min().unwrap();
    let mx1 = points.iter().map(|p| p.0 + p.1).max().unwrap();
    let mn1 = points.iter().map(|p| p.0 + p.1).min().unwrap();

    let ans = max(mx0 - mn0, mx1 - mn1);
    ans.to_string()
}


Measured memory_bytes: 9184
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;



int main() {

  int N;
  cin >> N;

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

  sort(A, A+N);
  int b = A[N/2];

  long long sad = 0;
  for(int i = 0; i < N; ++i)
    sad += abs(A[i] - b);

  cout << sad << endl;

}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>

using namespace std;

void print_vec(vector<int>& v) {
    for (vector<int>::iterator it = v.begin(); it != v.end(); it++) {
        cout << *it;
        if ((it+1) != v.end())
            cout << " ";
    }
    cout << endl;
}

int main() {
    int len;
    vector<int> v;

    cin >> len;
    for (int i; i < len; i++) {
        int tmp;
        cin >> tmp;
        v.push_back(tmp);
    }

    for (int i = 1; i < v.size(); i++) {
        print_vec(v);

        int key = v[i];
        int j = i - 1;
        while (j >= 0 && v[j] > key) {
            v[j+1] = v[j];
            j--;
        }
        v[j+1] = key;
    }
    print_vec(v);

    return 0;
}

Measured memory_bytes: 3144
{-# LANGUAGE BangPatterns #-}

module Main where

import Control.Applicative
import Control.Monad

mod2 :: Int -> (Int, Int)
mod2 x
    | r == 0    = (q, r)
    | otherwise = (q + 1, r + 2)
  where
    (q, r) = x `divMod` (-2)

solve :: Int -> [Int]
solve 0 = [0]
solve a = iter [] a
  where
    iter !xs 0 = xs
    iter !xs n = let (q, r) = mod2 n
                 in iter (r:xs) q

main :: IO ()
main = do
    n <- readLn :: IO Int
    putStrLn . concatMap show $ solve n

Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main() {
    int A, B, C, K;
    cin >> A >> B >> C >> K;

    if(A >= K){
        cout << K << endl;
    }else{
        if(A + B >= K){
            cout << A << endl;
        }else{
            cout << 2*A + B - K << endl;
        };
    };
}

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

const int N = 5005;
int a, b, n, stack[N], top; char ch;
bool ans[N];

bool query(int x, int y) {return std::cout << "? " << x << ' ' << y << std::endl, std::cin >> ch, ch == 'Y';}
int main() {
	std::ios::sync_with_stdio(0), std::cin.tie(0);
	std::cin >> a >> b, n = a + b;
	if (a <= b) return std::cout << "Impossible" << '\n', 0;
	stack[top = 1] = 0;
	for (int i = 1; i < n; ++i) 
		if (!top) stack[top = 1] = i; 
		else if (query(stack[top], i)) stack[++top] = i; else --top;
	for (int i = 0; i < n; ++i) ans[i] = query(stack[top], i); std::cout << "! ";
	for (int i = 0; i < n; ++i) std::cout << ans[i]; std::cout << '\n';
	return 0;
}

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

int main(){

  char x,y;

  cin>>x>>y;

  if(x < y) cout<<'<'<<endl;

  else if(x > y) cout<<'>'<<endl;

  else if(x == y)cout<<'='<<endl;

  return 0;
  
}


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

int main()
{
	int x, y, z;

	cin >> x >> y >> z;

	if (x == y)
	{
		cout << z << endl;
	}
	else if (y == z)
	{
		cout << x << endl;
	}
	else if (x == z)
	{
		cout << y << endl;
	}

	return 0;

}

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


int main() {

	string ss, tt;
    cin >> ss;
    cin.ignore();
    cin >> tt;
    cin.ignore();
    for(int i = 0; i < (int)(ss.size()); i++) {
    	if(ss[i] != tt[i]) {
        	cout << "No\n";
            return 0;
        }
     }
	 cout << "Yes\n";

}

Measured memory_bytes: 3632
#include <iostream>

using namespace std;

int main(void){
    string s;
    cin>>s;
    int min = 9999;
    int tmp = 0;
    for(unsigned int i=0; i<s.length()-2; i++) {
        tmp = abs(753-abs(stoi(s.substr(i, 3))));
        if(tmp < min) min = tmp;
    }
    cout<<min<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int a, b;
    char op;
	while(cin >> a >> op >> b && op != '?')
	if(op == '+')
	{
		cout << a + b << endl;
	}else if(op == '-'){
		cout << a - b << endl;
	}else if(op == '*'){
		cout << a * b << endl;
		
	}else if(op == '/'){
		cout << a/b << endl;
	}else{
		return 0;
	}
}


Measured memory_bytes: 3100
<?php
class Scanner {
    private $arr = [];
    private $count = 0;
    private $pointer = 0;
    public function next() {
        if($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(' ', $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        $this->pointer++;
        return $result;
    }
    public function hasNext() {
        return $this->pointer < $this->count;
    }
    public function nextInt() {
        return (int)$this->next();
    }
    public function nextDouble() {
        return (double)$this->next();
    }
}

class out {
    public static function println($str = "") {
        echo $str . PHP_EOL;
    }
}


$sc = new Scanner();
$A = $sc->nextInt();
$B = $sc->nextInt();

for($i = 1; $i <= 10000; ++$i) {
	if(intval(floor($i * 0.08)) === $A && intval(floor($i * 0.1)) === $B) {
		out::println($i);
		break;
	}
	if($i === 10000) {
		out::println(-1);
		break;
	}
}
	


Measured memory_bytes: 4604
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <set>
#include <stdio.h> 
using namespace std;
	typedef long long int lli;
	const int MaxN=200005;
	#define fst first
	#define snd second
	#define mp make_pair
	lli mcd(lli a,lli b){	
		if(a==0)return b;
		return mcd(b%a,a);
	}		
	lli arr[MaxN];
int main(){
	lli N,K,i,j,res=0,ans=4;
	cin>>N;
	for(i=0;i<5;i++){
		cin>>arr[i];
	}
	res=N/arr[0];
	lli aux;
	if(N%arr[0]!=0)res+=1;
	for(i=1;i<5;i++){
		if(arr[i]<arr[i-1]){
			aux=N/arr[i];
			if(N%arr[i]!=0)aux+=1;
			res=max(res,aux);
		}
	}
	cout<<ans+res;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<ll,ll> p;
const int inf=(1<<30);
#define rep(i,a,n)	for(int i=a;i<n;i++)
#define rrep(i,a,n) for(int i=(a-1);i>=n;i--)
	
int main(){
	ll n;
	cin>>n;
	ll a[n];
	a[0]=0;
	rep(i,1,n+1)cin>>a[i];
	ll h=0;
	ll ans=0;
	rep(i,1,n+1){
		if(h<=a[i]){
			ans++;
			h=max(h,a[i]);
		}
	}
	cout<<ans<<endl;
}

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

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

int N;
vector<int> A;
vector<bool> chosen;

int main() {

    cin >> N;

    A.resize(N);
    REP(i, N) cin >> A[i];

    chosen.assign(N, false);

    int xr = 0;
    REP(i, N) xr ^= A[i];

    int res = 0;

    for (int i = 31; i >= 0; --i) {
        if ((xr & (1 << i)) == 0) continue;
        ++res;
        bool valid = false;
        REP(j, N) {
            if (not chosen[j] and ((A[j] & (1 << i)) != 0) and ((A[j] & ((1 << i) - 1)) == 0)) {
                chosen[j] = true;
                A[j]--;
                valid = true;
                xr ^= A[j];
                break;
            }
        }
        // REP(i, N) cout << A[i] << " \n"[i == N - 1];
        if (not valid) {
            cout << -1 << endl;
            return 0;
        }
    }
    
    cout << res << endl;

}


Measured memory_bytes: 640
#include<stdio.h>
#define max(a,b) ((a)>(b)?(a):(b))
int main(){
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);
  printf("%d",max(a,max(b,c))*10+a+b+c-max(a,max(b,c)));
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))
#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define nepit(x) for (__typeof((x).rbegin()) it = (x).rbegin(); it != (x).rend(); it++)
#define All(x) (x).begin(),(x).end()
#define Mem0(x) memset(x, 0, sizeof(x))
#define Mem1(x) memset(x, -1, sizeof(x))
#define Unique(v) v.resize(unique(All(v)) - v.begin())
#define End '\n'
#define Out(x) cout<<(x)<<End
#define OutP(p, sep, end) cout<<p.first<<sep<<p.second<<end
template<typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

#define pb push_back
#define mp make_pair
#define X first
#define Y second

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

    cin.tie(0);
    ios::sync_with_stdio(false);

    ll s;

	cin >> s;

	map<ll, bool> table;

	table[s] = 1;

	ll index = 1;

	while (1) {
		if (s % 2 == 0) s /= 2;
		else s = s * 3 + 1;

		index++;

		if (table.find(s) != table.end()) {
			Out(index);

			return 0;
		} else {
			table[s] = 1;
		}
	}
	
	return 0;
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long
#define inf 1e18
#define pi acos(-1.0)
#define mod 998244353

int main(void)
{
    fastio;

    int n,a,p[100005],i;
    cin >> n;
    for(i=1;i<=n;i++)
    {
        cin >> a;
        p[a]=i;
    }
    for(i=1;i<=n;i++)cout << p[i] << " ";
    return 0;
}


Measured memory_bytes: 3960
#include "bits/stdc++.h"
using namespace std;

int main() {
	int N, A;
	cin >> N>>A;//N,Aの入力
	if (N%500-A<=0)//計算結果が0以下になるか
		cout << "Yes" << endl;
	else if (N % 500 - A >= 0)//計算結果が0以上になるか
		cout << "No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <assert.h>
#include <vector>
#include <unordered_map>
#include <queue>
#include <climits>
#include <cmath>
#include <algorithm>
#include <unordered_set>
using namespace std;
constexpr int64_t MOD = 1e9 + 7;

int64_t modpow(int64_t a, int64_t b, int64_t mod = 1000000007) {
  int64_t res = 1;
  for (a %= mod; b; a = a * a % mod, b >>= 1)
    if (b & 1) res = res * a % mod;
  return res;
}

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

  int32_t N, P;
  string S;
  cin >> N >> P;
  cin >> S;
  int64_t res = 0;
  int32_t s_size = (int)S.size();
  if (P == 2 || P == 5) {
    int32_t mod_zero_cnt = 0;
    for (int i = s_size - 1; i >= 0; i--) {
      res += mod_zero_cnt;
      if ((S[i] - '0') % P == 0) {
        mod_zero_cnt++; 
        res++;
      }
    }
  } else {
    vector<int32_t> mod_cnt(P, 0);
    mod_cnt[0]++;
    int64_t modval = 0;
    for (int i = s_size - 1; i >= 0; i--) {
      modval += modpow(10, s_size - 1 - i, P) * (S[i] - '0');
      modval %= P;
      //cout << "modval : " << modval << endl;
      res += mod_cnt[modval];
      //cout << "res : " << res << endl;
      mod_cnt[modval]++;
    }
  }
  cout << res << endl;
  return 0;
}



Measured memory_bytes: 720
#include <cstdio>
#include <cmath>

using namespace std;

const double eps = 1.0e-7;
const double pi = acos(-1);

bool equals(double a, double b) { return abs(a-b) < eps; }

int main() {
  const static double rr = 1.0/(2.0*(1.0-cos(pi*2.0/3.0)));
  double N;
  while(scanf("%lf",&N) != EOF && N) {
    double n;
    for(n = 1; n < N && !equals(0,fmod(3*n,N)); n+=1);
    n *= 3;
    printf("%.6f\n",
	   rr*pi - n*( (pi*2/n-sin(pi*2/n))*rr/2.0
		       + tan((pi*(n-2)/n-pi/3.0)/2.0)*2*rr*(1-cos(pi*2/n))/4.0 ));
  }
  return 0;
}

Measured memory_bytes: 0
/* おまじない　*/
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
typedef long long ll;
typedef long double ld;
using namespace std;
const ll MOD=pow(10,9)+7;
const ll INF=(1LL<<62);
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
}

template<typename T>
vector<ll> countVector(vector< T >v,T guard=-1){
    ll size=v.size();
    //番兵を追加(初期値は-1)
    v.push_back(guard);
    vector<ll>ret;
    ll count=1;
    for(int i=0;i<size;i++){
        if(v[i]==v[i+1]){
            count++;
        }else{
            ret.push_back(count);
            count=1;
        }
    }
    return ret;
}

int main(){
  init();
  ll A,P;cin>>A>>P;
  cout<<(A*3+P)/2<<endl;
}


Measured memory_bytes: 256
module.exports=function(e){var r={};function n(t){if(r[t])return r[t].exports;var o=r[t]={i:t,l:!1,exports:{}};return e[t].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=r,n.d=function(e,r,t){n.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,r){if(1&r&&(e=n(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(n.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var o in e)n.d(t,o,function(r){return e[r]}.bind(null,o));return t},n.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(r,"a",r),r},n.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},n.p="",n(n.s=0)}([function(e,r,n){n(1)(n(2).readFileSync("/dev/stdin","UTF-8").split("\n"))},function(e,r){e.exports=function(e){for(var r=e[0].split("").map(function(e){return parseInt(e,36)-10}),n=r.length,t=Number(e[1]),o=0;o<n;o++)if(0!=r[o]){var u=26-r[o];u<=t&&(t-=u,r[o]=0)}t>0&&(r[n-1]+=t,r[n-1]%=26);var i=r.map(function(e){return String.fromCharCode(e+97)}).join("");console.log(i)}},function(e,r){e.exports=require("fs")}]);

Measured memory_bytes: 10132