akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], *ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline ll getint() {
	ll A = 0;
	if (ci - cn + 20 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}


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


	int N = getint();
	ll L = getint();
	ll X[100000];
	int V[100000];
	ll A[100001], B[100001], C, D;
	*A = 0;
	*B = 0;
	C = 0;
	D = 0;
	ll mae = 0;
	ll maeA = 0;
	ll maeB = 0;
	rep(i, N) {
		*(X + i) = getint();
		*(V + i) = getint();
		maeA = maeA + *(V + i) - *(X + i) + mae;
		*(A + i + 1) = max(*(A + i), maeA);
		maeB = maeB + *(V + i) - (*(X + i) - mae) * 2;
		*(B + i + 1) = max(*(B + i), maeB);
		mae = *(X + i);
	}
	mae = L;
	maeA = 0;
	maeB = 0;
	ll kotae = max(*(A + N), *(B + N));
	rep1(i, N) {
		maeA = maeA + *(V + N - i) + *(X + N - i) - mae;
		C = max(C, maeA);
		kotae = max(kotae, *(B + N - i) + C);
		maeB = maeB + *(V + N - i) + (*(X + N - i) - mae) * 2;
		D = max(D, maeB);
		kotae = max(kotae, *(A + N - i) + D);
		mae = *(X + N - i);
	}

	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 3072
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstdlib>

using namespace std;

typedef long long lli;
typedef pair<lli, int> P;
const int L = 4;
lli n, in;
vector<lli> input;
map<lli, int> data;
set<lli> vis;

lli rev(lli num, int a, int b){
  string str;
  while(num > 0){
    str += (char)((int)(num % 10LL) + '0');
    num /= 10LL;
  }
  reverse(str.begin(), str.end());
  if(str.size() != n) str = "0" + str;
  reverse(str.begin() + a, str.begin() + b + 1);
  return strtoll(str.c_str(), NULL, 10);

}

int solve(){
  lli state = 0;
  for(int i=0;i<n;i++){
    state *= 10;
    if(input[i] != 10) state += input[i];
  }
  if(data.find(state) != data.end()) return data[state];
  vis.clear();
  P u = P(state, 0), v;
  queue<P> q;
  q.push(u);
  while(!q.empty()){
    u = q.front();
    q.pop();
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
        if(i == j) continue;
        v = P(rev(u.first, i, j), u.second + 1);
        if(vis.find(v.first) == vis.end()){
          vis.insert(v.first);
          if(data.find(v.first) != data.end()) return data[v.first] + v.second;
          if(v.second < L) q.push(v);
        }
      }
    }
  }
  return n-1;
}

void init(){
  data.clear();
  lli state = 0;
  for(int i=1;i<=n;i++){
    state *= 10;
    if(i != 10) state += i;
  }
  P u = P(state, 0), v;
  queue<P> q;
  q.push(u);
  data[state] = 0;
  while(!q.empty()){
    u = q.front();
    q.pop();
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
        if(i == j) continue;
        v = P(rev(u.first, i, j), u.second + 1);
        if(data.find(v.first) == data.end()){
          data[v.first] = v.second;
          if(v.second < L) q.push(v);
        }
      }
    }
  }
}

main(){
  while(cin >> n){
    input.clear();
    for(int i=0;i<n;i++){
      cin >> in;
      input.push_back(in);
    }
    init();
    cout << solve() << endl;
  }
}

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

int field[100][100];
int chip[4][50][50];
int main()
{
	int n,m;
	while(cin >> n >> m){
		if(!n&&!m)
			break;
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				cin >> field[i][j];
			}
		}
		for(int i=0;i<m;i++){
			for(int j=0;j<m;j++){
				cin >> chip[0][i][j];
			}
		}
		for(int i=1;i<4;i++){
			for(int j=0;j<m;j++){
				for(int k=0;k<m;k++){
					chip[i][k][m-1-j] = chip[i-1][j][k];
				}
			}
		}
		
		int x=n,y=n;
		for(int i=0;i<=n-m;i++){
			for(int j=0;j<=n-m;j++){
				for(int k=0;k<4;k++){
					bool flag = true;
					bool fl = true;
					int xx,yy;
					for(int l=0;l<m;l++){
						for(int o=0;o<m;o++){
							if(chip[k][l][o] >= 0){
								if(chip[k][l][o] == field[i+l][j+o]){
									if(fl){
										xx = j+o;yy = i+l; fl = false;
									}
								}else{
									flag = false;
								}
							}
						}
					}
					if(flag){
						if(y > yy){
							y = yy;
						if(x > xx)
							x = xx;
						}
					}
				}
			}
		}
		if(x!=n || y!=n)
			cout << x+1 << " " << y+1 << endl;
		else
			cout << "NA" << endl;
	}
	return 0;
}

Measured memory_bytes: 956
#include <iostream>
#include <cmath>
#include <map>
#include <set>
using namespace std;

int main() {
    int n;
    scanf("%d", &n);
    map<pair<int, int>, set<int>> pair_index;
    for(int i=0; i<n; i++){
        double x;
        int pow2=0, pow5=0;
        unsigned long long val;
        scanf("%lf", &x);
        val=llround(x*1e9);
        while(val%2==0){
            pow2++;
            val/=2;
        }
        while(val%5==0){
            pow5++;
            val/=5;
        }
        pair_index[*new pair(pow2, pow5)].insert(i);
    }
    unsigned long long counter=0;
    for(auto i=pair_index.begin(); i!=pair_index.end(); i++){
        for(auto j=pair_index.begin(); j!=pair_index.end(); j++){
            if(min(i->first.first+j->first.first, i->first.second+j->first.second)>=18){
                if(i==j){
                    counter+=i->second.size()*(j->second.size()-1)/2;
                }else if(*i<*j){
                    counter+=(i->second.size()*j->second.size());
                }
            }
        }
    }
    printf("%llu\n", counter);
    return 0;
}

