akhauriyash/Code-Regression huggingface dataset:
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
//#include<unordered_map>//イテレータあるけど順序保持しないmap
//#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<valarray>//なんとなく追加
//メモ：表示桁数を大きくする　　cout << fixed << setprecision(20) << cm << endl;
using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define PI acos(-1.0)
#define answer(ans) cout<<ans<<endl;
#define input(N) cin >> N;


signed main() {
   int N,n;
   ll sum=0;
   cin >> N;

    vector<ll> ff(N+1,0);
    for(int i=1;i<=N;i++){
        n=1;
        while(i*n<=N){
            ff[i*n]+=i*n;
            n++;
        }
    }

    REP(i,N+1){
        sum +=ff[i];
    }
answer(sum);

}

Measured memory_bytes: 81400
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;

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

int main(){
	ll H,N; cin>>H>>N;
	ll max_dam = 123456;
	vector<lp> magic(N);
	rep(i,N)cin>>magic[i].first>>magic[i].second;
	vector<vector<ll>> dp(N+1, vector<ll> (max_dam+1,INF));
	rep(i,N+1)dp[i][0] = 0;
	REP(i,N){
		REP(j,max_dam){
			ll item_num = i-1;
			chmin(dp[i][j], dp[i-1][j]);
			if(j<magic[item_num].first)continue;
			chmin(dp[i][j], dp[i][j-magic[item_num].first] + magic[item_num].second);
		}
	}
	ll ans = INF;
	// rep(i,N+1){
	// 	rep(j,10){
	// 		int t;
	// 		if(dp[i][j] == INF)t = -1;
	// 		else t = dp[i][j];
	// 		printf("%3d ",t);
	// 	}
	// 	cout<<endl;
	// }
	for(ll i = H; i<=max_dam; ++i)chmin(ans, dp[N][i]);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 970240
/*
    Bismillahir Rahmanir Raheem
    Think Twice Code Once
    author : reaziii
*/
#include<bits/stdc++.h>
#define sc(x)        scanf("%lld",&x)
#define pcase(x)     printf("Case %d: ",x++)
#define pn           printf("\n")
#define fri(f)       for(int i=0;i<f;i++)
#define frj(f)       for(int j=0;j<f;j++)
#define reset(x,e)   memset(x,e,sizeof(x))
#define all(x)       x.begin(),x.end()
#define input        freopen("input.txt","r",stdin);
#define output       freopen("output.txt","w",stdout)
#define infi         INT_MAX
#define m_v          3000000
#define pii          pair<int,int>
#define pch          pair<char,char>
#define pll          pair<ll,ll>
#define mgraph       map<int,set<int> >
#define mp           make_pair
#define pb           push_back
#define clr(x)       memset(x,0,sizeof(x))
#define frx(x,y)     for(int x=0;x<y;x++)
#define deb(x)       cout<<x
#define ideb(i,x)    cout<<i<<" "<<x
#define F            first
#define S            second
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
bool checkbitt(ll num,int pos);
ll setbitt(ll num,ll pos);
ll resetbitt(ll num,int pos);
 //.................___Start from here___.................//
//.................._____________________................//


int counter(int x) {
    if(x == 0) return 0;
    return counter(x >> 1) + (x & 1);
}
 


void solve(){
    int n;
    cin>>n;
    int mask = 1<<n;
    mask--;

    int a[n+1],x[n+1][n+1],y[n+1][n+1];

    for(int u = 1 ; u <= n ; u++ ){
        cin>>a[u];
        for(int v = 1;v<=a[u];v++){
            cin>>x[u][v]>>y[u][v];
        }
    }

    int ans = 0;

    for(int i=1;i<=mask;i++){
        bool f =true;

        for(int j=1;j<=n;j++){
            if(i & (1<<(j-1))){
                for(int k=1;k<=a[j];k++){
                    if(y[j][k]^checkbitt(i,(x[j][k]-1))) f = false;
                }
            }
        }

        if(f) ans = max(ans,counter(i));
    }

    cout<<ans<<endl;

}


int main(){
    // input;
    // output;

    solve();
}






bool checkbitt(ll num,int pos){
    return (num>>pos) & 1;
}

ll setbitt(ll num,ll pos){
    return (1<<pos) | num;
}

ll resetbitt(ll num,int pos){
    if(!checkbitt(num,pos)) {
        return num;
    }
    else{
        return (1<<pos)^num;
    }
}





Measured memory_bytes: 256
import sys
a = []
op = []
b = []

for l in sys.stdin:
    aa, opo, bb = l.split()

    if opo == "?":
        break

    a.append(aa)
    op.append(opo)
    b.append(bb)

for i, num in enumerate(a):
    if op[i] == "+":
        print(int(a[i]) + int(b[i]))
    elif op[i] == "-":
        print(int(a[i]) - int(b[i]))
    elif op[i] == "*":
        print(int(a[i]) * int(b[i]))
    elif op[i] == "/":
        print(int(a[i]) // int(b[i]))


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

int main(){
	int n, x, y;cin >> n >> x >> y;
	x--;y--;
	vector<int> ans(n);

	rep(i,n){
		queue<int> q;
		vector<int> dist(n, -1);
		q.push(i);
		dist[i] = 0;
		while(!q.empty()){
			int v = q.front();q.pop();
			//cout << v;
			if(v < 0 || n-1 < v) continue;
			if(dist[v+1] == -1){
				q.push(v+1);
				dist[v+1] = dist[v] + 1;
			}
			if(dist[v-1] == -1){
				q.push(v-1);
				dist[v-1] = dist[v] + 1;
			}
			if(v == x && dist[y] == -1){
				q.push(y);
				dist[y] = dist[v] + 1;
			}
			if(v == y && dist[x] == -1){
				q.push(x);
				dist[x] = dist[v] + 1;
			}
		}
		//cout << endl;
		rep(j,n) {
			//cout << dist[j];
			ans[dist[j]]++;
		}
		//cout << endl;
	}
	rep(j,n) ans[j] /= 2;

	for(int i=1;i<n;i++){
		cout << ans[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int a,b,c,i,j,count=0;
	cin>>a>>b>>c;
	for(i=a;i<=b;i++){
		if(a>b){
		break;
		}
		j=c%i;
		if(j==0){
			count++;
		}
	}
	cout<<count<<endl;
}

Measured memory_bytes: 3060
#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(){
  int n;
  cin >> n;
  cout << (n - 2) * 180 << endl;
  return 0;
}


Measured memory_bytes: 3576
#include <stdio.h>

int main(void)
{
  int i;
  int tmp;
  int count=0;
  int n;

  scanf("%d\n",&n);
  int p[n];


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

  for(i=1;i<n-1;i++)
  {
    if(p[i-1]<p[i]&&p[i]<p[i+1])
    {
      count=count+1;
    }
    else if (p[i-1]>p[i]&&p[i]>p[i+1])
    {
      count=count+1;
    }
  }

  printf("%d",count);

  return 0;
}


Measured memory_bytes: 128
def f_strivore(MOD=10**9 + 7):
    K = int(input())
    S = input()
    length = len(S)

    class Combination(object):
        """素数 mod に対する二項係数の計算"""
        __slots__ = ['mod', 'fact', 'factinv']

        def __init__(self, max_val_arg: int = 10**6, mod: int = 10**9 + 7):
            fac, inv = [1], []
            fac_append, inv_append = fac.append, inv.append

            for i in range(1, max_val_arg + 1):
                fac_append(fac[-1] * i % mod)

            inv_append(pow(fac[-1], -1, mod))
            for i in range(max_val_arg, 0, -1):
                inv_append((inv[-1] * i) % mod)

            self.mod, self.fact, self.factinv = mod, fac, inv[::-1]

        def combination(self, n, r):
            return (0 if n < 0 or r < 0 or n < r
                    else self.fact[n] * self.factinv[r] * self.factinv[n - r] % self.mod)

    comb = Combination(length + K).combination
    f = [1] * (K + 1)
    tmp = 1
    for n in range(K + 1):
        f[n] = (comb(length + n - 1, length - 1) * tmp) % MOD
        tmp = (tmp * 25) % MOD
    g = [1] * (K + 1)
    for n in range(1, K + 1):
        g[n] = (f[n] + 26 * g[n - 1]) % MOD
    return g[K]

print(f_strivore())

Measured memory_bytes: 247492
def B():
    s = input()    
    WA = 'WA'
    AC = 'AC'
    result = AC
    
    if s[0] != 'A':
        result = WA
    
    a_cnt=2
    C_count=0
    C_nsub=""
    for a in s[2:-1]:
        a_cnt += 1
        if a=='C':
            C_count += 1
            C_nsub = s[1:a_cnt-1] + s[a_cnt:]
    
    if C_count!=1 and result==AC:
        result = WA
    
    if not C_nsub.islower() and result==AC:
        result = WA
    
    print (result)

if __name__ =='__main__':
    B()
    

Measured memory_bytes: 3064
using System;
using System.Linq;

class Program
{
    public static void Main()
    {
        string[] inp = Console.ReadLine().Split(' ');
        int n = int.Parse(inp[0]), m = int.Parse(inp[1]), l = int.Parse(inp[2]);
        long[,] A = new long[n, m];
        for (int i = 0; i < n; ++i)
        {
            string[] row = Console.ReadLine().Split(' ');
            for (int j = 0; j < m; ++j)
            {
                A[i, j] = int.Parse(row[j]);
            }
        }
        long[,] B = new long[m, l];
        for (int i = 0; i < m; ++i)
        {
            string[] row = Console.ReadLine().Split(' ');
            for (int j = 0; j < l; ++j)
            {
                B[i, j] = int.Parse(row[j]);
            }
        }
        long[,] C = new long[n, l];
        for (int i = 0; i < n; ++i)
        {
            for (int j = 0; j < m; ++j)
            {
                for (int k = 0; k < l; ++k)
                {
                    C[i, k] += A[i, j] * B[j, k];
                }
            }
        }
        for (int i = 0; i < n; ++i)
        {
            for (int j = 0; j < l; ++j)
            {
                if (j != 0) Console.Write(' ');
                Console.Write(C[i, j]);
            }
            Console.WriteLine();
        }
    }
}


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

int main() {
  int L;
  cin >> L;
  
  double V;
  V = (L / 3.0) * (L / 3.0) * (L / 3.0);
  cout << fixed << setprecision(12);
  cout << V << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ldb = long double;
using pa = pair < ll, ll >;
using vec = vector < ll >;
#define pb push_back
#define po pop_back
#define mp make_pair
#define mt make_tuple
#define F  first
#define S  second
#define f(i,x,n) for(ll i=x;i<n;i++) 
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))
#define all(c) c.begin(),c.end()
#define str string
#define edl "\n"
#define add insert
#define cot continue
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;
const double PI = acos(-1);
const ll LINF = LLONG_MAX;




int main() 
{

 fast();
    

  
  ll n;
  cin>>n;
  vec q(n);
  f(i,0,n)
  {
    cin>>q[i];
  }
  vec q1=q;

  sort(all(q1));
  ll ma=q1[n-1];

  f(i,0,n)
  {
    if(ma==q[i])
      cout<<q1[n-2]<<edl;
    else
      cout<<ma<<edl;
  }








    cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
    return 0;
}
 

Measured memory_bytes: 4736
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
long long m[100000][2];
int main(){
while(1){
long long n,k,i,j,x=0;
cin>>n>>k;
if(n==0&&k==0)break;
for(i=0;i<n;i++)cin>>m[i][0];
m[0][1]=m[0][0];
for(i=1;i<n;i++){
m[i][1]=m[i-1][1]+m[i][0];
}
x=m[k-1][1];
for(i=k;i<n;i++){
x=max(x,m[i][1]-m[i-k][1]);
}
cout<<x<<endl;
}
return 0;
}

Measured memory_bytes: 4620
//#pragma GCC optimize("O3")
//#pragma GCC target ("avx")

#include <cstdio>
#include <cstdlib>

__attribute__((target("avx"))) int main() {
	int n;
    int a[200000], b[200000];

    scanf("%d", &n);

    for (int i = 0; i < n; i++) {
        scanf("%d", a + i);
    }

    for (int i = 0; i < n; i++) {
        scanf("%d", b + i);
    }

    int ans = 0;
    int m = n / 6 * 6;

    for (int i = 0; i < m; i += 6) {
        for (int j = 0; j < n; j++) {
            ans ^= a[i] + b[j];
            ans ^= a[i + 1] + b[j];
            ans ^= a[i + 2] + b[j];
            ans ^= a[i + 3] + b[j];
            ans ^= a[i + 4] + b[j];
            ans ^= a[i + 5] + b[j];
        }
    }

    for (int i = m; i < n; i++) {
        for (int j = 0; j < n; j++) {
            ans ^= a[i] + b[j];
        }
    }

    printf("%d\n", ans);
}


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

a.sort(reverse=True)
middle = []
if (n % 2 == 0):
    middle = a[:n // 2]
    # print(middle)

    sum = sum(middle)-middle[-1]
    for i in range(n // 2-1):
        sum += middle[i + 1]
    sum += middle[-1]
else:
    middle = a[:n // 2+1]
    # print(middle)

    sum = sum(middle)-middle[-1]
    for i in range(n // 2):
        sum += middle[i+1]
print(sum)


Measured memory_bytes: 31432
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;
ll u[100010];
ll v[100010];
int d[100010];
int main(){
	int n,m;
	cin>>n>>m;
	lol(i,m)u[i]=v[i]=0;
	lol(i,n)cin>>d[i];
	ll sum=0;
	int within=0;
	lol(i,n-1){
		int a=d[i]-1,b=d[i+1]-1;
		u[a+1]++;
		u[b]--;
		int tmp=(b-a+m)%m;
		v[b]+=tmp-1;
		sum+=min(tmp,b+1);
		if(b<a)within++;
	}
	ll ans=sum;
	lol(x,m){
		ans=min(ans,sum);
		within+=u[x];
		sum+=v[x]-within;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 2176
#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++)

const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

typedef long long ll;

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

ll LCM(ll x, ll y)
{
    return x * y / GCD(x, y);
}

int main()
{
    ll N, M;
    cin >> N >> M;

    ll lcm = 1;
    vector<ll> a(N);

    for (int i = 0; i < N; i++) {
        cin >> a.at(i);
        a.at(i) /= 2;
        lcm = LCM(a.at(i), lcm);
    }

    for (int i = 0; i < N; i++) {
        if ((lcm / a.at(i)) % 2 == 0) {
            cout << 0 << endl;
            return 0;
        }
    }

    cout << (M / lcm + 2 - 1) / 2 << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
using namespace std;
using ll = long long;
using d = double;
  //n even
  //m odd
int main(){
  int n,m;
  cin >> n >> m;
  int t=n*(n-1)/2;
  t+=m*(m-1)/2;
  printf("%d",t);
  return 0;
}


Measured memory_bytes: 3756
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;

long long int INF = 1e18;
long long int mod = 1000000007;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "RULD";
//↓,→,↑,←

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll number1,ll number2){
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
    if(number1 > number2){
        swap(number1 , number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1 , number1);
    }
}

ll i,j,k,ii,jj,n,m,a,b,c,d,e,f,g,h,r,w,l;
ll num,ans,sum,ok,ng;
ll x[500005],y[500005],z[500005];
char s[500005],t[500005],u[500005];
bool dame,flag;

int main(){
	cin >> n >> s >> t >> u;
	for(i=0;i<n;i++){
		if(s[i] != t[i] && t[i] != u[i] && u[i] != s[i]){
			ans += 2;
		}else if(s[i] == t[i] && t[i] == u[i]){
			ans += 0;
		}else{
			ans ++;
		}
	}
	p(ans);
	return 0;
}

Measured memory_bytes: 24576
#include<iostream>
#include<vector>
using namespace std;
using ll = long long int;

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

    ll nowres = 0;
    int ans = -1;


    for(int i = 1; i <= k; i++){
        nowres = nowres * 10 + 7;
        nowres %= k;
        if (nowres == 0){
            ans = i;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3188
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <vector>

using namespace std;

#define all(c) ((c).begin()), ((c).end())
#define dump(c) cerr << "> " << #c << " = " << (c) << endl;
#define REP(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

const int INF = 1001001001;
const double EPS = 1e-10;


template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
  return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
  os<<'[';
  rep(i,a.size()) os<<(i?" ":"")<<a[i];
  return os<<']';
}

int main() {
  for (int x, y, s; cin >> x >> y >> s, (x | y | s) != 0; ) {
    int ans = 0;
    REP(a, 1, s) REP(b, 1, s) {
      int xa = a + a * x / 100.0, xb = b + b * x / 100.0;
      if (xa + xb != s) continue;
      int ya = a + a * y / 100.0, yb = b + b * y / 100.0;
      ans = max(ans, ya + yb);
    }

    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k;
    cin>>n>>k;
    ll a[n];
    for(ll i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n,greater<ll>());
    ll f[n];
    for(ll i=0;i<n;i++)
        cin>>f[i];
    sort(f,f+n);
    ll l=0;
    ll r=1e12;
    ll ans;
    while(l<=r)
    {
        ll mid=(l+r)/2;
        ll count=0;
        for(ll i=0;i<n;i++)
        {
            if(a[i]*f[i]>mid)
            {
                count=count+(a[i]-mid/f[i]);
            }
        }
        //cout<<mid<<count<<endl;
        if(count<=k)
        {
            ans=mid;
            r=mid-1;
        }
        else
        {
            l=mid+1;
        }
    }
    cout<<ans;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
const int sz=6e5+7;
const int mod=998244353;
int n,t;
int ans;
int cnt;
int pos;
int sum;
bool flag;
int a[sz];
int fac[sz];
int st[sz],ed[sz];
int main(){
	scanf("%d",&n);
	fac[0]=1;
	for(int i=1;i<=n;i++) fac[i]=1ll*i*fac[i-1]%mod;
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		a[n+i]=a[i];
	}
	pos=2;
	while(a[pos]==a[pos-1]) ++pos;
	if(pos==2*n+1&&a[1]!=1) return printf("0\n"),0;
	if(pos==2*n+1) return printf("%d\n",fac[n]),0;
	for(int i=pos;i<pos+n;i++){
		if(a[i]!=a[i-1]){
			if(st[a[i]]) flag=1;
			st[a[i]]=i;
		}
		if(a[i]!=a[i+1]) ed[a[i]]=i;
	}
	if(flag) return printf("0\n"),0;
	
	t=ed[1]-st[1];
	for(int i=1;i<=n;i++) if(ed[i]-st[i]>t) flag=1;
	if(flag) return printf("0\n"),0;
	
	ans=1;
	cnt=1,sum=t+1;
	for(int i=2;i<=n;i++){
		if(!st[i]) { ans=1ll*(sum-t*cnt-i+1)*ans%mod;continue; }
		int k1=a[st[i]-1]<i,k2=a[ed[i]+1]<i;
		if(k1&&k2) ans=1ll*(st[i]-(ed[i]-t)+1)*ans%mod,cnt--;
		if(!k1&&!k2) cnt++;
		if(!k1&&!k2&&ed[i]-st[i]!=t) ans=0;
		sum+=ed[i]-st[i]+1;
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 8704
import sys
input = sys.stdin.readline
def main():
    def find(x):
        if par[x] < 0:
            return x
        else:
            par[x] = find(par[x])
            return par[x]

    def unite(x, y):
        x = find(x)
        y = find(y)
        if x == y:
            return False
        else:
            if par[x] > par[y]:
                x, y = y, x
            par[x] += par[y]
            par[y] = x
            return True

    def same(x, y):
        return find(x) == find(y)

    n, m = map(int, input().split())
    p = list(map(int, input().split()))
    pdic = {e :0 for e in range(n)}
    for i, pe in enumerate(p):
        pdic[pe] = i

    par = [-1] * n
    for _ in range(m):
        x, y = map(int, input().split())
        unite(x-1, y-1)

    r = 0
    for i1 in range(n):
        r += same(i1, pdic[i1+1])
    print(r)


if __name__ == '__main__':
    main()


Measured memory_bytes: 95116
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

int main(){
    ll n;
    cin >> n;
    vector<vector<ll>> ta(n, vector<ll>(2));
    vector<vector<ll>> ta2(n, vector<ll>(2));

    rep(i,n){
        cin >> ta[i][0] >> ta[i][1];
        ta2[i][0] = ta[i][0]+ta[i][1];
        ta2[i][1] = ta[i][0]-ta[i][1];
    }

    sort(ta2.begin(), ta2.end());

    ll ans =0, t=-1e9;

    rep(i,n){
        if(t <= ta2[i][1]){
            ans++;
            t = ta2[i][0];
        }
    }

    dunk(ans);
}





Measured memory_bytes: 11136
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#pragma region Macros
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define all(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
int gcd(int a, int b) // assuming a,b >= 1
{
    if (a < b)
        swap(a, b);
    if (b == 0)
        return a;
    if (a % b == 0)
        return b;
    return gcd(b, a % b);
}
int lcm(int a, int b) // assuming a,b >= 1
{
    return  a * b / gcd(a, b);
}
using namespace std;
#pragma endregion
signed main() {
    int A,P;
    cin >> A >> P;
    cout << (A * 3 + P) / 2;
}

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

int N, K;
int H[200010];

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

	cin >> N >> K;
	rep(i, 0, N)
	{
		cin >> H[i];
	}

	sort(H, H + N, greater<int>());

	int ans = 0;

	rep(i, 0, N)
	{
		if (i < K)
		{
		}
		else
		{
			ans += H[i];
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1792
class Dice:
    def __init__(self, d):
        self.d = d

    def setNum(self, n0, n1, n2, n3, n4, n5):
        self.d[0], self.d[1], self.d[2], self.d[3], self.d[4], self.d[5] = (
            n0,
            n1,
            n2,
            n3,
            n4,
            n5,
        )

    def roll(self, direction):
        if direction == "E":
            self.setNum(
                self.d[3], self.d[1], self.d[0], self.d[5], self.d[4], self.d[2]
            )
        elif direction == "N":
            self.setNum(
                self.d[1], self.d[5], self.d[2], self.d[3], self.d[0], self.d[4]
            )
        elif direction == "S":
            self.setNum(
                self.d[4], self.d[0], self.d[2], self.d[3], self.d[5], self.d[1]
            )
        elif direction == "W":
            self.setNum(
                self.d[2], self.d[1], self.d[5], self.d[0], self.d[4], self.d[3]
            )

n = int(input())
dices = [Dice(list(map(int, input().split()))) for i in range(n)]

flag = False
for i in range(n - 1):
    for j in range(i + 1, n):
        for k in list("NNNNWNNNWNNNENNNENNNWNNN"):
            dices[i].roll(k)
            if dices[i].d == dices[j].d:
                flag = True
if flag:
    print("No")
else:
    print("Yes")



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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ar array

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;

const int mod = 1e9 + 7;

int f[305][305][305], N, M;
vector<ii> v[305];

signed main(void)
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #ifdef LOCAL
    freopen("A.INP", "r", stdin);
    freopen("A.OUT", "w", stdout);
  #endif // LOCAL
  cin >> N >> M;
  while(M--){
    int l, r, x; cin >> l >> r >> x;
    v[r].eb(l, x);
  }
  auto add = [&](int & x, int y)
  {
    x += y;
    if(x >= mod) x -= mod;
  };
  f[1][0][0] = 1;
  for(int i = 1; i <= N; ++i){
    for(int j = 0; j < i; ++j){
      for(int k = 0; k < max(1, j); ++k){
        for(auto p : v[i]){
          if(p.se == 1 && p.fi <= j) f[i][j][k] = 0;
          if(p.se == 2 && (p.fi <= k || p.fi > j)) f[i][j][k] = 0;
          if(p.se == 3 && p.fi > k) f[i][j][k] = 0;
        }
      }
    }
    for(int j = 0; j < i; ++j){
      for(int k = 0; k < max(1, j); ++k){
        add(f[i + 1][j][k], f[i][j][k]);
        add(f[i + 1][i][k], f[i][j][k]);
        add(f[i + 1][i][j], f[i][j][k]);
      }
    }
  }
  int res = 0;
  for(int j = 0; j < N; ++j){
    for(int k = 0; k < max(1, j); ++k)
      add(res, f[N][j][k]);
  }
  #ifdef LOCAL
  for(int i = 1; i <= N; ++i){
    cerr << i << '\n';
    for(int j = 0; j < i; ++j){
      for(int k = 0; k < max(1, j); ++k){
        cerr << f[i][j][k] << " ";
      }
      cerr << '\n';
    }
    cerr << '\n';
  }
  #endif // LOCAl
  res = 3ll * res % mod;
  cout << res;
}


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

S = input()
N = len(S)

cnt_0 = 0
cnt_1 = 0
for i in range(N):
    if S[i] == '0':
        cnt_0 += 1
    else:
        cnt_1 += 1

ans = N - abs(cnt_0 - cnt_1)
print(ans)

Measured memory_bytes: 3188
s=input()
gou=0
if s[0]=="R" or s[1]=="R" or s[2]=="R":
  gou=1
if s[0]=="R" and s[1]=="R":
  gou=2
if s[1]=="R" and s[2]=="R":
  gou=2
if s[1]=="R" and s[2]=="R" and s[0]=="R":
  gou=3
print(gou)

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

typedef long long ll;
typedef long double ld;
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353
#define Graph vector<vector<int>>

int main() {
    int N; cin >> N;
    string S; cin >> S;
    vector<int> W(N), E(N);
    int ans = inf, recW = 0, recE = 0;
    for (int i = 0; i < N; i++) {
        if (S.at(i) == 'W') {
            W.at(i) += 1 + recW;
            recW = W.at(i);
            E.at(i) = recE;
        }
        else {
            E.at(i) += 1 + recE;
            recE = E.at(i);
            W.at(i) = recW;
        }
    }
    for (int i = 0; i < N; i++) {
        if (S.at(i) == 'W') {
            ans = min(ans, W.at(i) - 1 + E.at(N - 1) - E.at(i));
        }
        else {
            ans = min(ans, W.at(i) + E.at(N - 1) - E.at(i));
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3076
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<string>
#include<math.h>

using namespace std;

int main(){
    string N;
	cin>>N;
    int cnt = 0;
    for(int i=0;i<N.size();i++){
        if(N[i] == '2'){
            cnt++;
        }
    }

    cout<<cnt<<endl;
	
	
}


Measured memory_bytes: 256
import math
x = int(input())
for b in range(-10000, 10000):
    p = b**5 + x
    if p < 0:
        a = int(math.floor(-((-p)**0.2)))
    else:
        a = int(math.floor(p**0.2))
    if (a-1)**5 == p:
        print(a-1, b)
        break
    elif a**5 == p:
        print(a,b)
        break
    elif (a+1)**5 == p:
        print(a+1, b)
        break

Measured memory_bytes: 68788
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <iostream>
#include <vector>
#include <list>
#include <map>
#include<string>
#include <algorithm>
#include <functional>
#include <cmath>
using namespace std;
typedef vector <int> ivector;

int main(){
	
	int arr[10];
	for (int i = 0; i <10; i++){
		cin >> arr[i];
	}
	sort(arr, arr + 10,greater<int>());
	for (int i = 0; i < 3; i++){
		cout << arr[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

//find_by_order gives kth-largest element
//order_of_key gives the number of items in the set that are strictly smaller!!

// OT.find_by_order(k-1)
// 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define db4(x, y, z, w) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << "," << #w << "=" << w << endl
#define ll long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define X first
#define Y second
#define sz(x) (int)((x).size())
#define pii pair<int,int>
#define MOD (ll)(998244353)
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
typedef vector<int> vi;
#define inf (ll)(1e18)
#define double long double
#define int long long

//////////////////////
// const int N = 316330;


int32_t main() {

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

    int n,k;
    string st;
    cin >> n >> st >> k;
    k--;
    rep(i,sz(st)) {
        if(st[i] != st[k])
            st[i] = '*';
    }
    cout << st << '\n';
}

Measured memory_bytes: 256
/**
 *   
 *   Date: 01 September 2019
 *   Time: 18:01:37
**/
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <vector>
#include <cmath>
#include <cstring>
#include<queue>
#include<stack>
#include<climits>
#include<iomanip>
#define endl "\n"
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pi;
typedef vector<ll> vec;
typedef vector<vector<ll> > matrix;
ll const mod=1000000007;

int main(){
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	ll n,d;
	cin>>n;
	d=n*(n-1)/2;
	cout<<d<<endl;

return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define inf 10000000000000007
#define eps 1e-13
#define PI 3.14159265359
#define sp printf(" ")
#define vi vector<int>
#define vl vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pcc pair<char, char>
#define mp make_pair
#define FF first
#define SS second
#define pb(x) push_back(x)
#define sd(x) scanf("%d", &(x))
#define pd(x) printf("%d", (x))
#define pdn(x) printf("%d\n", (x))
#define sld(x) scanf("%ld", &(x))
#define pld(x) printf("%ld", (x))
#define pldn(x) printf("%ld\n", (x))
#define slf(x) scanf("%lf", &(x))
#define plf(x) printf("%.9lf", (x))
#define plfn(x) printf("%.9lf\n", (x))
#define sch(x) scanf("%c", &(x))
#define pch(x) printf("%c", (x))
#define pchn(x) printf("%c\n", (x))
#define gtl(x) getline(cin, (x))
#define flsh fflush(stdout)
#define ios ios::sync_with_stdio(false); cin.tie(0) ; cout.tie(0)
#define endl '\n'
using namespace std;
int a[2003][2004],dp[2004][2004],v[2004][2004],z[2003][2004],z2[2003][2004];
int main()
{
    int n,m,q;
    cin>>n>>m>>q;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++){char c;cin>>c;a[i][j]=c-'0';}
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {

            dp[i][j]=dp[i-1][j]+dp[i][j-1]-dp[i-1][j-1];
          //  cout<<dp[i-1][j]<<" "<<dp[i][j-1]<<" "<<dp[i-1][j-1]<<" GGGGGGG "<<i<<" "<<j<<endl;
            v[i][j]=v[i-1][j]+v[i][j-1]-v[i-1][j-1];
            if(a[i][j]==1)
            {
                v[i][j]++;
                if(a[i-1][j]==1)dp[i][j]++;
                if(a[i][j-1]==1)dp[i][j]++;
            }
            z2[i][j]=z2[i][j-1];
            if(a[i][j]==1&&a[i][j-1]==1)z2[i][j]++;
            //cout<<dp[i][j]<<" "<<v[i][j]<<" "<<i<<" "<<j<<endl;
        }
    }
    for(int j=1;j<=m;j++)
    {
        for(int i=1;i<=n;i++)
        {
            z[j][i]=z[j][i-1];
            if(a[i][j]==1&&a[i-1][j]==1)z[j][i]++;
        }
    }
    for(int i=1;i<=q;i++)
    {
        int x1,y1,x2,y2;
        cin>>x1>>y1>>x2>>y2;
        if(x1>x2)swap(x1,x2);
        if(y1>y2)swap(y1,y2);
        int p=dp[x2][y2]-dp[x2][y1]-dp[x1][y2]+dp[x1][y1];
        p+=z[y1][x2]-z[y1][x1]+z2[x1][y2]-z2[x1][y1];
        int r=v[x2][y2]-v[x2][y1-1]-v[x1-1][y2]+v[x1-1][y1-1];
        cout<<r-p<<endl;


    }



}




Measured memory_bytes: 80256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll a,b;
    cin>>a>>b;
    if(a<=8 && b<=8)
    {
        printf("Yay!\n");
    }
    else 
    {
        printf(":(\n");
    }

}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
	uint64_t n, ans = 0, tmp = 0;
	cin >> n;

	for (uint64_t i = 1; i < (tmp = n / i - 1); ++i)
	{
		if ((n - i) % i)
			continue;
		ans += tmp;
	}
	
	cout << ans << "\n";

	return 0;
}

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

using namespace std;
typedef long long ll;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define endl '\n'
#define MOD 1000000007
void findNumberOfDigits(long n, int base)
{
    int dig = (int)(floor( log(n) /
                         log(base)) + 1);

    cout << dig << endl;
}
int main()
{ FAST
    int n; cin >> n;
    int arr[n];
    ll ans = 100000000000;
    for(int i = 0; i < n; i++){
        cin >> arr[i];
    }
    for(int i = 1; i <= 100; i++){
        ll sum = 0;
        for(int j = 0; j < n; j++){
            int stam = (i - arr[j]) * (i - arr[j]);
            sum += stam;
        }
        ans = min(ans, sum);
    }
    cout  << ans << endl;
    return 0;
}


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

int main(){
  string S;
  cin >> S;
  // switch(S){
  //   case "SUN":
  //     cout << 7 << endl;
  //     break;
  //   case "MON":
  //     cout << 6 << endl;
  //     break;
  //   case "TUE":
  //     cout << 5 << endl;
  //     break;
  //   case "WED":
  //     cout << 4 << endl;
  //     break;
  //   case "THU":
  //     cout << 3 << endl;
  //     break;
  //   case "FRI":
  //     cout << 2 << endl;
  //     break;
  //   case "SAT":
  //     cout << 1 << endl;
  //     break;
  // }
  if(S=="SUN"){
    cout << 7 << endl;
  }else if(S=="MON"){
    cout << 6 << endl;
  }else if(S=="TUE"){
    cout << 5 << endl;
  }else if(S=="WED"){
    cout << 4 << endl;
  }else if(S=="THU"){
    cout << 3 << endl;
  }else if(S=="FRI"){
    cout << 2 << endl;
  }else if (S=="SAT"){
    cout << 1 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <string>
#include <vector>

using namespace std;

int main ()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    while (0 < a || 0 < c) {
        c -= b;
        if (c <= 0)
            break;
        a -= d;
    }
    if (0 < a)
        cout << "Yes";
    else
        cout << "No";
}


Measured memory_bytes: 3596
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <cassert>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'
#define FIR first
#define SEC second
#define PB push_back
#define SZ(x) ((int)x.size())

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

template<class U, class V>
ostream& operator <<(ostream& out, pair<U, V>& p) {
    return out << p.first << " " << p.second;
}

template<class T>
ostream& operator <<(ostream& out, vector<T> vec) {
    for (T& e : vec)
        out << e << " ";
    return out << endl;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

const lint LIM = 1000000000000000000LL;

void solveSingleCase(int caseNo)
{
    int N;
    cin >> N;
    lint ret = 1;
    VEC(lint) A(N);
    READVEC(A);
    FOR(i, 0, N)
        if (A[i] == 0) {
            cout << 0 << endl;
            return;
        }

    for (lint a : A) {
        if (a > LIM / ret)
        {
            ret = -1;
            break;
        }
        ret *= a;
    }

    cout << ret << endl;
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int T = 1;
    // cin >> T;
    FOR(tcase, 1, T + 1) {
        solveSingleCase(tcase);
    }
    return 0;
};


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

using namespace std;

int main(void) {
    vector <int> e(3);
    for (int i = 0; i < 3; i++) {
        cin >> e[i];
    }

    sort(e.begin(), e.end());

    cout << e[0] * e[1] / 2 << endl;
}

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

const long double PI = acos(-1);
constexpr long double EPS = 1e-15;
constexpr int inf = 2e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;

//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

int n, m, a[112345];

int main(){
    cin >> n;
    --n;
    int prev;
    cin >> prev;
    REP(i, n){
      int tmp;
      cin >> tmp;
      if(prev == tmp){
        ++m;
      }else{
        ++a[m];
      }
      prev = tmp;
    }
    /*
    cout << m << endl;
    REP(i, m){
      cout << a[i] << " ";
    }
    */
    int ans = 0;
    REP(i, m + 1) ans = max(ans, a[i] + 1);
    REP(i, m) ans = max(ans, a[i] + a[i + 1] + 2);
    REP(i, m - 1) ans = max(ans, a[i] + a[i + 1] + a[i + 2] + 3);
    cout << ans << endl;
}



Measured memory_bytes: 3304
N = int(input())
if N%10 == 2 or  N%10 == 4 or N%10 == 5 or N%10 == 7 or N%10 == 9 :
    print('hon')
elif N%10 == 0 or N%10 == 1 or N%10 == 6 or N%10 == 8:
    print('pon')
else :
    print('bon')

Measured memory_bytes: 9188
class Heap

  attr_accessor(:data, :size)

  def initialize()
    @data = []
    @size = 0
  end

  def data()
    @data
  end

  def push(x)
    @data[@size] = x
    i = @size
    j = ((i + 1) / 2 ) - 1
    issorted = false
    while j >= 0 && !issorted
      if @data[i] > @data[j]
        @data[i], @data[j] = @data[j], @data[i]
        i = j
        j = ((i + 1) / 2 ) - 1
      else
        issorted = true
      end
    end
    @size += 1
  end

  def pop()
    if @size == 0
      nil
    else
      re = @data[0]
      @size -= 1
      @data[0] = @data[size]
      i = 0
      j1 = (i+1) * 2 - 1
      j2 = (i+1) * 2
      issorted = false
      while size > j1 && !issorted
        if size > j2
          max_i = @data[j1] > @data[j2] ? j1 : j2
          if @data[i] >= @data[max_i]
            issorted = true
          else
            @data[i], @data[max_i] = @data[max_i], @data[i]
            i = max_i
            j1 = (i+1) * 2 - 1
            j2 = (i+1) * 2
          end
        else
          if @data[i] >= @data[j1]
            issorted = true
          else
            @data[i], @data[j1] = @data[j1], @data[i]
            i = j1
            issorted = true
          end
        end
      end
      re
    end
  end

end

def connect(a,b)
  list = []
  while !a.empty? && !b.empty?
    if a[0] > b[0]
      list.push(a[0])
      a.shift
    else
      list.push(b[0])
      b.shift
    end
  end
  if a.empty?
    list = list + b
  else
    list = list + a
  end
  list
end

n,m = gets.chomp.split(" ").map(&:to_i)

works = Array.new(10**5+1).map{Array.new}
n.times do |i|
  a,b = gets.chomp.split(" ").map(&:to_i)
  works[a].push(b)
end

ans = 0
heap = Heap.new
for i in 1..m
  works[i].each do |x|
    heap.push(x)
  end

  highest = heap.pop()
  if highest != nil
    ans += highest
  end
end
puts ans

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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	if (n % 2 == 0)cout << n << endl;
	else cout << 2 * n << endl;
}

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

#define rep(i,a,b)                for(ll i=a;i<b;i++)
#define re(i,b)                for(ll i=0;i<b;i++)
#define repr(i,n)                for(ll i=n-1;i>=0;i--)
#define ll long long
#define ld long double
#define pll std::pair<ll, ll> 
#define ppll std::pair<pll, ll>
#define vll std::vector<ll> 
#define vpll std::vector<pll> 
#define vppll std::vector<ppll> 
#define mll std::unordered_map<ll, ll> 
#define mpll std::unordered_map<pll, ll>
#define mppll std::unordered_map<ppll, ll>
#define sll std::set<ll>
#define ff first
#define ss second
#define msll std::multiset<ll>
#define all(c) c.begin(), c.end()
#define allr(c) c.rbegin(), c.rend()
#define srt(x) sort(all(x))
#define rsrt(x) sort(allr(x))
#define eb emplace_back
#define pb push_back
#define s(yy) ll yy;cin>>yy
#define len length()
#define sz size()
const ll mod = 1e9 + 7;
const ll INF = 0x7FFFFFFFFFFFFFFF>>1;

/*#################################################### 
#                                                    #
#                     @author                        #
#                  Parth Lathiya                     #
#      https://www.cse.iitb.ac.in/~parthiitb/        #
#                                                    #
####################################################*/


int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    #ifdef PARTH_LATHIYA_HOME

        freopen("C_in.txt","r",stdin);
    
        ll ttt,bkkk;
        cin>>ttt;
        bkkk=ttt;
        while(ttt--) {
            cout<<"Testcase - "<<bkkk-ttt<<"\n";
    #endif

//--------------------------------------------------------------------------------------

    s(n);
    ll a[n+2];
    a[0]=0;
    a[n+1]=0;
    rep(i,1,n+1) 
        cin>>a[i];
    ll ans=0;
    rep(i,1,n+2)
        ans+=abs(a[i]-a[i-1]);
    // cout<<ans-abs(0-a[0])-abs(a[1]-a[0])+abs(a[1])<<"\n";
    rep(i,1,n+1)
        cout<<ans-abs(a[i-1]-a[i])-abs(a[i]-a[i+1])+abs(a[i-1]-a[i+1])<<"\n";



//--------------------------------------------------------------------------------------
    
    #ifdef PARTH_LATHIYA_HOME
        cout<<"\n"; }
    #endif

    return 0;
}

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

#define loop(i,a,b) for(int i=a; i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)
typedef long long ll;

int K;

void input(int x[]){
    string s;
    rep(i, K){
        cin >> s;
        if(s == "kougekida") x[i] = 0;
        else if(s == "mamoru") x[i] = 1;
        else if(s == "tameru") x[i] = 2;
    }
}

int main(){
    int win = 0;
    int isop = 0, nakap = 0, isono[105], nakajima[105];
    cin >> K;

    input(isono);
    input(nakajima);

    rep(i, K){
        if(isono[i] == 0 && nakajima[i] == 0){
            if(isop > nakap){
                win = 1;
                break;
            }else if(nakap > isop){
                win = 2;
                break;
            }else if(nakap == isop){
                ;
            }
            isop = 0; nakap = 0;
        }else if(isono[i] == 0 && nakajima[i] == 1){
            if(isop == 5){
                win = 1;
                break;
            }else if(isop == 0){
                win = 2;
                break;
            }
            isop = 0;
        }else if(isono[i] == 0 && nakajima[i] == 2){
            if(isop == 0){
                win = 2;
            }else{
                win = 1;
            }
            break;
        }else if(isono[i] == 1 && nakajima[i] == 0){
            if(nakap == 5){
                win = 2;
                break;
            }else if(nakap == 0){
                win = 1;
                break;
            }
            nakap = 0;
        }else if(isono[i] == 1 && nakajima[i] == 1){
            ;
        }else if(isono[i] == 1 && nakajima[i] == 2){
            if(nakap < 5) nakap++;
        }else if(isono[i] == 2 && nakajima[i] == 0){
            if(nakap == 0){
                win = 1;
            }else{
                win = 2;
            }
            break;
        }else if(isono[i] == 2 && nakajima[i] == 1){
            if(isop < 5) isop++;
        }else if(isono[i] == 2 && nakajima[i] == 2){
            if(isop < 5) isop++;
            if(nakap < 5) nakap++;
        }
    }
    if(win == 0) cout << "Hikiwake-kun" << endl;
    else if(win == 1) cout << "Isono-kun" << endl;
    else cout << "Nakajima-kun" << endl;
}

Measured memory_bytes: 1208