akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)n;++i)

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 101;

int d[MAX_N][MAX_N];
int n,m,s,g1,g2;

void warshall_floyd()
{
    rep(k,n){
        rep(i,n){
            rep(j,n){
                d[i][j] = min(d[i][j],d[i][k]+d[k][j]);
            }
        }
    }
}

int main()
{
    while(1){
        scanf("%d%d%d%d%d",&n,&m,&s,&g1,&g2);
        s--,g1--,g2--;
        if(n==0){
            break;
        }
        rep(i,n){
            rep(j,n){
                d[i][j] = INF;
            }
        }
        rep(i,n){
            d[i][i] = 0;
        }
    	rep(i,m){
    		int x,y,z;
            scanf("%d%d%d",&x,&y,&z);
            d[x-1][y-1] = z;
    	}
        warshall_floyd();
        ll res = (1LL << 60);
        rep(i,n){
            res = min(res,(ll)d[s][i]+d[i][g1]+d[i][g2]);
        }
        printf("%lld\n",res);
    }
	return 0;
}

Measured memory_bytes: 3136
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

int main(){
  int n;
  int h1,h2,m1,m2,s1,s2;
  int dp[3600*60+1];
  while(cin >> n, n){
    memset(dp, 0, sizeof(dp));
    for(int i = 0 ; i < n ; i++){
      scanf("%d:%d:%d %d:%d:%d", &h1, &m1, &s1, &h2, &m2, &s2);
      int t1 = h1*3600+m1*60+s1, t2 = h2*3600+m2*60+s2;
      dp[t1]++, dp[t2]--;
    }
    int ans = 0;
    for(int i = 1 ; i <= 3600*60 ; i++){
      dp[i] = dp[i-1]+dp[i];
      ans = max(ans, dp[i]);
    }
    cout << ans << endl;
  }
  return 0;
}

    
      

Measured memory_bytes: 2088
#-*-coding:utf-8-*-

def main():
    h, w = map(int, input().split())
    mine_list = []
    for _ in range(h):
        mine_list.append(input())
    mine_list_cp = mine_list[:]
    for i in range(h):
        mine_list[i] = '-' + mine_list[i] + '-'
    mine_list.insert(0, '-' * (w+2))
    mine_list.append('-' * (w+2))
    
    for i in range(1, h+1):
        for j in range(1, w+1):
            if mine_list[i][j] != '#':
                cnt = 0
                for k in range(-1, 2):
                    for l in range(-1, 2):
                        if mine_list[i+k][j+l] == '#':
                            cnt += 1
                a = list(mine_list_cp[i-1])
                a[j-1] = str(cnt)
                mine_list_cp[i - 1] = ''.join(a)
        
    for i in mine_list_cp:
        print(i)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>

using namespace std;

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

int a[5];

int func(int* per){
    int t = 0;
    rep(i, 5){
        while(t % 10 != 0){
            t++;
        }
        t += a[per[i]];
    }
    return t;
}

int main(){
    rep(i, 5) cin >> a[i];
    int per[5];
    rep(i, 5) per[i] = i;
    int ans = 1000000;
    do{
        ans = min(ans, func(per));
    }while(next_permutation(per, per + 5));
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<ctype.h>
#include<string.h>

int main(){
    char s[201];
    
    while(1){
        scanf("%s", s);

        if(s[0] == '-')break;

        int len = strlen(s);
        //printf("%d\n", len);
        int i, j, loop;
        scanf("%d", &loop);
        for(i = 0; i < loop; i++){
            int h;
            getchar();
            scanf("%d", &h);
            h = len - h;

            char ss[201];
            for(j = 0; j < h; j++){
                ss[j] = s[len - h + j];
            }

            for(j = 0; j < len - h; j++){
                ss[h + j] = s[j];
            }

            for(j = 0; j < len; j++){
                s[j] = ss[j];
            }
            // printf("%s\n", s);
        }
        //getchar();
        printf("%s\n", s);
    }
}


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

int main(){
	unsigned long long num, buf;
	int a[8], n, ans;

	cin>>n;
	for(int i=1; i<=n; i++){
		cin>>num;
		cout<<"Case "<<i<<":\n";

		for(int j=0; j<10; j++){
			ans=0;
			num*=num;
			buf=num;
			//cout<<"("<<num<<")";
			for(int k=0; k<8; k++){
				a[k] = buf%10;
				buf/=10;
				//cout<<a[k]<<"\n";
			}
			int x=1;
			for(int l=2; l<6; l++){
				ans+=a[l]*x;
				x*=10;
			}
			cout<<ans<<"\n";
			num=ans;
		}
	}
	return 0;
}

Measured memory_bytes: 3012
import java.util.Scanner;

class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int N = sc.nextInt();
	int M = sc.nextInt();
	// Mの接続状況をビットで管理
	int[] connection = new int[M];
	for(int i = 0; i < M; i++){
	    int k = sc.nextInt();
	    int state = 0;
	    // i番目のビットが立っていたらiとつながっているということになる
	    for(int j = 0; j < k; j++){
		int s = sc.nextInt();
		state += (1 << (s - 1));
	    }
	    connection[i] = state;
	}
	int[] p = new int[M];
	for(int i = 0; i < M; i++){
	    p[i] = sc.nextInt();
	}

	//Check
	int ans = 0;
	for(int i = 0; i < (1 << N); i++){
	    boolean check = true;
	    for(int j = 0; j < M; j++){
		int count = Integer.bitCount(i&connection[j]);
		if(count % 2 != p[j]){
		    check = false;
		    break;
		}
	    }
	    if(check){
		ans++;
	    }
	}
	System.out.println(ans);
	
	
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <unordered_set>
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
static const int INF = 1000010000;
static const int NIL = -1;
static const int MOD = 1000000007;
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define SORT(v) sort(v.begin(), v.end());
#define pb push_back
#define mp make_pair
#define np next_permutation
#define pq priority_queue
 
int gcd(int a, int b) { int c; while (b != 0) { c = a%b; a = b; b = c; }return a; }
int lcm(int a, int b) { int c = gcd(a, b); a /= c; return a*b; }
int nCr(int a, int b) { int i, r = 1; for (i = 1; i <= b; i++) { r *= (a + 1 - i); r /= i; }return r; }
int pow(int a, int b) { int i, r = 1; for (i = 1; i <= b; i++) { r *= a; }return r; }
long long llpow(long long a, long long b) { long long i, r = 1; for (i = 1; i <= b; i++) { r *= a; }return r; }
long long llgcd(long long a, long long b) { long long c; while (b != 0) { c = a%b; a = b; b = c; }return a; }
long long lllcm(long long a, long long b) { long long c = llgcd(a, b); a /= c; return a*b; }
long long llnCr(long long a, long long b) { long long i, r = 1; for (i = 1; i <= b; i++) { r *= (a + 1 - i); r /= i; }return r; }
 
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};