/*Logic:
 * Since floating points are stored as approximate value.
 * Direct multiplication will result in some anomaly.
 * To avoid that we multiplied the given floating point or regular number
 * with 10^9, because the highest number of digits after decimal is 9.
 * This will make the numbers to be in the form
 * number/10^9.
 * Now, if we multiply say (x/10^9 * y/10^9) then we get
 * xy/10^18.
 * To get an integer, all we have to do is cancel out the denominator.
 * So xy has be z*(10^(>=9)).
 * Now we also know that 10^p is basically (2^p)*(5^p).
 * Here, p has to be equal to or greater that 9.
 *
 * Now, comes to the problem of handling TLE.
 * Since the dataset is 2*10^6 and 2 sec, regular brute force gave me TLE.
 * So in order to handle that a map with key (2^p)*(5^q) where p varies and q varies
 * and as value stores the indices of where key was found.
 * Now, for any pair of keys min(p1+p2, q1+q2) >=18, then all we multiply the number
 * of values from the keys.
 * If for the same key min(p1+p1, q1+q1) >=18, then all possible combinations are required.
 * Thus number of values*(number of values-1)/2.
 * Summation of all of these results in the answer.
 */

Measured memory_bytes: 19368
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<queue>

const int INFTY = 1 << 22;
using namespace std;

class Town{
public:
  Town(){
    this->init();
  }
  void init(void){
    this->cost = INFTY;
    this->vis = false;
  }
  int cost;
  bool vis;
  vector<int> vcon;
  vector<int> vcost;
  bool operator <(const Town *t) const{
    return cost < t->cost;
  };
};

void Dijkstra( map<int, Town> &G, int st ){
  priority_queue<Town*> q;
  Town *pt;

  G[st].cost = 0;
  q.push( &G[st] );

  while( !q.empty() ){
    pt = q.top();
    q.pop();
    pt->vis = false;

    for(int i = 0; i < pt->vcon.size(); i++){
      if( G[ pt->vcon[i] ].cost > pt->cost + pt->vcost[i] ){
	G[ pt->vcon[i] ].cost = pt->cost + pt->vcost[i];
	if( G[ pt->vcon[i] ].vis ){
	  continue;
	}else{
	  G[ pt->vcon[i] ].vis = true;
	  q.push( &G[ pt->vcon[i] ] );
	}
      }
    }
  }
}
void ResetGraph( map<int, Town> &G, vector<int> &V){
  for(int i = 0; i < V.size(); i++ ){
    G[ V[i] ].init();
  }
}
int main(void){
  int n,m;
  int s,g;
  int money,pay;
  map<int, Town> G;
  vector<int> V;

  scanf("%d%d", &n, &m);
  for(int i = 0; i < m; i++){
    int a,b,c,d;

    scanf("%d,%d,%d,%d", &a, &b, &c, &d);
    V.push_back( a );
    V.push_back( b );
    G[a].vcon.push_back( b );
    G[a].vcost.push_back( c );
    G[b].vcon.push_back( a );
    G[b].vcost.push_back( d );
  }
  scanf("%d,%d,%d,%d", &s, &g, &money, &pay);

  Dijkstra( G , s );

  money -= pay;
  money -= G[ g ].cost;

  ResetGraph( G , V );
  Dijkstra( G , g );

  money -= G[ s ].cost;

  cout << money << endl;
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
const ll INF = 1001001001;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
//printf("%.10f\n", N);
/*
ll memo[100000];
ll fibo(ll n){
    if(memo[n] != 0)return memo[n];
    if(n <= 1)return n;
    else return memo[n] = fibo(n - 1)+ fibo(n - 2);
}*/
int main() {
    char A,B;
    cin >> A >> B;
    if(A > B)cout << ">" << endl;
    else if(A < B)cout << "<" << endl;
    else cout << "=" << endl;
}

Measured memory_bytes: 256
from sys import stdin, stdout
 
ii = lambda: int(stdin.readline())
mi = lambda: map(int, stdin.readline().strip().split())
li = lambda: list(mi())

MOD = int(10 ** 9 + 7)

n = ii()
A = li()

ans = 0
for j in range(60):
	cnt = [0] * 2
	for i in range(int(n)):
		c = (A[i] >> j) & 1
		ans += cnt[c ^ 1] << j
		cnt[c] += 1

ans %= MOD

stdout.write(str(ans) + "\n")




Measured memory_bytes: 124568
#include <iostream>
#include<bits/stdc++.h>
#define int unsigned long long int
#define vi vector<int>
#define vvi vector<vector<int>>
using namespace std;

int32_t main() {
	// your code goes here
	int t,x=1;
	
	  //cout<<"Case #"<<x++<<":\n";
	  int n,i,j,k;
cin>>n>>k;
vi a(n+1),prod(n+1,1);
for(i=1;i<=n;i++)
{cin>>a[i];

}
int res=1;
for(i=k+1;i<=n;i++)
{
   if(a[i]>a[i-k])
    cout<<"Yes\n";
    else cout<<"No\n";
}
	  
	    
	  
	
	
	return 0;
}


Measured memory_bytes: 6420
#include<bits/stdc++.h>
#define N 1005
using namespace std;
typedef unsigned long long ull;
string str,img[N],pat[N];
char temp[N][N];
ull Imgw[N][N];
int w,h,p;

string itos(int x){
  string res;
  while(x)res=(char)(x%2+'0')+res,x/=2;
  for(int i=res.size();i<6;i++)res='0'+res;
  return res;
}

int getNum(char c){
  if('A'<=c&&c<='Z')return c-'A';
  if('a'<=c&&c<='z')return c-'a'+26;
  if('0'<=c&&c<='9')return c-'0'+52;
  if(c=='+')return 62;
  return 63;
}

string ctob(string s){
  string res;
  for(int i=0;i<s.size();i++)
    res+=itos(getNum(s[i]));
  return res;
}

void rot(){
  for(int i=0;i<p;i++)
    for(int j=0;j<p;j++)
      temp[i][j]=pat[j][p-i-1];
  for(int i=0;i<p;i++)
    for(int j=0;j<p;j++)
      pat[i][j]=temp[i][j];
}

void rev(){
  for(int i=0;i<p;i++)
    reverse(pat[i].begin(),pat[i].end());
}

int rolling_hash(){
  ull M1=950527,M2=9999973;
  set<ull> s;
  for(int k=0;k<8;k++){
    if(k==4)rev();
    rot();
    ull target=0;
    for(int i=0;i<p;i++){
      ull key=0;
      for(int j=0;j<p;j++)
	key=key*M1+pat[i][j];
      target=target*M2+key;
    }
    s.insert(target);
  }
  for(int i=0;i<h;i++){
    ull k=0,l=1;
    for(int j=0;j<w;j++){
      k=k*M1+img[i][j];
      if(j-p>=0)k-=l*img[i][j-p];
      else l*=M1;
      Imgw[i][j]=k;
    }
  }
  int ans=0;
  for(int j=0;j<w;j++){
    ull k=0,l=1;
    for(int i=0;i<h;i++){
      k=k*M2+Imgw[i][j];
      if(i-p>=0)k-=l*Imgw[i-p][j];
      else l*=M2;
      if(s.count(k))ans++;
    }
  }
  return ans;
}

int main(){
  while(1){
    cin>>w>>h>>p;
    if(!w&&!h&&!p)break;
    for(int i=0;i<h;i++){
      cin>>str;
      img[i]=ctob(str);
      img[i]=img[i].substr(0,w);
    }
    for(int i=0;i<p;i++){
      cin>>str;
      pat[i]=ctob(str);
      pat[i]=pat[i].substr(0,p);
    }
    cout<<rolling_hash()<<endl;
  }
  return 0;
}

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

int main()
{
	int n;
	cin >> n;
	int dp[n][3];
	cin >> dp[0][0] >> dp[0][1] >> dp[0][2];
	for(int i = 1; i < n; i++){
		int a,b,c;
		cin >> a >> b >> c;
		dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a;
		dp[i][1] = max(dp[i-1][2], dp[i-1][0]) + b;
		dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + c;
	}

	cout << max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2])) << "\n";

	return 0;
}


