akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <iostream>
#include <vector>
#include <bitset>
#include <queue>
#include <map>
#include <utility>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define MOD 10000000000　+　7    //10億　= 10^9になってる
#define juu 100000               //10万 10e5
#define hyaku 1000000            //100万　10e6
#define mINF -922337200085470000 //llのmax-1桁の小さい方
#define pINF 922337203600070000  //llのmax-1桁のデカい方
#define uINF 1844674407300000000 //ullのmax-1桁してる
#define pi 3.1415926535897932384
ll factor[300];
ll memory[300];
/*素朴法で計算
factorは必ずmemset(factor,0,sizeof(factor));
グローバルであるmemoryに個数を書き込む
memory配列の走査にはfactorの要素を使う*/
void primefac(ll num)
{
    int i = 0, kosuu = 0;
    while (*(factor + i) != 0)
    {
        while (num % *(factor + i) == 0)
        {
            num /= *(factor + i);
            memory[*(factor + i)] += 1;
        }
        if (num == 1)
            break;
        i++;
    }
}
/*グローバルにあるfactorに素数書き込む.個数を返すので配列は-1しろforは<*/
int elast(ll number)
{
    ll tmp = 0;
    int flag = 0;
    *factor = 2;
    for (int i = 3; i <= number; i++)
    {
        flag = 0;
        for (int j = 0; j <= tmp; j++)
        {
            if (i % (*(factor + j)) == 0)
            {
                flag = 1;
                break;
            }
        }
        if (flag)
            continue;
        tmp += 1;
        *(factor + tmp) = i;
    }
    return tmp + 2;
}
/*整数をqsortする為だけのもの*/
long long compare(const long long *a, const long long *b)
{
    if (*a < *b)
        return -1;
    else if (*a > *b)
        return 1;
    return 0;
}
/*intで収まる範囲であってくれ*/
ll nCr(int n, int r)
{
    ll val = 1;
    int i;
    if (r == 0)
        return 1;
    for (i = 0; i < n - r; i++)
    {
        val *= (n - i);
        val /= (i + 1);
    }
    return val;
}
/*intで収まる範囲であってくれ*/
ll nPr(int n, int r)
{
    ll val = 1;
    int i;
    for (i = 0; i < r; i++)
    {
        val *= (n - i);
    }
    return val;
}

void chmin(ll &a, ll b)
{
    if (a > b)
        a = b;
}
void chmax(ll &a, ll b)
{
    if (a < b)
        a = b;
}

/*
qsort(array,length,sizeof(int),(int(*)(const int*, const int*))compare);
使う時これをコピペ
*/

int main()
{
    char s[201], s2[201];
    ll n, max;
    max = 0;
    memset(s, 0, 201);
    memset(s2, 0, 201);
    cin >> s;
    strcpy(s2, s);
    n = strlen(s);
    for (int i = 0; i < n + 1; i++)
    {
        for (int j = i; j + (j - i) + 1 < n-1; j++)
        {
            if (strncmp(s + i, s2 + j + 1, j - i + 1) == 0)
            {
                chmax(max, 2 * (j - i + 1));
            }
        }
    }
    cout << max;
    return 0;
}


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

a,b = (n[2] - n[0]), (n[3] - n[1])

o1,o2 = (n[2] - b), (n[3] + a)
o3,o4 = (o1 - a),(o2 - b)

print(" ".join(list(map(str, [o1,o2,o3,o4]))))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t n,d,cnt=0;
  cin >> n >> d;
  for(int i=0;i<n;i++){
    int64_t a,b;
    cin >> a >> b;
    if(d>=sqrt(a*a+b*b))cnt++;
  }
  cout << cnt << endl;
}

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

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_E 100000
#define MAX_V 100000

struct edge {
	ll from, to, cost;
};
ll d[MAX_V];
int V, E;

edge es[MAX_E];

void shortest_path(int s) {
	rep(i, 0, V) d[i] = INF;
	d[s] = 0;
	while(true) {
		bool update = false;
		rep(i, 0, E) {
			edge e = es[i];
			if(d[e.from] != INF && d[e.to] > d[e.from] + e.cost) {
				d[e.to] = d[e.from] + e.cost;
				update = true;
			}
		}
		if(!update) break;
	}
}

bool find_negative_loop(int s) {
	//memset(d, 0, sizeof(d));
	fill(d, d + V, INF);
	d[s] = 0;
	rep(i, 0, V) {
		rep(j, 0, E) {
			edge e = es[j];
			if(d[e.to] > d[e.from] + e.cost) {
				d[e.to] = d[e.from] + e.cost;
				if(i == V - 1 && e.to == V - 1) return true;
			}
		}
	}
	return false;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> V >> E;
	rep(i, 0, E) {
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		es[i].from = a;
		es[i].to = b;
		es[i].cost = -c;
	}

	if(find_negative_loop(0)) {
		cout << "inf" << endl;
		return 0;
	}

	//shortest_path(0);
	cout << -d[V - 1] << endl;
}




Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cassert>
#include <cstring>
#include <vector>
#include <valarray>
#include <array>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <complex>
#include <random>

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr int TEN(int n) {return (n==0)?1:10*TEN(n-1);}

int main() {
    int a, b;
    cin >> a >> b;
    if (a <= 0 and 0 <= b) {
        cout << "Zero" << endl;
        return 0;
    }
    if (b < 0 and (b-a+1)%2 == 1) {
        cout << "Negative" << endl;
    } else {
        cout << "Positive" << endl;
    }
    return 0;
}

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

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