struct edge{
    int to, cost;
};


// dijikstra
/* int V;
vector<edge> G[10];
int d[10];

void dijkstra(int s){
    priority_queue<P, vector<P>, greater<P>> que;
    fill(d, d + V + 1, INF);
    d[s] = 0;
    que.push(P(0, s));

    while(!que.empty()){
        P p = que.top(); que.pop();
        int v = p.second;
        if(d[v] < p.first) continue;
        REP(i, G[v].size()){
            edge e = G[v][i];
            if(d[e.to] > d[v] + e.cost){
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}
*/

int main(){
    ll n, m;
    cin >> n >> m;
    if(n >= m / 2){
        cout << m / 2 << endl;
    }else{
        m -= n * 2;
        ll ans = n + m / 4;
        cout << ans << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define dump(x) cerr<<#x<<": "<<(x)<<endl
using namespace std;
using vint = vector<int>;
using ll = long long;
using vll = vector<ll>;
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }
void yes() { cout << "Yes" << endl; exit(0); }
void no() { cout << "No" << endl; exit(0); }

int main() {
    ll x, y; cin >> x >> y;
    int cnt = 0;
    while(x <= y) {
        x *= 2;
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define mod 1000000007
#define fi first
#define se second
#define pii pair<int,int>
#define int long long
#define endl '\n'
#define pll pair<long long,long long>
#define LONGLONG_MAX 100000000000000
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
long long power(long long a,long long b){
    long long ans=1;
    while(b>0){
        if(b&1){ans=(ans*a)%mod;}
                a=(a*a)%mod;
                b>>=1;
        }
    return ans;
        
}
bool check(string s,int i,int j){
    while(i<j){
        if(s[i]!=s[j])return false;
        i++;j--;
    }
    return true;
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    srand(time(0));
    string s;
    cin>>s;
    int n=s.size();
    if(check(s,0,n-1)&&check(s,0,(n-1)/2-1)&&check(s,(n+3)/2-1,n-1))cout<<"Yes";
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <queue>
#include <map>
#include <set>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;


int main(){
long long MOD=1000000007;
long long N,K;
cin>>N>>K;
long long A[N+10];
long long rank=0;
long long after=0;
long long a;
for(int i=0;i<N;++i){
  cin>>a;
  A[i]=a;
}

for(int i=0;i<N;++i){
  a=A[i];
  long long small=0;
  long long after_small=0;
  for(int j=0;j<N;++j){
    if(A[j]<a){
      small+=1;
    }
    if(A[j]<a && i<j){
      after_small+=1;
    }
  }
  rank+=small;
  after+=after_small;
}
long long ans=0;
long long num1=K*after%MOD;
long long num2=((K-1)*K/2)%MOD;
num2=num2*rank%MOD;
ans=(num1+num2)%MOD;
if(ans<0){
  ans+=MOD;
}
cout<<ans<<"\n";
return 0;
}

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

int main() {
    string A, s, C;
    cin >> A >> s >> C;

    char B = s.at(0);

    cout << "A" << B << "C" << endl;

    return 0;
}

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

int main() {
  string S;
  cin >> S;
  bool bBad = false;
  for (int i=0; i<S.length()-1; i++) {
    if (S[i] == S[i+1]) {
      bBad = true;
      break;
    }
  }
  if (bBad) {
	  cout << "Bad" << endl;
  } else {
	  cout << "Good" << endl;
  }
}



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


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

    int n;
    cin>>n;
    int  a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int q;
    cin>>q;
    for(int i=0;i<q;i++){
        int c,l,r;
        cin>>c>>l>>r;
        if(c==1){
            cout<< *max_element(a+l,a+r) <<endl;;
        }
        else{
            cout<< *min_element(a+l,a+r) <<endl;
        }

    }
    
    
}


Measured memory_bytes: 3176
D = int(input())
C = list(map(int, input().split()))
S = [list(map(int, input().split())) for _ in range(D)]
T = [int(input())-1 for _ in range(D)]

last = [0] * 26
score = 0
for d in range(D):
    v = T[d]
    score += S[d][v]
    for i in range(26):
        if i == v:
            last[i] = 0
        else:
            last[i] += 1
        score -= C[i] * last[i]
    print(score)

Measured memory_bytes: 9268
import math
from decimal import Decimal as dec

def main():
    a, b, h, m = map(int, input().split())
    hr = dec(math.radians(dec((h%12) * (360//12) + (m%60) * (30/60))))
    mr = dec(math.radians((m%60) * (360//60)))
    ans = dec(math.sqrt(a**2 + b**2 - 2*a*b*dec(math.cos(abs(hr-mr)))))
    print(ans)
    

if __name__ == "__main__":
    main()

Measured memory_bytes: 10236
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <atcoder/all>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

using namespace atcoder;

struct S{
    ll zero,one,inversion;
};

using F=bool;
S op(S l,S r){
    return S{
        l.zero+r.zero,
        l.one+r.one,
        l.inversion+r.inversion+l.one*r.zero
    };
}

S e(){
    return S{0,0,0};
}

S mapping(F l,S r){
    if(!l) return r;
    return S{r.one,r.zero,r.one*r.zero-r.inversion};
}
F composition(F l,F r){
    return (l && !r) || (!l && r);
}
F id(){
    return false;
}

int main(){
    int n,q;
    cin >> n >> q;
    vector<S> a(n);
    rep(i,n){
        int x;
        cin >> x;
        if(x==0){
            a[i]=S{1,0,0};
        }
        else{
            a[i]=S{0,1,0};
        }
    }
    lazy_segtree<S,op,e,F,mapping,composition,id> seg(a);
    
    rep(i,q){
        int t;
        cin >> t;
        int l,r;
        cin >> l >> r;
        l--;
        if(t==1){
            seg.apply(l,r,true);
        }
        if(t==2){
            cout << seg.prod(l,r).inversion << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 20460
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class MainClass
{
    static void Main()
    {
        long N = long.Parse(ReadLine());
        long n = 0;
        int t = 0;
        /*
        int test = (int)Log10(N);
        while (N > 0)
        {
            WriteLine(N/(long)Pow(10,test));
            N %= (long)Pow(10, test);
            test--;
        }
        */
        while (n < N)
        {
            n = n * 26 + 26;
            t++;
        }
        t--;
        int[] ans = new int[t + 1];
        char[] Ans = new char[t + 1];
        for (int i = 0; i < t; i++)
        {
            N -= (long)Pow(26, i);
        }
        
        while (t>=0)
        {
            if (N == 0)
            {
                ans[t] = 0;
            }
            else
            {
                ans[t] = (int)(N / (long)Pow(26, t));
                N %= (long)Pow(26, t);
            }
            
            t--;
        }
        Array.Reverse(ans);
        ans[0]--;

        for (int i = 0; i < Ans.Length; i++)
        {
            Ans[i] = (char)('a' + ans[i]);
        }
        WriteLine(string.Join("",Ans));
        
    }
}


Measured memory_bytes: 27648
#include <bits/stdc++.h>
#define ll long long

#define TASKNAME ""

using namespace std;

const int INF = 1e9 + 7;
const int MAXN = 1e5 + 7;
const double EPS = 1e-8;
const int LOGN = 30;

int main() {
    #ifdef MY
        freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
    #else
        //freopen(TASKNAME".in", "r", stdin);
        //freopen(TASKNAME".out", "w", stdout);
    #endif // MY
    int l1, r1, l2, r2;
    cin >> l1 >> r1 >> l2 >> r2;
    int l, r;
    l = max(l1, l2);
    r = min(r1, r2);
    cout << max(0, r - l);
}


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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
typedef complex<ld> Point;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const int MAX_V = 1e5 + 5;
const int MAX_N = 1e5 + 5;
const double PI = acos(-1);

int main() {
    ll h, n;
    ll a = 0;
    cin >> h >> n;
    rep(i,n) {
        int temp;
        cin >> temp;
        a += temp;
    }
    if (a >= h)
        CYES;
    else
        CNO;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed
#define vi vector<int>
template <class t, class u>
bool chmax(t &a, u b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class t, class u>
bool chmin(t &a, u b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}

signed main()
{
    int D;
    cin >> D;
    vector<int> c(26);
    vector<vector<int>> s(D, vector<int>(26));
    rep(i, 26)
    {
        cin >> c[i];
    }
    rep(i, D)
    {
        rep(j, 26)
        {
            cin >> s[i][j];
        }
    }
    vector<int> best(D);
    rep(i, D)
    {
        best[i] = i % 26;
    }
    int best_score = -100000000;
    rep(loop, 26)
    {
        vector<int> schedule(D);
        vector<int> lastd(26);
        schedule.push_back(loop);
        int score = s[0][loop];
        lastd[loop] = 1;
        rep(i, D)
        {
            if (i == 0)
            {
                continue;
            }
            int tmpscore = -1000000;
            int best_j = -1;
            rep(j, 26)
            {
                int scr = 0;
                rep(k, 26)
                {
                    if (k == j)
                    {
                        scr += s[i][j];
                    }
                    else
                    {
                        scr -= c[k] * (i + 1 - lastd[k]);
                    }
                }
                if (scr > tmpscore)
                {
                    tmpscore = scr;
                    best_j = j;
                }
            }
            schedule[i] = best_j;
            score += tmpscore;
            lastd[best_j] = i + 1;
        }
        //        cout << score << endl;
        // rep(i, D)
        // {
        //     score += s[i][schedule[i]];
        //     lastd[schedule[i]] = i + 1;
        //     rep(j, 26)
        //     {
        //         score -= c[j] * (i + 1 - lastd[j]);
        //     }
        // }

        if (score > best_score)
        {
            best = schedule;
            best_score = score;
        }
        //        cout << score << endl;
        // rep(i, D)
        // {
        //     cout << best[i] << endl;
        // }
    }
    rep(i, D)
    {
        cout << best[i] + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3656
#include<iostream>
#include<algorithm>
#include<cstdint>
using namespace std;

const int MAX = 100000;
int main() {
	int N, A[MAX], top, side = 0;
	bool b = false;
	cin >> N;
	for (int i = 0;i < N;i ++) cin >> A[i];
	sort(A, A+N);
	top = A[N - 1];
	for (int i = N - 2;i >= 0;i --) {
		if (b) {
			if (side == A[i]) {
				cout << (int64_t)top * side;
				return 0;
			}
			side = A[i];
		} else {
			if (top == A[i]) b = true;
			else top = A[i];
		}
	}
	cout << 0;
	return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <cmath>
#include <iostream>
#include <deque>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <unordered_map>
#include <unordered_set>

using namespace std;

int dp[1000002][2];

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

	int l = n.length();

	dp[0][0] = 0;
	dp[0][1] = 1e9;

	for (int i = 0; i < l; ++i)
	{
		int d = n.at(l - i - 1) - '0';
		dp[i + 1][0] = min(dp[i][0] + d, dp[i][1] + (d + 1));
		dp[i + 1][1] = min(dp[i][0] + (10 - d), dp[i][1] + (10 - (d + 1)));
	}
	cout << min(dp[l][0], dp[l][1] + 1) << endl;
}

Measured memory_bytes: 9220
s = input()

def f(s, al):
    cnt = 0
    while True:
        if len(s) == 0:
            return cnt

        if len(set(s)) == 1 and s[0] == al:
            return cnt

        t = ""
        for i in range(len(s)-1):
            if al in s[i:i+2]:
                t += al
            else:
                t += s[i]
        
        s = t
        cnt += 1

res = 100
for i in range(26):
    res = min(f(s, chr(ord("a")+i)), res)

print(res)

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

void solve(int64_t N, int64_t X, int M)
{
    vector<int> occured(M, -1);
    occured.at(X) = 0;
    vector<int64_t> A(M);
    A.at(0) = X;
    int idx_start = N, len_loop = 0;
    int i = 1;
    while (i < N)
    {
        int Ai = (A.at(i - 1) * A.at(i - 1)) % M;
        if (occured.at(Ai) >= 0)
        {
            idx_start = occured.at(Ai);
            len_loop = i - idx_start;
            break;
        }
        occured.at(Ai) = i;
        A.at(i) = Ai;
        i++;
    }

    int64_t ans = 0;
    for (int i = 0; i < idx_start; i++)
    {
        ans += A.at(i);
    }
    if (len_loop > 0)
    {
        int64_t sum_loop = 0;
        for (int i = 0; i < len_loop; i++)
        {
            sum_loop += A.at(idx_start + i);
        }
        int64_t cnt_loop = (N - idx_start) / len_loop;
        ans += sum_loop * cnt_loop;
        int res_loop = (N - idx_start) % len_loop;
        for (int i = 0; i < res_loop; i++)
        {
            ans += A.at(idx_start + i);
        }
    }
    cout << ans << endl;
}

int main()
{
    int64_t N;
    cin >> N;
    int64_t X;
    cin >> X;
    int M;
    cin >> M;
    solve(N, X, M);
    return 0;
}


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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef unsigned long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const ll INF = 5e18+7;


int main(){
	//ios_base::sync_with_stdio(false);
	ll N, K, ans=0;
	ll w[100005], d[100005];

	cin >> N >> K;
	rep(i,N) cin >> w[i] >> d[i];

	ll l=0, r=INF;
	while(r-l>1){
		ll m = (l+r)/2ll;
		ll sum = 0;
		rep(i,N) if(w[i] <= m){
			sum += (m-w[i]) / d[i] + 1ll;
			sum = min(sum, INF);
		}
		(sum >= K ? r : l) = m;
	}

	ans = r;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1792
using System;

public class Hello
{
    public static void Main()
    {
        double num;
        string s;

        while((s = Console.ReadLine() ) != null)
        {
            if (s == "0") break;
            num = double.Parse(s);
            Console.WriteLine("{0:0.000000} {1:0.000000}", num * num * Math.PI, num * 2 * Math.PI);
        }
    }
}

Measured memory_bytes: 9304
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define endl "\n"
#define int ll

signed main ()
{
 
	 ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     //freopen("input.txt", "r", stdin); 
     //freopen("output.txt", "w", stdout);
 	
	int ans = 0;
	int n;
	cin >> n;
	
	for (int i=1; i<=n; i++){
		int a;
		cin >> a;
		
		if (i%2 and a%2) ans++;
	}
	
	cout << ans << endl;
	return 0;
}

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

#define	BUFFER_LENGTH	(256)

int
main(int argc, const char *argv[])
{
	char buffer[BUFFER_LENGTH];
	int k;
	int a;	/* a biscuits to 1 yen */
	int b;	/* 1 yen to b biscuits */
	long int n;
	int up;
	int kk;
	int kkm;
	int kkk;

	(void)fgets(buffer, sizeof(buffer), stdin);
	(void)sscanf(buffer, "%d %d %d\n", &k, &a, &b);

	if (a >= b) {
		n = 1 + k;
	} else {
		up = -a + b;
		kk = k - a + 1;
		kkm = kk % 2;
		kkk = kk / 2;
		n = a + kkm + ((long int)kkk * up);
		if (n < (1 + k)) {
			n = 1 + k;
		}
	}

	(void)printf("%ld\n", n);

	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
vector<string>vec;
char c[20][20]; int H, W; bool used[20][20];
int dx[8] = { 1,1,1,0,-1,-1,-1,0 };
int dy[8] = { -1,0,1,1,1,0,-1,-1 };
int main() {
	while (true) {
		cin >> H >> W; vec.clear(); if (H == 0)break;
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++)cin >> c[i][j];
		}
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				for (int k = 0; k < 8; k++) {
					for (int l = 0; l < 400; l++)used[l / 20][l % 20] = false;
					int cx = i, cy = j; string S; S += c[cx][cy]; used[cx][cy] = true;
					while (true) {
						cx += dx[k]; cy += dy[k];
						if (cx < 0)cx += H; if (cx >= H)cx -= H;
						if (cy < 0)cy += W; if (cy >= W)cy -= W;
						if (used[cx][cy] == true)break;
						used[cx][cy] = true; S += c[cx][cy]; vec.push_back(S);
					}
				}
			}
		}
		sort(vec.begin(), vec.end()); string T = "0";
		for (int i = 1; i < vec.size(); i++) {
			if (vec[i - 1] == vec[i]) {
				if (vec[i].size()>T.size())T = vec[i];
				else if (vec[i].size() == T.size())T = min(T, vec[i]);
			}
		}
		cout << T << endl;
	}
	return 0;
}

Measured memory_bytes: 28724
#include <iostream>
#include <fstream>
#include <string>
#include <set>
#include <unordered_set>
#include <map>
#include <list>
#include <vector>
#include <queue>
#include <bitset>
#include <cctype>
#include <algorithm>
#include <stdio.h> 


typedef long long ll;
#define nn cout << '\n'
#define rep(n) for(int i = 0; i < n; i++)
#define repi(n) for(int i = 0; i <n; i++)

using namespace std;

int binary[32];

void testcase() {
	ll n; cin >> n;
	vector<int> v(n);
	
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}

	int res = 0;
	for (int i = 0; i < n; i++) {
		res = (res ^ v[i]);
	}
	for (int i = 0; i < n; i++) {
		cout << (v[i] ^ res) << ' ';
	}
	


}


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

	int x = 1;
	rep(x) {
		testcase();
		nn;

	}
	return 0;
}

/*

*/

Measured memory_bytes: 3952
import java.util.Scanner;

public class Main {

    public static void main(String[] args)  {
        Scanner scanner = new Scanner(System.in);
        String s1 = scanner.next();
        String s2 = scanner.next();
        String s3 = scanner.next();
        if(s1.charAt(s1.length() - 1) == s2.charAt(0) && s2.charAt(s2.length() - 1) == s3.charAt(0)){
            System.out.println("YES");
        }
        else System.out.println("NO");
    }

}



Measured memory_bytes: 22612
import bisect
n=int(input())
L=[]*n
L=list(map(int,input().split()))
L.sort()
cnt=0
for i in range(n-2):
    for j in range(i+1,n-1):
        ab=L[i]+L[j]
        num=bisect.bisect_left(L,ab,j+1,n)-j-1
        cnt+=num
print(cnt)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef  long long ll;
typedef unsigned long long ull;

template<typename T>
void fin (T a){
    cout<<a<<endl;
    exit(0);
}
template<typename S>
void print(S a){
    cout<<a<<endl;
}


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

    int r;cin>>r;
    fin(r*2.0*M_PI);
}


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

#define int long long
#define itn int
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
constexpr int MOD = 1e9 + 7;

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
using P = pair<int, int>;
using vec = vector<int>;
template <typename T>
using mat = vector<vector<T>>;

// clang-format off
template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) { return stream << p.first << "," << p.second; }
template <typename T>
void print(const vector<T> vec) { rep (i, vec.size() - 1) cout << vec[i] << ' '; cout << vec[vec.size() - 1] << '\n'; }
template <typename Arg>
void print(const Arg arg) { cout << arg << '\n'; }
template <typename Head, typename... Args>
void print(const Head head, const Args... args) { cout << head << " "; print(args...); }
template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) { rep (i, v.size()) cin >> v[i] >> w[i]; }
template <typename T>
void init(vector<T>& v) { rep (i, v.size()) cin >> v[i]; }
template <typename T>
T sum_(vector<T> vec, T init = 0) { return std::accumulate(all(vec), T(init)); }
template<typename T>
bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <typename T>
int index(const T& vec, const typename T::iterator it) { return distance(vec.begin(), it); }
template <typename T = int>
mat<T> mmat(int n, int m=0) { return mat<T>(n, vector<T>(m)); }
template <typename T = int>
vector<T> ivec(int n) { vector<T> v(n); init(v); return v; }
// clang-format on

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int n;
    string s;
    cin >> n;
    cin >> s;

    int cnt = 0;
    For(i, 0, n - 3) {
        if (s.substr(i, 3) == "ABC") cnt++;
    }
    print(cnt);

    return 0;
}


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

class Program
{
    private static readonly Scanner sc = new Scanner();
    static void Main(string[] args)
    {
        long n = sc.Long;
        long k = sc.Long;

        long[] cnt = new long[100010];

        for (int i = 0; i < n; i++)
        {
            long a = sc.Long;
            long b = sc.Long;

            cnt[a] += b;
        }

        long j = 0;
        long c = 0;
        while (c < k)
            c += cnt[j++];
        
        Console.WriteLine(j - 1);
    }
}

class Scanner
{
    private string[] _str = new string[0];
    private int _i;

    public string Str
    {
        get
        {
            if (_i >= _str.Length)
            {
                _str = Console.ReadLine().Split(' ');
                _i = 0;
            }
            return _str[_i++];
        }
    }

    public int Int { get { return int.Parse(Str); } }
    public long Long { get { return long.Parse(Str); } }
    public double Double { get { return double.Parse(Str); } }
}

Measured memory_bytes: 15824
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<iterator>
#include<complex>
#include<stack>
#include "stdio.h"
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const long long mod_const = 1e9+7;
using MIte = multimap<long, long, greater<long> >::iterator;


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

	// long long?
	int A, B;
	cin >> A >> B;

	int ans = max({ A + B, A - B, A * B });

	cout << ans << endl;


	return 0;

}

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

int main(){
  int a,c,b;cin >> a >> c >> b;
  if(a>c){
    if(a>=b&&b>=c)cout << "Yes";
    else cout << "No";
  } else {
    if(a<=b&&b<=c)cout << "Yes";
    else cout << "No";
  }
}



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

// typedef
// -----------------------------------------------------------------------------
typedef long long ll;
typedef long double ld;

// container util
// -----------------------------------------------------------------------------
#define ALL(c)  (c).begin(),(c).end()
#define SZ(c) ((ll)(c).size())
#define MAX(c) *max_element(ALL(c))
#define MIN(c) *min_element(ALL(c))
#define SORT(c) sort((c).begin(),(c).end())

// repetition
// -----------------------------------------------------------------------------
#define FOR(i, a, b) for(ll i= (a); i < (ll)(b); ++i)
#define REP(i, n) FOR(i, 0, n)

// constant
// -----------------------------------------------------------------------------
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);

// debug
// -----------------------------------------------------------------------------
#define DUMP(x)  cerr << #x << " = " << (x) << endl


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    string S, T; cin >> S >> T;
    int maxl = -1;
    REP(i, S.length() - T.length() + 1) {
        int cnt = 0;
        REP(j, T.length()) {
            if (S[i + j] == T[j]) {
                cnt++;
            }
        }
        maxl = max(maxl, cnt);
    }
    cout << T.length() - maxl << "\n";
}

Measured memory_bytes: 3672
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

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

use std::cmp;

fn main() {
    input! {
        sx: isize,
        sy: isize,
        tx: isize,
        ty: isize,
    }
    let dx = tx - sx;
    let dy = ty - sy;
    let mut ans: String = String::from("");

    ans += "L";
    for _ in 0..(dy+1){
        ans += "U";
    }
    for _ in 0..(dx+1){
        ans += "R";
    }
    ans += "D";

    for _ in 0..(dx){
        ans += "L";
    }
    for _ in 0..(dy){
        ans += "D";
    }

    for _ in 0..(dx){
        ans += "R";
    }
    for _ in 0..(dy){
        ans += "U";
    }

    ans += "R";
    for _ in 0..(dy+1){
        ans += "D";
    }

    for _ in 0..(dx+1){
        ans += "L";
    }
    ans += "U";

    print!("{}", ans);
}


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

# define C continue;
# define R return

#define int long long
# define D double
# define I insert
# define ld long double
# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vull vector < ull >
# define vld vector < ld >

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvs vector < vs >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

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

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

#define PQ(type) priority_queue<type>
#define PQD(type) priority_queue<type, vector<type>, greater<type>>

#define mii map<int, int>
#define mll map<ll, ll>
#define mci map<char, int>
#define msi map<string, int>
#define mis map<int, string>
#define mib map<int, bool>
#define mcb map<char,bool>

#define umii unordered_map<int, int>
#define umll unordered_map<ll, ll>
#define umci unordered_map<char, int>
#define umsi unordered_map<string, int>
#define umis unordered_map<int, string>

#define init(arr,val) memset(arr,val,sizeof(arr))
#define REP(i,a,b) for(int i=a; i<b; i++)
#define distance(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define nl "\n"
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);

string vow = "aeiou";
int month[] = { -1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

const int dxhorse[] = { -2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

const int dx[] = { -1 , 0 , 1 , 0 } ;
const int dy[] = { 0 , 1 , 0 , -1 } ;

const ld pie = 3.1415926535897932384626 ;
const int mod = 1e9 + 7 ;
#define test int t; cin>>t;
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);
/// Tip : If a and b are positive integers ; we may say - ceil (a/b) = 1 + floor ( (a-1)/b ) .
void a_b_c()
{
    #ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
    #endif
}

void solve()
{
  string str; cin>>str;
  int cnt=0;
  REP(i,0,3) if(str[i]=='R') cnt++;
  if(str[0]=='R'&&str[1]=='R'&&str[2]=='R') cout<<3;
  else if((str[0]=='R'&&str[1]=='R')||(str[1]=='R'&&str[2]=='R')) cout<<2;
  else if(cnt>0) cout<<1;
  else cout<<0;
}
int32_t main()
{	fast
    int t=1;
    //freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
    //int t;  cin>>t;
    for(int i=1; i<=t; i++) solve();

}



Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
using P = pair<ll, ll>;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using Graph = VV;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int Inf = (1 << 30);
ll inf = (1LL << 60);
const int MOD = 1e9 + 7;
int main() { // 左から右だけじゃなくて右から左も考える!
	int n, k;
	cin >> n >> k;
	VL a(n);
	int i;
	for (i = 0; i < n; i++) {
		cin >> a[i];
	}
	ll ans = inf;
	rep(i, n - k + 1) {
		chmin(ans, abs(a[i]) + abs(a[i + k - 1] - a[i]));
		chmin(ans, abs(a[i + k - 1]) + abs(a[i] - a[i + k - 1]));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
use std::io::Read;

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

    let answer = solve(&buf);

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

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

    let a = iterator.next().unwrap().parse::<u8>().unwrap();
    let b = iterator.next().unwrap().parse::<u8>().unwrap();
    let c = iterator.next().unwrap().parse::<u8>().unwrap();

    if a == b && a != c {
        return String::from("Yes");
    }
    if a == c && a != b {
        return String::from("Yes");
    }
    if b == c && b != a {
        return String::from("Yes");
    }
    return String::from("No");
}

#[test]
fn test() {
    let cases: Vec<(&str, &str)> = vec![
        (
            r"5 7 5",
            "Yes"
        ),
        (
            r"4 4 4",
            "No"
        ),
        (
            r"4 9 6",
            "No"
        ),
        (
            r"3 3 4",
            "Yes"
        ),
    ];

    let mut all_ok = true;
    for (i, case) in cases.iter().enumerate() {
        print!("case {} : ", i);

        let expected = case.1;
        let actual = solve(case.0);

        if expected == actual {
            println!("OK");
        } else {
            println!("NG");
            println!("    Expected: {}", expected);
            println!("    Actual  : {}", actual);

            all_ok = false;
        }
    }

    assert_eq!(all_ok, true);
}


Measured memory_bytes: 4352
#include <iostream>
#include <sstream>
#include <string>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <list>
#include <algorithm>
#include <ctime>
#include <limits>
#include <iomanip>
#include <functional>
#include <array>
#include <climits>
#include <cmath>

using namespace std;
using ll = long long;
const ll MOD = (ll)1e9 + 7;
const ll LL_MAX = 0x7fffffffffffffff;

int main()
{
    int n, h[100];
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> h[i];
    }
    int h_max = h[0];
    int num = 1;
    for (int i = 1; i < n; i++)
    {
        if (h[i] >= h_max)
        {
            num++;
            h_max = h[i];
        }
    }
    cout << num;
    return 0;
}


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

int main()
{
    ll a,b,c,d,e,i,j,k,l,n,m,x,y,t,p;
    cin>>a>>b>>c>>d;
    x=-6e18;
    y=(a*c);
    x=max(x,y);
    y=(a*d);
    x=max(x,y);
    y=(b*c);
    x=max(x,y);
    y=(b*d);
    x=max(x,y);
    cout<<x<<endl;
}


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

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m;
    cin>>n;
    vector<int> t(n);
    rep(i,0,n)cin>>t[i];
    cin>>m;
    rep(lp,0,m){
        int p,x;
        int res=0;
        cin>>p>>x;
        p--;
        rep(i,0,n){
            if(i==p)res+=x;
            else res+=t[i];
        }
        cout<<res<<endl;
    }
}

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

namespace noteCsharp
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] inputstr0 = Console.ReadLine().Split(char.Parse(" "));
            int n = int.Parse(inputstr0[0]);
            int m = int.Parse(inputstr0[1]);
            int[,] inputmatrix = new int[n, m];
            for(int cycle0 = 0; cycle0 < n; cycle0++)
            {
                string[] inputstr1 = Console.ReadLine().Split(char.Parse(" "));
                for(int cycle1 = 0; cycle1 < m; cycle1++)
                {
                    inputmatrix[cycle0, cycle1] = int.Parse(inputstr1[cycle1]);
                }
            }
            int[] inputvector = new int[m];
            int[] outputvector = new int[m];
            for(int cycle = 0; cycle < m; cycle++)
            {
                inputvector[cycle] = int.Parse(Console.ReadLine());
            }
            for(int row = 0; row < n; row++)
            {
                int temp = 0;
                for(int column = 0; column < m; column++)
                {
                    temp += inputmatrix[row, column] * inputvector[column];
                }
                Console.WriteLine(temp);
            }
        }
    }
}



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

int main() 
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n,s=0,m=0;cin>>n;
  	for (int i = 0; i < n; i++)
	{
		int x;cin>>x;
		if(m<x)m=x;
		s+=x;
	}
	if(m < s-m)cout<<"Yes";
	else cout<<"No";
}