Measured memory_bytes: 1408
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    static class AWeatherPrediction
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var weathers = new List<string> { "Sunny", "Cloudy", "Rainy" };
            int crntIndex = weathers.IndexOf(s);
            int nextIndex = crntIndex == 2 ? 0 : crntIndex + 1;

            Console.WriteLine(weathers[nextIndex]);
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 11100
import java.io.*;
import java.util.ArrayList;
public class Main{
	public static void main(String args[]){
    int a=0,b=0,c=0,i=0,n=0;
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    while(true){
    try{
      String line = reader.readLine();
      String[] splitted = line.split(" ");
      a = Integer.parseInt(splitted[0]);
      b = Integer.parseInt(splitted[1]);
      c = Integer.parseInt(splitted[2]);
      if (a+b+c == -3) break;
		}catch(Exception e){
      break;
    }

    if (a == -1 || b == -1) {
      System.out.println("F");
    }else if (a + b >= 80){
      System.out.println("A");
    }else if (a + b >= 65){
      System.out.println("B");
    }else if (a + b >= 50){
      System.out.println("C");
    }else if (a + b >= 30){
      if (c >= 50) {
        System.out.println("C");
      }else{
        System.out.println("D");
      }
    }else{
      System.out.println("F");
    }

  }
	}
}


Measured memory_bytes: 24428
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
using namespace std;

int main(void)
{
	int N;
	cin >> N;

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

	int ret = 0;
	for(int i=0; i<N-1; i++)
		if(a[i] == a[i+1]){
			ret++;
			a[i+1] = -1;
		}

	cout << ret << endl;

	return 0;
}


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

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }



int main() {
    const double PI = acos(-1.0);
    double a, b, x;
    cin >> a >> b >> x;
    x /= a;
    cout << fixed << setprecision(10);
    if (x > a*b/2) cout << atan2((a*b-x)*2, a*a) * 180 / PI << endl;
    else cout << atan2(b*b, x*2) * 180 / PI << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;

const ll INF = 1001001001;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<P> ab(n);
    vector<P> cd(m);
    rep(i, n) cin >> ab[i].first >> ab[i].second;
    rep(i, m) cin >> cd[i].first >> cd[i].second;
    rep(i, n) {
        ll mi = INF;
        ll ans = 0;
        rep(j, m) {
            if(abs(ab[i].first - cd[j].first) + abs(ab[i].second - cd[j].second) < mi) {
                mi = abs(ab[i].first - cd[j].first) + abs(ab[i].second - cd[j].second);
                ans = j + 1;
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import numpy as np

N, D = map(int, input().split())

points = np.array([list(map(int, input().split())) for _ in range(N)])

def distance(p1, p2):
  squares = np.square(p1 - p2)
  return np.sqrt(squares.sum())

count = 0
for i in range(N):
  for j in range(i+1, N):
    dist = distance(points[i], points[j])
    count += dist.is_integer() * 1

print(count)

Measured memory_bytes: 12408
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) (v).begin(),(v).end()
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

int main() {
    string s, t;
    cin >> s >> t;
    int ans = t.length();
    rep(i, s.length()-t.length()+1) {
        string ss = s.substr(i, t.length());
        int tmp = 0;
        rep(j, ss.length()) {
            if (t[j]!=ss[j]) tmp++;
        }
        ans = min(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using lint = long;
using llint = long long;
using namespace std;

int main() {
    fastIO;
    int n;
    cin >> n;
    int r = n % 1000;
    if (r == 0)
        cout << 0;
    else
        cout << (1000 - r);
}

Measured memory_bytes: 3656
N,M = map(int,input().split())

D = []
C = []
CELL0 = [-1]
CELL1 = [-1]
CELL2 = [-1]




for i in range(M):
    line = list(map(int,input().split()))
    D.append(line)

for i in range(N):
    line = list(map(int,input().split()))
    C.append(line)

for k in range(1,M+1):
    cl0 = 0
    cl1 = 0
    cl2 = 0
    for i in range(N):
        for j in range(N):
            cell = C[i][j]
            if (i+j)%3 == 0:
                cl0 += D[cell-1][k-1]
            if (i+j)%3 == 1:
                cl1 += D[cell-1][k-1]
            if (i+j)%3 == 2:
                cl2 += D[cell-1][k-1]
    CELL0.append(cl0)
    CELL1.append(cl1)
    CELL2.append(cl2)

ans = 2**64

for cell0 in range(1,M+1):
    for cell1 in range(1,M+1):
        if cell0==cell1:
            continue
        for cell2 in range(1,M+1):
            if cell0==cell2 or cell1==cell2:
                continue
            temp = CELL0[cell0] + CELL1[cell1] + CELL2[cell2]
            ans = min(ans, temp)

print(ans)


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


int main() {
    long long A,B,C,D;
    cin >> A >> B >> C >> D;
    
    
        if (B>=C) {
            cout << "Yes" << endl;
            return 0;
        }
    if (D<=A) {
        for (int i = 1 ; i < 10000; i++){
              C = C - B;
            if (C<=0) {
              cout << "Yes" << endl;
                break;
            }
            A = A - D;
            if (A<=0) {
              cout << "No" << endl;
                break;
            }
        }
    }else {
        cout << "No" << endl;
        return 0;
    }
    
}


Measured memory_bytes: 3620
#include <iostream>
#include <iomanip>
#include <cstdint>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

int main(void)
{
    std::string S;
    std::cin >> S;

    std::string ans;
    for (auto&& c : S) {
        ans += "x";
    }

    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	
	int n;
	cin >> n;
	int i;
	int h[20];
	for (i = 0; i < n; i++) {
		cin >> h[i];
	}
	int maxh = 0;
	int hcounter = 0;
	maxh = h[0];
	hcounter++;
	for (i = 1; i < n; i++) {
		if (h[i] >= maxh) {
			maxh = h[i];
			hcounter++;
		}
	}
	cout << hcounter << endl;
	return 0;
	
	
	//A
	/*
	int a,b;
	cin >> a >> b;
	int x = 0;
	for (int i = 0; i < 2; i++) {
		if (a > b) {
			x = x + a;
			a--;
		}
		else {
			x = x + b;
			b--;
		}
	}
	cout << x << endl;
	return 0;
	*/


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
// by piano
template<typename tp> inline void read(tp &x) {
    x = 0;char c = getchar();bool f = 0;
    for(; c < '0' || c > '9'; f |= (c == '-'), c = getchar());
    for(; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
    if(f) x = -x;
}
const int N = 3e5 + 10;
int tr[N], n, m, L[N], R[N], st[N], top = 0, sum[N], op[N];

struct P {
	int L, R, len;
}p[N];

inline bool cmp(P a, P b) {
	return a.len < b.len;
}

struct T {
	#define ls (rt << 1)
	#define rs (rt << 1 | 1)
	#define mid ((l) + (((r) - (l)) >> 1))
	int tr[N << 2], tag[N << 2];
	inline void pd(int rt, int l, int r) {
		if(tag[rt]) {
			tr[ls] += tag[rt] * (mid - l + 1);
			tr[rs] += tag[rt] * (r - mid);
			tag[ls] += tag[rt];
			tag[rs] += tag[rt];
			tag[rt] = 0;
		}
	}
	
	inline void A(int L, int R, int C, int l, int r, int rt) {
		if(L <= l && r <= R) {
			tr[rt] += C * (min(r, R) - max(l, L) + 1);
			tag[rt] ++;
			return ;
		}pd(rt, l, r);
		if(L <= mid) A(L, R, C, l, mid, ls);
		if(R > mid) A(L, R, C, mid + 1, r, rs);
		tr[rt] = tr[ls] + tr[rs];
	}
	
	inline int Q(int L, int R, int l, int r, int rt) {
		if(L <= l && r <= R) return tr[rt];
		pd(rt, l, r);
		int ans = 0;
		if(L <= mid) ans += Q(L, R, l, mid, ls);
		if(R > mid) ans += Q(L, R, mid + 1, r, rs);
		return ans;
	}
	
	inline int ADD(int x, int val) {
		for(; x <= n ;x += x & -x) tr[x] += val;
	}
	
	inline int QUE(int x, int ans = 0) {
		for(ans = 0; x >= 1; x -= x & -x) ans += tr[x]; return ans;
	}
	
}s1, s2;


main() {
	read(m), read(n); 
	for(int i = 1; i <= m; i ++) {
		read(p[i].L), read(p[i].R);
		p[i].len = p[i].R - p[i].L + 1;
	}
	sort(p + 1, p + m + 1, cmp);
	int k = 1;
//	for(int i = 1; i <= m; i ++)
//		cout << i << "th " << p[i].L << ' ' << p[i].R << "\n";
	for(int i = 1; i <= n; i ++) {
		for(; k <= m && p[k].len < i; k ++) {
//			s1.A(p[k].L, p[k].R, 1, 1, n, 1);
			s1.ADD(p[k].L, 1);
			s1.ADD(p[k].R + 1, -1);
		}
		int ans = m - k + 1;
		for(int t = i; t <= n; t += i) ans += //s1.Q(t, t, 1, n, 1);//
		s1.QUE(t);
		cout << ans << "\n";
	}
//	for(int i = 1; i <= n; i ++)
//		printf("%lld\n", s2.Q(i, 1, n, 1));
}

Measured memory_bytes: 13184
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  int n;
  cin >> n ;
  vector<ll> l(n);
  for(auto &x: l) cin >> x;
  int ans{};
  for(int i=0; i<n; i++){
    for(int j=i+1; j<n; j++){
      if(l[i] == l[j]) continue;
      for(int k=j+1; k<n; k++){
        if(l[i] == l[k] || l[j] == l[k]) continue;

        int mx = max({l[i], l[j], l[k]});
        ll sm = l[i] + l[j] + l[k];
        if(mx < sm - mx) ans++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3652
N = int(input())
S = input()

W_cnt, E_cnt = [0], [0]
W_sum, E_sum = 0, 0

for S_i in S[:-1]:
    if S_i == 'W':
        W_sum += 1
    W_cnt.append(W_sum)
for S_i in list(reversed(S))[:-1]:
    if S_i == 'E':
        E_sum += 1
    E_cnt.append(E_sum)

ans = []
for W_i, E_i in zip(W_cnt, reversed(E_cnt)):
    ans.append(W_i+E_i)
print(min(ans))



Measured memory_bytes: 33220
/*
digu_J - Digvijay Janartha
NIT Hamirpur - INDIA
*/

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

void test() {
    int n;
    cin >> n;
    int a[n], b[n];
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (int i = 0; i < n; ++i) {
        cin >> b[i];
    }
    int lo = 0, hi = n - 1;
    while (lo <= hi) {
        while (lo <= hi and a[lo] != b[lo]) {
            ++lo;
        }
        while (lo <= hi and a[hi] != b[hi]) {
            --hi;
        }
        if (lo <= hi and b[lo] != b[hi]) {
            swap(b[lo], b[hi]);
            ++lo, --hi;
        } else {
            break;
        }
    }
    int cnt = max(0, hi - lo + 1);
    vector<int> idx;
    if (lo <= hi) {
        for (int i = 0; i < lo; ++i) {
            if (a[i] != b[lo] and b[i] != b[lo]) {
                idx.emplace_back(i);
            }
        }
        for (int i = hi + 1; i < n; ++i) {
            if (a[i] != b[lo] and b[i] != b[lo]) {
                idx.emplace_back(i);
            }
        }
    }
    if (cnt > int(idx.size())) {
        cout << "No\n";
    } else {
        cout << "Yes\n";
        for (int i = lo, j = 0; i <= hi; ++i, ++j) {
            swap(b[i], b[idx[j]]);
        }
        for (int i = 0; i < n; ++i) {
            cout << b[i] << " ";
        }
        cout << "\n";
    }
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifdef HOME
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int t = 1;
    // cin >> t;
    for (int i = 0; i < t; ++i) {
        test();
    }
    return 0;
}


Measured memory_bytes: 5852
k = int(input())
# やっぱり一旦はglobalで書こ
total_ls = []
def dfs(A):
    if int(A) > 3234566667:
        return
    global total_ls
    total_ls.append(int(A))
    last = int(A[-1])
    if last == 0:
        nex = [1,0]
    elif last == 9:
        nex = [8,9]
    else:
        nex = [last-1,last,last+1]
    for n in nex:
        A += str(n)
        dfs(A)
        A = A[:-1]

for i in range(1,10):
    dfs(str(i))
total_ls.sort()
print(total_ls[k-1])


    


Measured memory_bytes: 13436
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define ll long long
#define ull unsigned long long
#define dd double
#define oo 1001007000
#define ff float
#define ooo 4223352036854775007
#define iii pair<ll,ll>
#define vii vector<ll>
#define viii vector<iii>
#define sss pair<str,str>
#define str string
#define sii set<ll>
#define siii set<iii>
#define r0 return 0
#define pb push_back
#define sz size
using namespace std;

const char E='\n';
const int N=10005;
const int NN=2005;
const ll md=998244353;


int main(){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
    dd a,b,h,m;
    cin >> a >> b >> h >> m;
    dd ang;
    h=30*h+0.5*m;
    m=6*m;
    ang=max(h,m)-min(h,m);
    ang=min(ang,360-ang);
    if (ang==180){
        cout.setf(ios::fixed);
        cout.precision(10);
        cout << a+b << E;
        r0;
    }

    dd ans=a*a+b*b-2*a*b*cos((ang/180)*3.141592653);
    ans=sqrt(ans);
    cout.setf(ios::fixed);
    cout.precision(10);
    cout << ans << E;
    r0;
}
/*








*/


Measured memory_bytes: 4204
<?php
list($s) = strs();
$n = strlen($s);
$cs = 0; // 最終的に残るS
for ($i = 0; $i < $n; ++$i) {
    if ($s[$i] === 'S') $cs++;
    elseif ($cs > 0) $cs--;
}
echo $cs * 2;
function strs()
{
    return explode(' ', trim(fgets(STDIN)));
}


Measured memory_bytes: 16644
#include<bits/stdc++.h>
using namespace std;
int main(){
  char c;
  cin >> c;
  if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') cout << "vowel\n";
  else cout << "consonant\n";
  return 0;
}

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

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

int main() {
    int a[4][4], check[4][4] = {};
    int tmp;
    rep(i, 3) {
        rep(j, 3) {
            cin >> tmp;
            a[i][j] = tmp;
        }
    }
    int n;
    cin >> n;
    rep(i, n) {
        cin >> tmp;
        rep(j, 3) {
            rep(k, 3) {
                if (a[j][k] == tmp) {
                    check[j][k] = 1;
                }
            }
        }
    }

    bool flag = false;
    // 横をチェック
    rep(i, 3) {
        if (check[i][0] == 1 && check[i][1] == 1 && check[i][2]) flag = true;
        if (check[0][i] == 1 && check[1][i] == 1 && check[2][i] == 1) flag = true;
    }
    if(check[0][0]&&check[1][1]&&check[2][2]) flag = true;
    if(check[2][0]&&check[1][1]&&check[0][2]) flag = true;

    cout << (flag ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cassert>
#include <map>
using namespace std;

uint64_t ans = 0;

void Try(const string& s, int l, int r) {
  if (l >= r) {
    return;
  }
  int cnt_b = 0;
  for (int i = r; i >= l; i--) {
    if (s[i] == 'B') {
      cnt_b++;
    } else if (s[i] == 'A') {
      ans += cnt_b;
    }
  }
}

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

  string s;
  cin >> s;
  int l = 0;
  for (int r = 0; r < s.size(); r++) {

    auto get_next = [&]() {
      return r + 1 < s.size() ? s[r + 1] : 'D';
    };

    if (s[r] == 'C' || (s[r] == 'B' && get_next() != 'C')) {
      Try(s, l, r - 1);
      l = r + 1;
      continue;
    }
    if (s[r] == 'B') {
      r++;
    } else if (s[r] == 'A') {
      continue;
    }
  }
  Try(s, l, s.size() - 1);
  cout << ans << endl;
}

Measured memory_bytes: 720
from collections import Counter 
from collections import defaultdict
from collections import deque
from functools import reduce
import math
import itertools
import heapq
#import numpy as np
import bisect
import sys
#import sympy
sys.setrecursionlimit(10**6)


def bfs(s,n,node):
    #頂点が探索済みかどうかのチェック配列
    check=[False for _ in range(n)]
    check[s]=True
    #次見る頂点を格納するキュー
    queue=deque([s])
    visited_num=1

    #問題固有の配列
    #color_check=[[True for _ in range(l)] for _ in range(n)]
    color=[-1 for _ in range(n)]
    color[s]=0
    
    while visited_num<n:
        #グラフが全連結ではない場合
        if len(queue)==0:
            #空配列を返す
            #現状までの計算済み配列を返してもいいと思う
            return color

        now_vertex=queue.popleft()
        #インデックスがない場合は
        for next_vertex in node[now_vertex]:


            if check[next_vertex]==True:
                continue

            queue.append(next_vertex)
            check[next_vertex]=True

            #問題固有の計算
            color[next_vertex]=color[now_vertex]+1
            visited_num+=1

    return color

mod=10**9+7
#n=int(input())
#n,m=list(map(int,input().split()))
#a=list(map(int,input().split()))
ceil=lambda x,y: (x+y-1)//y
input_list = lambda : list(map(int,input().split()))

n=int(input())
tmp=list(map(int,input().split()))
a=[]
al=0
for each in tmp:
    al^=each
    a.append(each)

ans=[]
for each in (tmp):
    ans.append(str(each^al))

print(" ".join(ans))


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

int main() {
    int n, result = 0;
    cin >> n;
    map<int, int> count;
    for (int i = 0, k; i < n; i++) {
        cin >> k;
        count[k]++;
    }
    while (!count.empty()) {
        if (count.rbegin()->second == 0) {
            count.erase(prev(count.rbegin().base()));
            continue;
        }
        int a = count.rbegin()->first, pow2 = 1;
        count.rbegin()->second--;
        while (pow2 <= a) {
            pow2 *= 2;
        }
        auto it = count.find(pow2 - a);
        if (it != end(count) && it->second > 0) {
            it->second--;
            result++;
        }
    }
    cout << result;
    return 0;
}

Measured memory_bytes: 9600
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        while (true) {
            int a = sc.nextInt();
            String op = sc.next();
            int b = sc.nextInt();
            int answer = 0;

            if (op.equals("+")) {
                answer = a + b;
            } else if (op.equals("-")) {
                answer = a - b;
            } else if (op.equals("/")) {
                answer = a / b;
            } else if (op.equals("*")) {
                answer = a * b;
            } else {
                break;
            }

            System.out.println(answer);

        }
    }

}



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

using namespace std;

int main() {
  string s;
  cin >> s;
  int n = (int) s.size();
  long long ans = 0;
  for (int mask = 0; mask < (1 << (n - 1)); ++mask) {
    long long sum = 0, term = 0;
    for (int i = 0; i < n - 1; ++i) {
      term = term * 10 + (s[i] - '0');
      if (mask >> i & 1) {
        sum += term;
        term = 0;
      }
    }
    term = term * 10 + s.back() - '0';
    sum += term;
    ans += sum;
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>

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

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
 
    int a[3], ans=0;
    
    rep(i, 3){
        scanf("%d", &a[i]);
    }
    
    qsort(a, 3, sizeof(int), up_comp);
    
    ans=a[1]-a[0]+(a[2]-a[1]);
    
    printf("%d", ans);
    
    return 0;
}



Measured memory_bytes: 1716
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int n;
int a[105];
int ans;
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(i%2==0&&a[i]%2==1){
            ans++;
        }
    }
    cout<<ans<<endl;
    
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std; 
int main()
{
    ios::sync_with_stdio(false); 
    string a;  
    cin>>a; 
    for(register int i=0;i<a.length();i+=2)
	{ 
        cout<<a[i];
    }
    cout<<endl; 
    return 0; 
}

Measured memory_bytes: 592
#include <iostream>
#include <cstring>
#include <algorithm>
#include <set>
using namespace std;

int u[14] = {} , n , sum , tot;
int w[52];
int memo[1000][52];


int f(int s){
	if(memo[sum][s] >= 100) return false;
	else memo[sum][s]++;

	if(s==0){
		for(int i = n ; i > 0 ; i--){
			cout << w[i] << (i!=1?" ":"\n");
		}
		return true;
	}
	if(s==n){
		for(int i = 1 ; i <= 13 ; i++){
			if(u[i]){
				--u[i];
				sum += i;
				w[s] = i;
				if( f(s-1) ) return true;
				sum -= i;
				++u[i];
			}
		}
	}else{

		bool chk = 0;
		for(int i = 1 ; i <= 13 ; i++){
			if(u[i] && tot % i == 0) chk = true;
		}
		
		if(!chk ){
			
			return false;
		}
		for(int i = 1 ; i <= 13 ; i++){
			if(u[i] && sum % i == 0){
				--u[i];
				sum += i;
				w[s] = i;
				if( f(s-1) ) return true;
				sum -= i;
				++u[i];
			}
		}
	}
	return false;
}
int main(){
	while(cin >> n && n){
		
		tot = 0;
		memset(memo,0,sizeof(memo));
		for(int i = 1 ; i <= 13 ; i++){
			u[i] = 0;
		}
		for(int i = 0 ; i < n ; i++){ int a; cin >> a; ++u[a]; tot += a; }
		sum = 0;
		if(!f(n)) cout << "No" << endl;
	}
}

Measured memory_bytes: 0
#include<stdio.h>
int main(void){
int d[10],n,m,j=0;
for(n=0;n<=9;n++){
scanf("%d",&d[n]);
}
for(n=0;n<=7;n++){
for(m=n;m<10;m++){
if(d[n]<d[m]){
j=d[n];
d[n]=d[m];
d[m]=j;
}
}
}
for(n=0;n<3;n++){
printf("%d\n",d[n]);
}
return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int main() {
  string A, B;
  cin >> A >> B;
  int X = A.size();
  int Y = B.size();
  vector<char> vecA(X);
  vector<char> vecB(Y);
  rep(i, X) {
    vecA.at(i) = A.at(i);
  }
  rep(i, Y) {
    vecB.at(i) = B.at(i);
  }
  sort(vecA.begin(), vecA.end());
  sort(vecB.begin(), vecB.end());
  reverse(vecB.begin(), vecB.end());
  rep(i, X) {
    A.at(i) = vecA.at(i);
  }
  rep(i, Y) {
    B.at(i) = vecB.at(i);
  }
  if(A < B) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3592
# 入力値を文字の配列で返す
def gets_s_list()
  gets.chomp.split("")
end

# 空白区切の入力値を数値の配列で返す
def gets_i_list()
  gets.chomp.split(" ").map(&:to_i)
end

N, A, B = gets_i_list
S = gets_s_list

# 国内の学生は、現在予選の通過が確定した参加者が
# A + B 人に満たなければ、予選を通過する
#
# 海外の学生は、現在予選の通過が確定した参加者が
# A + B人に満たず、
# さらに海外の学生の中での順位がB位以内なら、予選を通過する
a_total = 0
b_total = 0
S.each do |s|
  if (a_total + b_total) < A + B
    if s == "a"
      a_total += 1
      puts "Yes"
    elsif s == "b"
      if b_total < B
        b_total += 1
        puts "Yes"
      else
        puts "No"
      end
    else
      puts "No"
    end
  else
    puts "No"
  end
end


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

void Main() {
  int n;
  R n;
  int a[n];
  rep(i,n) R a[i];
  deque<int> d;
  rep(i,n) {
    if(i%2) d.push_front(a[i]);
    else d.push_back(a[i]);
  }
  vector<int> v;
  rep(i,n) {
    v.push_back(d.front());
    d.pop_front();
  }
  if(n%2) reverse(all(v));
  PR(v,v.size());
}

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


Measured memory_bytes: 5496
#ifdef MY_LOCAL
#define MY_NAMESPACE(ns) namespace ns {
#define MY_NAMESPACE_    }
#define MY_DEBUG(s)      s
#else
#define MY_NAMESPACE(ns) 
#define MY_NAMESPACE_    
#define MY_DEBUG(s)      
#endif

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

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

#define EPS (1e-7)
#define IINF ((int)1e9)


MY_NAMESPACE(testbed)
bool ABC167F_order(pll const& lhs, pll const& rhs)
{
	// first:  open
	// second: close

	bool retval;

	int lhs_sign = 0;
	if (lhs.first > lhs.second)
		lhs_sign = 1;  // more open
	else if (lhs.first < lhs.second)
		lhs_sign = -1;  // more close

	int rhs_sign = 0;
	if (rhs.first > rhs.second)
		rhs_sign = 1;
	else if (rhs.first < rhs.second)
		rhs_sign = -1;

	if (lhs_sign != rhs_sign)
		retval = lhs_sign > rhs_sign;
	else
	{
		if (lhs_sign >= 0)
		{
			//if (lhs.second != rhs.second)
				retval = lhs.second < rhs.second;
			//else
			//	retval = lhs.first > rhs.first;
		}
		else
		{
			//if (lhs.second != rhs.second)
			//	retval = lhs.second > rhs.second;
			//else
				retval = lhs.first > rhs.first;
		}
	}

	return retval;
}

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

	int n;
	cin >> n;
	vector<pll> num_live_open_and_close(n);
	for (int i = 0; i < n; i++)
	{
		string s;
		cin >> s;
		for (auto it = s.begin(); it != s.end(); it++)
		{
			if (*it == '(')
			{
				num_live_open_and_close[i].first++;
			}
			else  // *it==')'
			{
				if (num_live_open_and_close[i].first > 0)
					num_live_open_and_close[i].first--;
				else
					num_live_open_and_close[i].second++;
			}
		}
	}

	sort(num_live_open_and_close.begin(), num_live_open_and_close.end(), ABC167F_order);

	ll level = 0;
	for (auto it = num_live_open_and_close.begin(); it != num_live_open_and_close.end(); it++)
	{
		level -= it->second;
		if (level < 0)
		{
			cout << "No" << "\n";
			return 0;
		}
		level += it->first;
	}
	if (level == 0)
		cout << "Yes" << "\n";
	else
		cout << "No" << "\n";
	return 0;
}
MY_NAMESPACE_

Measured memory_bytes: 18756
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
// const int MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
// cout << fixed << setprecision(10) << ans << endl; 有効桁数指定
// *min_element(c + l, c + r) *max_element(c + l, c + r) 配列の中のmin-max
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// ~ は、-1の時だけfalse


int main () {

    string s;cin>>s;

    int n=s.size()/2;

    int cnt=0;

    rep(i,s.size()) {
        if (s[i]=='p') cnt++;
    }

    cout<<n-cnt<<endl;

}

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

int main() {
  long long N, K;
  cin >> N >> K;
  vector<long long> A(N);
  vector<long long> round;
  vector<long long> maps(N+1, -1);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  int now = 1;
  while(maps.at(now) == -1) {
    maps.at(now) = round.size();
    round.push_back(now);
    now = A.at(now-1);
  }
  long long period = round.size() - maps.at(now);
  long long start = maps.at(now);
  if (K < start) {
    cout << round.at(K) << endl;
  } else {
    K -= start;
    K %= period;
    cout << round.at(start+K) << endl;
  }
}


Measured memory_bytes: 8416
import Data.List.Split

toInt :: String -> Int
toInt = read :: String -> Int

isHaiku :: [Int] -> String
isHaiku l
  | (sum l == 5+7+5) && (product l == 5*7*5) = "YES"
  | otherwise = "NO"

main = do
  s <- getLine
  putStrLn $ isHaiku (map toInt (splitOn " " s))

Measured memory_bytes: 508
n = int(input())
l = [0]*n
k = [0]*n
for i in range(n):
    x,y = map(int,input().split())
    l[i]=x+y
    k[i]=x-y
print(max(abs(max(l)-min(l)), abs(min(l)-max(l)), abs(max(k)-min(k)), abs(min(k)-max(k))))

Measured memory_bytes: 24664
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <tuple>
#include <stdbool.h>
#include <bitset>
#include <string>
#include <boost/multiprecision/cpp_int.hpp>

namespace mp = boost::multiprecision;
using namespace std;


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

    int sum = 0;
    int max = 0;
    for(int i = 0 ; i < n ; ++i) {
        int p;
        cin >> p;
        sum += p;
        if(max < p) {
            max = p;
        }
    }
    sum -= max / 2;
    cout << sum << endl;
    return 0;
}

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

#define ifor(a , b) for(int i = a ; i < b ; i++ )

using namespace std ;

int main()
{
  int n ;
  scanf("%d" , &n) ;
  string st ;
  cin >> st ;
  auto res = unique(st.begin() , st.end()) ;
  st = string(st.begin() , res) ;
  cout << st.length() ;
  return 0 ;
}

Measured memory_bytes: 512
package main

import "fmt"

var N = 1000000007

func main() {
	var n, m int
	fmt.Scanf("%d %d", &n, &m)
	a := factorization(m)
	r := 1
	for _, v := range a {
		r = r * comb(v+n-1, v) % N
	}
	fmt.Println(r)
}

func factorization(n int) map[int]int {
	a := make(map[int]int)
	for i := 2; i*i <= n; {
		if n%i == 0 {
			a[i]++
			n /= i
		} else {
			i++
		}
	}
	if n > 1 {
		a[n]++
	}
	return a
}

func pow(x, n int) int {
	r := 1
	for ; n > 0; n /= 2 {
		if n%2 == 1 {
			r = r * x % N
		}
		x = x * x % N
	}
	return r
}

func comb(n, m int) int {
	return factorial(n, n-m+1) * pow(factorial(m, 2), N-2) % N
}

func factorial(n, m int) int {
	r := 1
	for i := m; i <= n; i++ {
		r = r * i % N
	}
	return r
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<functional>
#include<map>
#include<unordered_set> 
#include<cmath>
using namespace std;
long long p  = 998244353;
//long long p = 1000000007;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define qin pair<int,pin>
#define V vector
#define Endl endl
#define veb vector<bool>
#define rev(s) reverse(s.begin(),s.end())
#define lower(h,val) lower_bound(h.begin(),h.end(),val)
#define upper(h,val) upper_bound(h.begin(),h.end(),val)
#define mint modint<998244353>
#define end_s(a) cout <<a<<endl;return 0
template <std::uint_fast64_t Modulus> class modint {
	using u64 = std::uint_fast64_t;

public:
	u64 a;

	constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
	constexpr u64 &value() noexcept { return a; }
	constexpr const u64 &value() const noexcept { return a; }
	constexpr modint operator+(const modint rhs) const noexcept {
		return modint(*this) += rhs;
	}
	constexpr modint operator-(const modint rhs) const noexcept {
		return modint(*this) -= rhs;
	}
	constexpr modint operator*(const modint rhs) const noexcept {
		return modint(*this) *= rhs;
	}
	constexpr modint operator/(const modint rhs) const noexcept {
		return modint(*this) /= rhs;
	}
	constexpr modint &operator+=(const modint rhs) noexcept {
		a += rhs.a;
		if (a >= Modulus) {
			a -= Modulus;
		}
		return *this;
	}
	constexpr modint &operator-=(const modint rhs) noexcept {
		if (a < rhs.a) {
			a += Modulus;
		}
		a -= rhs.a;
		return *this;
	}
	constexpr modint &operator*=(const modint rhs) noexcept {
		a = a * rhs.a % Modulus;
		return *this;
	}
	constexpr modint &operator/=(modint rhs) noexcept {
		u64 exp = Modulus - 2;
		while (exp) {
			if (exp % 2) {
				*this *= rhs;
			}
			rhs *= rhs;
			exp /= 2;
		}
		return *this;
	}
};
vel pa;
int root(int x) {
	if (pa[x] == -1) { return x; }
	int ans = root(pa[x]); pa[x] = ans;
	return ans;
}
void marge(int x, int y) {
	x = root(x);
	y = root(y);
	if (x != y) {pa[x] = y;}
}
signed main() {
	int n; cin >> n;
	string s; cin >> s;
	int ans = 1;
	for (int i = 1; i < n; i++) {
		if (s[i - 1] != s[i]) { ans++; }
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ref(i,x,y)for(int i=x;i<=y;++i)
const int N=100010;
long long ans;
int n,m,x1,x2,d[N],fa[N],s1[N],s2[N],a[N];bool vis[N],tg;
vector<int> e[N];
void dfs(int f,int x){
	fa[x]=f;vis[x]=1;s1[x]=1-d[x];s2[x]=d[x];
	ref(i,0,(int)e[x].size()-1){
		int y=e[x][i];if(y==f)continue;
		if(!vis[y])d[y]=d[x]^1,dfs(x,y),s1[x]+=s1[y],s2[x]+=s2[y];
		else if(!x1)x1=x,x2=y,tg=d[x]==d[y];
	}
}
int main(){
	cin>>n>>m;
	ref(i,1,m){int x,y;cin>>x>>y;e[x].push_back(y);e[y].push_back(x);}
	dfs(0,1);
	if((!x1||x1&&!tg)&&s1[1]!=s2[1]||x1&&n%2)puts("-1");else{
		if(x1&&!tg){
			ref(i,2,n)ans+=abs(s1[i]-s2[i]);
			for(int i=x1;i!=x2;i=fa[i])a[++a[0]]=s1[i]-s2[i];
			a[++a[0]]=s1[1]-s2[1];
			sort(a+1,a+a[0]+1);int x=a[a[0]/2+1];
			ref(i,1,a[0])ans-=abs(a[i]),ans+=abs(a[i]-x);
		}else{
			if(tg){
				ans=abs(n/2-s2[1]);
				int t=n/2-s2[1];
				for(int i=x1;i!=x2;i=fa[i])s2[i]+=t;
				for(int i=x2;i;i=fa[i])s2[i]+=t*2;
			}
			ref(i,2,n)ans+=abs(s1[i]-s2[i]);
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 15616