using namespace std;

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

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

  int result = 0;
  rep(i, 3) {
    if (s[i] == t[i]) {
      result++;
    }
  }
  cout << result << endl;

  return 0;
}


Measured memory_bytes: 256
// #include {{{
#include <array>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iterator>
#include <tuple>
#include <utility>
#include <random>
#include <limits>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cstdint>
#include <cassert>
// }}}

using namespace std;

// macros {{{
template<typename T, size_t N>
constexpr size_t NELEMS(T (&)[N]) { return N; }

template<typename InputIt>
void PRINT_RANGE(InputIt first, InputIt last)
{
    for(; first != last; ++first)
        cout << *first << (first==last ? "" : " ");
    cout << "\n";
}

template<typename T>
void PRINT_MATRIX(T mat, size_t nr, size_t nc)
{
    for(size_t r = 0; r < nr; ++r) {
        for(size_t c = 0; c < nc; ++c) {
            cout << mat[r][c] << (c==nc-1 ? "" : " ");
        }
        cout << "\n";
    }
}

#define FOR(i, start, end) for(int i = (start); i < (end); ++i)
#define REP(i, n) FOR(i, 0, n)
// }}}

// types {{{
using ll  = long long;
using ull = unsigned long long;
// }}}

int N;

bool done[100001] = {};

void solve()
{
    REP(_, N) {
        int l, r;
        cin >> l >> r;
        FOR(i, l, r+1) {
            done[i] = true;
        }
    }

    int ans = count(done+1, done+100001, true);
    cout << ans << "\n";
}

int main()
{
    cin >> N;

    solve();

    return 0;
}


Measured memory_bytes: 384
#include<stdio.h>

int main(void)
{
	unsigned long int  b, c;
	int i;
	char a[4];

	scanf("%s", &(a[0]));

	if (strcmp(a,"ABC") == 0) {
		printf("ARC");
	}

	else {
		printf("ABC");
	}

	return 0;
}

Measured memory_bytes: 2144
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdlib>
using namespace std;
int main()
{
	int a[5];
	while (~scanf("%d%d%d%d",&a[1],&a[2],&a[3],&a[4])){
		if(a[2]<=a[3] || a[1]>=a[4]) printf("0\n");
		else{
			sort(a+1,a+5);
			printf("%d\n",a[3]-a[2]);
		}
	}
	return 0;
}

Measured memory_bytes: 256
import math  # noqa: F401
from collections import deque  # noqa: F401
from itertools import combinations
from typing import Deque, Dict, List, Optional, Tuple, Union  # noqa: F401

import numpy as np


def count_sharp(C: List[List[str]]) -> int:
    n = 0
    for row in C:
        for e in row:
            if e == "#":
                n += 1
    return n


def main(H: int, W: int, K: int, C: List[List[str]]):
    ans = 0

    h_list = [x for x in range(0, H)]
    w_list = [x for x in range(0, W)]

    for num_row in range(H):
        for num_col in range(W):
            row_combs = list(combinations(h_list, num_row))
            col_combs = list(combinations(w_list, num_col))

            for row_comb in row_combs:
                for col_comb in col_combs:
                    C_np = np.array(C)
                    for row in row_comb:
                        C_np[row, :] = "*"
                    for col in col_comb:
                        C_np[:, col] = "*"

                    if count_sharp(C_np) == K:
                        ans += 1

    print(ans)


if __name__ == "__main__":
    H, W, K = map(int, input().split())
    C: List[List[str]] = []

    for _ in range(H):
        c: List[str] = list(input())
        C.append(c)

    main(H, W, K, C)


Measured memory_bytes: 27388
'use strict';
(function(input){
  input=input.trim().split(/\n/);
  input=input.map(str=>str.split(/\s+/).map(x=>x-0));
  const N=input[0][0],M=input[0][1];
  input.shift();
  const A=input[0];
  A.sort((a,b)=>a-b);
  input.shift();
  let counter=N;
  let last=0;
  let ans=0;
  input.sort((a,b)=>a[1]-b[1]);
  while((counter>0)&&(A.length>0)&&(input.length>0)){
    if(A[A.length-1]>=input[input.length-1][1]){
      counter--;
      ans+=A.pop();
      continue;
    }else{
      let BC=input.pop();
      counter-=BC[0];
      ans+=BC[1]*BC[0];
      last=BC[1];
    }
  }
  if(counter>0){
    while(counter>0){
      counter--;
      ans+=A.pop();
    }
  }
  else{
     ans+=counter*last;
  }
  console.log(ans);
})(require('fs').readFileSync('/dev/stdin','utf8'));


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

int main(void) {
    string  str;
    char letter;
    int index;
    int alphabet[26] = {};
    
    while(cin >> str) {
        for(int i = 0; i < str.length(); ++i) {
            letter = str[i];
            if(isalpha(letter)) {
                if(isupper(letter)) {
                    str[i] = tolower(letter);
                }
                index = str[i] - 'a';
                alphabet[index] += 1;
            }
        }
    }
    for(int i = 0; i < 26; ++i) {
        letter = 'a' + i;
        cout << letter << " : " << alphabet[i] << endl;
    }
    
    return 0;
}