Measured memory_bytes: 3160
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,k = inpl()
a = inpl()
now = 0
res = 0
for x in a:
    if x != 1: now += 1
    if now == k-1:
        res += 1
        now = 0
if now: res += 1
print(res) 

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


using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VP vector<pair<int,int>>
#define VPP vector<pair<int,pair<int,int>>>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

const int  INF = 1 << 29;
const ll INFL = 1LL << 60;
const ll mod = 1000000007;



int main() {

	int n, k, c;
	cin >> n >> k >> c;
	string s;
	cin >> s;

	int cnt = 0;

	multiset<int> m;

	REP(i, n) {
		if (s[i] == 'o') {
			cnt++;
			m.insert(i);
			i += c;
		}
	}
	
	if (cnt > k)return 0;
	multiset<int> mm;
	multiset<int> result;


	for (int i = n - 1; i >= 0; i--) {
		if (s[i] == 'o') {
			mm.insert(i);
			i -= c;
		}
	}
	set_intersection(m.begin(), m.end(),
		mm.begin(), mm.end(),
		std::inserter(result, result.end()));
	std::for_each(result.begin(), result.end(), [](int x) {
		std::cout << x + 1 << std::endl;
	});
	

}

Measured memory_bytes: 29828
#include <bits/stdc++.h>
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <regex>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ARRAY_LEN(ARR) (sizeof(ARR) / sizeof((ARR)[0]))
using namespace std;

const long long MOD = 1000000007;
typedef  long long ll;

int main(void){
  ll n,k;
  cin >> n >> k;
  vector<int> a(n);

  REP(i,n){
    cin >> a[i];
  }

  ll c,d;
  c = 0;
  d = 0;
  REP(i,n){
    FOR(j,i+1,n){
      if(a[i] > a[j]){
        c++;
        d++;
      }
      else if(a[i] < a[j]) d++;
    }
  }
  ll ans = 0;
  ans = c * k % MOD  + ( k * (k-1) / 2 % MOD ) * d;
  ans = ans % MOD;
  cout << ans << endl;

}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
	char b[2];

	scanf("%s", b);

	if (b[0] == 'A')printf("T\n");
	if (b[0] == 'T')printf("A\n");
	if (b[0] == 'C')printf("G\n");
	if (b[0] == 'G')printf("C\n");

	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void) {
	int N;
	scanf("%d\n", &N);
	
	int i;
	for (i = 0; i < N; i++) {
		int K;
		int P;
		scanf("%d %d\n", &K, &P);
		
		printf("%d\n", K % P ? K % P : P);
	}
	
	return 0;
}

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

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


Measured memory_bytes: 256