Measured memory_bytes: 3140
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<ll, ll>> vpll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef vector<vll> vvll;
typedef map<int, int> mii;
typedef set<int> si;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define arep(i, v) for (auto i : v)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define fi first
#define se second
// #include <atcoder/all>
// using namespace atcoder;
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;
}
template <class T>
inline void dump(T &v) {
    irep(i, v) { cout << (*i) << ((i == --v.end()) ? '\n' : ' '); }
}
template <class T, class U>
inline void dump(map<T, U> &v) {
    irep(i, v) { cout << i->first << " " << i->second << '\n'; }
}
inline string getline() {
    string s;
    getline(cin, s);
    return s;
}
inline void yn(const bool b) { b ? fin("yes") : fin("no"); }
inline void Yn(const bool b) { b ? fin("Yes") : fin("No"); }
inline void YN(const bool b) { b ? fin("YES") : fin("NO"); }
struct io {
    io() {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
constexpr ll LLINF = 1LL << 61;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-11;

/* --------------------   ここまでテンプレ   -------------------- */


int main() {
    int n;
    cin>>n;
    vvi v(n,vi(2));
    rep(i,n)rep(j,2)cin>>v[i][j];
    bool ch=0;
    rep(i,n-2){
        if(v[i][0]!=v[i][1])continue;
        if(v[i+1][0]!=v[i+1][1])continue;
        if(v[i+2][0]!=v[i+2][1])continue;
        ch=1;
    }
    Yn(ch);
}


Measured memory_bytes: 3628
#include <iostream>
using namespace std;
typedef long long ll;
const int mod = 1e9+7;
int main(){
    ll p=0,q=0,x,y,n;
    int a,b,c,i;
    cin>>a>>b;
    for(i = 0;i < a;i++){
        cin>>n;
        p = p+n*(i)-n*(a-i-1);
        p = p%mod;
    }
    for(i = 0;i < b;i++){
        cin>>n;
        q = q+n*(i)-n*(b-i-1);
        q = q%mod;
    }
    
    cout<<p*q%mod<<endl;;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<algorithm>

using namespace std;

int main()
{
	int n,x,t;
	int c=1;

	cin >> n >> x >> t;

	while(1){
		if(n - x > 0){
			c++;
			n -= x;
		}
		else
			break;
	}
	cout << t * c << endl;
}

Measured memory_bytes: 3192
s = list(map(str,input()))
l = len(s)
cntf = 0
cntl = l-1
ans = 0

while cntf < cntl:
    if s[cntf] == s[cntl]:
        cntf += 1
        cntl -= 1
    else:
        if s[cntf] == "x":
            ans += 1
            cntf += 1
        elif s[cntl] == "x":
            ans += 1
            cntl -= 1
        else:
            print(-1)
            exit()

print(ans)

Measured memory_bytes: 4212
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
#define ln '\n'
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
typedef long long ll;
typedef unsigned long long ull; 
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
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; }
///////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    string S; cin >> S;
    bool ok = false;
    if (S[2]==S[3]&&S[4]==S[5]) ok = true;
    cout << (ok ? "Yes" : "No") << ln;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(X) (X).begin(),(X).end()
#define P 1000000007
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)

using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii; 
typedef vector<int> vi;

void solve() {
	string s, t;
	cin >> s >> t;
	
	int ans = 0;
	for(int i = 0; i < s.length(); i++) if(s[i] != t[i]) ans++;
	
	cout << ans << endl;
}

int main(){
#define MULTITEST 0
#if MULTITEST   
 
    CASET {
        solve();
    }
    
#else

    solve();
    
#endif

    return 0;
}

Measured memory_bytes: 3920
n=int(input())
multi3 = [int(x.strip()) for x in input().split()]
ans=1
flag=True
for i in multi3:
    if ans*i>10**18:
        flag=False
    elif i==0:
        flag=True
        ans=0
        break
    else:
        ans*=i
if(flag):
    print(ans)
else:
    print(-1)


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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define mp(a,b) make_pair((a),(b))
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int INF=1<<30;
const long long int INFLL=1LL<<58;
const double EPS=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
	os << "[";
	for (const auto &v : vec) {
		os << v << ",";
	}
	os << "]";
	return os;
}

struct Edge{ int u,v,cost; };
vector<pii> graph[800];

pair<int,int> dfs(int v,int p){
    pair<int,int> res(v,0);
    for(auto &e:graph[v]){
        if(e.first==p) continue;
        if(graph[e.first].size()==1) continue;
        
        auto tmp=dfs(e.first,v);
        tmp.second+=e.second;
        if(res.second<tmp.second) res=tmp;
    }
    
    return res;
}

void solve(){
    int n;
    while(true){
        cin >> n;
        if(!n) break;

        for(auto &v:graph) v.clear();
        
        vector<int> p(n-1),d(n-1);
        rep(i,0,n-1){
            cin >> p[i];
            --p[i]; //辺(i+1,p[i])
        }
        rep(i,0,n-1) cin >> d[i];
        rep(i,0,n-1){
            graph[i+1].push_back(make_pair(p[i],d[i]));
            graph[p[i]].push_back(make_pair(i+1,d[i]));
        }
        
        int ans=0;
        rep(i,0,n-1){
            ans+=d[i]; //撤去にかかる時間
            if(graph[i+1].size()!=1 and graph[p[i]].size()!=1) ans+=d[i]*2; //橋を渡る時間
        }
        
        rep(i,0,n){
            if(graph[i].size()>1){
                int v=dfs(i,-1).first;
                ans-=dfs(v,-1).second; //直径を構成する橋は往復しないので片道分引く
                break;
            }
        }
        
        cout << ans << endl;
    }
}

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

Measured memory_bytes: 1352
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
const int MOD=1e9+7;


int main() {
    ios_base::sync_with_stdio(false);

    int n,m;
    cin >> m >> n;
    vector<int> c(n);
    rep(i,n) cin >> c[i];
    vector<vector<int>> dp(n+1,vector<int>(m+1,1e9));
    dp[0][0]=0;
    rep(i,n) {
        rep(j,m+1) {
            if (j<c[i]) dp[i+1][j]=dp[i][j];
            else dp[i+1][j]=min(dp[i][j],dp[i+1][j-c[i]]+1); 
        }
    }
    cout << dp[n][m] << endl;

    return 0;   
}



Measured memory_bytes: 7116
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  int N, M;
  cin >> N >> M;
 
  vector<int> s(M, 0);
  vector<int> c(M, 0);
  for (int i = 0; i < M; i++) {
    cin >> s.at(i) >> c.at(i);
  }
    
  vector<int> result(N,0);
  bool exist = true;
  
  for (int i = 0; i < M; i++) {
    //sが同じでかつcが異なるとアウト
    if (result.at(s.at(i) - 1) != 0 && c.at(i) != result.at(s.at(i) - 1)) {
      exist = false;
      break;
    }
    //N>=2でかつ左から1桁目に0が代入されようとするのはアウト
    if (N >=2 && s.at(i) == 1 && c.at(i) == 0) {
      exist = false;
    }
    result.at(s.at(i) - 1) = c.at(i);
  }
  
  //N>=2でかつ左から1桁目が0のときは、代わりに1を入れる
  if (N >= 2 && result.at(0) == 0) {
    result.at(0) = 1;
  }
  
  if (exist) {
    int num = 0;
    for (int i = 0; i < N; i++) {
      num += result.at(i) * pow(10, N-i);
    }
    num /= 10;
    cout << num;
  } else {
    cout << -1;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    int ans = 0;
    a.push_back(-1);
    int now = a[0];
    int cnt = 1;
    for(int i = 1; i <= n; i++){
        if(now == a[i]){
            cnt++;
        }else{
            ans += cnt / 2;
            cnt = 1;
            now = a[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
/// Code By t_bone_289 (Tushar Singh)
/// An Immature Programmer.... I'm still developing !!
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define pll pair<ll,ll>
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define endl '\n'
#define M 1000000007
#define error(x) cout << #x << " = " << x << endl;
#define pi 3.14159265358979323846
typedef long long ll;
typedef double d;
typedef long double ld;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
ll powmod(ll base,ll exp,ll MOD){ll res=1;while(exp>0){if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return (res%MOD);}
ll mpow(ll base,ll exp){ll res=1;while(exp>0){if(exp%2==1) res=(res*base);base=(base*base);exp/=2;}return (res);}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,q;
    string s;
    cin>>n>>q;
    cin>>s;
    vector<ll> v(n,0);
    for(ll i=1;i<n;i++)
    {
        if(s[i]=='C' && s[i-1]=='A')
        {
            v[i]=1;
        }
    }
    for(ll i=1;i<n;i++)
    {
        v[i]+=v[i-1];
    }
//    for(auto x:v)
//    {
//        cout<<x<<' ';
//    }
//    cout<<endl;
    while(q--)
    {
        ll l,r;
        cin>>l>>r;
        l--;
        r--;
        if(l!=0)
        {
            cout<<(v[r]-v[l])<<endl;
        }
        else
        {
            cout<<v[r]<<endl;
        }
    }
    return 0;
}



Measured memory_bytes: 1872
#include <bits/stdc++.h>
using namespace std;
#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 s;
  cin >> s;
  bool ans=true;
  int answ=0;
  
  while(ans){
    s.pop_back();
    s.pop_back();
    bool cor = true;
    
    rep(i,s.size()/2){
      if(!(s[i]==s[i+s.size()/2])){
        cor=false;
        break;
      }
    }
    if(cor){
      answ=s.size();
      break;
    }
    
  }
  cout << answ << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

int h,w;
vector<vector<char> > g(2010,vector<char>(2010,'#'));
vector<vector<int> > gl(2010,vector<int>(2010,0));
vector<vector<int> > gr(2010,vector<int>(2010,0));
vector<vector<int> > gu(2010,vector<int>(2010,0));
vector<vector<int> > gd(2010,vector<int>(2010,0));

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>h>>w;
    FOR(i,1,h+1)FOR(j,1,w+1) cin>>g[i][j];
    int ans=0;
    FOR(i,1,h+1){//左
      int cnt=0;
      FOR(j,1,w+1){
        if(g[i][j]=='#'){
          cnt=0;
          gl[i][j]=0;
        }else{
          gl[i][j]=cnt;
          cnt++;
        }
      }
    }
    FOR(i,1,h+1){//右
      int cnt=0;
      for(int j=w;j>=1;j--){
        if(g[i][j]=='#'){
          cnt=0;
          gr[i][j]=0;
        }else{
          gr[i][j]=cnt;
          cnt++;
        }
      }
    }
    FOR(j,1,w+1){//上
      int cnt=0;
      FOR(i,1,h+1){
        if(g[i][j]=='#'){
          cnt=0;
          gu[i][j]=0;
        }else{
          gu[i][j]=cnt;
          cnt++;
        }
      }
    }
    FOR(j,1,w+1){//右
      int cnt=0;
      for(int i=h;i>=1;i--){
        if(g[i][j]=='#'){
          cnt=0;
          gd[i][j]=0;
        }else{
          gd[i][j]=cnt;
          cnt++;
        }
      }
    }
    FOR(i,1,h+1)FOR(j,1,w+1){
      if(g[i][j]=='#') continue;
      int cnt=gl[i][j]+gr[i][j]+gu[i][j]+gd[i][j]+1;
      if(ans<cnt){
        ans=cnt;
        //cout<<ans<<' '<<i<<' '<<j<<endl;
      }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 67840
//  ____            _                  _                       _       _
// |  _ \ _   _ ___| |_    ___ _ __   | |_ ___ _ __ ___  _ __ | | __ _| |_ ___
// | |_) | | | / __| __|  / __| '_ \  | __/ _ \ '_ ` _ \| '_ \| |/ _` | __/ _ \
// |  _ <| |_| \__ \ |_  | (__| |_) | | ||  __/ | | | | | |_) | | (_| | ||  __/
// |_| \_\\__,_|___/\__|  \___| .__/___\__\___|_| |_| |_| .__/|_|\__,_|\__\___|
//                            |_| |_____|               |_|

//https://github.com/manta1130/Competitive_Programming_Template_Rust

#[macro_use]
mod input {

    use std;
    use std::io;

    const SPLIT_DELIMITER: char = ' ';

    #[macro_export]
    #[allow(unused_macros)]
    macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

    #[allow(dead_code)]
    pub fn input_line_str() -> String {
        let mut s = String::new();
        io::stdin().read_line(&mut s).unwrap();
        s.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn p<T>(t: T)
    where
        T: std::fmt::Display,
    {
        println!("{}", t);
    }

    #[allow(dead_code)]
    pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<Vec<T>> = Vec::new();

        for _ in 0..line {
            let vec_line = input_vector();
            v.push(vec_line);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector<T>() -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<T> = Vec::new();

        let s = input_line_str();
        let split_result = s.split(SPLIT_DELIMITER);
        for z in split_result {
            let buf = match z.parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector_row<T>(n: usize) -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v = Vec::with_capacity(n);
        for _ in 0..n {
            let buf = match input_line_str().parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    pub trait ToCharVec {
        fn to_charvec(&self) -> Vec<char>;
    }

    impl ToCharVec for String {
        fn to_charvec(&self) -> Vec<char> {
            self.to_string().chars().collect::<Vec<_>>()
        }
    }
}

use input::*;

fn main() {
    let (a, b): (usize, usize);
    input!(a, b);
    let c = a * b;
    if c % 2 != 0 {
        p("Yes");
    } else {
        p("No");
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <iostream>
#include <ctime>
using namespace std;
#define _LL long long
#define rep(i, n) for (_LL i = 0; i < (_LL)(n); i++)
#define vecrep(itr, v) for (auto itr = (v).begin(); itr != (v).end(); itr++)

int main()
{
    _LL n; cin >> n;
    vector<_LL> a(n);
    rep(i, n) cin >> a[i];
    _LL tallest = a[0];
    _LL ans = 0;
    rep(i, n)
    {
        if( a[i] < tallest )
        {
            ans += (tallest - a[i]);
        }
        else
        {
            tallest = a[i];
        }
    }
    cout << ans;
    return 0;    
}

Measured memory_bytes: 4836
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n+1],i,coun=0;
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    for(i=1;i<=n;i++)
    {
        if(i%2!=0&&a[i]%2!=0)
        {
            coun++;
        }
    }
    cout<<coun<<endl;
}


Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<math.h>
#include<string.h>
#include<set>
#include<stack>
#include<utility>
#include<queue>
#include<list>
#include<vector>


#define inf 0x3f3f3f3f
#define ii pair<int,int>
#define iii pair<int,ii>
#define pb push_back

using namespace std;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef long long ll;

const int maxn  = 265;
int f[maxn][maxn] , anc[maxn] , n, aux ,vis[maxn] , x ,y;

vi adj[maxn];
ii red[maxn] , blue[maxn];

void add_edge(  int a, int b , int c ) {
	f[a][b] = 1;
	adj[a].pb(b);
	adj[b].pb(a);
}

bool bfs ( int s, int t ){
	++aux;
	vis[s] = aux;
	
	queue<int> q;
	q.push(s);
	
	while ( !q.empty ()) {
		int u = q.front(); q.pop();
		
		for(size_t j =0 ; j < adj[u].size() ;j++){
			int next = adj[u][j];
			if ( vis[next] == aux || f[u][next] <= 0)continue;
			
			anc[next] = u;
			vis[next] = aux;
			q.push(next);
		}
	}
	return vis[t] == aux;
}

int max_flow(int s, int t){
	int mf = 0;
	while ( bfs ( s, t ) ){
		x = t;
		
		while ( x != s ) {
			f[anc[x]][x]--;
			f[x][anc[x]]++;
			x = anc[x];
		}
		
		++mf;
	}
	return mf;
}

int main(){
	//~ freopen("in","r",stdin);
	//~ ios::sync_with_stdio(0); cin.tie(0);
	
	
	cin >> n;
	
	aux = -inf;
	memset( f, 0, sizeof f);
	memset( vis ,-inf , sizeof vis );
	
	
	for(int i = 0 ;i < n;i++){
		cin >> x >> y;
		red[i] = {x, y};
	}
	
	for(int i = 0 ;i < n;i++){
		cin >> x >> y;
		blue[i] = { x, y};
	}	
	
	int ss = 250;
	int st = 251; 

	 for(int i = 0 ;i < n;i++){
		for(int j = 0 ;j < n;j++){
			if ( red[i].first < blue[j].first && red[i].second  < blue[j].second) {
				add_edge( i ,n + j , 1 ) ;
				add_edge(ss, i, 1);
				add_edge (n + j , st, 1);
			}
		}
	 }
	 
	cout << max_flow( ss, st )  <<'\n';
}



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

using namespace std;

int main(){
        string s;
        cin>>s;
        int res[2];
        for(int i=0;i<(int)s.size();i++){
                if(s[i]=='A'){
                        res[0]=i;
                        break;
                }
        }
        for(int i=(int)s.size()-1;i>=0;i--){
                if(s[i]=='Z'){
                        res[1]=i;
                        break;
                }
        }
        cout<<res[1]-res[0]+1<<endl;
        return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include<string.h>

int main(void)
{
	char S[100];
	int i;

	scanf("%s", S);

	for(i = 0; i < strlen(S); i++)
	{
		S[i] = 'x';
	}
	printf("%s", S);

	return 0;
}


Measured memory_bytes: 128
# def add_node(tree, counter, ope, node, value):
#     if node in ope:
#         value += ope[node]
#     counter[node - 1] += value

#     if node in tree:
#         for i in tree[node]:
#             add_node(tree, counter, ope, i, value)


n, q = map(int, input().split())

tree = {}

for i in range(n - 1):
    a, b = map(int, input().split())
    if a not in tree:
        tree[a] = [b]
    else:
        tree[a].append(b)

ope = {}
for j in range(q):
    p, x = map(int, input().split())
    if p not in ope:
        ope[p] = x
    else:
        ope[p] += x

counter = [0] * n

# print(tree, ope)

# for k in ope:
for i in range(1, n + 1):
    if i in ope:
        counter[i - 1] += ope[i]
    if i in tree:
        for j in tree[i]:
            counter[j - 1] += counter[i - 1]
    
# add_node(tree, counter, ope, 1, 0)

print(*counter)



Measured memory_bytes: 84844
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>
#include <cmath>
#include <functional>
#include <map>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

template <class T>
void debug(T& v)
{
    for(auto& x: v) cout << x << " ";
    cout << endl;
}

int main()
{
    ll X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;
    vector<ll> p(A), q(B), r(C);
    for(auto& x: p) cin >> x;
    for(auto& x: q) cin >> x;
    for(auto& x: r) cin >> x;
    sort(p.begin(), p.end(), greater<ll>());
    sort(q.begin(), q.end(), greater<ll>());
    sort(r.begin(), r.end(), greater<ll>());

    ll x=0, y=0;
    priority_queue<ll, vector<ll>, greater<ll> > R, G;
    for(int i=0; i<X; i++) R.push(p[i]);
    for(int i=0; i<Y; i++) G.push(q[i]);

    ll z = 0;
    while(z < C){
        // cout << R.top() << " " << G.top() << endl;
        if(R.top() > r[z] && G.top() > r[z]) break;
        if(R.top() < G.top()){
            R.pop();
            R.push(r[z]);
        }
        else{
            G.pop();
            G.push(r[z]);
        }
        z++;
    }

    ll ans = 0;
    while(!R.empty()){
        ans += R.top(); R.pop();
    }
    while(!G.empty()){
        ans += G.top(); G.pop();
    }
    cout << ans << endl;
}

Measured memory_bytes: 4852
#include<stdio.h>

int main(void){
	int S,h,m,s;
	scanf("%d",&S);
	h = S/3600;
	m = (S-h*3600)/60;
	s = S-h*3600-m*60;
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}

Measured memory_bytes: 592
#include "bits/stdc++.h"
using namespace std;
int main(){
    int n,a,i,ma=0,ans=0;
    cin >> n;
    for(i=0;i<n;i++){
        cin >> a;
        ans += a;
        ma = max(ma,a);
    }
    cout << ans - ma/2 << endl;
    return 0;
}

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

int main(){
    int a,b,c;  cin>>a>>b>>c;
    int x=max(max(a,b),max(a,c));

    if(x==a)a*=10;
    else if(x==b)b*=10;
    else c*=10;

    cout<<a+b+c<<endl;



    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int min(int a,int b){
  if(b > a){
    return a;
  }
  return b;
}

int main(void){
  int A,B,C;
  scanf("%d%d%d",&A,&B,&C);

  printf("%d\n",min(B/A,C));

  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
map<string,int> M;
int main()
{
  int N,mx=0;
  cin>>N;
  while(N--)
  {
    string S;
    cin>>S;
    M[S]++;
    mx=max(mx,M[S]);
  }
  for(map<string,int>::iterator it=M.begin();it!=M.end();it++)
    if(it->second==mx)
      cout<<it->first<<endl;
  return 0;
}

Measured memory_bytes: 25216
#include<bits/stdc++.h>
using namespace std;
long long q, h, s, d, n;
int main()
{
	cin >> q >> h >> s >> d >> n;
	long long t1 = q * 8ll, t2 = h * 4ll, t3 = s * 2ll, t4 = d;
	long long x = min(min(t1, t2), min(t3, t4));
	if(x != t4) printf("%lld\n", x * n / 2ll);
	else if(n % 2 == 0) printf("%lld\n", (long long)x * n / 2ll);
	else 
	{
		long long y = min(t1, min(t2, t3));
		printf("%lld\n", (long long)(n - 1) * x / 2ll + (long long)y / 2);
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REP(i,n) FOR(i,0,n)
int main()
{
    int n,dp1[1000000],dp2[1000000],dp3[1000000],dp[1000000];
    cin>>n;
    int arreglo[1000000][3];
    
    REP(i,n){
      REP(j,3)
        cin>>arreglo[i][j];
    }
    dp1[0]=arreglo[0][0];
    dp2[0]=arreglo[0][1];
    dp3[0]=arreglo[0][2];
    dp[0]=max({dp1[0],dp2[0],dp3[0]});
    FOR(i,1,n){
      dp1[i]=max(dp2[i-1]+arreglo[i][0],dp3[i-1]+arreglo[i][0]);
      dp2[i]=max(dp1[i-1]+arreglo[i][1],dp3[i-1]+arreglo[i][1]);
      dp3[i]=max(dp2[i-1]+arreglo[i][2],dp1[i-1]+arreglo[i][2]);
      dp[i]=max({dp1[i],dp2[i],dp3[i]});
      
    }
    cout<<dp[n-1];
    return 0;}

Measured memory_bytes: 14720
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();
        int d = scanner.nextInt();
        if((c+(b-1))/b>(a+(d-1))/d) System.out.println("No");
        else System.out.println("Yes");
    }
}


Measured memory_bytes: 35588
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    loop {
        let n:f64 = read();
        if n == 0.0 {
            break;
        }
        let arr:Vec<f64> = (0..n as usize).map(|_| read()).collect();
        let av:f64 = arr.iter().sum::<f64>() / n;
        let var = arr.iter().fold(0f64, |acc, val| acc + (val-av).powf(2.0))/n;
        let std_dev = var.sqrt();
        println!("{}", std_dev);
    }
}


Measured memory_bytes: 5092
import java.util.*;

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

        Scanner sc = new Scanner(System.in);
        
        String S = sc.next();
        boolean isOK = true;
        boolean isC = false;
        
        for(int i = 0; i < S.length(); i++){
            
            char x = S.charAt(i);
            
            if( i == 0){
                if( x != 'A' ){
                    isOK = false;
                    break;
                }
            }else if( i == 1 ){
                if( x - 'Z' <= 0 ){
                    isOK = false;
                    break;  
                }
            }else if( i == S.length()-1 ){
                if( x == 'C' || !isC || x - 'Z' <= 0){
                    isOK = false;
                    break;
                }
            }else if( isC ){
                if( x - 'Z' <= 0 ){
                    isOK = false;
                    break;
                }
            } else {
                if( x == 'C' ){
                    isC = true;
                }else if( x - 'Z' <= 0 ){
                    isOK = false;
                    break;
                }
            }
            
        }
        
        System.out.println( isOK ? "AC" : "WA" );
    }
}


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

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=(n); i--)
#define LREP(lst,itr) for(auto itr = lst.begin(); itr != lst.end(); ++itr)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define P(s) cout<<(s)<<endl
#define P2(a, b) cout<<(a)<<" "<<(b)<<endl
#define P3(a, b, c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl
#define V2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main(){
    int N, A, x, y;
    cin >> N;
    vector<pair<int, int>> member[N];
    REP(i,0,N){
        cin >> A;
        REP(j,0,A){
            cin >> x >> y;
            member[i].push_back(make_pair(x-1, y));
        }
    }

    int ans=0;
    REP(bit,1,1<<N){
        bool flag=true;
        REP(j,0,N){
            if(bit & 1<<j){
                for(auto m : member[j]){
                    if((1<<m.first & bit ? 1 : 0) != m.second) flag=false;
                }
            }
        }
        if(flag){
            int kari=0;
            REP(i,0,N){
                kari += (bit & 1<<i ? 1 : 0);
                //P2(bit, kari);
            }
            ans = max(kari, ans);
        }
    }

    P(ans);
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline


def main():
    n, m, x = map(int, input().split())
    a = list(map(int, input().split()))
    print(
        min(
            sum([i in a for i in range(x, n + 1)]),
            sum([i in a for i in range(x, 0, -1)]),
        )
    )


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
int H,W;
char M[52][52];
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};

bool solve(int x,int y){
    for(int i=0;i<4;i++){
        int rx=x+dx[i];
        int ry=y+dy[i];
        if(M[rx][ry]=='#')return true;
    }
    return false;
}
int main(){
    std::cin>>H>>W;
    for(int i=1;i<=H;i++){
        for(int j=1;j<=W;j++){
            std::cin>>M[i][j];
        }
    }
    for(int i=1;i<=H;i++){
        for(int j=1;j<=W;j++){
            if(M[i][j]=='#'){
                if(!solve(i,j)){
                    std::cout<<"No"<<std::endl;
                    return 0;
                }
            }
        }
    }
    std::cout<<"Yes"<<std::endl;
    return 0;
}


Measured memory_bytes: 256
N, T = map(int, input().split())
A = list(map(int, input().split()))

low = [A[0]]
high = [A[N-1]]
for i in range(1, N):
    low.append(min(A[i], low[i-1]))
for i in reversed(range(N-1)):
    high.append(max(A[i], high[N-2-i]))

high.reverse()
max_gap = max([high[i] - low[i] for i in range(N)])
num = 0
first = True
for i in range(N):
    if high[i] - low[i] == max_gap:
        if first:
            idx = i
            num += 1
            first = False
        else:
            if low[idx] != low[i]:
                idx = i
                num += 1

print(num)


Measured memory_bytes: 14480
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
string str;

int main(){
	cin >> str;
	string abc[6] = {"abc", "acb","bac", "bca", "cab", "cba"};
	string ans = "No";
	for(int i = 0; i < 6; i++){if(str == abc[i])ans = "Yes";}
	cout << ans << endl;
	return 0;
}

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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define ALL(c) (c).begin(), (c).end()
#define sz(v) (int)v.size()
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;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
const char EOL = '\n';

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    solve();
    return 0;
}

template<typename D, typename F> class BinarySearch {
    D left;
    D right;
    F func;

    public:
        BinarySearch(D l, D r, F f) {
            left = l;
            right = r;
            func = f;
        }

        D calc() {
            while (abs(right - left) > 1) {
                D m = (left + right) / 2;
                if (func(m)) {
                    right = m;
                } else {
                    left = m;
                }
            }
            return right;
        }
};
 
void solve() {
    int n;
    ll k;
    cin >> n >> k;

    vector<ll> a(n);
    vector<ll> f(n);
    REP(i, n) cin >> a[i];
    REP(i, n) cin >> f[i];
    sort(ALL(a));
    sort(ALL(f), greater<int>());

    auto isOk = [&](ll m) {
        ll x = k;
        bool b = true;
        REP(i, n) if (a[i] * f[i] > m) {
            x -= a[i] - m / f[i];
            if (x < 0) {
                b = false;
                break;
            }
        }
        return b;
    };

    BinarySearch<ll, function<bool(ll)>> bs = BinarySearch<ll, function<bool(ll)>>(-1LL, LINF, isOk);
    cout << bs.calc() << EOL;
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;


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

	ll ans = 0;
	for(int i = 1; i <= n; ++i)
	{
		if((i % 3) * (i % 5) > 0)
		{
			ans += i;
		}
	}
	cout << ans << endl;
}

int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 3608
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<functional>
typedef long long ll;
using namespace std;
typedef pair<int,int> p;

int main(){
  int n;
  vector<int> w;
  cin >> n;
  for(int i=0;i<n;i++){
    int t;
    cin >> t;
    w.push_back(t);
  }
  //sort(w.begin(),w.end());
  int minmin = 1000000007;
  for(int i=0;i<n;i++){
    int left = 0;
    int right = 0;
    int flag = i;
    for(int j=0;j<n;j++){
      if(j<=flag) {
        left+=w[j];
      }else{
        right+=w[j];
      }
    }
    //cout << abs(left-right) << endl;
    minmin = min(minmin,abs(left-right));
  }
  cout << minmin << endl;
  return 0;

}


Measured memory_bytes: 256
# ABC134c
import sys
from operator import itemgetter
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

n = int(input())
a = [(i, int(input())) for i in range(n)]

aSort = sorted(a, reverse=True, key=itemgetter(1))

for i in range(n):
    j = 0
    while (aSort[j][0] == i):
        j += 1
    print(aSort[j][1])

Measured memory_bytes: 35036
#凸包を求める

def quickhull(l,r,s,k):
    if not s:
        return
    su = []
    sd = []
    a = (r[0]-l[0],r[1]-l[1])
    for x,y in s:
        b = (x-l[0],y-l[1])
        cro = cross(a,b)
        if cro > 0:
            su.append((x,y)) #上半分
        elif cro < 0:
            sd.append((x,y)) #下半分

    if su:
        c,d = direction(l,r,su[0])
        p = su[0]
        for i in range(1,len(su)):
            c_,d_ = direction(l,r,su[i])
            if c*d_ < c_*d:
                c,d = c_,d_
                p = su[i]
        k.append(tuple(p)) #もっとも離れた点を凸包の頂点に追加
        b = (l[0]-p[0],l[1]-p[1])
        c = (p[0]-r[0],p[1]-r[1])
        s1 = []
        s2 = []
        for x,y in su:
            b_ = (x-p[0],y-p[1])
            c_ = (x-r[0],y-r[1])
            cro_b,cro_c = cross(b,b_),cross(c,c_)
            if cro_b >= 0 and cro_c >= 0: #三角形内部判定
                continue
            else:
                if cro_b < 0:
                    s1.append((x,y))
                elif cro_c < 0:
                    s2.append((x,y))
        quickhull(l,p,s1,k) #再帰
        quickhull(p,r,s2,k)

    if sd:
        c,d = direction(l,r,sd[0])
        p = sd[0]
        for i in range(1,len(sd)):
            c_,d_ = direction(l,r,sd[i])
            if c*d_ < c_*d:
                c,d = c_,d_
                p = sd[i]
        k.append(tuple(p)) #もっとも離れた点を凸包の頂点に追加
        b = (l[0]-p[0],l[1]-p[1])
        c = (p[0]-r[0],p[1]-r[1])
        s1 = []
        s2 = []
        for x,y in sd:
            b_ = (x-p[0],y-p[1])
            c_ = (x-r[0],y-r[1])
            cro_b,cro_c = cross(b,b_),cross(c,c_)
            if cro_b <= 0 and cro_c <= 0: #三角形内部判定(ベクトルの向きにより上下で判定が異なることに注意)
                continue
            else:
                if cro_b > 0:
                    s1.append((x,y))
                elif cro_c > 0:
                    s2.append((x,y))
        quickhull(l,p,s1,k) #再帰
        quickhull(p,r,s2,k)
    return k

def cross(a,b): #外積
    return a[0]*b[1]-a[1]*b[0]

def direction(l,r,p): #点と直線の距離
    a = r[1]-l[1]
    b = l[0]-r[0]
    return (a*(p[0]-l[0])+b*(p[1]-l[1]))**2, a**2+b**2 #分子の2乗,分母の2乗
while 1:
    n = int(input())
    if n == 0:
        break
    s = [[float(x) for x in input().split(",")] for i in range(n)]
    s.sort()
    l = tuple(s.pop(0))
    r = tuple(s.pop(-1))
    k = quickhull(l,r,s,[l,r])
    print(n-len(k))



Measured memory_bytes: 5660